Commit 44a1c7bd authored by Steve Lhomme's avatar Steve Lhomme

mkv.cpp: chapter merging works + small fixes

parent 10b8c360
...@@ -339,6 +339,8 @@ public: ...@@ -339,6 +339,8 @@ public:
int64_t RefreshChapters( bool b_ordered, int64_t i_prev_user_time ); int64_t RefreshChapters( bool b_ordered, int64_t i_prev_user_time );
void PublishChapters( input_title_t & title, int i_level ); void PublishChapters( input_title_t & title, int i_level );
const chapter_item_t * FindTimecode( mtime_t i_timecode ) const; const chapter_item_t * FindTimecode( mtime_t i_timecode ) const;
void Append( const chapter_item_t & edition );
chapter_item_t * FindChapter( const chapter_item_t & chapter );
int64_t i_start_time, i_end_time; int64_t i_start_time, i_end_time;
int64_t i_user_start_time, i_user_end_time; /* the time in the stream when an edition is ordered */ int64_t i_user_start_time, i_user_end_time; /* the time in the stream when an edition is ordered */
...@@ -369,8 +371,6 @@ public: ...@@ -369,8 +371,6 @@ public:
void RefreshChapters( ); void RefreshChapters( );
mtime_t Duration() const; mtime_t Duration() const;
void PublishChapters( input_title_t & title ); void PublishChapters( input_title_t & title );
void Append( const chapter_edition_t & edition );
chapter_item_t * FindChapter( const chapter_item_t & chapter ) const;
bool b_ordered; bool b_ordered;
}; };
...@@ -1604,7 +1604,6 @@ bool virtual_segment_t::Select( input_title_t & title ) ...@@ -1604,7 +1604,6 @@ bool virtual_segment_t::Select( input_title_t & title )
// copy editions from the first segment // copy editions from the first segment
p_segment = linked_segments[0]; p_segment = linked_segments[0];
editions = p_segment->stored_editions; editions = p_segment->stored_editions;
i_current_edition = p_segment->i_default_edition;
for ( i=1 ; i<linked_segments.size(); i++ ) for ( i=1 ; i<linked_segments.size(); i++ )
{ {
...@@ -1641,10 +1640,10 @@ void chapter_item_t::PublishChapters( input_title_t & title, int i_level ) ...@@ -1641,10 +1640,10 @@ void chapter_item_t::PublishChapters( input_title_t & title, int i_level )
title.i_seekpoint++; title.i_seekpoint++;
title.seekpoint = (seekpoint_t**)realloc( title.seekpoint, title.i_seekpoint * sizeof( seekpoint_t* ) ); title.seekpoint = (seekpoint_t**)realloc( title.seekpoint, title.i_seekpoint * sizeof( seekpoint_t* ) );
title.seekpoint[title.i_seekpoint-1] = sk; title.seekpoint[title.i_seekpoint-1] = sk;
i_seekpoint_num = title.i_seekpoint;
} }
i_seekpoint_num = title.i_seekpoint;
for ( size_t i=0; i<sub_chapters.size() ; i++) for ( size_t i=0; i<sub_chapters.size() ; i++)
{ {
sub_chapters[i].PublishChapters( title, i_level+1 ); sub_chapters[i].PublishChapters( title, i_level+1 );
...@@ -1687,25 +1686,37 @@ void virtual_segment_t::UpdateCurrentToChapter( demux_t & demux ) ...@@ -1687,25 +1686,37 @@ void virtual_segment_t::UpdateCurrentToChapter( demux_t & demux )
} }
} }
void chapter_edition_t::Append( const chapter_edition_t & edition ) void chapter_item_t::Append( const chapter_item_t & chapter )
{ {
// we are appending content for the same chapter UID
size_t i; size_t i;
chapter_item_t *p_chapter; chapter_item_t *p_chapter;
for ( i=0; i<edition.sub_chapters.size(); i++ ) for ( i=0; i<chapter.sub_chapters.size(); i++ )
{ {
p_chapter = FindChapter( edition.sub_chapters[i] ); p_chapter = FindChapter( chapter.sub_chapters[i] );
if ( p_chapter != NULL ) if ( p_chapter != NULL )
{ {
p_chapter->Append( chapter.sub_chapters[i] );
} }
else else
{ {
sub_chapters.push_back( chapter.sub_chapters[i] );
} }
} }
i_user_start_time = min( i_user_start_time, chapter.i_user_start_time );
i_user_end_time = max( i_user_end_time, chapter.i_user_end_time );
} }
chapter_item_t * chapter_edition_t::FindChapter( const chapter_item_t & chapter ) const chapter_item_t * chapter_item_t::FindChapter( const chapter_item_t & chapter )
{ {
size_t i;
for ( i=0; i<sub_chapters.size(); i++)
{
if ( sub_chapters[i].i_uid == chapter.i_uid )
return &sub_chapters[i];
}
return NULL; return NULL;
} }
...@@ -3587,6 +3598,7 @@ void virtual_segment_t::PreloadLinked( ) ...@@ -3587,6 +3598,7 @@ void virtual_segment_t::PreloadLinked( )
{ {
linked_segments[i]->Preload( ); linked_segments[i]->Preload( );
} }
i_current_edition = linked_segments[0]->i_default_edition;
} }
mtime_t virtual_segment_t::Duration() const mtime_t virtual_segment_t::Duration() const
......
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