avfilter/f_select: fix loss of precission in SAD calculation
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 16 Apr 2014 00:06:37 +0000 (02:06 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 16 Apr 2014 01:44:57 +0000 (03:44 +0200)
Fixes part of Ticket3466
Found-by: Andrey_Karpov / PVS-Studio
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavfilter/f_select.c
tests/ref/fate/filter-metadata-scenedetect

index ec84da8..1ffc006 100644 (file)
@@ -279,7 +279,7 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame *frame)
             p2 += 8 * linesize;
         }
         emms_c();
-        mafd = nb_sad ? sad / nb_sad : 0;
+        mafd = nb_sad ? (double)sad / nb_sad : 0;
         diff = fabs(mafd - select->prev_mafd);
         ret  = av_clipf(FFMIN(mafd, diff) / 100., 0, 1);
         select->prev_mafd = mafd;
index 67251df..4e70723 100644 (file)
@@ -1,10 +1,10 @@
 pkt_pts=1620|tag:lavfi.scene_score=1.000000
-pkt_pts=4140|tag:lavfi.scene_score=0.880000
+pkt_pts=4140|tag:lavfi.scene_score=0.876043
 pkt_pts=5800|tag:lavfi.scene_score=1.000000
-pkt_pts=6720|tag:lavfi.scene_score=0.460000
+pkt_pts=6720|tag:lavfi.scene_score=0.463259
 pkt_pts=8160|tag:lavfi.scene_score=1.000000
 pkt_pts=9760|tag:lavfi.scene_score=1.000000
-pkt_pts=14080|tag:lavfi.scene_score=0.840000
+pkt_pts=14080|tag:lavfi.scene_score=0.841420
 pkt_pts=15700|tag:lavfi.scene_score=1.000000
-pkt_pts=18500|tag:lavfi.scene_score=0.470000
+pkt_pts=18500|tag:lavfi.scene_score=0.471738
 pkt_pts=21760|tag:lavfi.scene_score=1.000000