[Mplayer-cvslog] CVS: main demux_asf.c,1.15,1.16 demux_avi.c,1.24,1.25 demux_mpg.c,1.29,1.30 demuxer.c,1.24,1.25

Arpi of Ize arpi at mplayer.dev.hu
Wed Aug 22 21:03:17 CEST 2001


Update of /cvsroot/mplayer/main
In directory mplayer:/var/tmp.root/cvs-serv22823

Modified Files:
	demux_asf.c demux_avi.c demux_mpg.c demuxer.c 
Log Message:
seeking flags implemented: 0x1=rel/abs and 0x2=time/percent

Index: demux_asf.c
===================================================================
RCS file: /cvsroot/mplayer/main/demux_asf.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- demux_asf.c	17 Aug 2001 00:40:25 -0000	1.15
+++ demux_asf.c	22 Aug 2001 19:03:15 -0000	1.16
@@ -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);

Index: demux_avi.c
===================================================================
RCS file: /cvsroot/mplayer/main/demux_avi.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- demux_avi.c	22 Aug 2001 16:42:37 -0000	1.24
+++ demux_avi.c	22 Aug 2001 19:03:15 -0000	1.25
@@ -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;

Index: demux_mpg.c
===================================================================
RCS file: /cvsroot/mplayer/main/demux_mpg.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- demux_mpg.c	20 Aug 2001 21:20:39 -0000	1.29
+++ demux_mpg.c	22 Aug 2001 19:03:15 -0000	1.30
@@ -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->movi_start) newpos=demuxer->movi_start;
 
-        if(newpos<demuxer->stream->start_pos 
-	 && demuxer->stream->type==STREAMTYPE_VCD)
-	     newpos=demuxer->stream->start_pos; // for VCD
 #ifdef _LARGEFILE_SOURCE
         newpos&=~((long long)STREAM_BUFFER_SIZE-1);  /* sector boundary */
 #else

Index: demuxer.c
===================================================================
RCS file: /cvsroot/mplayer/main/demuxer.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- demuxer.c	22 Aug 2001 16:42:37 -0000	1.24
+++ demuxer.c	22 Aug 2001 19:03:15 -0000	1.25
@@ -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);




More information about the MPlayer-cvslog mailing list