Refine sample presentation time validation for negative PTS workaround

In case of negative PTS workaround, instead of disallowing all cases where samples are not in presentation order, we now validate that the first sample's presentation time is the smallest. This adjustment allows for correctly applying an offset to ensure all samples have a presentation time >= 0.

#cherrypick

PiperOrigin-RevId: 673434793
This commit is contained in:
rohks 2024-09-11 10:01:28 -07:00 committed by Copybara-Service
parent bb3d055191
commit d9a678483b

View File

@ -201,12 +201,13 @@ import java.util.Map;
trackTokenToLastPresentationTimeUs.put(trackToken, presentationTimeUs);
checkState(
presentationTimeOffsetUs == 0 || presentationTimeUs >= lastSamplePresentationTimeUs,
"Samples not in presentation order ("
+ presentationTimeUs
+ " < "
+ lastSamplePresentationTimeUs
+ ") unsupported when using negative PTS workaround");
presentationTimeOffsetUs == 0 || presentationTimeUs >= 0,
String.format(
Locale.US,
"Sample presentation time (%d) < first sample presentation time (%d). Ensure the first"
+ " sample has the smallest timestamp when using the negative PTS workaround.",
presentationTimeUs - presentationTimeOffsetUs,
-presentationTimeOffsetUs));
bufferInfo.set(bufferInfo.offset, bufferInfo.size, presentationTimeUs, bufferInfo.flags);
try {