summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHardeep Sidhu <dyp@pobox.com>2002-08-30 07:07:57 +0000
committerHardeep Sidhu <dyp@pobox.com>2002-08-30 07:07:57 +0000
commit98cb63629b2eb76b49b21ccf60fcd7e743897145 (patch)
tree6bfe5ab19482f37ca1bf79c5ba8c228ede724402
parent87f53249b22fda1dda1549e1ff2c3c7ca89d92ad (diff)
downloadrockbox-98cb63629b2eb76b49b21ccf60fcd7e743897145.tar.gz
rockbox-98cb63629b2eb76b49b21ccf60fcd7e743897145.zip
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.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 49b0804cb9..6fd411282d 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -286,7 +286,7 @@ static void set_elapsed(struct mp3entry* id3)
286 286
287 /* calculate remainder time */ 287 /* calculate remainder time */
288 plen = (nextpos - relpos) * (id3->filesize / 256); 288 plen = (nextpos - relpos) * (id3->filesize / 256);
289 id3->elapsed += remainder * 1000 / plen ; 289 id3->elapsed += (((remainder * 100) / plen) * id3->length) / 10000;
290 } 290 }
291 else { 291 else {
292 /* no TOC exists. set a rough estimate using average bitrate */ 292 /* no TOC exists. set a rough estimate using average bitrate */
@@ -921,9 +921,9 @@ static void mpeg_thread(void)
921 } 921 }
922 922
923 case MPEG_FF_REWIND: { 923 case MPEG_FF_REWIND: {
924 struct mp3entry *id3 = mpeg_current_track(); 924 struct mp3entry *id3 = mpeg_current_track();
925 int oldtime = id3->elapsed; 925 unsigned int oldtime = id3->elapsed;
926 int newtime = oldtime + (int)ev.data; 926 unsigned int newtime = oldtime + (int)ev.data;
927 int curpos, newpos, diffpos; 927 int curpos, newpos, diffpos;
928 DEBUGF("MPEG_FF_REWIND\n"); 928 DEBUGF("MPEG_FF_REWIND\n");
929 929
@@ -933,7 +933,7 @@ static void mpeg_thread(void)
933 { 933 {
934 /* Use the TOC to find the new position */ 934 /* Use the TOC to find the new position */
935 unsigned int percent, remainder; 935 unsigned int percent, remainder;
936 int curtoc, nexttoc, nextpos; 936 int curtoc, nexttoc, plen;
937 937
938 percent = (newtime*100)/id3->length; 938 percent = (newtime*100)/id3->length;
939 if (percent > 99) 939 if (percent > 99)
@@ -951,11 +951,11 @@ static void mpeg_thread(void)
951 /* Use the remainder to get a more accurate position */ 951 /* Use the remainder to get a more accurate position */
952 remainder = (newtime*100)%id3->length; 952 remainder = (newtime*100)%id3->length;
953 remainder = (remainder*100)/id3->length; 953 remainder = (remainder*100)/id3->length;
954 nextpos = (id3->filesize/256)*nexttoc; 954 plen = (nexttoc - curtoc)*(id3->filesize/256);
955 newpos += ((nextpos-newpos)*remainder)/100; 955 newpos += (plen/100)*remainder;
956 } 956 }
957 else if (id3->bpf && id3->tpf) 957 else if (id3->bpf && id3->tpf)
958 newpos = (newtime*id3->bpf)/id3->tpf; 958 newpos = (newtime/id3->tpf)*id3->bpf;
959 else 959 else
960 { 960 {
961 /* Not enough information to FF/Rewind */ 961 /* Not enough information to FF/Rewind */