summaryrefslogtreecommitdiff
path: root/libavfilter/vf_minterpolate.c
diff options
context:
space:
mode:
authorLimin Wang <lance.lmwang@gmail.com>2019-10-08 23:28:38 +0800
committerLimin Wang <lance.lmwang@gmail.com>2020-05-14 23:03:07 +0800
commitd88e1c9838dbcfe29d7835f2705ffc9ee6a36bf3 (patch)
tree314113263d7c5b6bee9b55c79722adecd5b86ee9 /libavfilter/vf_minterpolate.c
parent339593ca90cb3e05d659ec99a1479904ec742294 (diff)
avfilter/vf_minterpolate: if metadata lavfi.scd.mafd exists, we'll use it first
Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Diffstat (limited to 'libavfilter/vf_minterpolate.c')
-rw-r--r--libavfilter/vf_minterpolate.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/libavfilter/vf_minterpolate.c b/libavfilter/vf_minterpolate.c
index b0bb238ade..db3d7d4ca3 100644
--- a/libavfilter/vf_minterpolate.c
+++ b/libavfilter/vf_minterpolate.c
@@ -832,11 +832,19 @@ static int detect_scene_change(MIContext *mi_ctx)
ptrdiff_t linesize2 = mi_ctx->frames[2].avf->linesize[0];
if (mi_ctx->scd_method == SCD_METHOD_FDIFF) {
- double ret = 0, mafd, diff;
+ double ret = 0, mafd = HUGE_VAL, diff;
uint64_t sad;
- mi_ctx->sad(p1, linesize1, p2, linesize2, me_ctx->width, me_ctx->height, &sad);
- emms_c();
- mafd = (double) sad / (me_ctx->height * me_ctx->width * 3);
+ AVDictionaryEntry *e_mafd = NULL;
+ char *tail = NULL;
+
+ e_mafd = av_dict_get(mi_ctx->frames[2].avf->metadata, "lavfi.scd.mafd", NULL, AV_DICT_MATCH_CASE);
+ if (e_mafd)
+ mafd = strtod(e_mafd->value, &tail);
+ if (*tail || mafd == HUGE_VAL) {
+ mi_ctx->sad(p1, linesize1, p2, linesize2, me_ctx->width, me_ctx->height, &sad);
+ emms_c();
+ mafd = (double) sad / (me_ctx->height * me_ctx->width * 3);
+ }
diff = fabs(mafd - mi_ctx->prev_mafd);
ret = av_clipf(FFMIN(mafd, diff), 0, 100.0);
mi_ctx->prev_mafd = mafd;