demux/mkv: do not calculate duration for infinite clusters
authorFilip Roséen <filip@atch.se>
Sat, 22 Oct 2016 02:54:11 +0000 (04:54 +0200)
committerThomas Guillem <thomas@gllm.fr>
Wed, 26 Oct 2016 14:30:02 +0000 (16:30 +0200)
It does not make sense trying to calculate the duration for something
for which there is no end, as such we should protect ourselves from
wasting our breath.

Signed-off-by: Steve Lhomme <robux4@videolabs.io>
Signed-off-by: Thomas Guillem <thomas@gllm.fr>
modules/demux/mkv/matroska_segment.cpp

index 3e0bb4e..f2557a0 100644 (file)
@@ -686,7 +686,8 @@ bool matroska_segment_c::Preload( )
 
     b_preloaded = true;
 
-    EnsureDuration();
+    if( cluster == NULL || cluster->IsFiniteSize() )
+        EnsureDuration();
 
     return true;
 }
@@ -1026,6 +1027,12 @@ void matroska_segment_c::EnsureDuration()
             return;
         ParseCluster( p_last_cluster, false, SCOPE_PARTIAL_DATA );
 
+        if( p_last_cluster->IsFiniteSize() == false )
+        {
+            es.I_O().setFilePointer( i_current_position, seek_beginning );
+            return;
+        }
+
         // use the last block + duration
         uint64 i_last_timecode = p_last_cluster->GlobalTimecode();
         for( unsigned int i = 0; i < p_last_cluster->ListSize(); i++ )