[SCM] libav/experimental: adpcm: Skip samples whose ssd calculation has wrapped around

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 17:19:33 UTC 2013


The following commit has been merged in the experimental branch:
commit cfff297d9890a43a51b2f3f0efbfcdd12964b5fe
Author: Martin Storsjö <martin at martin.st>
Date:   Wed Dec 1 08:57:45 2010 +0000

    adpcm: Skip samples whose ssd calculation has wrapped around
    
    Wraparound in ssd is mainly avoided by subtracting the ssd of the
    best node from all the others once it has grown large enough.
    
    If using very large trellis sizes (e.g. -trellis 15), the frontier
    is so large that the difference between the best and the worst is
    large enough to cause wraparound, even if the ssd of the best one
    is subtracted regularly.
    
    When using -trellis 10 on a 30 second sample, this causes only a slight
    slowdown, from 61 to 64 seconds.
    
    Originally committed as revision 25858 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index 1e9ab5b..ee2ce54 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -382,6 +382,12 @@ static void adpcm_compress_trellis(AVCodecContext *avctx, const short *samples,
                     dec_sample = av_clip_int16(dec_sample);\
                     d = sample - dec_sample;\
                     ssd = nodes[j]->ssd + d*d;\
+                    /* Check for wraparound, skip such samples completely. \
+                     * Note, changing ssd to a 64 bit variable would be \
+                     * simpler, avoiding this check, but it's slower on \
+                     * x86 32 bit at the moment. */\
+                    if (ssd < nodes[j]->ssd)\
+                        goto next_##NAME;\
                     /* Collapse any two states with the same previous sample value. \
                      * One could also distinguish states by step and by 2nd to last
                      * sample, but the effects of that are negligible.

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list