[vlc-commits] demux:mkv: refactor the fast/slow seeking code
Steve Lhomme
git at videolan.org
Wed Feb 14 13:46:18 CET 2018
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Feb 14 09:59:48 2018 +0100| [99aae13400215dc9915de98ea6a1fcb168367fb8] | committer: Steve Lhomme
demux:mkv: refactor the fast/slow seeking code
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=99aae13400215dc9915de98ea6a1fcb168367fb8
---
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 01d0e770db..9c59e8d2fe 100644
--- a/modules/demux/mkv/matroska_segment.cpp
+++ b/modules/demux/mkv/matroska_segment.cpp
@@ -773,28 +773,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;
@@ -872,9 +851,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 //
@@ -885,6 +867,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 f0f7ec34cf..39320bda3b 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 *);
@@ -171,7 +170,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 8bcea134a6..b5a9f5a033 100644
--- a/modules/demux/mkv/virtual_segment.cpp
+++ b/modules/demux/mkv/virtual_segment.cpp
@@ -543,16 +543,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;
More information about the vlc-commits
mailing list