[FFmpeg-devel] [PATCH 07/14] lavfi/vf_overlay: use framesync2 options.

Michael Niedermayer michael at niedermayer.cc
Wed Aug 2 04:47:17 EEST 2017


On Mon, Jul 31, 2017 at 02:02:20PM +0200, Nicolas George wrote:
> Signed-off-by: Nicolas George <george at nsup.org>
> ---
>  libavfilter/vf_overlay.c | 45 ++++-----------------------------------------
>  1 file changed, 4 insertions(+), 41 deletions(-)
> 
> diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
> index c1d2a21c05..512df87630 100644
> --- a/libavfilter/vf_overlay.c
> +++ b/libavfilter/vf_overlay.c
> @@ -70,16 +70,6 @@ enum var_name {
>      VAR_VARS_NB
>  };
>  
> -enum EOFAction {
> -    EOF_ACTION_REPEAT,
> -    EOF_ACTION_ENDALL,
> -    EOF_ACTION_PASS
> -};
> -
> -static const char * const eof_action_str[] = {
> -    "repeat", "endall", "pass"
> -};
> -
>  #define MAIN    0
>  #define OVERLAY 1
>  
> @@ -131,10 +121,6 @@ typedef struct OverlayContext {
>      double var_values[VAR_VARS_NB];
>      char *x_expr, *y_expr;
>  
> -    int eof_action;             ///< action to take on EOF from source
> -    int opt_shortest;
> -    int opt_repeatlast;
> -
>      AVExpr *x_pexpr, *y_pexpr;
>  
>      void (*blend_image)(AVFilterContext *ctx, AVFrame *dst, const AVFrame *src, int x, int y);
> @@ -377,12 +363,11 @@ static int config_input_overlay(AVFilterLink *inlink)
>      }
>  
>      av_log(ctx, AV_LOG_VERBOSE,
> -           "main w:%d h:%d fmt:%s overlay w:%d h:%d fmt:%s eof_action:%s\n",
> +           "main w:%d h:%d fmt:%s overlay w:%d h:%d fmt:%s\n",
>             ctx->inputs[MAIN]->w, ctx->inputs[MAIN]->h,
>             av_get_pix_fmt_name(ctx->inputs[MAIN]->format),
>             ctx->inputs[OVERLAY]->w, ctx->inputs[OVERLAY]->h,
> -           av_get_pix_fmt_name(ctx->inputs[OVERLAY]->format),
> -           eof_action_str[s->eof_action]);
> +           av_get_pix_fmt_name(ctx->inputs[OVERLAY]->format));
>      return 0;
>  }
>  
> @@ -394,12 +379,6 @@ static int config_output(AVFilterLink *outlink)
>  
>      if ((ret = ff_framesync2_init_dualinput(&s->fs, ctx)) < 0)
>          return ret;
> -    if (s->opt_shortest)
> -        s->fs.in[0].after = s->fs.in[1].after = EXT_STOP;
> -    if (!s->opt_repeatlast) {
> -        s->fs.in[1].after = EXT_NULL;
> -        s->fs.in[1].sync  = 0;
> -    }
>  
>      outlink->w = ctx->inputs[MAIN]->w;
>      outlink->h = ctx->inputs[MAIN]->h;
> @@ -818,15 +797,6 @@ static av_cold int init(AVFilterContext *ctx)
>  {
>      OverlayContext *s = ctx->priv;
>  
> -    if (!s->opt_repeatlast || s->eof_action == EOF_ACTION_PASS) {
> -        s->opt_repeatlast = 0;
> -        s->eof_action = EOF_ACTION_PASS;
> -    }
> -    if (s->opt_shortest || s->eof_action == EOF_ACTION_ENDALL) {
> -        s->opt_shortest = 1;
> -        s->eof_action = EOF_ACTION_ENDALL;
> -    }
> -
>      s->fs.on_event = do_blend;
>      return 0;
>  }

> @@ -843,16 +813,9 @@ static int activate(AVFilterContext *ctx)
>  static const AVOption overlay_options[] = {
>      { "x", "set the x expression", OFFSET(x_expr), AV_OPT_TYPE_STRING, {.str = "0"}, CHAR_MIN, CHAR_MAX, FLAGS },
>      { "y", "set the y expression", OFFSET(y_expr), AV_OPT_TYPE_STRING, {.str = "0"}, CHAR_MIN, CHAR_MAX, FLAGS },
> -    { "eof_action", "Action to take when encountering EOF from secondary input ",
> -        OFFSET(eof_action), AV_OPT_TYPE_INT, { .i64 = EOF_ACTION_REPEAT },
> -        EOF_ACTION_REPEAT, EOF_ACTION_PASS, .flags = FLAGS, "eof_action" },
> -        { "repeat", "Repeat the previous frame.",   0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_REPEAT }, .flags = FLAGS, "eof_action" },
> -        { "endall", "End both streams.",            0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_ENDALL }, .flags = FLAGS, "eof_action" },
> -        { "pass",   "Pass through the main input.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_PASS },   .flags = FLAGS, "eof_action" },
>      { "eval", "specify when to evaluate expressions", OFFSET(eval_mode), AV_OPT_TYPE_INT, {.i64 = EVAL_MODE_FRAME}, 0, EVAL_MODE_NB-1, FLAGS, "eval" },
>           { "init",  "eval expressions once during initialization", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_INIT},  .flags = FLAGS, .unit = "eval" },
>           { "frame", "eval expressions per-frame",                  0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_FRAME}, .flags = FLAGS, .unit = "eval" },
> -    { "shortest", "force termination when the shortest input terminates", OFFSET(opt_shortest), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
>      { "format", "set output format", OFFSET(format), AV_OPT_TYPE_INT, {.i64=OVERLAY_FORMAT_YUV420}, 0, OVERLAY_FORMAT_NB-1, FLAGS, "format" },
>          { "yuv420", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_YUV420}, .flags = FLAGS, .unit = "format" },
>          { "yuv422", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_YUV422}, .flags = FLAGS, .unit = "format" },
> @@ -860,11 +823,10 @@ static const AVOption overlay_options[] = {
>          { "rgb",    "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_RGB},    .flags = FLAGS, .unit = "format" },
>          { "gbrp",   "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_GBRP},   .flags = FLAGS, .unit = "format" },
>          { "auto",   "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_AUTO},   .flags = FLAGS, .unit = "format" },
> -    { "repeatlast", "repeat overlay of the last overlay frame", OFFSET(opt_repeatlast), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGS },
>      { NULL }
>  };

removing these elements causes command lines using them to fail
for example:


./ffmpeg -i matrixbench_mpeg2.mpg -i lena.pnm -filter_complex 'overlay=10:main_h-overlay_h-10:pass' -qscale 2 -t 1 file.avi


[overlay @ 0x3662fa0] [Eval @ 0x7ffd8a759260] Undefined constant or missing '(' in 'pass'
[overlay @ 0x3662fa0] Unable to parse option value "pass"
[overlay @ 0x3662fa0] [Eval @ 0x7ffd8a7592e0] Undefined constant or missing '(' in 'pass'
[overlay @ 0x3662fa0] Unable to parse option value "pass"
[overlay @ 0x3662fa0] Error setting option eval to value pass.
[Parsed_overlay_0 @ 0x3662ea0] Error applying options to the filter.
[AVFilterGraph @ 0x364f120] Error initializing filter 'overlay' with args '10:main_h-overlay_h-10:pass'
Error initializing complex filters.
Invalid argument


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Concerning the gods, I have no means of knowing whether they exist or not
or of what sort they may be, because of the obscurity of the subject, and
the brevity of human life -- Protagoras
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170802/09773310/attachment.sig>


More information about the ffmpeg-devel mailing list