From 14a2993796c4f6ab0cb65e656a9b06c0672c79d2 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 12 Oct 2015 21:19:43 +0200 Subject: demux_mkv: do not return subtitle packets that end before seek target This affects the subtitle preroll mode during seeking. It could matter somewhat with insane files with ten-thousands of subtitle events, which now seem to pop up, and will avoid packet queue overflow. --- demux/demux_mkv.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'demux') diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c index e2743d5ef8..daf03d615b 100644 --- a/demux/demux_mkv.c +++ b/demux/demux_mkv.c @@ -2389,8 +2389,12 @@ static int handle_block(demuxer_t *demuxer, struct block_info *block_info) if (mkv_d->a_skip_to_keyframe) use_this_block &= keyframe; } else if (track->type == MATROSKA_TRACK_SUBTITLE) { - if (!use_this_block && mkv_d->subtitle_preroll) - use_this_block = 1; + if (!use_this_block && mkv_d->subtitle_preroll) { + int64_t end_time = block_info->timecode + block_info->duration; + if (!block_info->duration) + end_time = INT64_MAX; + use_this_block = end_time > mkv_d->skip_to_timecode; + } if (use_this_block) { if (mkv_d->subtitle_preroll) { mkv_d->subtitle_preroll--; -- cgit v1.2.3