diff options
Diffstat (limited to 'libavcodec/imc.c')
-rw-r--r-- | libavcodec/imc.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/libavcodec/imc.c b/libavcodec/imc.c index 2749099d22..eb7c25524a 100644 --- a/libavcodec/imc.c +++ b/libavcodec/imc.c @@ -4,20 +4,20 @@ * Copyright (c) 2006 Benjamin Larsson * Copyright (c) 2006 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 */ @@ -38,6 +38,7 @@ #include "libavutil/channel_layout.h" #include "libavutil/float_dsp.h" #include "libavutil/internal.h" +#include "libavutil/libm.h" #include "avcodec.h" #include "get_bits.h" #include "dsputil.h" @@ -343,7 +344,7 @@ static void imc_decode_level_coefficients(IMCContext *q, int *levlCoeffBuf, float tmp, tmp2; // maybe some frequency division thingy - flcoeffs1[0] = 20000.0 / pow (2, levlCoeffBuf[0] * 0.18945); // 0.18945 = log2(10) * 0.05703125 + flcoeffs1[0] = 20000.0 / exp2 (levlCoeffBuf[0] * 0.18945); // 0.18945 = log2(10) * 0.05703125 flcoeffs2[0] = log2f(flcoeffs1[0]); tmp = flcoeffs1[0]; tmp2 = flcoeffs2[0]; @@ -803,6 +804,13 @@ static int imc_decode_block(AVCodecContext *avctx, IMCContext *q, int ch) imc_decode_level_coefficients2(q, chctx->levlCoeffBuf, chctx->old_floor, chctx->flcoeffs1, chctx->flcoeffs2); + for(i=0; i<BANDS; i++) { + if(chctx->flcoeffs1[i] > INT_MAX) { + av_log(avctx, AV_LOG_ERROR, "scalefactor out of range\n"); + return AVERROR_INVALIDDATA; + } + } + memcpy(chctx->old_floor, chctx->flcoeffs1, 32 * sizeof(float)); counter = 0; @@ -939,10 +947,8 @@ static int imc_decode_frame(AVCodecContext *avctx, void *data, /* get output buffer */ frame->nb_samples = COEFFS; - 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; - } for (i = 0; i < avctx->channels; i++) { q->out_samples = (float *)frame->extended_data[i]; @@ -977,7 +983,15 @@ static av_cold int imc_decode_close(AVCodecContext * avctx) return 0; } +static av_cold void flush(AVCodecContext *avctx) +{ + IMCContext *q = avctx->priv_data; + q->chctx[0].decoder_reset = + q->chctx[1].decoder_reset = 1; +} + +#if CONFIG_IMC_DECODER AVCodec ff_imc_decoder = { .name = "imc", .type = AVMEDIA_TYPE_AUDIO, @@ -986,12 +1000,14 @@ AVCodec ff_imc_decoder = { .init = imc_decode_init, .close = imc_decode_close, .decode = imc_decode_frame, + .flush = flush, .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("IMC (Intel Music Coder)"), .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, }; - +#endif +#if CONFIG_IAC_DECODER AVCodec ff_iac_decoder = { .name = "iac", .type = AVMEDIA_TYPE_AUDIO, @@ -1000,8 +1016,10 @@ AVCodec ff_iac_decoder = { .init = imc_decode_init, .close = imc_decode_close, .decode = imc_decode_frame, + .flush = flush, .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("IAC (Indeo Audio Coder)"), .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, }; +#endif |