[vlc-devel] [PATCH 26/34] mkv: support "inprecise seeking" (ie. "Fast Seek")

Filip Roséen filip at videolabs.io
Fri May 6 19:09:05 CEST 2016


We should use a less-precise but faster seeking algorithm if this has
been requested when receiving DEMUX_SET_POSITION or DEMUX_SET_TIME from
the core.

This patch makes the relevant changes so that this information
propagates down to the relevant sections of the demuxer.
---
 modules/demux/mkv/mkv.cpp             | 13 ++++++++-----
 modules/demux/mkv/virtual_segment.cpp |  2 +-
 modules/demux/mkv/virtual_segment.hpp |  3 +--
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/modules/demux/mkv/mkv.cpp b/modules/demux/mkv/mkv.cpp
index 9b94474..c064376 100644
--- a/modules/demux/mkv/mkv.cpp
+++ b/modules/demux/mkv/mkv.cpp
@@ -87,7 +87,7 @@ struct demux_sys_t;
 
 static int  Demux  ( demux_t * );
 static int  Control( demux_t *, int, va_list );
-static void Seek   ( demux_t *, mtime_t i_mk_date, double f_percent, virtual_chapter_c *p_vchapter );
+static void Seek   ( demux_t *, mtime_t i_mk_date, double f_percent, virtual_chapter_c *p_vchapter, bool b_precise = true );
 
 /*****************************************************************************
  * Open: initializes matroska demux structures
@@ -298,6 +298,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
     double      *pf, f;
     int         i_skp;
     size_t      i_idx;
+    bool            b;
 
     vlc_meta_t *p_meta;
     input_attachment_t ***ppp_attach;
@@ -357,7 +358,8 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             if( p_sys->f_duration > 0.0 )
             {
                 f = va_arg( args, double );
-                Seek( p_demux, -1, f, NULL );
+                b = va_arg( args, int ); /* precise? */
+                Seek( p_demux, -1, f, NULL, b );
                 return VLC_SUCCESS;
             }
             return VLC_EGENERIC;
@@ -436,8 +438,9 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 
         case DEMUX_SET_TIME:
             i64 = va_arg( args, int64_t );
+            b = va_arg( args, int ); /* precise? */
             msg_Dbg(p_demux,"SET_TIME to %" PRId64, i64 );
-            Seek( p_demux, i64, -1, NULL );
+            Seek( p_demux, i64, -1, NULL, b );
             return VLC_SUCCESS;
         default:
             return VLC_EGENERIC;
@@ -445,7 +448,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 }
 
 /* Seek */
-static void Seek( demux_t *p_demux, mtime_t i_mk_date, double f_percent, virtual_chapter_c *p_vchapter )
+static void Seek( demux_t *p_demux, mtime_t i_mk_date, double f_percent, virtual_chapter_c *p_vchapter, bool b_precise )
 {
     demux_sys_t        *p_sys = p_demux->p_sys;
     virtual_segment_c  *p_vsegment = p_sys->p_current_vsegment;
@@ -480,7 +483,7 @@ static void Seek( demux_t *p_demux, mtime_t i_mk_date, double f_percent, virtual
     {
         i_mk_date = int64_t( f_percent * p_sys->f_duration * 1000.0 );
     }
-    p_vsegment->Seek( *p_demux, i_mk_date, p_vchapter );
+    p_vsegment->Seek( *p_demux, i_mk_date, p_vchapter, b_precise );
 }
 
 /* Needed by matroska_segment::Seek() and Seek */
diff --git a/modules/demux/mkv/virtual_segment.cpp b/modules/demux/mkv/virtual_segment.cpp
index f655333..7b3d0f7 100644
--- a/modules/demux/mkv/virtual_segment.cpp
+++ b/modules/demux/mkv/virtual_segment.cpp
@@ -509,7 +509,7 @@ bool virtual_chapter_c::EnterAndLeave( virtual_chapter_c *p_leaving_vchapter, bo
 }
 
 void virtual_segment_c::Seek( demux_t & demuxer, mtime_t i_mk_date,
-                              virtual_chapter_c *p_vchapter );
+                              virtual_chapter_c *p_vchapter, bool b_precise )
 {
     demux_sys_t *p_sys = demuxer.p_sys;
 
diff --git a/modules/demux/mkv/virtual_segment.hpp b/modules/demux/mkv/virtual_segment.hpp
index 6991e0e..d4e3510 100644
--- a/modules/demux/mkv/virtual_segment.hpp
+++ b/modules/demux/mkv/virtual_segment.hpp
@@ -160,8 +160,7 @@ public:
     virtual_chapter_c * FindChapter( int64_t i_find_uid );
 
     bool UpdateCurrentToChapter( demux_t & demux );
-    void Seek( demux_t & demuxer, mtime_t i_mk_date,
-               virtual_chapter_c *p_vchapter, int64_t i_global_position );
+    void Seek( demux_t & demuxer, mtime_t i_mk_date, virtual_chapter_c *p_vchapter, bool b_precise = true );
 private:
     void KeepTrackSelection( matroska_segment_c & old, matroska_segment_c & next );
 };
-- 
2.8.2



More information about the vlc-devel mailing list