diff options
Diffstat (limited to 'apps/metadata')
-rw-r--r-- | apps/metadata/id3tags.c | 12 | ||||
-rw-r--r-- | apps/metadata/metadata_common.c | 5 | ||||
-rw-r--r-- | apps/metadata/mp4.c | 31 |
3 files changed, 26 insertions, 22 deletions
diff --git a/apps/metadata/id3tags.c b/apps/metadata/id3tags.c index 9ee183a1b3..9143f8ad25 100644 --- a/apps/metadata/id3tags.c +++ b/apps/metadata/id3tags.c | |||
@@ -358,8 +358,7 @@ static int parseuser( struct mp3entry* entry, char* tag, int bufferpos ) | |||
358 | 358 | ||
359 | if ((tag - entry->id3v2buf + desc_len + 2) < bufferpos) { | 359 | if ((tag - entry->id3v2buf + desc_len + 2) < bufferpos) { |
360 | /* At least part of the value was read, so we can safely try to | 360 | /* At least part of the value was read, so we can safely try to |
361 | * parse it | 361 | * parse it */ |
362 | */ | ||
363 | value = tag + desc_len + 1; | 362 | value = tag + desc_len + 1; |
364 | value_len = bufferpos - (tag - entry->id3v2buf); | 363 | value_len = bufferpos - (tag - entry->id3v2buf); |
365 | 364 | ||
@@ -368,8 +367,7 @@ static int parseuser( struct mp3entry* entry, char* tag, int bufferpos ) | |||
368 | entry->albumartist = tag; | 367 | entry->albumartist = tag; |
369 | #if CONFIG_CODEC == SWCODEC | 368 | #if CONFIG_CODEC == SWCODEC |
370 | } else { | 369 | } else { |
371 | value_len = parse_replaygain(tag, value, entry, tag, | 370 | value_len = parse_replaygain(tag, value, entry, tag, value_len); |
372 | value_len); | ||
373 | #endif | 371 | #endif |
374 | } | 372 | } |
375 | } | 373 | } |
@@ -1040,6 +1038,12 @@ void setid3v2title(int fd, struct mp3entry *entry) | |||
1040 | #endif | 1038 | #endif |
1041 | if( tr->ppFunc ) | 1039 | if( tr->ppFunc ) |
1042 | bufferpos = tr->ppFunc(entry, tag, bufferpos); | 1040 | bufferpos = tr->ppFunc(entry, tag, bufferpos); |
1041 | |||
1042 | /* Trim. Take into account that multiple string contents will | ||
1043 | * only be displayed up to their first null termination. All | ||
1044 | * content after this null termination is obsolete and can be | ||
1045 | * overwritten. */ | ||
1046 | bufferpos -= (bytesread - strlen(tag)); | ||
1043 | 1047 | ||
1044 | /* Seek to the next frame */ | 1048 | /* Seek to the next frame */ |
1045 | if(framelen < totframelen) | 1049 | if(framelen < totframelen) |
diff --git a/apps/metadata/metadata_common.c b/apps/metadata/metadata_common.c index e1ef9a0d62..4f001775f3 100644 --- a/apps/metadata/metadata_common.c +++ b/apps/metadata/metadata_common.c | |||
@@ -337,7 +337,10 @@ long parse_tag(const char* name, char* value, struct mp3entry* id3, | |||
337 | p = NULL; | 337 | p = NULL; |
338 | } | 338 | } |
339 | 339 | ||
340 | if (p) | 340 | /* Do not overwrite already available metadata. Especially when reading |
341 | * tags with e.g. multiple genres / artists. This way only the first | ||
342 | * of multiple entries is used, all following are dropped. */ | ||
343 | if (p!=NULL && *p==NULL) | ||
341 | { | 344 | { |
342 | len = strlen(value); | 345 | len = strlen(value); |
343 | len = MIN(len, buf_remaining - 1); | 346 | len = MIN(len, buf_remaining - 1); |
diff --git a/apps/metadata/mp4.c b/apps/metadata/mp4.c index 1ef3701e30..26ab7cc30a 100644 --- a/apps/metadata/mp4.c +++ b/apps/metadata/mp4.c | |||
@@ -73,9 +73,6 @@ | |||
73 | #define MP4_udta FOURCC('u', 'd', 't', 'a') | 73 | #define MP4_udta FOURCC('u', 'd', 't', 'a') |
74 | #define MP4_extra FOURCC('-', '-', '-', '-') | 74 | #define MP4_extra FOURCC('-', '-', '-', '-') |
75 | 75 | ||
76 | /* Used to correct id3->samples, if SBR upsampling was detected in esds atom. */ | ||
77 | static bool SBR_upsampling_used = false; | ||
78 | |||
79 | /* Read the tag data from an MP4 file, storing up to buffer_size bytes in | 76 | /* Read the tag data from an MP4 file, storing up to buffer_size bytes in |
80 | * buffer. | 77 | * buffer. |
81 | */ | 78 | */ |
@@ -120,11 +117,17 @@ static unsigned int read_mp4_tag_string(int fd, int size_left, char** buffer, | |||
120 | 117 | ||
121 | if (bytes_read) | 118 | if (bytes_read) |
122 | { | 119 | { |
123 | (*buffer)[bytes_read] = 0; | 120 | /* Do not overwrite already available metadata. Especially when reading |
124 | *dest = *buffer; | 121 | * tags with e.g. multiple genres / artists. This way only the first |
125 | length = strlen(*buffer) + 1; | 122 | * of multiple entries is used, all following are dropped. */ |
126 | *buffer_left -= length; | 123 | if (*dest == NULL) |
127 | *buffer += length; | 124 | { |
125 | (*buffer)[bytes_read] = 0; | ||
126 | *dest = *buffer; | ||
127 | length = strlen(*buffer) + 1; | ||
128 | *buffer_left -= length; | ||
129 | *buffer += length; | ||
130 | } | ||
128 | } | 131 | } |
129 | else | 132 | else |
130 | { | 133 | { |
@@ -343,11 +346,6 @@ static bool read_mp4_esds(int fd, struct mp3entry* id3, uint32_t* size) | |||
343 | * decoding (parts of) the file. | 346 | * decoding (parts of) the file. |
344 | */ | 347 | */ |
345 | id3->frequency *= 2; | 348 | id3->frequency *= 2; |
346 | |||
347 | /* Set this to true to be able to calculate the correct runtime | ||
348 | * and bitrate. */ | ||
349 | SBR_upsampling_used = true; | ||
350 | |||
351 | sbr = true; | 349 | sbr = true; |
352 | } | 350 | } |
353 | } | 351 | } |
@@ -640,7 +638,7 @@ static bool read_mp4_container(int fd, struct mp3entry* id3, | |||
640 | unsigned int i; | 638 | unsigned int i; |
641 | 639 | ||
642 | /* Reset to false. */ | 640 | /* Reset to false. */ |
643 | id3->needs_upsampling_correction = true; | 641 | id3->needs_upsampling_correction = false; |
644 | 642 | ||
645 | lseek(fd, 4, SEEK_CUR); | 643 | lseek(fd, 4, SEEK_CUR); |
646 | read_uint32be(fd, &entries); | 644 | read_uint32be(fd, &entries); |
@@ -654,12 +652,12 @@ static bool read_mp4_container(int fd, struct mp3entry* id3, | |||
654 | read_uint32be(fd, &n); | 652 | read_uint32be(fd, &n); |
655 | read_uint32be(fd, &l); | 653 | read_uint32be(fd, &l); |
656 | 654 | ||
657 | /* Some SBR files use upsampling. In this case the number | 655 | /* Some AAC file use HE profile. In this case the number |
658 | * of output samples is doubled to a maximum of 2048 | 656 | * of output samples is doubled to a maximum of 2048 |
659 | * samples per frame. This means that files which already | 657 | * samples per frame. This means that files which already |
660 | * report a frame size of 2048 in their header will not | 658 | * report a frame size of 2048 in their header will not |
661 | * need any further special handling. */ | 659 | * need any further special handling. */ |
662 | if (SBR_upsampling_used && l<=1024) | 660 | if (id3->codectype==AFMT_MP4_AAC_HE && l<=1024) |
663 | { | 661 | { |
664 | id3->samples += n * l * 2; | 662 | id3->samples += n * l * 2; |
665 | id3->needs_upsampling_correction = true; | 663 | id3->needs_upsampling_correction = true; |
@@ -774,7 +772,6 @@ static bool read_mp4_container(int fd, struct mp3entry* id3, | |||
774 | 772 | ||
775 | bool get_mp4_metadata(int fd, struct mp3entry* id3) | 773 | bool get_mp4_metadata(int fd, struct mp3entry* id3) |
776 | { | 774 | { |
777 | SBR_upsampling_used = false; | ||
778 | id3->codectype = AFMT_UNKNOWN; | 775 | id3->codectype = AFMT_UNKNOWN; |
779 | id3->filesize = 0; | 776 | id3->filesize = 0; |
780 | errno = 0; | 777 | errno = 0; |