[Mplayer-cvslog] CVS: main demux_mov.c,1.9,1.10 demuxer.c,1.33,1.34

Arpi of Ize arpi at mplayer.dev.hu
Wed Oct 17 00:41:59 CEST 2001


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

Modified Files:
	demux_mov.c demuxer.c 
Log Message:
mov seeking implemented

Index: demux_mov.c
===================================================================
RCS file: /cvsroot/mplayer/main/demux_mov.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- demux_mov.c	10 Oct 2001 01:07:50 -0000	1.9
+++ demux_mov.c	16 Oct 2001 22:41:46 -0000	1.10
@@ -107,6 +107,7 @@
     if(!trak->samples_size){
 	// constant sampesize
 	if(trak->durmap_size==1 || (trak->durmap_size==2 && trak->durmap[1].num==1)){
+	    trak->duration=trak->durmap[0].dur;
 	} else printf("*** constant samplesize & variable duration not yet supported! ***\nContact the author if you have such sample file!\n");
 	return;
     }
@@ -558,3 +559,55 @@
     return 1;
     
 }
+
+static float mov_seek_track(mov_track_t* trak,float pts,int flags){
+
+//    printf("MOV track seek called  %5.3f  \n",pts);
+    if(flags&2) pts*=trak->length; else pts*=(float)trak->timescale;
+
+if(trak->samplesize){
+    int sample=pts/trak->duration;
+//    printf("MOV track seek - chunk: %d  (pts: %5.3f  dur=%d)  \n",sample,pts,trak->duration);
+    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;
+    pts=(float)(trak->chunks[trak->pos].sample*trak->duration)/(float)trak->timescale;
+} else {
+    unsigned int ipts=pts;
+//    printf("MOV track seek - sample: %d  \n",ipts);
+    if(!(flags&1)) ipts+=trak->samples[trak->pos].pts;
+    trak->pos=0;
+    while(trak->pos<trak->samples_size && trak->samples[trak->pos].pts<ipts) ++trak->pos;
+    pts=(float)trak->samples[trak->pos].pts/(float)trak->timescale;
+}
+
+//    printf("MOV track seek done:  %5.3f  \n",pts);
+
+return pts;
+}
+
+void demux_seek_mov(demuxer_t *demuxer,float pts,int flags){
+    mov_priv_t* priv=demuxer->priv;
+    demux_stream_t* ds;
+
+//    printf("MOV seek called  %5.3f  flag=%d  \n",pts,flags);
+    
+    ds=demuxer->video;
+    if(ds && ds->id>=0 && ds->id<priv->track_db){
+	mov_track_t* trak=priv->tracks[ds->id];
+	//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);
+	flags=1; // absolute seconds
+    }
+
+    ds=demuxer->audio;
+    if(ds && ds->id>=0 && ds->id<priv->track_db){
+	mov_track_t* trak=priv->tracks[ds->id];
+	//if(flags&2) pts*=(float)trak->length/(float)trak->timescale;
+	//if(!(flags&1)) pts+=ds->pts;
+	ds->pts=mov_seek_track(trak,pts,flags);
+    }
+
+}
+

Index: demuxer.c
===================================================================
RCS file: /cvsroot/mplayer/main/demuxer.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- demuxer.c	7 Oct 2001 21:59:49 -0000	1.33
+++ demuxer.c	16 Oct 2001 22:41:46 -0000	1.34
@@ -532,6 +532,7 @@
 int demux_seek_avi(demuxer_t *demuxer,float rel_seek_secs,int flags);
 int demux_seek_asf(demuxer_t *demuxer,float rel_seek_secs,int flags);
 int demux_seek_mpg(demuxer_t *demuxer,float rel_seek_secs,int flags);
+void demux_seek_mov(demuxer_t *demuxer,float pts,int flags);
 
 int demux_seek(demuxer_t *demuxer,float rel_seek_secs,int flags){
     demux_stream_t *d_audio=demuxer->audio;
@@ -567,6 +568,9 @@
   case DEMUXER_TYPE_MPEG_ES:
   case DEMUXER_TYPE_MPEG_PS:
       demux_seek_mpg(demuxer,rel_seek_secs,flags);  break;
+
+  case DEMUXER_TYPE_MOV:
+      demux_seek_mov(demuxer,rel_seek_secs,flags);  break;
 
 } // switch(demuxer->file_format)
 




More information about the MPlayer-cvslog mailing list