[FFmpeg-devel] [PATCH v4 1/3] lavfi/vf_scale: use default swscale flags for scaler

Linjie Fu fulinjie at zju.edu.cn
Wed Aug 4 20:03:09 EEST 2021


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

Use default swscale flags (bicubic currently) for scale filter.
- Remove flags="bilinear" from vf_scale
- Update the FATE refs

Signed-off-by: Linjie Fu <linjie.justin.fu at gmail.com>
---
 libavfilter/vf_scale.c                      |  4 ++--
 tests/ref/fate/filter-scale2ref_keep_aspect | 10 +++++-----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index f07e01bf90..683c4caa37 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -313,7 +313,7 @@ static av_cold int init_dict(AVFilterContext *ctx, AVDictionary **opts)
 
     scale->flags = 0;
 
-    if (scale->flags_str) {
+    if (*scale->flags_str) {
         const AVClass *class = sws_get_class();
         const AVOption    *o = av_opt_find(&class, "sws_flags", NULL, 0,
                                            AV_OPT_SEARCH_FAKE_OBJ);
@@ -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 = "" }, .flags = FLAGS },
     { "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 },
diff --git a/tests/ref/fate/filter-scale2ref_keep_aspect b/tests/ref/fate/filter-scale2ref_keep_aspect
index 8dd0dbb13b..53c6fc14ec 100644
--- a/tests/ref/fate/filter-scale2ref_keep_aspect
+++ b/tests/ref/fate/filter-scale2ref_keep_aspect
@@ -7,8 +7,8 @@
 #dimensions 0: 160x120
 #sar 0: 1/1
 #stream#, dts,        pts, duration,     size, hash
-0,          0,          0,        1,    57600, 9a19c23dc3a557786840d0098606d5f1
-0,          1,          1,        1,    57600, e6fbdabaf1bb0d28afc648ed4d27e9f0
-0,          2,          2,        1,    57600, 52924ed0a751214c50fb2e7a626c8cc5
-0,          3,          3,        1,    57600, 67d5fd6ee71793f1cf8794d1c27afdce
-0,          4,          4,        1,    57600, 85f7775f7b01afd369fc8919dc759d30
+0,          0,          0,        1,    57600, 65fe9892ad710cc5763b04b390327d40
+0,          1,          1,        1,    57600, 5e8d4524bc8889afa8769e851e998bc0
+0,          2,          2,        1,    57600, 8f5e0e58d1f4c2104b82ef7a16850f1e
+0,          3,          3,        1,    57600, cfe4142845e1445d33748493faa63cda
+0,          4,          4,        1,    57600, bb491f3b01788773fb6129aef0f0abd2
-- 
2.31.1



More information about the ffmpeg-devel mailing list