Skip to content

Commit

Permalink
Use adts_frame for adts header detection
Browse files Browse the repository at this point in the history
It already contains logic for header check with sync errors
  • Loading branch information
bahusoid authored Dec 27, 2023
1 parent 677918d commit 4bb39a3
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions libfaad/decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 4bb39a3

Please sign in to comment.