Unified · Split
| @@ -2319,8 +2319,9 @@ static inline uint32_t latm_get_value(GetBitContext *b) · 2318 unmodified lines | ||
| 2319 | 2319 | static int latm_decode_audio_specific_config(struct LATMContext *latmctx, |
| 2320 | 2320 | GetBitContext *gb, int asclen) |
| 2321 | 2321 | { |
| 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}; | |
| 2324 | 2325 | int config_start_bit = get_bits_count(gb); |
| 2325 | 2326 | int sync_extension = 0; |
| 2326 | 2327 | int bits_consumed, esize; |
| @@ -2335,18 +2336,23 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx, · 8 unmodified lines | ||
| 2335 | 2336 | av_log_missing_feature(latmctx->aac_ctx.avctx, "audio specific " |
| 2336 | 2337 | "config not byte aligned.\n", 1); |
| 2337 | 2338 | 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, | |
| 2341 | 2341 | gb->buffer + (config_start_bit / 8), |
| 2342 | 2342 | asclen, sync_extension); |
| 2343 | 2343 | |
| 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; | |
| 2346 | 2352 | |
| 2347 | 2353 | esize = (bits_consumed+7) / 8; |
| 2348 | 2354 | |
| 2349 | − if (avctx->extradata_size <= esize) { | |
| 2355 | + if (avctx->extradata_size < esize) { | |
| 2350 | 2356 | av_free(avctx->extradata); |
| 2351 | 2357 | avctx->extradata = av_malloc(esize + FF_INPUT_BUFFER_PADDING_SIZE); |
| 2352 | 2358 | if (!avctx->extradata) |
| @@ -2356,9 +2362,8 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx, · 3 unmodified lines | ||
| 2356 | 2362 | avctx->extradata_size = esize; |
| 2357 | 2363 | memcpy(avctx->extradata, gb->buffer + (config_start_bit/8), esize); |
| 2358 | 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 | 2368 | return bits_consumed; |
| 2364 | 2369 | } |