[vlc-commits] demux:mkv: fix the PCR for ordered chapters

Steve Lhomme git at videolan.org
Mon Feb 26 10:12:03 CET 2018


vlc/vlc-3.0 | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Feb 23 09:43:45 2018 +0100| [693daec6b210bb46f02357d4faf5bb529febcb5e] | committer: Hugo Beauzée-Luyssen

demux:mkv: fix the PCR for ordered chapters

Fixes #19101

(cherry-picked from commit 566df1a6f36f549b391cf2ff7dcf7953a3370cae)
Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

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

 modules/demux/mkv/matroska_segment.cpp | 2 +-
 modules/demux/mkv/virtual_segment.cpp  | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/modules/demux/mkv/matroska_segment.cpp b/modules/demux/mkv/matroska_segment.cpp
index e774af4d93..4ff15c7503 100644
--- a/modules/demux/mkv/matroska_segment.cpp
+++ b/modules/demux/mkv/matroska_segment.cpp
@@ -872,7 +872,7 @@ bool matroska_segment_c::Seek( demux_t &demuxer, mtime_t i_absolute_mk_date, mti
             trackit->second->i_skip_until_fpos = it->second.fpos;
         else
             trackit->second->i_skip_until_fpos = std::numeric_limits<uint64_t>::max();
-        trackit->second->i_last_dts        = it->second.pts;
+        trackit->second->i_last_dts        = it->second.pts + i_mk_time_offset;
 
         msg_Dbg( &sys.demuxer, "seek: preroll{ track: %u, pts: %" PRId64 ", fpos: %" PRIu64 " skip: %" PRIu64 "} ",
           it->first, it->second.pts, it->second.fpos, trackit->second->i_skip_until_fpos );
diff --git a/modules/demux/mkv/virtual_segment.cpp b/modules/demux/mkv/virtual_segment.cpp
index d7c7aded25..e5673d896a 100644
--- a/modules/demux/mkv/virtual_segment.cpp
+++ b/modules/demux/mkv/virtual_segment.cpp
@@ -114,7 +114,7 @@ virtual_edition_c::virtual_edition_c( chapter_edition_c * p_edit, matroska_segme
     p_edition = p_edit;
     b_ordered = false;
 
-    int64_t usertime_offset = 0;
+    int64_t usertime_offset = 0; // microseconds
 
     /* ordered chapters */
     if( p_edition && p_edition->b_ordered )
@@ -468,6 +468,7 @@ bool virtual_segment_c::UpdateCurrentToChapter( demux_t & demux )
                     }
                     sys.i_start_pts = p_cur_vchapter->i_mk_virtual_start_time + VLC_TS_0;
                 }
+                sys.i_mk_chapter_time = p_cur_vchapter->i_mk_virtual_start_time - p_cur_vchapter->segment.i_mk_start_time - ( ( p_cur_vchapter->p_chapter )? p_cur_vchapter->p_chapter->i_start_time : 0 ) /* + VLC_TS_0 */;
             }
 
             p_current_vchapter = p_cur_vchapter;
@@ -527,7 +528,8 @@ bool virtual_segment_c::Seek( demux_t & demuxer, mtime_t i_mk_date,
     if ( p_vchapter != NULL )
     {
         mtime_t i_mk_time_offset = p_vchapter->i_mk_virtual_start_time - ( ( p_vchapter->p_chapter )? p_vchapter->p_chapter->i_start_time : 0 );
-        p_sys->i_mk_chapter_time = i_mk_time_offset - p_vchapter->segment.i_mk_start_time /* + VLC_TS_0 */;
+        if (CurrentEdition()->b_ordered)
+            p_sys->i_mk_chapter_time = p_vchapter->i_mk_virtual_start_time - p_vchapter->segment.i_mk_start_time - ( ( p_vchapter->p_chapter )? p_vchapter->p_chapter->i_start_time : 0 ) /* + VLC_TS_0 */;
         if ( p_vchapter->p_chapter && p_vchapter->i_seekpoint_num > 0 )
         {
             demuxer.info.i_update |= INPUT_UPDATE_TITLE | INPUT_UPDATE_SEEKPOINT;



More information about the vlc-commits mailing list