summaryrefslogtreecommitdiff
path: root/apps/metadata.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/metadata.c')
-rw-r--r--apps/metadata.c51
1 files changed, 12 insertions, 39 deletions
diff --git a/apps/metadata.c b/apps/metadata.c
index dcbc29e73c..83c29649a1 100644
--- a/apps/metadata.c
+++ b/apps/metadata.c
@@ -194,11 +194,12 @@ static void convert_endian(void *data, const char *format)
194 } 194 }
195} 195}
196 196
197#if 0 /* not needed atm */
197/* Read an unsigned 16-bit integer from a big-endian file. */ 198/* Read an unsigned 16-bit integer from a big-endian file. */
198#ifdef ROCKBOX_BIG_ENDIAN 199#ifdef ROCKBOX_BIG_ENDIAN
199#define read_uint16be(fd, buf) read((fd), (buf), 2) 200#define read_uint16be(fd, buf) read((fd), (buf), 2)
200#else 201#else
201int read_uint16be(int fd, unsigned short* buf) 202static int read_uint16be(int fd, unsigned short* buf)
202{ 203{
203 size_t n; 204 size_t n;
204 205
@@ -207,12 +208,13 @@ int read_uint16be(int fd, unsigned short* buf)
207 return n; 208 return n;
208} 209}
209#endif 210#endif
211#endif /* if 0 */
210 212
211/* Read an unsigned 32-bit integer from a big-endian file. */ 213/* Read an unsigned 32-bit integer from a big-endian file. */
212#ifdef ROCKBOX_BIG_ENDIAN 214#ifdef ROCKBOX_BIG_ENDIAN
213#define read_uint32be(fd,buf) read((fd), (buf), 4) 215#define read_uint32be(fd,buf) read((fd), (buf), 4)
214#else 216#else
215int read_uint32be(int fd, unsigned int* buf) 217static int read_uint32be(int fd, unsigned int* buf)
216{ 218{
217 size_t n; 219 size_t n;
218 220
@@ -238,35 +240,6 @@ static unsigned long get_long_be(void* buf)
238 return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; 240 return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
239} 241}
240 242
241/* Read a string tag from an M4A file */
242void read_m4a_tag_string(int fd, int len,char** bufptr,size_t* bytes_remaining, char** dest)
243{
244 int data_length;
245
246 if (bytes_remaining==0) {
247 lseek(fd,len,SEEK_CUR); /* Skip everything */
248 } else {
249 /* Skip the data tag header - maybe we should parse it properly? */
250 lseek(fd,16,SEEK_CUR);
251 len-=16;
252
253 *dest=*bufptr;
254 if ((size_t)len+1 > *bytes_remaining) {
255 read(fd,*bufptr,*bytes_remaining-1);
256 lseek(fd,len-(*bytes_remaining-1),SEEK_CUR);
257 *bufptr+=(*bytes_remaining-1);
258 } else {
259 read(fd,*bufptr,len);
260 *bufptr+=len;
261 }
262 **bufptr=(char)0;
263
264 data_length = strlen(*dest)+1;
265 *bufptr=(*dest)+data_length;
266 *bytes_remaining-=data_length;
267 }
268}
269
270/* Parse the tag (the name-value pair) and fill id3 and buffer accordingly. 243/* Parse the tag (the name-value pair) and fill id3 and buffer accordingly.
271 * String values to keep are written to buf. Returns number of bytes written 244 * String values to keep are written to buf. Returns number of bytes written
272 * to buf (including end nil). 245 * to buf (including end nil).
@@ -953,8 +926,8 @@ static bool get_wave_metadata(int fd, struct mp3entry* id3)
953/* Read the tag data from an MP4 file, storing up to buffer_size bytes in 926/* Read the tag data from an MP4 file, storing up to buffer_size bytes in
954 * buffer. 927 * buffer.
955 */ 928 */
956unsigned long read_mp4_tag(int fd, unsigned int size_left, char* buffer, 929static unsigned long read_mp4_tag(int fd, unsigned int size_left, char* buffer,
957 unsigned int buffer_left) 930 unsigned int buffer_left)
958{ 931{
959 unsigned int bytes_read = 0; 932 unsigned int bytes_read = 0;
960 933
@@ -985,8 +958,8 @@ unsigned long read_mp4_tag(int fd, unsigned int size_left, char* buffer,
985} 958}
986 959
987/* Read a string tag from an MP4 file */ 960/* Read a string tag from an MP4 file */
988unsigned int read_mp4_tag_string(int fd, int size_left, char** buffer, 961static unsigned int read_mp4_tag_string(int fd, int size_left, char** buffer,
989 unsigned int* buffer_left, char** dest) 962 unsigned int* buffer_left, char** dest)
990{ 963{
991 unsigned int bytes_read = read_mp4_tag(fd, size_left, *buffer, 964 unsigned int bytes_read = read_mp4_tag(fd, size_left, *buffer,
992 *buffer_left - 1); 965 *buffer_left - 1);
@@ -1009,7 +982,7 @@ unsigned int read_mp4_tag_string(int fd, int size_left, char** buffer,
1009} 982}
1010 983
1011static unsigned int read_mp4_atom(int fd, unsigned int* size, 984static unsigned int read_mp4_atom(int fd, unsigned int* size,
1012 unsigned int* type, unsigned int size_left) 985 unsigned int* type, unsigned int size_left)
1013{ 986{
1014 read_uint32be(fd, size); 987 read_uint32be(fd, size);
1015 read_uint32be(fd, type); 988 read_uint32be(fd, type);
@@ -1177,7 +1150,7 @@ static bool read_mp4_esds(int fd, struct mp3entry* id3,
1177} 1150}
1178 1151
1179static bool read_mp4_tags(int fd, struct mp3entry* id3, 1152static bool read_mp4_tags(int fd, struct mp3entry* id3,
1180 unsigned int size_left) 1153 unsigned int size_left)
1181{ 1154{
1182 unsigned int size; 1155 unsigned int size;
1183 unsigned int type; 1156 unsigned int type;
@@ -1300,7 +1273,7 @@ static bool read_mp4_tags(int fd, struct mp3entry* id3,
1300} 1273}
1301 1274
1302static bool read_mp4_container(int fd, struct mp3entry* id3, 1275static bool read_mp4_container(int fd, struct mp3entry* id3,
1303 unsigned int size_left) 1276 unsigned int size_left)
1304{ 1277{
1305 unsigned int size; 1278 unsigned int size;
1306 unsigned int type; 1279 unsigned int type;
@@ -1858,7 +1831,7 @@ unsigned int probe_file_format(const char *filename)
1858 * file that would prevent playback. 1831 * file that would prevent playback.
1859 */ 1832 */
1860bool get_metadata(struct track_info* track, int fd, const char* trackname, 1833bool get_metadata(struct track_info* track, int fd, const char* trackname,
1861 bool v1first) 1834 bool v1first)
1862{ 1835{
1863#if CONFIG_CODEC == SWCODEC 1836#if CONFIG_CODEC == SWCODEC
1864 unsigned char* buf; 1837 unsigned char* buf;