[vlc-commits] [Git][videolan/vlc][master] demux: mkv: shift the timestamps based on the biggest CodecDelay

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sat Nov 27 10:08:01 UTC 2021



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
45036317 by Steve Lhomme at 2021-11-27T09:47:22+00:00
demux: mkv: shift the timestamps based on the biggest CodecDelay

The CodecDelay needs to be substracted from the PTS of all frames of that
track. That may result in negative DTS, PTS and PCR which is not well handled.
So we just shift all timestamps based on the biggest CodecDelay so all
timestamps are always positive.

This is in line with how libavformat reports the timestamps on frames from a
track with a CodecDelay.

This is done per segment as other segments may use a different CodecDelay
per track.

Fixes #25129

- - - - -


3 changed files:

- modules/demux/mkv/matroska_segment.hpp
- modules/demux/mkv/matroska_segment_parse.cpp
- modules/demux/mkv/mkv.cpp


Changes:

=====================================
modules/demux/mkv/matroska_segment.hpp
=====================================
@@ -98,6 +98,7 @@ public:
     /* all tracks */
     tracks_map_t tracks;
     SegmentSeeker::track_ids_t priority_tracks;
+    vlc_tick_t                 pcr_shift = 0;
 
     /* from seekhead */
     int                     i_seekhead_count;


=====================================
modules/demux/mkv/matroska_segment_parse.cpp
=====================================
@@ -1097,6 +1097,12 @@ void matroska_segment_c::ParseTracks( KaxTracks *tracks )
     };
 
     TrackHandlers::Dispatcher().iterate( tracks->begin(), tracks->end(), &payload );
+
+    auto t = matroska_segment_c::tracks.begin();
+    for (t; t != matroska_segment_c::tracks.end(); ++t)
+    {
+        pcr_shift = std::max(pcr_shift, t->second->i_codec_delay);
+    }
 }
 
 /*****************************************************************************


=====================================
modules/demux/mkv/mkv.cpp
=====================================
@@ -557,7 +557,8 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock
         return;
     }
 
-    i_pts -= track.i_codec_delay;
+    if (i_pts != VLC_TICK_INVALID)
+        i_pts += p_segment->pcr_shift - track.i_codec_delay;
 
     if ( track.fmt.i_cat != DATA_ES )
     {



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/450363175621f1b6893a8cc833508b5129bfd938

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/450363175621f1b6893a8cc833508b5129bfd938
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list