summaryrefslogtreecommitdiffstats
path: root/firmware/id3.c
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-09-09 07:19:41 +0000
committerJens Arnold <amiconn@rockbox.org>2005-09-09 07:19:41 +0000
commit4a939ecdcd1e32bd3d77e485d137f58ba35329d8 (patch)
treec86a9e1fad6f722cdda59926eea3d82b7adb7dea /firmware/id3.c
parentc2779e5ef3740781c30b8c2b5d9f876709b091d9 (diff)
downloadrockbox-4a939ecdcd1e32bd3d77e485d137f58ba35329d8.tar.gz
rockbox-4a939ecdcd1e32bd3d77e485d137f58ba35329d8.tar.bz2
rockbox-4a939ecdcd1e32bd3d77e485d137f58ba35329d8.zip
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
Diffstat (limited to 'firmware/id3.c')
-rw-r--r--firmware/id3.c11
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;