00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00028
00029
00030 #include "avfilter.h"
00031 #include "formats.h"
00032 #include "libavutil/common.h"
00033 #include "libavutil/eval.h"
00034 #include "libavutil/avstring.h"
00035 #include "libavutil/opt.h"
00036 #include "libavutil/pixdesc.h"
00037 #include "libavutil/imgutils.h"
00038 #include "libavutil/mathematics.h"
00039 #include "libavutil/timestamp.h"
00040 #include "internal.h"
00041 #include "bufferqueue.h"
00042 #include "drawutils.h"
00043 #include "video.h"
00044
00045 static const char *const var_names[] = {
00046 "main_w", "W",
00047 "main_h", "H",
00048 "overlay_w", "w",
00049 "overlay_h", "h",
00050 NULL
00051 };
00052
00053 enum var_name {
00054 VAR_MAIN_W, VAR_MW,
00055 VAR_MAIN_H, VAR_MH,
00056 VAR_OVERLAY_W, VAR_OW,
00057 VAR_OVERLAY_H, VAR_OH,
00058 VAR_VARS_NB
00059 };
00060
00061 #define MAIN 0
00062 #define OVERLAY 1
00063
00064 #define R 0
00065 #define G 1
00066 #define B 2
00067 #define A 3
00068
00069 #define Y 0
00070 #define U 1
00071 #define V 2
00072
00073 typedef struct {
00074 const AVClass *class;
00075 int x, y;
00076
00077 int allow_packed_rgb;
00078 uint8_t frame_requested;
00079 uint8_t overlay_eof;
00080 uint8_t main_is_packed_rgb;
00081 uint8_t main_rgba_map[4];
00082 uint8_t main_has_alpha;
00083 uint8_t overlay_is_packed_rgb;
00084 uint8_t overlay_rgba_map[4];
00085 uint8_t overlay_has_alpha;
00086
00087 AVFilterBufferRef *overpicref;
00088 struct FFBufQueue queue_main;
00089 struct FFBufQueue queue_over;
00090
00091 int main_pix_step[4];
00092 int overlay_pix_step[4];
00093 int hsub, vsub;
00094
00095 char *x_expr, *y_expr;
00096 } OverlayContext;
00097
00098 #define OFFSET(x) offsetof(OverlayContext, x)
00099 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
00100
00101 static const AVOption overlay_options[] = {
00102 { "x", "set the x expression", OFFSET(x_expr), AV_OPT_TYPE_STRING, {.str = "0"}, CHAR_MIN, CHAR_MAX, FLAGS },
00103 { "y", "set the y expression", OFFSET(y_expr), AV_OPT_TYPE_STRING, {.str = "0"}, CHAR_MIN, CHAR_MAX, FLAGS },
00104 {"rgb", "force packed RGB in input and output", OFFSET(allow_packed_rgb), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS },
00105 {NULL},
00106 };
00107
00108 AVFILTER_DEFINE_CLASS(overlay);
00109
00110 static av_cold int init(AVFilterContext *ctx, const char *args)
00111 {
00112 OverlayContext *over = ctx->priv;
00113 char *args1 = av_strdup(args);
00114 char *expr, *bufptr = NULL;
00115 int ret = 0;
00116
00117 over->class = &overlay_class;
00118 av_opt_set_defaults(over);
00119
00120 if (expr = av_strtok(args1, ":", &bufptr)) {
00121 av_free(over->x_expr);
00122 if (!(over->x_expr = av_strdup(expr))) {
00123 ret = AVERROR(ENOMEM);
00124 goto end;
00125 }
00126 }
00127 if (expr = av_strtok(NULL, ":", &bufptr)) {
00128 av_free(over->y_expr);
00129 if (!(over->y_expr = av_strdup(expr))) {
00130 ret = AVERROR(ENOMEM);
00131 goto end;
00132 }
00133 }
00134
00135 if (bufptr && (ret = av_set_options_string(over, bufptr, "=", ":")) < 0)
00136 goto end;
00137
00138 end:
00139 av_free(args1);
00140 return ret;
00141 }
00142
00143 static av_cold void uninit(AVFilterContext *ctx)
00144 {
00145 OverlayContext *over = ctx->priv;
00146
00147 av_freep(&over->x_expr);
00148 av_freep(&over->y_expr);
00149
00150 avfilter_unref_bufferp(&over->overpicref);
00151 ff_bufqueue_discard_all(&over->queue_main);
00152 ff_bufqueue_discard_all(&over->queue_over);
00153 }
00154
00155 static int query_formats(AVFilterContext *ctx)
00156 {
00157 OverlayContext *over = ctx->priv;
00158
00159
00160 const enum PixelFormat main_pix_fmts_yuv[] = { PIX_FMT_YUV420P, PIX_FMT_NONE };
00161 const enum PixelFormat overlay_pix_fmts_yuv[] = { PIX_FMT_YUVA420P, PIX_FMT_NONE };
00162 const enum PixelFormat main_pix_fmts_rgb[] = {
00163 PIX_FMT_ARGB, PIX_FMT_RGBA,
00164 PIX_FMT_ABGR, PIX_FMT_BGRA,
00165 PIX_FMT_RGB24, PIX_FMT_BGR24,
00166 PIX_FMT_NONE
00167 };
00168 const enum PixelFormat overlay_pix_fmts_rgb[] = {
00169 PIX_FMT_ARGB, PIX_FMT_RGBA,
00170 PIX_FMT_ABGR, PIX_FMT_BGRA,
00171 PIX_FMT_NONE
00172 };
00173
00174 AVFilterFormats *main_formats;
00175 AVFilterFormats *overlay_formats;
00176
00177 if (over->allow_packed_rgb) {
00178 main_formats = ff_make_format_list(main_pix_fmts_rgb);
00179 overlay_formats = ff_make_format_list(overlay_pix_fmts_rgb);
00180 } else {
00181 main_formats = ff_make_format_list(main_pix_fmts_yuv);
00182 overlay_formats = ff_make_format_list(overlay_pix_fmts_yuv);
00183 }
00184
00185 ff_formats_ref(main_formats, &ctx->inputs [MAIN ]->out_formats);
00186 ff_formats_ref(overlay_formats, &ctx->inputs [OVERLAY]->out_formats);
00187 ff_formats_ref(main_formats, &ctx->outputs[MAIN ]->in_formats );
00188
00189 return 0;
00190 }
00191
00192 static const enum PixelFormat alpha_pix_fmts[] = {
00193 PIX_FMT_YUVA420P, PIX_FMT_ARGB, PIX_FMT_ABGR, PIX_FMT_RGBA,
00194 PIX_FMT_BGRA, PIX_FMT_NONE
00195 };
00196
00197 static int config_input_main(AVFilterLink *inlink)
00198 {
00199 OverlayContext *over = inlink->dst->priv;
00200 const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[inlink->format];
00201
00202 av_image_fill_max_pixsteps(over->main_pix_step, NULL, pix_desc);
00203
00204 over->hsub = pix_desc->log2_chroma_w;
00205 over->vsub = pix_desc->log2_chroma_h;
00206
00207 over->main_is_packed_rgb =
00208 ff_fill_rgba_map(over->main_rgba_map, inlink->format) >= 0;
00209 over->main_has_alpha = ff_fmt_is_in(inlink->format, alpha_pix_fmts);
00210 return 0;
00211 }
00212
00213 static int config_input_overlay(AVFilterLink *inlink)
00214 {
00215 AVFilterContext *ctx = inlink->dst;
00216 OverlayContext *over = inlink->dst->priv;
00217 char *expr;
00218 double var_values[VAR_VARS_NB], res;
00219 int ret;
00220 const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[inlink->format];
00221
00222 av_image_fill_max_pixsteps(over->overlay_pix_step, NULL, pix_desc);
00223
00224
00225
00226 var_values[VAR_MAIN_W ] = var_values[VAR_MW] = ctx->inputs[MAIN ]->w;
00227 var_values[VAR_MAIN_H ] = var_values[VAR_MH] = ctx->inputs[MAIN ]->h;
00228 var_values[VAR_OVERLAY_W] = var_values[VAR_OW] = ctx->inputs[OVERLAY]->w;
00229 var_values[VAR_OVERLAY_H] = var_values[VAR_OH] = ctx->inputs[OVERLAY]->h;
00230
00231 if ((ret = av_expr_parse_and_eval(&res, (expr = over->x_expr), var_names, var_values,
00232 NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
00233 goto fail;
00234 over->x = res;
00235 if ((ret = av_expr_parse_and_eval(&res, (expr = over->y_expr), var_names, var_values,
00236 NULL, NULL, NULL, NULL, NULL, 0, ctx)))
00237 goto fail;
00238 over->y = res;
00239
00240 if ((ret = av_expr_parse_and_eval(&res, (expr = over->x_expr), var_names, var_values,
00241 NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
00242 goto fail;
00243 over->x = res;
00244
00245 over->overlay_is_packed_rgb =
00246 ff_fill_rgba_map(over->overlay_rgba_map, inlink->format) >= 0;
00247 over->overlay_has_alpha = ff_fmt_is_in(inlink->format, alpha_pix_fmts);
00248
00249 av_log(ctx, AV_LOG_VERBOSE,
00250 "main w:%d h:%d fmt:%s overlay x:%d y:%d w:%d h:%d fmt:%s\n",
00251 ctx->inputs[MAIN]->w, ctx->inputs[MAIN]->h,
00252 av_pix_fmt_descriptors[ctx->inputs[MAIN]->format].name,
00253 over->x, over->y,
00254 ctx->inputs[OVERLAY]->w, ctx->inputs[OVERLAY]->h,
00255 av_pix_fmt_descriptors[ctx->inputs[OVERLAY]->format].name);
00256
00257 if (over->x < 0 || over->y < 0 ||
00258 over->x + var_values[VAR_OVERLAY_W] > var_values[VAR_MAIN_W] ||
00259 over->y + var_values[VAR_OVERLAY_H] > var_values[VAR_MAIN_H]) {
00260 av_log(ctx, AV_LOG_ERROR,
00261 "Overlay area (%d,%d)<->(%d,%d) not within the main area (0,0)<->(%d,%d) or zero-sized\n",
00262 over->x, over->y,
00263 (int)(over->x + var_values[VAR_OVERLAY_W]),
00264 (int)(over->y + var_values[VAR_OVERLAY_H]),
00265 (int)var_values[VAR_MAIN_W], (int)var_values[VAR_MAIN_H]);
00266 return AVERROR(EINVAL);
00267 }
00268 return 0;
00269
00270 fail:
00271 av_log(NULL, AV_LOG_ERROR,
00272 "Error when evaluating the expression '%s'\n", expr);
00273 return ret;
00274 }
00275
00276 static int config_output(AVFilterLink *outlink)
00277 {
00278 AVFilterContext *ctx = outlink->src;
00279 int exact;
00280
00281 AVRational tb1 = ctx->inputs[MAIN ]->time_base;
00282 AVRational tb2 = ctx->inputs[OVERLAY]->time_base;
00283 AVRational *tb = &ctx->outputs[0]->time_base;
00284 exact = av_reduce(&tb->num, &tb->den,
00285 av_gcd((int64_t)tb1.num * tb2.den,
00286 (int64_t)tb2.num * tb1.den),
00287 (int64_t)tb1.den * tb2.den, INT_MAX);
00288 av_log(ctx, AV_LOG_VERBOSE,
00289 "main_tb:%d/%d overlay_tb:%d/%d -> tb:%d/%d exact:%d\n",
00290 tb1.num, tb1.den, tb2.num, tb2.den, tb->num, tb->den, exact);
00291 if (!exact)
00292 av_log(ctx, AV_LOG_WARNING,
00293 "Timestamp conversion inexact, timestamp information loss may occurr\n");
00294
00295 outlink->w = ctx->inputs[MAIN]->w;
00296 outlink->h = ctx->inputs[MAIN]->h;
00297
00298 return 0;
00299 }
00300
00301 static AVFilterBufferRef *get_video_buffer(AVFilterLink *link, int perms, int w, int h)
00302 {
00303 return ff_get_video_buffer(link->dst->outputs[0], perms, w, h);
00304 }
00305
00306
00307
00308 #define FAST_DIV255(x) ((((x) + 128) * 257) >> 16)
00309
00310 static void blend_slice(AVFilterContext *ctx,
00311 AVFilterBufferRef *dst, AVFilterBufferRef *src,
00312 int x, int y, int w, int h,
00313 int slice_y, int slice_w, int slice_h)
00314 {
00315 OverlayContext *over = ctx->priv;
00316 int i, j, k;
00317 int width, height;
00318 int overlay_end_y = y+h;
00319 int slice_end_y = slice_y+slice_h;
00320 int end_y, start_y;
00321
00322 width = FFMIN(slice_w - x, w);
00323 end_y = FFMIN(slice_end_y, overlay_end_y);
00324 start_y = FFMAX(y, slice_y);
00325 height = end_y - start_y;
00326
00327 if (over->main_is_packed_rgb) {
00328 uint8_t *dp = dst->data[0] + x * over->main_pix_step[0] +
00329 start_y * dst->linesize[0];
00330 uint8_t *sp = src->data[0];
00331 uint8_t alpha;
00332 const int dr = over->main_rgba_map[R];
00333 const int dg = over->main_rgba_map[G];
00334 const int db = over->main_rgba_map[B];
00335 const int da = over->main_rgba_map[A];
00336 const int dstep = over->main_pix_step[0];
00337 const int sr = over->overlay_rgba_map[R];
00338 const int sg = over->overlay_rgba_map[G];
00339 const int sb = over->overlay_rgba_map[B];
00340 const int sa = over->overlay_rgba_map[A];
00341 const int sstep = over->overlay_pix_step[0];
00342 const int main_has_alpha = over->main_has_alpha;
00343 if (slice_y > y)
00344 sp += (slice_y - y) * src->linesize[0];
00345 for (i = 0; i < height; i++) {
00346 uint8_t *d = dp, *s = sp;
00347 for (j = 0; j < width; j++) {
00348 alpha = s[sa];
00349
00350
00351
00352 if (main_has_alpha && alpha != 0 && alpha != 255) {
00353
00354
00355 alpha =
00356
00357 ( (alpha << 16) - (alpha << 9) + alpha )
00358 /
00359
00360 ( ((alpha + d[da]) << 8 ) - (alpha + d[da])
00361 - d[da] * alpha );
00362 }
00363
00364 switch (alpha) {
00365 case 0:
00366 break;
00367 case 255:
00368 d[dr] = s[sr];
00369 d[dg] = s[sg];
00370 d[db] = s[sb];
00371 break;
00372 default:
00373
00374
00375 d[dr] = FAST_DIV255(d[dr] * (255 - alpha) + s[sr] * alpha);
00376 d[dg] = FAST_DIV255(d[dg] * (255 - alpha) + s[sg] * alpha);
00377 d[db] = FAST_DIV255(d[db] * (255 - alpha) + s[sb] * alpha);
00378 }
00379 if (main_has_alpha) {
00380 switch (alpha) {
00381 case 0:
00382 break;
00383 case 255:
00384 d[da] = s[sa];
00385 break;
00386 default:
00387
00388 d[da] += FAST_DIV255((255 - d[da]) * s[sa]);
00389 }
00390 }
00391 d += dstep;
00392 s += sstep;
00393 }
00394 dp += dst->linesize[0];
00395 sp += src->linesize[0];
00396 }
00397 } else {
00398 for (i = 0; i < 3; i++) {
00399 int hsub = i ? over->hsub : 0;
00400 int vsub = i ? over->vsub : 0;
00401 uint8_t *dp = dst->data[i] + (x >> hsub) +
00402 (start_y >> vsub) * dst->linesize[i];
00403 uint8_t *sp = src->data[i];
00404 uint8_t *ap = src->data[3];
00405 int wp = FFALIGN(width, 1<<hsub) >> hsub;
00406 int hp = FFALIGN(height, 1<<vsub) >> vsub;
00407 if (slice_y > y) {
00408 sp += ((slice_y - y) >> vsub) * src->linesize[i];
00409 ap += (slice_y - y) * src->linesize[3];
00410 }
00411 for (j = 0; j < hp; j++) {
00412 uint8_t *d = dp, *s = sp, *a = ap;
00413 for (k = 0; k < wp; k++) {
00414
00415 int alpha_v, alpha_h, alpha;
00416 if (hsub && vsub && j+1 < hp && k+1 < wp) {
00417 alpha = (a[0] + a[src->linesize[3]] +
00418 a[1] + a[src->linesize[3]+1]) >> 2;
00419 } else if (hsub || vsub) {
00420 alpha_h = hsub && k+1 < wp ?
00421 (a[0] + a[1]) >> 1 : a[0];
00422 alpha_v = vsub && j+1 < hp ?
00423 (a[0] + a[src->linesize[3]]) >> 1 : a[0];
00424 alpha = (alpha_v + alpha_h) >> 1;
00425 } else
00426 alpha = a[0];
00427 *d = FAST_DIV255(*d * (255 - alpha) + *s * alpha);
00428 s++;
00429 d++;
00430 a += 1 << hsub;
00431 }
00432 dp += dst->linesize[i];
00433 sp += src->linesize[i];
00434 ap += (1 << vsub) * src->linesize[3];
00435 }
00436 }
00437 }
00438 }
00439
00440 static int try_start_frame(AVFilterContext *ctx, AVFilterBufferRef *mainpic)
00441 {
00442 OverlayContext *over = ctx->priv;
00443 AVFilterLink *outlink = ctx->outputs[0];
00444 AVFilterBufferRef *next_overpic, *outpicref;
00445 int ret;
00446
00447
00448
00449 while (1) {
00450 next_overpic = ff_bufqueue_peek(&over->queue_over, 0);
00451 if (!next_overpic || next_overpic->pts > mainpic->pts)
00452 break;
00453 ff_bufqueue_get(&over->queue_over);
00454 avfilter_unref_buffer(over->overpicref);
00455 over->overpicref = next_overpic;
00456 }
00457
00458
00459 if (!over->queue_over.available && !over->overlay_eof &&
00460 (!over->overpicref || over->overpicref->pts < mainpic->pts))
00461 return AVERROR(EAGAIN);
00462
00463
00464 outlink->out_buf = outpicref = avfilter_ref_buffer(mainpic, ~0);
00465
00466 av_dlog(ctx, "main_pts:%s main_pts_time:%s",
00467 av_ts2str(outpicref->pts), av_ts2timestr(outpicref->pts, &outlink->time_base));
00468 if (over->overpicref)
00469 av_dlog(ctx, " over_pts:%s over_pts_time:%s",
00470 av_ts2str(over->overpicref->pts), av_ts2timestr(over->overpicref->pts, &outlink->time_base));
00471 av_dlog(ctx, "\n");
00472
00473 ret = ff_start_frame(ctx->outputs[0], avfilter_ref_buffer(outpicref, ~0));
00474 over->frame_requested = 0;
00475 return ret;
00476 }
00477
00478 static int try_start_next_frame(AVFilterContext *ctx)
00479 {
00480 OverlayContext *over = ctx->priv;
00481 AVFilterBufferRef *next_mainpic = ff_bufqueue_peek(&over->queue_main, 0);
00482 int ret;
00483
00484 if (!next_mainpic)
00485 return AVERROR(EAGAIN);
00486 if ((ret = try_start_frame(ctx, next_mainpic)) == AVERROR(EAGAIN))
00487 return ret;
00488 avfilter_unref_buffer(ff_bufqueue_get(&over->queue_main));
00489 return ret;
00490 }
00491
00492 static int try_push_frame(AVFilterContext *ctx)
00493 {
00494 OverlayContext *over = ctx->priv;
00495 AVFilterLink *outlink = ctx->outputs[0];
00496 AVFilterBufferRef *outpicref;
00497 int ret;
00498
00499 if ((ret = try_start_next_frame(ctx)) < 0)
00500 return ret;
00501 outpicref = outlink->out_buf;
00502 if (over->overpicref)
00503 blend_slice(ctx, outpicref, over->overpicref, over->x, over->y,
00504 over->overpicref->video->w, over->overpicref->video->h,
00505 0, outpicref->video->w, outpicref->video->h);
00506 if ((ret = ff_draw_slice(outlink, 0, outpicref->video->h, +1)) < 0 ||
00507 (ret = ff_end_frame(outlink)) < 0)
00508 return ret;
00509 return 0;
00510 }
00511
00512 static int flush_frames(AVFilterContext *ctx)
00513 {
00514 int ret;
00515
00516 while (!(ret = try_push_frame(ctx)));
00517 return ret == AVERROR(EAGAIN) ? 0 : ret;
00518 }
00519
00520 static int start_frame_main(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
00521 {
00522 AVFilterContext *ctx = inlink->dst;
00523 OverlayContext *over = ctx->priv;
00524 int ret;
00525
00526 if ((ret = flush_frames(ctx)) < 0)
00527 return ret;
00528 inpicref->pts = av_rescale_q(inpicref->pts, ctx->inputs[MAIN]->time_base,
00529 ctx->outputs[0]->time_base);
00530 if ((ret = try_start_frame(ctx, inpicref)) < 0) {
00531 if (ret != AVERROR(EAGAIN))
00532 return ret;
00533 ff_bufqueue_add(ctx, &over->queue_main, inpicref);
00534 av_assert1(inpicref == inlink->cur_buf);
00535 inlink->cur_buf = NULL;
00536 }
00537 return 0;
00538 }
00539
00540 static int draw_slice_main(AVFilterLink *inlink, int y, int h, int slice_dir)
00541 {
00542 AVFilterContext *ctx = inlink->dst;
00543 OverlayContext *over = ctx->priv;
00544 AVFilterLink *outlink = ctx->outputs[0];
00545 AVFilterBufferRef *outpicref = outlink->out_buf;
00546
00547 if (!outpicref)
00548 return 0;
00549 if (over->overpicref &&
00550 y + h > over->y && y < over->y + over->overpicref->video->h) {
00551 blend_slice(ctx, outpicref, over->overpicref, over->x, over->y,
00552 over->overpicref->video->w, over->overpicref->video->h,
00553 y, outpicref->video->w, h);
00554 }
00555 return ff_draw_slice(outlink, y, h, slice_dir);
00556 }
00557
00558 static int end_frame_main(AVFilterLink *inlink)
00559 {
00560 AVFilterContext *ctx = inlink->dst;
00561 AVFilterLink *outlink = ctx->outputs[0];
00562 AVFilterBufferRef *outpicref = outlink->out_buf;
00563 flush_frames(ctx);
00564
00565 if (!outpicref)
00566 return 0;
00567 return ff_end_frame(ctx->outputs[0]);
00568 }
00569
00570 static int start_frame_over(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
00571 {
00572 return 0;
00573 }
00574
00575 static int end_frame_over(AVFilterLink *inlink)
00576 {
00577 AVFilterContext *ctx = inlink->dst;
00578 OverlayContext *over = ctx->priv;
00579 AVFilterBufferRef *inpicref = inlink->cur_buf;
00580 int ret;
00581
00582 inlink->cur_buf = NULL;
00583
00584 if ((ret = flush_frames(ctx)) < 0)
00585 return ret;
00586 inpicref->pts = av_rescale_q(inpicref->pts, ctx->inputs[OVERLAY]->time_base,
00587 ctx->outputs[0]->time_base);
00588 ff_bufqueue_add(ctx, &over->queue_over, inpicref);
00589 ret = try_push_frame(ctx);
00590 return ret == AVERROR(EAGAIN) ? 0 : ret;
00591 }
00592
00593 static int request_frame(AVFilterLink *outlink)
00594 {
00595 AVFilterContext *ctx = outlink->src;
00596 OverlayContext *over = ctx->priv;
00597 int input, ret;
00598
00599 if (!try_push_frame(ctx))
00600 return 0;
00601 over->frame_requested = 1;
00602 while (over->frame_requested) {
00603
00604 input = !over->overlay_eof && (over->queue_main.available ||
00605 over->queue_over.available < 2) ?
00606 OVERLAY : MAIN;
00607 ret = ff_request_frame(ctx->inputs[input]);
00608
00609 if (ret == AVERROR_EOF && input == OVERLAY) {
00610 over->overlay_eof = 1;
00611 if ((ret = try_start_next_frame(ctx)) != AVERROR(EAGAIN))
00612 return ret;
00613 ret = 0;
00614 }
00615 if (ret < 0)
00616 return ret;
00617 }
00618 return 0;
00619 }
00620
00621 static int null_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
00622 {
00623 return 0;
00624 }
00625
00626 AVFilter avfilter_vf_overlay = {
00627 .name = "overlay",
00628 .description = NULL_IF_CONFIG_SMALL("Overlay a video source on top of the input."),
00629
00630 .init = init,
00631 .uninit = uninit,
00632
00633 .priv_size = sizeof(OverlayContext),
00634
00635 .query_formats = query_formats,
00636
00637 .inputs = (const AVFilterPad[]) {{ .name = "main",
00638 .type = AVMEDIA_TYPE_VIDEO,
00639 .get_video_buffer= get_video_buffer,
00640 .config_props = config_input_main,
00641 .start_frame = start_frame_main,
00642 .draw_slice = draw_slice_main,
00643 .end_frame = end_frame_main,
00644 .min_perms = AV_PERM_READ | AV_PERM_WRITE | AV_PERM_PRESERVE },
00645 { .name = "overlay",
00646 .type = AVMEDIA_TYPE_VIDEO,
00647 .config_props = config_input_overlay,
00648 .start_frame = start_frame_over,
00649 .draw_slice = null_draw_slice,
00650 .end_frame = end_frame_over,
00651 .min_perms = AV_PERM_READ | AV_PERM_PRESERVE },
00652 { .name = NULL}},
00653 .outputs = (const AVFilterPad[]) {{ .name = "default",
00654 .type = AVMEDIA_TYPE_VIDEO,
00655 .rej_perms = AV_PERM_WRITE,
00656 .config_props = config_output,
00657 .request_frame = request_frame, },
00658 { .name = NULL}},
00659 .priv_class = &overlay_class,
00660 };