# HG changeset patch # User reimar # Date 1127921850 0 # Node ID 465ad78c43c9037e36c048881197fd0fd6dc41af # Parent e94616c973e3057a0394f914cc9148ed64b84aed Detect eof when seeking and do _not_ restart the video. Also fixes some invalid reads. diff -r e94616c973e3 -r 465ad78c43c9 libmpdemux/demux_mov.c --- 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->poschunks_size && trak->chunks[trak->pos].samplepos; + 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->possamples_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;ikeyframes_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; }