Re: [PATCH][BUG-FIX] Prevent seeking to negative times
Raindel Shachar <[email protected]> Sun, 1 Feb 2004 12:33:41 +0200 (IST)
| Newsgroups | gmane.comp.video.mplayer.g2.devel |
|---|---|
| Message-ID | <Pine.GSO.4.44_heb2.09.0402011232400.3063-200000@techunix.technion.ac.il> |
Ooops, Forgot the attachment.... On Sun, 1 Feb 2004, Raindel Shachar wrote: > Hi, > The attached patch prevents the demuxer from trying to seek to negative > offsets, or after the end of the file. > > Cheers, > Shachar > > BTW: G2 rocks - it uses only 10% CPU on my computer playing 2.5Mbps MPEG 2 > video. It is the lowest CPU usage I have ever seen for playing back > these video clips..... > > _______________________________________________ MPlayer-G2-dev mailing list [email protected] http://mplayerhq.hu/mailman/listinfo/mplayer-g2-dev
g2-fixseek.diff
(text/plain, 912 B)
Index: demux/demuxer.c
===================================================================
RCS file: /cvsroot/mplayer/g2/demux/demuxer.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 demuxer.c
--- demux/demuxer.c 31 Jan 2004 20:16:18 -0000 1.1.1.1
+++ demux/demuxer.c 1 Feb 2004 10:16:14 -0000
@@ -483,6 +483,8 @@
off_t newpos=(mode&1)?demuxer->movi_start:demuxer->filepos;
if(mode&2){
// float seek 0..1
+ if(pos>1) pos = 1;
+ if(pos<0) pos = 0;
newpos+=(demuxer->movi_end-demuxer->movi_start)*pos;
} else {
// time seek (secs)
@@ -492,7 +494,11 @@
if(demuxer->streams[i]->bitrate>0)
br+=demuxer->streams[i]->bitrate;
br/=8; if(!br) br=800000/8; // 800 kbit
- newpos+=br*pos;
+ if(newpos<-br*pos) {
+ newpos = 0;
+ }else {
+ newpos+=br*pos;
+ }
}
stream_seek(demuxer->stream,newpos);
ret=1;