Set flags on the decode units that indicate what type of data the frame contains

This commit is contained in:
Cameron Gutman 2014-02-26 01:00:17 -05:00
parent bc2ca0b386
commit 4fbe93e62d
2 changed files with 21 additions and 1 deletions

View File

@ -7,6 +7,9 @@ public class DecodeUnit {
public static final int TYPE_H264 = 1;
public static final int TYPE_OPUS = 2;
public static final int DU_FLAG_CODEC_CONFIG = 0x1;
public static final int DU_FLAG_SYNC_FRAME = 0x2;
private int type;
private List<ByteBufferDescriptor> bufferList;
private int dataLength;

View File

@ -46,8 +46,25 @@ public class VideoDepacketizer {
{
// This is the start of a new frame
if (avcFrameDataChain != null && avcFrameDataLength != 0) {
int flags = 0;
ByteBufferDescriptor firstBuffer = avcFrameDataChain.getFirst();
if (NAL.getSpecialSequenceDescriptor(firstBuffer, cachedDesc) && NAL.isAvcFrameStart(cachedDesc)) {
switch (cachedDesc.data[cachedDesc.offset+cachedDesc.length]) {
case 0x67:
case 0x68:
flags |= DecodeUnit.DU_FLAG_CODEC_CONFIG;
break;
case 0x65:
flags |= DecodeUnit.DU_FLAG_SYNC_FRAME;
break;
}
}
// Construct the H264 decode unit
DecodeUnit du = new DecodeUnit(DecodeUnit.TYPE_H264, avcFrameDataChain, avcFrameDataLength, 0, frameNumber);
DecodeUnit du = new DecodeUnit(DecodeUnit.TYPE_H264, avcFrameDataChain, avcFrameDataLength, flags, frameNumber);
if (directSubmitDr != null) {
// Submit directly to the decoder
directSubmitDr.submitDecodeUnit(du);