[MPlayer-G2-dev] Re: [PATCH][BUG-FIX] Prevent seeking to negative times
Raindel Shachar
raindel at techunix.technion.ac.il
Sun Feb 1 11:33:41 CET 2004
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.....
>
>
-------------- next part --------------
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;
More information about the MPlayer-G2-dev
mailing list