[vlc-devel] [PATCH 23/30] mkv: skip decoding of blocks that are not necessary

Filip Roséen filip at videolabs.io
Mon May 9 14:53:17 CEST 2016


Since the seeking algorithm(s) will set track.i_skip_until_fpos to a
value other than uint64_t( -1 ) (equivalent of the usage of
std::numeric_limits), we can ignore blocks with a lower file-position in
the Demuxer (and hence not send them to the decoder).

This will save us some time, while maintaining the proper state of the
relevant decoders.
---
 modules/demux/mkv/mkv.cpp | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/modules/demux/mkv/mkv.cpp b/modules/demux/mkv/mkv.cpp
index c064376..d85f809 100644
--- a/modules/demux/mkv/mkv.cpp
+++ b/modules/demux/mkv/mkv.cpp
@@ -736,8 +736,35 @@ static int Demux( demux_t *p_demux)
         return 0;
     }
 
+    {
+        matroska_segment_c::tracks_map_t::iterator track_it;
+
+        if( p_segment->FindTrackByBlock( &track_it, block, simpleblock ) )
+        {
+            msg_Err( p_demux, "invalid track number" );
+            delete block;
+            return 0;
+        }
+
+        matroska_segment_c::tracks_map_t::mapped_type& track = track_it->second;
+
+
+        if( track.i_skip_until_fpos != std::numeric_limits<uint64_t>::max() ) {
 
+            uint64_t block_fpos = 0;
 
+            if( block ) block_fpos = block->GetElementPosition();
+            else        block_fpos = simpleblock->GetElementPosition();
+
+            if ( track.i_skip_until_fpos > block_fpos )
+            {
+                delete block;
+                return 1; // this block shall be ignored
+            }
+
+            track.i_skip_until_fpos = -1;
+        }
+    }
 
     /* update pcr */
     {
-- 
2.8.2



More information about the vlc-devel mailing list