X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fwmadec.c;h=9081f35a16ee0f08a369959883a152214235615c;hb=a247ac640df3da573cd661065bf53f37863e2b46;hp=78b51e5871bf8c685f9eb7524025cdc738014a4e;hpb=39278ff0de5b5e3397c22538978bffbb38ee099b;p=ffmpeg diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c index 78b51e5871b..9081f35a16e 100644 --- a/libavcodec/wmadec.c +++ b/libavcodec/wmadec.c @@ -110,9 +110,9 @@ static av_cold int wma_decode_init(AVCodecContext *avctx) ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 1, 1.0 / 32768.0); if (s->use_noise_coding) { - init_vlc(&s->hgain_vlc, HGAINVLCBITS, sizeof(ff_wma_hgain_huffbits), - ff_wma_hgain_huffbits, 1, 1, - ff_wma_hgain_huffcodes, 2, 2, 0); + ff_init_vlc_from_lengths(&s->hgain_vlc, HGAINVLCBITS, FF_ARRAY_ELEMS(ff_wma_hgain_hufftab), + &ff_wma_hgain_hufftab[0][1], 2, + &ff_wma_hgain_hufftab[0][0], 2, 1, -18, 0, avctx); } if (s->use_exp_vlc) @@ -345,10 +345,6 @@ static int decode_exp_vlc(WMACodecContext *s, int ch) while (q < q_end) { code = get_vlc2(&s->gb, s->exp_vlc.table, EXPVLCBITS, EXPMAX); - if (code < 0) { - av_log(s->avctx, AV_LOG_ERROR, "Exponent vlc invalid\n"); - return -1; - } /* NOTE: this offset is the same as MPEG-4 AAC! */ last_exp += code - 60; if ((unsigned) last_exp + 60 >= FF_ARRAY_ELEMS(pow_tab)) { @@ -549,7 +545,7 @@ static int wma_decode_block(WMACodecContext *s) } for (ch = 0; ch < s->avctx->channels; ch++) { if (s->channel_coded[ch]) { - int i, n, val, code; + int i, n, val; n = s->exponent_high_sizes[bsize]; val = (int) 0x80000000; @@ -558,14 +554,8 @@ static int wma_decode_block(WMACodecContext *s) if (val == (int) 0x80000000) { val = get_bits(&s->gb, 7) - 19; } else { - code = get_vlc2(&s->gb, s->hgain_vlc.table, + val += get_vlc2(&s->gb, s->hgain_vlc.table, HGAINVLCBITS, HGAINMAX); - if (code < 0) { - av_log(s->avctx, AV_LOG_ERROR, - "hgain vlc invalid\n"); - return -1; - } - val += code - 18; } s->high_band_values[ch][i] = val; } @@ -585,10 +575,16 @@ static int wma_decode_block(WMACodecContext *s) decode_exp_lsp(s, ch); } s->exponents_bsize[ch] = bsize; + s->exponents_initialized[ch] = 1; } } } + for (ch = 0; ch < s->avctx->channels; ch++) { + if (s->channel_coded[ch] && !s->exponents_initialized[ch]) + return AVERROR_INVALIDDATA; + } + /* parse spectral coefficients : just RLE encoding */ for (ch = 0; ch < s->avctx->channels; ch++) { if (s->channel_coded[ch]) { @@ -889,11 +885,11 @@ static int wma_decode_superframe(AVCodecContext *avctx, void *data, q = s->last_superframe + s->last_superframe_len; len = bit_offset; while (len > 7) { - *q++ = (get_bits) (&s->gb, 8); + *q++ = get_bits(&s->gb, 8); len -= 8; } if (len > 0) - *q++ = (get_bits) (&s->gb, len) << (8 - len); + *q++ = get_bits(&s->gb, len) << (8 - len); memset(q, 0, AV_INPUT_BUFFER_PADDING_SIZE); /* XXX: bit_offset bits into last frame */ @@ -968,7 +964,7 @@ static av_cold void flush(AVCodecContext *avctx) } #if CONFIG_WMAV1_DECODER -AVCodec ff_wmav1_decoder = { +const AVCodec ff_wmav1_decoder = { .name = "wmav1", .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 1"), .type = AVMEDIA_TYPE_AUDIO, @@ -984,7 +980,7 @@ AVCodec ff_wmav1_decoder = { }; #endif #if CONFIG_WMAV2_DECODER -AVCodec ff_wmav2_decoder = { +const AVCodec ff_wmav2_decoder = { .name = "wmav2", .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 2"), .type = AVMEDIA_TYPE_AUDIO,