From 852e3128795aeb6df398894d523816ac5389361f Mon Sep 17 00:00:00 2001 From: Philippe G Date: Tue, 20 Apr 2021 19:38:01 -0700 Subject: [PATCH] Correct AAC handling of different AOT --- components/squeezelite/helix-aac.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/components/squeezelite/helix-aac.c b/components/squeezelite/helix-aac.c index 7b3adaf1..5ad72cd9 100644 --- a/components/squeezelite/helix-aac.c +++ b/components/squeezelite/helix-aac.c @@ -152,27 +152,28 @@ static int read_mp4_header(unsigned long *samplerate_p, unsigned char *channels_ return -1; } int desc_len = mp4_desc_length(&ptr); - info.profile = *ptr >> 3; + int AOT = *ptr >> 3; + info.profile = AAC_PROFILE_LC; info.sampRateCore = (*ptr++ & 0x07) << 1; info.sampRateCore |= (*ptr >> 7) & 0x01; info.sampRateCore = rates[info.sampRateCore]; info.nChans = (*ptr & 0x7f) >> 3; *channels_p = info.nChans; // Note that 24 bits frequencies are not handled - if (info.profile == 5) { + if (AOT == 5 || AOT == 29) { *samplerate_p = rates[((ptr[0] & 0x03) << 1) | (ptr[1] >> 7)]; LOG_WARN("AAC stream with SBR => high CPU required (use LMS proxied mode)"); } else if (desc_len > 2 && ((ptr[1] << 3) | (ptr[2] >> 5)) == 0x2b7 && (ptr[2] & 0x1f) == 0x05 && (ptr[3] & 0x80)) { *samplerate_p = rates[(ptr[3] & 0x78) >> 3]; LOG_WARN("AAC stream with extended SBR => high CPU required (use LMS proxied mode)"); - } else if (info.profile == 2 || info.profile == 29) { + } else if (AOT == 2) { *samplerate_p = info.sampRateCore; } else { *samplerate_p = 44100; - LOG_ERROR("AAC audio object type %d not handled", info.profile); + LOG_ERROR("AAC audio object type %d not handled", AOT); } HAAC(a, SetRawBlockParams, a->hAac, 0, &info); - LOG_DEBUG("playable aac track: %u (p:%x, r:%d, c:%d, desc_len:%d)", trak, info.profile, info.sampRateCore, info.nChans, desc_len); + LOG_DEBUG("playable aac track: %u (p:%x, r:%d, c:%d, desc_len:%d)", trak, AOT, info.sampRateCore, info.nChans, desc_len); play = trak; }