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

219 lines
7.8 KiB
Java

package androidx.media3.extractor;
import androidx.media3.common.DrmInitData;
import androidx.media3.common.Format;
import androidx.media3.common.util.ParsableBitArray;
import com.google.android.material.internal.ViewUtils;
import io.flutter.plugin.platform.PlatformPlugin;
import java.nio.ByteBuffer;
import java.util.Arrays;
/* loaded from: classes2.dex */
public final class DtsUtil {
public static final int DTS_HD_MAX_RATE_BYTES_PER_SECOND = 2250000;
public static final int DTS_MAX_RATE_BYTES_PER_SECOND = 192000;
private static final byte FIRST_BYTE_14B_BE = 31;
private static final byte FIRST_BYTE_14B_LE = -1;
private static final byte FIRST_BYTE_BE = Byte.MAX_VALUE;
private static final byte FIRST_BYTE_LE = -2;
private static final int SYNC_EXT_SUB_LE = 622876772;
private static final int SYNC_FTOC_LE = -233094848;
private static final int SYNC_FTOC_NON_SYNC_LE = -398277519;
private static final int SYNC_VALUE_14B_BE = 536864768;
private static final int SYNC_VALUE_14B_LE = -14745368;
private static final int SYNC_VALUE_BE = 2147385345;
private static final int SYNC_VALUE_LE = -25230976;
private static final int[] CHANNELS_BY_AMODE = {1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8};
private static final int[] SAMPLE_RATE_BY_SFREQ = {-1, 8000, 16000, 32000, -1, -1, 11025, 22050, 44100, -1, -1, 12000, 24000, 48000, -1, -1};
private static final int[] TWICE_BITRATE_KBPS_BY_RATE = {64, 112, 128, 192, 224, 256, 384, 448, 512, 640, ViewUtils.EDGE_TO_EDGE_FLAGS, 896, 1024, 1152, PlatformPlugin.DEFAULT_SYSTEM_UI, 1536, 1920, 2048, 2304, 2560, 2688, 2816, 2823, 2944, 3072, 3840, 4096, 6144, 7680};
public static boolean isSyncWord(int i) {
return i == SYNC_VALUE_BE || i == SYNC_VALUE_LE || i == SYNC_VALUE_14B_BE || i == SYNC_VALUE_14B_LE;
}
public static Format parseDtsFormat(byte[] bArr, String str, String str2, DrmInitData drmInitData) {
ParsableBitArray normalizedFrameHeader = getNormalizedFrameHeader(bArr);
normalizedFrameHeader.skipBits(60);
int i = CHANNELS_BY_AMODE[normalizedFrameHeader.readBits(6)];
int i2 = SAMPLE_RATE_BY_SFREQ[normalizedFrameHeader.readBits(4)];
int readBits = normalizedFrameHeader.readBits(5);
int[] iArr = TWICE_BITRATE_KBPS_BY_RATE;
int i3 = readBits >= iArr.length ? -1 : (iArr[readBits] * 1000) / 2;
normalizedFrameHeader.skipBits(10);
return new Format.Builder().setId(str).setSampleMimeType("audio/vnd.dts").setAverageBitrate(i3).setChannelCount(i + (normalizedFrameHeader.readBits(2) > 0 ? 1 : 0)).setSampleRate(i2).setDrmInitData(drmInitData).setLanguage(str2).build();
}
public static int parseDtsAudioSampleCount(byte[] bArr) {
int i;
byte b;
int i2;
byte b2;
byte b3 = bArr[0];
if (b3 != -2) {
if (b3 == -1) {
i = (bArr[4] & 7) << 4;
b2 = bArr[7];
} else if (b3 == 31) {
i = (bArr[5] & 7) << 4;
b2 = bArr[6];
} else {
i = (bArr[4] & 1) << 6;
b = bArr[5];
}
i2 = b2 & 60;
return (((i2 >> 2) | i) + 1) * 32;
}
i = (bArr[5] & 1) << 6;
b = bArr[4];
i2 = b & 252;
return (((i2 >> 2) | i) + 1) * 32;
}
public static int parseDtsAudioSampleCount(ByteBuffer byteBuffer) {
int i;
byte b;
int i2;
byte b2;
if (byteBuffer.getInt(0) == SYNC_FTOC_LE || byteBuffer.getInt(0) == SYNC_FTOC_NON_SYNC_LE) {
return 1024;
}
if (byteBuffer.getInt(0) == SYNC_EXT_SUB_LE) {
return 4096;
}
int position = byteBuffer.position();
byte b3 = byteBuffer.get(position);
if (b3 != -2) {
if (b3 == -1) {
i = (byteBuffer.get(position + 4) & 7) << 4;
b2 = byteBuffer.get(position + 7);
} else if (b3 == 31) {
i = (byteBuffer.get(position + 5) & 7) << 4;
b2 = byteBuffer.get(position + 6);
} else {
i = (byteBuffer.get(position + 4) & 1) << 6;
b = byteBuffer.get(position + 5);
}
i2 = b2 & 60;
return (((i2 >> 2) | i) + 1) * 32;
}
i = (byteBuffer.get(position + 5) & 1) << 6;
b = byteBuffer.get(position + 4);
i2 = b & 252;
return (((i2 >> 2) | i) + 1) * 32;
}
/* JADX WARN: Removed duplicated region for block: B:10:0x005f */
/* JADX WARN: Removed duplicated region for block: B:13:? A[RETURN, SYNTHETIC] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static int getDtsFrameSize(byte[] r7) {
/*
r0 = 0
r1 = r7[r0]
r2 = -2
r3 = 6
r4 = 7
r5 = 1
r6 = 4
if (r1 == r2) goto L4a
r2 = -1
if (r1 == r2) goto L32
r2 = 31
if (r1 == r2) goto L21
r1 = 5
r1 = r7[r1]
r1 = r1 & 3
int r1 = r1 << 12
r2 = r7[r3]
r2 = r2 & 255(0xff, float:3.57E-43)
int r2 = r2 << r6
r1 = r1 | r2
r7 = r7[r4]
goto L58
L21:
r0 = r7[r3]
r0 = r0 & 3
int r0 = r0 << 12
r1 = r7[r4]
r1 = r1 & 255(0xff, float:3.57E-43)
int r1 = r1 << r6
r0 = r0 | r1
r1 = 8
r7 = r7[r1]
goto L42
L32:
r0 = r7[r4]
r0 = r0 & 3
int r0 = r0 << 12
r1 = r7[r3]
r1 = r1 & 255(0xff, float:3.57E-43)
int r1 = r1 << r6
r0 = r0 | r1
r1 = 9
r7 = r7[r1]
L42:
r7 = r7 & 60
int r7 = r7 >> 2
r7 = r7 | r0
int r7 = r7 + r5
r0 = r5
goto L5d
L4a:
r1 = r7[r6]
r1 = r1 & 3
int r1 = r1 << 12
r2 = r7[r4]
r2 = r2 & 255(0xff, float:3.57E-43)
int r2 = r2 << r6
r1 = r1 | r2
r7 = r7[r3]
L58:
r7 = r7 & 240(0xf0, float:3.36E-43)
int r7 = r7 >> r6
r7 = r7 | r1
int r7 = r7 + r5
L5d:
if (r0 == 0) goto L63
int r7 = r7 * 16
int r7 = r7 / 14
L63:
return r7
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.media3.extractor.DtsUtil.getDtsFrameSize(byte[]):int");
}
private static ParsableBitArray getNormalizedFrameHeader(byte[] bArr) {
if (bArr[0] == Byte.MAX_VALUE) {
return new ParsableBitArray(bArr);
}
byte[] copyOf = Arrays.copyOf(bArr, bArr.length);
if (isLittleEndianFrameHeader(copyOf)) {
for (int i = 0; i < copyOf.length - 1; i += 2) {
byte b = copyOf[i];
int i2 = i + 1;
copyOf[i] = copyOf[i2];
copyOf[i2] = b;
}
}
ParsableBitArray parsableBitArray = new ParsableBitArray(copyOf);
if (copyOf[0] == 31) {
ParsableBitArray parsableBitArray2 = new ParsableBitArray(copyOf);
while (parsableBitArray2.bitsLeft() >= 16) {
parsableBitArray2.skipBits(2);
parsableBitArray.putInt(parsableBitArray2.readBits(14), 14);
}
}
parsableBitArray.reset(copyOf);
return parsableBitArray;
}
private static boolean isLittleEndianFrameHeader(byte[] bArr) {
byte b = bArr[0];
return b == -2 || b == -1;
}
private DtsUtil() {
}
}