Update decode-only flag logic in non-MediaCodec-renderers

MediaCodecRenderer has already been updated to not rely on the
input stream to mark its samples as decode-only and instead use
a simple time-based comparison to achieve the same effect.

This change makes the same update for all other renderers that
either use the flag directly or forward to a "decoder" instance.

PiperOrigin-RevId: 568232212
This commit is contained in:
tonihei 2023-09-25 08:51:06 -07:00 committed by Copybara-Service
parent 884b3de69a
commit 212f1f8ea8
6 changed files with 15 additions and 2 deletions

View file

@ -532,6 +532,9 @@ public abstract class DecoderAudioRenderer<
firstStreamSampleRead = true;
inputBuffer.addFlag(C.BUFFER_FLAG_FIRST_SAMPLE);
}
if (inputBuffer.timeUs < getLastResetPositionUs()) {
inputBuffer.addFlag(C.BUFFER_FLAG_DECODE_ONLY);
}
inputBuffer.flip();
inputBuffer.format = inputFormat;
decoder.queueInputBuffer(inputBuffer);

View file

@ -240,6 +240,9 @@ public final class MetadataRenderer extends BaseRenderer implements Callback {
inputStreamEnded = true;
} else {
buffer.subsampleOffsetUs = subsampleOffsetUs;
if (buffer.timeUs < getLastResetPositionUs()) {
buffer.addFlag(C.BUFFER_FLAG_DECODE_ONLY);
}
buffer.flip();
@Nullable Metadata metadata = castNonNull(decoder).decode(buffer);
if (metadata != null) {

View file

@ -316,6 +316,9 @@ public final class TextRenderer extends BaseRenderer implements Callback {
waitingForKeyFrame &= !nextInputBuffer.isKeyFrame();
}
if (!waitingForKeyFrame) {
if (nextInputBuffer.timeUs < getLastResetPositionUs()) {
nextInputBuffer.addFlag(C.BUFFER_FLAG_DECODE_ONLY);
}
checkNotNull(decoder).queueInputBuffer(nextInputBuffer);
this.nextInputBuffer = null;
}

View file

@ -775,6 +775,9 @@ public abstract class DecoderVideoRenderer extends BaseRenderer {
formatQueue.add(inputBuffer.timeUs, inputFormat);
waitingForFirstSampleInFormat = false;
}
if (inputBuffer.timeUs < getLastResetPositionUs()) {
inputBuffer.addFlag(C.BUFFER_FLAG_DECODE_ONLY);
}
inputBuffer.flip();
inputBuffer.format = inputFormat;
onQueueInputBuffer(inputBuffer);

View file

@ -107,7 +107,8 @@ public final class CameraMotionRenderer extends BaseRenderer {
}
lastTimestampUs = buffer.timeUs;
if (listener == null || buffer.isDecodeOnly()) {
boolean isDecodeOnly = lastTimestampUs < getLastResetPositionUs();
if (listener == null || isDecodeOnly) {
continue;
}

View file

@ -121,7 +121,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
@Override
protected void onDecoderInputReady(DecoderInputBuffer inputBuffer) {
if (inputBuffer.isDecodeOnly()) {
if (inputBuffer.timeUs < getLastResetPositionUs()) {
decodeOnlyPresentationTimestamps.add(inputBuffer.timeUs);
}
}