demux_mkv: fix subtitle preroll in some cases

Subtitle packets with a timestamp before the seek target may overlap
with the seek target anyway. This is why this subtitle preroll crap
exists: it needs to return packets before the seek target to ensure that
the subtitle is displayed at the seek target.

This didn't always work. Maybe it's a regression, but it must have been
an old one. The breakage is triggered by heuristic that is to prevent
excessive queuing of packets in garbage files (this heuristic apparently
became immediately necessary when this preroll mechanism was
implemented).

If a video keyframe packet was found, but no audio packet yet, then
subtitle_preroll was set to 0, and since a_skip_to_keyframe was still 0,
the subtitle packet was discarded. The dumb thing is that subtitle and
video seeking is finished at this point, so the preroll crap should not
be applied at all.

Fix this by moving the preoll overflow code into the block that handles
preroll.
This commit is contained in:
wm4 2019-06-16 16:08:54 +02:00
parent 530b203e5d
commit c13bfd271c
1 changed files with 6 additions and 7 deletions

View File

@ -2652,14 +2652,13 @@ static int handle_block(demuxer_t *demuxer, struct block_info *block_info)
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--;
} else {
// This could overflow the demuxer queue.
if (mkv_d->a_skip_to_keyframe || mkv_d->v_skip_to_keyframe)
if (use_this_block) {
if (mkv_d->subtitle_preroll) {
mkv_d->subtitle_preroll--;
} else {
// This could overflow the demuxer queue.
use_this_block = 0;
}
}
}
if (use_this_block) {