]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/vf_framerate: if metadata lavfi.scd.mafd exists, we'll use it first
authorLimin Wang <lance.lmwang@gmail.com>
Tue, 8 Oct 2019 15:28:37 +0000 (23:28 +0800)
committerLimin Wang <lance.lmwang@gmail.com>
Thu, 14 May 2020 15:03:06 +0000 (23:03 +0800)
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
libavfilter/vf_framerate.c

index 6c8d01c94bb629c2f9dea29e8aa66186d9e27357..8d16998457ffd4b0edce302c988c2359ca6a64fd 100644 (file)
@@ -71,13 +71,20 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame *crnt, AVFrame *next
 
     if (crnt->height == next->height &&
         crnt->width  == next->width) {
+        AVDictionaryEntry *e_mafd = NULL;
         uint64_t sad;
-        double mafd, diff;
+        double mafd = HUGE_VAL, diff;
+        char *tail = NULL;
 
         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);
+        e_mafd = av_dict_get(next->metadata, "lavfi.scd.mafd", NULL, AV_DICT_MATCH_CASE);
+        if (e_mafd)
+            mafd = strtod(e_mafd->value, &tail);
+        if (*tail || mafd == HUGE_VAL) {
+            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);
+        }
         diff = fabs(mafd - s->prev_mafd);
         ret  = av_clipf(FFMIN(mafd, diff), 0, 100.0);
         s->prev_mafd = mafd;