Go to the documentation of this file.
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;
121 params.algorithm =
ctx->mode;
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);
184 VASurfaceID input_surface;
187 VAProcPipelineParameterBuffer params;
188 VAProcFilterParameterBufferDeinterlacing *filter_params;
190 void *filter_params_addr =
NULL;
191 int err,
i,
field, current_frame_index;
199 if (
ctx->queue_count <
ctx->queue_depth) {
200 ctx->frame_queue[
ctx->queue_count++] = input_frame;
201 if (
ctx->queue_count <
ctx->queue_depth) {
207 for (
i = 0;
i + 1 <
ctx->queue_count;
i++)
208 ctx->frame_queue[
i] =
ctx->frame_queue[
i + 1];
209 ctx->frame_queue[
i] = input_frame;
212 current_frame_index =
ctx->pipeline_caps.num_forward_references;
214 input_frame =
ctx->frame_queue[current_frame_index];
218 input_surface = (VASurfaceID)(uintptr_t)input_frame->
data[3];
219 for (
i = 0;
i <
ctx->pipeline_caps.num_forward_references;
i++)
220 forward_references[
i] = (VASurfaceID)(uintptr_t)
221 ctx->frame_queue[current_frame_index -
i - 1]->data[3];
222 for (
i = 0;
i <
ctx->pipeline_caps.num_backward_references;
i++)
223 backward_references[
i] = (VASurfaceID)(uintptr_t)
224 ctx->frame_queue[current_frame_index +
i + 1]->data[3];
227 "deinterlace input.\n", input_surface);
229 for (
i = 0;
i <
ctx->pipeline_caps.num_backward_references;
i++)
233 for (
i = 0;
i <
ctx->pipeline_caps.num_forward_references;
i++)
256 &filter_params_addr);
257 if (vas != VA_STATUS_SUCCESS) {
259 "buffer: %d (%s).\n", vas, vaErrorStr(vas));
263 filter_params = filter_params_addr;
264 filter_params->flags = 0;
266 filter_params->flags |=
field ? VA_DEINTERLACING_BOTTOM_FIELD : 0;
268 filter_params->flags |= VA_DEINTERLACING_BOTTOM_FIELD_FIRST;
269 filter_params->flags |=
field ? 0 : VA_DEINTERLACING_BOTTOM_FIELD;
271 filter_params_addr =
NULL;
273 if (vas != VA_STATUS_SUCCESS)
275 "buffer: %d (%s).\n", vas, vaErrorStr(vas));
278 params.num_filters = 1;
280 params.forward_references = forward_references;
281 params.num_forward_references =
282 ctx->pipeline_caps.num_forward_references;
283 params.backward_references = backward_references;
284 params.num_backward_references =
285 ctx->pipeline_caps.num_backward_references;
288 params.filters =
NULL;
289 params.num_filters = 0;
296 if (
ctx->field_rate == 2) {
303 ctx->frame_queue[current_frame_index + 1]->pts;
305 #if FF_API_INTERLACED_FRAME
321 ctx->prev_pts = input_frame->
pts;
326 if (filter_params_addr)
363 #define OFFSET(x) offsetof(DeintVAAPIContext, x)
364 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
366 {
"mode",
"Deinterlacing mode",
368 VAProcDeinterlacingNone, VAProcDeinterlacingCount - 1,
FLAGS,
"mode" },
369 {
"default",
"Use the highest-numbered (and therefore possibly most advanced) deinterlacing algorithm",
371 {
"bob",
"Use the bob deinterlacing algorithm",
373 {
"weave",
"Use the weave deinterlacing algorithm",
375 {
"motion_adaptive",
"Use the motion adaptive deinterlacing algorithm",
377 {
"motion_compensated",
"Use the motion compensated deinterlacing algorithm",
380 {
"rate",
"Generate output at frame rate or field rate",
382 {
"frame",
"Output at frame rate (one frame of output for each field-pair)",
384 {
"field",
"Output at field rate (one frame of output for each field)",
387 {
"auto",
"Only deinterlace fields, passing frames through unchanged",
419 .
name =
"deinterlace_vaapi",
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
void ff_vaapi_vpp_pipeline_uninit(AVFilterContext *avctx)
void ff_vaapi_vpp_ctx_init(AVFilterContext *avctx)
#define FF_ENABLE_DEPRECATION_WARNINGS
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
int ff_vaapi_vpp_render_picture(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, AVFrame *output_frame)
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
#define AVERROR_EOF
End of file.
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
static int deint_vaapi_config_output(AVFilterLink *outlink)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static void deint_vaapi_pipeline_uninit(AVFilterContext *avctx)
static av_cold int deint_vaapi_init(AVFilterContext *avctx)
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).
#define FILTER_QUERY_FUNC(func)
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
AVFrame * frame_queue[MAX_REFERENCES]
#define AV_LOG_VERBOSE
Detailed information.
VADisplay display
The VADisplay handle, to be filled by the user.
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
const char * name
Filter name.
A link between two filters.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
int(* build_filter_params)(AVFilterContext *avctx)
void * priv
private data for use by the filter
static const char * deint_vaapi_mode_name(int mode)
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int flags
Flags modifying the (de)muxer behaviour.
int(* init)(AVBSFContext *ctx)
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0,...
const AVFilter ff_vf_deinterlace_vaapi
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
enum AVPixelFormat output_format
int ff_vaapi_vpp_make_param_buffers(AVFilterContext *avctx, int type, const void *data, size_t size, int count)
VAProcFilterCapDeinterlacing deint_caps[VAProcDeinterlacingCount]
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 field
AVVAAPIDeviceContext * hwctx
static const AVFilterPad deint_vaapi_outputs[]
#define FILTER_INPUTS(array)
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 link
static int deint_vaapi_request_frame(AVFilterLink *link)
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
static const AVClass deint_vaapi_class
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Rational number (pair of numerator and denominator).
AVFilterLink ** inputs
array of pointers to input links
const char * av_default_item_name(void *ptr)
Return the context name.
int extra_delay_for_timestamps
static int deint_vaapi_build_filter_params(AVFilterContext *avctx)
int ff_vaapi_vpp_config_input(AVFilterLink *inlink)
void ff_vaapi_vpp_ctx_uninit(AVFilterContext *avctx)
int ff_vaapi_vpp_query_formats(AVFilterContext *avctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static const AVOption deint_vaapi_options[]
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
AVFilterContext * src
source filter
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
#define i(width, name, range_min, range_max)
VABufferID filter_buffers[VAProcFilterCount]
const char * name
Pad name.
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
VAProcPipelineCaps pipeline_caps
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
void(* pipeline_uninit)(AVFilterContext *avctx)
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
#define FF_DISABLE_DEPRECATION_WARNINGS
#define FILTER_OUTPUTS(array)
static int deint_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
static av_cold int uninit(AVCodecContext *avctx)
static const AVFilterPad deint_vaapi_inputs[]
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_vaapi_vpp_init_params(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, const AVFrame *input_frame, AVFrame *output_frame)
AVFilterLink ** outputs
array of pointers to output links