From 693690e37f417d394a5e65296c75c2d971ffec58 Mon Sep 17 00:00:00 2001 From: Roman Artiukhin Date: Tue, 2 Jan 2024 11:11:00 +0200 Subject: [PATCH] Use adts_frame for adts header detection (#197) It already contains logic for header check with sync errors --- libfaad/decoder.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libfaad/decoder.c b/libfaad/decoder.c index c04da52..de3b169 100644 --- a/libfaad/decoder.c +++ b/libfaad/decoder.c @@ -276,6 +276,7 @@ long NeAACDecInit(NeAACDecHandle hpDecoder, if ((hDecoder == NULL) || (samplerate == NULL) || (channels == NULL) || (buffer_size == 0)) return -1; + adts.old_format = hDecoder->config.useOldADTSFormat; hDecoder->sf_index = get_sr_index(hDecoder->config.defSampleRate); hDecoder->object_type = hDecoder->config.defObjectType; *samplerate = get_sample_rate(hDecoder->sf_index); @@ -327,12 +328,9 @@ long NeAACDecInit(NeAACDecHandle hpDecoder, bits = bit2byte(faad_get_processed_bits(&ld)); /* Check if an ADTS header is present */ - } else if (faad_showbits(&ld, 12) == 0xfff) { + } else if (adts_frame(&adts, &ld) == 0) { hDecoder->adts_header_present = 1; - adts.old_format = hDecoder->config.useOldADTSFormat; - adts_frame(&adts, &ld); - hDecoder->sf_index = adts.sf_index; hDecoder->object_type = adts.profile + 1;