mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
Codecs: mp4: Fix sbr detections for some files
Use logic from libfaad/mp4.c AudioSpecificConfig2 for sbr detection Fixes FS#12856 Change-Id: I235aa27830aa99f1307b303347f7affe7deafbe3
This commit is contained in:
parent
951e239517
commit
35150b83d4
1 changed files with 7 additions and 6 deletions
|
@ -213,6 +213,7 @@ static bool read_mp4_esds(int fd, struct mp3entry* id3, uint32_t* size)
|
||||||
{
|
{
|
||||||
unsigned char buf[8] = {0};
|
unsigned char buf[8] = {0};
|
||||||
bool sbr = false;
|
bool sbr = false;
|
||||||
|
bool sbr_signaled = false;
|
||||||
|
|
||||||
lseek(fd, 4, SEEK_CUR); /* Version and flags. */
|
lseek(fd, 4, SEEK_CUR); /* Version and flags. */
|
||||||
read(fd, buf, 1); /* Verify ES_DescrTag. */
|
read(fd, buf, 1); /* Verify ES_DescrTag. */
|
||||||
|
@ -282,6 +283,7 @@ static bool read_mp4_esds(int fd, struct mp3entry* id3, uint32_t* size)
|
||||||
* Object type - 5 bits
|
* Object type - 5 bits
|
||||||
* Frequency index - 4 bits
|
* Frequency index - 4 bits
|
||||||
* Channel configuration - 4 bits
|
* Channel configuration - 4 bits
|
||||||
|
* Also see libfaad/mp4.c AudioSpecificConfig2 (consider using it instead of manual parsing)
|
||||||
*/
|
*/
|
||||||
bits = get_long_be(buf);
|
bits = get_long_be(buf);
|
||||||
type = bits >> 27; /* Object type - 5 bits */
|
type = bits >> 27; /* Object type - 5 bits */
|
||||||
|
@ -326,6 +328,7 @@ static bool read_mp4_esds(int fd, struct mp3entry* id3, uint32_t* size)
|
||||||
if (type == 5)
|
if (type == 5)
|
||||||
{
|
{
|
||||||
sbr = bits >> 31;
|
sbr = bits >> 31;
|
||||||
|
sbr_signaled = true;
|
||||||
|
|
||||||
if (sbr)
|
if (sbr)
|
||||||
{
|
{
|
||||||
|
@ -353,13 +356,11 @@ static bool read_mp4_esds(int fd, struct mp3entry* id3, uint32_t* size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sbr && (id3->frequency <= 24000) && (length <= 2))
|
if (!sbr && !sbr_signaled && id3->frequency <= 24000)
|
||||||
{
|
{
|
||||||
/* Double the frequency for low-frequency files without a "long"
|
/* As stated in libfaad/mp4.c AudioSpecificConfig2:
|
||||||
* DecSpecificConfig header. The file may or may not contain SBR,
|
* no SBR signalled, this could mean either implicit signalling or no SBR in this file
|
||||||
* but here we guess it does if the header is short. This can
|
* MPEG specification states: assume SBR on files with samplerate <= 24000 Hz
|
||||||
* fail on some files, but it's the best we can do, short of
|
|
||||||
* decoding (parts of) the file.
|
|
||||||
*/
|
*/
|
||||||
id3->frequency *= 2;
|
id3->frequency *= 2;
|
||||||
sbr = true;
|
sbr = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue