[FFmpeg-devel] [PATCH v1] avfilter/vf_framerate: make the scene change detection calculation method consistent with f_select filter

lance.lmwang at gmail.com lance.lmwang at gmail.com
Thu Sep 12 13:22:59 EEST 2019


From: Limin Wang <lance.lmwang at gmail.com>

Have been tested by fate-suite/svq3/Vertical400kbit.sorenson3.mov and the
testing results are consistent.

If it is acceptable, I want to move get_scene_score() to the public function and
make the scene change detection calculation method of the relevant module consistent.

Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
---
 doc/filters.texi           | 4 ++--
 libavfilter/vf_framerate.c | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 9d500e44a9..1c2e86b635 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -10626,10 +10626,10 @@ the default is @code{240}.
 
 @item scene
 Specify the level at which a scene change is detected as a value between
-0 and 100 to indicate a new scene; a low value reflects a low
+0 and 1.0 to indicate a new scene; a low value reflects a low
 probability for the current frame to introduce a new scene, while a higher
 value means the current frame is more likely to be one.
-The default is @code{8.2}.
+The default is @code{0.25}.
 
 @item flags
 Specify flags influencing the filter process.
diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c
index 06e463e4d7..def3f19f55 100644
--- a/libavfilter/vf_framerate.c
+++ b/libavfilter/vf_framerate.c
@@ -51,7 +51,7 @@ static const AVOption framerate_options[] = {
 
     {"interp_start",        "point to start linear interpolation",    OFFSET(interp_start),    AV_OPT_TYPE_INT,      {.i64=15},                 0,       255,     V|F },
     {"interp_end",          "point to end linear interpolation",      OFFSET(interp_end),      AV_OPT_TYPE_INT,      {.i64=240},                0,       255,     V|F },
-    {"scene",               "scene change level",                     OFFSET(scene_score),     AV_OPT_TYPE_DOUBLE,   {.dbl=8.2},                0,       INT_MAX, V|F },
+    {"scene",               "scene change level",                     OFFSET(scene_score),     AV_OPT_TYPE_DOUBLE,   {.dbl=0.25},               0,       1.0,     V|F },
 
     {"flags",               "set flags",                              OFFSET(flags),           AV_OPT_TYPE_FLAGS,    {.i64=1},                  0,       INT_MAX, V|F, "flags" },
     {"scene_change_detect", "enable scene change detection",          0,                       AV_OPT_TYPE_CONST,    {.i64=FRAMERATE_FLAG_SCD}, INT_MIN, INT_MAX, V|F, "flags" },
@@ -77,9 +77,9 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame *crnt, AVFrame *next
         ff_dlog(ctx, "get_scene_score() process\n");
         s->sad(crnt->data[0], crnt->linesize[0], next->data[0], next->linesize[0], crnt->width, crnt->height, &sad);
         emms_c();
-        mafd = (double)sad * 100.0 / (crnt->width * crnt->height) / (1 << s->bitdepth);
+        mafd = (double)sad / (crnt->width * crnt->height) / (1ULL << (s->bitdepth - 8));
         diff = fabs(mafd - s->prev_mafd);
-        ret  = av_clipf(FFMIN(mafd, diff), 0, 100.0);
+        ret  = av_clipf(FFMIN(mafd, diff) / 100., 0, 1);
         s->prev_mafd = mafd;
     }
     ff_dlog(ctx, "get_scene_score() result is:%f\n", ret);
-- 
2.21.0



More information about the ffmpeg-devel mailing list