diff options
Diffstat (limited to 'libavcodec/mpc8.c')
-rw-r--r-- | libavcodec/mpc8.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c index ee05a938b6..29c65f9ef5 100644 --- a/libavcodec/mpc8.c +++ b/libavcodec/mpc8.c @@ -2,20 +2,20 @@ * Musepack SV8 decoder * Copyright (c) 2007 Konstantin Shishkov * - * 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 */ @@ -126,6 +126,10 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx) skip_bits(&gb, 3);//sample rate c->maxbands = get_bits(&gb, 5) + 1; + if (c->maxbands >= BANDS) { + av_log(avctx,AV_LOG_ERROR, "maxbands %d too high\n", c->maxbands); + return AVERROR_INVALIDDATA; + } channels = get_bits(&gb, 4) + 1; if (channels > 2) { avpriv_request_sample(avctx, "Multichannel MPC SV8"); @@ -135,7 +139,8 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx) c->frames = 1 << (get_bits(&gb, 3) * 2); avctx->sample_fmt = AV_SAMPLE_FMT_S16P; - avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; + avctx->channel_layout = (channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; + avctx->channels = channels; if(vlc_initialized) return 0; av_log(avctx, AV_LOG_DEBUG, "Initing VLC\n"); @@ -247,10 +252,8 @@ static int mpc8_decode_frame(AVCodecContext * avctx, void *data, /* get output buffer */ frame->nb_samples = MPC_FRAME_SIZE; - if ((res = ff_get_buffer(avctx, frame, 0)) < 0) { - av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); + if ((res = ff_get_buffer(avctx, frame, 0)) < 0) return res; - } keyframe = c->cur_frame == 0; @@ -267,8 +270,11 @@ static int mpc8_decode_frame(AVCodecContext * avctx, void *data, maxband = c->last_max_band + get_vlc2(gb, band_vlc.table, MPC8_BANDS_BITS, 2); if(maxband > 32) maxband -= 33; } - if(maxband > c->maxbands + 1) + + if(maxband > c->maxbands + 1) { + av_log(avctx, AV_LOG_ERROR, "maxband %d too large\n",maxband); return AVERROR_INVALIDDATA; + } c->last_max_band = maxband; /* read subband indexes */ |