Commit 01e74784 authored by Filip Roséen's avatar Filip Roséen Committed by Jean-Baptiste Kempf
Browse files

mkv: create index points using matroska_segment_seeker.{hpp, cpp}



This patch simply utilizes the new functionality introduced in
matroska_segment_seeker.{hpp,cpp} to store seekpoints found during
playback/preloading.
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent b24434c5
......@@ -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,7 +474,7 @@ 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)
......@@ -631,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;
......@@ -875,7 +894,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
......@@ -1061,26 +1082,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 );
}
}
};
......
......@@ -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;
};
......
......@@ -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 );
......
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