[vlc-devel] [PATCH 02/14] mkv: make sure indexes are in order

Filip Roséen filip at videolabs.io
Wed Mar 9 12:49:57 CET 2016


This patch will protect us from seeking too far if a mkv-files contains
Cues that are not in ascending order.
---
 modules/demux/mkv/matroska_segment.cpp | 3 +++
 modules/demux/mkv/mkv.hpp              | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/modules/demux/mkv/matroska_segment.cpp b/modules/demux/mkv/matroska_segment.cpp
index 64d775b..5137ef4 100644
--- a/modules/demux/mkv/matroska_segment.cpp
+++ b/modules/demux/mkv/matroska_segment.cpp
@@ -229,6 +229,7 @@ void matroska_segment_c::LoadCues( KaxCues *cues )
     }
     b_cues = true;
     msg_Dbg( &sys.demuxer, "|   - loading cues done." );
+    std::sort( indexes_begin(), indexes_end() );
 }
 
 
@@ -875,6 +876,8 @@ void matroska_segment_c::Seek( mtime_t i_mk_date, mtime_t i_mk_time_offset, int6
                     break;
             }
         }
+
+        std::sort( indexes_begin(), indexes_end() );
     }
 
     /* Don't try complex seek if we seek to 0 */
diff --git a/modules/demux/mkv/mkv.hpp b/modules/demux/mkv/mkv.hpp
index ddaa60f..c55a83a 100644
--- a/modules/demux/mkv/mkv.hpp
+++ b/modules/demux/mkv/mkv.hpp
@@ -246,6 +246,10 @@ struct mkv_index_t
     mtime_t i_mk_time;
 
     bool       b_key;
+
+    bool operator< (mkv_index_t const& rhs) const {
+        return i_mk_time < rhs.i_mk_time;
+    }
 };
 
 
-- 
2.7.2



More information about the vlc-devel mailing list