diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2002-09-16 13:32:12 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2002-09-16 13:32:12 +0000 |
commit | 842d5a99d0885f15d5e28cf8661e6ba5529e4b15 (patch) | |
tree | f65b2b2472e057774a7f89ddc321f7ad02c6650d /firmware | |
parent | 2bd519d7b7f64e60be07063df0305d9f06382642 (diff) |
Now skips garbage padding after the ID3V2 tag, along with Xing and LAME headers
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2300 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/id3.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/firmware/id3.c b/firmware/id3.c index 4a803e7d2b..b6d9852175 100644 --- a/firmware/id3.c +++ b/firmware/id3.c @@ -419,7 +419,7 @@ static int getsonglength(int fd, struct mp3entry *entry) } /* Loop trough file until we find a frame header */ - bytecount = 0; + bytecount = entry->id3v2len - 1; restart: do { header <<= 8; @@ -557,29 +557,46 @@ static int getsonglength(int fd, struct mp3entry *entry) /* Yes, it is a VBR file */ entry->vbr = true; entry->vbrflags = xing[7]; + int i = 8; /* Where to start parsing info */ if (entry->vbrflags & VBR_FRAMES_FLAG) /* Is the frame count there? */ { - int framecount = (xing[8] << 24) | (xing[9] << 16) | - (xing[10] << 8) | xing[11]; + int framecount = (xing[i] << 24) | (xing[i+1] << 16) | + (xing[i+2] << 8) | xing[i+3]; filetime = framecount * tpf; + i += 4; } if (entry->vbrflags & VBR_BYTES_FLAG) /* is byte count there? */ { - int bytecount = (xing[12] << 24) | (xing[13] << 16) | - (xing[14] << 8) | xing[15]; + int bytecount = (xing[i] << 24) | (xing[i+1] << 16) | + (xing[i+2] << 8) | xing[i+3]; bitrate = bytecount * 8 / filetime; + i += 4; } if (entry->vbrflags & VBR_TOC_FLAG) /* is table-of-contents there? */ { - memcpy( entry->toc, xing+16, 100 ); + memcpy( entry->toc, xing+i, 100 ); } + + /* Make sure we skip this frame in playback */ + bytecount += bpf; + } + + /* Is it a LAME Info frame? */ + if (xing[0] == 'I' && + xing[1] == 'n' && + xing[2] == 'f' && + xing[3] == 'o') + { + /* Make sure we skip this frame in playback */ + bytecount += bpf; } + entry->bitrate = bitrate; /* If the file time hasn't been established, this may be a fixed @@ -593,6 +610,10 @@ static int getsonglength(int fd, struct mp3entry *entry) filetime = entry->filesize/bpf*tpf; } + DEBUGF("Old ID3V2 length: %x\n", entry->id3v2len); + entry->id3v2len = bytecount; + DEBUGF("New ID3V2 length: %x\n", bytecount); + return filetime; } |