diff options
| author | Hardeep Sidhu <dyp@pobox.com> | 2002-08-30 07:07:57 +0000 |
|---|---|---|
| committer | Hardeep Sidhu <dyp@pobox.com> | 2002-08-30 07:07:57 +0000 |
| commit | 98cb63629b2eb76b49b21ccf60fcd7e743897145 (patch) | |
| tree | 6bfe5ab19482f37ca1bf79c5ba8c228ede724402 | |
| parent | 87f53249b22fda1dda1549e1ff2c3c7ca89d92ad (diff) | |
| download | rockbox-98cb63629b2eb76b49b21ccf60fcd7e743897145.zip rockbox-98cb63629b2eb76b49b21ccf60fcd7e743897145.tar.gz rockbox-98cb63629b2eb76b49b21ccf60fcd7e743897145.tar.bz2 rockbox-98cb63629b2eb76b49b21ccf60fcd7e743897145.tar.xz | |
Fixed ff/rew new position calculation to handle large seek positions and files. This should remove any restrictions on CBR files. VBR files can now seek to ~12 hours (TODO: remove this limit). Also fixed small bug in elapsed time calculation after resume.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2073 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | firmware/mpeg.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c index 49b0804..6fd4112 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c @@ -286,7 +286,7 @@ static void set_elapsed(struct mp3entry* id3) /* calculate remainder time */ plen = (nextpos - relpos) * (id3->filesize / 256); - id3->elapsed += remainder * 1000 / plen ; + id3->elapsed += (((remainder * 100) / plen) * id3->length) / 10000; } else { /* no TOC exists. set a rough estimate using average bitrate */ @@ -921,9 +921,9 @@ static void mpeg_thread(void) } case MPEG_FF_REWIND: { - struct mp3entry *id3 = mpeg_current_track(); - int oldtime = id3->elapsed; - int newtime = oldtime + (int)ev.data; + struct mp3entry *id3 = mpeg_current_track(); + unsigned int oldtime = id3->elapsed; + unsigned int newtime = oldtime + (int)ev.data; int curpos, newpos, diffpos; DEBUGF("MPEG_FF_REWIND\n"); @@ -933,7 +933,7 @@ static void mpeg_thread(void) { /* Use the TOC to find the new position */ unsigned int percent, remainder; - int curtoc, nexttoc, nextpos; + int curtoc, nexttoc, plen; percent = (newtime*100)/id3->length; if (percent > 99) @@ -951,11 +951,11 @@ static void mpeg_thread(void) /* Use the remainder to get a more accurate position */ remainder = (newtime*100)%id3->length; remainder = (remainder*100)/id3->length; - nextpos = (id3->filesize/256)*nexttoc; - newpos += ((nextpos-newpos)*remainder)/100; + plen = (nexttoc - curtoc)*(id3->filesize/256); + newpos += (plen/100)*remainder; } else if (id3->bpf && id3->tpf) - newpos = (newtime*id3->bpf)/id3->tpf; + newpos = (newtime/id3->tpf)*id3->bpf; else { /* Not enough information to FF/Rewind */ |