X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Faacdec_template.c;h=c2d7d0565001ece88c0d18bdaed944b3e6c0ee03;hb=5131ba565792828a44ff275ea4dd53300cc6f119;hp=dda8d51e2cfb0d4bcc246907353623a952ea11f2;hpb=94d68a41fabb55dd8c7e59b88fe4a28a637d1e5f;p=ffmpeg diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c index dda8d51e2cf..c2d7d056500 100644 --- a/libavcodec/aacdec_template.c +++ b/libavcodec/aacdec_template.c @@ -940,13 +940,18 @@ static int decode_eld_specific_config(AACContext *ac, AVCodecContext *avctx, static int decode_audio_specific_config(AACContext *ac, AVCodecContext *avctx, MPEG4AudioConfig *m4ac, - const uint8_t *data, int bit_size, + const uint8_t *data, int64_t bit_size, int sync_extension) { GetBitContext gb; int i, ret; - ff_dlog(avctx, "audio specific config size %d\n", bit_size >> 3); + if (bit_size < 0 || bit_size > INT_MAX) { + av_log(avctx, AV_LOG_ERROR, "Audio specific config size is invalid\n"); + return AVERROR_INVALIDDATA; + } + + ff_dlog(avctx, "audio specific config size %d\n", (int)bit_size >> 3); for (i = 0; i < bit_size >> 3; i++) ff_dlog(avctx, "%02x ", data[i]); ff_dlog(avctx, "\n"); @@ -1076,7 +1081,7 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) if (avctx->extradata_size > 0) { if ((ret = decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac, avctx->extradata, - avctx->extradata_size * 8, + avctx->extradata_size * 8LL, 1)) < 0) return ret; } else { @@ -2694,7 +2699,7 @@ static void apply_channel_coupling(AACContext *ac, ChannelElement *cc, /** * Convert spectral data to samples, applying all supported tools as appropriate. */ -static void spectral_to_sample(AACContext *ac) +static void spectral_to_sample(AACContext *ac, int samples) { int i, type; void (*imdct_and_window)(AACContext *ac, SingleChannelElement *sce); @@ -2748,9 +2753,10 @@ static void spectral_to_sample(AACContext *ac) { int j; /* preparation for resampler */ - for(j = 0; j<2048; j++){ + for(j = 0; jch[0].ret[j] = (int32_t)av_clipl_int32((int64_t)che->ch[0].ret[j]<<7)+0x8000; - che->ch[1].ret[j] = (int32_t)av_clipl_int32((int64_t)che->ch[1].ret[j]<<7)+0x8000; + if(type == TYPE_CPE) + che->ch[1].ret[j] = (int32_t)av_clipl_int32((int64_t)che->ch[1].ret[j]<<7)+0x8000; } } #endif /* USE_FIXED */ @@ -2881,7 +2887,7 @@ static int aac_decode_er_frame(AVCodecContext *avctx, void *data, return err; } - spectral_to_sample(ac); + spectral_to_sample(ac, samples); ac->frame->nb_samples = samples; ac->frame->sample_rate = avctx->sample_rate; @@ -3029,11 +3035,11 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data, return 0; } - spectral_to_sample(ac); - multiplier = (ac->oc[1].m4ac.sbr == 1) ? ac->oc[1].m4ac.ext_sample_rate > ac->oc[1].m4ac.sample_rate : 0; samples <<= multiplier; + spectral_to_sample(ac, samples); + if (ac->oc[1].status && audio_found) { avctx->sample_rate = ac->oc[1].m4ac.sample_rate << multiplier; avctx->frame_size = samples; @@ -3098,7 +3104,7 @@ static int aac_decode_frame(AVCodecContext *avctx, void *data, if (new_extradata && 0) { av_free(avctx->extradata); avctx->extradata = av_mallocz(new_extradata_size + - FF_INPUT_BUFFER_PADDING_SIZE); + AV_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) return AVERROR(ENOMEM); avctx->extradata_size = new_extradata_size; @@ -3106,7 +3112,7 @@ static int aac_decode_frame(AVCodecContext *avctx, void *data, push_output_configuration(ac); if (decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac, avctx->extradata, - avctx->extradata_size*8, 1) < 0) { + avctx->extradata_size*8LL, 1) < 0) { pop_output_configuration(ac); return AVERROR_INVALIDDATA; } @@ -3121,7 +3127,7 @@ static int aac_decode_frame(AVCodecContext *avctx, void *data, if (INT_MAX / 8 <= buf_size) return AVERROR_INVALIDDATA; - if ((err = init_get_bits(&gb, buf, buf_size * 8)) < 0) + if ((err = init_get_bits8(&gb, buf, buf_size)) < 0) return err; switch (ac->oc[1].m4ac.object_type) {