MediaCodecRenderer: Remove unused code path

SampleStreams should always provide samples starting from a keyframe.
We do not have equivalent logic in any of our extension decoder renderers.

PiperOrigin-RevId: 319012365
This commit is contained in:
olly 2020-06-30 14:50:38 +01:00 committed by Oliver Woodman
parent 5be6eaa88c
commit 0a2bacb7b7
2 changed files with 11 additions and 24 deletions

View File

@ -401,7 +401,6 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
private long lastBufferInStreamPresentationTimeUs;
private boolean inputStreamEnded;
private boolean outputStreamEnded;
private boolean waitingForFirstSyncSample;
private boolean waitingForFirstSampleInFormat;
private boolean pendingOutputEndOfStream;
@MediaCodecOperationMode private int mediaCodecOperationMode;
@ -893,7 +892,6 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
codecHotswapDeadlineMs = C.TIME_UNSET;
codecReceivedEos = false;
codecReceivedBuffers = false;
waitingForFirstSyncSample = true;
codecNeedsAdaptationWorkaroundBuffer = false;
shouldSkipAdaptationWorkaroundOutputBuffer = false;
isDecodeOnlyOutputBuffer = false;
@ -1320,19 +1318,6 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
return false;
}
// TODO: This code block may be unnecessary, because it's probably the case that the buffer will
// always be a keyframe if waitingForFirstSyncSample is true. Check this, and remove if so.
if (waitingForFirstSyncSample && !buffer.isKeyFrame()) {
buffer.clear();
if (codecReconfigurationState == RECONFIGURATION_STATE_QUEUE_PENDING) {
// The buffer we just cleared contained reconfiguration data. We need to re-write this
// data into a subsequent buffer (if there is one).
codecReconfigurationState = RECONFIGURATION_STATE_WRITE_PENDING;
}
return true;
}
waitingForFirstSyncSample = false;
boolean bufferEncrypted = buffer.isEncrypted();
if (bufferEncrypted) {
buffer.cryptoInfo.increaseClearDataFirstSubSampleBy(adaptiveReconfigurationBytes);

View File

@ -503,13 +503,23 @@ public class SampleQueue implements TrackOutput {
if (upstreamFormatAdjustmentRequired) {
format(Assertions.checkStateNotNull(unadjustedUpstreamFormat));
}
boolean isKeyframe = (flags & C.BUFFER_FLAG_KEY_FRAME) != 0;
if (upstreamKeyframeRequired) {
if (!isKeyframe) {
return;
}
upstreamKeyframeRequired = false;
}
timeUs += sampleOffsetUs;
if (pendingSplice) {
if ((flags & C.BUFFER_FLAG_KEY_FRAME) == 0 || !attemptSplice(timeUs)) {
if (!isKeyframe || !attemptSplice(timeUs)) {
return;
}
pendingSplice = false;
}
long absoluteOffset = sampleDataQueue.getTotalBytesWritten() - size - offset;
commitSample(timeUs, flags, absoluteOffset, size, cryptoData);
}
@ -676,14 +686,6 @@ public class SampleQueue implements TrackOutput {
long offset,
int size,
@Nullable CryptoData cryptoData) {
if (upstreamKeyframeRequired) {
if ((sampleFlags & C.BUFFER_FLAG_KEY_FRAME) == 0) {
return;
}
upstreamKeyframeRequired = false;
}
Assertions.checkState(!upstreamFormatRequired);
isLastSampleQueued = (sampleFlags & C.BUFFER_FLAG_LAST_SAMPLE) != 0;
largestQueuedTimestampUs = Math.max(largestQueuedTimestampUs, timeUs);