mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-19 19:13:03 +00:00
Use packet flags to determine where frames end and begin instead of the packet index
This commit is contained in:
parent
c93812179f
commit
a96de39b28
@ -14,7 +14,6 @@ public class VideoDepacketizer {
|
||||
private LinkedList<ByteBufferDescriptor> avcNalDataChain = null;
|
||||
private int avcNalDataLength = 0;
|
||||
private int currentlyDecoding = DecodeUnit.TYPE_UNKNOWN;
|
||||
private boolean splitFrame = false;
|
||||
|
||||
// Sequencing state
|
||||
private short lastSequenceNumber;
|
||||
@ -175,15 +174,9 @@ public class VideoDepacketizer {
|
||||
// Remove extra padding
|
||||
location.length = packet.getPayloadLength();
|
||||
|
||||
boolean firstPacket = !splitFrame && packetIndex == 0;
|
||||
|
||||
// Reset split frame state on next frame start
|
||||
if (packetIndex == 0) {
|
||||
splitFrame = false;
|
||||
}
|
||||
|
||||
boolean firstPacket = (packet.getFlags() & VideoPacket.FLAG_SOF) != 0;
|
||||
if (firstPacket)
|
||||
{
|
||||
{
|
||||
if (NAL.getSpecialSequenceDescriptor(location, cachedDesc) && NAL.isAvcFrameStart(cachedDesc)
|
||||
&& cachedDesc.data[cachedDesc.offset+cachedDesc.length] == 0x67)
|
||||
{
|
||||
@ -195,12 +188,8 @@ public class VideoDepacketizer {
|
||||
|
||||
addInputDataFast(packet, location, firstPacket);
|
||||
|
||||
if (!splitFrame && packetIndex + 1 == packetsInFrame) {
|
||||
// Reassemble the frame if this was the last packet and it's not a split frame
|
||||
if (packet.getPayloadLength() == 968)
|
||||
splitFrame = true;
|
||||
else
|
||||
reassembleAvcNal();
|
||||
if ((packet.getFlags() & VideoPacket.FLAG_EOF) != 0) {
|
||||
reassembleAvcNal();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,10 @@ public class VideoPacket {
|
||||
private int packetIndex;
|
||||
private int totalPackets;
|
||||
private int payloadLength;
|
||||
private int flags;
|
||||
|
||||
public static final int FLAG_EOF = 0x2;
|
||||
public static final int FLAG_SOF = 0x4;
|
||||
|
||||
public VideoPacket(ByteBufferDescriptor rtpPayload)
|
||||
{
|
||||
@ -23,12 +27,15 @@ public class VideoPacket {
|
||||
frameIndex = bb.getInt();
|
||||
packetIndex = bb.getInt();
|
||||
totalPackets = bb.getInt();
|
||||
|
||||
bb.position(bb.position()+4);
|
||||
|
||||
flags = bb.getInt();
|
||||
payloadLength = bb.getInt();
|
||||
}
|
||||
|
||||
public int getFlags()
|
||||
{
|
||||
return flags;
|
||||
}
|
||||
|
||||
public int getFrameIndex()
|
||||
{
|
||||
return frameIndex;
|
||||
|
Loading…
x
Reference in New Issue
Block a user