Mercurial > mplayer.hg
changeset 1628:bd1ef18cdf33
seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
author | arpi |
---|---|
date | Wed, 22 Aug 2001 19:03:15 +0000 |
parents | eeaee1632340 |
children | 13aeaa05ac5e |
files | demux_asf.c demux_avi.c demux_mpg.c demuxer.c |
diffstat | 4 files changed, 38 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/demux_asf.c Wed Aug 22 19:02:28 2001 +0000 +++ b/demux_asf.c Wed Aug 22 19:03:15 2001 +0000 @@ -327,13 +327,15 @@ //================= seek in ASF ========================== float p_rate=10; // packets / sec - off_t rel_seek_packs=rel_seek_secs*p_rate; // FIXME: int may be enough? + off_t rel_seek_packs=(flags&2)? // FIXME: int may be enough? + (rel_seek_secs*(demuxer->movi_end-demuxer->movi_start)/asf_packetsize): + (rel_seek_secs*p_rate); off_t rel_seek_bytes=rel_seek_packs*asf_packetsize; off_t newpos; //printf("ASF: packs: %d duration: %d \n",(int)fileh.packets,*((int*)&fileh.duration)); // printf("ASF_seek: %d secs -> %d packs -> %d bytes \n", // rel_seek_secs,rel_seek_packs,rel_seek_bytes); - newpos=demuxer->filepos+rel_seek_bytes; + newpos=((flags&1)?demuxer->movi_start:demuxer->filepos)+rel_seek_bytes; if(newpos<0 || newpos<demuxer->movi_start) newpos=demuxer->movi_start; // printf("\r -- asf: newpos=%d -- \n",newpos); stream_seek(demuxer->stream,newpos);
--- a/demux_avi.c Wed Aug 22 19:02:28 2001 +0000 +++ b/demux_avi.c Wed Aug 22 19:03:15 2001 +0000 @@ -488,6 +488,25 @@ int rel_seek_frames=rel_seek_secs*sh_video->fps; int video_chunk_pos=d_video->pos; int i; + + if(flags&1){ + // seek absolute + video_chunk_pos=0; + } + + if(flags&2){ + // float 0..1 + int total=sh_video->video.dwLength; + if(total<=1){ + // bad video header, try to get it from audio + total=sh_video->fps*sh_audio->audio.dwLength/sh_audio->wf->nAvgBytesPerSec; + if(total<1){ + mp_msg(MSGT_SEEK,MSGL_WARN,"Couldn't determine number of frames (for absoulte seek) \n"); + total=0; + } + } + rel_seek_frames=rel_seek_secs*total; + } priv->skip_video_frames=0; priv->avi_audio_pts=0;
--- a/demux_mpg.c Wed Aug 22 19:02:28 2001 +0000 +++ b/demux_mpg.c Wed Aug 22 19:03:15 2001 +0000 @@ -351,15 +351,21 @@ sh_video_t *sh_video=d_video->sh; //================= seek in MPEG ========================== - off_t newpos; - if(!sh_video->i_bps) // unspecified? - newpos=demuxer->filepos+2324*75*rel_seek_secs; // 174.3 kbyte/sec + off_t newpos=(flags&1)?demuxer->movi_start:demuxer->filepos; + + if(flags&2){ + // float seek 0..1 + newpos+=(demuxer->movi_end-demuxer->movi_start)*rel_seek_secs; + } else { + // time seek (secs) + if(!sh_video->i_bps) // unspecified or VBR + newpos+=2324*75*rel_seek_secs; // 174.3 kbyte/sec else - newpos=demuxer->filepos+(sh_video->i_bps)*rel_seek_secs; + newpos+=sh_video->i_bps*rel_seek_secs; + } - if(newpos<demuxer->stream->start_pos - && demuxer->stream->type==STREAMTYPE_VCD) - newpos=demuxer->stream->start_pos; // for VCD + if(newpos<demuxer->movi_start) newpos=demuxer->movi_start; + #ifdef _LARGEFILE_SOURCE newpos&=~((long long)STREAM_BUFFER_SIZE-1); /* sector boundary */ #else
--- a/demuxer.c Wed Aug 22 19:02:28 2001 +0000 +++ b/demuxer.c Wed Aug 22 19:03:15 2001 +0000 @@ -460,6 +460,8 @@ } case DEMUXER_TYPE_MPEG_PS: { sh_video=d_video->sh;sh_video->ds=d_video; + if(demuxer->stream->type!=STREAMTYPE_VCD) demuxer->movi_start=0; // for VCD + if(audio_id!=-2) { if(!ds_fill_buffer(d_audio)){ mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_MissingMPEGaudio);