mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Merge pull request #3371 from andymiao858/dev-v2
Fix FLV AVCVIDEOPACKET CTS Type Issue
This commit is contained in:
commit
28bd4661ed
3 changed files with 26 additions and 1 deletions
|
|
@ -79,7 +79,8 @@ import com.google.android.exoplayer2.video.AvcConfig;
|
||||||
@Override
|
@Override
|
||||||
protected void parsePayload(ParsableByteArray data, long timeUs) throws ParserException {
|
protected void parsePayload(ParsableByteArray data, long timeUs) throws ParserException {
|
||||||
int packetType = data.readUnsignedByte();
|
int packetType = data.readUnsignedByte();
|
||||||
int compositionTimeMs = data.readUnsignedInt24();
|
int compositionTimeMs = data.readSignedInt24();
|
||||||
|
|
||||||
timeUs += compositionTimeMs * 1000L;
|
timeUs += compositionTimeMs * 1000L;
|
||||||
// Parse avc sequence header in case this was not done before.
|
// Parse avc sequence header in case this was not done before.
|
||||||
if (packetType == AVC_PACKET_TYPE_SEQUENCE_HEADER && !hasOutputFormat) {
|
if (packetType == AVC_PACKET_TYPE_SEQUENCE_HEADER && !hasOutputFormat) {
|
||||||
|
|
|
||||||
|
|
@ -256,6 +256,14 @@ public final class ParsableByteArray {
|
||||||
| (data[position++] & 0xFF);
|
| (data[position++] & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the next three bytes as an signed value.
|
||||||
|
*/
|
||||||
|
public int readSignedInt24() {
|
||||||
|
int ui24 = readUnsignedInt24();
|
||||||
|
return (ui24 & 0x800000L) >>> 23 == 1 ? (ui24 | 0xff000000) : ui24;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the next three bytes as a signed value in little endian order.
|
* Reads the next three bytes as a signed value in little endian order.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -334,6 +334,22 @@ public final class ParsableByteArrayTest {
|
||||||
assertThat(byteArray.getPosition()).isEqualTo(3);
|
assertThat(byteArray.getPosition()).isEqualTo(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReadPositiveSignedInt24() {
|
||||||
|
byte[] data = { 0x01, 0x02, (byte) 0xFF };
|
||||||
|
ParsableByteArray byteArray = new ParsableByteArray(data);
|
||||||
|
assertThat(byteArray.readSignedInt24()).isEqualTo(0x0102FF);
|
||||||
|
assertThat(byteArray.getPosition()).isEqualTo(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testReadNegativeSignedInt24() {
|
||||||
|
byte[] data = { (byte)0xFF, 0x02, (byte) 0x01 };
|
||||||
|
ParsableByteArray byteArray = new ParsableByteArray(data);
|
||||||
|
assertThat(byteArray.readSignedInt24()).isEqualTo(0xFFFF0201);
|
||||||
|
assertThat(byteArray.getPosition()).isEqualTo(3);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReadLittleEndianUnsignedShort() {
|
public void testReadLittleEndianUnsignedShort() {
|
||||||
ParsableByteArray byteArray = new ParsableByteArray(new byte[] {
|
ParsableByteArray byteArray = new ParsableByteArray(new byte[] {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue