diff options
author | Jens Arnold <amiconn@rockbox.org> | 2005-09-09 07:19:41 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2005-09-09 07:19:41 +0000 |
commit | 4a939ecdcd1e32bd3d77e485d137f58ba35329d8 (patch) | |
tree | c86a9e1fad6f722cdda59926eea3d82b7adb7dea | |
parent | c2779e5ef3740781c30b8c2b5d9f876709b091d9 (diff) |
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
-rw-r--r-- | firmware/id3.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/firmware/id3.c b/firmware/id3.c index 8240e0d846..f1aa821fba 100644 --- a/firmware/id3.c +++ b/firmware/id3.c @@ -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; |