[vlc-devel] [PATCH] MKV: allow dummy elements in Tags to skip old deprecated elements
Steve Lhomme
robUx4 at videolabs.io
Fri Feb 27 16:30:08 CET 2015
---
modules/demux/mkv/Ebml_parser.cpp | 8 +++---
modules/demux/mkv/Ebml_parser.hpp | 3 +-
modules/demux/mkv/demux.cpp | 3 +-
modules/demux/mkv/matroska_segment.cpp | 41 ++++++++++++++++++----------
modules/demux/mkv/matroska_segment_parse.cpp | 3 +-
5 files changed, 37 insertions(+), 21 deletions(-)
diff --git a/modules/demux/mkv/Ebml_parser.cpp b/modules/demux/mkv/Ebml_parser.cpp
index b45a2d5..0561ad1 100644
--- a/modules/demux/mkv/Ebml_parser.cpp
+++ b/modules/demux/mkv/Ebml_parser.cpp
@@ -29,18 +29,19 @@
/*****************************************************************************
* 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 ),
m_es( es ),
mi_level( 1 ),
m_got( NULL ),
mi_user_level( 1 ),
- mb_keep( false )
+ mb_keep( false ),
+ mb_dummy( b_with_dummy )
{
mi_remain_size[0] = el_start->GetSize();
memset( m_el, 0, 6 * sizeof( *m_el ) );
m_el[0] = el_start;
- mb_dummy = var_InheritBool( p_demux, "mkv-use-dummy" );
}
EbmlParser::~EbmlParser( void )
@@ -143,7 +144,6 @@ void EbmlParser::Reset( demux_t *p_demux )
mi_user_level = mi_level = 1;
// a little faster and cleaner
m_es->I_O().setFilePointer( static_cast<KaxSegment*>(m_el[0])->GetGlobalPosition(0) );
- mb_dummy = var_InheritBool( p_demux, "mkv-use-dummy" );
}
diff --git a/modules/demux/mkv/Ebml_parser.hpp b/modules/demux/mkv/Ebml_parser.hpp
index 96f9f4b..3d68f5c 100644
--- a/modules/demux/mkv/Ebml_parser.hpp
+++ b/modules/demux/mkv/Ebml_parser.hpp
@@ -33,7 +33,8 @@
class EbmlParser
{
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 );
void Up( void );
diff --git a/modules/demux/mkv/demux.cpp b/modules/demux/mkv/demux.cpp
index 21618f4..b718d92 100644
--- a/modules/demux/mkv/demux.cpp
+++ b/modules/demux/mkv/demux.cpp
@@ -508,7 +508,8 @@ matroska_stream_c *demux_sys_t::AnalyseAllSegmentsFound( demux_t *p_demux, EbmlS
EbmlParser *ep;
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->segment = (KaxSegment*)p_l0;
diff --git a/modules/demux/mkv/matroska_segment.cpp b/modules/demux/mkv/matroska_segment.cpp
index 3f12c0e..617ad02 100644
--- a/modules/demux/mkv/matroska_segment.cpp
+++ b/modules/demux/mkv/matroska_segment.cpp
@@ -117,7 +117,8 @@ void matroska_segment_c::LoadCues( KaxCues *cues )
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 )
{
if( MKV_IS_ID( el, KaxCuePoint ) )
@@ -277,7 +278,8 @@ static const struct {
SimpleTag * matroska_segment_c::ParseSimpleTags( KaxTagSimple *tag, int target_type )
{
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;
size_t max_size = tag->GetSize();
size_t size = 0;
@@ -383,7 +385,7 @@ done:
void matroska_segment_c::LoadTags( KaxTags *tags )
{
/* Master elements */
- EbmlParser *ep = new EbmlParser( &es, tags, &sys.demuxer );
+ EbmlParser *ep = new EbmlParser( &es, tags, &sys.demuxer, true );
EbmlElement *el;
while( ( el = ep->Get() ) != NULL )
@@ -422,7 +424,7 @@ void matroska_segment_c::LoadTags( KaxTags *tags )
msg_Dbg( &sys.demuxer, "| | + TargetTypeValue: %u", 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;
KaxTagTrackUID &uid = *(KaxTagTrackUID*) el;
@@ -431,7 +433,7 @@ void matroska_segment_c::LoadTags( KaxTags *tags )
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;
KaxTagEditionUID &uid = *(KaxTagEditionUID*) el;
@@ -439,7 +441,7 @@ void matroska_segment_c::LoadTags( KaxTags *tags )
p_tag->i_uid = uint64( 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;
KaxTagChapterUID &uid = *(KaxTagChapterUID*) el;
@@ -447,7 +449,7 @@ void matroska_segment_c::LoadTags( KaxTags *tags )
p_tag->i_uid = uint64( 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;
KaxTagAttachmentUID &uid = *(KaxTagAttachmentUID*) el;
@@ -455,6 +457,10 @@ void matroska_segment_c::LoadTags( KaxTags *tags )
p_tag->i_uid = uint64( uid );
msg_Dbg( &sys.demuxer, "| | + AttachmentUID: %" PRIu64, p_tag->i_uid);
}
+ else
+ {
+ msg_Dbg( &sys.demuxer, "| | + LoadTag Unknown (%s)", typeid( *el ).name() );
+ }
}
catch(...)
{
@@ -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,
seek_beginning );
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;
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_
es.I_O().setFilePointer( i_start_pos );
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;
sys.i_start_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_
es.I_O().setFilePointer( i_seek_position, seek_beginning );
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;
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_
i_pts = 0;
es.I_O().setFilePointer( p_indexes[i_idx].i_position );
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;
}
@@ -1197,7 +1207,8 @@ void matroska_segment_c::EnsureDuration()
EbmlParser *ep;
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 )
{
@@ -1216,7 +1227,8 @@ void matroska_segment_c::EnsureDuration()
EbmlParser *ep;
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();
ParseCluster( p_last_cluster, false, SCOPE_PARTIAL_DATA );
@@ -1306,7 +1318,8 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
es.I_O().setFilePointer( i_start_pos );
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;
}
diff --git a/modules/demux/mkv/matroska_segment_parse.cpp b/modules/demux/mkv/matroska_segment_parse.cpp
index ff47a2b5..1c4d066 100644
--- a/modules/demux/mkv/matroska_segment_parse.cpp
+++ b/modules/demux/mkv/matroska_segment_parse.cpp
@@ -76,7 +76,8 @@ void matroska_segment_c::ParseSeekHead( KaxSeekHead *seekhead )
if( !b_seekable )
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 )
{
--
2.2.2
More information about the vlc-devel
mailing list