aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-09-04 14:02:30 +0300
committerDiego Biurrun <diego@biurrun.de>2014-08-23 05:19:12 -0700
commit2deac60a387409dcbc7b37a8c30de89c7aeb58ac (patch)
tree97744c6b4fcf567ed85d01e39aeb1679a459ac9a
parent3eed35addb461c42471e0367bb6cd68d8ffd3aec (diff)
downloadffmpeg-2deac60a387409dcbc7b37a8c30de89c7aeb58ac.tar.gz
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ö <martin@martin.st> (cherry picked from commit aa264da5bf6a3d82a47abba4cfcfa629dd1f3daa) Signed-off-by: Diego Biurrun <diego@biurrun.de> Conflicts: tests/ref/fate/acodec-adpcm-ima_qt
-rw-r--r--libavcodec/adpcmenc.c2
-rw-r--r--tests/ref/acodec/adpcm_ima_qt6
2 files changed, 4 insertions, 4 deletions
diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index 9697f829d2..c88a5da894 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -550,7 +550,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx,
init_put_bits(&pb, dst, buf_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/acodec/adpcm_ima_qt b/tests/ref/acodec/adpcm_ima_qt
index c1db43f1aa..a50c30a27c 100644
--- a/tests/ref/acodec/adpcm_ima_qt
+++ b/tests/ref/acodec/adpcm_ima_qt
@@ -1,4 +1,4 @@
-057d27978b35888776512e4e9669a63b *./tests/data/acodec/adpcm_qt.aiff
+23cbae1182e150ebf28e0abfb9cba127 *./tests/data/acodec/adpcm_qt.aiff
281252 ./tests/data/acodec/adpcm_qt.aiff
-169c40435c68d50112c9c61fc67e446d *./tests/data/adpcm_ima_qt.acodec.out.wav
-stddev: 918.61 PSNR: 37.07 MAXDIFF:34029 bytes: 1058560/ 1058400
+b0fafd002c38fb70acaddfda1a31ed61 *./tests/data/adpcm_ima_qt.acodec.out.wav
+stddev: 904.76 PSNR: 37.20 MAXDIFF:34029 bytes: 1058560/ 1058400