1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Linus Nielsen Feltzing 2002-09-16 13:32:12 +00:00
parent 2bd519d7b7
commit 842d5a99d0

View file

@ -419,7 +419,7 @@ static int getsonglength(int fd, struct mp3entry *entry)
} }
/* Loop trough file until we find a frame header */ /* Loop trough file until we find a frame header */
bytecount = 0; bytecount = entry->id3v2len - 1;
restart: restart:
do { do {
header <<= 8; header <<= 8;
@ -557,29 +557,46 @@ static int getsonglength(int fd, struct mp3entry *entry)
/* Yes, it is a VBR file */ /* Yes, it is a VBR file */
entry->vbr = true; entry->vbr = true;
entry->vbrflags = xing[7]; entry->vbrflags = xing[7];
int i = 8; /* Where to start parsing info */
if (entry->vbrflags & VBR_FRAMES_FLAG) /* Is the frame count there? */ if (entry->vbrflags & VBR_FRAMES_FLAG) /* Is the frame count there? */
{ {
int framecount = (xing[8] << 24) | (xing[9] << 16) | int framecount = (xing[i] << 24) | (xing[i+1] << 16) |
(xing[10] << 8) | xing[11]; (xing[i+2] << 8) | xing[i+3];
filetime = framecount * tpf; filetime = framecount * tpf;
i += 4;
} }
if (entry->vbrflags & VBR_BYTES_FLAG) /* is byte count there? */ if (entry->vbrflags & VBR_BYTES_FLAG) /* is byte count there? */
{ {
int bytecount = (xing[12] << 24) | (xing[13] << 16) | int bytecount = (xing[i] << 24) | (xing[i+1] << 16) |
(xing[14] << 8) | xing[15]; (xing[i+2] << 8) | xing[i+3];
bitrate = bytecount * 8 / filetime; bitrate = bytecount * 8 / filetime;
i += 4;
} }
if (entry->vbrflags & VBR_TOC_FLAG) /* is table-of-contents there? */ 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; entry->bitrate = bitrate;
/* If the file time hasn't been established, this may be a fixed /* 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; 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; return filetime;
} }