[vlc-devel] [PATCH 17/30] mkv: add every seen subtitle block as seekpoint

Filip Roséen filip at videolabs.io
Mon May 9 14:53:11 CEST 2016


Currently there are issues outside of the demuxer that does not allow us
to display an "on-going" subtitle if we seek to a location where a
subtitle has started, but yet finished.

Since there are several mkv files in the wild where there is no proper
mkv-cue for every subtitle, we should add every subtitle block we see as
an index; and then use this for seeking (if we know about it, and have
to).

In general, every subtitle block is effectively a "keyframe"; meaning
that this hack is safe (at least enough to justify its purpose). Having
seekpoints for the subtitle track will allow us to send it to the
relevant decoder, and after we have support for "unfinished" subtitles;
mkv's will magically play along nicely.
---
 modules/demux/mkv/matroska_segment.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/modules/demux/mkv/matroska_segment.cpp b/modules/demux/mkv/matroska_segment.cpp
index a9a3c80..44201b8 100644
--- a/modules/demux/mkv/matroska_segment.cpp
+++ b/modules/demux/mkv/matroska_segment.cpp
@@ -1118,15 +1118,18 @@ int matroska_segment_c::BlockGet( KaxBlock * & pp_block, KaxSimpleBlock * & pp_s
             vars.block->ReadData( vars.obj->es.I_O() );
             vars.block->SetParent( *vars.obj->cluster );
 
+            if( vars.obj->tracks[ kblock.TrackNum() ].fmt.i_cat == SPU_ES )
+            {
+                vars.obj->_seeker.add_seekpoint( kblock.TrackNum(), SegmentSeeker::Seekpoint::TRUSTED, kblock.GetElementPosition(), kblock.GlobalTimecode() / 1000 );
+            }
+
             vars.obj->ep->Keep ();
         }
-
         E_CASE( KaxBlockDuration, kduration )
         {
             kduration.ReadData( vars.obj->es.I_O() );
             vars.i_duration = static_cast<uint64>( kduration );
         }
-
         E_CASE( KaxReferenceBlock, kreference )
         {
            kreference.ReadData( vars.obj->es.I_O() );
-- 
2.8.2



More information about the vlc-devel mailing list