Submit codec config data with a timestamp of 0 like MediaCodec does with csd-0

This commit is contained in:
Cameron Gutman 2022-05-29 22:10:49 -05:00
parent 82619063ee
commit bd64dfb661

View File

@ -772,17 +772,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C
int inputBufferIndex;
ByteBuffer buf;
long timestampUs = enqueueTimeMs * 1000;
if (timestampUs <= lastTimestampUs) {
// We can't submit multiple buffers with the same timestamp
// so bump it up by one before queuing
timestampUs = lastTimestampUs + 1;
}
lastTimestampUs = timestampUs;
long timestampUs;
int codecFlags = 0;
// H264 SPS
@ -948,6 +938,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C
// This is the CSD blob
codecFlags |= MediaCodec.BUFFER_FLAG_CODEC_CONFIG;
timestampUs = 0;
}
else {
// Batch this to submit together with the next I-frame
@ -1001,6 +992,16 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C
codecFlags |= MediaCodec.BUFFER_FLAG_SYNC_FRAME;
}
timestampUs = enqueueTimeMs * 1000;
if (timestampUs <= lastTimestampUs) {
// We can't submit multiple buffers with the same timestamp
// so bump it up by one before queuing
timestampUs = lastTimestampUs + 1;
}
lastTimestampUs = timestampUs;
numFramesIn++;
}
@ -1071,8 +1072,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C
// Queue the new SPS
return queueInputBuffer(inputIndex,
0, inputBuffer.position(),
System.nanoTime() / 1000,
MediaCodec.BUFFER_FLAG_CODEC_CONFIG);
0, MediaCodec.BUFFER_FLAG_CODEC_CONFIG);
}
@Override