[MPlayer-cvslog] r20076 - trunk/libmpdemux/demux_lavf.c

reimar subversion at mplayerhq.hu
Thu Oct 5 23:25:23 CEST 2006


Author: reimar
Date: Thu Oct  5 23:25:22 2006
New Revision: 20076

Modified:
   trunk/libmpdemux/demux_lavf.c

Log:
Implement absolute and percent-based seek


Modified: trunk/libmpdemux/demux_lavf.c
==============================================================================
--- trunk/libmpdemux/demux_lavf.c	(original)
+++ trunk/libmpdemux/demux_lavf.c	Thu Oct  5 23:25:22 2006
@@ -403,9 +403,20 @@
 
 static void demux_seek_lavf(demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags){
     lavf_priv_t *priv = demuxer->priv;
+    int avsflags = 0;
     mp_msg(MSGT_DEMUX,MSGL_DBG2,"demux_seek_lavf(%p, %f, %f, %d)\n", demuxer, rel_seek_secs, audio_delay, flags);
 
-    av_seek_frame(priv->avfc, -1, priv->last_pts + rel_seek_secs*AV_TIME_BASE, rel_seek_secs < 0 ? AVSEEK_FLAG_BACKWARD : 0);
+    if (flags & 1) // absolute seek
+      priv->last_pts = priv->avfc->start_time;
+    if (flags & 2) { // percent seek
+      if (priv->avfc->duration == 0 || priv->avfc->duration == AV_NOPTS_VALUE)
+        return;
+      priv->last_pts += rel_seek_secs * priv->avfc->duration;
+    } else {
+      priv->last_pts += rel_seek_secs * AV_TIME_BASE;
+      if (rel_seek_secs < 0) avsflags = AVSEEK_FLAG_BACKWARD;
+    }
+    av_seek_frame(priv->avfc, -1, priv->last_pts, avsflags);
 }
 
 static int demux_lavf_control(demuxer_t *demuxer, int cmd, void *arg)



More information about the MPlayer-cvslog mailing list