Go to the documentation of this file.
53 for (
i = 0;
i <
ctx->nb_filter_buffers;
i++) {
54 if (
ctx->filter_buffers[
i] != VA_INVALID_ID) {
55 vaDestroyBuffer(
ctx->hwctx->display,
ctx->filter_buffers[
i]);
56 ctx->filter_buffers[
i] = VA_INVALID_ID;
59 ctx->nb_filter_buffers = 0;
61 if (
ctx->va_context != VA_INVALID_ID) {
62 vaDestroyContext(
ctx->hwctx->display,
ctx->va_context);
63 ctx->va_context = VA_INVALID_ID;
66 if (
ctx->va_config != VA_INVALID_ID) {
67 vaDestroyConfig(
ctx->hwctx->display,
ctx->va_config);
68 ctx->va_config = VA_INVALID_ID;
80 if (
ctx->pipeline_uninit)
81 ctx->pipeline_uninit(avctx);
83 if (!
inlink->hw_frames_ctx) {
85 "required to associate the processing device.\n");
90 if (!
ctx->input_frames_ref) {
112 if (
ctx->pipeline_uninit)
113 ctx->pipeline_uninit(avctx);
115 if (!
ctx->output_width)
117 if (!
ctx->output_height)
120 outlink->
w =
ctx->output_width;
121 outlink->
h =
ctx->output_height;
123 if (
ctx->passthrough) {
124 if (
inlink->hw_frames_ctx)
133 if (!
ctx->device_ref) {
141 vas = vaCreateConfig(
ctx->hwctx->display, VAProfileNone,
142 VAEntrypointVideoProc,
NULL, 0, &
ctx->va_config);
143 if (vas != VA_STATUS_SUCCESS) {
145 "config: %d (%s).\n", vas, vaErrorStr(vas));
165 ctx->output_format =
ctx->input_frames->sw_format;
184 "size %dx%d (constraints: width %d-%d height %d-%d).\n",
185 ctx->output_width,
ctx->output_height,
204 output_frames->
width =
ctx->output_width;
205 output_frames->
height =
ctx->output_height;
219 "context for output: %d\n", err);
223 va_frames = output_frames->
hwctx;
228 vas = vaCreateContext(
ctx->hwctx->display,
ctx->va_config,
229 ctx->output_width,
ctx->output_height,
233 if (vas != VA_STATUS_SUCCESS) {
235 "context: %d (%s).\n", vas, vaErrorStr(vas));
239 if (
ctx->build_filter_params) {
240 err =
ctx->build_filter_params(avctx);
271 { VAProcColorStandardBT601, 5, 6, 5 },
272 { VAProcColorStandardBT601, 6, 6, 6 },
273 { VAProcColorStandardBT709, 1, 1, 1 },
274 { VAProcColorStandardBT470M, 4, 4, 4 },
275 { VAProcColorStandardBT470BG, 5, 5, 5 },
276 { VAProcColorStandardSMPTE170M, 6, 6, 6 },
277 { VAProcColorStandardSMPTE240M, 7, 7, 7 },
278 { VAProcColorStandardGenericFilm, 8, 1, 1 },
279 #if VA_CHECK_VERSION(1, 1, 0)
280 { VAProcColorStandardSRGB, 1, 13, 0 },
281 { VAProcColorStandardXVYCC601, 1, 11, 5 },
282 { VAProcColorStandardXVYCC709, 1, 11, 1 },
283 { VAProcColorStandardBT2020, 9, 14, 9 },
288 VAProcColorStandardType *vacs,
292 int i, j, score, best_score, worst_score;
293 VAProcColorStandardType best_standard;
295 #if VA_CHECK_VERSION(1, 3, 0)
300 for (
i = 0;
i < nb_vacs;
i++) {
301 if (vacs[
i] == VAProcColorStandardExplicit) {
313 best_standard = VAProcColorStandardNone;
320 if (worst_score == 0) {
327 for (
i = 0;
i < nb_vacs;
i++) {
343 if (score < worst_score &&
344 (best_score == -1 || score < best_score)) {
355 #if VA_CHECK_VERSION(1, 1, 0)
356 static const struct {
362 VA_CHROMA_SITING_HORIZONTAL_LEFT },
364 VA_CHROMA_SITING_HORIZONTAL_CENTER },
366 VA_CHROMA_SITING_HORIZONTAL_LEFT },
368 VA_CHROMA_SITING_HORIZONTAL_CENTER },
370 VA_CHROMA_SITING_HORIZONTAL_LEFT },
372 VA_CHROMA_SITING_HORIZONTAL_CENTER },
390 #if VA_CHECK_VERSION(1, 1, 0)
409 VAProcColorStandardType *vacs,
417 "to VA standard %d chroma siting %#x range %#x.\n",
432 frame->hw_frames_ctx);
440 VAProcPipelineParameterBuffer *params,
446 VAProcPipelineCaps caps;
449 vas = vaQueryVideoProcPipelineCaps(
ctx->hwctx->display,
ctx->va_context,
450 ctx->filter_buffers,
ctx->nb_filter_buffers,
452 if (vas != VA_STATUS_SUCCESS) {
454 "colour standard support: %d (%s).\n", vas, vaErrorStr(vas));
468 caps.input_color_standards,
469 caps.num_input_color_standards);
477 .chroma_sample_location =
output_frame->chroma_location,
480 caps.output_color_standards,
481 caps.num_output_color_standards);
485 #if VA_CHECK_VERSION(1, 3, 0)
499 if (output_standard) {
510 #if VA_CHECK_VERSION(1, 1, 0)
511 params->input_color_properties = (VAProcColorProperties) {
514 #if VA_CHECK_VERSION(1, 3, 0)
516 .transfer_characteristics = input_props.
color_trc,
517 .matrix_coefficients = input_props.
colorspace,
520 params->output_color_properties = (VAProcColorProperties) {
523 #if VA_CHECK_VERSION(1, 3, 0)
525 .transfer_characteristics = output_props.
color_trc,
526 .matrix_coefficients = output_props.
colorspace,
535 VAProcPipelineParameterBuffer *params,
542 ctx->input_region = (VARectangle) {
545 .width = input_frame->
width -
555 *params = (VAProcPipelineParameterBuffer) {
557 .surface_region = &
ctx->input_region,
558 .output_region =
NULL,
561 .filter_flags = VA_FRAME_PICTURE,
565 #if VA_CHECK_VERSION(1, 1, 0)
566 .rotation_state = VA_ROTATION_NONE,
567 .mirror_state = VA_MIRROR_NONE,
595 vas = vaCreateBuffer(
ctx->hwctx->display,
ctx->va_context,
597 if (vas != VA_STATUS_SUCCESS) {
599 "buffer (type %d): %d (%s).\n",
600 type, vas, vaErrorStr(vas));
612 VAProcPipelineParameterBuffer *params,
613 VABufferID *params_id)
618 vas = vaCreateBuffer(
ctx->hwctx->display,
ctx->va_context,
619 VAProcPipelineParameterBufferType,
620 sizeof(*params), 1, params, params_id);
621 if (vas != VA_STATUS_SUCCESS) {
623 "%d (%s).\n", vas, vaErrorStr(vas));
624 *params_id = VA_INVALID_ID;
630 vas = vaRenderPicture(
ctx->hwctx->display,
ctx->va_context, params_id, 1);
631 if (vas != VA_STATUS_SUCCESS) {
633 "%d (%s).\n", vas, vaErrorStr(vas));
641 VAProcPipelineParameterBuffer *params_list,
646 VABufferID *params_ids;
654 for (
int i = 0;
i < cout;
i++)
655 params_ids[
i] = VA_INVALID_ID;
657 vas = vaBeginPicture(
ctx->hwctx->display,
659 if (vas != VA_STATUS_SUCCESS) {
661 "%d (%s).\n", vas, vaErrorStr(vas));
666 for (
int i = 0;
i < cout;
i++) {
669 goto fail_after_begin;
672 vas = vaEndPicture(
ctx->hwctx->display,
ctx->va_context);
673 if (vas != VA_STATUS_SUCCESS) {
675 "%d (%s).\n", vas, vaErrorStr(vas));
677 goto fail_after_render;
680 if (CONFIG_VAAPI_1 ||
ctx->hwctx->driver_quirks &
682 for (
int i = 0;
i < cout && params_ids[
i] != VA_INVALID_ID;
i++) {
683 vas = vaDestroyBuffer(
ctx->hwctx->display, params_ids[
i]);
684 if (vas != VA_STATUS_SUCCESS) {
686 "%d (%s).\n", vas, vaErrorStr(vas));
700 vaRenderPicture(
ctx->hwctx->display,
ctx->va_context, ¶ms_ids[0], 1);
702 vaEndPicture(
ctx->hwctx->display,
ctx->va_context);
709 VAProcPipelineParameterBuffer *params,
720 ctx->va_config = VA_INVALID_ID;
721 ctx->va_context = VA_INVALID_ID;
724 for (
i = 0;
i < VAProcFilterCount;
i++)
725 ctx->filter_buffers[
i] = VA_INVALID_ID;
726 ctx->nb_filter_buffers = 0;
732 if (
ctx->valid_ids &&
ctx->pipeline_uninit)
733 ctx->pipeline_uninit(avctx);
enum AVColorTransferCharacteristic color_trc
void ff_vaapi_vpp_pipeline_uninit(AVFilterContext *avctx)
void ff_vaapi_vpp_ctx_init(AVFilterContext *avctx)
static int vaapi_vpp_frame_is_rgb(const AVFrame *frame)
static VASurfaceID ff_vaapi_vpp_get_surface_id(const AVFrame *frame)
enum AVColorRange color_range
MPEG vs JPEG YUV range.
AVPixelFormat
Pixel format.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
VAAPI hardware pipeline configuration details.
AVColorTransferCharacteristic
Color Transfer Characteristic.
int ff_vaapi_vpp_render_picture(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, AVFrame *output_frame)
void * av_hwdevice_hwconfig_alloc(AVBufferRef *ref)
Allocate a HW-specific configuration structure for a given HW device.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
uint8_t * data
The data buffer.
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
enum AVColorPrimaries color_primaries
enum AVColorSpace colorspace
YUV colorspace type.
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
This structure describes decoded (raw) audio or video data.
@ AVCOL_RANGE_JPEG
Full range content.
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
int ff_vaapi_vpp_render_pictures(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params_list, int cout, AVFrame *output_frame)
#define AV_LOG_VERBOSE
Detailed information.
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
AVColorPrimaries
Chromaticity coordinates of the source primaries.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
int width
The allocated dimensions of the frames in this pool.
AVHWFramesConstraints * av_hwdevice_get_hwframe_constraints(AVBufferRef *ref, const void *hwconfig)
Get the constraints on HW frames given a device and the HW-specific configuration to be used with tha...
A link between two filters.
AVFilterFormatsConfig outcfg
Lists of supported formats / etc.
const char * av_chroma_location_name(enum AVChromaLocation location)
enum AVColorPrimaries color_primaries
This struct describes the constraints on hardware frames attached to a given device with a hardware-s...
VAConfigID config_id
ID of a VAAPI pipeline configuration.
enum AVChromaLocation chroma_location
VASurfaceID * surface_ids
The surfaces IDs of all surfaces in the pool after creation.
const char * av_color_space_name(enum AVColorSpace space)
void * priv
private data for use by the filter
int min_width
The minimum size of frames in this hw_frames_ctx.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
enum AVPixelFormat * valid_sw_formats
A list of possible values for sw_format in the hw_frames_ctx, terminated by AV_PIX_FMT_NONE.
void av_hwframe_constraints_free(AVHWFramesConstraints **constraints)
Free an AVHWFrameConstraints structure.
enum AVColorSpace colorspace
enum AVColorRange color_range
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static enum AVPixelFormat pix_fmts[]
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int ff_vaapi_vpp_make_param_buffers(AVFilterContext *avctx, int type, const void *data, size_t size, int count)
static void vaapi_vpp_fill_chroma_sample_location(VAAPIColourProperties *props)
const char * av_color_range_name(enum AVColorRange range)
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
@ AVCHROMA_LOC_LEFT
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
static int vaapi_vpp_colour_properties(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, const AVFrame *input_frame, AVFrame *output_frame)
@ AVCHROMA_LOC_TOPLEFT
ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2.
AVFilterLink ** inputs
array of pointers to input links
const char * av_color_primaries_name(enum AVColorPrimaries primaries)
int ff_vaapi_vpp_config_input(AVFilterLink *inlink)
static const VAAPIColourProperties vaapi_colour_standard_map[]
void ff_vaapi_vpp_ctx_uninit(AVFilterContext *avctx)
@ AVCOL_RANGE_UNSPECIFIED
int ff_vaapi_vpp_query_formats(AVFilterContext *avctx)
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
@ AVCHROMA_LOC_UNSPECIFIED
AVFilterContext * src
source filter
AVFilterFormatsConfig incfg
Lists of supported formats / etc.
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
#define AVERROR_EXTERNAL
Generic error in an external library.
int max_width
The maximum size of frames in this hw_frames_ctx.
@ AV_PIX_FMT_VAAPI
Hardware acceleration through VA-API, data[3] contains a VASurfaceID.
AVChromaLocation
Location of chroma samples.
#define i(width, name, range_min, range_max)
int w
agreed upon image width
#define av_malloc_array(a, b)
AVColorSpace
YUV colorspace type.
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
This struct describes a set or pool of "hardware" frames (i.e.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
static void vaapi_vpp_fill_colour_range(VAAPIColourProperties *props)
static void vaapi_vpp_fill_colour_properties(AVFilterContext *avctx, VAAPIColourProperties *props, VAProcColorStandardType *vacs, int nb_vacs)
int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
int h
agreed upon image height
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
@ AVCHROMA_LOC_CENTER
MPEG-1 4:2:0, JPEG 4:2:0, H.263 4:2:0.
VAProcColorStandardType va_color_standard
uint8_t va_chroma_sample_location
enum AVChromaLocation chroma_sample_location
static void vaapi_vpp_fill_colour_standard(VAAPIColourProperties *props, VAProcColorStandardType *vacs, int nb_vacs)
int initial_pool_size
Initial size of the frame pool.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
VAAPI-specific data associated with a frame pool.
static int vaapi_vpp_render_single_pipeline_buffer(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, VABufferID *params_id)
@ AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS
The driver does not destroy parameter buffers when they are used by vaRenderPicture().
enum AVColorTransferCharacteristic color_trc
#define VAAPI_VPP_BACKGROUND_BLACK
AVColorRange
Visual content value range.
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
@ AVCHROMA_LOC_BOTTOMLEFT
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link, int default_pool_size)
Perform any additional setup required for hardware frames.
int ff_vaapi_vpp_init_params(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, const AVFrame *input_frame, AVFrame *output_frame)
AVFilterLink ** outputs
array of pointers to output links