浏览代码

more AAC SBR combinations

Philippe G 4 年之前
父节点
当前提交
c79cf5b58f
共有 2 个文件被更改,包括 15 次插入8 次删除
  1. 14 7
      components/squeezelite/helix-aac.c
  2. 1 1
      main/Kconfig.projbuild

+ 14 - 7
components/squeezelite/helix-aac.c

@@ -156,16 +156,23 @@ static int read_mp4_header(unsigned long *samplerate_p, unsigned char *channels_
 			info.sampRateCore = (*ptr++ & 0x07) << 1;
 			info.sampRateCore |= (*ptr >> 7) & 0x01;
 			info.sampRateCore = rates[info.sampRateCore];								
-			info.nChans = (*ptr++ & 0x7f) >> 3;
-			*channels_p = info.nChans;						
-			if (desc_len > 2 && ((ptr[0] << 3) | (ptr[1] >> 5)) == 0x2b7 && (ptr[1] & 0x1f) == 0x05 && (ptr[2] & 0x80)) {
-				*samplerate_p = rates[(ptr[2] & 0x78) >> 3];
-				LOG_WARN("AAC SBR mode activated => high CPU consumption expected, please use LMS proxy to mitigate");						
-			} else {
+			info.nChans = (*ptr & 0x7f) >> 3;
+			*channels_p = info.nChans;				
+			// Note that 24 bits frequencies are not handled	
+			if (info.profile == 5) {
+				*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) {
 				*samplerate_p = info.sampRateCore;
+			} else {	
+				*samplerate_p = 44100;
+				LOG_ERROR("AAC audio object type %d not handled", info.profile);									
 			}	
 			HAAC(a, SetRawBlockParams, a->hAac, 0, &info); 
-			LOG_DEBUG("playable aac track: %u (p:%x, r:%d, c:%d)", trak, info.profile, info.sampRateCore, info.nChans);
+			LOG_DEBUG("playable aac track: %u (p:%x, r:%d, c:%d, desc_len:%d)", trak, info.profile, info.sampRateCore, info.nChans, desc_len);
 			play = trak;
 		}
 

+ 1 - 1
main/Kconfig.projbuild

@@ -87,7 +87,7 @@ menu "Squeezelite-ESP32"
 			default "TWATCH" if TWATCH2020
 			default "I2S-4MFlash" if !A1S && !SQUEEZEAMP && !DAC32 && !TWATCH2020
 		# AGGREGATES - begin
-		# these parameters are "aggregates"	that take precedence. The must have a default value	
+		# these parameters are "aggregates"	that take precedence. They must have a default value	
 		config DAC_CONFIG
 			string 
 			default "model=TAS57xx,bck=33,ws=25,do=32,sda=27,scl=26,mute=14:0" if SQUEEZEAMP