aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorJanne Grunau <janne-libav@jannau.net>2011-10-22 22:04:00 +0200
committerJanne Grunau <janne-libav@jannau.net>2011-12-03 00:42:48 +0100
commitd268b79e3436107c11ee8bcdf9f3645368bb3fcd (patch)
tree0b7906af43dfb4c18a0f5f35ae8fd203b76c9a57 /libavcodec
parentfd095539d10bb440042e671f95306b16b0fec674 (diff)
downloadffmpeg-d268b79e3436107c11ee8bcdf9f3645368bb3fcd.tar.gz
aac_latm: reconfigure decoder on audio specific config changes
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/aacdec.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index a4fe2ee2cc..8e4b510354 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -2319,8 +2319,9 @@ static inline uint32_t latm_get_value(GetBitContext *b)
static int latm_decode_audio_specific_config(struct LATMContext *latmctx,
GetBitContext *gb, int asclen)
{
- AVCodecContext *avctx = latmctx->aac_ctx.avctx;
- MPEG4AudioConfig m4ac;
+ AACContext *ac = &latmctx->aac_ctx;
+ AVCodecContext *avctx = ac->avctx;
+ MPEG4AudioConfig m4ac = {0};
int config_start_bit = get_bits_count(gb);
int sync_extension = 0;
int bits_consumed, esize;
@@ -2335,18 +2336,23 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx,
av_log_missing_feature(latmctx->aac_ctx.avctx, "audio specific "
"config not byte aligned.\n", 1);
return AVERROR_INVALIDDATA;
- } else {
- bits_consumed =
- decode_audio_specific_config(NULL, avctx, &m4ac,
+ }
+ bits_consumed = decode_audio_specific_config(NULL, avctx, &m4ac,
gb->buffer + (config_start_bit / 8),
asclen, sync_extension);
- if (bits_consumed < 0)
- return AVERROR_INVALIDDATA;
+ if (bits_consumed < 0)
+ return AVERROR_INVALIDDATA;
+
+ if (ac->m4ac.sample_rate != m4ac.sample_rate ||
+ ac->m4ac.chan_config != m4ac.chan_config) {
+
+ av_log(avctx, AV_LOG_INFO, "audio config changed\n");
+ latmctx->initialized = 0;
esize = (bits_consumed+7) / 8;
- if (avctx->extradata_size <= esize) {
+ if (avctx->extradata_size < esize) {
av_free(avctx->extradata);
avctx->extradata = av_malloc(esize + FF_INPUT_BUFFER_PADDING_SIZE);
if (!avctx->extradata)
@@ -2356,9 +2362,8 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx,
avctx->extradata_size = esize;
memcpy(avctx->extradata, gb->buffer + (config_start_bit/8), esize);
memset(avctx->extradata+esize, 0, FF_INPUT_BUFFER_PADDING_SIZE);
-
- skip_bits_long(gb, bits_consumed);
}
+ skip_bits_long(gb, bits_consumed);
return bits_consumed;
}