Mercurial > mplayer.hg
changeset 16613:465ad78c43c9
Detect eof when seeking and do _not_ restart the video.
Also fixes some invalid reads.
author | reimar |
---|---|
date | Wed, 28 Sep 2005 15:37:30 +0000 |
parents | e94616c973e3 |
children | 3e63ab4120b2 |
files | libmpdemux/demux_mov.c |
diffstat | 1 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/demux_mov.c Tue Sep 27 19:04:10 2005 +0000 +++ b/libmpdemux/demux_mov.c Wed Sep 28 15:37:30 2005 +0000 @@ -1850,6 +1850,7 @@ int x; off_t pos; + if (ds->eof) return 0; trak = stream_track(priv, ds); if (!trak) return 0; @@ -1946,6 +1947,7 @@ if(!(flags&1)) sample+=trak->chunks[trak->pos].sample; // relative trak->pos=0; while(trak->pos<trak->chunks_size && trak->chunks[trak->pos].sample<sample) ++trak->pos; + if (trak->pos == trak->chunks_size) return -1; pts=(float)(trak->chunks[trak->pos].sample*trak->duration)/(float)trak->timescale; } else { unsigned int ipts; @@ -1956,12 +1958,14 @@ for(trak->pos=0;trak->pos<trak->samples_size;++trak->pos){ if(trak->samples[trak->pos].pts>=ipts) break; // found it! } + if (trak->pos == trak->samples_size) return -1; if(trak->keyframes_size){ // find nearest keyframe int i; for(i=0;i<trak->keyframes_size;i++){ if(trak->keyframes[i]>=trak->pos) break; } + if (i == trak->keyframes_size) return -1; if(i>0 && (trak->keyframes[i]-trak->pos) > (trak->pos-trak->keyframes[i-1])) --i; trak->pos=trak->keyframes[i]; @@ -1987,7 +1991,9 @@ if (trak) { //if(flags&2) pts*=(float)trak->length/(float)trak->timescale; //if(!(flags&1)) pts+=ds->pts; - pts=ds->pts=mov_seek_track(trak,pts,flags); + ds->pts=mov_seek_track(trak,pts,flags); + if (ds->pts < 0) ds->eof = 1; + else pts = ds->pts; flags=1; // absolute seconds } @@ -1997,6 +2003,7 @@ //if(flags&2) pts*=(float)trak->length/(float)trak->timescale; //if(!(flags&1)) pts+=ds->pts; ds->pts=mov_seek_track(trak,pts,flags); + if (ds->pts < 0) ds->eof = 1; if (demuxer->video->id < 0) ((sh_audio_t*)ds->sh)->delay = ds->pts; }