summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-11-05 20:47:42 +0100
committerwm4 <wm4@nowhere>2014-11-05 21:52:20 +0100
commit6ab364df4b2a80b53f46d5ba3bd46a5557c90f5a (patch)
tree55a2d3ba502f323e3745597b3cbc53df7474d5c1
parent805e952d82536f0ea435ca1e7c82178fb00640c6 (diff)
downloadmpv-6ab364df4b2a80b53f46d5ba3bd46a5557c90f5a.tar.bz2
mpv-6ab364df4b2a80b53f46d5ba3bd46a5557c90f5a.tar.xz
demux_mkv: apply subtitle preroll only if needed, based on cue index
The demuxer has a hack to seek to the cluster before the target cluster in order to "catch" subtitle lines that start before the seek target, but overlap with the video after the seek target. Avoid this hack if the cue index indicates that there are no overlapping subtitle packets that can be caught by seeking to the previous cluster.
-rw-r--r--demux/demux_mkv.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c
index 0b51d9386e..417ac1ba38 100644
--- a/demux/demux_mkv.c
+++ b/demux/demux_mkv.c
@@ -2722,6 +2722,22 @@ static struct mkv_index *seek_with_cues(struct demuxer *demuxer, int seek_id,
prev_target = index_pos;
}
}
+ if (mkv_d->index_has_durations) {
+ // If there are no earlier subtitles overlapping with the
+ // target cluster, then disable preroll-seeking.
+ bool overlap = false;
+ for (size_t i = 0; i < mkv_d->num_indexes; i++) {
+ struct mkv_index *cur = &mkv_d->indexes[i];
+ overlap = cur->timecode <= index->timecode &&
+ cur->timecode + cur->duration > index->timecode &&
+ cur->filepos >= prev_target &&
+ cur->filepos != seek_pos;
+ if (overlap)
+ break;
+ }
+ if (!overlap)
+ prev_target = 0;
+ }
if (prev_target)
seek_pos = prev_target;
}