Skip to content

Commit

Permalink
Refine sample presentation time validation for negative PTS workaround
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rohitjoins authored and copybara-github committed Sep 11, 2024
1 parent bb3d055 commit d9a6784
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,13 @@ public void writeSampleData(TrackToken trackToken, ByteBuffer data, BufferInfo b
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 {
Expand Down

0 comments on commit d9a6784

Please sign in to comment.