X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fwavpack.c;h=d0242809fe02c21ed8ba078314c9ea6704d7d984;hb=7b9ca44cbca4fcd2ac3a5e50f85851f8f0927103;hp=0e40b29879959a4a003e27a60248fe2653dd76bb;hpb=ae7e66fb4b1a256fb79a016b9c585de84ac77339;p=ffmpeg diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c index 0e40b298799..d0242809fe0 100644 --- a/libavcodec/wavpack.c +++ b/libavcodec/wavpack.c @@ -85,7 +85,7 @@ typedef struct WavpackContext { #define LEVEL_DECAY(a) (((a) + 0x80) >> 8) -static av_always_inline int get_tail(GetBitContext *gb, int k) +static av_always_inline unsigned get_tail(GetBitContext *gb, int k) { int p, e, res; @@ -452,7 +452,7 @@ static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb, if (type != AV_SAMPLE_FMT_S16P) R2 = R + ((s->decorr[i].weightB * (int64_t)L2 + 512) >> 10); else - R2 = R + ((int)(s->decorr[i].weightB * (unsigned)L2 + 512) >> 10); + R2 = R + (unsigned)((int)(s->decorr[i].weightB * (unsigned)L2 + 512) >> 10); UPDATE_WEIGHT_CLIP(s->decorr[i].weightB, s->decorr[i].delta, L2, R); R = R2; s->decorr[i].samplesA[0] = R; @@ -940,13 +940,23 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, case 3: chmask = bytestream2_get_le32(&gb); break; - case 5: + case 4: size = bytestream2_get_byte(&gb); - if (avctx->channels != size) + chan |= (bytestream2_get_byte(&gb) & 0xF) << 8; + chan += 1; + if (avctx->channels != chan) av_log(avctx, AV_LOG_WARNING, "%i channels signalled" - " instead of %i.\n", size, avctx->channels); + " instead of %i.\n", chan, avctx->channels); + chmask = bytestream2_get_le24(&gb); + break; + case 5: + size = bytestream2_get_byte(&gb); chan |= (bytestream2_get_byte(&gb) & 0xF) << 8; - chmask = bytestream2_get_le16(&gb); + chan += 1; + if (avctx->channels != chan) + av_log(avctx, AV_LOG_WARNING, "%i channels signalled" + " instead of %i.\n", chan, avctx->channels); + chmask = bytestream2_get_le32(&gb); break; default: av_log(avctx, AV_LOG_ERROR, "Invalid channel info size %d\n",