[vlc-commits] demux:mkv: fix trying to seek before the first audio/video

Steve Lhomme git at videolan.org
Fri Jan 19 18:44:24 CET 2018


vlc/vlc-3.0 | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Jan 19 18:07:55 2018 +0100| [60c219a4c063b2d0308bce3d9d820bfc37ad11a4] | committer: Jean-Baptiste Kempf

demux:mkv: fix trying to seek before the first audio/video

We just seek to the first known Cluster.

Fixes #19286

(cherry picked from commit 117bf6fea8eb81d6c8d2616f55cad51999efe44a)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=60c219a4c063b2d0308bce3d9d820bfc37ad11a4
---

 modules/demux/mkv/matroska_segment_seeker.cpp | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/modules/demux/mkv/matroska_segment_seeker.cpp b/modules/demux/mkv/matroska_segment_seeker.cpp
index 6825ef195f..027a973279 100644
--- a/modules/demux/mkv/matroska_segment_seeker.cpp
+++ b/modules/demux/mkv/matroska_segment_seeker.cpp
@@ -151,6 +151,23 @@ SegmentSeeker::find_greatest_seekpoints_in_range( fptr_t start_fpos, mtime_t end
         tpoints.insert( tracks_seekpoint_t::value_type( it->first, sp ) );
     }
 
+    if (tpoints.empty())
+    {
+        // try a further pts
+        for( tracks_seekpoints_t::const_iterator it = _tracks_seekpoints.begin(); it != _tracks_seekpoints.end(); ++it )
+        {
+            if ( std::find( filter_tracks.begin(), filter_tracks.end(), it->first ) == filter_tracks.end() )
+                continue;
+
+            Seekpoint sp = get_first_seekpoint_around( end_pts, it->second );
+
+            if( sp.fpos < start_fpos )
+                continue;
+
+            tpoints.insert( tracks_seekpoint_t::value_type( it->first, sp ) );
+        }
+    }
+
     return tpoints;
 }
 
@@ -198,6 +215,10 @@ SegmentSeeker::get_seekpoints_around( mtime_t pts, seekpoints_t const& seekpoint
     iterator const it_end    = seekpoints.end();
     iterator const it_middle = greatest_lower_bound( it_begin, it_end, needle );
 
+    if ( it_middle != it_end && (*it_middle).pts > pts)
+        // found nothing low enough, use the first one
+        return seekpoint_pair_t( *it_begin, Seekpoint() );
+
     iterator it_before = it_middle;
     iterator it_after = it_middle == it_end ? it_middle : next_( it_middle ) ;
 



More information about the vlc-commits mailing list