From: Michael Niedermayer Date: Tue, 4 Sep 2012 11:02:30 +0000 (+0300) Subject: adpcmenc: Calculate the IMA_QT predictor without overflow X-Git-Tag: android-x86-4.4-r1~8529^2~700 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=aa264da5bf6a3d82a47abba4cfcfa629dd1f3daa;p=android-x86%2Fexternal-ffmpeg.git adpcmenc: Calculate the IMA_QT predictor without overflow Previously, the value given to put_bits was 10 bits long for positive predictors, even though 9 bits were to be written. The extra bit could in some cases overwrite existing bits in the bitstream writer cache. This fixes a failed assert in put_bits.h, when running a version built with -DDEBUG. The fate test result gets slightly improved, thanks to getting rid of the overwritten bits in the bitstream writer cache. Signed-off-by: Martin Storsjö --- diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c index 843b32fae5..f8ecd589dc 100644 --- a/libavcodec/adpcmenc.c +++ b/libavcodec/adpcmenc.c @@ -570,7 +570,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, init_put_bits(&pb, dst, pkt_size * 8); for (ch = 0; ch < avctx->channels; ch++) { - put_bits(&pb, 9, (c->status[ch].prev_sample + 0x10000) >> 7); + put_bits(&pb, 9, (c->status[ch].prev_sample & 0xFFFF) >> 7); put_bits(&pb, 7, c->status[ch].step_index); if (avctx->trellis > 0) { uint8_t buf[64]; diff --git a/tests/ref/fate/acodec-adpcm-ima_qt b/tests/ref/fate/acodec-adpcm-ima_qt index 79b8c60ccc..80015275fc 100644 --- a/tests/ref/fate/acodec-adpcm-ima_qt +++ b/tests/ref/fate/acodec-adpcm-ima_qt @@ -1,4 +1,4 @@ -057d27978b35888776512e4e9669a63b *tests/data/fate/acodec-adpcm-ima_qt.aiff +23cbae1182e150ebf28e0abfb9cba127 *tests/data/fate/acodec-adpcm-ima_qt.aiff 281252 tests/data/fate/acodec-adpcm-ima_qt.aiff -169c40435c68d50112c9c61fc67e446d *tests/data/fate/acodec-adpcm-ima_qt.out.wav -stddev: 918.61 PSNR: 37.07 MAXDIFF:34029 bytes: 1058400/ 1058560 +b0fafd002c38fb70acaddfda1a31ed61 *tests/data/fate/acodec-adpcm-ima_qt.out.wav +stddev: 904.76 PSNR: 37.20 MAXDIFF:34029 bytes: 1058400/ 1058560