[FFmpeg-devel] [PATCH]lavf/decimate: Fix total difference for the first frame

Carl Eugen Hoyos cehoyos at ag.or.at
Sun Jan 3 16:11:03 CET 2016


Hi!

Attached patch fixes ticket #4990 for me, I tested the following 
command line:
$ ffmpeg -loglevel debug -i bugged.avi -vf fieldmatch,decimate -f null -

The first frames show the following debug output:
before:
[Parsed_decimate_0 @ 0x329e160] 1/5 frame drop:
[Parsed_decimate_0 @ 0x329e160]   #1: totdiff=7fffffffffffffff 
maxbdiff=7fffffffffffffff sc [DROP]
[Parsed_decimate_0 @ 0x329e160]   #2: totdiff=00ca660c maxbdiff=000130d8
[Parsed_decimate_0 @ 0x329e160]   #3: totdiff=015715f3 maxbdiff=00022e12
[Parsed_decimate_0 @ 0x329e160]   #4: totdiff=00c6e459 maxbdiff=0001df5b
[Parsed_decimate_0 @ 0x329e160]   #5: totdiff=000d4fce maxbdiff=00000d05 
lowest

after:
[Parsed_decimate_1 @ 0x2714720] 1/5 frame drop:
[Parsed_decimate_1 @ 0x2714720]   #1: totdiff=04ba4100 
maxbdiff=7fffffffffffffff
[Parsed_decimate_1 @ 0x2714720]   #2: totdiff=00ca660c maxbdiff=000130d8
[Parsed_decimate_1 @ 0x2714720]   #3: totdiff=015715f3 maxbdiff=00022e12
[Parsed_decimate_1 @ 0x2714720]   #4: totdiff=00c6e459 maxbdiff=0001df5b
[Parsed_decimate_1 @ 0x2714720]   #5: totdiff=000d4fce maxbdiff=00000d05 
lowest [DROP]

With the patch, the frame with the lowest diff is actually dropped 
instead of the first frame that indicates a scene change without 
the patch (iiuc).

Please review, Carl Eugen
-------------- next part --------------
diff --git a/libavfilter/vf_decimate.c b/libavfilter/vf_decimate.c
index 8b950b4..91c6d7f 100644
--- a/libavfilter/vf_decimate.c
+++ b/libavfilter/vf_decimate.c
@@ -169,7 +169,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         prv = dm->fid ? dm->queue[dm->fid - 1].frame : dm->last;
         if (!prv) {
             dm->queue[dm->fid].maxbdiff = INT64_MAX;
-            dm->queue[dm->fid].totdiff  = INT64_MAX;
+            dm->queue[dm->fid].totdiff  = dm->scthresh;
         } else {
             calc_diffs(dm, &dm->queue[dm->fid], prv, in);
         }


More information about the ffmpeg-devel mailing list