[Mplayer-cvslog] CVS: main/libmpdemux demux_lavf.c,1.4,1.5

Michael Niedermayer CVS syncmail at mplayerhq.hu
Sun Apr 11 19:20:54 CEST 2004


CVS change done by Michael Niedermayer CVS

Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv29100/libmpdemux

Modified Files:
	demux_lavf.c 
Log Message:
seeking


Index: demux_lavf.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_lavf.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- demux_lavf.c	11 Apr 2004 16:48:48 -0000	1.4
+++ demux_lavf.c	11 Apr 2004 17:20:52 -0000	1.5
@@ -41,6 +41,7 @@
     ByteIOContext pb;
     int audio_streams;
     int video_streams;
+    int64_t last_pts;
 }lavf_priv_t;
 
 extern void print_wave_header(WAVEFORMATEX *h);
@@ -305,6 +306,8 @@
         av_free_packet(&pkt);
     }
 
+    priv->last_pts= pkt.pts;
+    
     dp->pts=pkt.pts / (float)AV_TIME_BASE;
     dp->pos=demux->filepos;
     dp->flags= !!(pkt.flags&PKT_FLAG_KEY);
@@ -314,7 +317,10 @@
 }
 
 void demux_seek_lavf(demuxer_t *demuxer, float rel_seek_secs, int flags){
-    mp_msg(MSGT_DEMUX,MSGL_DBG2,"demux_seek_lavf()\n");
+    lavf_priv_t *priv = demuxer->priv;
+    mp_msg(MSGT_DEMUX,MSGL_DBG2,"demux_seek_lavf(%p, %f, %d)\n", demuxer, rel_seek_secs, flags);
+    
+    av_seek_frame(priv->avfc, -1, priv->last_pts + rel_seek_secs*AV_TIME_BASE);
 }
 
 int demux_lavf_control(demuxer_t *demuxer, int cmd, void *arg)
@@ -322,19 +328,19 @@
     lavf_priv_t *priv = demuxer->priv;
     
     switch (cmd) {
-/*        case DEMUXER_CTRL_GET_TIME_LENGTH:
-	    if (priv->duration == 0)
+        case DEMUXER_CTRL_GET_TIME_LENGTH:
+	    if (priv->avfc->duration == 0)
 	        return DEMUXER_CTRL_DONTKNOW;
 	    
-	    *((unsigned long *)arg) = priv->duration;
+	    *((unsigned long *)arg) = priv->avfc->duration / AV_TIME_BASE;
 	    return DEMUXER_CTRL_OK;
 
 	case DEMUXER_CTRL_GET_PERCENT_POS:
-	    if (priv->duration == 0)
+	    if (priv->avfc->duration == 0)
 	        return DEMUXER_CTRL_DONTKNOW;
 	    
-	    *((int *)arg) = (int)(100 * lastpts / priv->duration);
-	    return DEMUXER_CTRL_OK;*/
+	    *((int *)arg) = (int)(priv->last_pts*100 / priv->avfc->duration);
+	    return DEMUXER_CTRL_OK;
 	
 	default:
 	    return DEMUXER_CTRL_NOTIMPL;




More information about the MPlayer-cvslog mailing list