vlc/vlc-3.0 | branch: master | Steve Lhomme <rob...@ycbcr.xyz> | Wed Feb 14 
09:59:48 2018 +0100| [a0e1d21cda7aab0b8ed9052cb20b383416259789] | committer: 
Hugo Beauzée-Luyssen

demux:mkv: refactor the fast/slow seeking code

(cherry picked from commit 99aae13400215dc9915de98ea6a1fcb168367fb8)
Signed-off-by: Hugo Beauzée-Luyssen <h...@beauzee.fr>

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

 modules/demux/mkv/matroska_segment.cpp | 33 ++++++++-------------------------
 modules/demux/mkv/matroska_segment.hpp |  4 +---
 modules/demux/mkv/virtual_segment.cpp  |  9 +--------
 3 files changed, 10 insertions(+), 36 deletions(-)

diff --git a/modules/demux/mkv/matroska_segment.cpp 
b/modules/demux/mkv/matroska_segment.cpp
index c0a879de62..2711906274 100644
--- a/modules/demux/mkv/matroska_segment.cpp
+++ b/modules/demux/mkv/matroska_segment.cpp
@@ -795,28 +795,7 @@ bool matroska_segment_c::LoadSeekHeadItem( const 
EbmlCallbacks & ClassInfos, int
     return true;
 }
 
-bool matroska_segment_c::FastSeek( demux_t &demuxer, mtime_t i_mk_date, 
mtime_t i_mk_time_offset )
-{
-    if( InternalSeek( demuxer, i_mk_date, i_mk_time_offset, false ) )
-    {
-        sys.i_start_pts = sys.i_pts;
-        es_out_Control( sys.demuxer.out, ES_OUT_SET_NEXT_DISPLAY_TIME, 
sys.i_start_pts );
-        return true;
-    }
-    return false;
-}
-
-bool matroska_segment_c::Seek( demux_t &demuxer, mtime_t i_mk_date, mtime_t 
i_mk_time_offset )
-{
-    if( InternalSeek( demuxer, i_mk_date, i_mk_time_offset, true ) )
-    {
-        es_out_Control( sys.demuxer.out, ES_OUT_SET_NEXT_DISPLAY_TIME, 
sys.i_start_pts );
-        return true;
-    }
-    return false;
-}
-
-bool matroska_segment_c::InternalSeek( demux_t &demuxer, mtime_t 
i_absolute_mk_date, mtime_t i_mk_time_offset, bool b_accurate )
+bool matroska_segment_c::Seek( demux_t &demuxer, mtime_t i_absolute_mk_date, 
mtime_t i_mk_time_offset, bool b_accurate )
 {
     SegmentSeeker::tracks_seekpoint_t seekpoints;
 
@@ -894,9 +873,12 @@ bool matroska_segment_c::InternalSeek( demux_t &demuxer, 
mtime_t i_absolute_mk_d
 
     // propogate seek information //
 
-    sys.i_pcr       = VLC_TS_INVALID;
-    sys.i_pts       = VLC_TS_0 + i_mk_seek_time + i_mk_time_offset;
-    sys.i_start_pts = VLC_TS_0 + i_absolute_mk_date;
+    sys.i_pcr           = VLC_TS_INVALID;
+    sys.i_pts           = VLC_TS_0 + i_mk_seek_time + i_mk_time_offset;
+    if (b_accurate)
+        sys.i_start_pts = VLC_TS_0 + i_absolute_mk_date;
+    else
+        sys.i_start_pts = sys.i_pts;
 
     // make the jump //
 
@@ -907,6 +889,7 @@ bool matroska_segment_c::InternalSeek( demux_t &demuxer, 
mtime_t i_absolute_mk_d
     msg_Dbg( &sys.demuxer, "seek: preroll{ req: %" PRId64 ", start-pts: %" 
PRId64 ", start-fpos: %" PRIu64 "} ",
       sys.i_start_pts, sys.i_pts, i_seek_position );
 
+    es_out_Control( sys.demuxer.out, ES_OUT_SET_NEXT_DISPLAY_TIME, 
sys.i_start_pts );
     return true;
 }
 
diff --git a/modules/demux/mkv/matroska_segment.hpp 
b/modules/demux/mkv/matroska_segment.hpp
index c753644cc8..7c564d054f 100644
--- a/modules/demux/mkv/matroska_segment.hpp
+++ b/modules/demux/mkv/matroska_segment.hpp
@@ -141,8 +141,7 @@ public:
     bool PreloadClusters( uint64 i_cluster_position );
     void InformationCreate();
 
-    bool FastSeek( demux_t &, mtime_t i_mk_date, mtime_t i_mk_time_offset );
-    bool Seek( demux_t &, mtime_t i_mk_date, mtime_t i_mk_time_offset );
+    bool Seek( demux_t &, mtime_t i_mk_date, mtime_t i_mk_time_offset, bool 
b_accurate );
 
     int BlockGet( KaxBlock * &, KaxSimpleBlock * &, bool *, bool *, int64_t *);
 
@@ -172,7 +171,6 @@ private:
     bool TrackInit( mkv_track_t * p_tk );
     void ComputeTrackPriority();
     void EnsureDuration();
-    bool InternalSeek( demux_t &, mtime_t i_mk_date, mtime_t i_mk_time_offset, 
bool b_accurate );
 
     SegmentSeeker _seeker;
 
diff --git a/modules/demux/mkv/virtual_segment.cpp 
b/modules/demux/mkv/virtual_segment.cpp
index a3b2e34127..37a9708882 100644
--- a/modules/demux/mkv/virtual_segment.cpp
+++ b/modules/demux/mkv/virtual_segment.cpp
@@ -549,16 +549,9 @@ bool virtual_segment_c::Seek( demux_t & demuxer, mtime_t 
i_mk_date,
         }
         else
         {
-            typedef bool( matroska_segment_c::* seek_callback_t )( demux_t &, 
mtime_t, mtime_t );
-
-            seek_callback_t pf_seek = &matroska_segment_c::Seek;
-
-            if( ! b_precise )
-                pf_seek = &matroska_segment_c::FastSeek;
-
             p_current_vchapter = p_vchapter;
 
-            return ( p_current_vchapter->segment.*pf_seek )( demuxer, 
i_mk_date, i_mk_time_offset );
+            return p_current_vchapter->segment.Seek( demuxer, i_mk_date, 
i_mk_time_offset, b_precise );
         }
     }
     return false;

_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to