[vlc-devel] [PATCH 1/2] mkv: only jump on known chapters from chapter commands

Steve Lhomme robux4 at videolabs.io
Thu Mar 17 15:11:02 CET 2016


---
 modules/demux/mkv/chapter_command.cpp | 14 +++++++-------
 modules/demux/mkv/demux.cpp           | 12 ++++--------
 modules/demux/mkv/demux.hpp           |  2 +-
 3 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/modules/demux/mkv/chapter_command.cpp b/modules/demux/mkv/chapter_command.cpp
index 966c339..ab49ad5 100644
--- a/modules/demux/mkv/chapter_command.cpp
+++ b/modules/demux/mkv/chapter_command.cpp
@@ -308,9 +308,9 @@ bool dvd_command_interpretor_c::Interpret( const binary * p_command, size_t i_si
 
             // find in the ChapProcessPrivate matching this Title level
             p_vchapter = sys.BrowseCodecPrivate( 1, MatchTitleNumber, &i_title, sizeof(i_title), p_vsegment );
-            if ( p_vsegment != NULL )
+            if ( p_vsegment != NULL && p_vchapter != NULL )
             {
-                sys.JumpTo( *p_vsegment, p_vchapter );
+                sys.JumpTo( *p_vsegment, *p_vchapter );
                 f_result = true;
             }
 
@@ -351,9 +351,9 @@ bool dvd_command_interpretor_c::Interpret( const binary * p_command, size_t i_si
                         break;
                     }
                     p_vchapter = sys.BrowseCodecPrivate( 1, MatchPgcType, &p_type, 1, p_vsegment );
-                    if ( p_vsegment != NULL )
+                    if ( p_vsegment != NULL && p_vchapter != NULL )
                     {
-                        sys.JumpTo( *p_vsegment, p_vchapter );
+                        sys.JumpTo( *p_vsegment, *p_vchapter );
                         f_result = true;
                     }
                 break;
@@ -410,7 +410,7 @@ bool dvd_command_interpretor_c::Interpret( const binary * p_command, size_t i_si
                         p_vchapter = p_vsegment->BrowseCodecPrivate( 1, MatchPgcType, &p_type, 1 );
                         if ( p_vchapter != NULL )
                         {
-                            sys.JumpTo( *p_vsegment, p_vchapter );
+                            sys.JumpTo( *p_vsegment, *p_vchapter );
                             f_result = true;
                         }
                     }
@@ -454,7 +454,7 @@ bool dvd_command_interpretor_c::Interpret( const binary * p_command, size_t i_si
                             p_vchapter = p_vsegment->BrowseCodecPrivate( 1, MatchPgcType, &p_type, 1 );
                             if ( p_vchapter != NULL )
                             {
-                                sys.JumpTo( *p_vsegment, p_vchapter );
+                                sys.JumpTo( *p_vsegment, *p_vchapter );
                                 f_result = true;
                             }
                         }
@@ -496,7 +496,7 @@ bool dvd_command_interpretor_c::Interpret( const binary * p_command, size_t i_si
                             p_vchapter = p_vchapter->BrowseCodecPrivate( 1, MatchChapterNumber, &i_ptt, sizeof(i_ptt) );
                             if ( p_vchapter != NULL )
                             {
-                                sys.JumpTo( *p_vsegment, p_vchapter );
+                                sys.JumpTo( *p_vsegment, *p_vchapter );
                                 f_result = true;
                             }
                         }
diff --git a/modules/demux/mkv/demux.cpp b/modules/demux/mkv/demux.cpp
index 110508e..ac50dd4 100644
--- a/modules/demux/mkv/demux.cpp
+++ b/modules/demux/mkv/demux.cpp
@@ -804,7 +804,7 @@ bool demux_sys_t::PreparePlayback( virtual_segment_c *p_new_vsegment )
     return true;
 }
 
-void demux_sys_t::JumpTo( virtual_segment_c & vsegment, virtual_chapter_c * p_vchapter )
+void demux_sys_t::JumpTo( virtual_segment_c & vsegment, virtual_chapter_c & vchapter )
 {
     // if the segment is not part of the current segment, select the new one
     if ( &vsegment != p_current_vsegment )
@@ -812,15 +812,11 @@ void demux_sys_t::JumpTo( virtual_segment_c & vsegment, virtual_chapter_c * p_vc
         PreparePlayback( &vsegment );
     }
 
-    if ( p_vchapter )
+    if ( !vchapter.p_chapter || !vchapter.p_chapter->Enter( true ) )
     {
-        if ( !p_vchapter->p_chapter || !p_vchapter->p_chapter->Enter( true ) )
-        {
-            // jump to the location in the found segment
-            vsegment.Seek( demuxer, p_vchapter->i_mk_virtual_start_time, p_vchapter, -1 );
-        }
+        // jump to the location in the found segment
+        vsegment.Seek( demuxer, vchapter.i_mk_virtual_start_time, &vchapter, -1 );
     }
-
 }
 
 matroska_segment_c *demux_sys_t::FindSegment( const EbmlBinary & uid ) const
diff --git a/modules/demux/mkv/demux.hpp b/modules/demux/mkv/demux.hpp
index 44e8bd4..519e85b 100644
--- a/modules/demux/mkv/demux.hpp
+++ b/modules/demux/mkv/demux.hpp
@@ -385,7 +385,7 @@ public:
     void FreeUnused();
     bool PreparePlayback( virtual_segment_c *p_new_vsegment );
     matroska_stream_c *AnalyseAllSegmentsFound( demux_t *p_demux, EbmlStream *p_estream, bool b_initial = false );
-    void JumpTo( virtual_segment_c & p_vsegment, virtual_chapter_c * p_vchapter );
+    void JumpTo( virtual_segment_c & vsegment, virtual_chapter_c & vchapter );
 
     void InitUi();
     void CleanUi();
-- 
2.7.1



More information about the vlc-devel mailing list