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
2319static int latm_decode_audio_specific_config(struct LATMContext *latmctx,2319static int latm_decode_audio_specific_config(struct LATMContext *latmctx,
2320 GetBitContext *gb, int asclen)2320 GetBitContext *gb, int asclen)
2321{2321{
2322 AVCodecContext *avctx = latmctx->aac_ctx.avctx;2322 AACContext *ac = &latmctx->aac_ctx;
2323 MPEG4AudioConfig m4ac;2323 AVCodecContext *avctx = ac->avctx;
2324 MPEG4AudioConfig m4ac = {0};
2324 int config_start_bit = get_bits_count(gb);2325 int config_start_bit = get_bits_count(gb);
2325 int sync_extension = 0;2326 int sync_extension = 0;
2326 int bits_consumed, esize;2327 int bits_consumed, esize;
@@ -2335,18 +2336,23 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx, · 8 unmodified lines
2335 av_log_missing_feature(latmctx->aac_ctx.avctx, "audio specific "2336 av_log_missing_feature(latmctx->aac_ctx.avctx, "audio specific "
2336 "config not byte aligned.\n", 1);2337 "config not byte aligned.\n", 1);
2337 return AVERROR_INVALIDDATA;2338 return AVERROR_INVALIDDATA;
2338 } else {2339 }
2339 bits_consumed =2340 bits_consumed = decode_audio_specific_config(NULL, avctx, &m4ac,
2340 decode_audio_specific_config(NULL, avctx, &m4ac,
2341 gb->buffer + (config_start_bit / 8),2341 gb->buffer + (config_start_bit / 8),
2342 asclen, sync_extension);2342 asclen, sync_extension);
2343 2343
2344 if (bits_consumed < 0)2344 if (bits_consumed < 0)
2345 return AVERROR_INVALIDDATA;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;
2346 2352
2347 esize = (bits_consumed+7) / 8;2353 esize = (bits_consumed+7) / 8;
2348 2354
2349 if (avctx->extradata_size <= esize) {2355 if (avctx->extradata_size < esize) {
2350 av_free(avctx->extradata);2356 av_free(avctx->extradata);
2351 avctx->extradata = av_malloc(esize + FF_INPUT_BUFFER_PADDING_SIZE);2357 avctx->extradata = av_malloc(esize + FF_INPUT_BUFFER_PADDING_SIZE);
2352 if (!avctx->extradata)2358 if (!avctx->extradata)
@@ -2356,9 +2362,8 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx, · 3 unmodified lines
2356 avctx->extradata_size = esize;2362 avctx->extradata_size = esize;
2357 memcpy(avctx->extradata, gb->buffer + (config_start_bit/8), esize);2363 memcpy(avctx->extradata, gb->buffer + (config_start_bit/8), esize);
2358 memset(avctx->extradata+esize, 0, FF_INPUT_BUFFER_PADDING_SIZE);2364 memset(avctx->extradata+esize, 0, FF_INPUT_BUFFER_PADDING_SIZE);
2359
2360 skip_bits_long(gb, bits_consumed);
2361 }2365 }
2366 skip_bits_long(gb, bits_consumed);
2362 2367
2363 return bits_consumed;2368 return bits_consumed;
2364}2369}

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