History

aac_latm: reconfigure decoder on audio specific config changes

Janne Grunau committed 15 years ago

Commit d268b791 parent fd095531 file · +15 −10Browse files

Unified · Split

libavcodec/aacdec.c+15−10
@@ -2319,8 +2319,9 @@ static inline uint32_t latm_get_value(GetBitContext *b) · 2318 unmodified lines
23192319 static int latm_decode_audio_specific_config(struct LATMContext *latmctx,
23202320 GetBitContext *gb, int asclen)
23212321 {
2322− AVCodecContext *avctx = latmctx->aac_ctx.avctx;
2323− MPEG4AudioConfig m4ac;
2322+ AACContext *ac = &latmctx->aac_ctx;
2323+ AVCodecContext *avctx = ac->avctx;
2324+ MPEG4AudioConfig m4ac = {0};
23242325 int config_start_bit = get_bits_count(gb);
23252326 int sync_extension = 0;
23262327 int bits_consumed, esize;
@@ -2335,18 +2336,23 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx, · 8 unmodified lines
23352336 av_log_missing_feature(latmctx->aac_ctx.avctx, "audio specific "
23362337 "config not byte aligned.\n", 1);
23372338 return AVERROR_INVALIDDATA;
2338− } else {
2339− bits_consumed =
2340− decode_audio_specific_config(NULL, avctx, &m4ac,
2339+ }
2340+ bits_consumed = decode_audio_specific_config(NULL, avctx, &m4ac,
23412341 gb->buffer + (config_start_bit / 8),
23422342 asclen, sync_extension);
23432343
2344− if (bits_consumed < 0)
2345− return AVERROR_INVALIDDATA;
2344+ if (bits_consumed < 0)
2345+ return AVERROR_INVALIDDATA;
2346+
2347+ if (ac->m4ac.sample_rate != m4ac.sample_rate ||
2348+ ac->m4ac.chan_config != m4ac.chan_config) {
2349+
2350+ av_log(avctx, AV_LOG_INFO, "audio config changed\n");
2351+ latmctx->initialized = 0;
23462352
23472353 esize = (bits_consumed+7) / 8;
23482354
2349− if (avctx->extradata_size <= esize) {
2355+ if (avctx->extradata_size < esize) {
23502356 av_free(avctx->extradata);
23512357 avctx->extradata = av_malloc(esize + FF_INPUT_BUFFER_PADDING_SIZE);
23522358 if (!avctx->extradata)
@@ -2356,9 +2362,8 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx, · 3 unmodified lines
23562362 avctx->extradata_size = esize;
23572363 memcpy(avctx->extradata, gb->buffer + (config_start_bit/8), esize);
23582364 memset(avctx->extradata+esize, 0, FF_INPUT_BUFFER_PADDING_SIZE);
2359−
2360− skip_bits_long(gb, bits_consumed);
23612365 }
2366+ skip_bits_long(gb, bits_consumed);
23622367
23632368 return bits_consumed;
23642369 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t