[vlc-commits] demux: asf: wait keyframe on index seek too

Francois Cartegnie git at videolan.org
Tue Dec 3 18:37:55 CET 2013


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Dec  3 15:59:03 2013 +0100| [adf378a9cb47017a59178763097b402bdcb57479] | committer: Francois Cartegnie

demux: asf: wait keyframe on index seek too

Index could be post keyframe type !

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=adf378a9cb47017a59178763097b402bdcb57479
---

 modules/demux/asf/asf.c |   41 ++++++++++++++++++++++++++++++++++-------
 1 file changed, 34 insertions(+), 7 deletions(-)

diff --git a/modules/demux/asf/asf.c b/modules/demux/asf/asf.c
index 45fc150..9dd3b10 100644
--- a/modules/demux/asf/asf.c
+++ b/modules/demux/asf/asf.c
@@ -229,11 +229,30 @@ static void Close( vlc_object_t * p_this )
 }
 
 /*****************************************************************************
- * SeekIndex: goto to i_date or i_percent
+ * WaitKeyframe: computes the number of frames to wait for a keyframe
  *****************************************************************************/
-static int SeekPercent( demux_t *p_demux, int i_query, va_list args )
+static void WaitKeyframe( demux_t *p_demux )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
+    if ( ! p_sys->i_seek_track )
+    {
+        for ( int i=0; i<128; i++ )
+        {
+            asf_track_t *tk = p_sys->track[i];
+            if ( tk && tk->p_sp && tk->i_cat == VIDEO_ES )
+            {
+                bool b_selected = false;
+                es_out_Control( p_demux->out, ES_OUT_GET_ES_STATE,
+                                tk->p_es, &b_selected );
+                if ( b_selected )
+                {
+                    p_sys->i_seek_track = tk->p_sp->i_stream_number;
+                    break;
+                }
+            }
+        }
+    }
+
     if ( p_sys->i_seek_track )
     {
         /* Skip forward at least 1 min */
@@ -255,6 +274,18 @@ static int SeekPercent( demux_t *p_demux, int i_query, va_list args )
     {
         p_sys->i_wait_keyframe = 0;
     }
+
+}
+
+/*****************************************************************************
+ * SeekIndex: goto to i_date or i_percent
+ *****************************************************************************/
+static int SeekPercent( demux_t *p_demux, int i_query, va_list args )
+{
+    demux_sys_t *p_sys = p_demux->p_sys;
+
+    WaitKeyframe( p_demux );
+
     msg_Dbg( p_demux, "seek with percent: waiting %i frames", p_sys->i_wait_keyframe );
     return demux_vaControlHelper( p_demux->s, p_sys->i_data_begin,
                                    p_sys->i_data_end, p_sys->i_bitrate,
@@ -282,7 +313,7 @@ static int SeekIndex( demux_t *p_demux, mtime_t i_date, float f_pos )
         return VLC_EGENERIC;
     }
 
-    p_sys->i_wait_keyframe = p_sys->i_seek_track ? 50 : 0;
+    WaitKeyframe( p_demux );
 
     uint64_t i_offset = (uint64_t)p_index->index_entry[i_entry].i_packet_number *
                         p_sys->p_fp->i_min_data_packet_size;
@@ -1171,10 +1202,6 @@ static int DemuxInit( demux_t *p_demux )
                     *p = '\0';
             }
 
-            /* Set the track on which we'll do our seeking to the first video track */
-            if(!p_sys->i_seek_track && fmt.i_cat == VIDEO_ES)
-                p_sys->i_seek_track = p_sp->i_stream_number;
-
             /* Set our priority so we won't get multiple videos */
             int i_priority = ES_PRIORITY_SELECTABLE_MIN;
             for( int16_t i = 0; i < fmt_priorities_ex.i_count; i++ )



More information about the vlc-commits mailing list