summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-09-30 18:41:59 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-09-30 18:41:59 +0000
commit18ae8f573580660363b4a1c84b483b663d618b12 (patch)
treecc3766787381013698934c1eb6668aa0bee667bb
parent410c75bd06e2499cdb1175edaf7b9483df211a2c (diff)
Bill Napier's fix for header lengths for ID3v2.3 and earlier.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2450 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/id3.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/firmware/id3.c b/firmware/id3.c
index 0e7a5f227b..4da0224641 100644
--- a/firmware/id3.c
+++ b/firmware/id3.c
@@ -49,6 +49,11 @@
((b3 & 0x7F) << (1*7)) | \
((b4 & 0x7F) << (0*7)))
+#define BYTES_TO_INT(b1,b2,b3,b4) (((b1 & 0xFF) << (3*8)) | \
+ ((b2 & 0xFF) << (2*8)) | \
+ ((b3 & 0xFF) << (1*8)) | \
+ ((b4 & 0xFF) << (0*8)))
+
/* Table of bitrates for MP3 files, all values in kilo.
* Indexed by version, layer and value of bit 15-12 in header.
*/
@@ -215,8 +220,15 @@ static void setid3v2title(int fd, struct mp3entry *entry)
if(version > 2) {
memcpy(header, (buffer + readsize), 10);
readsize += 10;
- headerlen = UNSYNC(header[4], header[5],
- header[6], header[7]);
+ if (version > 3) {
+ headerlen = UNSYNC(header[4], header[5],
+ header[6], header[7]);
+ } else {
+ /* version .3 files don't use synchsafe ints for
+ * size */
+ headerlen = BYTES_TO_INT(header[4], header[5],
+ header[6], header[7]);
+ }
} else {
memcpy(header, (buffer + readsize), 6);
readsize += 6;