[vlc-devel] [PATCH 2/4] demux: mkv: truncate length on preskip, don't set negative pts
Francois Cartegnie
fcvlcdev at free.fr
Wed Sep 30 17:44:05 CEST 2020
Same as other demuxers do with preskip
refs #25129
---
modules/demux/mkv/mkv.cpp | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/modules/demux/mkv/mkv.cpp b/modules/demux/mkv/mkv.cpp
index 82f464a74a..2af7d5c87b 100644
--- a/modules/demux/mkv/mkv.cpp
+++ b/modules/demux/mkv/mkv.cpp
@@ -547,8 +547,6 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock
return;
}
- i_pts -= track.i_codec_delay;
-
if ( track.fmt.i_cat != DATA_ES )
{
bool b;
@@ -695,6 +693,24 @@ void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock
}
else
{
+ if( track.i_codec_delay ) /* Handle pre-skip */
+ {
+ if( i_pts > track.i_codec_delay )
+ {
+ p_block->i_length -= track.i_codec_delay;
+ }
+ else
+ {
+ vlc_tick_t skipped = i_pts - track.i_codec_delay;
+ if( p_block->i_length <= skipped )
+ {
+ p_block->i_length = 0;
+ p_block->i_flags |= BLOCK_FLAG_PREROLL;
+ }
+ else p_block->i_length -= skipped;
+ }
+ }
+
// correct timestamping when B frames are used
if( track.b_dts_only )
{
--
2.25.4
More information about the vlc-devel
mailing list