Fix decoding of misaligned start sequences.

This commit is contained in:
Cameron Gutman 2013-11-10 02:53:51 -05:00
parent c631649867
commit d5665ac318
2 changed files with 12 additions and 11 deletions

View File

@ -100,10 +100,8 @@ public class NvVideoStream {
} }
System.out.println("VID: First frame read ("+offset+" bytes)"); System.out.println("VID: First frame read ("+offset+" bytes)");
// FIXME: Investigate: putting these NALs into the data stream depacketizer.addInputData(new AvVideoPacket(new AvByteBufferDescriptor(firstFrame, 0, offset)));
// causes the picture to get messed up
//depacketizer.addInputData(new AvPacket(new AvBufferDescriptor(firstFrame, 0, offset)));
} }
public void setupRtpSession(String host) throws SocketException public void setupRtpSession(String host) throws SocketException

View File

@ -111,16 +111,20 @@ public class AvVideoDepacketizer {
avcNalDataChain = new LinkedList<AvByteBufferDescriptor>(); avcNalDataChain = new LinkedList<AvByteBufferDescriptor>();
avcNalDataLength = 0; avcNalDataLength = 0;
} }
// Skip the start sequence
location.length -= specialSeq.length;
location.offset += specialSeq.length;
} }
else else
{ {
// Not either sequence we want // 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 // Move to the next special sequence
@ -140,9 +144,8 @@ public class AvVideoDepacketizer {
location.length--; location.length--;
} }
} }
AvByteBufferDescriptor data = new AvByteBufferDescriptor(location.data, start, location.offset-start); AvByteBufferDescriptor data = new AvByteBufferDescriptor(location.data, start, location.offset-start);
if (currentlyDecoding == AvDecodeUnit.TYPE_H264 && avcNalDataChain != null) if (currentlyDecoding == AvDecodeUnit.TYPE_H264 && avcNalDataChain != null)
{ {
// Add a buffer descriptor describing the NAL data in this packet // Add a buffer descriptor describing the NAL data in this packet