diff options
Diffstat (limited to 'apps/metadata.c')
-rw-r--r-- | apps/metadata.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/apps/metadata.c b/apps/metadata.c index 357c5e649e..a0c2f31eee 100644 --- a/apps/metadata.c +++ b/apps/metadata.c | |||
@@ -206,6 +206,43 @@ static long get_slong(void* buf) | |||
206 | 206 | ||
207 | return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); | 207 | return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); |
208 | } | 208 | } |
209 | |||
210 | static char* skip_space(char* str) | ||
211 | { | ||
212 | while (isspace(*str)) | ||
213 | { | ||
214 | str++; | ||
215 | } | ||
216 | |||
217 | return str; | ||
218 | } | ||
219 | |||
220 | static unsigned long get_itunes_int32(char* value, int count) | ||
221 | { | ||
222 | static const char hexdigits[] = "0123456789ABCDEF"; | ||
223 | const char* c; | ||
224 | int r = 0; | ||
225 | |||
226 | while (count-- > 0) | ||
227 | { | ||
228 | value = skip_space(value); | ||
229 | |||
230 | while (*value && !isspace(*value)) | ||
231 | { | ||
232 | value++; | ||
233 | } | ||
234 | } | ||
235 | |||
236 | value = skip_space(value); | ||
237 | |||
238 | while (*value && ((c = strchr(hexdigits, toupper(*value))) != NULL)) | ||
239 | { | ||
240 | r = (r << 4) | (c - hexdigits); | ||
241 | value++; | ||
242 | } | ||
243 | |||
244 | return r; | ||
245 | } | ||
209 | 246 | ||
210 | /* Parse the tag (the name-value pair) and fill id3 and buffer accordingly. | 247 | /* Parse the tag (the name-value pair) and fill id3 and buffer accordingly. |
211 | * String values to keep are written to buf. Returns number of bytes written | 248 | * String values to keep are written to buf. Returns number of bytes written |
@@ -1520,6 +1557,19 @@ static bool read_mp4_tags(int fd, struct mp3entry* id3, | |||
1520 | { | 1557 | { |
1521 | read_mp4_tag_string(fd, size, &buffer, &buffer_left, | 1558 | read_mp4_tag_string(fd, size, &buffer, &buffer_left, |
1522 | &id3->composer); | 1559 | &id3->composer); |
1560 | } | ||
1561 | else if (strcasecmp(tag_name, "iTunSMPB") == 0) | ||
1562 | { | ||
1563 | char value[TAG_VALUE_LENGTH]; | ||
1564 | char* value_p = value; | ||
1565 | char* any; | ||
1566 | unsigned int length = sizeof(value); | ||
1567 | |||
1568 | read_mp4_tag_string(fd, size, &value_p, &length, &any); | ||
1569 | id3->lead_trim = get_itunes_int32(value, 1); | ||
1570 | id3->tail_trim = get_itunes_int32(value, 2); | ||
1571 | DEBUGF("AAC: lead_trim %d, tail_trim %d\n", | ||
1572 | id3->lead_trim, id3->tail_trim); | ||
1523 | } | 1573 | } |
1524 | else | 1574 | else |
1525 | { | 1575 | { |