From d5665ac3188abdda97143ca1bc32e749f02fb2a0 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 10 Nov 2013 02:53:51 -0500 Subject: [PATCH] Fix decoding of misaligned start sequences. --- src/com/limelight/nvstream/NvVideoStream.java | 6 ++---- .../nvstream/av/video/AvVideoDepacketizer.java | 17 ++++++++++------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/com/limelight/nvstream/NvVideoStream.java b/src/com/limelight/nvstream/NvVideoStream.java index 8c5ba264..175d6dcc 100644 --- a/src/com/limelight/nvstream/NvVideoStream.java +++ b/src/com/limelight/nvstream/NvVideoStream.java @@ -100,10 +100,8 @@ public class NvVideoStream { } System.out.println("VID: First frame read ("+offset+" bytes)"); - - // FIXME: Investigate: putting these NALs into the data stream - // causes the picture to get messed up - //depacketizer.addInputData(new AvPacket(new AvBufferDescriptor(firstFrame, 0, offset))); + + depacketizer.addInputData(new AvVideoPacket(new AvByteBufferDescriptor(firstFrame, 0, offset))); } public void setupRtpSession(String host) throws SocketException diff --git a/src/com/limelight/nvstream/av/video/AvVideoDepacketizer.java b/src/com/limelight/nvstream/av/video/AvVideoDepacketizer.java index f1d063e1..d59994a9 100644 --- a/src/com/limelight/nvstream/av/video/AvVideoDepacketizer.java +++ b/src/com/limelight/nvstream/av/video/AvVideoDepacketizer.java @@ -111,16 +111,20 @@ public class AvVideoDepacketizer { avcNalDataChain = new LinkedList(); avcNalDataLength = 0; } + + // Skip the start sequence + location.length -= specialSeq.length; + location.offset += specialSeq.length; } else { // Not either sequence we want - //currentlyDecoding = AvDecodeUnit.TYPE_UNKNOWN; + currentlyDecoding = AvDecodeUnit.TYPE_UNKNOWN; + + // Just skip this byte + location.length--; + location.offset++; } - - // Skip the start sequence - location.length -= specialSeq.length; - location.offset += specialSeq.length; } // Move to the next special sequence @@ -140,9 +144,8 @@ public class AvVideoDepacketizer { location.length--; } } - + AvByteBufferDescriptor data = new AvByteBufferDescriptor(location.data, start, location.offset-start); - if (currentlyDecoding == AvDecodeUnit.TYPE_H264 && avcNalDataChain != null) { // Add a buffer descriptor describing the NAL data in this packet