[FFmpeg-cvslog] avfilter/guided: simplify subsampling assignment.

Gyan Doshi git at videolan.org
Fri May 14 13:05:25 EEST 2021


ffmpeg | branch: master | Gyan Doshi <ffmpeg at gyani.pro> | Fri May 14 09:27:49 2021 +0530| [93ddb9b6177ab668cae92f9b117a91b05cde386f] | committer: Gyan Doshi

avfilter/guided: simplify subsampling assignment.

Reduce option ranges to effective values.

Signed-off-by: Gyan Doshi <ffmpeg at gyani.pro>
Reviewed-by: Steven Liu <liuqi05 at kuaishou.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=93ddb9b6177ab668cae92f9b117a91b05cde386f
---

 libavfilter/vf_guided.c | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/libavfilter/vf_guided.c b/libavfilter/vf_guided.c
index e7c689e7be..88bae5ab19 100644
--- a/libavfilter/vf_guided.c
+++ b/libavfilter/vf_guided.c
@@ -61,10 +61,10 @@ typedef struct GuidedContext {
 static const AVOption guided_options[] = {
     { "radius", "set the box radius",                               OFFSET(radius), AV_OPT_TYPE_INT,   {.i64 = 3    },   1,           20, FLAGS },
     { "eps",    "set the regularization parameter (with square)",   OFFSET(eps),    AV_OPT_TYPE_FLOAT, {.dbl = 0.01 }, 0.0,            1, FLAGS },
-    { "mode",   "set filtering mode (0: basic mode; 1: fast mode)", OFFSET(mode),   AV_OPT_TYPE_INT,   {.i64 = BASIC},   0, NB_MODES - 1, FLAGS, "mode" },
+    { "mode",   "set filtering mode (0: basic mode; 1: fast mode)", OFFSET(mode),   AV_OPT_TYPE_INT,   {.i64 = BASIC}, BASIC, NB_MODES - 1, FLAGS, "mode" },
     { "basic",  "basic guided filter",                              0,              AV_OPT_TYPE_CONST, {.i64 = BASIC},   0,            0, FLAGS, "mode" },
     { "fast",   "fast guided filter",                               0,              AV_OPT_TYPE_CONST, {.i64 = FAST },   0,            0, FLAGS, "mode" },
-    { "sub",    "subsampling ratio",                                OFFSET(sub),    AV_OPT_TYPE_INT,   {.i64 = 1    },   1,           64, FLAGS },
+    { "sub",    "subsampling ratio for fast mode",                  OFFSET(sub),    AV_OPT_TYPE_INT,   {.i64 = 4    },   2,           64, FLAGS },
     { "planes", "set planes to filter",                             OFFSET(planes), AV_OPT_TYPE_INT,   {.i64=1      },   0,          0xF, FLAGS },
     { NULL }
 };
@@ -160,24 +160,14 @@ static int config_input(AVFilterLink *inlink)
     }
 
     if (s->mode == BASIC) {
-        if (s->sub != 1) {
-            av_log(ctx, AV_LOG_WARNING, "Subsampling ratio is 1 in basic mode.\n");
-            s->sub = 1;
-        }
+        s->sub = 1;
     }
     else if (s->mode == FAST) {
-        if (s->sub == 1) {
-            av_log(ctx, AV_LOG_WARNING, "Subsampling ratio is larger than 1 in fast mode.\n");
-            s->sub = 4;
-        }
-        if (s->radius >= s->sub)
-            s->radius = s->radius / s->sub;
-        else {
-            s->radius = 1;
-        }
-    }
-    else {
-        return AVERROR_BUG;
+       if (s->radius >= s->sub)
+           s->radius = s->radius / s->sub;
+       else {
+           s->radius = 1;
+       }
     }
 
     s->depth = desc->comp[0].depth;



More information about the ffmpeg-cvslog mailing list