mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-01-05 06:40:03 +00:00
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>
This commit is contained in:
parent
ad51833a1a
commit
b6aaa6d9a0
@ -460,7 +460,7 @@ static int decode_ga_specific_config(AACContext *ac, AVCodecContext *avctx,
|
|||||||
static int decode_audio_specific_config(AACContext *ac,
|
static int decode_audio_specific_config(AACContext *ac,
|
||||||
AVCodecContext *avctx,
|
AVCodecContext *avctx,
|
||||||
MPEG4AudioConfig *m4ac,
|
MPEG4AudioConfig *m4ac,
|
||||||
const uint8_t *data, int data_size)
|
const uint8_t *data, int data_size, int asclen)
|
||||||
{
|
{
|
||||||
GetBitContext gb;
|
GetBitContext gb;
|
||||||
int i;
|
int i;
|
||||||
@ -472,7 +472,7 @@ static int decode_audio_specific_config(AACContext *ac,
|
|||||||
|
|
||||||
init_get_bits(&gb, data, data_size * 8);
|
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;
|
return -1;
|
||||||
if (m4ac->sampling_index > 12) {
|
if (m4ac->sampling_index > 12) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", m4ac->sampling_index);
|
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 (avctx->extradata_size > 0) {
|
||||||
if (decode_audio_specific_config(ac, ac->avctx, &ac->m4ac,
|
if (decode_audio_specific_config(ac, ac->avctx, &ac->m4ac,
|
||||||
avctx->extradata,
|
avctx->extradata,
|
||||||
avctx->extradata_size) < 0)
|
avctx->extradata_size, 8*avctx->extradata_size) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
int sr, i;
|
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,
|
static int latm_decode_audio_specific_config(struct LATMContext *latmctx,
|
||||||
GetBitContext *gb)
|
GetBitContext *gb, int asclen)
|
||||||
{
|
{
|
||||||
AVCodecContext *avctx = latmctx->aac_ctx.avctx;
|
AVCodecContext *avctx = latmctx->aac_ctx.avctx;
|
||||||
MPEG4AudioConfig m4ac;
|
MPEG4AudioConfig m4ac;
|
||||||
@ -2324,7 +2324,7 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx,
|
|||||||
bits_consumed =
|
bits_consumed =
|
||||||
decode_audio_specific_config(NULL, avctx, &m4ac,
|
decode_audio_specific_config(NULL, avctx, &m4ac,
|
||||||
gb->buffer + (config_start_bit / 8),
|
gb->buffer + (config_start_bit / 8),
|
||||||
get_bits_left(gb) / 8);
|
get_bits_left(gb) / 8, asclen);
|
||||||
|
|
||||||
if (bits_consumed < 0)
|
if (bits_consumed < 0)
|
||||||
return AVERROR_INVALIDDATA;
|
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);
|
// for all but first stream: use_same_config = get_bits(gb, 1);
|
||||||
if (!audio_mux_version) {
|
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;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
int ascLen = latm_get_value(gb);
|
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;
|
return ret;
|
||||||
ascLen -= ret;
|
ascLen -= ret;
|
||||||
skip_bits_long(gb, ascLen);
|
skip_bits_long(gb, ascLen);
|
||||||
|
Loading…
Reference in New Issue
Block a user