[vlc-commits] mkv: make sure indexes are in order

Filip Roséen git at videolan.org
Fri Mar 11 16:03:05 CET 2016


vlc | branch: master | Filip Roséen <filip at videolabs.io> | Wed Mar  9 12:49:57 2016 +0100| [938eb73ecd0732cc2392f9eba6bf4cdd1aaec4f9] | committer: Jean-Baptiste Kempf

mkv: make sure indexes are in order

This patch will protect us from seeking too far if a mkv-files contains
Cues that are not in ascending order.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=938eb73ecd0732cc2392f9eba6bf4cdd1aaec4f9
---

 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 dedd4d5..7473668 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() );
 }
 
 
@@ -800,6 +801,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;
+    }
 };
 
 



More information about the vlc-commits mailing list