Commit 99aae134 authored by Steve Lhomme's avatar Steve Lhomme

demux:mkv: refactor the fast/slow seeking code

parent 9069683b
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment