mirror of
https://github.com/samsonjs/media.git
synced 2026-04-14 12:45:47 +00:00
Update SsaParser logic to show it never returns duration=UNSET
In an upcoming change I'm going to mark SSA subtitles as 'merge replacement behavior', which will mean that `CuesWithTiming.durationUs=C.TIME_UNSET` will not be permitted. This CL makes it clear that `SsaParser` obeys that invariant. PiperOrigin-RevId: 557504633
This commit is contained in:
parent
d3894e6691
commit
9631923440
1 changed files with 5 additions and 3 deletions
|
|
@ -139,11 +139,13 @@ public final class SsaParser implements SubtitleParser {
|
|||
// An empty cue list has already been implicitly encoded in the duration of the previous
|
||||
// sample (unless there was no previous sample).
|
||||
continue;
|
||||
} else if (i == cues.size() - 1) {
|
||||
// The last cue list must be empty
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
long startTimeUs = startTimesUs.get(i);
|
||||
// The duration of the last CuesWithTiming is C.TIME_UNSET by design
|
||||
long durationUs =
|
||||
i == cues.size() - 1 ? C.TIME_UNSET : startTimesUs.get(i + 1) - startTimesUs.get(i);
|
||||
// It's safe to inspect element i+1, because we already exited the loop above if i=size()-1.
|
||||
long durationUs = startTimesUs.get(i + 1) - startTimesUs.get(i);
|
||||
cuesWithStartTimeAndDuration.add(
|
||||
new CuesWithTiming(cuesForThisStartTime, startTimeUs, durationUs));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue