aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/aacdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-09-23 22:34:26 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-09-23 22:34:26 +0200
commitb6aaa6d9a081f4851e76f1182c959be3c09ee59c (patch)
treea08a3748fbaf1a6a3b29acc12220667772378727 /libavcodec/aacdec.c
parentad51833a1a0a31ea39fa5542c1ec3851feb6630c (diff)
downloadffmpeg-b6aaa6d9a081f4851e76f1182c959be3c09ee59c.tar.gz
aacdec: Make aac-latm closer to the spec (not reading random data leading to random false configurations)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/aacdec.c')
-rw-r--r--libavcodec/aacdec.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 557e5268f2..3c73ad2fa1 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -460,7 +460,7 @@ static int decode_ga_specific_config(AACContext *ac, AVCodecContext *avctx,
static int decode_audio_specific_config(AACContext *ac,
AVCodecContext *avctx,
MPEG4AudioConfig *m4ac,
- const uint8_t *data, int data_size)
+ const uint8_t *data, int data_size, int asclen)
{
GetBitContext gb;
int i;
@@ -472,7 +472,7 @@ static int decode_audio_specific_config(AACContext *ac,
init_get_bits(&gb, data, data_size * 8);
- if ((i = ff_mpeg4audio_get_config(m4ac, data, data_size)) < 0)
+ if ((i = ff_mpeg4audio_get_config(m4ac, data, asclen/8)) < 0)
return -1;
if (m4ac->sampling_index > 12) {
av_log(avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", m4ac->sampling_index);
@@ -572,7 +572,7 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
if (avctx->extradata_size > 0) {
if (decode_audio_specific_config(ac, ac->avctx, &ac->m4ac,
avctx->extradata,
- avctx->extradata_size) < 0)
+ avctx->extradata_size, 8*avctx->extradata_size) < 0)
return -1;
} else {
int sr, i;
@@ -2309,7 +2309,7 @@ static inline uint32_t latm_get_value(GetBitContext *b)
}
static int latm_decode_audio_specific_config(struct LATMContext *latmctx,
- GetBitContext *gb)
+ GetBitContext *gb, int asclen)
{
AVCodecContext *avctx = latmctx->aac_ctx.avctx;
MPEG4AudioConfig m4ac;
@@ -2324,7 +2324,7 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx,
bits_consumed =
decode_audio_specific_config(NULL, avctx, &m4ac,
gb->buffer + (config_start_bit / 8),
- get_bits_left(gb) / 8);
+ get_bits_left(gb) / 8, asclen);
if (bits_consumed < 0)
return AVERROR_INVALIDDATA;
@@ -2382,11 +2382,11 @@ static int read_stream_mux_config(struct LATMContext *latmctx,
// for all but first stream: use_same_config = get_bits(gb, 1);
if (!audio_mux_version) {
- if ((ret = latm_decode_audio_specific_config(latmctx, gb)) < 0)
+ if ((ret = latm_decode_audio_specific_config(latmctx, gb, 0)) < 0)
return ret;
} else {
int ascLen = latm_get_value(gb);
- if ((ret = latm_decode_audio_specific_config(latmctx, gb)) < 0)
+ if ((ret = latm_decode_audio_specific_config(latmctx, gb, ascLen)) < 0)
return ret;
ascLen -= ret;
skip_bits_long(gb, ascLen);