mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-27 09:32:27 -06:00
50 lines
1.7 KiB
Java
50 lines
1.7 KiB
Java
package androidx.media3.extractor.ts;
|
|
|
|
import androidx.media3.common.util.ParsableByteArray;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class TsUtil {
|
|
public static boolean isStartOfTsPacket(byte[] bArr, int i, int i2, int i3) {
|
|
int i4 = 0;
|
|
for (int i5 = -4; i5 <= 4; i5++) {
|
|
int i6 = (i5 * 188) + i3;
|
|
if (i6 < i || i6 >= i2 || bArr[i6] != 71) {
|
|
i4 = 0;
|
|
} else {
|
|
i4++;
|
|
if (i4 == 5) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static int findSyncBytePosition(byte[] bArr, int i, int i2) {
|
|
while (i < i2 && bArr[i] != 71) {
|
|
i++;
|
|
}
|
|
return i;
|
|
}
|
|
|
|
public static long readPcrFromPacket(ParsableByteArray parsableByteArray, int i, int i2) {
|
|
parsableByteArray.setPosition(i);
|
|
if (parsableByteArray.bytesLeft() < 5) {
|
|
return -9223372036854775807L;
|
|
}
|
|
int readInt = parsableByteArray.readInt();
|
|
if ((8388608 & readInt) != 0 || ((2096896 & readInt) >> 8) != i2 || (readInt & 32) == 0 || parsableByteArray.readUnsignedByte() < 7 || parsableByteArray.bytesLeft() < 7 || (parsableByteArray.readUnsignedByte() & 16) != 16) {
|
|
return -9223372036854775807L;
|
|
}
|
|
byte[] bArr = new byte[6];
|
|
parsableByteArray.readBytes(bArr, 0, 6);
|
|
return readPcrValueFromPcrBytes(bArr);
|
|
}
|
|
|
|
private static long readPcrValueFromPcrBytes(byte[] bArr) {
|
|
return ((bArr[0] & 255) << 25) | ((bArr[1] & 255) << 17) | ((bArr[2] & 255) << 9) | ((bArr[3] & 255) << 1) | ((255 & bArr[4]) >> 7);
|
|
}
|
|
|
|
private TsUtil() {
|
|
}
|
|
}
|