here is the same change for LATM, it's a whole lot uglier since the
length of the ASC is not promised to be padded to full bytes.
Janne
---8<---
---
libavcodec/aacdec.c | 23 +++++++++++++++--------
1 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 4d3f1ff..1c675a0 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -2312,6 +2312,7 @@ struct LATMContext {
AACContext aac_ctx; ///< containing AACContext
int initialized; ///< initilized after a valid
extradata was seen
+ int asc_size; ///< size of the ASC in bits
// parser data
int audio_mux_version_A; ///< LATM syntax version
int frame_length_type; ///< 0/1 variable/fixed frame length
@@ -2333,7 +2334,8 @@ static int latm_decode_audio_specific_config(struct
LATMContext *latmctx,
MPEG4AudioConfig m4ac = {0};
int config_start_bit = get_bits_count(gb);
int sync_extension = 0;
- int bits_consumed, esize;
+ int bits_consumed, esize, mask;
+ const uint8_t *asc_start;
if (asclen) {
sync_extension = 1;
@@ -2346,21 +2348,24 @@ static int latm_decode_audio_specific_config(struct
LATMContext *latmctx,
"config not byte aligned.\n", 1);
return AVERROR_INVALIDDATA;
}
- bits_consumed = decode_audio_specific_config(NULL, avctx, &m4ac,
- gb->buffer + (config_start_bit / 8),
+ asc_start = gb->buffer + (config_start_bit / 8);
+ bits_consumed = decode_audio_specific_config(NULL, avctx, &m4ac, asc_start,
asclen, sync_extension);
if (bits_consumed < 0)
return AVERROR_INVALIDDATA;
- if (ac->m4ac.sample_rate != m4ac.sample_rate ||
- ac->m4ac.chan_config != m4ac.chan_config) {
+ esize = (bits_consumed + 7) / 8;
+ mask = 0xFF << ((-bits_consumed) & 7);
+
+ if (!avctx->extradata ||
+ bits_consumed != latmctx->asc_size ||
+ memcmp(avctx->extradata, asc_start, esize - 1) ||
+ (avctx->extradata[esize - 1] & mask) != (asc_start[esize - 1] & mask))
{
av_log(avctx, AV_LOG_INFO, "audio config changed\n");
latmctx->initialized = 0;
- esize = (bits_consumed+7) / 8;
-
if (avctx->extradata_size < esize) {
av_free(avctx->extradata);
avctx->extradata = av_malloc(esize + FF_INPUT_BUFFER_PADDING_SIZE);
@@ -2369,8 +2374,10 @@ static int latm_decode_audio_specific_config(struct
LATMContext *latmctx,
}
avctx->extradata_size = esize;
- memcpy(avctx->extradata, gb->buffer + (config_start_bit/8), esize);
+ memcpy(avctx->extradata, asc_start, esize);
memset(avctx->extradata+esize, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+
+ latmctx->asc_size = bits_consumed;
}
skip_bits_long(gb, bits_consumed);
--
1.7.8.2
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel