On Thu, 14 May 2020, [email protected] wrote:

From: Limin Wang <[email protected]>

Reviewed-by: Paul B Mahol <[email protected]>
Signed-off-by: Limin Wang <[email protected]>
---
libavfilter/vf_framerate.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c
index 6c8d01c..8d16998 100644
--- a/libavfilter/vf_framerate.c
+++ b/libavfilter/vf_framerate.c
@@ -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) {

Seems like null pointer dereference.

I am not a huge fan of this patch, mafd refers to a score between this frame and the previous frame, we cannot ensure that there were no additional frame processing between scdet and this filter which may have duplicated or removed frames. So I'd rather not add this feature.

Regards,
Marton

+            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;
--
1.8.3.1

_______________________________________________
ffmpeg-devel mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".

Reply via email to