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

Carl Eugen Hoyos cehoyos at ag.or.at
Mon Jan 4 21:53:24 CET 2016

Clément Bœsch <u <at> pkh.me> writes:

> +    if (cyclestart == 0) {
> +        vdm->vmi[0].maxbdiff = vdm->vmi[1].maxbdiff;
> +        vdm->vmi[0].totdiff = vdm->scthresh + 1;
> +    }
> +

> I suggest to "cherry-pick" this if it works.

Nicolas has already found a very similar solution 
that only differs in rare cases (although the change 
should be ported) and not for the file in question.
Sorry to say this but I wonder how the filter ever 
passed any test without this (or a similar) change.

The OP of ticket #4990 claims that for his sample 
the first frames are correctly handled with avisynth.
(I have no idea how to test this.)

When looking at the frames visually, I can very, very 
easily distinguish between the four duplicates of the 
20 frames and the other frames and I do not see any 
difference between the duplicates. FFmpeg's decimate 
filter does not detect any of the duplicates and 
therefore drops the first frame because it is a scene 
change, the other three duplicates are correctly 
dropped because they are "lowest" by a large margin 
but are not detected as duplicates.

It works if blockx and blocky are set to 128 but I 
wonder why this should be necessary and why it isn't 
necessary for avisynth (if this is true).

Perhaps somebody can test the fieldmatched.avi file in 
with the Virtualdub filter to see if it really works 
correctly for the first frames and ideally add debug 
output to see its maxbdiff and dupthresh values.

Thank you, Carl Eugen

duppos: -1 lowest: 4, dm->queue[lowest].maxbdiff: 3333, dm->dupthresh: 2872
    Last message repeated 11 times
[Parsed_decimate_0 @ 0x362b160] 1/5 frame drop:
[Parsed_decimate_0 @ 0x362b160]   #1: totdiff=7fffffffffffffff
maxbdiff=7fffffffffffffff sc [DROP]
[Parsed_decimate_0 @ 0x362b160]   #2: totdiff=00ca660c maxbdiff=000130d8
[Parsed_decimate_0 @ 0x362b160]   #3: totdiff=015715f3 maxbdiff=00022e12
[Parsed_decimate_0 @ 0x362b160]   #4: totdiff=00c6e459 maxbdiff=0001df5b
[Parsed_decimate_0 @ 0x362b160]   #5: totdiff=000d4fce maxbdiff=00000d05 lowest
duppos: -1 lowest: 4, dm->queue[lowest].maxbdiff: 3947, dm->dupthresh: 2872
[Parsed_decimate_0 @ 0x362b160] 1/5 frame drop:
[Parsed_decimate_0 @ 0x362b160]   #1: totdiff=0093eda5 maxbdiff=0001b481
[Parsed_decimate_0 @ 0x362b160]   #2: totdiff=0089d968 maxbdiff=00019ebc
[Parsed_decimate_0 @ 0x362b160]   #3: totdiff=0080a999 maxbdiff=00017223
[Parsed_decimate_0 @ 0x362b160]   #4: totdiff=007c98d0 maxbdiff=00018261
[Parsed_decimate_0 @ 0x362b160]   #5: totdiff=00099bf0 maxbdiff=00000f6b
lowest [DROP]
duppos: -1 lowest: 4, dm->queue[lowest].maxbdiff: 7578, dm->dupthresh: 2872
[Parsed_decimate_0 @ 0x362b160] 1/5 frame drop:
[Parsed_decimate_0 @ 0x362b160]   #1: totdiff=0079855c maxbdiff=0001ab54
[Parsed_decimate_0 @ 0x362b160]   #2: totdiff=008401c0 maxbdiff=0001bf8e
[Parsed_decimate_0 @ 0x362b160]   #3: totdiff=007db8bb maxbdiff=0001ade7
[Parsed_decimate_0 @ 0x362b160]   #4: totdiff=007f553c maxbdiff=0001806d
[Parsed_decimate_0 @ 0x362b160]   #5: totdiff=0010b14d maxbdiff=00001d9a
lowest [DROP]
duppos: -1 lowest: 4, dm->queue[lowest].maxbdiff: 5389, dm->dupthresh: 2872
[Parsed_decimate_0 @ 0x362b160] 1/5 frame drop:
[Parsed_decimate_0 @ 0x362b160]   #1: totdiff=007b5d19 maxbdiff=0001691f
[Parsed_decimate_0 @ 0x362b160]   #2: totdiff=0076c12d maxbdiff=00012a61
[Parsed_decimate_0 @ 0x362b160]   #3: totdiff=006cc5ab maxbdiff=00014404
[Parsed_decimate_0 @ 0x362b160]   #4: totdiff=005b2dca maxbdiff=0000e7ce
[Parsed_decimate_0 @ 0x362b160]   #5: totdiff=000fe7bc maxbdiff=0000150d
lowest [DROP]

Note the missing "dup" for the "lowest" frames.

More information about the ffmpeg-devel mailing list