Commit f8cd3a97 by Rakesh Kumar

Fix some more review comment in RTP H263 Reader.

Change-Id: If1f80a369b47319251e262c8f171091bb37e90c5
parent ff80a41f
...@@ -39,6 +39,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -39,6 +39,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
/** I-frame VOP unit type. */ /** I-frame VOP unit type. */
private static final int I_VOP = 0; private static final int I_VOP = 0;
private static final int PICTURE_START_CODE = 128;
private final RtpPayloadFormat payloadFormat; private final RtpPayloadFormat payloadFormat;
...@@ -71,7 +72,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -71,7 +72,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
@Override @Override
public void createTracks(ExtractorOutput extractorOutput, int trackId) { public void createTracks(ExtractorOutput extractorOutput, int trackId) {
trackOutput = extractorOutput.track(trackId, C.TRACK_TYPE_VIDEO); trackOutput = extractorOutput.track(trackId, C.TRACK_TYPE_VIDEO);
castNonNull(trackOutput).format(payloadFormat.format); trackOutput.format(payloadFormat.format);
} }
@Override @Override
...@@ -90,24 +91,25 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -90,24 +91,25 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
int currPosition = data.getPosition(); int currPosition = data.getPosition();
int header = data.readUnsignedShort(); int header = data.readUnsignedShort();
boolean pBit = ((header & 0x400) == 0x400); boolean pBitIsSet = ((header & 0x400) > 0);
// Check if optional Video Redundancy Coding or PLEN or PEBIT is present, RFC4629 Section 5.1. // Check if optional V (Video Redundancy Coding), PLEN or PEBIT is present, RFC4629 Section 5.1.
if ((header & 0x200) != 0 || (header & 0x1f8) != 0 || (header & 0x7) != 0) { if ((header & 0x200) != 0 || (header & 0x1f8) != 0 || (header & 0x7) != 0) {
Log.w(TAG, "Packet discarded due to (VRC != 0) or (PLEN != 0) or (PEBIT != 0)"); Log.w(TAG, "Packet discarded due to (VRC != 0) or (PLEN != 0) or (PEBIT != 0)");
return; return;
} }
int startCodePayload = data.peekUnsignedByte() & 0xfc;
if (pBit == true) { if (pBitIsSet == true) {
if (startCodePayload < 128) { int startCodePayload = data.peekUnsignedByte() & 0xfc;
// Packets that begin with a Picture Start Code(100000). Refer RFC4629 Section 6.1.1.
if (startCodePayload < PICTURE_START_CODE) {
Log.w(TAG, "Picture start Code (PSC) missing, Dropping packet."); Log.w(TAG, "Picture start Code (PSC) missing, Dropping packet.");
return; return;
} else {
// Setting first two bytes of the start code. Refer RFC4629 Section 5.1.
data.getData()[currPosition] = 0;
data.getData()[currPosition + 1] = 0;
data.setPosition(currPosition);
} }
// Setting first two bytes of the start code. Refer RFC4629 Section 6.1.1.
data.getData()[currPosition] = 0;
data.getData()[currPosition + 1] = 0;
data.setPosition(currPosition);
} else { } else {
// Check that this packet is in the sequence of the previous packet. // Check that this packet is in the sequence of the previous packet.
int expectedSequenceNumber = RtpPacket.getNextSequenceNumber(previousSequenceNumber); int expectedSequenceNumber = RtpPacket.getNextSequenceNumber(previousSequenceNumber);
...@@ -124,7 +126,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -124,7 +126,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
if (fragmentedSampleSizeBytes == 0) { if (fragmentedSampleSizeBytes == 0) {
getBufferFlagsAndResolutionFromVop(data, isOutputFormatSet); getBufferFlagsAndResolutionFromVop(data, isOutputFormatSet);
if (!isOutputFormatSet && isKeyFrame == true) { if (!isOutputFormatSet && isKeyFrame) {
if (width != payloadFormat.format.width || height != payloadFormat.format.height) { if (width != payloadFormat.format.width || height != payloadFormat.format.height) {
trackOutput.format( trackOutput.format(
payloadFormat.format.buildUpon().setWidth(width).setHeight(height).build()); payloadFormat.format.buildUpon().setWidth(width).setHeight(height).build());
...@@ -168,7 +170,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -168,7 +170,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
private void getBufferFlagsAndResolutionFromVop(ParsableByteArray data, boolean gotResolution) { private void getBufferFlagsAndResolutionFromVop(ParsableByteArray data, boolean gotResolution) {
// Picture Segment Packets (RFC4629 Section 6.1). // Picture Segment Packets (RFC4629 Section 6.1).
// Search for SHORT_VIDEO_START_MARKER (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0). // Search for SHORT_VIDEO_START_MARKER (0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0).
int currPosition = data.getPosition(); int currDataOffset = data.getPosition();
long shortHeader = data.readUnsignedInt(); long shortHeader = data.readUnsignedInt();
if ((shortHeader & 0xffff) >> 10 == 0x20) { if ((shortHeader & 0xffff) >> 10 == 0x20) {
int header = data.peekUnsignedByte(); int header = data.peekUnsignedByte();
...@@ -190,11 +192,11 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -190,11 +192,11 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
height = (short) (144 << (sourceFormat - 2)); height = (short) (144 << (sourceFormat - 2));
} }
} }
data.setPosition(currPosition); data.setPosition(currDataOffset);
isKeyFrame = (vopType == I_VOP ? true : false); isKeyFrame = (vopType == I_VOP ? true : false);
return; return;
} }
data.setPosition(currPosition); data.setPosition(currDataOffset);
isKeyFrame = false; isKeyFrame = false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment