22 #include <va/va_vpp.h>
36 #define MAX_REFERENCES 8
58 VAProcFilterCapDeinterlacing
73 #define D(name) case VAProcDeinterlacing ## name: return #name
140 "required to associate the processing device.\n");
154 VAProcFilterParameterBufferDeinterlacing
params;
160 VAProcFilterDeinterlacing,
163 if (vas != VA_STATUS_SUCCESS) {
165 "caps: %d (%s).\n", vas, vaErrorStr(vas));
169 if (ctx->
mode == VAProcDeinterlacingNone) {
175 "deinterlacing mode.\n", ctx->
mode,
184 "not supported.\n", ctx->
mode,
189 params.type = VAProcFilterDeinterlacing;
190 params.algorithm = ctx->
mode;
195 VAProcFilterParameterBufferType,
196 sizeof(params), 1, ¶ms,
198 if (vas != VA_STATUS_SUCCESS) {
200 "parameter buffer: %d (%s).\n", vas, vaErrorStr(vas));
208 if (vas != VA_STATUS_SUCCESS) {
210 "caps: %d (%s).\n", vas, vaErrorStr(vas));
218 "references (%u forward, %u back).\n",
247 vas = vaCreateConfig(ctx->
hwctx->
display, VAProfileNone,
248 VAEntrypointVideoProc, 0, 0, &ctx->
va_config);
249 if (vas != VA_STATUS_SUCCESS) {
251 "config: %d (%s).\n", vas, vaErrorStr(vas));
275 "deinterlacing to size %dx%d "
276 "(constraints: width %d-%d height %d-%d).\n",
307 "context for output: %d\n", err);
318 if (vas != VA_STATUS_SUCCESS) {
320 "context: %d (%s).\n", vas, vaErrorStr(vas));
352 #define CS(av, va) case AVCOL_SPC_ ## av: return VAProcColorStandard ## va;
354 CS(BT470BG, BT470BG);
355 CS(SMPTE170M, SMPTE170M);
356 CS(SMPTE240M, SMPTE240M);
359 return VAProcColorStandardNone;
369 VASurfaceID input_surface, output_surface;
372 VAProcPipelineParameterBuffer
params;
373 VAProcFilterParameterBufferDeinterlacing *filter_params;
374 VARectangle input_region;
375 VABufferID params_id;
377 void *filter_params_addr =
NULL;
399 input_surface = (VASurfaceID)(uintptr_t)input_frame->
data[3];
400 for (i = 0; i < ctx->
pipeline_caps.num_backward_references; i++)
401 backward_references[i] = (VASurfaceID)(uintptr_t)
405 forward_references[i] = (VASurfaceID)(uintptr_t)
410 "deinterlace input.\n", input_surface);
412 for (i = 0; i < ctx->
pipeline_caps.num_backward_references; i++)
416 for (i = 0; i < ctx->
pipeline_caps.num_forward_references; i++)
433 output_surface = (VASurfaceID)(uintptr_t)output_frame->
data[3];
435 "deinterlace output.\n", output_surface);
437 memset(¶ms, 0,
sizeof(params));
439 input_region = (VARectangle) {
442 .width = input_frame->
width,
443 .height = input_frame->
height,
446 params.surface = input_surface;
447 params.surface_region = &input_region;
451 params.output_region =
NULL;
452 params.output_background_color = 0xff000000;
453 params.output_color_standard = params.surface_color_standard;
455 params.pipeline_flags = 0;
456 params.filter_flags = VA_FRAME_PICTURE;
459 &filter_params_addr);
460 if (vas != VA_STATUS_SUCCESS) {
462 "buffer: %d (%s).\n", vas, vaErrorStr(vas));
466 filter_params = filter_params_addr;
467 filter_params->flags = 0;
469 filter_params->flags |= VA_DEINTERLACING_BOTTOM_FIELD_FIRST;
470 filter_params_addr =
NULL;
472 if (vas != VA_STATUS_SUCCESS)
474 "buffer: %d (%s).\n", vas, vaErrorStr(vas));
477 params.num_filters = 1;
479 params.forward_references = forward_references;
480 params.num_forward_references =
482 params.backward_references = backward_references;
483 params.num_backward_references =
488 if (vas != VA_STATUS_SUCCESS) {
490 "%d (%s).\n", vas, vaErrorStr(vas));
496 VAProcPipelineParameterBufferType,
497 sizeof(params), 1, ¶ms, ¶ms_id);
498 if (vas != VA_STATUS_SUCCESS) {
500 "%d (%s).\n", vas, vaErrorStr(vas));
502 goto fail_after_begin;
509 if (vas != VA_STATUS_SUCCESS) {
511 "%d (%s).\n", vas, vaErrorStr(vas));
513 goto fail_after_begin;
517 if (vas != VA_STATUS_SUCCESS) {
519 "%d (%s).\n", vas, vaErrorStr(vas));
521 goto fail_after_render;
527 if (vas != VA_STATUS_SUCCESS) {
529 "%d (%s).\n", vas, vaErrorStr(vas));
549 if (filter_params_addr)
579 #define OFFSET(x) offsetof(DeintVAAPIContext, x)
580 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
582 {
"mode",
"Deinterlacing mode",
584 VAProcDeinterlacingNone, VAProcDeinterlacingCount - 1,
FLAGS,
"mode" },
585 {
"default",
"Use the highest-numbered (and therefore possibly most advanced) deinterlacing algorithm",
587 {
"bob",
"Use the bob deinterlacing algorithm",
589 {
"weave",
"Use the weave deinterlacing algorithm",
591 {
"motion_adaptive",
"Use the motion adaptive deinterlacing algorithm",
592 0,
AV_OPT_TYPE_CONST, { .i64 = VAProcDeinterlacingMotionAdaptive }, .unit =
"mode" },
593 {
"motion_compensated",
"Use the motion compensated deinterlacing algorithm",
594 0,
AV_OPT_TYPE_CONST, { .i64 = VAProcDeinterlacingMotionCompensated }, .unit =
"mode" },
625 .
name =
"deinterlace_vaapi",
631 .
inputs = deint_vaapi_inputs,
632 .
outputs = deint_vaapi_outputs,
633 .priv_class = &deint_vaapi_class,
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
VAAPI-specific data associated with a frame pool.
This structure describes decoded (raw) audio or video data.
#define LIBAVUTIL_VERSION_INT
Main libavfilter public API header.
Memory handling functions.
static av_cold int init(AVCodecContext *avctx)
int h
agreed upon image height
VAProcFilterCapDeinterlacing deint_caps[VAProcDeinterlacingCount]
static int deint_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
int width
The allocated dimensions of the frames in this pool.
void * av_hwdevice_hwconfig_alloc(AVBufferRef *ref)
Allocate a HW-specific configuration structure for a given HW device.
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
static int deint_vaapi_build_filter_params(AVFilterContext *avctx)
int max_width
The maximum size of frames in this hw_frames_ctx.
API-specific header for AV_HWDEVICE_TYPE_VAAPI.
void av_hwframe_constraints_free(AVHWFramesConstraints **constraints)
Free an AVHWFrameConstraints structure.
const char * name
Pad name.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
AVFilterLink ** inputs
array of pointers to input links
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
AVVAAPIDeviceContext * hwctx
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static av_cold int uninit(AVCodecContext *avctx)
AVColorSpace
YUV colorspace type.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
AVFilter ff_vf_deinterlace_vaapi
#define AV_LOG_VERBOSE
Detailed information.
int interlaced_frame
The content of the picture is interlaced.
static int deint_vaapi_query_formats(AVFilterContext *avctx)
A filter pad used for either input or output.
A link between two filters.
AVHWFramesContext * input_frames
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
VAAPI hardware pipeline configuration details.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
simple assert() macros that are a bit more flexible than ISO C assert().
AVFilterFormats * in_formats
Lists of formats and channel layouts supported by the input and output filters respectively.
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, AVFrame *frame, int flags)
Allocate a new frame attached to the given AVHWFramesContext.
static int deint_vaapi_config_output(AVFilterLink *outlink)
int w
agreed upon image width
int initial_pool_size
Initial size of the frame pool.
AVFrame * frame_queue[MAX_REFERENCES]
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames...
static const char * deint_vaapi_mode_name(int mode)
static int deint_vaapi_config_input(AVFilterLink *inlink)
AVFilterContext * src
source filter
static const AVFilterPad outputs[]
AVBufferRef * input_frames_ref
VAProcPipelineCaps pipeline_caps
VADisplay display
The VADisplay handle, to be filled by the user.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
int min_width
The minimum size of frames in this hw_frames_ctx.
static const AVFilterPad inputs[]
This struct describes the constraints on hardware frames attached to a given device with a hardware-s...
AVBufferRef * output_frames_ref
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...
uint8_t * data
The data buffer.
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
unsigned int driver_quirks
Driver quirks to apply - this is filled by av_hwdevice_ctx_init(), with reference to a table of known...
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
enum AVColorSpace av_frame_get_colorspace(const AVFrame *frame)
AVHWFramesContext * output_frames
Describe the class of an AVClass context structure.
This struct describes a set or pool of "hardware" frames (i.e.
const char * name
Filter name.
static const AVClass deint_vaapi_class
AVFilterLink ** outputs
array of pointers to output links
static enum AVPixelFormat pix_fmts[]
static int deint_vaapi_pipeline_uninit(AVFilterContext *avctx)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
A reference to a data buffer.
static av_cold int deint_vaapi_init(AVFilterContext *avctx)
static const AVFilterPad deint_vaapi_inputs[]
static int query_formats(AVFilterContext *ctx)
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
static const AVFilterPad deint_vaapi_outputs[]
The driver does not destroy parameter buffers when they are used by vaRenderPicture().
int top_field_first
If the content is interlaced, is top field displayed first.
AVFilterContext * dst
dest filter
VAAPI connection details.
VAConfigID config_id
ID of a VAAPI pipeline configuration.
VASurfaceID * surface_ids
The surfaces IDs of all surfaces in the pool after creation.
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.
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
AVPixelFormat
Pixel format.
mode
Use these values in ebur128_init (or'ed).
static int vaapi_proc_colour_standard(enum AVColorSpace av_cs)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
AVFilterFormats * out_formats
static av_cold void deint_vaapi_uninit(AVFilterContext *avctx)
static const AVOption deint_vaapi_options[]