30#define MAX_REFERENCES 8
39 VAProcFilterCapDeinterlacing
56#define D(name) case VAProcDeinterlacing ## name: return #name
72 for (
i = 0;
i <
ctx->queue_count;
i++)
84 VAProcFilterParameterBufferDeinterlacing
params;
87 ctx->nb_deint_caps = VAProcDeinterlacingCount;
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) {
100 for (
i = 0;
i <
ctx->nb_deint_caps;
i++) {
101 if (
ctx->deint_caps[
i].type >
ctx->mode)
102 ctx->mode =
ctx->deint_caps[
i].type;
105 "deinterlacing mode.\n",
ctx->mode,
108 for (
i = 0;
i <
ctx->nb_deint_caps;
i++) {
109 if (
ctx->deint_caps[
i].type ==
ctx->mode)
112 if (
i >=
ctx->nb_deint_caps) {
114 "not supported.\n",
ctx->mode,
120 params.type = VAProcFilterDeinterlacing;
125 VAProcFilterParameterBufferType,
132 vas = vaQueryVideoProcPipelineCaps(vpp_ctx->
hwctx->
display,
135 &
ctx->pipeline_caps);
136 if (vas != VA_STATUS_SUCCESS) {
138 "caps: %d (%s).\n", vas, vaErrorStr(vas));
142 ctx->extra_delay_for_timestamps =
ctx->field_rate == 2 &&
143 ctx->pipeline_caps.num_backward_references == 0;
145 ctx->queue_depth =
ctx->pipeline_caps.num_backward_references +
146 ctx->pipeline_caps.num_forward_references +
147 ctx->extra_delay_for_timestamps + 1;
150 "references (%u forward, %u back).\n",
151 ctx->pipeline_caps.num_forward_references,
152 ctx->pipeline_caps.num_backward_references);
186 VASurfaceID input_surface;
189 VAProcPipelineParameterBuffer
params;
190 VAProcFilterParameterBufferDeinterlacing *filter_params;
192 void *filter_params_addr =
NULL;
193 int err,
i, field, current_frame_index;
201 if (
ctx->queue_count <
ctx->queue_depth) {
202 ctx->frame_queue[
ctx->queue_count++] = input_frame;
203 if (
ctx->queue_count <
ctx->queue_depth) {
209 for (
i = 0;
i + 1 <
ctx->queue_count;
i++)
210 ctx->frame_queue[
i] =
ctx->frame_queue[
i + 1];
211 ctx->frame_queue[
i] = input_frame;
214 current_frame_index =
ctx->pipeline_caps.num_forward_references;
216 input_frame =
ctx->frame_queue[current_frame_index];
220 input_surface = (VASurfaceID)(uintptr_t)input_frame->
data[3];
221 for (
i = 0;
i <
ctx->pipeline_caps.num_forward_references;
i++)
222 forward_references[
i] = (VASurfaceID)(uintptr_t)
223 ctx->frame_queue[current_frame_index -
i - 1]->data[3];
224 for (
i = 0;
i <
ctx->pipeline_caps.num_backward_references;
i++)
225 backward_references[
i] = (VASurfaceID)(uintptr_t)
226 ctx->frame_queue[current_frame_index +
i + 1]->data[3];
229 "deinterlace input.\n", input_surface);
231 for (
i = 0;
i <
ctx->pipeline_caps.num_backward_references;
i++)
235 for (
i = 0;
i <
ctx->pipeline_caps.num_forward_references;
i++)
239 for (field = 0; field <
ctx->field_rate; field++) {
258 &filter_params_addr);
259 if (vas != VA_STATUS_SUCCESS) {
261 "buffer: %d (%s).\n", vas, vaErrorStr(vas));
265 filter_params = filter_params_addr;
266 filter_params->flags = 0;
268 filter_params->flags |= field ? VA_DEINTERLACING_BOTTOM_FIELD : 0;
270 filter_params->flags |= VA_DEINTERLACING_BOTTOM_FIELD_FIRST;
271 filter_params->flags |= field ? 0 : VA_DEINTERLACING_BOTTOM_FIELD;
273 filter_params_addr =
NULL;
275 if (vas != VA_STATUS_SUCCESS)
277 "buffer: %d (%s).\n", vas, vaErrorStr(vas));
282 params.forward_references = forward_references;
283 params.num_forward_references =
284 ctx->pipeline_caps.num_forward_references;
285 params.backward_references = backward_references;
286 params.num_backward_references =
287 ctx->pipeline_caps.num_backward_references;
298 if (
ctx->field_rate == 2) {
305 ctx->frame_queue[current_frame_index + 1]->pts;
318 ctx->prev_pts = input_frame->
pts;
323 if (filter_params_addr)
360#define OFFSET(x) offsetof(DeintVAAPIContext, x)
361#define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
363 {
"mode",
"Deinterlacing mode",
365 VAProcDeinterlacingNone, VAProcDeinterlacingCount - 1,
FLAGS, .unit =
"mode" },
366 {
"default",
"Use the highest-numbered (and therefore possibly most advanced) deinterlacing algorithm",
368 {
"bob",
"Use the bob deinterlacing algorithm",
370 {
"weave",
"Use the weave deinterlacing algorithm",
372 {
"motion_adaptive",
"Use the motion adaptive deinterlacing algorithm",
374 {
"motion_compensated",
"Use the motion compensated deinterlacing algorithm",
377 {
"rate",
"Generate output at frame rate or field rate",
379 {
"frame",
"Output at frame rate (one frame of output for each field-pair)",
381 {
"field",
"Output at field rate (one frame of output for each field)",
384 {
"auto",
"Only deinterlace fields, passing frames through unchanged",
391 .class_name =
"deinterlace_vaapi",
416 .p.name =
"deinterlace_vaapi",
SwsAArch64OpImplParams params
const FFFilter ff_vf_deinterlace_vaapi
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
common internal and external API header
int(* init)(AVBSFContext *ctx)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
#define AVERROR_EOF
End of file.
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
#define LIBAVUTIL_VERSION_INT
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
static FilterLink * ff_filter_link(AVFilterLink *link)
#define FILTER_QUERY_FUNC2(func)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
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.
Describe the class of an AVClass context structure.
AVFilterLink ** inputs
array of pointers to input links
void * priv
private data for use by the filter
AVFilterLink ** outputs
array of pointers to output links
A link between two filters.
AVFilterContext * src
source filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Rational number (pair of numerator and denominator).
VADisplay display
The VADisplay handle, to be filled by the user.
AVFrame * frame_queue[MAX_REFERENCES]
VAProcFilterCapDeinterlacing deint_caps[VAProcDeinterlacingCount]
VAProcPipelineCaps pipeline_caps
int extra_delay_for_timestamps
Link properties exposed to filter code, but not external callers.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
VABufferID filter_buffers[VAProcFilterCount]
void(* pipeline_uninit)(AVFilterContext *avctx)
enum AVPixelFormat output_format
int(* build_filter_params)(AVFilterContext *avctx)
AVVAAPIDeviceContext * hwctx
static AVFormatContext * ctx
int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
int ff_vaapi_vpp_config_input(AVFilterLink *inlink)
int ff_vaapi_vpp_query_formats(const AVFilterContext *avctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
void ff_vaapi_vpp_pipeline_uninit(AVFilterContext *avctx)
void ff_vaapi_vpp_ctx_init(AVFilterContext *avctx)
int ff_vaapi_vpp_make_param_buffers(AVFilterContext *avctx, int type, const void *data, size_t size, int count)
int ff_vaapi_vpp_init_params(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, const AVFrame *input_frame, AVFrame *output_frame)
int ff_vaapi_vpp_render_picture(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, AVFrame *output_frame)
void ff_vaapi_vpp_ctx_uninit(AVFilterContext *avctx)
static const AVClass deint_vaapi_class
static av_cold int deint_vaapi_init(AVFilterContext *avctx)
static int deint_vaapi_config_output(AVFilterLink *outlink)
static int deint_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
static const AVOption deint_vaapi_options[]
static void deint_vaapi_pipeline_uninit(AVFilterContext *avctx)
static int deint_vaapi_build_filter_params(AVFilterContext *avctx)
static const char * deint_vaapi_mode_name(int mode)
static const AVFilterPad deint_vaapi_outputs[]
static const AVFilterPad deint_vaapi_inputs[]
static int deint_vaapi_request_frame(AVFilterLink *link)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.