Rabbit-R1/android (non root)/java/sources/androidx/media3/extractor/Ac4Util.java
2024-05-21 17:08:36 -04:00

210 lines
6.8 KiB
Java

package androidx.media3.extractor;
import androidx.media3.common.DrmInitData;
import androidx.media3.common.Format;
import androidx.media3.common.util.ParsableBitArray;
import androidx.media3.common.util.ParsableByteArray;
import com.google.common.primitives.SignedBytes;
import java.nio.ByteBuffer;
/* loaded from: classes2.dex */
public final class Ac4Util {
public static final int AC40_SYNCWORD = 44096;
public static final int AC41_SYNCWORD = 44097;
private static final int CHANNEL_COUNT_2 = 2;
public static final int HEADER_SIZE_FOR_PARSER = 16;
public static final int MAX_RATE_BYTES_PER_SECOND = 336000;
private static final int[] SAMPLE_COUNT = {2002, 2000, 1920, 1601, 1600, 1001, 1000, 960, 800, 800, 480, 400, 400, 2048};
public static final int SAMPLE_HEADER_SIZE = 7;
/* loaded from: classes2.dex */
public static final class SyncFrameInfo {
public final int bitstreamVersion;
public final int channelCount;
public final int frameSize;
public final int sampleCount;
public final int sampleRate;
private SyncFrameInfo(int i, int i2, int i3, int i4, int i5) {
this.bitstreamVersion = i;
this.channelCount = i2;
this.sampleRate = i3;
this.frameSize = i4;
this.sampleCount = i5;
}
}
public static Format parseAc4AnnexEFormat(ParsableByteArray parsableByteArray, String str, String str2, DrmInitData drmInitData) {
parsableByteArray.skipBytes(1);
return new Format.Builder().setId(str).setSampleMimeType("audio/ac4").setChannelCount(2).setSampleRate(((parsableByteArray.readUnsignedByte() & 32) >> 5) == 1 ? 48000 : 44100).setDrmInitData(drmInitData).setLanguage(str2).build();
}
/* JADX WARN: Code restructure failed: missing block: B:37:0x0080, code lost:
if (r11 != 11) goto L46;
*/
/* JADX WARN: Code restructure failed: missing block: B:41:0x0085, code lost:
if (r11 != 11) goto L46;
*/
/* JADX WARN: Code restructure failed: missing block: B:43:0x008a, code lost:
if (r11 != 8) goto L46;
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static androidx.media3.extractor.Ac4Util.SyncFrameInfo parseAc4SyncframeInfo(androidx.media3.common.util.ParsableBitArray r11) {
/*
r0 = 16
int r1 = r11.readBits(r0)
int r0 = r11.readBits(r0)
r2 = 65535(0xffff, float:9.1834E-41)
r3 = 4
if (r0 != r2) goto L18
r0 = 24
int r0 = r11.readBits(r0)
r2 = 7
goto L19
L18:
r2 = r3
L19:
int r0 = r0 + r2
r2 = 44097(0xac41, float:6.1793E-41)
if (r1 != r2) goto L21
int r0 = r0 + 2
L21:
r8 = r0
r0 = 2
int r1 = r11.readBits(r0)
r2 = 3
if (r1 != r2) goto L2f
int r4 = readVariableBits(r11, r0)
int r1 = r1 + r4
L2f:
r5 = r1
r1 = 10
int r1 = r11.readBits(r1)
boolean r4 = r11.readBit()
if (r4 == 0) goto L45
int r4 = r11.readBits(r2)
if (r4 <= 0) goto L45
r11.skipBits(r0)
L45:
boolean r4 = r11.readBit()
r6 = 48000(0xbb80, float:6.7262E-41)
r7 = 44100(0xac44, float:6.1797E-41)
if (r4 == 0) goto L53
r9 = r6
goto L54
L53:
r9 = r7
L54:
int r11 = r11.readBits(r3)
if (r9 != r7) goto L63
r4 = 13
if (r11 != r4) goto L63
int[] r0 = androidx.media3.extractor.Ac4Util.SAMPLE_COUNT
r11 = r0[r11]
goto L93
L63:
if (r9 != r6) goto L92
int[] r4 = androidx.media3.extractor.Ac4Util.SAMPLE_COUNT
int r6 = r4.length
if (r11 >= r6) goto L92
r4 = r4[r11]
int r1 = r1 % 5
r6 = 8
r7 = 1
if (r1 == r7) goto L88
r7 = 11
if (r1 == r0) goto L83
if (r1 == r2) goto L88
if (r1 == r3) goto L7c
goto L8d
L7c:
if (r11 == r2) goto L8f
if (r11 == r6) goto L8f
if (r11 != r7) goto L8d
goto L8f
L83:
if (r11 == r6) goto L8f
if (r11 != r7) goto L8d
goto L8f
L88:
if (r11 == r2) goto L8f
if (r11 != r6) goto L8d
goto L8f
L8d:
r11 = r4
goto L93
L8f:
int r4 = r4 + 1
goto L8d
L92:
r11 = 0
L93:
androidx.media3.extractor.Ac4Util$SyncFrameInfo r0 = new androidx.media3.extractor.Ac4Util$SyncFrameInfo
r6 = 2
r10 = 0
r4 = r0
r7 = r9
r9 = r11
r4.<init>(r5, r6, r7, r8, r9)
return r0
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.media3.extractor.Ac4Util.parseAc4SyncframeInfo(androidx.media3.common.util.ParsableBitArray):androidx.media3.extractor.Ac4Util$SyncFrameInfo");
}
public static int parseAc4SyncframeSize(byte[] bArr, int i) {
int i2 = 7;
if (bArr.length < 7) {
return -1;
}
int i3 = ((bArr[2] & 255) << 8) | (bArr[3] & 255);
if (i3 == 65535) {
i3 = ((bArr[4] & 255) << 16) | ((bArr[5] & 255) << 8) | (bArr[6] & 255);
} else {
i2 = 4;
}
if (i == 44097) {
i2 += 2;
}
return i3 + i2;
}
public static int parseAc4SyncframeAudioSampleCount(ByteBuffer byteBuffer) {
byte[] bArr = new byte[16];
int position = byteBuffer.position();
byteBuffer.get(bArr);
byteBuffer.position(position);
return parseAc4SyncframeInfo(new ParsableBitArray(bArr)).sampleCount;
}
public static void getAc4SampleHeader(int i, ParsableByteArray parsableByteArray) {
parsableByteArray.reset(7);
byte[] data = parsableByteArray.getData();
data[0] = -84;
data[1] = SignedBytes.MAX_POWER_OF_TWO;
data[2] = -1;
data[3] = -1;
data[4] = (byte) ((i >> 16) & 255);
data[5] = (byte) ((i >> 8) & 255);
data[6] = (byte) (i & 255);
}
private static int readVariableBits(ParsableBitArray parsableBitArray, int i) {
int i2 = 0;
while (true) {
int readBits = i2 + parsableBitArray.readBits(i);
if (!parsableBitArray.readBit()) {
return readBits;
}
i2 = (readBits + 1) << i;
}
}
private Ac4Util() {
}
}