[vlc-devel] [PATCH 23/34] mkv: fix matroska_segment_c::ParseCluster to use new functionality

Filip Roséen filip at videolabs.io
Fri May 6 19:09:02 CEST 2016


Make use of _seeker in matroska_segment_c::ParseCluster, as well as
making the code a little bit more readable by using more descriptive
variable names.
---
 modules/demux/mkv/matroska_segment_parse.cpp | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/modules/demux/mkv/matroska_segment_parse.cpp b/modules/demux/mkv/matroska_segment_parse.cpp
index 8550c14..5727633 100644
--- a/modules/demux/mkv/matroska_segment_parse.cpp
+++ b/modules/demux/mkv/matroska_segment_parse.cpp
@@ -1193,20 +1193,18 @@ void matroska_segment_c::ParseChapters( KaxChapters *chapters )
 
 void matroska_segment_c::ParseCluster( KaxCluster *cluster, bool b_update_start_time, ScopeMode read_fully )
 {
-    EbmlElement *el;
-    EbmlMaster  *m;
-    int i_upper_level = 0;
-
-    /* Master elements */
-    m = static_cast<EbmlMaster *>( cluster );
-    if( unlikely( m->IsFiniteSize() && m->GetSize() >= SIZE_MAX ) )
+    if( unlikely( cluster->IsFiniteSize() && cluster->GetSize() >= SIZE_MAX ) )
     {
         msg_Err( &sys.demuxer, "Cluster too big, aborting" );
         return;
     }
+
     try
     {
-        m->Read( es, EBML_CONTEXT(cluster), i_upper_level, el, true, read_fully );
+        EbmlElement *el;
+        int i_upper_level = 0;
+
+        cluster->Read( es, EBML_CONTEXT(cluster), i_upper_level, el, true, read_fully );
     }
     catch(...)
     {
@@ -1214,21 +1212,18 @@ void matroska_segment_c::ParseCluster( KaxCluster *cluster, bool b_update_start_
         return;
     }
 
-    for( unsigned int i = 0; i < m->ListSize(); i++ )
+    for( unsigned int i = 0; i < cluster->ListSize(); ++i )
     {
-        EbmlElement *l = (*m)[i];
-
-        if( MKV_IS_ID( l, KaxClusterTimecode ) )
+        if( MKV_CHECKED_PTR_DECL( p_ctc, KaxClusterTimecode, (*cluster)[i] ) )
         {
-            KaxClusterTimecode &ctc = *static_cast<KaxClusterTimecode*>( l );
-
-            cluster->InitTimecode( static_cast<uint64>( ctc ), i_timescale );
+            cluster->InitTimecode( static_cast<uint64>( *p_ctc ), i_timescale );
+            _seeker.add_cluster( cluster );
             break;
         }
     }
 
     if( b_update_start_time )
-        i_mk_start_time = cluster->GlobalTimecode() / 1000;
+        i_mk_start_time = cluster->GlobalTimecode() / INT64_C( 1000 );
 }
 
 
-- 
2.8.2



More information about the vlc-devel mailing list