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

Clément Bœsch u at pkh.me
Mon Jan 4 21:10:09 CET 2016


On Mon, Jan 04, 2016 at 05:32:32PM +0000, Derek Buitenhuis wrote:
> On 1/4/2016 5:17 PM, Carl Eugen Hoyos wrote:
> > I wish I would understand;-(
> > 
> > Since this fixes a reported issue here, I will 
> > commit my patch if nobody objects.
> 
> [17:30]  * Daemon404 pokes ubitux
> [17:30] <@ubitux> yup?
> [17:30] <@Daemon404> do you have a comment on carl's decimate change
> [17:31] <@ubitux> i need to look more closely, it's been a long time
> [17:31] <@ubitux> i need to "sync" it with upstream since a long time
> [17:31] <@ubitux> i'll check tonight (in ~3h probably)
> 

commit e004c18ced0cd1c9b0d3680835b8ec474c539217
Author: cantabile <cantabile.desu at gmail.com>
Date:   Mon May 19 00:03:17 2014 +0300

    VDecimate: Fix decimation of the first cycle
    
    The first frame's metrics are always zero, thus the first frame is
    always considered a duplicate, which means it's always dropped. Avoid
    this by copying the second frame's maximum block difference.
    
    Also make the first frame's total difference just a bit higher than the
    scene change threshold, so it's always considered a scene change. This
    way the first frame will be dropped when there are no duplicates and no
    other scene changes in the cycle.

diff --git a/src/filters/vivtc/vivtc.c b/src/filters/vivtc/vivtc.c
index b0eba1d..abfa900 100644
--- a/src/filters/vivtc/vivtc.c
+++ b/src/filters/vivtc/vivtc.c
@@ -1252,6 +1252,12 @@ static const VSFrameRef *VS_CC vdecimateGetFrame(int n, int activationReason, vo
                 vsapi->freeFrame(cur);
             }
 
+            // The first frame's metrics are always 0, thus it's always considered a duplicate.
+            if (cyclestart == 0) {
+                vdm->vmi[0].maxbdiff = vdm->vmi[1].maxbdiff;
+                vdm->vmi[0].totdiff = vdm->scthresh + 1;
+            }
+
             if (*drop < 0)
                 *drop = findDropFrame(&vdm->vmi[cyclestart], cycleend - cyclestart, vdm->scthresh, vdm->dupthresh);
         }

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

Regards,

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160104/d4a27e49/attachment.sig>


More information about the ffmpeg-devel mailing list