From 24756e1cf77cf02aa427357e3f0d4562972952e6 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 19 May 2003 14:15:21 +0000 Subject: Stevie Oh's patch #739898 that corrects how vbrfix works on large files. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3685 a1c6a512-1295-4272-9138-f99709370657 --- firmware/mp3data.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'firmware/mp3data.c') diff --git a/firmware/mp3data.c b/firmware/mp3data.c index 5baa9ec149..38fae384e0 100644 --- a/firmware/mp3data.c +++ b/firmware/mp3data.c @@ -646,7 +646,23 @@ int create_xing_header(int fd, int startpos, int filesize, } /* Fill in the TOC entry */ - toc[i] = filepos * 256 / filesize; + /* each toc is a single byte indicating how many 256ths of the + * way through the file, is that percent of the way through the + * song. the easy method, filepos*256/filesize, chokes when + * the upper 8 bits of the file position are nonzero + * (i.e. files over 16mb in size). + */ + if (filepos > 0xFFFFFF) + { + /* instead of multiplying filepos by 256, we divide + * filesize by 256. + */ + toc[i] = filepos / (filesize >> 8); + } + else + { + toc[i] = filepos * 256 / filesize; + } DEBUGF("Pos %d: %d relpos: %d filepos: %x tocentry: %x\n", i, pos, pos-last_pos, filepos, toc[i]); -- cgit v1.2.3