Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Codecs: mp4: Fix sbr detections for some files

Use logic from libfaad/mp4.c AudioSpecificConfig2 for sbr detection

Fixes FS#12856

Change-Id: I235aa27830aa99f1307b303347f7affe7deafbe3

authored by

roman.artiukhin and committed by
Solomon Peachy
35150b83 951e2395

+7 -6
+7 -6
lib/rbcodec/metadata/mp4.c
··· 213 213 { 214 214 unsigned char buf[8] = {0}; 215 215 bool sbr = false; 216 + bool sbr_signaled = false; 216 217 217 218 lseek(fd, 4, SEEK_CUR); /* Version and flags. */ 218 219 read(fd, buf, 1); /* Verify ES_DescrTag. */ ··· 282 283 * Object type - 5 bits 283 284 * Frequency index - 4 bits 284 285 * Channel configuration - 4 bits 286 + * Also see libfaad/mp4.c AudioSpecificConfig2 (consider using it instead of manual parsing) 285 287 */ 286 288 bits = get_long_be(buf); 287 289 type = bits >> 27; /* Object type - 5 bits */ ··· 326 328 if (type == 5) 327 329 { 328 330 sbr = bits >> 31; 331 + sbr_signaled = true; 329 332 330 333 if (sbr) 331 334 { ··· 353 356 } 354 357 } 355 358 356 - if (!sbr && (id3->frequency <= 24000) && (length <= 2)) 359 + if (!sbr && !sbr_signaled && id3->frequency <= 24000) 357 360 { 358 - /* Double the frequency for low-frequency files without a "long" 359 - * DecSpecificConfig header. The file may or may not contain SBR, 360 - * but here we guess it does if the header is short. This can 361 - * fail on some files, but it's the best we can do, short of 362 - * decoding (parts of) the file. 361 + /* As stated in libfaad/mp4.c AudioSpecificConfig2: 362 + * no SBR signalled, this could mean either implicit signalling or no SBR in this file 363 + * MPEG specification states: assume SBR on files with samplerate <= 24000 Hz 363 364 */ 364 365 id3->frequency *= 2; 365 366 sbr = true;