[vlc-commits] mkv: add virtual_chapter_c::ContainsTimestamp() helper method

Steve Lhomme git at videolan.org
Thu Mar 17 16:58:27 CET 2016


vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Thu Mar 17 12:16:09 2016 +0100| [08d08dcc46521020341d944905c93b21a87604ee] | committer: Jean-Baptiste Kempf

mkv: add virtual_chapter_c::ContainsTimestamp() helper method

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

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

 modules/demux/mkv/virtual_segment.cpp |   14 +++++++++-----
 modules/demux/mkv/virtual_segment.hpp |    2 ++
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/modules/demux/mkv/virtual_segment.cpp b/modules/demux/mkv/virtual_segment.cpp
index e10b2ee..2ae194a 100644
--- a/modules/demux/mkv/virtual_segment.cpp
+++ b/modules/demux/mkv/virtual_segment.cpp
@@ -382,12 +382,18 @@ virtual_chapter_c * virtual_chapter_c::BrowseCodecPrivate( unsigned int codec_id
     return NULL;
 }
 
+bool virtual_chapter_c::ContainsTimestamp( int64_t time )
+{
+    /*with the current implementation only the last chapter can have a negative virtual_stop_time*/
+    return ( time >= i_mk_virtual_start_time &&
+        ( i_mk_virtual_stop_time < 0 || time < i_mk_virtual_stop_time ) );
+}
+
 virtual_chapter_c* virtual_chapter_c::getSubChapterbyTimecode( int64_t time )
 {
     for( size_t i = 0; i < sub_vchapters.size(); i++ )
     {
-        if( time >= sub_vchapters[i]->i_mk_virtual_start_time &&
-            ( sub_vchapters[i]->i_mk_virtual_stop_time < 0 || time < sub_vchapters[i]->i_mk_virtual_stop_time ) )
+        if( sub_vchapters[i]->ContainsTimestamp( time ) )
             return sub_vchapters[i]->getSubChapterbyTimecode( time );
     }
 
@@ -398,9 +404,7 @@ virtual_chapter_c* virtual_edition_c::getChapterbyTimecode( int64_t time )
 {
     for( size_t i = 0; i < vchapters.size(); i++ )
     {
-        if( time >= vchapters[i]->i_mk_virtual_start_time &&
-            ( vchapters[i]->i_mk_virtual_stop_time < 0 || time < vchapters[i]->i_mk_virtual_stop_time ) )
-            /*with the current implementation only the last chapter can have a negative virtual_stop_time*/
+        if( vchapters[i]->ContainsTimestamp( time ) )
             return vchapters[i]->getSubChapterbyTimecode( time );
     }
 
diff --git a/modules/demux/mkv/virtual_segment.hpp b/modules/demux/mkv/virtual_segment.hpp
index 4036d5e..320f4dd 100644
--- a/modules/demux/mkv/virtual_segment.hpp
+++ b/modules/demux/mkv/virtual_segment.hpp
@@ -67,6 +67,8 @@ public:
         return ( itemA->i_mk_virtual_start_time < itemB->i_mk_virtual_start_time );
     }
 
+    bool ContainsTimestamp( mtime_t i_pts );
+
     matroska_segment_c  &segment;
     chapter_item_c      *p_chapter;
     mtime_t             i_mk_virtual_start_time;



More information about the vlc-commits mailing list