diff options
-rw-r--r-- | apps/metadata/ape.c | 6 | ||||
-rw-r--r-- | apps/metadata/asap.c | 41 | ||||
-rw-r--r-- | apps/metadata/asf.c | 14 | ||||
-rw-r--r-- | apps/metadata/metadata_common.h | 2 | ||||
-rw-r--r-- | apps/metadata/mp4.c | 76 | ||||
-rw-r--r-- | apps/metadata/mpc.c | 2 | ||||
-rw-r--r-- | apps/metadata/rm.c | 11 | ||||
-rw-r--r-- | apps/metadata/sid.c | 2 |
8 files changed, 79 insertions, 75 deletions
diff --git a/apps/metadata/ape.c b/apps/metadata/ape.c index dcb359799c..44fc69a45a 100644 --- a/apps/metadata/ape.c +++ b/apps/metadata/ape.c | |||
@@ -59,7 +59,8 @@ bool read_ape_tags(int fd, struct mp3entry* id3) | |||
59 | struct apetag_header header; | 59 | struct apetag_header header; |
60 | 60 | ||
61 | if ((lseek(fd, -APETAG_HEADER_LENGTH, SEEK_END) < 0) | 61 | if ((lseek(fd, -APETAG_HEADER_LENGTH, SEEK_END) < 0) |
62 | || (ecread(fd, &header, 1, APETAG_HEADER_FORMAT, IS_BIG_ENDIAN) != APETAG_HEADER_LENGTH) | 62 | || (ecread(fd, &header, 1, APETAG_HEADER_FORMAT, IS_BIG_ENDIAN) |
63 | != APETAG_HEADER_LENGTH) | ||
63 | || (memcmp(header.id, "APETAGEX", sizeof(header.id)))) | 64 | || (memcmp(header.id, "APETAGEX", sizeof(header.id)))) |
64 | { | 65 | { |
65 | return false; | 66 | return false; |
@@ -91,7 +92,8 @@ bool read_ape_tags(int fd, struct mp3entry* id3) | |||
91 | break; | 92 | break; |
92 | } | 93 | } |
93 | 94 | ||
94 | if (ecread(fd, &item, 1, APETAG_ITEM_HEADER_FORMAT, IS_BIG_ENDIAN) < (long) sizeof(item)) | 95 | if (ecread(fd, &item, 1, APETAG_ITEM_HEADER_FORMAT, IS_BIG_ENDIAN) |
96 | < (long) sizeof(item)) | ||
95 | { | 97 | { |
96 | return false; | 98 | return false; |
97 | } | 99 | } |
diff --git a/apps/metadata/asap.c b/apps/metadata/asap.c index 128a18d642..ea9b201bff 100644 --- a/apps/metadata/asap.c +++ b/apps/metadata/asap.c | |||
@@ -104,9 +104,10 @@ static int ASAP_ParseDuration(const char *s) | |||
104 | return r; | 104 | return r; |
105 | } | 105 | } |
106 | 106 | ||
107 | static bool read_asap_string(char* source,char** buf,char** buffer_end,char** dest) | 107 | static bool read_asap_string(char* source, char** buf, char** buffer_end, char** dest) |
108 | { | 108 | { |
109 | if(parse_text(*buf,source) == false) return false; | 109 | if(parse_text(*buf,source) == false) |
110 | return false; | ||
110 | 111 | ||
111 | /* set dest pointer */ | 112 | /* set dest pointer */ |
112 | *dest = *buf; | 113 | *dest = *buf; |
@@ -123,7 +124,7 @@ static bool read_asap_string(char* source,char** buf,char** buffer_end,char** de | |||
123 | return true; | 124 | return true; |
124 | } | 125 | } |
125 | 126 | ||
126 | static bool parse_sap_header(int fd,struct mp3entry* id3,int file_len) | 127 | static bool parse_sap_header(int fd, struct mp3entry* id3, int file_len) |
127 | { | 128 | { |
128 | int module_index = 0; | 129 | int module_index = 0; |
129 | int sap_signature = -1; | 130 | int sap_signature = -1; |
@@ -132,9 +133,9 @@ static bool parse_sap_header(int fd,struct mp3entry* id3,int file_len) | |||
132 | int i; | 133 | int i; |
133 | 134 | ||
134 | /* set defaults */ | 135 | /* set defaults */ |
135 | int numSongs=1; | 136 | int numSongs = 1; |
136 | int defSong=0; | 137 | int defSong = 0; |
137 | int numChannels=1; | 138 | int numChannels = 1; |
138 | int durations[MAX_SONGS]; | 139 | int durations[MAX_SONGS]; |
139 | int loops[MAX_SONGS]; | 140 | int loops[MAX_SONGS]; |
140 | for (i = 0; i < MAX_SONGS; i++) { | 141 | for (i = 0; i < MAX_SONGS; i++) { |
@@ -190,36 +191,36 @@ static bool parse_sap_header(int fd,struct mp3entry* id3,int file_len) | |||
190 | sap_signature = 1; | 191 | sap_signature = 1; |
191 | if (sap_signature == -1) | 192 | if (sap_signature == -1) |
192 | return false; | 193 | return false; |
193 | if (strcmp(line,"AUTHOR") == 0) | 194 | if (strcmp(line, "AUTHOR") == 0) |
194 | { | 195 | { |
195 | if(read_asap_string(p,&buffer,&buffer_end,&id3->artist) == false) | 196 | if(read_asap_string(p, &buffer, &buffer_end, &id3->artist) == false) |
196 | return false; | 197 | return false; |
197 | } | 198 | } |
198 | else if(strcmp(line,"NAME")==0) | 199 | else if(strcmp(line, "NAME") == 0) |
199 | { | 200 | { |
200 | if(read_asap_string(p,&buffer,&buffer_end,&id3->title) == false) | 201 | if(read_asap_string(p, &buffer, &buffer_end, &id3->title) == false) |
201 | return false; | 202 | return false; |
202 | } | 203 | } |
203 | else if(strcmp(line,"DATE")==0) | 204 | else if(strcmp(line, "DATE") == 0) |
204 | { | 205 | { |
205 | if(read_asap_string(p,&buffer,&buffer_end,&id3->year_string) == false) | 206 | if(read_asap_string(p, &buffer, &buffer_end, &id3->year_string) == false) |
206 | return false; | 207 | return false; |
207 | } | 208 | } |
208 | else if (strcmp(line,"SONGS")==0) | 209 | else if (strcmp(line, "SONGS") == 0) |
209 | { | 210 | { |
210 | if (parse_dec(&numSongs, p,1,MAX_SONGS) == false ) | 211 | if (parse_dec(&numSongs, p, 1, MAX_SONGS) == false ) |
211 | return false; | 212 | return false; |
212 | } | 213 | } |
213 | else if (strcmp(line,"DEFSONG")==0) | 214 | else if (strcmp(line, "DEFSONG") == 0) |
214 | { | 215 | { |
215 | if (parse_dec(&defSong, p,0,MAX_SONGS) == false) | 216 | if (parse_dec(&defSong, p, 0, MAX_SONGS) == false) |
216 | return false; | 217 | return false; |
217 | } | 218 | } |
218 | else if (strcmp(line,"STEREO")==0) | 219 | else if (strcmp(line, "STEREO") == 0) |
219 | { | 220 | { |
220 | numChannels = 2; | 221 | numChannels = 2; |
221 | } | 222 | } |
222 | else if (strcmp(line,"TIME") == 0) | 223 | else if (strcmp(line, "TIME") == 0) |
223 | { | 224 | { |
224 | int durationTemp = ASAP_ParseDuration(p); | 225 | int durationTemp = ASAP_ParseDuration(p); |
225 | if (durationTemp < 0 || duration_index >= MAX_SONGS) | 226 | if (durationTemp < 0 || duration_index >= MAX_SONGS) |
@@ -237,7 +238,7 @@ static bool parse_sap_header(int fd,struct mp3entry* id3,int file_len) | |||
237 | length = 180 * 1000; | 238 | length = 180 * 1000; |
238 | id3->length = length; | 239 | id3->length = length; |
239 | 240 | ||
240 | lseek(fd,0,SEEK_SET); | 241 | lseek(fd, 0, SEEK_SET); |
241 | return true; | 242 | return true; |
242 | } | 243 | } |
243 | 244 | ||
@@ -247,7 +248,7 @@ bool get_asap_metadata(int fd, struct mp3entry* id3) | |||
247 | 248 | ||
248 | int filelength = filesize(fd); | 249 | int filelength = filesize(fd); |
249 | 250 | ||
250 | if(parse_sap_header(fd,id3,filelength) == false) | 251 | if(parse_sap_header(fd, id3, filelength) == false) |
251 | { | 252 | { |
252 | DEBUGF("parse sap header failed.\n"); | 253 | DEBUGF("parse sap header failed.\n"); |
253 | return false; | 254 | return false; |
diff --git a/apps/metadata/asf.c b/apps/metadata/asf.c index 611cc2aca3..9362485eb7 100644 --- a/apps/metadata/asf.c +++ b/apps/metadata/asf.c | |||
@@ -140,11 +140,11 @@ static int asf_intdecode(int fd, int type, int length) | |||
140 | uint32_t tmp32; | 140 | uint32_t tmp32; |
141 | uint64_t tmp64; | 141 | uint64_t tmp64; |
142 | 142 | ||
143 | if (type==3) { | 143 | if (type == 3) { |
144 | read_uint32le(fd, &tmp32); | 144 | read_uint32le(fd, &tmp32); |
145 | lseek(fd,length - 4,SEEK_CUR); | 145 | lseek(fd,length - 4,SEEK_CUR); |
146 | return (int)tmp32; | 146 | return (int)tmp32; |
147 | } else if (type==4) { | 147 | } else if (type == 4) { |
148 | read_uint64le(fd, &tmp64); | 148 | read_uint64le(fd, &tmp64); |
149 | lseek(fd,length - 8,SEEK_CUR); | 149 | lseek(fd,length - 8,SEEK_CUR); |
150 | return (int)tmp64; | 150 | return (int)tmp64; |
@@ -430,19 +430,19 @@ static int asf_parse_header(int fd, struct mp3entry* id3, | |||
430 | } else { | 430 | } else { |
431 | lseek(fd, length, SEEK_CUR); | 431 | lseek(fd, length, SEEK_CUR); |
432 | } | 432 | } |
433 | } else if ((!strcmp("WM/Genre",utf8buf)) && (type == 0)) { | 433 | } else if ((!strcmp("WM/Genre", utf8buf)) && (type == 0)) { |
434 | id3->genre_string = id3buf; | 434 | id3->genre_string = id3buf; |
435 | asf_utf16LEdecode(fd, length, &id3buf, &id3buf_remaining); | 435 | asf_utf16LEdecode(fd, length, &id3buf, &id3buf_remaining); |
436 | } else if ((!strcmp("WM/AlbumTitle",utf8buf)) && (type == 0)) { | 436 | } else if ((!strcmp("WM/AlbumTitle", utf8buf)) && (type == 0)) { |
437 | id3->album = id3buf; | 437 | id3->album = id3buf; |
438 | asf_utf16LEdecode(fd, length, &id3buf, &id3buf_remaining); | 438 | asf_utf16LEdecode(fd, length, &id3buf, &id3buf_remaining); |
439 | } else if ((!strcmp("WM/AlbumArtist",utf8buf)) && (type == 0)) { | 439 | } else if ((!strcmp("WM/AlbumArtist", utf8buf)) && (type == 0)) { |
440 | id3->albumartist = id3buf; | 440 | id3->albumartist = id3buf; |
441 | asf_utf16LEdecode(fd, length, &id3buf, &id3buf_remaining); | 441 | asf_utf16LEdecode(fd, length, &id3buf, &id3buf_remaining); |
442 | } else if ((!strcmp("WM/Composer",utf8buf)) && (type == 0)) { | 442 | } else if ((!strcmp("WM/Composer", utf8buf)) && (type == 0)) { |
443 | id3->composer = id3buf; | 443 | id3->composer = id3buf; |
444 | asf_utf16LEdecode(fd, length, &id3buf, &id3buf_remaining); | 444 | asf_utf16LEdecode(fd, length, &id3buf, &id3buf_remaining); |
445 | } else if (!strcmp("WM/Year",utf8buf)) { | 445 | } else if (!strcmp("WM/Year", utf8buf)) { |
446 | if (type == 0) { | 446 | if (type == 0) { |
447 | id3->year_string = id3buf; | 447 | id3->year_string = id3buf; |
448 | asf_utf16LEdecode(fd, length, &id3buf, &id3buf_remaining); | 448 | asf_utf16LEdecode(fd, length, &id3buf, &id3buf_remaining); |
diff --git a/apps/metadata/metadata_common.h b/apps/metadata/metadata_common.h index f7539950e1..c7d7d67dfb 100644 --- a/apps/metadata/metadata_common.h +++ b/apps/metadata/metadata_common.h | |||
@@ -29,6 +29,8 @@ | |||
29 | #define TAG_NAME_LENGTH 32 | 29 | #define TAG_NAME_LENGTH 32 |
30 | #define TAG_VALUE_LENGTH 128 | 30 | #define TAG_VALUE_LENGTH 128 |
31 | 31 | ||
32 | #define FOURCC(a,b,c,d) (((a)<<24) | ((b) << 16) | ((c) << 8) | (d)) | ||
33 | |||
32 | enum tagtype { TAGTYPE_APE = 1, TAGTYPE_VORBIS }; | 34 | enum tagtype { TAGTYPE_APE = 1, TAGTYPE_VORBIS }; |
33 | 35 | ||
34 | bool read_ape_tags(int fd, struct mp3entry* id3); | 36 | bool read_ape_tags(int fd, struct mp3entry* id3); |
diff --git a/apps/metadata/mp4.c b/apps/metadata/mp4.c index a520597972..410bb79b81 100644 --- a/apps/metadata/mp4.c +++ b/apps/metadata/mp4.c | |||
@@ -33,45 +33,43 @@ | |||
33 | #include "debug.h" | 33 | #include "debug.h" |
34 | #include "replaygain.h" | 34 | #include "replaygain.h" |
35 | 35 | ||
36 | #define MP4_ID(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d)) | 36 | #define MP4_3gp6 FOURCC('3', 'g', 'p', '6') |
37 | 37 | #define MP4_aART FOURCC('a', 'A', 'R', 'T') | |
38 | #define MP4_3gp6 MP4_ID('3', 'g', 'p', '6') | 38 | #define MP4_alac FOURCC('a', 'l', 'a', 'c') |
39 | #define MP4_aART MP4_ID('a', 'A', 'R', 'T') | 39 | #define MP4_calb FOURCC(0xa9, 'a', 'l', 'b') |
40 | #define MP4_alac MP4_ID('a', 'l', 'a', 'c') | 40 | #define MP4_cART FOURCC(0xa9, 'A', 'R', 'T') |
41 | #define MP4_calb MP4_ID(0xa9, 'a', 'l', 'b') | 41 | #define MP4_cgrp FOURCC(0xa9, 'g', 'r', 'p') |
42 | #define MP4_cART MP4_ID(0xa9, 'A', 'R', 'T') | 42 | #define MP4_cgen FOURCC(0xa9, 'g', 'e', 'n') |
43 | #define MP4_cgrp MP4_ID(0xa9, 'g', 'r', 'p') | 43 | #define MP4_chpl FOURCC('c', 'h', 'p', 'l') |
44 | #define MP4_cgen MP4_ID(0xa9, 'g', 'e', 'n') | 44 | #define MP4_cnam FOURCC(0xa9, 'n', 'a', 'm') |
45 | #define MP4_chpl MP4_ID('c', 'h', 'p', 'l') | 45 | #define MP4_cwrt FOURCC(0xa9, 'w', 'r', 't') |
46 | #define MP4_cnam MP4_ID(0xa9, 'n', 'a', 'm') | 46 | #define MP4_ccmt FOURCC(0xa9, 'c', 'm', 't') |
47 | #define MP4_cwrt MP4_ID(0xa9, 'w', 'r', 't') | 47 | #define MP4_cday FOURCC(0xa9, 'd', 'a', 'y') |
48 | #define MP4_ccmt MP4_ID(0xa9, 'c', 'm', 't') | 48 | #define MP4_disk FOURCC('d', 'i', 's', 'k') |
49 | #define MP4_cday MP4_ID(0xa9, 'd', 'a', 'y') | 49 | #define MP4_esds FOURCC('e', 's', 'd', 's') |
50 | #define MP4_disk MP4_ID('d', 'i', 's', 'k') | 50 | #define MP4_ftyp FOURCC('f', 't', 'y', 'p') |
51 | #define MP4_esds MP4_ID('e', 's', 'd', 's') | 51 | #define MP4_gnre FOURCC('g', 'n', 'r', 'e') |
52 | #define MP4_ftyp MP4_ID('f', 't', 'y', 'p') | 52 | #define MP4_hdlr FOURCC('h', 'd', 'l', 'r') |
53 | #define MP4_gnre MP4_ID('g', 'n', 'r', 'e') | 53 | #define MP4_ilst FOURCC('i', 'l', 's', 't') |
54 | #define MP4_hdlr MP4_ID('h', 'd', 'l', 'r') | 54 | #define MP4_M4A FOURCC('M', '4', 'A', ' ') |
55 | #define MP4_ilst MP4_ID('i', 'l', 's', 't') | 55 | #define MP4_M4B FOURCC('M', '4', 'B', ' ') |
56 | #define MP4_M4A MP4_ID('M', '4', 'A', ' ') | 56 | #define MP4_mdat FOURCC('m', 'd', 'a', 't') |
57 | #define MP4_M4B MP4_ID('M', '4', 'B', ' ') | 57 | #define MP4_mdia FOURCC('m', 'd', 'i', 'a') |
58 | #define MP4_mdat MP4_ID('m', 'd', 'a', 't') | 58 | #define MP4_mdir FOURCC('m', 'd', 'i', 'r') |
59 | #define MP4_mdia MP4_ID('m', 'd', 'i', 'a') | 59 | #define MP4_meta FOURCC('m', 'e', 't', 'a') |
60 | #define MP4_mdir MP4_ID('m', 'd', 'i', 'r') | 60 | #define MP4_minf FOURCC('m', 'i', 'n', 'f') |
61 | #define MP4_meta MP4_ID('m', 'e', 't', 'a') | 61 | #define MP4_moov FOURCC('m', 'o', 'o', 'v') |
62 | #define MP4_minf MP4_ID('m', 'i', 'n', 'f') | 62 | #define MP4_mp4a FOURCC('m', 'p', '4', 'a') |
63 | #define MP4_moov MP4_ID('m', 'o', 'o', 'v') | 63 | #define MP4_mp42 FOURCC('m', 'p', '4', '2') |
64 | #define MP4_mp4a MP4_ID('m', 'p', '4', 'a') | 64 | #define MP4_qt FOURCC('q', 't', ' ', ' ') |
65 | #define MP4_mp42 MP4_ID('m', 'p', '4', '2') | 65 | #define MP4_soun FOURCC('s', 'o', 'u', 'n') |
66 | #define MP4_qt MP4_ID('q', 't', ' ', ' ') | 66 | #define MP4_stbl FOURCC('s', 't', 'b', 'l') |
67 | #define MP4_soun MP4_ID('s', 'o', 'u', 'n') | 67 | #define MP4_stsd FOURCC('s', 't', 's', 'd') |
68 | #define MP4_stbl MP4_ID('s', 't', 'b', 'l') | 68 | #define MP4_stts FOURCC('s', 't', 't', 's') |
69 | #define MP4_stsd MP4_ID('s', 't', 's', 'd') | 69 | #define MP4_trak FOURCC('t', 'r', 'a', 'k') |
70 | #define MP4_stts MP4_ID('s', 't', 't', 's') | 70 | #define MP4_trkn FOURCC('t', 'r', 'k', 'n') |
71 | #define MP4_trak MP4_ID('t', 'r', 'a', 'k') | 71 | #define MP4_udta FOURCC('u', 'd', 't', 'a') |
72 | #define MP4_trkn MP4_ID('t', 'r', 'k', 'n') | 72 | #define MP4_extra FOURCC('-', '-', '-', '-') |
73 | #define MP4_udta MP4_ID('u', 'd', 't', 'a') | ||
74 | #define MP4_extra MP4_ID('-', '-', '-', '-') | ||
75 | 73 | ||
76 | /* Read the tag data from an MP4 file, storing up to buffer_size bytes in | 74 | /* Read the tag data from an MP4 file, storing up to buffer_size bytes in |
77 | * buffer. | 75 | * buffer. |
diff --git a/apps/metadata/mpc.c b/apps/metadata/mpc.c index 5ab1241153..e20ac3e8a2 100644 --- a/apps/metadata/mpc.c +++ b/apps/metadata/mpc.c | |||
@@ -50,7 +50,7 @@ static int set_replaygain(struct mp3entry* id3, bool album, long value, | |||
50 | 50 | ||
51 | bool get_musepack_metadata(int fd, struct mp3entry *id3) | 51 | bool get_musepack_metadata(int fd, struct mp3entry *id3) |
52 | { | 52 | { |
53 | const int32_t sfreqs_sv7[4] = { 44100, 48000, 37800, 32000 }; | 53 | static const int32_t sfreqs_sv7[4] = { 44100, 48000, 37800, 32000 }; |
54 | uint32_t header[8]; | 54 | uint32_t header[8]; |
55 | uint64_t samples = 0; | 55 | uint64_t samples = 0; |
56 | int i; | 56 | int i; |
diff --git a/apps/metadata/rm.c b/apps/metadata/rm.c index e4b5005f2d..4b52c34d02 100644 --- a/apps/metadata/rm.c +++ b/apps/metadata/rm.c | |||
@@ -60,15 +60,16 @@ struct real_object_t | |||
60 | uint16_t version; | 60 | uint16_t version; |
61 | }; | 61 | }; |
62 | 62 | ||
63 | #define FOURCC(a,b,c,d) (((a)<<24) | ((b) << 16) | ((c) << 8) | (d)) | ||
64 | |||
65 | static int real_read_object_header(int fd, struct real_object_t* obj) | 63 | static int real_read_object_header(int fd, struct real_object_t* obj) |
66 | { | 64 | { |
67 | int n; | 65 | int n; |
68 | 66 | ||
69 | if ((n = read_uint32be(fd, &obj->fourcc)) <= 0) return n; | 67 | if ((n = read_uint32be(fd, &obj->fourcc)) <= 0) |
70 | if ((n = read_uint32be(fd, &obj->size)) <= 0) return n; | 68 | return n; |
71 | if ((n = read_uint16be(fd, &obj->version)) <= 0) return n; | 69 | if ((n = read_uint32be(fd, &obj->size)) <= 0) |
70 | return n; | ||
71 | if ((n = read_uint16be(fd, &obj->version)) <= 0) | ||
72 | return n; | ||
72 | 73 | ||
73 | return 1; | 74 | return 1; |
74 | } | 75 | } |
diff --git a/apps/metadata/sid.c b/apps/metadata/sid.c index bab7233752..d4e6627778 100644 --- a/apps/metadata/sid.c +++ b/apps/metadata/sid.c | |||
@@ -46,7 +46,7 @@ bool get_sid_metadata(int fd, struct mp3entry* id3) | |||
46 | return false; | 46 | return false; |
47 | } | 47 | } |
48 | 48 | ||
49 | if ((memcmp(buf, "PSID",4) != 0)) | 49 | if ((memcmp(buf, "PSID", 4) != 0)) |
50 | { | 50 | { |
51 | return false; | 51 | return false; |
52 | } | 52 | } |