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

@ -101,9 +101,7 @@ 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,17 +111,21 @@ public class AvVideoDepacketizer {
avcNalDataChain = new LinkedList<AvByteBufferDescriptor>(); avcNalDataChain = new LinkedList<AvByteBufferDescriptor>();
avcNalDataLength = 0; avcNalDataLength = 0;
} }
}
else
{
// Not either sequence we want
//currentlyDecoding = AvDecodeUnit.TYPE_UNKNOWN;
}
// Skip the start sequence // Skip the start sequence
location.length -= specialSeq.length; location.length -= specialSeq.length;
location.offset += specialSeq.length; location.offset += specialSeq.length;
} }
else
{
// Not either sequence we want
currentlyDecoding = AvDecodeUnit.TYPE_UNKNOWN;
// Just skip this byte
location.length--;
location.offset++;
}
}
// Move to the next special sequence // Move to the next special sequence
while (location.length != 0) while (location.length != 0)
@ -142,7 +146,6 @@ public class AvVideoDepacketizer {
} }
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