diff options
Diffstat (limited to 'apps/metadata')
-rw-r--r-- | apps/metadata/metadata_common.c | 15 | ||||
-rw-r--r-- | apps/metadata/metadata_common.h | 2 | ||||
-rw-r--r-- | apps/metadata/mp4.c | 21 |
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) | |||
124 | *buf = betoh32(*buf); | 124 | *buf = betoh32(*buf); |
125 | return n; | 125 | return n; |
126 | } | 126 | } |
127 | /* Read an unsigned 64-bit integer from a big-endian file. */ | ||
128 | int read_uint64be(int fd, uint64_t* buf) | ||
129 | { | ||
130 | size_t n; | ||
131 | uint8_t data[8]; | ||
132 | int i; | ||
133 | |||
134 | n = read(fd, data, 8); | ||
135 | |||
136 | for (i=0, *buf=0; i<=7; i++) { | ||
137 | *buf <<= 8; | ||
138 | *buf |= data[i]; | ||
139 | } | ||
140 | return n; | ||
141 | } | ||
127 | #else | 142 | #else |
128 | /* Read unsigned integers from a little-endian file. */ | 143 | /* Read unsigned integers from a little-endian file. */ |
129 | int read_uint16le(int fd, uint16_t* buf) | 144 | 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); | |||
42 | #ifdef ROCKBOX_BIG_ENDIAN | 42 | #ifdef ROCKBOX_BIG_ENDIAN |
43 | #define read_uint16be(fd,buf) read((fd), (buf), 2) | 43 | #define read_uint16be(fd,buf) read((fd), (buf), 2) |
44 | #define read_uint32be(fd,buf) read((fd), (buf), 4) | 44 | #define read_uint32be(fd,buf) read((fd), (buf), 4) |
45 | #define read_uint64be(fd,buf) read((fd), (buf), 8) | ||
45 | int read_uint16le(int fd, uint16_t* buf); | 46 | int read_uint16le(int fd, uint16_t* buf); |
46 | int read_uint32le(int fd, uint32_t* buf); | 47 | int read_uint32le(int fd, uint32_t* buf); |
47 | int read_uint64le(int fd, uint64_t* buf); | 48 | int read_uint64le(int fd, uint64_t* buf); |
48 | #else | 49 | #else |
49 | int read_uint16be(int fd, uint16_t* buf); | 50 | int read_uint16be(int fd, uint16_t* buf); |
50 | int read_uint32be(int fd, uint32_t* buf); | 51 | int read_uint32be(int fd, uint32_t* buf); |
52 | int read_uint64be(int fd, uint64_t* buf); | ||
51 | #define read_uint16le(fd,buf) read((fd), (buf), 2) | 53 | #define read_uint16le(fd,buf) read((fd), (buf), 2) |
52 | #define read_uint32le(fd,buf) read((fd), (buf), 4) | 54 | #define read_uint32le(fd,buf) read((fd), (buf), 4) |
53 | #define read_uint64le(fd,buf) read((fd), (buf), 8) | 55 | #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 @@ | |||
42 | #define MP4_cART MP4_ID(0xa9, 'A', 'R', 'T') | 42 | #define MP4_cART MP4_ID(0xa9, 'A', 'R', 'T') |
43 | #define MP4_cgrp MP4_ID(0xa9, 'g', 'r', 'p') | 43 | #define MP4_cgrp MP4_ID(0xa9, 'g', 'r', 'p') |
44 | #define MP4_cgen MP4_ID(0xa9, 'g', 'e', 'n') | 44 | #define MP4_cgen MP4_ID(0xa9, 'g', 'e', 'n') |
45 | #define MP4_chpl MP4_ID('c', 'h', 'p', 'l') | ||
45 | #define MP4_cnam MP4_ID(0xa9, 'n', 'a', 'm') | 46 | #define MP4_cnam MP4_ID(0xa9, 'n', 'a', 'm') |
46 | #define MP4_cwrt MP4_ID(0xa9, 'w', 'r', 't') | 47 | #define MP4_cwrt MP4_ID(0xa9, 'w', 'r', 't') |
47 | #define MP4_ccmt MP4_ID(0xa9, 'c', 'm', 't') | 48 | #define MP4_ccmt MP4_ID(0xa9, 'c', 'm', 't') |
@@ -681,6 +682,26 @@ static bool read_mp4_container(int fd, struct mp3entry* id3, | |||
681 | id3->filesize = size; | 682 | id3->filesize = size; |
682 | break; | 683 | break; |
683 | 684 | ||
685 | case MP4_chpl: | ||
686 | { | ||
687 | /* ADDME: add support for real chapters. Right now it's only | ||
688 | * used for Nero's gapless hack */ | ||
689 | uint8_t chapters; | ||
690 | uint64_t timestamp; | ||
691 | |||
692 | lseek(fd, 8, SEEK_CUR); | ||
693 | read_uint8(fd, &chapters); | ||
694 | size -= 9; | ||
695 | |||
696 | /* the first chapter will be used as the lead_trim */ | ||
697 | if (chapters > 0) { | ||
698 | read_uint64be(fd, ×tamp); | ||
699 | id3->lead_trim = (timestamp * id3->frequency) / 10000000; | ||
700 | size -= 8; | ||
701 | } | ||
702 | } | ||
703 | break; | ||
704 | |||
684 | default: | 705 | default: |
685 | break; | 706 | break; |
686 | } | 707 | } |