FFmpeg
vf_overlay_qsv.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 /**
20  * @file
21  * A hardware accelerated overlay filter based on Intel Quick Sync Video VPP
22  */
23 
24 #include "libavutil/mem.h"
25 #include "libavutil/opt.h"
26 #include "libavutil/common.h"
27 #include "libavutil/pixdesc.h"
28 #include "libavutil/eval.h"
29 #include "libavutil/hwcontext.h"
30 #include "libavutil/mathematics.h"
31 
32 #include "internal.h"
33 #include "avfilter.h"
34 #include "formats.h"
35 
36 #include "framesync.h"
37 #include "qsvvpp.h"
38 
39 #define MAIN 0
40 #define OVERLAY 1
41 
42 #define OFFSET(x) offsetof(QSVOverlayContext, x)
43 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM)
44 
45 enum var_name {
55 };
56 
57 typedef struct QSVOverlayContext {
59 
62  mfxExtVPPComposite comp_conf;
64 
67 
69 
70 static const char *const var_names[] = {
71  "main_w", "W", /* input width of the main layer */
72  "main_h", "H", /* input height of the main layer */
73  "overlay_iw", /* input width of the overlay layer */
74  "overlay_ih", /* input height of the overlay layer */
75  "overlay_x", "x", /* x position of the overlay layer inside of main */
76  "overlay_y", "y", /* y position of the overlay layer inside of main */
77  "overlay_w", "w", /* output width of overlay layer */
78  "overlay_h", "h", /* output height of overlay layer */
79  NULL
80 };
81 
82 static const AVOption overlay_qsv_options[] = {
83  { "x", "Overlay x position", OFFSET(overlay_ox), AV_OPT_TYPE_STRING, { .str="0"}, 0, 255, .flags = FLAGS},
84  { "y", "Overlay y position", OFFSET(overlay_oy), AV_OPT_TYPE_STRING, { .str="0"}, 0, 255, .flags = FLAGS},
85  { "w", "Overlay width", OFFSET(overlay_ow), AV_OPT_TYPE_STRING, { .str="overlay_iw"}, 0, 255, .flags = FLAGS},
86  { "h", "Overlay height", OFFSET(overlay_oh), AV_OPT_TYPE_STRING, { .str="overlay_ih*w/overlay_iw"}, 0, 255, .flags = FLAGS},
87  { "alpha", "Overlay global alpha", OFFSET(overlay_alpha), AV_OPT_TYPE_INT, { .i64 = 255}, 0, 255, .flags = FLAGS},
88  { "eof_action", "Action to take when encountering EOF from secondary input ",
89  OFFSET(fs.opt_eof_action), AV_OPT_TYPE_INT, { .i64 = EOF_ACTION_REPEAT },
90  EOF_ACTION_REPEAT, EOF_ACTION_PASS, .flags = FLAGS, .unit = "eof_action" },
91  { "repeat", "Repeat the previous frame.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_REPEAT }, .flags = FLAGS, .unit = "eof_action" },
92  { "endall", "End both streams.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_ENDALL }, .flags = FLAGS, .unit = "eof_action" },
93  { "pass", "Pass through the main input.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_PASS }, .flags = FLAGS, .unit = "eof_action" },
94  { "shortest", "force termination when the shortest input terminates", OFFSET(fs.opt_shortest), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
95  { "repeatlast", "repeat overlay of the last overlay frame", OFFSET(fs.opt_repeatlast), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGS },
96  { NULL }
97 };
98 
100 
102 {
103  QSVOverlayContext *vpp = ctx->priv;
104  double *var_values = vpp->var_values;
105  int ret = 0;
106  AVExpr *ox_expr = NULL, *oy_expr = NULL;
107  AVExpr *ow_expr = NULL, *oh_expr = NULL;
108 
109 #define PASS_EXPR(e, s) {\
110  ret = av_expr_parse(&e, s, var_names, NULL, NULL, NULL, NULL, 0, ctx); \
111  if (ret < 0) {\
112  av_log(ctx, AV_LOG_ERROR, "Error when passing '%s'.\n", s);\
113  goto release;\
114  }\
115 }
116  PASS_EXPR(ox_expr, vpp->overlay_ox);
117  PASS_EXPR(oy_expr, vpp->overlay_oy);
118  PASS_EXPR(ow_expr, vpp->overlay_ow);
119  PASS_EXPR(oh_expr, vpp->overlay_oh);
120 #undef PASS_EXPR
121 
122  var_values[VAR_OVERLAY_W] =
123  var_values[VAR_OW] = av_expr_eval(ow_expr, var_values, NULL);
124  var_values[VAR_OVERLAY_H] =
125  var_values[VAR_OH] = av_expr_eval(oh_expr, var_values, NULL);
126 
127  /* calc again in case ow is relative to oh */
128  var_values[VAR_OVERLAY_W] =
129  var_values[VAR_OW] = av_expr_eval(ow_expr, var_values, NULL);
130 
131  var_values[VAR_OVERLAY_X] =
132  var_values[VAR_OX] = av_expr_eval(ox_expr, var_values, NULL);
133  var_values[VAR_OVERLAY_Y] =
134  var_values[VAR_OY] = av_expr_eval(oy_expr, var_values, NULL);
135 
136  /* calc again in case ox is relative to oy */
137  var_values[VAR_OVERLAY_X] =
138  var_values[VAR_OX] = av_expr_eval(ox_expr, var_values, NULL);
139 
140  /* calc overlay_w and overlay_h again incase relative to ox,oy */
141  var_values[VAR_OVERLAY_W] =
142  var_values[VAR_OW] = av_expr_eval(ow_expr, var_values, NULL);
143  var_values[VAR_OVERLAY_H] =
144  var_values[VAR_OH] = av_expr_eval(oh_expr, var_values, NULL);
145  var_values[VAR_OVERLAY_W] =
146  var_values[VAR_OW] = av_expr_eval(ow_expr, var_values, NULL);
147 
148 release:
149  av_expr_free(ox_expr);
150  av_expr_free(oy_expr);
151  av_expr_free(ow_expr);
152  av_expr_free(oh_expr);
153 
154  return ret;
155 }
156 
158 {
160  const AVPixFmtDescriptor *desc;
161  AVHWFramesContext *fctx;
162 
163  if (link->format == AV_PIX_FMT_QSV) {
165  pix_fmt = fctx->sw_format;
166  }
167 
169  if (!desc)
170  return 0;
171 
172  return !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA);
173 }
174 
176 {
177  AVFilterContext *ctx = inlink->dst;
178  QSVOverlayContext *vpp = ctx->priv;
179  mfxVPPCompInputStream *st = &vpp->comp_conf.InputStream[0];
180 
181  av_log(ctx, AV_LOG_DEBUG, "Input[%d] is of %s.\n", FF_INLINK_IDX(inlink),
182  av_get_pix_fmt_name(inlink->format));
183 
184  vpp->var_values[VAR_MAIN_iW] =
185  vpp->var_values[VAR_MW] = inlink->w;
186  vpp->var_values[VAR_MAIN_iH] =
187  vpp->var_values[VAR_MH] = inlink->h;
188 
189  st->DstX = 0;
190  st->DstY = 0;
191  st->DstW = inlink->w;
192  st->DstH = inlink->h;
193  st->GlobalAlphaEnable = 0;
194  st->PixelAlphaEnable = 0;
195 
196  return 0;
197 }
198 
200 {
201  AVFilterContext *ctx = inlink->dst;
202  QSVOverlayContext *vpp = ctx->priv;
203  mfxVPPCompInputStream *st = &vpp->comp_conf.InputStream[1];
204  int ret = 0;
205 
206  av_log(ctx, AV_LOG_DEBUG, "Input[%d] is of %s.\n", FF_INLINK_IDX(inlink),
207  av_get_pix_fmt_name(inlink->format));
208 
209  vpp->var_values[VAR_OVERLAY_iW] = inlink->w;
210  vpp->var_values[VAR_OVERLAY_iH] = inlink->h;
211 
212  ret = eval_expr(ctx);
213  if (ret < 0)
214  return ret;
215 
216  st->DstX = vpp->var_values[VAR_OX];
217  st->DstY = vpp->var_values[VAR_OY];
218  st->DstW = vpp->var_values[VAR_OW];
219  st->DstH = vpp->var_values[VAR_OH];
220  st->GlobalAlpha = vpp->overlay_alpha;
221  st->GlobalAlphaEnable = (st->GlobalAlpha < 255);
222  st->PixelAlphaEnable = have_alpha_planar(inlink);
223 
224  return 0;
225 }
226 
228 {
229  AVFilterContext *ctx = fs->parent;
230  QSVVPPContext *qsv = fs->opaque;
231  AVFrame *frame = NULL;
232  int ret = 0, i;
233 
234  for (i = 0; i < ctx->nb_inputs; i++) {
236  if (ret == 0)
237  ret = ff_qsvvpp_filter_frame(qsv, ctx->inputs[i], frame);
238  if (ret < 0 && ret != AVERROR(EAGAIN))
239  break;
240  }
241 
242  return ret;
243 }
244 
246 {
247  QSVOverlayContext *s = ctx->priv;
248  int ret, i;
249 
250  s->fs.on_event = process_frame;
251  s->fs.opaque = s;
252  ret = ff_framesync_init(&s->fs, ctx, ctx->nb_inputs);
253  if (ret < 0)
254  return ret;
255 
256  for (i = 0; i < ctx->nb_inputs; i++) {
257  FFFrameSyncIn *in = &s->fs.in[i];
258  in->before = EXT_STOP;
259  in->after = EXT_INFINITY;
260  in->sync = i ? 1 : 2;
261  in->time_base = ctx->inputs[i]->time_base;
262  }
263 
264  return ff_framesync_configure(&s->fs);
265 }
266 
267 static int config_output(AVFilterLink *outlink)
268 {
269  AVFilterContext *ctx = outlink->src;
270  QSVOverlayContext *vpp = ctx->priv;
271  AVFilterLink *in0 = ctx->inputs[0];
272  AVFilterLink *in1 = ctx->inputs[1];
273  int ret;
274 
275  av_log(ctx, AV_LOG_DEBUG, "Output is of %s.\n", av_get_pix_fmt_name(outlink->format));
276  vpp->qsv_param.out_sw_format = in0->format;
277  if ((in0->format == AV_PIX_FMT_QSV && in1->format != AV_PIX_FMT_QSV) ||
278  (in0->format != AV_PIX_FMT_QSV && in1->format == AV_PIX_FMT_QSV)) {
279  av_log(ctx, AV_LOG_ERROR, "Mixing hardware and software pixel formats is not supported.\n");
280  return AVERROR(EINVAL);
281  } else if (in0->format == AV_PIX_FMT_QSV) {
284 
285  if (hw_frame0->device_ctx != hw_frame1->device_ctx) {
286  av_log(ctx, AV_LOG_ERROR, "Inputs with different underlying QSV devices are forbidden.\n");
287  return AVERROR(EINVAL);
288  }
289  vpp->qsv_param.out_sw_format = hw_frame0->sw_format;
290  }
291 
292  outlink->w = vpp->var_values[VAR_MW];
293  outlink->h = vpp->var_values[VAR_MH];
294  outlink->frame_rate = in0->frame_rate;
295  outlink->time_base = av_inv_q(outlink->frame_rate);
296 
298  if (ret < 0)
299  return ret;
300 
301  return ff_qsvvpp_init(ctx, &vpp->qsv_param);
302 }
303 
304 /*
305  * Callback for qsvvpp
306  * @Note: qsvvpp composition does not generate PTS for result frame.
307  * so we assign the PTS from framesync to the output frame.
308  */
309 
311 {
312  QSVOverlayContext *s = outlink->src->priv;
313  frame->pts = av_rescale_q(s->fs.pts,
314  s->fs.time_base, outlink->time_base);
315  return ff_filter_frame(outlink, frame);
316 }
317 
318 
320 {
321  QSVOverlayContext *vpp = ctx->priv;
322 
323  /* fill composite config */
324  vpp->comp_conf.Header.BufferId = MFX_EXTBUFF_VPP_COMPOSITE;
325  vpp->comp_conf.Header.BufferSz = sizeof(vpp->comp_conf);
326  vpp->comp_conf.NumInputStream = ctx->nb_inputs;
327  vpp->comp_conf.InputStream = av_calloc(ctx->nb_inputs,
328  sizeof(*vpp->comp_conf.InputStream));
329  if (!vpp->comp_conf.InputStream)
330  return AVERROR(ENOMEM);
331 
332  /* initialize QSVVPP params */
334  vpp->qsv_param.ext_buf = av_mallocz(sizeof(*vpp->qsv_param.ext_buf));
335  if (!vpp->qsv_param.ext_buf)
336  return AVERROR(ENOMEM);
337 
338  vpp->qsv_param.ext_buf[0] = (mfxExtBuffer *)&vpp->comp_conf;
339  vpp->qsv_param.num_ext_buf = 1;
341  vpp->qsv_param.num_crop = 0;
342 
343  return 0;
344 }
345 
347 {
348  QSVOverlayContext *vpp = ctx->priv;
349 
351  ff_framesync_uninit(&vpp->fs);
352  av_freep(&vpp->comp_conf.InputStream);
353  av_freep(&vpp->qsv_param.ext_buf);
354 }
355 
357 {
358  QSVOverlayContext *s = ctx->priv;
359  return ff_framesync_activate(&s->fs);
360 }
361 
363 {
364  int i;
365  int ret;
366 
367  static const enum AVPixelFormat main_in_fmts[] = {
374  };
375  static const enum AVPixelFormat out_pix_fmts[] = {
379  };
380 
381  for (i = 0; i < ctx->nb_inputs; i++) {
382  ret = ff_formats_ref(ff_make_format_list(main_in_fmts), &ctx->inputs[i]->outcfg.formats);
383  if (ret < 0)
384  return ret;
385  }
386 
387  ret = ff_formats_ref(ff_make_format_list(out_pix_fmts), &ctx->outputs[0]->incfg.formats);
388  if (ret < 0)
389  return ret;
390 
391  return 0;
392 }
393 
394 static const AVFilterPad overlay_qsv_inputs[] = {
395  {
396  .name = "main",
397  .type = AVMEDIA_TYPE_VIDEO,
398  .config_props = config_main_input,
399  .get_buffer.video = ff_qsvvpp_get_video_buffer,
400  },
401  {
402  .name = "overlay",
403  .type = AVMEDIA_TYPE_VIDEO,
404  .config_props = config_overlay_input,
405  .get_buffer.video = ff_qsvvpp_get_video_buffer,
406  },
407 };
408 
410  {
411  .name = "default",
412  .type = AVMEDIA_TYPE_VIDEO,
413  .config_props = config_output,
414  },
415 };
416 
418  .name = "overlay_qsv",
419  .description = NULL_IF_CONFIG_SMALL("Quick Sync Video overlay."),
420  .priv_size = sizeof(QSVOverlayContext),
421  .preinit = overlay_qsv_framesync_preinit,
424  .activate = activate,
428  .priv_class = &overlay_qsv_class,
429  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
430  .flags = AVFILTER_FLAG_HWDEVICE,
431 };
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_overlay_qsv.c:267
VAR_OVERLAY_W
@ VAR_OVERLAY_W
Definition: vf_overlay_qsv.c:52
QSVOverlayContext::var_values
double var_values[VAR_VARS_NB]
Definition: vf_overlay_qsv.c:63
FFFrameSyncIn::time_base
AVRational time_base
Time base for the incoming frames.
Definition: framesync.h:117
ff_framesync_configure
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
Definition: framesync.c:134
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
AVERROR
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
opt.h
VAR_OX
@ VAR_OX
Definition: vf_overlay_qsv.c:50
var_name
var_name
Definition: noise.c:47
ff_make_format_list
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:436
VAR_OVERLAY_X
@ VAR_OVERLAY_X
Definition: vf_overlay_qsv.c:50
ff_framesync_uninit
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
Definition: framesync.c:304
FF_FILTER_FLAG_HWFRAME_AWARE
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
Definition: internal.h:351
QSVVPPParam::out_sw_format
enum AVPixelFormat out_sw_format
Definition: qsvvpp.h:120
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1015
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2965
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
FRAMESYNC_DEFINE_CLASS
FRAMESYNC_DEFINE_CLASS(overlay_qsv, QSVOverlayContext, fs)
QSVOverlayContext::overlay_oy
char * overlay_oy
Definition: vf_overlay_qsv.c:65
ff_framesync_get_frame
int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, unsigned get)
Get the current frame in an input.
Definition: framesync.c:267
var_names
static const char *const var_names[]
Definition: vf_overlay_qsv.c:70
ff_qsvvpp_get_video_buffer
AVFrame * ff_qsvvpp_get_video_buffer(AVFilterLink *inlink, int w, int h)
Definition: qsvvpp.c:1147
inlink
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
Definition: filter_design.txt:212
process_frame
static int process_frame(FFFrameSync *fs)
Definition: vf_overlay_qsv.c:227
VAR_OY
@ VAR_OY
Definition: vf_overlay_qsv.c:51
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:374
pixdesc.h
QSVOverlayContext::qsv
QSVVPPContext qsv
Definition: vf_overlay_qsv.c:58
AVOption
AVOption.
Definition: opt.h:346
EOF_ACTION_ENDALL
@ EOF_ACTION_ENDALL
Definition: framesync.h:28
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:159
QSVOverlayContext
Definition: vf_overlay_qsv.c:57
VAR_OVERLAY_iH
@ VAR_OVERLAY_iH
Definition: vf_overlay_qsv.c:49
preinit
static av_cold int preinit(AVFilterContext *ctx)
Definition: af_aresample.c:49
mathematics.h
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
FLAGS
#define FLAGS
Definition: vf_overlay_qsv.c:43
FFFrameSync
Frame sync structure.
Definition: framesync.h:168
EXT_INFINITY
@ EXT_INFINITY
Extend the frame to infinity.
Definition: framesync.h:75
OFFSET
#define OFFSET(x)
Definition: vf_overlay_qsv.c:42
config_overlay_input
static int config_overlay_input(AVFilterLink *inlink)
Definition: vf_overlay_qsv.c:199
formats.h
overlay_qsv_options
static const AVOption overlay_qsv_options[]
Definition: vf_overlay_qsv.c:82
EXT_STOP
@ EXT_STOP
Completely stop all streams with this one.
Definition: framesync.h:65
overlay_qsv_init
static int overlay_qsv_init(AVFilterContext *ctx)
Definition: vf_overlay_qsv.c:319
activate
static int activate(AVFilterContext *ctx)
Definition: vf_overlay_qsv.c:356
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:422
QSVOverlayContext::overlay_oh
char * overlay_oh
Definition: vf_overlay_qsv.c:65
qsvvpp.h
VAR_OW
@ VAR_OW
Definition: vf_overlay_qsv.c:52
FFFrameSyncIn
Input stream structure.
Definition: framesync.h:102
FFFrameSyncIn::sync
unsigned sync
Synchronization level: frames on input at the highest sync level will generate output frame events.
Definition: framesync.h:160
VAR_OVERLAY_Y
@ VAR_OVERLAY_Y
Definition: vf_overlay_qsv.c:51
av_expr_free
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
Definition: eval.c:358
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:33
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
QSVOverlayContext::overlay_pixel_alpha
uint16_t overlay_pixel_alpha
Definition: vf_overlay_qsv.c:66
av_cold
#define av_cold
Definition: attributes.h:90
s
#define s(width, name)
Definition: cbs_vp9.c:198
pix_fmt
static enum AVPixelFormat pix_fmt
Definition: demux_decode.c:41
ff_formats_ref
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add *ref as a new reference to formats.
Definition: formats.c:679
VAR_OVERLAY_iW
@ VAR_OVERLAY_iW
Definition: vf_overlay_qsv.c:48
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
AV_PIX_FMT_FLAG_ALPHA
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
Definition: pixdesc.h:147
ctx
AVFormatContext * ctx
Definition: movenc.c:49
av_expr_eval
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
Definition: eval.c:792
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
AVExpr
Definition: eval.c:158
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
EOF_ACTION_PASS
@ EOF_ACTION_PASS
Definition: framesync.h:29
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
link
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
Definition: filter_design.txt:23
QSVVPPContext
Definition: qsvvpp.h:63
init_framesync
static int init_framesync(AVFilterContext *ctx)
Definition: vf_overlay_qsv.c:245
ff_qsvvpp_close
int ff_qsvvpp_close(AVFilterContext *avctx)
Definition: qsvvpp.c:937
NULL
#define NULL
Definition: coverity.c:32
AVHWFramesContext::sw_format
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition: hwcontext.h:210
fs
#define fs(width, name, subs,...)
Definition: cbs_vp9.c:200
QSVVPPParam::num_crop
int num_crop
Definition: qsvvpp.h:123
QSVVPPParam
Definition: qsvvpp.h:110
QSVOverlayContext::overlay_alpha
uint16_t overlay_alpha
Definition: vf_overlay_qsv.c:66
AV_PIX_FMT_YUYV422
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:74
VAR_OH
@ VAR_OH
Definition: vf_overlay_qsv.c:53
VAR_MAIN_iW
@ VAR_MAIN_iW
Definition: vf_overlay_qsv.c:46
eval_expr
static int eval_expr(AVFilterContext *ctx)
Definition: vf_overlay_qsv.c:101
AV_PIX_FMT_QSV
@ AV_PIX_FMT_QSV
HW acceleration through QSV, data[3] contains a pointer to the mfxFrameSurface1 structure.
Definition: pixfmt.h:247
QSVOverlayContext::overlay_ow
char * overlay_ow
Definition: vf_overlay_qsv.c:65
eval.h
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:366
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
overlay_qsv_inputs
static const AVFilterPad overlay_qsv_inputs[]
Definition: vf_overlay_qsv.c:394
AVFILTER_FLAG_HWDEVICE
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
Definition: avfilter.h:138
overlay_qsv_outputs
static const AVFilterPad overlay_qsv_outputs[]
Definition: vf_overlay_qsv.c:409
config_main_input
static int config_main_input(AVFilterLink *inlink)
Definition: vf_overlay_qsv.c:175
QSVOverlayContext::comp_conf
mfxExtVPPComposite comp_conf
Definition: vf_overlay_qsv.c:62
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:461
have_alpha_planar
static int have_alpha_planar(AVFilterLink *link)
Definition: vf_overlay_qsv.c:157
VAR_VARS_NB
@ VAR_VARS_NB
Definition: vf_overlay_qsv.c:54
ff_vf_overlay_qsv
const AVFilter ff_vf_overlay_qsv
Definition: vf_overlay_qsv.c:417
AV_PIX_FMT_RGB32
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:451
QSVOverlayContext::overlay_ox
char * overlay_ox
Definition: vf_overlay_qsv.c:65
overlay_qsv_query_formats
static int overlay_qsv_query_formats(AVFilterContext *ctx)
Definition: vf_overlay_qsv.c:362
internal.h
QSVOverlayContext::fs
FFFrameSync fs
Definition: vf_overlay_qsv.c:60
uninit
static void uninit(AVBSFContext *ctx)
Definition: pcm_rechunk.c:68
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
filter_callback
static int filter_callback(AVFilterLink *outlink, AVFrame *frame)
Definition: vf_overlay_qsv.c:310
overlay_alpha
static const char overlay_alpha[]
Definition: vf_overlay_vulkan.c:67
common.h
out_pix_fmts
static enum AVPixelFormat out_pix_fmts[]
Definition: vf_ciescope.c:137
QSVVPPParam::num_ext_buf
int num_ext_buf
Definition: qsvvpp.h:116
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:256
av_inv_q
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
QSVVPPParam::filter_frame
int(* filter_frame)(AVFilterLink *outlink, AVFrame *frame)
Definition: qsvvpp.h:112
ff_qsvvpp_init
int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param)
Definition: qsvvpp.c:745
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:39
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:264
PASS_EXPR
#define PASS_EXPR(e, s)
AVFilter
Filter definition.
Definition: avfilter.h:166
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:115
ret
ret
Definition: filter_design.txt:187
AV_PIX_FMT_NV12
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:96
frame
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
Definition: filter_design.txt:264
AVHWFramesContext::device_ctx
AVHWDeviceContext * device_ctx
The parent AVHWDeviceContext.
Definition: hwcontext.h:134
VAR_MH
@ VAR_MH
Definition: vf_overlay_qsv.c:47
ff_framesync_init
int ff_framesync_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in)
Initialize a frame sync structure.
Definition: framesync.c:86
EOF_ACTION_REPEAT
@ EOF_ACTION_REPEAT
Definition: framesync.h:27
VAR_MW
@ VAR_MW
Definition: vf_overlay_qsv.c:46
AVFrame::hw_frames_ctx
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame.
Definition: frame.h:725
FFFrameSyncIn::before
enum FFFrameSyncExtMode before
Extrapolation mode for timestamps before the first frame.
Definition: framesync.h:107
framesync.h
ff_qsvvpp_filter_frame
int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *picref)
Definition: qsvvpp.c:961
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
FF_INLINK_IDX
#define FF_INLINK_IDX(link)
Find the index of a link.
Definition: internal.h:331
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
avfilter.h
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
desc
const char * desc
Definition: libsvtav1.c:79
VAR_OVERLAY_H
@ VAR_OVERLAY_H
Definition: vf_overlay_qsv.c:53
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
mem.h
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:251
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
hwcontext.h
VAR_MAIN_iH
@ VAR_MAIN_iH
Definition: vf_overlay_qsv.c:47
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
QSVOverlayContext::qsv_param
QSVVPPParam qsv_param
Definition: vf_overlay_qsv.c:61
FFFrameSyncIn::after
enum FFFrameSyncExtMode after
Extrapolation mode for timestamps after the last frame.
Definition: framesync.h:112
ff_framesync_activate
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
Definition: framesync.c:355
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:239
overlay_qsv_uninit
static av_cold void overlay_qsv_uninit(AVFilterContext *ctx)
Definition: vf_overlay_qsv.c:346
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:244
QSVVPPParam::ext_buf
mfxExtBuffer ** ext_buf
Definition: qsvvpp.h:117
av_get_pix_fmt_name
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.
Definition: pixdesc.c:2885