Don't enforce SimpleDecoder skipping for samples before start time

We currently enforce the skipping if the sample has a timestamp less
than the start time. While this may be the default desired behavior
for most implementations, it prevents an implementation from outputting
a sample with such a timestamp.

This change updates the logic to pre-fill the shouldBeSkipped flag
based on the input timestamp, and only check this flag on the output
buffer. None of the implementations in our library change timestamps
of samples, so this is equivalent to the previous code.

PiperOrigin-RevId: 629708873
This commit is contained in:
tonihei 2024-05-01 06:40:09 -07:00 committed by Copybara-Service
parent 5805287620
commit fb982c2d54

View file

@ -262,6 +262,9 @@ public abstract class SimpleDecoder<
if (inputBuffer.isFirstSample()) {
outputBuffer.addFlag(C.BUFFER_FLAG_FIRST_SAMPLE);
}
if (!isAtLeastOutputStartTimeUs(inputBuffer.timeUs)) {
outputBuffer.shouldBeSkipped = true;
}
@Nullable E exception;
try {
exception = decode(inputBuffer, outputBuffer, resetDecoder);
@ -286,8 +289,7 @@ public abstract class SimpleDecoder<
synchronized (lock) {
if (flushed) {
outputBuffer.release();
} else if ((!outputBuffer.isEndOfStream() && !isAtLeastOutputStartTimeUs(outputBuffer.timeUs))
|| outputBuffer.shouldBeSkipped) {
} else if (outputBuffer.shouldBeSkipped) {
skippedOutputBufferCount++;
outputBuffer.release();
} else {