diff options
Diffstat (limited to 'libavcodec/wmadec.c')
-rw-r--r-- | libavcodec/wmadec.c | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c index dbefbe0..0648c1e 100644 --- a/libavcodec/wmadec.c +++ b/libavcodec/wmadec.c @@ -1,21 +1,21 @@ /* * WMA compatible decoder - * Copyright (c) 2002 The Libav Project + * Copyright (c) 2002 The FFmpeg Project * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -92,6 +92,13 @@ static int wma_decode_init(AVCodecContext * avctx) s->use_bit_reservoir = flags2 & 0x0002; s->use_variable_block_len = flags2 & 0x0004; + if(avctx->codec->id == AV_CODEC_ID_WMAV2 && avctx->extradata_size >= 8){ + if(AV_RL16(extradata+4)==0xd && s->use_variable_block_len){ + av_log(avctx, AV_LOG_WARNING, "Disabling use_variable_block_len, if this fails contact the ffmpeg developers and send us the file\n"); + s->use_variable_block_len= 0; // this fixes issue1503 + } + } + if(ff_wma_init(avctx, flags2)<0) return -1; @@ -471,6 +478,11 @@ static int wma_decode_block(WMACodecContext *s) s->block_len_bits = s->frame_len_bits; } + if (s->frame_len_bits - s->block_len_bits >= s->nb_block_sizes){ + av_log(s->avctx, AV_LOG_ERROR, "block_len_bits not initialized to a valid value\n"); + return -1; + } + /* now check if the block length is coherent with the frame length */ s->block_len = 1 << s->block_len_bits; if ((s->block_pos + s->block_len) > s->frame_len){ @@ -811,7 +823,8 @@ static int wma_decode_superframe(AVCodecContext *avctx, void *data, buf_size, avctx->block_align); return AVERROR_INVALIDDATA; } - buf_size = avctx->block_align; + if(avctx->block_align) + buf_size = avctx->block_align; init_get_bits(&s->gb, buf, buf_size*8); @@ -819,16 +832,18 @@ static int wma_decode_superframe(AVCodecContext *avctx, void *data, /* read super frame header */ skip_bits(&s->gb, 4); /* super frame index */ nb_frames = get_bits(&s->gb, 4) - (s->last_superframe_len <= 0); + if (nb_frames <= 0) { + av_log(avctx, AV_LOG_ERROR, "nb_frames is %d\n", nb_frames); + return AVERROR_INVALIDDATA; + } } else { nb_frames = 1; } /* get output buffer */ frame->nb_samples = nb_frames * s->frame_len; - if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) { - av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); + if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; - } samples = (float **)frame->extended_data; samples_offset = 0; @@ -910,7 +925,7 @@ static int wma_decode_superframe(AVCodecContext *avctx, void *data, *got_frame_ptr = 1; - return avctx->block_align; + return buf_size; fail: /* when error, we reset the bit reservoir */ s->last_superframe_len = 0; @@ -925,6 +940,7 @@ static av_cold void flush(AVCodecContext *avctx) s->last_superframe_len= 0; } +#if CONFIG_WMAV1_DECODER AVCodec ff_wmav1_decoder = { .name = "wmav1", .type = AVMEDIA_TYPE_AUDIO, @@ -939,7 +955,8 @@ AVCodec ff_wmav1_decoder = { .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, }; - +#endif +#if CONFIG_WMAV2_DECODER AVCodec ff_wmav2_decoder = { .name = "wmav2", .type = AVMEDIA_TYPE_AUDIO, @@ -954,3 +971,4 @@ AVCodec ff_wmav2_decoder = { .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, }; +#endif |