1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-16 12:17:12 +00:00

sd_lavc: use SUB_GAP_THRESHOLD for overlaps/gaps

It turns out this already exists for sd_ass and is being used there. We
can make use of this arbitrary threshold instead for overlapping
subtitle durations to avoid the weird flashing behavior with some
pgs subtitles.
This commit is contained in:
Dudemanguy 2023-08-18 19:56:40 -05:00
parent 72e4178503
commit 725b631ec3

View File

@ -398,8 +398,8 @@ static struct sub *get_current(struct sd_lavc_priv *priv, double pts)
if (!sub->valid) if (!sub->valid)
continue; continue;
if (pts == MP_NOPTS_VALUE || if (pts == MP_NOPTS_VALUE ||
((sub->pts == MP_NOPTS_VALUE || pts + 1e-6 >= sub->pts) && ((sub->pts == MP_NOPTS_VALUE || pts + SUB_GAP_THRESHOLD >= sub->pts) &&
(sub->endpts == MP_NOPTS_VALUE || pts < sub->endpts))) (sub->endpts == MP_NOPTS_VALUE || pts - SUB_GAP_THRESHOLD <= sub->endpts)))
{ {
// Ignore "trailing" subtitles with unknown length after 1 minute. // Ignore "trailing" subtitles with unknown length after 1 minute.
if (sub->endpts == MP_NOPTS_VALUE && pts >= sub->pts + 60) if (sub->endpts == MP_NOPTS_VALUE && pts >= sub->pts + 60)