[vlc-commits] [Git][videolan/vlc][master] 8 commits: demux: mkv: always go up a level when no element could be found

Steve Lhomme (@robUx4) gitlab at videolan.org
Sat May 30 11:36:27 UTC 2026



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
0556a12e by Steve Lhomme at 2026-05-30T11:22:45+00:00
demux: mkv: always go up a level when no element could be found

Even at the EOF the parser should be in a usable state.

- - - - -
c0e1c8d7 by Steve Lhomme at 2026-05-30T11:22:45+00:00
demux: mkv: do not use KaxBlockGroup in a Cluster without a timestamp

It should have been added in 3a9943c78c71339168ef515b8d61134e5d40732c as well.
We will not be able to use the KaxBlock and the related elements without that.

- - - - -
db619a02 by Steve Lhomme at 2026-05-30T11:22:45+00:00
demux: mkv: fix bogus string format

- - - - -
3a58e1d1 by Steve Lhomme at 2026-05-30T11:22:45+00:00
demux: mkv: tag format string parameters

- - - - -
2b45fa97 by Steve Lhomme at 2026-05-30T11:22:45+00:00
demux: mkv: add KaxContentCompSettings log

- - - - -
41c6adce by Steve Lhomme at 2026-05-30T11:22:45+00:00
demux: mkv: add consistency check

- - - - -
3b1c41ee by Steve Lhomme at 2026-05-30T11:22:45+00:00
demux: add some documentation

- - - - -
652a15cd by Steve Lhomme at 2026-05-30T11:22:45+00:00
demux: mkv: do not read data we won't use

The element will be skipped which might be slightly faster and will not
allocate a buffer for nothing.

- - - - -


6 changed files:

- modules/demux/mkv/Ebml_parser.cpp
- modules/demux/mkv/Ebml_parser.hpp
- modules/demux/mkv/matroska_segment.cpp
- modules/demux/mkv/matroska_segment_parse.cpp
- modules/demux/mkv/matroska_segment_seeker.cpp
- modules/demux/mkv/util.hpp


Changes:

=====================================
modules/demux/mkv/Ebml_parser.cpp
=====================================
@@ -242,7 +242,7 @@ next:
 
         if( m_el[mi_level] == NULL )
         {
-            if ( i_max_read != UINT64_MAX && !m_es->I_O().IsEOF() )
+            if ( i_max_read != UINT64_MAX )
             {
                 msg_Dbg(p_demux, "found nothing, go up");
                 i_ulev = 1;


=====================================
modules/demux/mkv/Ebml_parser.hpp
=====================================
@@ -41,6 +41,7 @@ class EbmlParser
 
     void Up( void );
     void Down( void );
+    ///< Reset the parser to the start of the Segment
     void Reset( demux_t *p_demux );
     EbmlElement *Get( bool allow_overshoot = true );
     void        Keep( void );


=====================================
modules/demux/mkv/matroska_segment.cpp
=====================================
@@ -167,23 +167,19 @@ void matroska_segment_c::LoadCues( KaxCues *cues )
 #if LIBMATROSKA_VERSION >= 0x010401
                             else if( MKV_CHECKED_PTR_DECL( cuerelative, KaxCueRelativePosition, el ) )
                             {
-                                // IGNORE
-                                cuerelative->ReadData( es.I_O() );
+                                VLC_UNUSED( cuerelative );
                             }
                             else if( MKV_CHECKED_PTR_DECL( cueblock, KaxCueBlockNumber, el ) )
                             {
-                                // IGNORE
-                                cueblock->ReadData( es.I_O() );
+                                VLC_UNUSED( cueblock );
                             }
                             else if( MKV_CHECKED_PTR_DECL( cueref, KaxCueReference, el ) )
                             {
-                                // IGNORE
-                                cueref->ReadData( es.I_O(), SCOPE_ALL_DATA );
+                                VLC_UNUSED( cueref );
                             }
                             else if( MKV_CHECKED_PTR_DECL( cueduration, KaxCueDuration, el ) )
                             {
-                                /* For future use */
-                                cueduration->ReadData( es.I_O() );
+                                VLC_UNUSED( cueduration );
                             }
 #endif
                             else
@@ -1230,6 +1226,12 @@ int matroska_segment_c::BlockGet( KaxBlock * & pp_block, KaxSimpleBlock * & pp_s
         }
         E_CASE( KaxBlockGroup, kbgroup )
         {
+            if( vars.b_cluster_timecode == false )
+            {
+                msg_Warn( vars.p_demuxer, "ignoring KaxBlockGroup prior to mandatory Timecode" );
+                return;
+            }
+
             vars.obj->i_block_pos = kbgroup.GetElementPosition();
             vars.ep->Down ();
         }


=====================================
modules/demux/mkv/matroska_segment_parse.cpp
=====================================
@@ -279,7 +279,7 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
     {
         MKV_SWITCH_INIT();
 
-        static void debug (MetaDataCapture const& vars, char const * fmt, ...)
+        static void debug (MetaDataCapture const& vars, char const * fmt, ...) VLC_FORMAT( 2, 3 )
         {
             va_list args; va_start( args, fmt );
             MkvTree_va( *vars.p_demuxer, vars.level, fmt, args);
@@ -494,6 +494,7 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
         }
         E_CASE( KaxContentCompSettings, kccs )
         {
+            debug( vars, "Compression Settings" );
             delete vars.tk->p_compression_data;
             vars.tk->p_compression_data = new KaxContentCompSettings( kccs );
         }
@@ -889,7 +890,7 @@ void matroska_segment_c::ParseTrackEntry( const KaxTrackEntry *m )
             if (vars.tk->fmt.video.primaries == COLOR_PRIMARIES_UNDEF)
                 debug( vars, "Unsupported Colour Primaries=%d", static_cast<uint8_t>(primaries) );
             else if (name == nullptr)
-                debug( vars, "Colour Primaries=%s", static_cast<uint8_t>(primaries) );
+                debug( vars, "Colour Primaries=%" PRIu8, static_cast<uint8_t>(primaries) );
             else
                 debug( vars, "Colour Primaries=%s", name );
         }
@@ -1218,7 +1219,7 @@ void matroska_segment_c::ParseInfo( KaxInfo *info )
     {
         MKV_SWITCH_INIT();
 
-        static void debug (InfoHandlerPayload& vars, char const * fmt, ...)
+        static void debug (InfoHandlerPayload& vars, char const * fmt, ...) VLC_FORMAT( 2, 3 )
         {
             va_list args; va_start( args, fmt );
             MkvTree_va( *vars.p_demuxer, 2, fmt, args);
@@ -1382,7 +1383,7 @@ void matroska_segment_c::ParseChapterAtom( int i_level, KaxChapterAtom *ca, chap
     {
         MKV_SWITCH_INIT();
 
-        static void debug (ChapterPayload const& vars, char const * fmt, ...)
+        static void debug (ChapterPayload const& vars, char const * fmt, ...) VLC_FORMAT( 2, 3 )
         {
             va_list args; va_start( args, fmt );
             MkvTree_va( *vars.p_demuxer, vars.level, fmt, args);


=====================================
modules/demux/mkv/matroska_segment_seeker.cpp
=====================================
@@ -518,6 +518,7 @@ SegmentSeeker::mkv_jump_to( matroska_segment_c& ms, fptr_t fpos )
         ms.es.I_O().setFilePointer(ms.cluster->GetDataStart());
     }
 
+    assert(ms.ep.GetLevel() == 1);
     ms.ep.Down();
 
     /* read until cluster/timecode to initialize cluster */


=====================================
modules/demux/mkv/util.hpp
=====================================
@@ -121,6 +121,6 @@ block_t * packetize_wavpack( const mkv_track_t &, uint8_t *, size_t);
 
 /* helper functions to print the mkv parse tree */
 void MkvTree_va( demux_t& demuxer, int i_level, const char* fmt, va_list args);
-void MkvTree( demux_t & demuxer, int i_level, const char *psz_format, ... );
+void MkvTree( demux_t & demuxer, int i_level, const char *psz_format, ... ) VLC_FORMAT( 3, 4 );
 
 } // namespace



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/88f2cd806ffe968ef019915cd28bbab2473c96ed...652a15cde1b8370e3321dea65aa4eb37d4eb7f4c

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/88f2cd806ffe968ef019915cd28bbab2473c96ed...652a15cde1b8370e3321dea65aa4eb37d4eb7f4c
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list