[FFmpeg-devel] [PATCH 1/2] libavfilter/scale: More descriptive in/ref/out logging

Kevin Mark kmark937 at gmail.com
Mon Jun 5 13:55:20 EEST 2017


This change makes it more clear when using the scale and scale2ref
filters what is actually happening. The old format did not
differentiate between scale and scale2ref which would make it seem
that, when using scale2ref, the ref was what was truly being scaled.

Old format for both scale and scale2ref:

w:640 h:360 fmt:rgb24 sar:1/1 -> w:160 h:120 fmt:rgb24 sar:4/3 flags:0x2

The left side is the input and the right side is the output. While
this is sufficiently clear for scale, for scale2ref it appears to
conflate the main input with the reference input. To be fair that is
exactly what the code is doing (and on purpose) but that's not a very
intuitive implementation detail to expose to the user. Now that the
main input's constants are exposed in scale2ref it makes even more
sense to correct this.

New format for scale:

in  w:320 h:240 fmt:rgb24 sar:1/1
out w:80 h:60 fmt:rgb24 sar:1/1 flags:0xc0000

New format for scale2ref:

in  w:320 h:240 fmt:rgb24 sar:1/1
ref w:640 h:360 fmt:rgb24 sar:1/1
out w:160 h:120 fmt:rgb24 sar:4/3 flags:0x2

The increase in clarity is self-evident.

Signed-off-by: Kevin Mark <kmark937 at gmail.com>
---
 libavfilter/vf_scale.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index c59ac6b0ea..9232bc4439 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -342,9 +342,18 @@ static int config_props(AVFilterLink *outlink)
     } else
         outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
 
-    av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d fmt:%s sar:%d/%d -> w:%d h:%d fmt:%s sar:%d/%d flags:0x%0x\n",
-           inlink ->w, inlink ->h, av_get_pix_fmt_name( inlink->format),
-           inlink->sample_aspect_ratio.num, inlink->sample_aspect_ratio.den,
+    if (ctx->filter == &ff_vf_scale2ref) {
+        av_log(ctx, AV_LOG_VERBOSE, "in  w:%d h:%d fmt:%s sar:%d/%d\n",
+               inlink0->w, inlink0->h, av_get_pix_fmt_name(inlink0->format),
+               inlink0->sample_aspect_ratio.num, inlink0->sample_aspect_ratio.den);
+    }
+
+    av_log(ctx, AV_LOG_VERBOSE, "%s w:%d h:%d fmt:%s sar:%d/%d\n",
+           ctx->filter == &ff_vf_scale2ref ? "ref" : "in ",
+           inlink->w, inlink->h, av_get_pix_fmt_name(inlink->format),
+           inlink->sample_aspect_ratio.num, inlink->sample_aspect_ratio.den);
+
+    av_log(ctx, AV_LOG_VERBOSE, "out w:%d h:%d fmt:%s sar:%d/%d flags:0x%0x\n",
            outlink->w, outlink->h, av_get_pix_fmt_name(outlink->format),
            outlink->sample_aspect_ratio.num, outlink->sample_aspect_ratio.den,
            scale->flags);
-- 
2.13.0



More information about the ffmpeg-devel mailing list