Skip to content

Commit

Permalink
Clarify purpose of omitting zero duration clipped audio samples
Browse files Browse the repository at this point in the history
When applying edit lists, we need to output the last partial samples
to have all the necessary data needed for rendering.

The only case where we can omit the sample is for zero duration
audio data that has no additional information.

The current comment and variable name doesn't make this very clear
and this change improves the naming and the comment.

PiperOrigin-RevId: 608579746
  • Loading branch information
tonihei authored and copybara-github committed Feb 20, 2024
1 parent 8dd6590 commit 711d24a
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,11 @@ private static TrackSampleTable parseStbl(
track, offsets, sizes, maximumSize, timestamps, flags, durationUs);
}

// Omit any sample at the end point of an edit for audio tracks.
boolean omitClippedSample = track.type == C.TRACK_TYPE_AUDIO;
// When applying edit lists, we need to include any partial clipped samples at the end to ensure
// the final output is rendered correctly (see https://github.com/google/ExoPlayer/issues/2408).
// For audio only, we can omit any sample that starts at exactly the end point of an edit as
// there is no partial audio in this case.
boolean omitZeroDurationClippedSample = track.type == C.TRACK_TYPE_AUDIO;

// Count the number of samples after applying edits.
int editedSampleCount = 0;
Expand Down Expand Up @@ -707,7 +710,7 @@ private static TrackSampleTable parseStbl(
Util.binarySearchCeil(
timestamps,
editMediaTime + editDuration,
/* inclusive= */ omitClippedSample,
/* inclusive= */ omitZeroDurationClippedSample,
/* stayInBounds= */ false);
while (startIndices[i] < endIndices[i]
&& (flags[startIndices[i]] & C.BUFFER_FLAG_KEY_FRAME) == 0) {
Expand Down

0 comments on commit 711d24a

Please sign in to comment.