[FFmpeg-devel] [PATCH v2 2/4] lavfi/vf_scale: use single default swscale flags for simple and complex filter graph

Nicolas George george at nsup.org
Mon Aug 2 20:04:08 EEST 2021


Linjie Fu (12021-08-03):
> From: Linjie Fu <linjie.justin.fu at gmail.com>
> 
> Currently the default swscale flags for simple filter graph is bicubic,
> however for complex filter graph it uses bilinear as decleared in scale
> filter.
> 
> $ffmpeg -v verbose -i input.mp4 -vf format=yuv420p,scale=800x600 -an -f null -
> [Parsed_scale_1 @ 0x7f86d2c160c0] w:1920 h:1080 fmt:yuv420p sar:0/1 -> w:800 h:600 fmt:yuv420p sar:0/1 flags:0x4
> 
> $ffmpeg -v verbose -i input.mp4 -filter_complex format=yuv420p,scale=800x600 -an -f null -
> [Parsed_scale_1 @ 0x7f8779e046c0] w:1920 h:1080 fmt:yuv420p sar:0/1 -> w:800 h:600 fmt:yuv420p sar:0/1 flags:0x2
> 
> Set the default flags for scale filter to "bicubic" to match the behaviour in swscale.
> And remove setting defaults in ffmpeg/ffprobe/ffplay.
> 
> Signed-off-by: Linjie Fu <linjie.justin.fu at gmail.com>
> ---
>  fftools/cmdutils.c     | 8 --------
>  fftools/ffplay.c       | 2 --
>  fftools/ffprobe.c      | 1 -
>  libavfilter/vf_scale.c | 2 +-
>  4 files changed, 1 insertion(+), 12 deletions(-)
> 
> diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
> index 0b1ef03a25..912e881174 100644
> --- a/fftools/cmdutils.c
> +++ b/fftools/cmdutils.c
> @@ -81,11 +81,6 @@ enum show_muxdemuxers {
>      SHOW_MUXERS,
>  };
>  
> -void init_opts(void)
> -{
> -    av_dict_set(&sws_dict, "flags", "bicubic", 0);
> -}
> -
>  void uninit_opts(void)
>  {
>      av_dict_free(&swr_opts);
> @@ -670,7 +665,6 @@ static void finish_group(OptionParseContext *octx, int group_idx,
>      resample_opts = NULL;
>      sws_dict    = NULL;
>      swr_opts    = NULL;
> -    init_opts();
>  
>      memset(&octx->cur_group, 0, sizeof(octx->cur_group));
>  }
> @@ -708,8 +702,6 @@ static void init_parse_context(OptionParseContext *octx,
>  
>      octx->global_opts.group_def = &global_group;
>      octx->global_opts.arg       = "";
> -
> -    init_opts();
>  }
>  
>  void uninit_parse_context(OptionParseContext *octx)
> diff --git a/fftools/ffplay.c b/fftools/ffplay.c
> index 6b19574eae..46758b9f55 100644
> --- a/fftools/ffplay.c
> +++ b/fftools/ffplay.c
> @@ -3695,8 +3695,6 @@ int main(int argc, char **argv)
>  #endif
>      avformat_network_init();
>  
> -    init_opts();
> -
>      signal(SIGINT , sigterm_handler); /* Interrupt (ANSI).    */
>      signal(SIGTERM, sigterm_handler); /* Termination (ANSI).  */
>  
> diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
> index f411ba35b5..95263e1e6f 100644
> --- a/fftools/ffprobe.c
> +++ b/fftools/ffprobe.c
> @@ -3721,7 +3721,6 @@ int main(int argc, char **argv)
>      options = real_options;
>      parse_loglevel(argc, argv, options);
>      avformat_network_init();
> -    init_opts();
>  #if CONFIG_AVDEVICE
>      avdevice_register_all();
>  #endif
> diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
> index f07e01bf90..3029ab4b68 100644
> --- a/libavfilter/vf_scale.c
> +++ b/libavfilter/vf_scale.c
> @@ -900,7 +900,7 @@ static const AVOption scale_options[] = {
>      { "width", "Output video width",          OFFSET(w_expr),    AV_OPT_TYPE_STRING,        .flags = TFLAGS },
>      { "h",     "Output video height",         OFFSET(h_expr),    AV_OPT_TYPE_STRING,        .flags = TFLAGS },
>      { "height","Output video height",         OFFSET(h_expr),    AV_OPT_TYPE_STRING,        .flags = TFLAGS },

> -    { "flags", "Flags to pass to libswscale", OFFSET(flags_str), AV_OPT_TYPE_STRING, { .str = "bilinear" }, .flags = FLAGS },
> +    { "flags", "Flags to pass to libswscale", OFFSET(flags_str), AV_OPT_TYPE_STRING, { .str = "bicubic" }, .flags = FLAGS },

This is wrong: still overriding swscale's default.

>      { "interl", "set interlacing", OFFSET(interlaced), AV_OPT_TYPE_BOOL, {.i64 = 0 }, -1, 1, FLAGS },
>      { "size",   "set video size",          OFFSET(size_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, FLAGS },
>      { "s",      "set video size",          OFFSET(size_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, FLAGS },

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20210802/a0ebb852/attachment.sig>


More information about the ffmpeg-devel mailing list