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

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.
This commit is contained in:
VincentVerdynanta 2022-09-08 16:45:31 +08:00 committed by Leo Izen
parent b3d77397eb
commit 59fc8eecbc

View File

@ -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;
}
}
}
}