From 1c82fdf0489bc4626c3030b39c20f428bfb68202 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 30 Jun 2014 21:03:16 -0700 Subject: [PATCH] Add flags back to the decode unit because TI OMAP devices need them --- .../com/limelight/nvstream/av/DecodeUnit.java | 9 ++++++++- .../nvstream/av/video/VideoDepacketizer.java | 18 +++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/moonlight-common/src/com/limelight/nvstream/av/DecodeUnit.java b/moonlight-common/src/com/limelight/nvstream/av/DecodeUnit.java index 3de796ca..207af908 100644 --- a/moonlight-common/src/com/limelight/nvstream/av/DecodeUnit.java +++ b/moonlight-common/src/com/limelight/nvstream/av/DecodeUnit.java @@ -15,14 +15,16 @@ public class DecodeUnit { private int dataLength; private int frameNumber; private long receiveTimestamp; + private int flags; - public DecodeUnit(int type, List bufferList, int dataLength, int frameNumber, long receiveTimestamp) + public DecodeUnit(int type, List bufferList, int dataLength, int frameNumber, long receiveTimestamp, int flags) { this.type = type; this.bufferList = bufferList; this.dataLength = dataLength; this.frameNumber = frameNumber; this.receiveTimestamp = receiveTimestamp; + this.flags = flags; } public int getType() @@ -49,4 +51,9 @@ public class DecodeUnit { { return frameNumber; } + + public int getFlags() + { + return flags; + } } diff --git a/moonlight-common/src/com/limelight/nvstream/av/video/VideoDepacketizer.java b/moonlight-common/src/com/limelight/nvstream/av/video/VideoDepacketizer.java index dfde336f..bd672043 100644 --- a/moonlight-common/src/com/limelight/nvstream/av/video/VideoDepacketizer.java +++ b/moonlight-common/src/com/limelight/nvstream/av/video/VideoDepacketizer.java @@ -50,8 +50,24 @@ public class VideoDepacketizer { { // This is the start of a new frame if (avcFrameDataChain != null && avcFrameDataLength != 0) { + ByteBufferDescriptor firstBuffer = avcFrameDataChain.getFirst(); + + int flags = 0; + if (NAL.getSpecialSequenceDescriptor(firstBuffer, cachedSpecialDesc) && NAL.isAvcFrameStart(cachedSpecialDesc)) { + switch (cachedSpecialDesc.data[cachedSpecialDesc.offset+cachedSpecialDesc.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, frameNumber, frameStartTime); + DecodeUnit du = new DecodeUnit(DecodeUnit.TYPE_H264, avcFrameDataChain, + avcFrameDataLength, frameNumber, frameStartTime, flags); if (!decodedUnits.offer(du)) { LimeLog.warning("Video decoder is too slow! Forced to drop decode units");