1
0
Fork 0
forked from len0rd/rockbox

Exact song length calculation for CBR mpeg audio files (without Info header).

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7502 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jens Arnold 2005-09-09 07:19:41 +00:00
parent c2779e5ef3
commit 4a939ecdcd

View file

@ -906,17 +906,16 @@ static int getsonglength(int fd, struct mp3entry *entry)
if(filetime == 0)
{
/*
* Now song length is
* ((filesize)/(bytes per frame))*(time per frame)
*/
filetime = entry->filesize/info.frame_size*info.frame_time;
filetime = (entry->filesize - bytecount) / (info.bitrate / 8);
/* bitrate is in kbps so this delivers milliseconds. Doing bitrate / 8
* instead of filesize * 8 is exact, because mpeg audio bitrates are
* always multiples of 8, and it avoids overflows. */
}
entry->tpf = info.frame_time;
entry->bpf = info.frame_size;
entry->frame_count = info.frame_count;
entry->vbr = info.is_vbr;
entry->has_toc = info.has_toc;