Commit 5d0a4cf2 authored by Steve Lhomme's avatar Steve Lhomme Committed by Jean-Baptiste Kempf

MKV: allow dummy elements in Tags to skip old deprecated elements

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 68181f9c
...@@ -29,18 +29,19 @@ ...@@ -29,18 +29,19 @@
/***************************************************************************** /*****************************************************************************
* Ebml Stream parser * Ebml Stream parser
*****************************************************************************/ *****************************************************************************/
EbmlParser::EbmlParser( EbmlStream *es, EbmlElement *el_start, demux_t *p_demux ) : EbmlParser::EbmlParser( EbmlStream *es, EbmlElement *el_start, demux_t *p_demux,
bool b_with_dummy ) :
p_demux( p_demux ), p_demux( p_demux ),
m_es( es ), m_es( es ),
mi_level( 1 ), mi_level( 1 ),
m_got( NULL ), m_got( NULL ),
mi_user_level( 1 ), mi_user_level( 1 ),
mb_keep( false ) mb_keep( false ),
mb_dummy( b_with_dummy )
{ {
mi_remain_size[0] = el_start->GetSize(); mi_remain_size[0] = el_start->GetSize();
memset( m_el, 0, 6 * sizeof( *m_el ) ); memset( m_el, 0, 6 * sizeof( *m_el ) );
m_el[0] = el_start; m_el[0] = el_start;
mb_dummy = var_InheritBool( p_demux, "mkv-use-dummy" );
} }
EbmlParser::~EbmlParser( void ) EbmlParser::~EbmlParser( void )
...@@ -143,7 +144,6 @@ void EbmlParser::Reset( demux_t *p_demux ) ...@@ -143,7 +144,6 @@ void EbmlParser::Reset( demux_t *p_demux )
mi_user_level = mi_level = 1; mi_user_level = mi_level = 1;
// a little faster and cleaner // a little faster and cleaner
m_es->I_O().setFilePointer( static_cast<KaxSegment*>(m_el[0])->GetGlobalPosition(0) ); m_es->I_O().setFilePointer( static_cast<KaxSegment*>(m_el[0])->GetGlobalPosition(0) );
mb_dummy = var_InheritBool( p_demux, "mkv-use-dummy" );
} }
......
...@@ -33,7 +33,8 @@ ...@@ -33,7 +33,8 @@
class EbmlParser class EbmlParser
{ {
public: public:
EbmlParser( EbmlStream *es, EbmlElement *el_start, demux_t *p_demux ); EbmlParser( EbmlStream *es, EbmlElement *el_start, demux_t *p_demux,
bool b_with_dummy );
~EbmlParser( void ); ~EbmlParser( void );
void Up( void ); void Up( void );
......
...@@ -508,7 +508,8 @@ matroska_stream_c *demux_sys_t::AnalyseAllSegmentsFound( demux_t *p_demux, EbmlS ...@@ -508,7 +508,8 @@ matroska_stream_c *demux_sys_t::AnalyseAllSegmentsFound( demux_t *p_demux, EbmlS
EbmlParser *ep; EbmlParser *ep;
matroska_segment_c *p_segment1 = new matroska_segment_c( *this, *p_estream ); matroska_segment_c *p_segment1 = new matroska_segment_c( *this, *p_estream );
ep = new EbmlParser(p_estream, p_l0, &demuxer ); ep = new EbmlParser(p_estream, p_l0, &demuxer,
var_InheritBool( &demuxer, "mkv-use-dummy" ) );
p_segment1->ep = ep; p_segment1->ep = ep;
p_segment1->segment = (KaxSegment*)p_l0; p_segment1->segment = (KaxSegment*)p_l0;
......
...@@ -117,7 +117,8 @@ void matroska_segment_c::LoadCues( KaxCues *cues ) ...@@ -117,7 +117,8 @@ void matroska_segment_c::LoadCues( KaxCues *cues )
return; return;
} }
ep = new EbmlParser( &es, cues, &sys.demuxer ); ep = new EbmlParser( &es, cues, &sys.demuxer,
var_InheritBool( &sys.demuxer, "mkv-use-dummy" ) );
while( ( el = ep->Get() ) != NULL ) while( ( el = ep->Get() ) != NULL )
{ {
if( MKV_IS_ID( el, KaxCuePoint ) ) if( MKV_IS_ID( el, KaxCuePoint ) )
...@@ -277,7 +278,8 @@ static const struct { ...@@ -277,7 +278,8 @@ static const struct {
SimpleTag * matroska_segment_c::ParseSimpleTags( KaxTagSimple *tag, int target_type ) SimpleTag * matroska_segment_c::ParseSimpleTags( KaxTagSimple *tag, int target_type )
{ {
EbmlElement *el; EbmlElement *el;
EbmlParser *ep = new EbmlParser( &es, tag, &sys.demuxer ); EbmlParser *ep = new EbmlParser( &es, tag, &sys.demuxer,
var_InheritBool( &sys.demuxer, "mkv-use-dummy" ) );
SimpleTag * p_simple = new SimpleTag; SimpleTag * p_simple = new SimpleTag;
size_t max_size = tag->GetSize(); size_t max_size = tag->GetSize();
size_t size = 0; size_t size = 0;
...@@ -383,7 +385,7 @@ done: ...@@ -383,7 +385,7 @@ done:
void matroska_segment_c::LoadTags( KaxTags *tags ) void matroska_segment_c::LoadTags( KaxTags *tags )
{ {
/* Master elements */ /* Master elements */
EbmlParser *ep = new EbmlParser( &es, tags, &sys.demuxer ); EbmlParser *ep = new EbmlParser( &es, tags, &sys.demuxer, true );
EbmlElement *el; EbmlElement *el;
while( ( el = ep->Get() ) != NULL ) while( ( el = ep->Get() ) != NULL )
...@@ -422,7 +424,7 @@ void matroska_segment_c::LoadTags( KaxTags *tags ) ...@@ -422,7 +424,7 @@ void matroska_segment_c::LoadTags( KaxTags *tags )
msg_Dbg( &sys.demuxer, "| | + TargetTypeValue: %u", uint32(value)); msg_Dbg( &sys.demuxer, "| | + TargetTypeValue: %u", uint32(value));
target_type = uint32(value); target_type = uint32(value);
} }
if( MKV_IS_ID( el, KaxTagTrackUID ) ) else if( MKV_IS_ID( el, KaxTagTrackUID ) )
{ {
p_tag->i_tag_type = TRACK_UID; p_tag->i_tag_type = TRACK_UID;
KaxTagTrackUID &uid = *(KaxTagTrackUID*) el; KaxTagTrackUID &uid = *(KaxTagTrackUID*) el;
...@@ -431,7 +433,7 @@ void matroska_segment_c::LoadTags( KaxTags *tags ) ...@@ -431,7 +433,7 @@ void matroska_segment_c::LoadTags( KaxTags *tags )
msg_Dbg( &sys.demuxer, "| | + TrackUID: %" PRIu64, p_tag->i_uid); msg_Dbg( &sys.demuxer, "| | + TrackUID: %" PRIu64, p_tag->i_uid);
} }
if( MKV_IS_ID( el, KaxTagEditionUID ) ) else if( MKV_IS_ID( el, KaxTagEditionUID ) )
{ {
p_tag->i_tag_type = EDITION_UID; p_tag->i_tag_type = EDITION_UID;
KaxTagEditionUID &uid = *(KaxTagEditionUID*) el; KaxTagEditionUID &uid = *(KaxTagEditionUID*) el;
...@@ -439,7 +441,7 @@ void matroska_segment_c::LoadTags( KaxTags *tags ) ...@@ -439,7 +441,7 @@ void matroska_segment_c::LoadTags( KaxTags *tags )
p_tag->i_uid = uint64( uid ); p_tag->i_uid = uint64( uid );
msg_Dbg( &sys.demuxer, "| | + EditionUID: %" PRIu64, p_tag->i_uid); msg_Dbg( &sys.demuxer, "| | + EditionUID: %" PRIu64, p_tag->i_uid);
} }
if( MKV_IS_ID( el, KaxTagChapterUID ) ) else if( MKV_IS_ID( el, KaxTagChapterUID ) )
{ {
p_tag->i_tag_type = CHAPTER_UID; p_tag->i_tag_type = CHAPTER_UID;
KaxTagChapterUID &uid = *(KaxTagChapterUID*) el; KaxTagChapterUID &uid = *(KaxTagChapterUID*) el;
...@@ -447,7 +449,7 @@ void matroska_segment_c::LoadTags( KaxTags *tags ) ...@@ -447,7 +449,7 @@ void matroska_segment_c::LoadTags( KaxTags *tags )
p_tag->i_uid = uint64( uid ); p_tag->i_uid = uint64( uid );
msg_Dbg( &sys.demuxer, "| | + ChapterUID: %" PRIu64, p_tag->i_uid); msg_Dbg( &sys.demuxer, "| | + ChapterUID: %" PRIu64, p_tag->i_uid);
} }
if( MKV_IS_ID( el, KaxTagAttachmentUID ) ) else if( MKV_IS_ID( el, KaxTagAttachmentUID ) )
{ {
p_tag->i_tag_type = ATTACHMENT_UID; p_tag->i_tag_type = ATTACHMENT_UID;
KaxTagAttachmentUID &uid = *(KaxTagAttachmentUID*) el; KaxTagAttachmentUID &uid = *(KaxTagAttachmentUID*) el;
...@@ -455,6 +457,10 @@ void matroska_segment_c::LoadTags( KaxTags *tags ) ...@@ -455,6 +457,10 @@ void matroska_segment_c::LoadTags( KaxTags *tags )
p_tag->i_uid = uint64( uid ); p_tag->i_uid = uint64( uid );
msg_Dbg( &sys.demuxer, "| | + AttachmentUID: %" PRIu64, p_tag->i_uid); msg_Dbg( &sys.demuxer, "| | + AttachmentUID: %" PRIu64, p_tag->i_uid);
} }
else
{
msg_Dbg( &sys.demuxer, "| | + LoadTag Unknown (%s)", typeid( *el ).name() );
}
} }
catch(...) catch(...)
{ {
...@@ -876,7 +882,8 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_ ...@@ -876,7 +882,8 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_
es.I_O().setFilePointer( p_indexes[ i_index - 1 ].i_position, es.I_O().setFilePointer( p_indexes[ i_index - 1 ].i_position,
seek_beginning ); seek_beginning );
delete ep; delete ep;
ep = new EbmlParser( &es, segment, &sys.demuxer ); ep = new EbmlParser( &es, segment, &sys.demuxer,
var_InheritBool( &sys.demuxer, "mkv-use-dummy" ) );
cluster = NULL; cluster = NULL;
while( ( el = ep->Get() ) != NULL ) while( ( el = ep->Get() ) != NULL )
...@@ -907,7 +914,8 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_ ...@@ -907,7 +914,8 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_
es.I_O().setFilePointer( i_start_pos ); es.I_O().setFilePointer( i_start_pos );
delete ep; delete ep;
ep = new EbmlParser( &es, segment, &sys.demuxer ); ep = new EbmlParser( &es, segment, &sys.demuxer,
var_InheritBool( &sys.demuxer, "mkv-use-dummy" ) );
cluster = NULL; cluster = NULL;
sys.i_start_pts = 0; sys.i_start_pts = 0;
sys.i_pts = 0; sys.i_pts = 0;
...@@ -935,7 +943,8 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_ ...@@ -935,7 +943,8 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_
es.I_O().setFilePointer( i_seek_position, seek_beginning ); es.I_O().setFilePointer( i_seek_position, seek_beginning );
delete ep; delete ep;
ep = new EbmlParser( &es, segment, &sys.demuxer ); ep = new EbmlParser( &es, segment, &sys.demuxer,
var_InheritBool( &sys.demuxer, "mkv-use-dummy" ) );
cluster = NULL; cluster = NULL;
sys.i_start_pts = i_date; sys.i_start_pts = i_date;
...@@ -1056,7 +1065,8 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_ ...@@ -1056,7 +1065,8 @@ void matroska_segment_c::Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_
i_pts = 0; i_pts = 0;
es.I_O().setFilePointer( p_indexes[i_idx].i_position ); es.I_O().setFilePointer( p_indexes[i_idx].i_position );
delete ep; delete ep;
ep = new EbmlParser( &es, segment, &sys.demuxer ); ep = new EbmlParser( &es, segment, &sys.demuxer,
var_InheritBool( &sys.demuxer, "mkv-use-dummy" ) );
cluster = NULL; cluster = NULL;
} }
...@@ -1197,7 +1207,8 @@ void matroska_segment_c::EnsureDuration() ...@@ -1197,7 +1207,8 @@ void matroska_segment_c::EnsureDuration()
EbmlParser *ep; EbmlParser *ep;
es.I_O().setFilePointer( cluster->GetElementPosition(), seek_beginning ); es.I_O().setFilePointer( cluster->GetElementPosition(), seek_beginning );
ep = new EbmlParser( &es , segment, &sys.demuxer ); ep = new EbmlParser( &es , segment, &sys.demuxer,
var_InheritBool( &sys.demuxer, "mkv-use-dummy" ) );
while( ( el = ep->Get() ) != NULL ) while( ( el = ep->Get() ) != NULL )
{ {
...@@ -1216,7 +1227,8 @@ void matroska_segment_c::EnsureDuration() ...@@ -1216,7 +1227,8 @@ void matroska_segment_c::EnsureDuration()
EbmlParser *ep; EbmlParser *ep;
es.I_O().setFilePointer( i_last_cluster_pos, seek_beginning ); es.I_O().setFilePointer( i_last_cluster_pos, seek_beginning );
ep = new EbmlParser( &es , segment, &sys.demuxer ); ep = new EbmlParser( &es , segment, &sys.demuxer,
var_InheritBool( &sys.demuxer, "mkv-use-dummy" ) );
KaxCluster *p_last_cluster = (KaxCluster *) ep->Get(); KaxCluster *p_last_cluster = (KaxCluster *) ep->Get();
ParseCluster( p_last_cluster, false, SCOPE_PARTIAL_DATA ); ParseCluster( p_last_cluster, false, SCOPE_PARTIAL_DATA );
...@@ -1306,7 +1318,8 @@ bool matroska_segment_c::Select( mtime_t i_start_time ) ...@@ -1306,7 +1318,8 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
es.I_O().setFilePointer( i_start_pos ); es.I_O().setFilePointer( i_start_pos );
delete ep; delete ep;
ep = new EbmlParser( &es, segment, &sys.demuxer ); ep = new EbmlParser( &es, segment, &sys.demuxer,
var_InheritBool( &sys.demuxer, "mkv-use-dummy" ) );
return true; return true;
} }
......
...@@ -76,7 +76,8 @@ void matroska_segment_c::ParseSeekHead( KaxSeekHead *seekhead ) ...@@ -76,7 +76,8 @@ void matroska_segment_c::ParseSeekHead( KaxSeekHead *seekhead )
if( !b_seekable ) if( !b_seekable )
return; return;
ep = new EbmlParser( &es, seekhead, &sys.demuxer ); ep = new EbmlParser( &es, seekhead, &sys.demuxer,
var_InheritBool( &sys.demuxer, "mkv-use-dummy" ) );
while( ( l = ep->Get() ) != NULL ) while( ( l = ep->Get() ) != NULL )
{ {
......
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