summaryrefslogtreecommitdiff
path: root/apps/metadata
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2011-02-02 09:38:24 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2011-02-02 09:38:24 +0000
commit4343399473929fd5e746ceee23350d5c6cb264cf (patch)
treeeb2f2306ada36dd7fdb755cfb03a800e45efe0c3 /apps/metadata
parent0a93396cdeab4eb96c7e21531a2d9e2dfde15a2b (diff)
downloadrockbox-4343399473929fd5e746ceee23350d5c6cb264cf.zip
rockbox-4343399473929fd5e746ceee23350d5c6cb264cf.tar.gz
rockbox-4343399473929fd5e746ceee23350d5c6cb264cf.tar.bz2
rockbox-4343399473929fd5e746ceee23350d5c6cb264cf.tar.xz
Recognize AAC-HE SBR with upsampling and correct duration, bitrate, seek and resume behaviour for such files. When SBR upsampling is used the decoder outputs the double amount of samples per frame. As the seek and resume functions do not know about this fact a special handling is introduced. Fixes issues reported in FS#11916.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29186 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/metadata')
-rw-r--r--apps/metadata/mp4.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/apps/metadata/mp4.c b/apps/metadata/mp4.c
index a59b3f9..c9c691f 100644
--- a/apps/metadata/mp4.c
+++ b/apps/metadata/mp4.c
@@ -73,6 +73,9 @@
#define MP4_udta FOURCC('u', 'd', 't', 'a')
#define MP4_extra FOURCC('-', '-', '-', '-')
+/* Used to correct id3->samples, if SBR upsampling was detected in esds atom. */
+static bool SBR_upsampling_used = false;
+
/* Read the tag data from an MP4 file, storing up to buffer_size bytes in
* buffer.
*/
@@ -272,7 +275,6 @@ static bool read_mp4_esds(int fd, struct mp3entry* id3, uint32_t* size)
if (type == 5)
{
- DEBUGF("MP4: SBR\n");
unsigned int old_index = index;
sbr = true;
@@ -342,6 +344,12 @@ static bool read_mp4_esds(int fd, struct mp3entry* id3, uint32_t* size)
* decoding (parts of) the file.
*/
id3->frequency *= 2;
+
+ /* Set this to true to be able to calculate the correct runtime
+ * and bitrate. */
+ SBR_upsampling_used = true;
+
+ sbr = true;
}
}
@@ -665,6 +673,7 @@ static bool read_mp4_container(int fd, struct mp3entry* id3,
{
uint32_t subsize;
uint32_t subtype;
+ bool sbr_used;
/* Get frequency from the decoder info tag, if possible. */
lseek(fd, 2, SEEK_CUR);
@@ -676,7 +685,14 @@ static bool read_mp4_container(int fd, struct mp3entry* id3,
if (subtype == MP4_esds)
{
- read_mp4_esds(fd, id3, &size);
+ sbr_used = read_mp4_esds(fd, id3, &size);
+ if (sbr_used)
+ {
+ if (SBR_upsampling_used)
+ DEBUGF("MP4: AAC-HE, SBR upsampling\n");
+ else
+ DEBUGF("MP4: AAC-HE, SBR\n");
+ }
}
}
}
@@ -730,6 +746,7 @@ static bool read_mp4_container(int fd, struct mp3entry* id3,
bool get_mp4_metadata(int fd, struct mp3entry* id3)
{
+ SBR_upsampling_used = false;
id3->codectype = AFMT_UNKNOWN;
id3->filesize = 0;
errno = 0;
@@ -743,6 +760,12 @@ bool get_mp4_metadata(int fd, struct mp3entry* id3)
logf("Not an ALAC or AAC file");
return false;
}
+
+ /* SBR upsampling will output double amount of samples per frame. */
+ if (SBR_upsampling_used)
+ {
+ id3->samples *= 2;
+ }
id3->length = ((int64_t) id3->samples * 1000) / id3->frequency;