Browse Source

activate SBR mode in AAC

Philippe G 4 years ago
parent
commit
cac6306a04
1 changed files with 8 additions and 4 deletions
  1. 8 4
      components/squeezelite/helix-aac.c

+ 8 - 4
components/squeezelite/helix-aac.c

@@ -151,14 +151,18 @@ static int read_mp4_header(unsigned long *samplerate_p, unsigned char *channels_
 				LOG_WARN("error parsing esds");
 				return -1;
 			}
-			mp4_desc_length(&ptr);
+			int desc_len = mp4_desc_length(&ptr);
 			info.profile = *ptr >> 3;
 			info.sampRateCore = (*ptr++ & 0x07) << 1;
 			info.sampRateCore |= (*ptr >> 7) & 0x01;
-			info.sampRateCore = rates[info.sampRateCore];
-			info.nChans = (*ptr & 0x7f) >> 3;
-			*channels_p = info.nChans;
+			info.sampRateCore = rates[info.sampRateCore];								
+			info.nChans = (*ptr++ & 0x7f) >> 3;
+			*channels_p = info.nChans;						
 			*samplerate_p = info.sampRateCore;
+			if (desc_len > 2 && ((ptr[0] << 3) | (ptr[1] >> 5)) == 0x2b7 && (ptr[1] & 0x1f) == 0x05 && (ptr[2] & 0x80)) {
+				LOG_WARN("AAC SBR mode activated => high CPU consumption (please proxy)");		
+				*samplerate_p = rates[(ptr[2] & 0x78) >> 3];
+			}	
 			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);
 			play = trak;