FFmpeg
vf_overlay.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010 Stefano Sabatini
3  * Copyright (c) 2010 Baptiste Coudurier
4  * Copyright (c) 2007 Bobby Bingham
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 /**
24  * @file
25  * overlay one video on top of another
26  */
27 
28 #include "avfilter.h"
29 #include "formats.h"
30 #include "libavutil/common.h"
31 #include "libavutil/eval.h"
32 #include "libavutil/avstring.h"
33 #include "libavutil/pixdesc.h"
34 #include "libavutil/imgutils.h"
35 #include "libavutil/mathematics.h"
36 #include "libavutil/opt.h"
37 #include "libavutil/timestamp.h"
38 #include "internal.h"
39 #include "drawutils.h"
40 #include "framesync.h"
41 #include "video.h"
42 #include "vf_overlay.h"
43 
44 typedef struct ThreadData {
45  AVFrame *dst, *src;
46 } ThreadData;
47 
48 static const char *const var_names[] = {
49  "main_w", "W", ///< width of the main video
50  "main_h", "H", ///< height of the main video
51  "overlay_w", "w", ///< width of the overlay video
52  "overlay_h", "h", ///< height of the overlay video
53  "hsub",
54  "vsub",
55  "x",
56  "y",
57  "n", ///< number of frame
58 #if FF_API_FRAME_PKT
59  "pos", ///< position in the file
60 #endif
61  "t", ///< timestamp expressed in seconds
62  NULL
63 };
64 
65 #define MAIN 0
66 #define OVERLAY 1
67 
68 #define R 0
69 #define G 1
70 #define B 2
71 #define A 3
72 
73 #define Y 0
74 #define U 1
75 #define V 2
76 
77 enum EvalMode {
81 };
82 
84 {
85  OverlayContext *s = ctx->priv;
86 
87  ff_framesync_uninit(&s->fs);
88  av_expr_free(s->x_pexpr); s->x_pexpr = NULL;
89  av_expr_free(s->y_pexpr); s->y_pexpr = NULL;
90 }
91 
92 static inline int normalize_xy(double d, int chroma_sub)
93 {
94  if (isnan(d))
95  return INT_MAX;
96  return (int)d & ~((1 << chroma_sub) - 1);
97 }
98 
100 {
101  OverlayContext *s = ctx->priv;
102 
103  s->var_values[VAR_X] = av_expr_eval(s->x_pexpr, s->var_values, NULL);
104  s->var_values[VAR_Y] = av_expr_eval(s->y_pexpr, s->var_values, NULL);
105  /* It is necessary if x is expressed from y */
106  s->var_values[VAR_X] = av_expr_eval(s->x_pexpr, s->var_values, NULL);
107  s->x = normalize_xy(s->var_values[VAR_X], s->hsub);
108  s->y = normalize_xy(s->var_values[VAR_Y], s->vsub);
109 }
110 
111 static int set_expr(AVExpr **pexpr, const char *expr, const char *option, void *log_ctx)
112 {
113  int ret;
114  AVExpr *old = NULL;
115 
116  if (*pexpr)
117  old = *pexpr;
118  ret = av_expr_parse(pexpr, expr, var_names,
119  NULL, NULL, NULL, NULL, 0, log_ctx);
120  if (ret < 0) {
121  av_log(log_ctx, AV_LOG_ERROR,
122  "Error when evaluating the expression '%s' for %s\n",
123  expr, option);
124  *pexpr = old;
125  return ret;
126  }
127 
128  av_expr_free(old);
129  return 0;
130 }
131 
132 static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
133  char *res, int res_len, int flags)
134 {
135  OverlayContext *s = ctx->priv;
136  int ret;
137 
138  if (!strcmp(cmd, "x"))
139  ret = set_expr(&s->x_pexpr, args, cmd, ctx);
140  else if (!strcmp(cmd, "y"))
141  ret = set_expr(&s->y_pexpr, args, cmd, ctx);
142  else
143  ret = AVERROR(ENOSYS);
144 
145  if (ret < 0)
146  return ret;
147 
148  if (s->eval_mode == EVAL_MODE_INIT) {
149  eval_expr(ctx);
150  av_log(ctx, AV_LOG_VERBOSE, "x:%f xi:%d y:%f yi:%d\n",
151  s->var_values[VAR_X], s->x,
152  s->var_values[VAR_Y], s->y);
153  }
154  return ret;
155 }
156 
157 static const enum AVPixelFormat alpha_pix_fmts[] = {
162 };
163 
165 {
166  OverlayContext *s = ctx->priv;
167 
168  /* overlay formats contains alpha, for avoiding conversion with alpha information loss */
169  static const enum AVPixelFormat main_pix_fmts_yuv420[] = {
173  };
174  static const enum AVPixelFormat overlay_pix_fmts_yuv420[] = {
176  };
177 
178  static const enum AVPixelFormat main_pix_fmts_yuv420p10[] = {
181  };
182  static const enum AVPixelFormat overlay_pix_fmts_yuv420p10[] = {
184  };
185 
186  static const enum AVPixelFormat main_pix_fmts_yuv422[] = {
188  };
189  static const enum AVPixelFormat overlay_pix_fmts_yuv422[] = {
191  };
192 
193  static const enum AVPixelFormat main_pix_fmts_yuv422p10[] = {
195  };
196  static const enum AVPixelFormat overlay_pix_fmts_yuv422p10[] = {
198  };
199 
200  static const enum AVPixelFormat main_pix_fmts_yuv444[] = {
202  };
203  static const enum AVPixelFormat overlay_pix_fmts_yuv444[] = {
205  };
206 
207  static const enum AVPixelFormat main_pix_fmts_gbrp[] = {
209  };
210  static const enum AVPixelFormat overlay_pix_fmts_gbrp[] = {
212  };
213 
214  static const enum AVPixelFormat main_pix_fmts_rgb[] = {
219  };
220  static const enum AVPixelFormat overlay_pix_fmts_rgb[] = {
224  };
225 
226  const enum AVPixelFormat *main_formats, *overlay_formats;
228  int ret;
229 
230  switch (s->format) {
232  main_formats = main_pix_fmts_yuv420;
233  overlay_formats = overlay_pix_fmts_yuv420;
234  break;
236  main_formats = main_pix_fmts_yuv420p10;
237  overlay_formats = overlay_pix_fmts_yuv420p10;
238  break;
240  main_formats = main_pix_fmts_yuv422;
241  overlay_formats = overlay_pix_fmts_yuv422;
242  break;
244  main_formats = main_pix_fmts_yuv422p10;
245  overlay_formats = overlay_pix_fmts_yuv422p10;
246  break;
248  main_formats = main_pix_fmts_yuv444;
249  overlay_formats = overlay_pix_fmts_yuv444;
250  break;
251  case OVERLAY_FORMAT_RGB:
252  main_formats = main_pix_fmts_rgb;
253  overlay_formats = overlay_pix_fmts_rgb;
254  break;
255  case OVERLAY_FORMAT_GBRP:
256  main_formats = main_pix_fmts_gbrp;
257  overlay_formats = overlay_pix_fmts_gbrp;
258  break;
259  case OVERLAY_FORMAT_AUTO:
261  default:
262  av_assert0(0);
263  }
264 
265  formats = ff_make_format_list(main_formats);
266  if ((ret = ff_formats_ref(formats, &ctx->inputs[MAIN]->outcfg.formats)) < 0 ||
267  (ret = ff_formats_ref(formats, &ctx->outputs[MAIN]->incfg.formats)) < 0)
268  return ret;
269 
270  return ff_formats_ref(ff_make_format_list(overlay_formats),
271  &ctx->inputs[OVERLAY]->outcfg.formats);
272 }
273 
275 {
276  AVFilterContext *ctx = inlink->dst;
277  OverlayContext *s = inlink->dst->priv;
278  int ret;
279  const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
280 
281  av_image_fill_max_pixsteps(s->overlay_pix_step, NULL, pix_desc);
282 
283  /* Finish the configuration by evaluating the expressions
284  now when both inputs are configured. */
285  s->var_values[VAR_MAIN_W ] = s->var_values[VAR_MW] = ctx->inputs[MAIN ]->w;
286  s->var_values[VAR_MAIN_H ] = s->var_values[VAR_MH] = ctx->inputs[MAIN ]->h;
287  s->var_values[VAR_OVERLAY_W] = s->var_values[VAR_OW] = ctx->inputs[OVERLAY]->w;
288  s->var_values[VAR_OVERLAY_H] = s->var_values[VAR_OH] = ctx->inputs[OVERLAY]->h;
289  s->var_values[VAR_HSUB] = 1<<pix_desc->log2_chroma_w;
290  s->var_values[VAR_VSUB] = 1<<pix_desc->log2_chroma_h;
291  s->var_values[VAR_X] = NAN;
292  s->var_values[VAR_Y] = NAN;
293  s->var_values[VAR_N] = 0;
294  s->var_values[VAR_T] = NAN;
295 #if FF_API_FRAME_PKT
296  s->var_values[VAR_POS] = NAN;
297 #endif
298 
299  if ((ret = set_expr(&s->x_pexpr, s->x_expr, "x", ctx)) < 0 ||
300  (ret = set_expr(&s->y_pexpr, s->y_expr, "y", ctx)) < 0)
301  return ret;
302 
303  s->overlay_is_packed_rgb =
304  ff_fill_rgba_map(s->overlay_rgba_map, inlink->format) >= 0;
305  s->overlay_has_alpha = ff_fmt_is_in(inlink->format, alpha_pix_fmts);
306 
307  if (s->eval_mode == EVAL_MODE_INIT) {
308  eval_expr(ctx);
309  av_log(ctx, AV_LOG_VERBOSE, "x:%f xi:%d y:%f yi:%d\n",
310  s->var_values[VAR_X], s->x,
311  s->var_values[VAR_Y], s->y);
312  }
313 
315  "main w:%d h:%d fmt:%s overlay w:%d h:%d fmt:%s\n",
316  ctx->inputs[MAIN]->w, ctx->inputs[MAIN]->h,
317  av_get_pix_fmt_name(ctx->inputs[MAIN]->format),
318  ctx->inputs[OVERLAY]->w, ctx->inputs[OVERLAY]->h,
319  av_get_pix_fmt_name(ctx->inputs[OVERLAY]->format));
320  return 0;
321 }
322 
323 static int config_output(AVFilterLink *outlink)
324 {
325  AVFilterContext *ctx = outlink->src;
326  OverlayContext *s = ctx->priv;
327  int ret;
328 
329  if ((ret = ff_framesync_init_dualinput(&s->fs, ctx)) < 0)
330  return ret;
331 
332  outlink->w = ctx->inputs[MAIN]->w;
333  outlink->h = ctx->inputs[MAIN]->h;
334  outlink->time_base = ctx->inputs[MAIN]->time_base;
335 
336  return ff_framesync_configure(&s->fs);
337 }
338 
339 // divide by 255 and round to nearest
340 // apply a fast variant: (X+127)/255 = ((X+127)*257+257)>>16 = ((X+128)*257)>>16
341 #define FAST_DIV255(x) ((((x) + 128) * 257) >> 16)
342 
343 // calculate the unpremultiplied alpha, applying the general equation:
344 // alpha = alpha_overlay / ( (alpha_main + alpha_overlay) - (alpha_main * alpha_overlay) )
345 // (((x) << 16) - ((x) << 9) + (x)) is a faster version of: 255 * 255 * x
346 // ((((x) + (y)) << 8) - ((x) + (y)) - (y) * (x)) is a faster version of: 255 * (x + y)
347 #define UNPREMULTIPLY_ALPHA(x, y) ((((x) << 16) - ((x) << 9) + (x)) / ((((x) + (y)) << 8) - ((x) + (y)) - (y) * (x)))
348 
349 /**
350  * Blend image in src to destination buffer dst at position (x, y).
351  */
352 
354  AVFrame *dst, const AVFrame *src,
355  int main_has_alpha, int x, int y,
356  int is_straight, int jobnr, int nb_jobs)
357 {
358  OverlayContext *s = ctx->priv;
359  int i, imax, j, jmax;
360  const int src_w = src->width;
361  const int src_h = src->height;
362  const int dst_w = dst->width;
363  const int dst_h = dst->height;
364  uint8_t alpha; ///< the amount of overlay to blend on to main
365  const int dr = s->main_rgba_map[R];
366  const int dg = s->main_rgba_map[G];
367  const int db = s->main_rgba_map[B];
368  const int da = s->main_rgba_map[A];
369  const int dstep = s->main_pix_step[0];
370  const int sr = s->overlay_rgba_map[R];
371  const int sg = s->overlay_rgba_map[G];
372  const int sb = s->overlay_rgba_map[B];
373  const int sa = s->overlay_rgba_map[A];
374  const int sstep = s->overlay_pix_step[0];
375  int slice_start, slice_end;
376  uint8_t *S, *sp, *d, *dp;
377 
378  i = FFMAX(-y, 0);
379  imax = FFMIN3(-y + dst_h, FFMIN(src_h, dst_h), y + src_h);
380 
381  slice_start = i + (imax * jobnr) / nb_jobs;
382  slice_end = i + (imax * (jobnr+1)) / nb_jobs;
383 
384  sp = src->data[0] + (slice_start) * src->linesize[0];
385  dp = dst->data[0] + (y + slice_start) * dst->linesize[0];
386 
387  for (i = slice_start; i < slice_end; i++) {
388  j = FFMAX(-x, 0);
389  S = sp + j * sstep;
390  d = dp + (x+j) * dstep;
391 
392  for (jmax = FFMIN(-x + dst_w, src_w); j < jmax; j++) {
393  alpha = S[sa];
394 
395  // if the main channel has an alpha channel, alpha has to be calculated
396  // to create an un-premultiplied (straight) alpha value
397  if (main_has_alpha && alpha != 0 && alpha != 255) {
398  uint8_t alpha_d = d[da];
399  alpha = UNPREMULTIPLY_ALPHA(alpha, alpha_d);
400  }
401 
402  switch (alpha) {
403  case 0:
404  break;
405  case 255:
406  d[dr] = S[sr];
407  d[dg] = S[sg];
408  d[db] = S[sb];
409  break;
410  default:
411  // main_value = main_value * (1 - alpha) + overlay_value * alpha
412  // since alpha is in the range 0-255, the result must divided by 255
413  d[dr] = is_straight ? FAST_DIV255(d[dr] * (255 - alpha) + S[sr] * alpha) :
414  FFMIN(FAST_DIV255(d[dr] * (255 - alpha)) + S[sr], 255);
415  d[dg] = is_straight ? FAST_DIV255(d[dg] * (255 - alpha) + S[sg] * alpha) :
416  FFMIN(FAST_DIV255(d[dg] * (255 - alpha)) + S[sg], 255);
417  d[db] = is_straight ? FAST_DIV255(d[db] * (255 - alpha) + S[sb] * alpha) :
418  FFMIN(FAST_DIV255(d[db] * (255 - alpha)) + S[sb], 255);
419  }
420  if (main_has_alpha) {
421  switch (alpha) {
422  case 0:
423  break;
424  case 255:
425  d[da] = S[sa];
426  break;
427  default:
428  // apply alpha compositing: main_alpha += (1-main_alpha) * overlay_alpha
429  d[da] += FAST_DIV255((255 - d[da]) * S[sa]);
430  }
431  }
432  d += dstep;
433  S += sstep;
434  }
435  dp += dst->linesize[0];
436  sp += src->linesize[0];
437  }
438 }
439 
440 #define DEFINE_BLEND_PLANE(depth, nbits) \
441 static av_always_inline void blend_plane_##depth##_##nbits##bits(AVFilterContext *ctx, \
442  AVFrame *dst, const AVFrame *src, \
443  int src_w, int src_h, \
444  int dst_w, int dst_h, \
445  int i, int hsub, int vsub, \
446  int x, int y, \
447  int main_has_alpha, \
448  int dst_plane, \
449  int dst_offset, \
450  int dst_step, \
451  int straight, \
452  int yuv, \
453  int jobnr, \
454  int nb_jobs) \
455 { \
456  OverlayContext *octx = ctx->priv; \
457  int src_wp = AV_CEIL_RSHIFT(src_w, hsub); \
458  int src_hp = AV_CEIL_RSHIFT(src_h, vsub); \
459  int dst_wp = AV_CEIL_RSHIFT(dst_w, hsub); \
460  int dst_hp = AV_CEIL_RSHIFT(dst_h, vsub); \
461  int yp = y>>vsub; \
462  int xp = x>>hsub; \
463  uint##depth##_t *s, *sp, *d, *dp, *dap, *a, *da, *ap; \
464  int jmax, j, k, kmax; \
465  int slice_start, slice_end; \
466  const uint##depth##_t max = (1 << nbits) - 1; \
467  const uint##depth##_t mid = (1 << (nbits -1)) ; \
468  int bytes = depth / 8; \
469  \
470  dst_step /= bytes; \
471  j = FFMAX(-yp, 0); \
472  jmax = FFMIN3(-yp + dst_hp, FFMIN(src_hp, dst_hp), yp + src_hp); \
473  \
474  slice_start = j + (jmax * jobnr) / nb_jobs; \
475  slice_end = j + (jmax * (jobnr+1)) / nb_jobs; \
476  \
477  sp = (uint##depth##_t *)(src->data[i] + (slice_start) * src->linesize[i]); \
478  dp = (uint##depth##_t *)(dst->data[dst_plane] \
479  + (yp + slice_start) * dst->linesize[dst_plane] \
480  + dst_offset); \
481  ap = (uint##depth##_t *)(src->data[3] + (slice_start << vsub) * src->linesize[3]); \
482  dap = (uint##depth##_t *)(dst->data[3] + ((yp + slice_start) << vsub) * dst->linesize[3]); \
483  \
484  for (j = slice_start; j < slice_end; j++) { \
485  k = FFMAX(-xp, 0); \
486  d = dp + (xp+k) * dst_step; \
487  s = sp + k; \
488  a = ap + (k<<hsub); \
489  da = dap + ((xp+k) << hsub); \
490  kmax = FFMIN(-xp + dst_wp, src_wp); \
491  \
492  if (nbits == 8 && ((vsub && j+1 < src_hp) || !vsub) && octx->blend_row[i]) { \
493  int c = octx->blend_row[i]((uint8_t*)d, (uint8_t*)da, (uint8_t*)s, \
494  (uint8_t*)a, kmax - k, src->linesize[3]); \
495  \
496  s += c; \
497  d += dst_step * c; \
498  da += (1 << hsub) * c; \
499  a += (1 << hsub) * c; \
500  k += c; \
501  } \
502  for (; k < kmax; k++) { \
503  int alpha_v, alpha_h, alpha; \
504  \
505  /* average alpha for color components, improve quality */ \
506  if (hsub && vsub && j+1 < src_hp && k+1 < src_wp) { \
507  alpha = (a[0] + a[src->linesize[3]] + \
508  a[1] + a[src->linesize[3]+1]) >> 2; \
509  } else if (hsub || vsub) { \
510  alpha_h = hsub && k+1 < src_wp ? \
511  (a[0] + a[1]) >> 1 : a[0]; \
512  alpha_v = vsub && j+1 < src_hp ? \
513  (a[0] + a[src->linesize[3]]) >> 1 : a[0]; \
514  alpha = (alpha_v + alpha_h) >> 1; \
515  } else \
516  alpha = a[0]; \
517  /* if the main channel has an alpha channel, alpha has to be calculated */ \
518  /* to create an un-premultiplied (straight) alpha value */ \
519  if (main_has_alpha && alpha != 0 && alpha != max) { \
520  /* average alpha for color components, improve quality */ \
521  uint8_t alpha_d; \
522  if (hsub && vsub && j+1 < src_hp && k+1 < src_wp) { \
523  alpha_d = (da[0] + da[dst->linesize[3]] + \
524  da[1] + da[dst->linesize[3]+1]) >> 2; \
525  } else if (hsub || vsub) { \
526  alpha_h = hsub && k+1 < src_wp ? \
527  (da[0] + da[1]) >> 1 : da[0]; \
528  alpha_v = vsub && j+1 < src_hp ? \
529  (da[0] + da[dst->linesize[3]]) >> 1 : da[0]; \
530  alpha_d = (alpha_v + alpha_h) >> 1; \
531  } else \
532  alpha_d = da[0]; \
533  alpha = UNPREMULTIPLY_ALPHA(alpha, alpha_d); \
534  } \
535  if (straight) { \
536  if (nbits > 8) \
537  *d = (*d * (max - alpha) + *s * alpha) / max; \
538  else \
539  *d = FAST_DIV255(*d * (255 - alpha) + *s * alpha); \
540  } else { \
541  if (nbits > 8) { \
542  if (i && yuv) \
543  *d = av_clip((*d * (max - alpha) + *s * alpha) / max + *s - mid, -mid, mid) + mid; \
544  else \
545  *d = av_clip_uintp2((*d * (max - alpha) + *s * alpha) / max + *s - (16<<(nbits-8)),\
546  nbits);\
547  } else { \
548  if (i && yuv) \
549  *d = av_clip(FAST_DIV255((*d - mid) * (max - alpha)) + *s - mid, -mid, mid) + mid; \
550  else \
551  *d = av_clip_uint8(FAST_DIV255(*d * (255 - alpha)) + *s - 16); \
552  } \
553  } \
554  s++; \
555  d += dst_step; \
556  da += 1 << hsub; \
557  a += 1 << hsub; \
558  } \
559  dp += dst->linesize[dst_plane] / bytes; \
560  sp += src->linesize[i] / bytes; \
561  ap += (1 << vsub) * src->linesize[3] / bytes; \
562  dap += (1 << vsub) * dst->linesize[3] / bytes; \
563  } \
564 }
565 DEFINE_BLEND_PLANE(8, 8)
566 DEFINE_BLEND_PLANE(16, 10)
567 
568 #define DEFINE_ALPHA_COMPOSITE(depth, nbits) \
569 static inline void alpha_composite_##depth##_##nbits##bits(const AVFrame *src, const AVFrame *dst, \
570  int src_w, int src_h, \
571  int dst_w, int dst_h, \
572  int x, int y, \
573  int jobnr, int nb_jobs) \
574 { \
575  uint##depth##_t alpha; /* the amount of overlay to blend on to main */ \
576  uint##depth##_t *s, *sa, *d, *da; \
577  int i, imax, j, jmax; \
578  int slice_start, slice_end; \
579  const uint##depth##_t max = (1 << nbits) - 1; \
580  int bytes = depth / 8; \
581  \
582  imax = FFMIN3(-y + dst_h, FFMIN(src_h, dst_h), y + src_h); \
583  i = FFMAX(-y, 0); \
584  \
585  slice_start = i + (imax * jobnr) / nb_jobs; \
586  slice_end = i + ((imax * (jobnr+1)) / nb_jobs); \
587  \
588  sa = (uint##depth##_t *)(src->data[3] + (slice_start) * src->linesize[3]); \
589  da = (uint##depth##_t *)(dst->data[3] + (y + slice_start) * dst->linesize[3]); \
590  \
591  for (i = slice_start; i < slice_end; i++) { \
592  j = FFMAX(-x, 0); \
593  s = sa + j; \
594  d = da + x+j; \
595  \
596  for (jmax = FFMIN(-x + dst_w, src_w); j < jmax; j++) { \
597  alpha = *s; \
598  if (alpha != 0 && alpha != max) { \
599  uint8_t alpha_d = *d; \
600  alpha = UNPREMULTIPLY_ALPHA(alpha, alpha_d); \
601  } \
602  if (alpha == max) \
603  *d = *s; \
604  else if (alpha > 0) { \
605  /* apply alpha compositing: main_alpha += (1-main_alpha) * overlay_alpha */ \
606  if (nbits > 8) \
607  *d += (max - *d) * *s / max; \
608  else \
609  *d += FAST_DIV255((max - *d) * *s); \
610  } \
611  d += 1; \
612  s += 1; \
613  } \
614  da += dst->linesize[3] / bytes; \
615  sa += src->linesize[3] / bytes; \
616  } \
617 }
620 
621 #define DEFINE_BLEND_SLICE_YUV(depth, nbits) \
622 static av_always_inline void blend_slice_yuv_##depth##_##nbits##bits(AVFilterContext *ctx, \
623  AVFrame *dst, const AVFrame *src, \
624  int hsub, int vsub, \
625  int main_has_alpha, \
626  int x, int y, \
627  int is_straight, \
628  int jobnr, int nb_jobs) \
629 { \
630  OverlayContext *s = ctx->priv; \
631  const int src_w = src->width; \
632  const int src_h = src->height; \
633  const int dst_w = dst->width; \
634  const int dst_h = dst->height; \
635  \
636  blend_plane_##depth##_##nbits##bits(ctx, dst, src, src_w, src_h, dst_w, dst_h, 0, 0, 0, \
637  x, y, main_has_alpha, s->main_desc->comp[0].plane, s->main_desc->comp[0].offset, \
638  s->main_desc->comp[0].step, is_straight, 1, jobnr, nb_jobs); \
639  blend_plane_##depth##_##nbits##bits(ctx, dst, src, src_w, src_h, dst_w, dst_h, 1, hsub, vsub, \
640  x, y, main_has_alpha, s->main_desc->comp[1].plane, s->main_desc->comp[1].offset, \
641  s->main_desc->comp[1].step, is_straight, 1, jobnr, nb_jobs); \
642  blend_plane_##depth##_##nbits##bits(ctx, dst, src, src_w, src_h, dst_w, dst_h, 2, hsub, vsub, \
643  x, y, main_has_alpha, s->main_desc->comp[2].plane, s->main_desc->comp[2].offset, \
644  s->main_desc->comp[2].step, is_straight, 1, jobnr, nb_jobs); \
645  \
646  if (main_has_alpha) \
647  alpha_composite_##depth##_##nbits##bits(src, dst, src_w, src_h, dst_w, dst_h, x, y, \
648  jobnr, nb_jobs); \
649 }
652 
654  AVFrame *dst, const AVFrame *src,
655  int hsub, int vsub,
656  int main_has_alpha,
657  int x, int y,
658  int is_straight,
659  int jobnr,
660  int nb_jobs)
661 {
662  OverlayContext *s = ctx->priv;
663  const int src_w = src->width;
664  const int src_h = src->height;
665  const int dst_w = dst->width;
666  const int dst_h = dst->height;
667 
668  blend_plane_8_8bits(ctx, dst, src, src_w, src_h, dst_w, dst_h, 0, 0, 0, x, y, main_has_alpha,
669  s->main_desc->comp[1].plane, s->main_desc->comp[1].offset, s->main_desc->comp[1].step, is_straight, 0,
670  jobnr, nb_jobs);
671  blend_plane_8_8bits(ctx, dst, src, src_w, src_h, dst_w, dst_h, 1, hsub, vsub, x, y, main_has_alpha,
672  s->main_desc->comp[2].plane, s->main_desc->comp[2].offset, s->main_desc->comp[2].step, is_straight, 0,
673  jobnr, nb_jobs);
674  blend_plane_8_8bits(ctx, dst, src, src_w, src_h, dst_w, dst_h, 2, hsub, vsub, x, y, main_has_alpha,
675  s->main_desc->comp[0].plane, s->main_desc->comp[0].offset, s->main_desc->comp[0].step, is_straight, 0,
676  jobnr, nb_jobs);
677 
678  if (main_has_alpha)
679  alpha_composite_8_8bits(src, dst, src_w, src_h, dst_w, dst_h, x, y, jobnr, nb_jobs);
680 }
681 
682 static int blend_slice_yuv420(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
683 {
684  OverlayContext *s = ctx->priv;
685  ThreadData *td = arg;
686  blend_slice_yuv_8_8bits(ctx, td->dst, td->src, 1, 1, 0, s->x, s->y, 1, jobnr, nb_jobs);
687  return 0;
688 }
689 
690 static int blend_slice_yuva420(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
691 {
692  OverlayContext *s = ctx->priv;
693  ThreadData *td = arg;
694  blend_slice_yuv_8_8bits(ctx, td->dst, td->src, 1, 1, 1, s->x, s->y, 1, jobnr, nb_jobs);
695  return 0;
696 }
697 
698 static int blend_slice_yuv420p10(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
699 {
700  OverlayContext *s = ctx->priv;
701  ThreadData *td = arg;
702  blend_slice_yuv_16_10bits(ctx, td->dst, td->src, 1, 1, 0, s->x, s->y, 1, jobnr, nb_jobs);
703  return 0;
704 }
705 
706 static int blend_slice_yuva420p10(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
707 {
708  OverlayContext *s = ctx->priv;
709  ThreadData *td = arg;
710  blend_slice_yuv_16_10bits(ctx, td->dst, td->src, 1, 1, 1, s->x, s->y, 1, jobnr, nb_jobs);
711  return 0;
712 }
713 
714 static int blend_slice_yuv422p10(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
715 {
716  OverlayContext *s = ctx->priv;
717  ThreadData *td = arg;
718  blend_slice_yuv_16_10bits(ctx, td->dst, td->src, 1, 0, 0, s->x, s->y, 1, jobnr, nb_jobs);
719  return 0;
720 }
721 
722 static int blend_slice_yuva422p10(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
723 {
724  OverlayContext *s = ctx->priv;
725  ThreadData *td = arg;
726  blend_slice_yuv_16_10bits(ctx, td->dst, td->src, 1, 0, 1, s->x, s->y, 1, jobnr, nb_jobs);
727  return 0;
728 }
729 
730 static int blend_slice_yuv422(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
731 {
732  OverlayContext *s = ctx->priv;
733  ThreadData *td = arg;
734  blend_slice_yuv_8_8bits(ctx, td->dst, td->src, 1, 0, 0, s->x, s->y, 1, jobnr, nb_jobs);
735  return 0;
736 }
737 
738 static int blend_slice_yuva422(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
739 {
740  OverlayContext *s = ctx->priv;
741  ThreadData *td = arg;
742  blend_slice_yuv_8_8bits(ctx, td->dst, td->src, 1, 0, 1, s->x, s->y, 1, jobnr, nb_jobs);
743  return 0;
744 }
745 
746 static int blend_slice_yuv444(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
747 {
748  OverlayContext *s = ctx->priv;
749  ThreadData *td = arg;
750  blend_slice_yuv_8_8bits(ctx, td->dst, td->src, 0, 0, 0, s->x, s->y, 1, jobnr, nb_jobs);
751  return 0;
752 }
753 
754 static int blend_slice_yuva444(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
755 {
756  OverlayContext *s = ctx->priv;
757  ThreadData *td = arg;
758  blend_slice_yuv_8_8bits(ctx, td->dst, td->src, 0, 0, 1, s->x, s->y, 1, jobnr, nb_jobs);
759  return 0;
760 }
761 
762 static int blend_slice_gbrp(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
763 {
764  OverlayContext *s = ctx->priv;
765  ThreadData *td = arg;
766  blend_slice_planar_rgb(ctx, td->dst, td->src, 0, 0, 0, s->x, s->y, 1, jobnr, nb_jobs);
767  return 0;
768 }
769 
770 static int blend_slice_gbrap(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
771 {
772  OverlayContext *s = ctx->priv;
773  ThreadData *td = arg;
774  blend_slice_planar_rgb(ctx, td->dst, td->src, 0, 0, 1, s->x, s->y, 1, jobnr, nb_jobs);
775  return 0;
776 }
777 
778 static int blend_slice_yuv420_pm(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
779 {
780  OverlayContext *s = ctx->priv;
781  ThreadData *td = arg;
782  blend_slice_yuv_8_8bits(ctx, td->dst, td->src, 1, 1, 0, s->x, s->y, 0, jobnr, nb_jobs);
783  return 0;
784 }
785 
786 static int blend_slice_yuva420_pm(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
787 {
788  OverlayContext *s = ctx->priv;
789  ThreadData *td = arg;
790  blend_slice_yuv_8_8bits(ctx, td->dst, td->src, 1, 1, 1, s->x, s->y, 0, jobnr, nb_jobs);
791  return 0;
792 }
793 
794 static int blend_slice_yuv422_pm(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
795 {
796  OverlayContext *s = ctx->priv;
797  ThreadData *td = arg;
798  blend_slice_yuv_8_8bits(ctx, td->dst, td->src, 1, 0, 0, s->x, s->y, 0, jobnr, nb_jobs);
799  return 0;
800 }
801 
802 static int blend_slice_yuva422_pm(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
803 {
804  OverlayContext *s = ctx->priv;
805  ThreadData *td = arg;
806  blend_slice_yuv_8_8bits(ctx, td->dst, td->src, 1, 0, 1, s->x, s->y, 0, jobnr, nb_jobs);
807  return 0;
808 }
809 
810 static int blend_slice_yuv444_pm(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
811 {
812  OverlayContext *s = ctx->priv;
813  ThreadData *td = arg;
814  blend_slice_yuv_8_8bits(ctx, td->dst, td->src, 0, 0, 0, s->x, s->y, 0, jobnr, nb_jobs);
815  return 0;
816 }
817 
818 static int blend_slice_yuva444_pm(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
819 {
820  OverlayContext *s = ctx->priv;
821  ThreadData *td = arg;
822  blend_slice_yuv_8_8bits(ctx, td->dst, td->src, 0, 0, 1, s->x, s->y, 0, jobnr, nb_jobs);
823  return 0;
824 }
825 
826 static int blend_slice_gbrp_pm(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
827 {
828  OverlayContext *s = ctx->priv;
829  ThreadData *td = arg;
830  blend_slice_planar_rgb(ctx, td->dst, td->src, 0, 0, 0, s->x, s->y, 0, jobnr, nb_jobs);
831  return 0;
832 }
833 
834 static int blend_slice_gbrap_pm(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
835 {
836  OverlayContext *s = ctx->priv;
837  ThreadData *td = arg;
838  blend_slice_planar_rgb(ctx, td->dst, td->src, 0, 0, 1, s->x, s->y, 0, jobnr, nb_jobs);
839  return 0;
840 }
841 
842 static int blend_slice_rgb(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
843 {
844  OverlayContext *s = ctx->priv;
845  ThreadData *td = arg;
846  blend_slice_packed_rgb(ctx, td->dst, td->src, 0, s->x, s->y, 1, jobnr, nb_jobs);
847  return 0;
848 }
849 
850 static int blend_slice_rgba(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
851 {
852  OverlayContext *s = ctx->priv;
853  ThreadData *td = arg;
854  blend_slice_packed_rgb(ctx, td->dst, td->src, 1, s->x, s->y, 1, jobnr, nb_jobs);
855  return 0;
856 }
857 
858 static int blend_slice_rgb_pm(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
859 {
860  OverlayContext *s = ctx->priv;
861  ThreadData *td = arg;
862  blend_slice_packed_rgb(ctx, td->dst, td->src, 0, s->x, s->y, 0, jobnr, nb_jobs);
863  return 0;
864 }
865 
866 static int blend_slice_rgba_pm(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
867 {
868  OverlayContext *s = ctx->priv;
869  ThreadData *td = arg;
870  blend_slice_packed_rgb(ctx, td->dst, td->src, 1, s->x, s->y, 0, jobnr, nb_jobs);
871  return 0;
872 }
873 
875 {
876  OverlayContext *s = inlink->dst->priv;
877  const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
878 
879  av_image_fill_max_pixsteps(s->main_pix_step, NULL, pix_desc);
880 
881  s->hsub = pix_desc->log2_chroma_w;
882  s->vsub = pix_desc->log2_chroma_h;
883 
884  s->main_desc = pix_desc;
885 
886  s->main_is_packed_rgb =
887  ff_fill_rgba_map(s->main_rgba_map, inlink->format) >= 0;
888  s->main_has_alpha = ff_fmt_is_in(inlink->format, alpha_pix_fmts);
889  switch (s->format) {
891  s->blend_slice = s->main_has_alpha ? blend_slice_yuva420 : blend_slice_yuv420;
892  break;
894  s->blend_slice = s->main_has_alpha ? blend_slice_yuva420p10 : blend_slice_yuv420p10;
895  break;
897  s->blend_slice = s->main_has_alpha ? blend_slice_yuva422 : blend_slice_yuv422;
898  break;
900  s->blend_slice = s->main_has_alpha ? blend_slice_yuva422p10 : blend_slice_yuv422p10;
901  break;
903  s->blend_slice = s->main_has_alpha ? blend_slice_yuva444 : blend_slice_yuv444;
904  break;
905  case OVERLAY_FORMAT_RGB:
906  s->blend_slice = s->main_has_alpha ? blend_slice_rgba : blend_slice_rgb;
907  break;
908  case OVERLAY_FORMAT_GBRP:
909  s->blend_slice = s->main_has_alpha ? blend_slice_gbrap : blend_slice_gbrp;
910  break;
911  case OVERLAY_FORMAT_AUTO:
912  switch (inlink->format) {
913  case AV_PIX_FMT_YUVA420P:
914  s->blend_slice = blend_slice_yuva420;
915  break;
917  s->blend_slice = blend_slice_yuva420p10;
918  break;
919  case AV_PIX_FMT_YUVA422P:
920  s->blend_slice = blend_slice_yuva422;
921  break;
923  s->blend_slice = blend_slice_yuva422p10;
924  break;
925  case AV_PIX_FMT_YUVA444P:
926  s->blend_slice = blend_slice_yuva444;
927  break;
928  case AV_PIX_FMT_ARGB:
929  case AV_PIX_FMT_RGBA:
930  case AV_PIX_FMT_BGRA:
931  case AV_PIX_FMT_ABGR:
932  s->blend_slice = blend_slice_rgba;
933  break;
934  case AV_PIX_FMT_GBRAP:
935  s->blend_slice = blend_slice_gbrap;
936  break;
937  default:
938  av_assert0(0);
939  break;
940  }
941  break;
942  }
943 
944  if (!s->alpha_format)
945  goto end;
946 
947  switch (s->format) {
949  s->blend_slice = s->main_has_alpha ? blend_slice_yuva420_pm : blend_slice_yuv420_pm;
950  break;
952  s->blend_slice = s->main_has_alpha ? blend_slice_yuva422_pm : blend_slice_yuv422_pm;
953  break;
955  s->blend_slice = s->main_has_alpha ? blend_slice_yuva444_pm : blend_slice_yuv444_pm;
956  break;
957  case OVERLAY_FORMAT_RGB:
958  s->blend_slice = s->main_has_alpha ? blend_slice_rgba_pm : blend_slice_rgb_pm;
959  break;
960  case OVERLAY_FORMAT_GBRP:
961  s->blend_slice = s->main_has_alpha ? blend_slice_gbrap_pm : blend_slice_gbrp_pm;
962  break;
963  case OVERLAY_FORMAT_AUTO:
964  switch (inlink->format) {
965  case AV_PIX_FMT_YUVA420P:
966  s->blend_slice = blend_slice_yuva420_pm;
967  break;
968  case AV_PIX_FMT_YUVA422P:
969  s->blend_slice = blend_slice_yuva422_pm;
970  break;
971  case AV_PIX_FMT_YUVA444P:
972  s->blend_slice = blend_slice_yuva444_pm;
973  break;
974  case AV_PIX_FMT_ARGB:
975  case AV_PIX_FMT_RGBA:
976  case AV_PIX_FMT_BGRA:
977  case AV_PIX_FMT_ABGR:
978  s->blend_slice = blend_slice_rgba_pm;
979  break;
980  case AV_PIX_FMT_GBRAP:
981  s->blend_slice = blend_slice_gbrap_pm;
982  break;
983  default:
984  av_assert0(0);
985  break;
986  }
987  break;
988  }
989 
990 end:
991 #if ARCH_X86
992  ff_overlay_init_x86(s, s->format, inlink->format,
993  s->alpha_format, s->main_has_alpha);
994 #endif
995 
996  return 0;
997 }
998 
999 static int do_blend(FFFrameSync *fs)
1000 {
1001  AVFilterContext *ctx = fs->parent;
1002  AVFrame *mainpic, *second;
1003  OverlayContext *s = ctx->priv;
1004  AVFilterLink *inlink = ctx->inputs[0];
1005  int ret;
1006 
1007  ret = ff_framesync_dualinput_get_writable(fs, &mainpic, &second);
1008  if (ret < 0)
1009  return ret;
1010  if (!second)
1011  return ff_filter_frame(ctx->outputs[0], mainpic);
1012 
1013  if (s->eval_mode == EVAL_MODE_FRAME) {
1014 
1015  s->var_values[VAR_N] = inlink->frame_count_out;
1016  s->var_values[VAR_T] = mainpic->pts == AV_NOPTS_VALUE ?
1017  NAN : mainpic->pts * av_q2d(inlink->time_base);
1018 #if FF_API_FRAME_PKT
1020  {
1021  int64_t pos = mainpic->pkt_pos;
1022  s->var_values[VAR_POS] = pos == -1 ? NAN : pos;
1023  }
1025 #endif
1026 
1027  s->var_values[VAR_OVERLAY_W] = s->var_values[VAR_OW] = second->width;
1028  s->var_values[VAR_OVERLAY_H] = s->var_values[VAR_OH] = second->height;
1029  s->var_values[VAR_MAIN_W ] = s->var_values[VAR_MW] = mainpic->width;
1030  s->var_values[VAR_MAIN_H ] = s->var_values[VAR_MH] = mainpic->height;
1031 
1032  eval_expr(ctx);
1033  av_log(ctx, AV_LOG_DEBUG, "n:%f t:%f x:%f xi:%d y:%f yi:%d\n",
1034  s->var_values[VAR_N], s->var_values[VAR_T],
1035  s->var_values[VAR_X], s->x,
1036  s->var_values[VAR_Y], s->y);
1037  }
1038 
1039  if (s->x < mainpic->width && s->x + second->width >= 0 &&
1040  s->y < mainpic->height && s->y + second->height >= 0) {
1041  ThreadData td;
1042 
1043  td.dst = mainpic;
1044  td.src = second;
1045  ff_filter_execute(ctx, s->blend_slice, &td, NULL, FFMIN(FFMAX(1, FFMIN3(s->y + second->height, FFMIN(second->height, mainpic->height), mainpic->height - s->y)),
1047  }
1048  return ff_filter_frame(ctx->outputs[0], mainpic);
1049 }
1050 
1052 {
1053  OverlayContext *s = ctx->priv;
1054 
1055  s->fs.on_event = do_blend;
1056  return 0;
1057 }
1058 
1060 {
1061  OverlayContext *s = ctx->priv;
1062  return ff_framesync_activate(&s->fs);
1063 }
1064 
1065 #define OFFSET(x) offsetof(OverlayContext, x)
1066 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
1067 
1068 static const AVOption overlay_options[] = {
1069  { "x", "set the x expression", OFFSET(x_expr), AV_OPT_TYPE_STRING, {.str = "0"}, 0, 0, FLAGS },
1070  { "y", "set the y expression", OFFSET(y_expr), AV_OPT_TYPE_STRING, {.str = "0"}, 0, 0, FLAGS },
1071  { "eof_action", "Action to take when encountering EOF from secondary input ",
1072  OFFSET(fs.opt_eof_action), AV_OPT_TYPE_INT, { .i64 = EOF_ACTION_REPEAT },
1073  EOF_ACTION_REPEAT, EOF_ACTION_PASS, .flags = FLAGS, "eof_action" },
1074  { "repeat", "Repeat the previous frame.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_REPEAT }, .flags = FLAGS, "eof_action" },
1075  { "endall", "End both streams.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_ENDALL }, .flags = FLAGS, "eof_action" },
1076  { "pass", "Pass through the main input.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_PASS }, .flags = FLAGS, "eof_action" },
1077  { "eval", "specify when to evaluate expressions", OFFSET(eval_mode), AV_OPT_TYPE_INT, {.i64 = EVAL_MODE_FRAME}, 0, EVAL_MODE_NB-1, FLAGS, "eval" },
1078  { "init", "eval expressions once during initialization", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_INIT}, .flags = FLAGS, .unit = "eval" },
1079  { "frame", "eval expressions per-frame", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_FRAME}, .flags = FLAGS, .unit = "eval" },
1080  { "shortest", "force termination when the shortest input terminates", OFFSET(fs.opt_shortest), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
1081  { "format", "set output format", OFFSET(format), AV_OPT_TYPE_INT, {.i64=OVERLAY_FORMAT_YUV420}, 0, OVERLAY_FORMAT_NB-1, FLAGS, "format" },
1082  { "yuv420", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_YUV420}, .flags = FLAGS, .unit = "format" },
1083  { "yuv420p10", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_YUV420P10}, .flags = FLAGS, .unit = "format" },
1084  { "yuv422", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_YUV422}, .flags = FLAGS, .unit = "format" },
1085  { "yuv422p10", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_YUV422P10}, .flags = FLAGS, .unit = "format" },
1086  { "yuv444", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_YUV444}, .flags = FLAGS, .unit = "format" },
1087  { "rgb", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_RGB}, .flags = FLAGS, .unit = "format" },
1088  { "gbrp", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_GBRP}, .flags = FLAGS, .unit = "format" },
1089  { "auto", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_AUTO}, .flags = FLAGS, .unit = "format" },
1090  { "repeatlast", "repeat overlay of the last overlay frame", OFFSET(fs.opt_repeatlast), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGS },
1091  { "alpha", "alpha format", OFFSET(alpha_format), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "alpha_format" },
1092  { "straight", "", 0, AV_OPT_TYPE_CONST, {.i64=0}, .flags = FLAGS, .unit = "alpha_format" },
1093  { "premultiplied", "", 0, AV_OPT_TYPE_CONST, {.i64=1}, .flags = FLAGS, .unit = "alpha_format" },
1094  { NULL }
1095 };
1096 
1098 
1100  {
1101  .name = "main",
1102  .type = AVMEDIA_TYPE_VIDEO,
1103  .config_props = config_input_main,
1104  },
1105  {
1106  .name = "overlay",
1107  .type = AVMEDIA_TYPE_VIDEO,
1108  .config_props = config_input_overlay,
1109  },
1110 };
1111 
1113  {
1114  .name = "default",
1115  .type = AVMEDIA_TYPE_VIDEO,
1116  .config_props = config_output,
1117  },
1118 };
1119 
1121  .name = "overlay",
1122  .description = NULL_IF_CONFIG_SMALL("Overlay a video source on top of the input."),
1123  .preinit = overlay_framesync_preinit,
1124  .init = init,
1125  .uninit = uninit,
1126  .priv_size = sizeof(OverlayContext),
1127  .priv_class = &overlay_class,
1128  .activate = activate,
1135 };
formats
formats
Definition: signature.h:48
FF_ENABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:81
VAR_MAIN_H
@ VAR_MAIN_H
Definition: vf_drawtext.c:126
ff_framesync_configure
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
Definition: framesync.c:134
td
#define td
Definition: regdef.h:70
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
blend_slice_packed_rgb
static av_always_inline void blend_slice_packed_rgb(AVFilterContext *ctx, AVFrame *dst, const AVFrame *src, int main_has_alpha, int x, int y, int is_straight, int jobnr, int nb_jobs)
Blend image in src to destination buffer dst at position (x, y).
Definition: vf_overlay.c:353
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
VAR_Y
@ VAR_Y
Definition: vf_blend.c:52
opt.h
VAR_OH
@ VAR_OH
Definition: scale_eval.c:46
blend_slice_rgb
static int blend_slice_rgb(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_overlay.c:842
set_expr
static int set_expr(AVExpr **pexpr, const char *expr, const char *option, void *log_ctx)
Definition: vf_overlay.c:111
OVERLAY
#define OVERLAY
Definition: vf_overlay.c:66
ff_make_format_list
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:401
ff_framesync_uninit
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
Definition: framesync.c:304
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:971
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2936
blend_slice_yuv422
static int blend_slice_yuv422(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_overlay.c:730
avfilter_vf_overlay_outputs
static const AVFilterPad avfilter_vf_overlay_outputs[]
Definition: vf_overlay.c:1112
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
blend_slice_yuv422p10
static int blend_slice_yuv422p10(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_overlay.c:714
blend_slice_yuva422_pm
static int blend_slice_yuva422_pm(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_overlay.c:802
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:330
pixdesc.h
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:442
AVFrame::width
int width
Definition: frame.h:402
do_blend
static int do_blend(FFFrameSync *fs)
Definition: vf_overlay.c:999
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:502
AVOption
AVOption.
Definition: opt.h:251
EOF_ACTION_ENDALL
@ EOF_ACTION_ENDALL
Definition: framesync.h:28
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:171
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:465
VAR_HSUB
@ VAR_HSUB
Definition: boxblur.c:40
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:69
AV_PIX_FMT_BGRA
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:95
mathematics.h
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
blend_slice_yuv420
static int blend_slice_yuv420(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_overlay.c:682
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
FFFrameSync
Frame sync structure.
Definition: framesync.h:168
blend_slice_yuva422p10
static int blend_slice_yuva422p10(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_overlay.c:722
video.h
VAR_MAIN_W
@ VAR_MAIN_W
Definition: vf_drawtext.c:127
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:503
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:351
hsub
static void hsub(htype *dst, const htype *src, int bins)
Definition: vf_median.c:74
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
blend_slice_gbrap
static int blend_slice_gbrap(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_overlay.c:770
formats.h
av_expr_parse
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
Definition: eval.c:685
var_names
static const char *const var_names[]
Definition: vf_overlay.c:48
S
#define S(s, c, i)
Definition: flacdsp_template.c:46
VAR_T
@ VAR_T
Definition: aeval.c:53
VAR_VSUB
@ VAR_VSUB
Definition: boxblur.c:41
OVERLAY_FORMAT_RGB
@ OVERLAY_FORMAT_RGB
Definition: vf_overlay.h:50
blend_slice_gbrp_pm
static int blend_slice_gbrp_pm(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_overlay.c:826
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:205
FAST_DIV255
#define FAST_DIV255(x)
Definition: vf_overlay.c:341
OVERLAY_FORMAT_YUV422P10
@ OVERLAY_FORMAT_YUV422P10
Definition: vf_overlay.h:48
av_expr_free
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
Definition: eval.c:336
R
#define R
Definition: vf_overlay.c:68
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:49
ff_overlay_init_x86
void ff_overlay_init_x86(OverlayContext *s, int format, int pix_format, int alpha_format, int main_has_alpha)
Definition: vf_overlay_init.c:35
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
config_input_main
static int config_input_main(AVFilterLink *inlink)
Definition: vf_overlay.c:874
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_overlay.c:164
av_cold
#define av_cold
Definition: attributes.h:90
blend_slice_rgb_pm
static int blend_slice_rgb_pm(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_overlay.c:858
EVAL_MODE_FRAME
@ EVAL_MODE_FRAME
Definition: vf_overlay.c:79
AV_PIX_FMT_YUVJ422P
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:79
s
#define s(width, name)
Definition: cbs_vp9.c:256
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
OVERLAY_FORMAT_YUV422
@ OVERLAY_FORMAT_YUV422
Definition: vf_overlay.h:47
format
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 format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
ff_formats_ref
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add *ref as a new reference to formats.
Definition: formats.c:617
slice_end
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:2020
av_q2d
static double av_q2d(AVRational a)
Convert an AVRational to a double.
Definition: rational.h:104
ff_set_common_formats_from_list
int ff_set_common_formats_from_list(AVFilterContext *ctx, const int *fmts)
Equivalent to ff_set_common_formats(ctx, ff_make_format_list(fmts))
Definition: formats.c:776
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
VAR_MW
@ VAR_MW
Definition: vf_overlay.h:28
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
ctx
AVFormatContext * ctx
Definition: movenc.c:48
av_expr_eval
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
Definition: eval.c:766
UNPREMULTIPLY_ALPHA
#define UNPREMULTIPLY_ALPHA(x, y)
Definition: vf_overlay.c:347
AVExpr
Definition: eval.c:157
AVPixFmtDescriptor::log2_chroma_w
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:80
vf_overlay.h
B
#define B
Definition: vf_overlay.c:70
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:66
blend_slice_yuva420p10
static int blend_slice_yuva420p10(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_overlay.c:706
eval_expr
static void eval_expr(AVFilterContext *ctx)
Definition: vf_overlay.c:99
EOF_ACTION_PASS
@ EOF_ACTION_PASS
Definition: framesync.h:29
NAN
#define NAN
Definition: mathematics.h:115
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:194
AV_PIX_FMT_YUVJ444P
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:80
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:93
arg
const char * arg
Definition: jacosubdec.c:67
ff_vf_overlay
const AVFilter ff_vf_overlay
Definition: vf_overlay.c:1120
option
option
Definition: libkvazaar.c:313
ThreadData::dst
AVFrame * dst
Definition: vf_blend.c:56
config_input_overlay
static int config_input_overlay(AVFilterLink *inlink)
Definition: vf_overlay.c:274
NULL
#define NULL
Definition: coverity.c:32
EVAL_MODE_NB
@ EVAL_MODE_NB
Definition: vf_overlay.c:80
fs
#define fs(width, name, subs,...)
Definition: cbs_vp9.c:258
ThreadData::src
const uint8_t * src
Definition: vf_bm3d.c:55
blend_slice_yuva444_pm
static int blend_slice_yuva444_pm(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_overlay.c:818
isnan
#define isnan(x)
Definition: libm.h:340
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_overlay.c:83
AV_PIX_FMT_YUVJ420P
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:78
OverlayContext
Definition: vf_overlay.h:56
VAR_POS
@ VAR_POS
Definition: noise_bsf.c:55
ff_fmt_is_in
int ff_fmt_is_in(int fmt, const int *fmts)
Tell if an integer is contained in the provided -1-terminated list of integers.
Definition: formats.c:372
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:466
blend_slice_yuv420_pm
static int blend_slice_yuv420_pm(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_overlay.c:778
AV_PIX_FMT_ABGR
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:94
avfilter_vf_overlay_inputs
static const AVFilterPad avfilter_vf_overlay_inputs[]
Definition: vf_overlay.c:1099
VAR_X
@ VAR_X
Definition: vf_blend.c:52
eval.h
blend_slice_yuv420p10
static int blend_slice_yuv420p10(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_overlay.c:698
AV_PIX_FMT_RGB24
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:68
A
#define A
Definition: vf_overlay.c:71
overlay_options
static const AVOption overlay_options[]
Definition: vf_overlay.c:1068
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:114
ff_framesync_init_dualinput
int ff_framesync_init_dualinput(FFFrameSync *fs, AVFilterContext *parent)
Initialize a frame sync structure for dualinput.
Definition: framesync.c:372
VAR_N
@ VAR_N
Definition: noise_bsf.c:47
OVERLAY_FORMAT_NB
@ OVERLAY_FORMAT_NB
Definition: vf_overlay.h:53
OVERLAY_FORMAT_YUV420P10
@ OVERLAY_FORMAT_YUV420P10
Definition: vf_overlay.h:46
sp
#define sp
Definition: regdef.h:63
OVERLAY_FORMAT_YUV420
@ OVERLAY_FORMAT_YUV420
Definition: vf_overlay.h:45
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
VAR_MH
@ VAR_MH
Definition: vf_overlay.h:29
AVFrame::pkt_pos
attribute_deprecated int64_t pkt_pos
reordered pos from the last AVPacket that has been input into the decoder
Definition: frame.h:677
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_overlay.c:323
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:167
OVERLAY_FORMAT_AUTO
@ OVERLAY_FORMAT_AUTO
Definition: vf_overlay.h:52
DEFINE_ALPHA_COMPOSITE
#define DEFINE_ALPHA_COMPOSITE(depth, nbits)
Definition: vf_overlay.c:568
blend_slice_rgba
static int blend_slice_rgba(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_overlay.c:850
internal.h
blend_slice_yuva420_pm
static int blend_slice_yuva420_pm(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_overlay.c:786
AV_PIX_FMT_ARGB
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:92
FLAGS
#define FLAGS
Definition: vf_overlay.c:1066
blend_slice_gbrap_pm
static int blend_slice_gbrap_pm(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_overlay.c:834
blend_slice_yuva444
static int blend_slice_yuva444(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_overlay.c:754
blend_slice_rgba_pm
static int blend_slice_rgba_pm(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_overlay.c:866
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
blend_slice_planar_rgb
static av_always_inline void blend_slice_planar_rgb(AVFilterContext *ctx, AVFrame *dst, const AVFrame *src, int hsub, int vsub, int main_has_alpha, int x, int y, int is_straight, int jobnr, int nb_jobs)
Definition: vf_overlay.c:653
FFMIN3
#define FFMIN3(a, b, c)
Definition: macros.h:50
common.h
ff_filter_get_nb_threads
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:779
ThreadData
Used for passing data between threads.
Definition: dsddec.c:69
EvalMode
EvalMode
Definition: af_volume.h:39
av_always_inline
#define av_always_inline
Definition: attributes.h:49
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AV_PIX_FMT_NV21
@ AV_PIX_FMT_NV21
as above, but U and V bytes are swapped
Definition: pixfmt.h:90
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:55
blend_slice_gbrp
static int blend_slice_gbrp(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_overlay.c:762
VAR_OVERLAY_H
@ VAR_OVERLAY_H
Definition: vf_overlay.h:31
VAR_OW
@ VAR_OW
Definition: scale_eval.c:45
normalize_xy
static int normalize_xy(double d, int chroma_sub)
Definition: vf_overlay.c:92
blend_slice_yuv444
static int blend_slice_yuv444(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_overlay.c:746
AVFilter
Filter definition.
Definition: avfilter.h:166
process_command
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: vf_overlay.c:132
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:89
DEFINE_BLEND_PLANE
#define DEFINE_BLEND_PLANE(depth, nbits)
Definition: vf_overlay.c:440
MAIN
#define MAIN
Definition: vf_overlay.c:65
pos
unsigned int pos
Definition: spdifenc.c:413
EOF_ACTION_REPEAT
@ EOF_ACTION_REPEAT
Definition: framesync.h:27
blend_slice_yuva422
static int blend_slice_yuva422(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_overlay.c:738
AVFrame::height
int height
Definition: frame.h:402
framesync.h
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
avfilter.h
activate
static int activate(AVFilterContext *ctx)
Definition: vf_overlay.c:1059
G
#define G
Definition: vf_overlay.c:69
av_image_fill_max_pixsteps
void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], const AVPixFmtDescriptor *pixdesc)
Compute the max pixel step for each plane of an image with a format described by pixdesc.
Definition: imgutils.c:35
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
blend_slice_yuv444_pm
static int blend_slice_yuv444_pm(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_overlay.c:810
AVFilterContext
An instance of a filter.
Definition: avfilter.h:397
FF_DISABLE_DEPRECATION_WARNINGS
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:80
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:158
OVERLAY_FORMAT_GBRP
@ OVERLAY_FORMAT_GBRP
Definition: vf_overlay.h:51
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:117
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
OVERLAY_FORMAT_YUV444
@ OVERLAY_FORMAT_YUV444
Definition: vf_overlay.h:49
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
FRAMESYNC_DEFINE_CLASS
FRAMESYNC_DEFINE_CLASS(overlay, OverlayContext, fs)
alpha
static const int16_t alpha[]
Definition: ilbcdata.h:55
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:244
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:195
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
EVAL_MODE_INIT
@ EVAL_MODE_INIT
Definition: vf_overlay.c:78
ff_fill_rgba_map
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
Definition: drawutils.c:35
DEFINE_BLEND_SLICE_YUV
#define DEFINE_BLEND_SLICE_YUV(depth, nbits)
Definition: vf_overlay.c:621
d
d
Definition: ffmpeg_filter.c:354
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
Definition: avfilter.h:155
imgutils.h
timestamp.h
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:375
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
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
avstring.h
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:229
ff_framesync_dualinput_get_writable
int ff_framesync_dualinput_get_writable(FFFrameSync *fs, AVFrame **f0, AVFrame **f1)
Same as ff_framesync_dualinput_get(), but make sure that f0 is writable.
Definition: framesync.c:410
drawutils.h
alpha_pix_fmts
static enum AVPixelFormat alpha_pix_fmts[]
Definition: vf_overlay.c:157
OFFSET
#define OFFSET(x)
Definition: vf_overlay.c:1065
ff_filter_execute
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
Definition: internal.h:146
VAR_OVERLAY_W
@ VAR_OVERLAY_W
Definition: vf_overlay.h:30
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
blend_slice_yuva420
static int blend_slice_yuva420(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_overlay.c:690
AVPixFmtDescriptor::log2_chroma_h
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:89
AV_PIX_FMT_YUVA422P
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:166
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:2856
blend_slice_yuv422_pm
static int blend_slice_yuv422_pm(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_overlay.c:794
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_overlay.c:1051