From aa264da5bf6a3d82a47abba4cfcfa629dd1f3daa Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 4 Sep 2012 14:02:30 +0300 Subject: adpcmenc: Calculate the IMA_QT predictor without overflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ö --- libavcodec/adpcmenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libavcodec/adpcmenc.c') 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]; -- cgit v1.2.3