33 #define MAX_REFERENCES 8
42 VAProcFilterCapDeinterlacing
56 #define D(name) case VAProcDeinterlacing ## name: return #name
84 VAProcFilterParameterBufferDeinterlacing
params;
88 vas = vaQueryVideoProcFilterCaps(vpp_ctx->
hwctx->
display,
90 VAProcFilterDeinterlacing,
93 if (vas != VA_STATUS_SUCCESS) {
95 "caps: %d (%s).\n", vas, vaErrorStr(vas));
99 if (ctx->
mode == VAProcDeinterlacingNone) {
105 "deinterlacing mode.\n", ctx->
mode,
114 "not supported.\n", ctx->
mode,
119 params.type = VAProcFilterDeinterlacing;
120 params.algorithm = ctx->
mode;
124 VAProcFilterParameterBufferType,
131 vas = vaQueryVideoProcPipelineCaps(vpp_ctx->
hwctx->
display,
135 if (vas != VA_STATUS_SUCCESS) {
137 "caps: %d (%s).\n", vas, vaErrorStr(vas));
149 "references (%u forward, %u back).\n",
170 outlink->frame_rate =
av_mul_q(inlink->frame_rate,
183 VASurfaceID input_surface, output_surface;
186 VAProcPipelineParameterBuffer
params;
187 VAProcFilterParameterBufferDeinterlacing *filter_params;
188 VARectangle input_region;
190 void *filter_params_addr =
NULL;
191 int err, i, field, current_frame_index;
210 current_frame_index = ctx->
pipeline_caps.num_forward_references;
212 input_frame = ctx->
frame_queue[current_frame_index];
213 input_surface = (VASurfaceID)(uintptr_t)input_frame->
data[3];
214 for (i = 0; i < ctx->
pipeline_caps.num_forward_references; i++)
215 forward_references[i] = (VASurfaceID)(uintptr_t)
218 backward_references[i] = (VASurfaceID)(uintptr_t)
222 "deinterlace input.\n", input_surface);
224 for (i = 0; i < ctx->
pipeline_caps.num_backward_references; i++)
228 for (i = 0; i < ctx->
pipeline_caps.num_forward_references; i++)
232 for (field = 0; field < ctx->
field_rate; field++) {
240 output_surface = (VASurfaceID)(uintptr_t)output_frame->
data[3];
242 "deinterlace output.\n", output_surface);
244 memset(¶ms, 0,
sizeof(params));
246 input_region = (VARectangle) {
249 .width = input_frame->
width,
250 .height = input_frame->
height,
253 params.surface = input_surface;
254 params.surface_region = &input_region;
255 params.surface_color_standard =
258 params.output_region =
NULL;
259 params.output_background_color = 0xff000000;
260 params.output_color_standard = params.surface_color_standard;
262 params.pipeline_flags = 0;
263 params.filter_flags = VA_FRAME_PICTURE;
267 &filter_params_addr);
268 if (vas != VA_STATUS_SUCCESS) {
270 "buffer: %d (%s).\n", vas, vaErrorStr(vas));
274 filter_params = filter_params_addr;
275 filter_params->flags = 0;
277 filter_params->flags |= field ? VA_DEINTERLACING_BOTTOM_FIELD : 0;
279 filter_params->flags |= VA_DEINTERLACING_BOTTOM_FIELD_FIRST;
280 filter_params->flags |= field ? 0 : VA_DEINTERLACING_BOTTOM_FIELD;
282 filter_params_addr =
NULL;
284 if (vas != VA_STATUS_SUCCESS)
286 "buffer: %d (%s).\n", vas, vaErrorStr(vas));
289 params.num_filters = 1;
291 params.forward_references = forward_references;
292 params.num_forward_references =
294 params.backward_references = backward_references;
295 params.num_backward_references =
299 params.filters =
NULL;
300 params.num_filters = 0;
313 output_frame->
pts = 2 * input_frame->
pts;
315 output_frame->
pts = input_frame->
pts +
332 if (filter_params_addr)
350 #define OFFSET(x) offsetof(DeintVAAPIContext, x)
351 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
353 {
"mode",
"Deinterlacing mode",
355 VAProcDeinterlacingNone, VAProcDeinterlacingCount - 1,
FLAGS,
"mode" },
356 {
"default",
"Use the highest-numbered (and therefore possibly most advanced) deinterlacing algorithm",
358 {
"bob",
"Use the bob deinterlacing algorithm",
360 {
"weave",
"Use the weave deinterlacing algorithm",
362 {
"motion_adaptive",
"Use the motion adaptive deinterlacing algorithm",
364 {
"motion_compensated",
"Use the motion compensated deinterlacing algorithm",
367 {
"rate",
"Generate output at frame rate or field rate",
369 {
"frame",
"Output at frame rate (one frame of output for each field-pair)",
371 {
"field",
"Output at field rate (one frame of output for each field)",
374 {
"auto",
"Only deinterlace fields, passing frames through unchanged",
407 .
name =
"deinterlace_vaapi",
413 .
inputs = deint_vaapi_inputs,
414 .
outputs = deint_vaapi_outputs,
415 .priv_class = &deint_vaapi_class,
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
This structure describes decoded (raw) audio or video data.
int ff_vaapi_vpp_config_input(AVFilterLink *inlink)
int(* build_filter_params)(AVFilterContext *avctx)
#define LIBAVUTIL_VERSION_INT
Main libavfilter public API header.
Memory handling functions.
int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
static av_cold int init(AVCodecContext *avctx)
VAProcFilterCapDeinterlacing deint_caps[VAProcDeinterlacingCount]
static int deint_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
const char * av_default_item_name(void *ptr)
Return the context name.
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static int deint_vaapi_build_filter_params(AVFilterContext *avctx)
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
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static av_cold int uninit(AVCodecContext *avctx)
void(* pipeline_uninit)(AVFilterContext *avctx)
static void deint_vaapi_pipeline_uninit(AVFilterContext *avctx)
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.
int ff_vaapi_vpp_render_picture(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, VASurfaceID output_surface)
A filter pad used for either input or output.
A link between two filters.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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.
enum AVColorSpace colorspace
YUV colorspace type.
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
simple assert() macros that are a bit more flexible than ISO C assert().
int ff_vaapi_vpp_make_param_buffers(AVFilterContext *avctx, int type, const void *data, size_t size, int count)
static int deint_vaapi_config_output(AVFilterLink *outlink)
AVFrame * frame_queue[MAX_REFERENCES]
static const char * deint_vaapi_mode_name(int mode)
void ff_vaapi_vpp_pipeline_uninit(AVFilterContext *avctx)
int extra_delay_for_timestamps
AVFilterContext * src
source filter
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
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...
VABufferID filter_buffers[VAProcFilterCount]
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
Describe the class of an AVClass context structure.
Rational number (pair of numerator and denominator).
const char * name
Filter name.
static const AVClass deint_vaapi_class
AVFilterLink ** outputs
array of pointers to output links
enum AVPixelFormat output_format
AVVAAPIDeviceContext * hwctx
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static av_cold int deint_vaapi_init(AVFilterContext *avctx)
int ff_vaapi_vpp_query_formats(AVFilterContext *avctx)
static const AVFilterPad deint_vaapi_inputs[]
static int query_formats(AVFilterContext *ctx)
common internal and external API header
void ff_vaapi_vpp_ctx_init(AVFilterContext *avctx)
int ff_vaapi_vpp_colour_standard(enum AVColorSpace av_cs)
static const AVFilterPad deint_vaapi_outputs[]
int top_field_first
If the content is interlaced, is top field displayed first.
AVFilterContext * dst
dest filter
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
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.
mode
Use these values in ebur128_init (or'ed).
void ff_vaapi_vpp_ctx_uninit(AVFilterContext *avctx)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
static const AVOption deint_vaapi_options[]