Commit 1f08a9d3 authored by Steve Lhomme's avatar Steve Lhomme

mkv.cpp: handle missing linked segments (seg->missing->seg)

parent e617b434
...@@ -528,12 +528,15 @@ public: ...@@ -528,12 +528,15 @@ public:
class virtual_segment_t class virtual_segment_t
{ {
public: public:
virtual_segment_t() virtual_segment_t( matroska_segment_t *p_segment )
:i_current_segment(0) :i_current_segment(0)
{} {
linked_segments.push_back( p_segment );
std::vector<matroska_segment_t*> linked_segments; AppendUID( p_segment->segment_uid );
size_t i_current_segment; AppendUID( p_segment->prev_segment_uid );
AppendUID( p_segment->next_segment_uid );
}
void Sort(); void Sort();
size_t AddSegment( matroska_segment_t *p_segment ); size_t AddSegment( matroska_segment_t *p_segment );
...@@ -557,6 +560,13 @@ public: ...@@ -557,6 +560,13 @@ public:
} }
return false; return false;
} }
protected:
std::vector<matroska_segment_t*> linked_segments;
std::vector<const KaxSegmentUID> linked_uids;
size_t i_current_segment;
void AppendUID( const EbmlBinary & UID );
}; };
class matroska_stream_t class matroska_stream_t
...@@ -3423,10 +3433,7 @@ void demux_sys_t::PreloadLinked( matroska_segment_t *p_segment ) ...@@ -3423,10 +3433,7 @@ void demux_sys_t::PreloadLinked( matroska_segment_t *p_segment )
size_t i_preloaded, i; size_t i_preloaded, i;
delete p_current_segment; delete p_current_segment;
p_current_segment = new virtual_segment_t(); p_current_segment = new virtual_segment_t( p_segment );
// fill our current virtual segment with the used segment from the current stream
p_current_segment->linked_segments.push_back( p_segment );
// fill our current virtual segment with all hard linked segments // fill our current virtual segment with all hard linked segments
do { do {
...@@ -3458,6 +3465,9 @@ bool matroska_segment_t::CompareSegmentUIDs( const matroska_segment_t * p_item_a ...@@ -3458,6 +3465,9 @@ bool matroska_segment_t::CompareSegmentUIDs( const matroska_segment_t * p_item_a
if ( *p_itema == p_item_b->segment_uid ) if ( *p_itema == p_item_b->segment_uid )
return true; return true;
if ( *p_itema == p_item_b->prev_segment_uid )
return true;
return false; return false;
} }
...@@ -3557,16 +3567,17 @@ size_t virtual_segment_t::AddSegment( matroska_segment_t *p_segment ) ...@@ -3557,16 +3567,17 @@ size_t virtual_segment_t::AddSegment( matroska_segment_t *p_segment )
} }
// find possible mates // find possible mates
for ( i=0; i<linked_segments.size(); i++ ) for ( i=0; i<linked_uids.size(); i++ )
{
if ( p_segment->segment_uid == linked_segments[i]->prev_segment_uid )
{ {
linked_segments.push_back( p_segment ); if ( p_segment->segment_uid == linked_uids[i]
return 1; || p_segment->prev_segment_uid == linked_uids[i]
} || p_segment->next_segment_uid == linked_uids[i] )
if ( p_segment->segment_uid == linked_segments[i]->next_segment_uid )
{ {
linked_segments.push_back( p_segment ); linked_segments.push_back( p_segment );
AppendUID( p_segment->prev_segment_uid );
AppendUID( p_segment->next_segment_uid );
return 1; return 1;
} }
} }
...@@ -3598,3 +3609,16 @@ void virtual_segment_t::LoadCues( ) ...@@ -3598,3 +3609,16 @@ void virtual_segment_t::LoadCues( )
linked_segments[i]->LoadCues(); linked_segments[i]->LoadCues();
} }
} }
void virtual_segment_t::AppendUID( const EbmlBinary & UID )
{
if ( UID.GetBuffer() == NULL )
return;
for (size_t i=0; i<linked_uids.size(); i++)
{
if ( UID == linked_uids[i] )
return;
}
linked_uids.push_back( *(KaxSegmentUID*)(&UID) );
}
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