]> git.sesse.net Git - vlc/commitdiff
MKV: Don't allow Matroska Void/CRC32 elements fallback when looking for a level 1...
authorSteve Lhomme <robux4@gmail.com>
Wed, 18 Feb 2015 16:12:33 +0000 (16:12 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Fri, 20 Feb 2015 14:33:48 +0000 (15:33 +0100)
Slightly better version with the right macros to access the semantic
context master.

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/demux/mkv/Ebml_parser.cpp
modules/demux/mkv/Ebml_parser.hpp

index 21e219e1432a6e2fe829ec3a900aa8f2277fef62..a42b9369162271898354edfd9f313aee81e942b9 100644 (file)
@@ -146,6 +146,28 @@ void EbmlParser::Reset( demux_t *p_demux )
     mb_dummy = var_InheritBool( p_demux, "mkv-use-dummy" );
 }
 
+
+// Define a special Segment context that doesn't allow void/crc32 elements
+static const EbmlSemanticContext & GetEbmlNoGlobal_Context();
+static const EbmlSemanticContext Context_EbmlNoGlobal = EbmlSemanticContext(0, NULL, NULL, *GetEbmlNoGlobal_Context, NULL);
+static const EbmlSemantic EbmlNoGlobal_ContextList[0] =
+{
+  //EbmlSemantic(false, false, EBML_INFO(EbmlCrc32)),   ///< EbmlCrc32
+  //EbmlSemantic(false, false, EBML_INFO(EbmlVoid)),    ///< EbmlVoid
+};
+static const EbmlSemanticContext EbmlNoGlobal_Context = EbmlSemanticContext(countof(EbmlNoGlobal_ContextList), EbmlNoGlobal_ContextList, NULL, *GetEbmlNoGlobal_Context, NULL);
+static const EbmlSemanticContext & GetEbmlNoGlobal_Context()
+{
+  return EbmlNoGlobal_Context;
+}
+
+// the Segment Context should not allow Void or CRC32 elements to avoid lookup false alarm
+const EbmlSemanticContext Context_KaxSegmentVLC = EbmlSemanticContext(KaxSegment_Context.GetSize(),
+                                                                      KaxSegment_Context.MyTable,
+                                                                      KaxSegment_Context.Parent(),
+                                                                      GetEbmlNoGlobal_Context,
+                                                                      KaxSegment_Context.GetMaster());
+
 EbmlElement *EbmlParser::Get( int n_call )
 {
     int i_ulev = 0;
@@ -170,8 +192,13 @@ EbmlElement *EbmlParser::Get( int n_call )
 
     }
 
+    // ignore global Void/CRC32 elements when looking for level 1 elements in the Segment
+    EbmlSemanticContext e_context =
+            EBML_CTX_MASTER( EBML_CONTEXT(m_el[mi_level - 1]) ) == EBML_CTX_MASTER( Context_KaxSegmentVLC )
+            ? Context_KaxSegmentVLC
+            : EBML_CONTEXT(m_el[mi_level - 1]);
     /* Ignore unknown level 0 or 1 elements */
-    m_el[mi_level] = m_es->FindNextElement( EBML_CONTEXT(m_el[mi_level - 1]),
+    m_el[mi_level] = m_es->FindNextElement( e_context,
                                             i_ulev, UINT64_MAX,
                                             (  mb_dummy | (mi_level > 1) ), 1 );
     if( i_ulev > 0 )
index 57fdf232203c2a7db598b88d773555f3563ddecd..96f9f4bed857670469836c8d8321add2196ea40c 100644 (file)
@@ -60,6 +60,7 @@ class EbmlParser
 
     int          mi_user_level;
     bool         mb_keep;
+    /* Allow dummy/unknown EBML elements */
     bool         mb_dummy;
 };