mirror of
https://github.com/samsonjs/media.git
synced 2026-04-03 10:55:48 +00:00
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:
parent
884b3de69a
commit
212f1f8ea8
6 changed files with 15 additions and 2 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue