Go to the documentation of this file.
   54     for (
i = 0; 
i < 
ctx->nb_filter_buffers; 
i++) {
 
   55         if (
ctx->filter_buffers[
i] != VA_INVALID_ID) {
 
   56             vaDestroyBuffer(
ctx->hwctx->display, 
ctx->filter_buffers[
i]);
 
   57             ctx->filter_buffers[
i] = VA_INVALID_ID;
 
   60     ctx->nb_filter_buffers = 0;
 
   62     if (
ctx->va_context != VA_INVALID_ID) {
 
   63         vaDestroyContext(
ctx->hwctx->display, 
ctx->va_context);
 
   64         ctx->va_context = VA_INVALID_ID;
 
   67     if (
ctx->va_config != VA_INVALID_ID) {
 
   68         vaDestroyConfig(
ctx->hwctx->display, 
ctx->va_config);
 
   69         ctx->va_config = VA_INVALID_ID;
 
   82     if (
ctx->pipeline_uninit)
 
   83         ctx->pipeline_uninit(avctx);
 
   87                "required to associate the processing device.\n");
 
   92     if (!
ctx->input_frames_ref) {
 
  116     if (
ctx->pipeline_uninit)
 
  117         ctx->pipeline_uninit(avctx);
 
  119     if (!
ctx->output_width)
 
  121     if (!
ctx->output_height)
 
  124     outlink->
w = 
ctx->output_width;
 
  125     outlink->
h = 
ctx->output_height;
 
  127     if (
ctx->passthrough) {
 
  137     if (!
ctx->device_ref) {
 
  145     vas = vaCreateConfig(
ctx->hwctx->display, VAProfileNone,
 
  146                          VAEntrypointVideoProc, 
NULL, 0, &
ctx->va_config);
 
  147     if (vas != VA_STATUS_SUCCESS) {
 
  149                "config: %d (%s).\n", vas, vaErrorStr(vas));
 
  169         ctx->output_format = 
ctx->input_frames->sw_format;
 
  188                "size %dx%d (constraints: width %d-%d height %d-%d).\n",
 
  189                ctx->output_width, 
ctx->output_height,
 
  208     output_frames->
width     = 
ctx->output_width;
 
  209     output_frames->
height    = 
ctx->output_height;
 
  223                "context for output: %d\n", err);
 
  227     va_frames = output_frames->
hwctx;
 
  232     vas = vaCreateContext(
ctx->hwctx->display, 
ctx->va_config,
 
  233                           ctx->output_width, 
ctx->output_height,
 
  237     if (vas != VA_STATUS_SUCCESS) {
 
  239                "context: %d (%s).\n", vas, vaErrorStr(vas));
 
  243     if (
ctx->build_filter_params) {
 
  244         err = 
ctx->build_filter_params(avctx);
 
  275     { VAProcColorStandardBT601,       5,  6,  5 },
 
  276     { VAProcColorStandardBT601,       6,  6,  6 },
 
  277     { VAProcColorStandardBT709,       1,  1,  1 },
 
  278     { VAProcColorStandardBT470M,      4,  4,  4 },
 
  279     { VAProcColorStandardBT470BG,     5,  5,  5 },
 
  280     { VAProcColorStandardSMPTE170M,   6,  6,  6 },
 
  281     { VAProcColorStandardSMPTE240M,   7,  7,  7 },
 
  282     { VAProcColorStandardGenericFilm, 8,  1,  1 },
 
  283 #if VA_CHECK_VERSION(1, 1, 0) 
  284     { VAProcColorStandardSRGB,        1, 13,  0 },
 
  285     { VAProcColorStandardXVYCC601,    1, 11,  5 },
 
  286     { VAProcColorStandardXVYCC709,    1, 11,  1 },
 
  287     { VAProcColorStandardBT2020,      9, 14,  9 },
 
  292                                            VAProcColorStandardType *vacs,
 
  296     int i, j, score, best_score, worst_score;
 
  297     VAProcColorStandardType best_standard;
 
  299 #if VA_CHECK_VERSION(1, 3, 0) 
  304     for (
i = 0; 
i < nb_vacs; 
i++) {
 
  305         if (vacs[
i] == VAProcColorStandardExplicit) {
 
  317     best_standard = VAProcColorStandardNone;
 
  324     if (worst_score == 0) {
 
  331     for (
i = 0; 
i < nb_vacs; 
i++) {
 
  347             if (score < worst_score &&
 
  348                 (best_score == -1 || score < best_score)) {
 
  359 #if VA_CHECK_VERSION(1, 1, 0) 
  360     static const struct {
 
  366                                     VA_CHROMA_SITING_HORIZONTAL_LEFT },
 
  368                                     VA_CHROMA_SITING_HORIZONTAL_CENTER },
 
  370                                     VA_CHROMA_SITING_HORIZONTAL_LEFT },
 
  372                                     VA_CHROMA_SITING_HORIZONTAL_CENTER },
 
  374                                     VA_CHROMA_SITING_HORIZONTAL_LEFT },
 
  376                                     VA_CHROMA_SITING_HORIZONTAL_CENTER },
 
  394 #if VA_CHECK_VERSION(1, 1, 0) 
  413                                              VAProcColorStandardType *vacs,
 
  421            "to VA standard %d chroma siting %#x range %#x.\n",
 
  436                frame->hw_frames_ctx);
 
  444                                        VAProcPipelineParameterBuffer *params,
 
  450     VAProcPipelineCaps caps;
 
  453     vas = vaQueryVideoProcPipelineCaps(
ctx->hwctx->display, 
ctx->va_context,
 
  454                                        ctx->filter_buffers, 
ctx->nb_filter_buffers,
 
  456     if (vas != VA_STATUS_SUCCESS) {
 
  458                "colour standard support: %d (%s).\n", vas, vaErrorStr(vas));
 
  472                                      caps.input_color_standards,
 
  473                                      caps.num_input_color_standards);
 
  481         .chroma_sample_location = 
output_frame->chroma_location,
 
  484                                      caps.output_color_standards,
 
  485                                      caps.num_output_color_standards);
 
  489 #if VA_CHECK_VERSION(1, 3, 0) 
  503         if (output_standard) {
 
  514 #if VA_CHECK_VERSION(1, 1, 0) 
  515     params->input_color_properties = (VAProcColorProperties) {
 
  518 #if VA_CHECK_VERSION(1, 3, 0) 
  520         .transfer_characteristics = input_props.
color_trc,
 
  521         .matrix_coefficients      = input_props.
colorspace,
 
  524     params->output_color_properties = (VAProcColorProperties) {
 
  527 #if VA_CHECK_VERSION(1, 3, 0) 
  529         .transfer_characteristics = output_props.
color_trc,
 
  530         .matrix_coefficients      = output_props.
colorspace,
 
  539                              VAProcPipelineParameterBuffer *params,
 
  546     ctx->input_region = (VARectangle) {
 
  549         .width  = input_frame->
width -
 
  559     *params = (VAProcPipelineParameterBuffer) {
 
  561         .surface_region          = &
ctx->input_region,
 
  562         .output_region           = 
NULL,
 
  565         .filter_flags            = VA_FRAME_PICTURE,
 
  569 #if VA_CHECK_VERSION(1, 1, 0) 
  570         .rotation_state = VA_ROTATION_NONE,
 
  571         .mirror_state   = VA_MIRROR_NONE,
 
  599     vas = vaCreateBuffer(
ctx->hwctx->display, 
ctx->va_context,
 
  601     if (vas != VA_STATUS_SUCCESS) {
 
  603                "buffer (type %d): %d (%s).\n",
 
  604                type, vas, vaErrorStr(vas));
 
  616                                                    VAProcPipelineParameterBuffer *params,
 
  617                                                    VABufferID *params_id)
 
  622     vas = vaCreateBuffer(
ctx->hwctx->display, 
ctx->va_context,
 
  623                          VAProcPipelineParameterBufferType,
 
  624                          sizeof(*params), 1, params, params_id);
 
  625     if (vas != VA_STATUS_SUCCESS) {
 
  627                "%d (%s).\n", vas, vaErrorStr(vas));
 
  628         *params_id = VA_INVALID_ID;
 
  634     vas = vaRenderPicture(
ctx->hwctx->display, 
ctx->va_context, params_id, 1);
 
  635     if (vas != VA_STATUS_SUCCESS) {
 
  637                "%d (%s).\n", vas, vaErrorStr(vas));
 
  645                                  VAProcPipelineParameterBuffer *params_list,
 
  650     VABufferID *params_ids;
 
  658     for (
int i = 0; 
i < cout; 
i++)
 
  659         params_ids[
i] = VA_INVALID_ID;
 
  661     vas = vaBeginPicture(
ctx->hwctx->display,
 
  663     if (vas != VA_STATUS_SUCCESS) {
 
  665                "%d (%s).\n", vas, vaErrorStr(vas));
 
  670     for (
int i = 0; 
i < cout; 
i++) {
 
  673             goto fail_after_begin;
 
  676     vas = vaEndPicture(
ctx->hwctx->display, 
ctx->va_context);
 
  677     if (vas != VA_STATUS_SUCCESS) {
 
  679                "%d (%s).\n", vas, vaErrorStr(vas));
 
  681         goto fail_after_render;
 
  684     if (CONFIG_VAAPI_1 || 
ctx->hwctx->driver_quirks &
 
  686         for (
int i = 0; 
i < cout && params_ids[
i] != VA_INVALID_ID; 
i++) {
 
  687             vas = vaDestroyBuffer(
ctx->hwctx->display, params_ids[
i]);
 
  688             if (vas != VA_STATUS_SUCCESS) {
 
  690                        "%d (%s).\n", vas, vaErrorStr(vas));
 
  704     vaRenderPicture(
ctx->hwctx->display, 
ctx->va_context, ¶ms_ids[0], 1);
 
  706     vaEndPicture(
ctx->hwctx->display, 
ctx->va_context);
 
  713                                 VAProcPipelineParameterBuffer *params,
 
  724     ctx->va_config  = VA_INVALID_ID;
 
  725     ctx->va_context = VA_INVALID_ID;
 
  728     for (
i = 0; 
i < VAProcFilterCount; 
i++)
 
  729         ctx->filter_buffers[
i] = VA_INVALID_ID;
 
  730     ctx->nb_filter_buffers = 0;
 
  736     if (
ctx->valid_ids && 
ctx->pipeline_uninit)
 
  737         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)
Link properties exposed to filter code, but not external callers.
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.
@ AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS
The driver does not destroy parameter buffers when they are used by vaRenderPicture().
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)
static FilterLink * ff_filter_link(AVFilterLink *link)
#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.
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.
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.
@ 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)
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