[vlc-commits] mkv: removed unnecessary complexity in Ebml_parser.cpp

Filip Roséen git at videolan.org
Tue Feb 21 16:24:52 CET 2017


vlc | branch: master | Filip Roséen <filip at videolabs.io> | Mon May  9 14:53:21 2016 +0200| [2bebd4d1b3fc65b5527e79f6f771ae804126dedd] | committer: Jean-Baptiste Kempf

mkv: removed unnecessary complexity in Ebml_parser.cpp

For starters it is ill-formed to have zero-sized arrays according to the
ISO C++ Standard, but most importantly the code is unnecessary complex
since there is no need for the array at all (given that the elements
inside of it has been commented out).

This commit also changes a comment which has not been accurate for a
long time, though it would be possible to simplify the code in question
-- it is hard to prove that the behavior will not change, and as such it
has been left as is.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2bebd4d1b3fc65b5527e79f6f771ae804126dedd
---

 modules/demux/mkv/Ebml_parser.cpp | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/modules/demux/mkv/Ebml_parser.cpp b/modules/demux/mkv/Ebml_parser.cpp
index 822c1c7..4e16c4b 100644
--- a/modules/demux/mkv/Ebml_parser.cpp
+++ b/modules/demux/mkv/Ebml_parser.cpp
@@ -123,15 +123,8 @@ void EbmlParser::Reset( demux_t *p_demux )
 }
 
 
-// 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 EbmlNoGlobal_Context = EbmlSemanticContext(0, NULL, NULL, *GetEbmlNoGlobal_Context, NULL);
 static const EbmlSemanticContext & GetEbmlNoGlobal_Context()
 {
   return EbmlNoGlobal_Context;
@@ -168,11 +161,13 @@ EbmlElement *EbmlParser::Get( int n_call )
 
     }
 
-    // ignore global Void/CRC32 elements when looking for level 1 elements in the Segment
+    // If the parent is a segment, use the segment context when creating children
+    // (to prolong their lifetime), otherwise just continue as normal
     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( e_context,
                                             i_ulev, UINT64_MAX,



More information about the vlc-commits mailing list