summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMarcoen Hirschberg <marcoen@gmail.com>2009-10-06 13:47:12 +0000
committerMarcoen Hirschberg <marcoen@gmail.com>2009-10-06 13:47:12 +0000
commitc48af23c7ea13d91a3514b342bf0f6ec1fb3b5d4 (patch)
treee0714cab9ee6427fa44ad910c2f4544822712938 /apps
parent67ded6ce9d8d1ace0112ae7d4222fa7a129c0be6 (diff)
add gapless playback for Nero encoded AAC files
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22984 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/metadata/metadata_common.c15
-rw-r--r--apps/metadata/metadata_common.h2
-rw-r--r--apps/metadata/mp4.c21
3 files changed, 38 insertions, 0 deletions
diff --git a/apps/metadata/metadata_common.c b/apps/metadata/metadata_common.c
index 5947098f12..318399693c 100644
--- a/apps/metadata/metadata_common.c
+++ b/apps/metadata/metadata_common.c
@@ -124,6 +124,21 @@ int read_uint32be(int fd, uint32_t* buf)
*buf = betoh32(*buf);
return n;
}
+/* Read an unsigned 64-bit integer from a big-endian file. */
+int read_uint64be(int fd, uint64_t* buf)
+{
+ size_t n;
+ uint8_t data[8];
+ int i;
+
+ n = read(fd, data, 8);
+
+ for (i=0, *buf=0; i<=7; i++) {
+ *buf <<= 8;
+ *buf |= data[i];
+ }
+ return n;
+}
#else
/* Read unsigned integers from a little-endian file. */
int read_uint16le(int fd, uint16_t* buf)
diff --git a/apps/metadata/metadata_common.h b/apps/metadata/metadata_common.h
index 1bfa6b09e4..f7539950e1 100644
--- a/apps/metadata/metadata_common.h
+++ b/apps/metadata/metadata_common.h
@@ -42,12 +42,14 @@ int read_uint8(int fd, uint8_t* buf);
#ifdef ROCKBOX_BIG_ENDIAN
#define read_uint16be(fd,buf) read((fd), (buf), 2)
#define read_uint32be(fd,buf) read((fd), (buf), 4)
+#define read_uint64be(fd,buf) read((fd), (buf), 8)
int read_uint16le(int fd, uint16_t* buf);
int read_uint32le(int fd, uint32_t* buf);
int read_uint64le(int fd, uint64_t* buf);
#else
int read_uint16be(int fd, uint16_t* buf);
int read_uint32be(int fd, uint32_t* buf);
+int read_uint64be(int fd, uint64_t* buf);
#define read_uint16le(fd,buf) read((fd), (buf), 2)
#define read_uint32le(fd,buf) read((fd), (buf), 4)
#define read_uint64le(fd,buf) read((fd), (buf), 8)
diff --git a/apps/metadata/mp4.c b/apps/metadata/mp4.c
index 00f0bf9d4c..a520597972 100644
--- a/apps/metadata/mp4.c
+++ b/apps/metadata/mp4.c
@@ -42,6 +42,7 @@
#define MP4_cART MP4_ID(0xa9, 'A', 'R', 'T')
#define MP4_cgrp MP4_ID(0xa9, 'g', 'r', 'p')
#define MP4_cgen MP4_ID(0xa9, 'g', 'e', 'n')
+#define MP4_chpl MP4_ID('c', 'h', 'p', 'l')
#define MP4_cnam MP4_ID(0xa9, 'n', 'a', 'm')
#define MP4_cwrt MP4_ID(0xa9, 'w', 'r', 't')
#define MP4_ccmt MP4_ID(0xa9, 'c', 'm', 't')
@@ -681,6 +682,26 @@ static bool read_mp4_container(int fd, struct mp3entry* id3,
id3->filesize = size;
break;
+ case MP4_chpl:
+ {
+ /* ADDME: add support for real chapters. Right now it's only
+ * used for Nero's gapless hack */
+ uint8_t chapters;
+ uint64_t timestamp;
+
+ lseek(fd, 8, SEEK_CUR);
+ read_uint8(fd, &chapters);
+ size -= 9;
+
+ /* the first chapter will be used as the lead_trim */
+ if (chapters > 0) {
+ read_uint64be(fd, &timestamp);
+ id3->lead_trim = (timestamp * id3->frequency) / 10000000;
+ size -= 8;
+ }
+ }
+ break;
+
default:
break;
}