[vlc-devel] [PATCH 21/34] mkv: utilize functionality introduced by matroska_segment_seeker.hpp
Filip Roséen
filip at videolabs.io
Fri May 6 19:09:00 CEST 2016
---
modules/demux/mkv/matroska_segment.cpp | 34 ++++++++++++++++++++++++----
modules/demux/mkv/matroska_segment.hpp | 8 +++++++
modules/demux/mkv/matroska_segment_parse.cpp | 6 ++++-
3 files changed, 43 insertions(+), 5 deletions(-)
diff --git a/modules/demux/mkv/matroska_segment.cpp b/modules/demux/mkv/matroska_segment.cpp
index 13b8cef..131ccd6 100644
--- a/modules/demux/mkv/matroska_segment.cpp
+++ b/modules/demux/mkv/matroska_segment.cpp
@@ -218,7 +218,15 @@ void matroska_segment_c::LoadCues( KaxCues *cues )
if( tracks.find( track_id ) != tracks.end() )
{
- // TODO: handle addition of seekpoint
+ for( tracks_map_t::iterator it = tracks.begin(); it != tracks.end(); ++it )
+ {
+ int const tlevel = SegmentSeeker::Seekpoint::QUESTIONABLE; // TODO: var_inheritBool( ..., "mkv-trust-cues" ) => TRUSTED;
+ int const qlevel = SegmentSeeker::Seekpoint::QUESTIONABLE;
+
+ int level = ( track_id == it->first ? tlevel : qlevel );
+
+ _seeker.add_seekpoint( it->first, level, cue_position, cue_mk_time );
+ }
}
else
msg_Warn( &sys.demuxer, "Found cue with invalid track id = %u", track_id );
@@ -466,6 +474,8 @@ void matroska_segment_c::InformationCreate( )
void matroska_segment_c::IndexAppendCluster( KaxCluster *cluster )
{
+ _seeker.add_cluster( cluster );
+}
bool matroska_segment_c::PreloadClusters(uint64 i_cluster_pos)
{
@@ -629,6 +639,17 @@ bool matroska_segment_c::Preload( )
ParseCluster( cluster );
IndexAppendCluster( cluster );
+ // add first cluster as trusted seekpoint for all tracks
+ for( tracks_map_t::iterator it = tracks.begin(); it != tracks.end(); ++it )
+ {
+ _seeker.add_seekpoint(
+ it->first,
+ SegmentSeeker::Seekpoint::TRUSTED,
+ cluster->GetElementPosition(),
+ cluster->GlobalTimecode() / 1000
+ );
+ }
+
ep->Down();
/* stop pre-parsing the stream */
break;
@@ -1087,7 +1108,9 @@ void matroska_segment_c::EnsureDuration()
uint64 i_last_cluster_pos = 0;
// find the last Cluster from the Cues
+ if ( b_cues && _seeker._cluster_positions.size() )
{
+ i_last_cluster_pos = *_seeker._cluster_positions.rbegin();
}
// find the last Cluster manually
@@ -1273,26 +1296,29 @@ int matroska_segment_c::BlockGet( KaxBlock * & pp_block, KaxSimpleBlock * & pp_s
{
ktimecode.ReadData( vars.obj->es.I_O(), SCOPE_ALL_DATA );
vars.obj->cluster->InitTimecode( static_cast<uint64>( ktimecode ), vars.obj->i_timescale );
+ vars.obj->IndexAppendCluster( vars.obj->cluster );
}
-
E_CASE( KaxClusterSilentTracks, ksilent )
{
vars.obj->ep->Down ();
VLC_UNUSED( ksilent );
}
-
E_CASE( KaxBlockGroup, kbgroup )
{
vars.obj->i_block_pos = kbgroup.GetElementPosition();
vars.obj->ep->Down ();
}
-
E_CASE( KaxSimpleBlock, ksblock )
{
vars.simpleblock = &ksblock;
vars.simpleblock->ReadData( vars.obj->es.I_O() );
vars.simpleblock->SetParent( *vars.obj->cluster );
+
+ if( ksblock.IsKeyframe() )
+ {
+ vars.obj->_seeker.add_seekpoint( ksblock.TrackNum(), SegmentSeeker::Seekpoint::TRUSTED, ksblock.GetElementPosition(), ksblock.GlobalTimecode() / 1000 );
+ }
}
};
diff --git a/modules/demux/mkv/matroska_segment.hpp b/modules/demux/mkv/matroska_segment.hpp
index d596cb3..5b44a47 100644
--- a/modules/demux/mkv/matroska_segment.hpp
+++ b/modules/demux/mkv/matroska_segment.hpp
@@ -26,9 +26,13 @@
#define VLC_MKV_MATROSKA_SEGMENT_HPP_
#include "mkv.hpp"
+#include "matroska_segment_seeker.hpp"
#include <vector>
#include <string>
+#include <map>
+#include <set>
+
class EbmlParser;
class chapter_edition_c;
@@ -165,6 +169,10 @@ private:
int32_t TrackInit( mkv_track_t * p_tk );
void ComputeTrackPriority();
void EnsureDuration();
+
+ SegmentSeeker _seeker;
+
+ friend SegmentSeeker;
};
diff --git a/modules/demux/mkv/matroska_segment_parse.cpp b/modules/demux/mkv/matroska_segment_parse.cpp
index ae84a71..8550c14 100644
--- a/modules/demux/mkv/matroska_segment_parse.cpp
+++ b/modules/demux/mkv/matroska_segment_parse.cpp
@@ -144,7 +144,11 @@ void matroska_segment_c::ParseSeekHead( KaxSeekHead *seekhead )
if( i_pos >= 0 )
{
- if( id == EBML_ID(KaxCues) )
+ if( id == EBML_ID(KaxCluster) )
+ {
+ _seeker.add_cluster_position( i_pos );
+ }
+ else if( id == EBML_ID(KaxCues) )
{
msg_Dbg( &sys.demuxer, "| - cues at %" PRId64, i_pos );
LoadSeekHeadItem( EBML_INFO(KaxCues), i_pos );
--
2.8.2
More information about the vlc-devel
mailing list