vf_overlay.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  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. * @file
  24. * overlay one video on top of another
  25. */
  26. /* #define DEBUG */
  27. #include "avfilter.h"
  28. #include "libavutil/eval.h"
  29. #include "libavutil/avstring.h"
  30. #include "libavutil/opt.h"
  31. #include "libavutil/pixdesc.h"
  32. #include "libavutil/imgutils.h"
  33. #include "libavutil/mathematics.h"
  34. #include "libavutil/timestamp.h"
  35. #include "internal.h"
  36. #include "drawutils.h"
  37. static const char *const var_names[] = {
  38. "main_w", "W", ///< width of the main video
  39. "main_h", "H", ///< height of the main video
  40. "overlay_w", "w", ///< width of the overlay video
  41. "overlay_h", "h", ///< height of the overlay video
  42. NULL
  43. };
  44. enum var_name {
  45. VAR_MAIN_W, VAR_MW,
  46. VAR_MAIN_H, VAR_MH,
  47. VAR_OVERLAY_W, VAR_OW,
  48. VAR_OVERLAY_H, VAR_OH,
  49. VAR_VARS_NB
  50. };
  51. #define MAIN 0
  52. #define OVERLAY 1
  53. #define R 0
  54. #define G 1
  55. #define B 2
  56. #define A 3
  57. #define Y 0
  58. #define U 1
  59. #define V 2
  60. typedef struct {
  61. const AVClass *class;
  62. int x, y; ///< position of overlayed picture
  63. int allow_packed_rgb;
  64. uint8_t main_is_packed_rgb;
  65. uint8_t main_rgba_map[4];
  66. uint8_t main_has_alpha;
  67. uint8_t overlay_is_packed_rgb;
  68. uint8_t overlay_rgba_map[4];
  69. uint8_t overlay_has_alpha;
  70. AVFilterBufferRef *overpicref, *overpicref_next;
  71. int main_pix_step[4]; ///< steps per pixel for each plane of the main output
  72. int overlay_pix_step[4]; ///< steps per pixel for each plane of the overlay
  73. int hsub, vsub; ///< chroma subsampling values
  74. char *x_expr, *y_expr;
  75. } OverlayContext;
  76. #define OFFSET(x) offsetof(OverlayContext, x)
  77. static const AVOption overlay_options[] = {
  78. { "x", "set the x expression", OFFSET(x_expr), AV_OPT_TYPE_STRING, {.str = "0"}, CHAR_MIN, CHAR_MAX },
  79. { "y", "set the y expression", OFFSET(y_expr), AV_OPT_TYPE_STRING, {.str = "0"}, CHAR_MIN, CHAR_MAX },
  80. {"rgb", "force packed RGB in input and output", OFFSET(allow_packed_rgb), AV_OPT_TYPE_INT, {.dbl=0}, 0, 1 },
  81. {NULL},
  82. };
  83. static const char *overlay_get_name(void *ctx)
  84. {
  85. return "overlay";
  86. }
  87. static const AVClass overlay_class = {
  88. "OverlayContext",
  89. overlay_get_name,
  90. overlay_options
  91. };
  92. static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
  93. {
  94. OverlayContext *over = ctx->priv;
  95. char *args1 = av_strdup(args);
  96. char *expr, *bufptr = NULL;
  97. int ret = 0;
  98. over->class = &overlay_class;
  99. av_opt_set_defaults(over);
  100. if (expr = av_strtok(args1, ":", &bufptr)) {
  101. av_free(over->x_expr);
  102. if (!(over->x_expr = av_strdup(expr))) {
  103. ret = AVERROR(ENOMEM);
  104. goto end;
  105. }
  106. }
  107. if (expr = av_strtok(NULL, ":", &bufptr)) {
  108. av_free(over->y_expr);
  109. if (!(over->y_expr = av_strdup(expr))) {
  110. ret = AVERROR(ENOMEM);
  111. goto end;
  112. }
  113. }
  114. if (bufptr && (ret = av_set_options_string(over, bufptr, "=", ":")) < 0)
  115. goto end;
  116. end:
  117. av_free(args1);
  118. return ret;
  119. }
  120. static av_cold void uninit(AVFilterContext *ctx)
  121. {
  122. OverlayContext *over = ctx->priv;
  123. av_freep(&over->x_expr);
  124. av_freep(&over->y_expr);
  125. if (over->overpicref)
  126. avfilter_unref_buffer(over->overpicref);
  127. if (over->overpicref_next)
  128. avfilter_unref_buffer(over->overpicref_next);
  129. }
  130. static int query_formats(AVFilterContext *ctx)
  131. {
  132. OverlayContext *over = ctx->priv;
  133. /* overlay formats contains alpha, for avoiding conversion with alpha information loss */
  134. const enum PixelFormat main_pix_fmts_yuv[] = { PIX_FMT_YUV420P, PIX_FMT_NONE };
  135. const enum PixelFormat overlay_pix_fmts_yuv[] = { PIX_FMT_YUVA420P, PIX_FMT_NONE };
  136. const enum PixelFormat main_pix_fmts_rgb[] = {
  137. PIX_FMT_ARGB, PIX_FMT_RGBA,
  138. PIX_FMT_ABGR, PIX_FMT_BGRA,
  139. PIX_FMT_RGB24, PIX_FMT_BGR24,
  140. PIX_FMT_NONE
  141. };
  142. const enum PixelFormat overlay_pix_fmts_rgb[] = {
  143. PIX_FMT_ARGB, PIX_FMT_RGBA,
  144. PIX_FMT_ABGR, PIX_FMT_BGRA,
  145. PIX_FMT_NONE
  146. };
  147. AVFilterFormats *main_formats;
  148. AVFilterFormats *overlay_formats;
  149. if (over->allow_packed_rgb) {
  150. main_formats = avfilter_make_format_list(main_pix_fmts_rgb);
  151. overlay_formats = avfilter_make_format_list(overlay_pix_fmts_rgb);
  152. } else {
  153. main_formats = avfilter_make_format_list(main_pix_fmts_yuv);
  154. overlay_formats = avfilter_make_format_list(overlay_pix_fmts_yuv);
  155. }
  156. avfilter_formats_ref(main_formats, &ctx->inputs [MAIN ]->out_formats);
  157. avfilter_formats_ref(overlay_formats, &ctx->inputs [OVERLAY]->out_formats);
  158. avfilter_formats_ref(main_formats, &ctx->outputs[MAIN ]->in_formats );
  159. return 0;
  160. }
  161. static const enum PixelFormat alpha_pix_fmts[] = {
  162. PIX_FMT_YUVA420P, PIX_FMT_ARGB, PIX_FMT_ABGR, PIX_FMT_RGBA,
  163. PIX_FMT_BGRA, PIX_FMT_NONE
  164. };
  165. static int config_input_main(AVFilterLink *inlink)
  166. {
  167. OverlayContext *over = inlink->dst->priv;
  168. const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[inlink->format];
  169. av_image_fill_max_pixsteps(over->main_pix_step, NULL, pix_desc);
  170. over->hsub = pix_desc->log2_chroma_w;
  171. over->vsub = pix_desc->log2_chroma_h;
  172. over->main_is_packed_rgb =
  173. ff_fill_rgba_map(over->main_rgba_map, inlink->format) >= 0;
  174. over->main_has_alpha = ff_fmt_is_in(inlink->format, alpha_pix_fmts);
  175. return 0;
  176. }
  177. static int config_input_overlay(AVFilterLink *inlink)
  178. {
  179. AVFilterContext *ctx = inlink->dst;
  180. OverlayContext *over = inlink->dst->priv;
  181. char *expr;
  182. double var_values[VAR_VARS_NB], res;
  183. int ret;
  184. const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[inlink->format];
  185. av_image_fill_max_pixsteps(over->overlay_pix_step, NULL, pix_desc);
  186. /* Finish the configuration by evaluating the expressions
  187. now when both inputs are configured. */
  188. var_values[VAR_MAIN_W ] = var_values[VAR_MW] = ctx->inputs[MAIN ]->w;
  189. var_values[VAR_MAIN_H ] = var_values[VAR_MH] = ctx->inputs[MAIN ]->h;
  190. var_values[VAR_OVERLAY_W] = var_values[VAR_OW] = ctx->inputs[OVERLAY]->w;
  191. var_values[VAR_OVERLAY_H] = var_values[VAR_OH] = ctx->inputs[OVERLAY]->h;
  192. if ((ret = av_expr_parse_and_eval(&res, (expr = over->x_expr), var_names, var_values,
  193. NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
  194. goto fail;
  195. over->x = res;
  196. if ((ret = av_expr_parse_and_eval(&res, (expr = over->y_expr), var_names, var_values,
  197. NULL, NULL, NULL, NULL, NULL, 0, ctx)))
  198. goto fail;
  199. over->y = res;
  200. /* x may depend on y */
  201. if ((ret = av_expr_parse_and_eval(&res, (expr = over->x_expr), var_names, var_values,
  202. NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
  203. goto fail;
  204. over->x = res;
  205. over->overlay_is_packed_rgb =
  206. ff_fill_rgba_map(over->overlay_rgba_map, inlink->format) >= 0;
  207. over->overlay_has_alpha = ff_fmt_is_in(inlink->format, alpha_pix_fmts);
  208. av_log(ctx, AV_LOG_INFO,
  209. "main w:%d h:%d fmt:%s overlay x:%d y:%d w:%d h:%d fmt:%s\n",
  210. ctx->inputs[MAIN]->w, ctx->inputs[MAIN]->h,
  211. av_pix_fmt_descriptors[ctx->inputs[MAIN]->format].name,
  212. over->x, over->y,
  213. ctx->inputs[OVERLAY]->w, ctx->inputs[OVERLAY]->h,
  214. av_pix_fmt_descriptors[ctx->inputs[OVERLAY]->format].name);
  215. if (over->x < 0 || over->y < 0 ||
  216. over->x + var_values[VAR_OVERLAY_W] > var_values[VAR_MAIN_W] ||
  217. over->y + var_values[VAR_OVERLAY_H] > var_values[VAR_MAIN_H]) {
  218. av_log(ctx, AV_LOG_ERROR,
  219. "Overlay area (%d,%d)<->(%d,%d) not within the main area (0,0)<->(%d,%d) or zero-sized\n",
  220. over->x, over->y,
  221. (int)(over->x + var_values[VAR_OVERLAY_W]),
  222. (int)(over->y + var_values[VAR_OVERLAY_H]),
  223. (int)var_values[VAR_MAIN_W], (int)var_values[VAR_MAIN_H]);
  224. return AVERROR(EINVAL);
  225. }
  226. return 0;
  227. fail:
  228. av_log(NULL, AV_LOG_ERROR,
  229. "Error when evaluating the expression '%s'\n", expr);
  230. return ret;
  231. }
  232. static int config_output(AVFilterLink *outlink)
  233. {
  234. AVFilterContext *ctx = outlink->src;
  235. int exact;
  236. // common timebase computation:
  237. AVRational tb1 = ctx->inputs[MAIN ]->time_base;
  238. AVRational tb2 = ctx->inputs[OVERLAY]->time_base;
  239. AVRational *tb = &ctx->outputs[0]->time_base;
  240. exact = av_reduce(&tb->num, &tb->den,
  241. av_gcd((int64_t)tb1.num * tb2.den,
  242. (int64_t)tb2.num * tb1.den),
  243. (int64_t)tb1.den * tb2.den, INT_MAX);
  244. av_log(ctx, AV_LOG_INFO,
  245. "main_tb:%d/%d overlay_tb:%d/%d -> tb:%d/%d exact:%d\n",
  246. tb1.num, tb1.den, tb2.num, tb2.den, tb->num, tb->den, exact);
  247. if (!exact)
  248. av_log(ctx, AV_LOG_WARNING,
  249. "Timestamp conversion inexact, timestamp information loss may occurr\n");
  250. outlink->w = ctx->inputs[MAIN]->w;
  251. outlink->h = ctx->inputs[MAIN]->h;
  252. return 0;
  253. }
  254. static AVFilterBufferRef *get_video_buffer(AVFilterLink *link, int perms, int w, int h)
  255. {
  256. return avfilter_get_video_buffer(link->dst->outputs[0], perms, w, h);
  257. }
  258. static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
  259. {
  260. AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0);
  261. AVFilterContext *ctx = inlink->dst;
  262. OverlayContext *over = ctx->priv;
  263. av_unused AVFilterLink *outlink = ctx->outputs[0];
  264. inlink->dst->outputs[0]->out_buf = outpicref;
  265. outpicref->pts = av_rescale_q(outpicref->pts, ctx->inputs[MAIN]->time_base,
  266. ctx->outputs[0]->time_base);
  267. if (!over->overpicref || over->overpicref->pts < outpicref->pts) {
  268. if (!over->overpicref_next)
  269. avfilter_request_frame(ctx->inputs[OVERLAY]);
  270. if (over->overpicref && over->overpicref_next &&
  271. over->overpicref_next->pts <= outpicref->pts) {
  272. avfilter_unref_buffer(over->overpicref);
  273. over->overpicref = over->overpicref_next;
  274. over->overpicref_next = NULL;
  275. }
  276. }
  277. av_dlog(ctx, "main_pts:%s main_pts_time:%s",
  278. av_ts2str(outpicref->pts), av_ts2timestr(outpicref->pts, &outlink->time_base));
  279. if (over->overpicref)
  280. av_dlog(ctx, " over_pts:%s over_pts_time:%s",
  281. av_ts2str(over->overpicref->pts), av_ts2timestr(over->overpicref->pts, &outlink->time_base));
  282. av_dlog(ctx, "\n");
  283. avfilter_start_frame(inlink->dst->outputs[0], outpicref);
  284. }
  285. static void start_frame_overlay(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
  286. {
  287. AVFilterContext *ctx = inlink->dst;
  288. OverlayContext *over = ctx->priv;
  289. inpicref->pts = av_rescale_q(inpicref->pts, ctx->inputs[OVERLAY]->time_base,
  290. ctx->outputs[0]->time_base);
  291. if (!over->overpicref) over->overpicref = inpicref;
  292. else over->overpicref_next = inpicref;
  293. }
  294. // divide by 255 and round to nearest
  295. // apply a fast variant: (X+127)/255 = ((X+127)*257+257)>>16 = ((X+128)*257)>>16
  296. #define FAST_DIV255(x) ((((x) + 128) * 257) >> 16)
  297. static void blend_slice(AVFilterContext *ctx,
  298. AVFilterBufferRef *dst, AVFilterBufferRef *src,
  299. int x, int y, int w, int h,
  300. int slice_y, int slice_w, int slice_h)
  301. {
  302. OverlayContext *over = ctx->priv;
  303. int i, j, k;
  304. int width, height;
  305. int overlay_end_y = y+h;
  306. int slice_end_y = slice_y+slice_h;
  307. int end_y, start_y;
  308. width = FFMIN(slice_w - x, w);
  309. end_y = FFMIN(slice_end_y, overlay_end_y);
  310. start_y = FFMAX(y, slice_y);
  311. height = end_y - start_y;
  312. if (over->main_is_packed_rgb) {
  313. uint8_t *dp = dst->data[0] + x * over->main_pix_step[0] +
  314. start_y * dst->linesize[0];
  315. uint8_t *sp = src->data[0];
  316. uint8_t alpha; ///< the amount of overlay to blend on to main
  317. const int dr = over->main_rgba_map[R];
  318. const int dg = over->main_rgba_map[G];
  319. const int db = over->main_rgba_map[B];
  320. const int da = over->main_rgba_map[A];
  321. const int dstep = over->main_pix_step[0];
  322. const int sr = over->overlay_rgba_map[R];
  323. const int sg = over->overlay_rgba_map[G];
  324. const int sb = over->overlay_rgba_map[B];
  325. const int sa = over->overlay_rgba_map[A];
  326. const int sstep = over->overlay_pix_step[0];
  327. const int main_has_alpha = over->main_has_alpha;
  328. if (slice_y > y)
  329. sp += (slice_y - y) * src->linesize[0];
  330. for (i = 0; i < height; i++) {
  331. uint8_t *d = dp, *s = sp;
  332. for (j = 0; j < width; j++) {
  333. alpha = s[sa];
  334. // if the main channel has an alpha channel, alpha has to be calculated
  335. // to create an un-premultiplied (straight) alpha value
  336. if (main_has_alpha && alpha != 0 && alpha != 255) {
  337. // apply the general equation:
  338. // alpha = alpha_overlay / ( (alpha_main + alpha_overlay) - (alpha_main * alpha_overlay) )
  339. alpha =
  340. // the next line is a faster version of: 255 * 255 * alpha
  341. ( (alpha << 16) - (alpha << 9) + alpha )
  342. /
  343. // the next line is a faster version of: 255 * (alpha + d[da])
  344. ( ((alpha + d[da]) << 8 ) - (alpha + d[da])
  345. - d[da] * alpha );
  346. }
  347. switch (alpha) {
  348. case 0:
  349. break;
  350. case 255:
  351. d[dr] = s[sr];
  352. d[dg] = s[sg];
  353. d[db] = s[sb];
  354. break;
  355. default:
  356. // main_value = main_value * (1 - alpha) + overlay_value * alpha
  357. // since alpha is in the range 0-255, the result must divided by 255
  358. d[dr] = FAST_DIV255(d[dr] * (255 - alpha) + s[sr] * alpha);
  359. d[dg] = FAST_DIV255(d[dg] * (255 - alpha) + s[sg] * alpha);
  360. d[db] = FAST_DIV255(d[db] * (255 - alpha) + s[sb] * alpha);
  361. }
  362. if (main_has_alpha) {
  363. switch (alpha) {
  364. case 0:
  365. break;
  366. case 255:
  367. d[da] = s[sa];
  368. break;
  369. default:
  370. // apply alpha compositing: main_alpha += (1-main_alpha) * overlay_alpha
  371. d[da] += FAST_DIV255((255 - d[da]) * s[sa]);
  372. }
  373. }
  374. d += dstep;
  375. s += sstep;
  376. }
  377. dp += dst->linesize[0];
  378. sp += src->linesize[0];
  379. }
  380. } else {
  381. for (i = 0; i < 3; i++) {
  382. int hsub = i ? over->hsub : 0;
  383. int vsub = i ? over->vsub : 0;
  384. uint8_t *dp = dst->data[i] + (x >> hsub) +
  385. (start_y >> vsub) * dst->linesize[i];
  386. uint8_t *sp = src->data[i];
  387. uint8_t *ap = src->data[3];
  388. int wp = FFALIGN(width, 1<<hsub) >> hsub;
  389. int hp = FFALIGN(height, 1<<vsub) >> vsub;
  390. if (slice_y > y) {
  391. sp += ((slice_y - y) >> vsub) * src->linesize[i];
  392. ap += (slice_y - y) * src->linesize[3];
  393. }
  394. for (j = 0; j < hp; j++) {
  395. uint8_t *d = dp, *s = sp, *a = ap;
  396. for (k = 0; k < wp; k++) {
  397. // average alpha for color components, improve quality
  398. int alpha_v, alpha_h, alpha;
  399. if (hsub && vsub && j+1 < hp && k+1 < wp) {
  400. alpha = (a[0] + a[src->linesize[3]] +
  401. a[1] + a[src->linesize[3]+1]) >> 2;
  402. } else if (hsub || vsub) {
  403. alpha_h = hsub && k+1 < wp ?
  404. (a[0] + a[1]) >> 1 : a[0];
  405. alpha_v = vsub && j+1 < hp ?
  406. (a[0] + a[src->linesize[3]]) >> 1 : a[0];
  407. alpha = (alpha_v + alpha_h) >> 1;
  408. } else
  409. alpha = a[0];
  410. *d = FAST_DIV255(*d * (255 - alpha) + *s * alpha);
  411. s++;
  412. d++;
  413. a += 1 << hsub;
  414. }
  415. dp += dst->linesize[i];
  416. sp += src->linesize[i];
  417. ap += (1 << vsub) * src->linesize[3];
  418. }
  419. }
  420. }
  421. }
  422. static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
  423. {
  424. AVFilterContext *ctx = inlink->dst;
  425. AVFilterLink *outlink = ctx->outputs[0];
  426. AVFilterBufferRef *outpicref = outlink->out_buf;
  427. OverlayContext *over = ctx->priv;
  428. if (over->overpicref &&
  429. !(over->x >= outpicref->video->w || over->y >= outpicref->video->h ||
  430. y+h < over->y || y >= over->y + over->overpicref->video->h)) {
  431. blend_slice(ctx, outpicref, over->overpicref, over->x, over->y,
  432. over->overpicref->video->w, over->overpicref->video->h,
  433. y, outpicref->video->w, h);
  434. }
  435. avfilter_draw_slice(outlink, y, h, slice_dir);
  436. }
  437. static void end_frame(AVFilterLink *inlink)
  438. {
  439. avfilter_end_frame(inlink->dst->outputs[0]);
  440. avfilter_unref_buffer(inlink->cur_buf);
  441. }
  442. static void null_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) { }
  443. static void null_end_frame(AVFilterLink *inlink) { }
  444. static int poll_frame(AVFilterLink *link)
  445. {
  446. AVFilterContext *s = link->src;
  447. OverlayContext *over = s->priv;
  448. int ret = avfilter_poll_frame(s->inputs[OVERLAY]);
  449. if (ret == AVERROR_EOF)
  450. ret = !!over->overpicref;
  451. return ret && avfilter_poll_frame(s->inputs[MAIN]);
  452. }
  453. AVFilter avfilter_vf_overlay = {
  454. .name = "overlay",
  455. .description = NULL_IF_CONFIG_SMALL("Overlay a video source on top of the input."),
  456. .init = init,
  457. .uninit = uninit,
  458. .priv_size = sizeof(OverlayContext),
  459. .query_formats = query_formats,
  460. .inputs = (const AVFilterPad[]) {{ .name = "main",
  461. .type = AVMEDIA_TYPE_VIDEO,
  462. .start_frame = start_frame,
  463. .get_video_buffer= get_video_buffer,
  464. .config_props = config_input_main,
  465. .draw_slice = draw_slice,
  466. .end_frame = end_frame,
  467. .min_perms = AV_PERM_READ,
  468. .rej_perms = AV_PERM_REUSE2|AV_PERM_PRESERVE, },
  469. { .name = "overlay",
  470. .type = AVMEDIA_TYPE_VIDEO,
  471. .start_frame = start_frame_overlay,
  472. .config_props = config_input_overlay,
  473. .draw_slice = null_draw_slice,
  474. .end_frame = null_end_frame,
  475. .min_perms = AV_PERM_READ,
  476. .rej_perms = AV_PERM_REUSE2, },
  477. { .name = NULL}},
  478. .outputs = (const AVFilterPad[]) {{ .name = "default",
  479. .type = AVMEDIA_TYPE_VIDEO,
  480. .config_props = config_output,
  481. .poll_frame = poll_frame },
  482. { .name = NULL}},
  483. };