Fix decoder is queued buffer with timestamp TIME_END_OF_SOURCE
ExoPlayer queues the EOS buffer to the decoder with offset/size/timestamp all
equal to zero, and a EOS flag.
69769c77b3
set TIME_END_OF_SOURCE on the EOS buffer from the extractor.
Queueing the EOS buffer to the decoder with TIME_END_OF_SOURCE causes some
decoders to output wrong timestamps in its output.
This CL replicates what ExoPlayer does in Transformer.
PiperOrigin-RevId: 553104213
This commit is contained in:
parent
fec6252065
commit
af546b8eda
@ -209,20 +209,30 @@ public final class DefaultCodec implements Codec {
|
|||||||
|
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
|
int flags = 0;
|
||||||
if (inputBuffer.data != null && inputBuffer.data.hasRemaining()) {
|
if (inputBuffer.data != null && inputBuffer.data.hasRemaining()) {
|
||||||
offset = inputBuffer.data.position();
|
offset = inputBuffer.data.position();
|
||||||
size = inputBuffer.data.remaining();
|
size = inputBuffer.data.remaining();
|
||||||
}
|
}
|
||||||
int flags = 0;
|
long timestampUs = inputBuffer.timeUs;
|
||||||
|
|
||||||
if (inputBuffer.isEndOfStream()) {
|
if (inputBuffer.isEndOfStream()) {
|
||||||
inputStreamEnded = true;
|
inputStreamEnded = true;
|
||||||
flags = MediaCodec.BUFFER_FLAG_END_OF_STREAM;
|
flags = MediaCodec.BUFFER_FLAG_END_OF_STREAM;
|
||||||
if (isVideo && isDecoder) {
|
|
||||||
|
if (isDecoder) {
|
||||||
|
if (isVideo) {
|
||||||
DebugTraceUtil.logEvent(DebugTraceUtil.EVENT_DECODER_RECEIVE_EOS, C.TIME_END_OF_SOURCE);
|
DebugTraceUtil.logEvent(DebugTraceUtil.EVENT_DECODER_RECEIVE_EOS, C.TIME_END_OF_SOURCE);
|
||||||
}
|
}
|
||||||
|
// EOS buffer on the decoder input should never carry data.
|
||||||
|
checkState(inputBuffer.data == null || !inputBuffer.data.hasRemaining());
|
||||||
|
offset = 0;
|
||||||
|
size = 0;
|
||||||
|
timestampUs = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
mediaCodec.queueInputBuffer(inputBufferIndex, offset, size, inputBuffer.timeUs, flags);
|
mediaCodec.queueInputBuffer(inputBufferIndex, offset, size, timestampUs, flags);
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
Log.d(TAG, "MediaCodec error", e);
|
Log.d(TAG, "MediaCodec error", e);
|
||||||
throw createExportException(e);
|
throw createExportException(e);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user