Commit 0a617146 by olly Committed by Oliver Woodman

Remove duplicate DECODE_ONLY check

PiperOrigin-RevId: 316119460
parent f1b94f6f
...@@ -81,8 +81,7 @@ import java.util.PriorityQueue; ...@@ -81,8 +81,7 @@ import java.util.PriorityQueue;
Assertions.checkArgument(inputBuffer == dequeuedInputBuffer); Assertions.checkArgument(inputBuffer == dequeuedInputBuffer);
CeaInputBuffer ceaInputBuffer = (CeaInputBuffer) inputBuffer; CeaInputBuffer ceaInputBuffer = (CeaInputBuffer) inputBuffer;
if (ceaInputBuffer.isDecodeOnly()) { if (ceaInputBuffer.isDecodeOnly()) {
// We can drop this buffer early (i.e. before it would be decoded) as the CEA formats allow // We can start decoding anywhere in CEA formats, so discarding on the input side is fine.
// for decoding to begin mid-stream.
releaseInputBuffer(ceaInputBuffer); releaseInputBuffer(ceaInputBuffer);
} else { } else {
ceaInputBuffer.queuedInputBufferCount = queuedInputBufferCount++; ceaInputBuffer.queuedInputBufferCount = queuedInputBufferCount++;
...@@ -97,15 +96,12 @@ import java.util.PriorityQueue; ...@@ -97,15 +96,12 @@ import java.util.PriorityQueue;
if (availableOutputBuffers.isEmpty()) { if (availableOutputBuffers.isEmpty()) {
return null; return null;
} }
// iterate through all available input buffers whose timestamps are less than or equal // Process input buffers up to the current playback position. Processing of input buffers for
// to the current playback position; processing input buffers for future content should // future content is deferred.
// be deferred until they would be applicable
while (!queuedInputBuffers.isEmpty() while (!queuedInputBuffers.isEmpty()
&& Util.castNonNull(queuedInputBuffers.peek()).timeUs <= playbackPositionUs) { && Util.castNonNull(queuedInputBuffers.peek()).timeUs <= playbackPositionUs) {
CeaInputBuffer inputBuffer = Util.castNonNull(queuedInputBuffers.poll()); CeaInputBuffer inputBuffer = Util.castNonNull(queuedInputBuffers.poll());
// If the input buffer indicates we've reached the end of the stream, we can
// return immediately with an output buffer propagating that
if (inputBuffer.isEndOfStream()) { if (inputBuffer.isEndOfStream()) {
// availableOutputBuffers.isEmpty() is checked at the top of the method, so this is safe. // availableOutputBuffers.isEmpty() is checked at the top of the method, so this is safe.
SubtitleOutputBuffer outputBuffer = Util.castNonNull(availableOutputBuffers.pollFirst()); SubtitleOutputBuffer outputBuffer = Util.castNonNull(availableOutputBuffers.pollFirst());
...@@ -116,18 +112,13 @@ import java.util.PriorityQueue; ...@@ -116,18 +112,13 @@ import java.util.PriorityQueue;
decode(inputBuffer); decode(inputBuffer);
// check if we have any caption updates to report
if (isNewSubtitleDataAvailable()) { if (isNewSubtitleDataAvailable()) {
// Even if the subtitle is decode-only; we need to generate it to consume the data so it
// isn't accidentally prepended to the next subtitle
Subtitle subtitle = createSubtitle(); Subtitle subtitle = createSubtitle();
if (!inputBuffer.isDecodeOnly()) { // availableOutputBuffers.isEmpty() is checked at the top of the method, so this is safe.
// availableOutputBuffers.isEmpty() is checked at the top of the method, so this is safe. SubtitleOutputBuffer outputBuffer = Util.castNonNull(availableOutputBuffers.pollFirst());
SubtitleOutputBuffer outputBuffer = Util.castNonNull(availableOutputBuffers.pollFirst()); outputBuffer.setContent(inputBuffer.timeUs, subtitle, Format.OFFSET_SAMPLE_RELATIVE);
outputBuffer.setContent(inputBuffer.timeUs, subtitle, Format.OFFSET_SAMPLE_RELATIVE); releaseInputBuffer(inputBuffer);
releaseInputBuffer(inputBuffer); return outputBuffer;
return outputBuffer;
}
} }
releaseInputBuffer(inputBuffer); releaseInputBuffer(inputBuffer);
...@@ -160,7 +151,7 @@ import java.util.PriorityQueue; ...@@ -160,7 +151,7 @@ import java.util.PriorityQueue;
@Override @Override
public void release() { public void release() {
// Do nothing // Do nothing.
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment