summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2010-03-08 22:39:15 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2010-03-08 22:39:15 +0000
commit56023837ae7d49dcd3fdd32295ddf62fb89e6cbe (patch)
tree9f0ed4c6089fce85126c31d88e535bdd72331806
parent1abda91faa7efa110628b7513f777b78c9a5c8f3 (diff)
downloadrockbox-56023837ae7d49dcd3fdd32295ddf62fb89e6cbe.tar.gz
rockbox-56023837ae7d49dcd3fdd32295ddf62fb89e6cbe.zip
Fix musepack sv8 metadata parser. Thanks to Magnus Holmgren for spotting.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25076 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/metadata/mpc.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/apps/metadata/mpc.c b/apps/metadata/mpc.c
index 8db7993364..a8cd128828 100644
--- a/apps/metadata/mpc.c
+++ b/apps/metadata/mpc.c
@@ -132,14 +132,18 @@ bool get_musepack_metadata(int fd, struct mp3entry *id3)
if (!memcmp(sv8_header, "SH", 2)) { /* Stream Header ID */
int32_t k = 0;
uint32_t streamversion;
- uint64_t size = 0;
+ uint64_t size = 0; /* tag size */
+ uint64_t dummy = 0; /* used to dummy read data from header */
- /* 4 bytes 'MPCK' + 4 bytes crc + 2 'SH' */
- lseek(fd, 10, SEEK_SET);
+ /* 4 bytes 'MPCK' + 2 'SH' */
+ lseek(fd, 6, SEEK_SET);
if (read(fd, sv8_header, 32) != 32) return false;
-
- /* dummy read the correct amount of bits within the header data. */
- size = sv8_header[k++];
+
+ /* Read the size of 'SH'-tag */
+ k = sv8_get_size(sv8_header, k, &size);
+
+ /* Skip crc32 */
+ k += 4;
/* Read stream version */
streamversion = sv8_header[k++];
@@ -149,7 +153,7 @@ bool get_musepack_metadata(int fd, struct mp3entry *id3)
k = sv8_get_size(sv8_header, k, &samples);
/* Number of leading zero-samples */
- k = sv8_get_size(sv8_header, k, &size);
+ k = sv8_get_size(sv8_header, k, &dummy);
/* Sampling frequency */
id3->frequency = sfreqs[(sv8_header[k++] >> 5) & 0x0003];
@@ -157,6 +161,9 @@ bool get_musepack_metadata(int fd, struct mp3entry *id3)
/* Number of channels */
id3->channels = (sv8_header[k++] >> 4) + 1;
+ /* Skip to next tag: k = size -2 */
+ k = size - 2;
+
if (!memcmp(sv8_header+k, "RG", 2)) { /* Replay Gain ID */
long peak, gain;
int bufused = 0;