diff options
author | Paul B Mahol <onemda@gmail.com> | 2016-04-11 14:06:10 +0300 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2016-04-11 14:14:55 +0300 |
commit | b62ed56e25c8894a39352c82c7dadd2ebb9191f9 (patch) | |
tree | 9d3d88dd500776d4c51b2c7f9ef3245d50f1aa72 | |
parent | 15fa01786ce6cd714e85e36e86b974fc6918f357 (diff) |
avcodec/shorten: properly handle bitshift > 31
Signed-off-by: Paul B Mahol <onemda@gmail.com>
-rw-r--r-- | libavcodec/shorten.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index b3b6d2a5a6..061a74b8f5 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -164,9 +164,13 @@ static void fix_bitshift(ShortenContext *s, int32_t *buffer) { int i; - if (s->bitshift != 0) + if (s->bitshift == 32) { + for (i = 0; i < s->blocksize; i++) + buffer[i] = 0; + } else if (s->bitshift != 0) { for (i = 0; i < s->blocksize; i++) buffer[i] <<= s->bitshift; + } } static int init_offset(ShortenContext *s) @@ -602,7 +606,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, void *data, break; case FN_BITSHIFT: { unsigned bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE); - if (bitshift > 31) { + if (bitshift > 32) { av_log(avctx, AV_LOG_ERROR, "bitshift %d is invalid\n", bitshift); return AVERROR_INVALIDDATA; @@ -680,7 +684,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, void *data, if (s->version < 2) s->offset[channel][s->nmean - 1] = sum / s->blocksize; else - s->offset[channel][s->nmean - 1] = (sum / s->blocksize) << s->bitshift; + s->offset[channel][s->nmean - 1] = s->bitshift == 32 ? 0 : (sum / s->blocksize) << s->bitshift; } /* copy wrap samples for use with next block */ |