diff options
author | VincentVerdynanta <go.wenlung@gmail.com> | 2022-09-08 16:45:31 +0800 |
---|---|---|
committer | Leo Izen <leo.izen@gmail.com> | 2022-10-12 19:57:44 -0400 |
commit | 59fc8eecbc08d22368451b31fcf799aec557ab0d (patch) | |
tree | 2d4a641c3f599f2e7bfcf3c75bd30dd7858e3881 | |
parent | b3d77397ebb13ee075e1f01328b45eac115aec0f (diff) | |
download | mpv-59fc8eecbc08d22368451b31fcf799aec557ab0d.tar.bz2 mpv-59fc8eecbc08d22368451b31fcf799aec557ab0d.tar.xz |
sd_ass: improve handling of subtitles with unknown duration
Commit 740b701 introduced handling for subtitles with unknown duration,
but it came with a minor flaw where a track event that shares identical
start time with following track event will has its Duration value set
to 0, we don't want this to happen since it will prevent simultaneous
rendering of multiple track events.
This commit aims to address this issue.
-rw-r--r-- | sub/sd_ass.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sub/sd_ass.c b/sub/sd_ass.c index 765b77822d..d7b1e479b7 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -359,10 +359,14 @@ static void decode(struct sd *sd, struct demux_packet *packet) filter_and_add(sd, &pkt2); } if (ctx->duration_unknown) { - for (int n = 0; n < track->n_events - 1; n++) { + for (int n = track->n_events - 2; n >= 0; n--) { if (track->events[n].Duration == UNKNOWN_DURATION * 1000) { - track->events[n].Duration = track->events[n + 1].Start - - track->events[n].Start; + if (track->events[n].Start != track->events[n + 1].Start) { + track->events[n].Duration = track->events[n + 1].Start - + track->events[n].Start; + } else { + track->events[n].Duration = track->events[n + 1].Duration; + } } } } |