- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
215 lines
8.0 KiB
Java
215 lines
8.0 KiB
Java
package com.mbridge.msdk.playercommon.exoplayer2.util;
|
|
|
|
import com.applovin.exoplayer2.common.base.Ascii;
|
|
import java.nio.ByteBuffer;
|
|
import java.util.Arrays;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public final class NalUnitUtil {
|
|
public static final int EXTENDED_SAR = 255;
|
|
private static final int H264_NAL_UNIT_TYPE_SEI = 6;
|
|
private static final int H264_NAL_UNIT_TYPE_SPS = 7;
|
|
private static final int H265_NAL_UNIT_TYPE_PREFIX_SEI = 39;
|
|
private static final String TAG = "NalUnitUtil";
|
|
public static final byte[] NAL_START_CODE = {0, 0, 0, 1};
|
|
public static final float[] ASPECT_RATIO_IDC_VALUES = {1.0f, 1.0f, 1.0909091f, 0.90909094f, 1.4545455f, 1.2121212f, 2.1818182f, 1.8181819f, 2.909091f, 2.4242425f, 1.6363636f, 1.3636364f, 1.939394f, 1.6161616f, 1.3333334f, 1.5f, 2.0f};
|
|
private static final Object scratchEscapePositionsLock = new Object();
|
|
private static int[] scratchEscapePositions = new int[10];
|
|
|
|
public static final class SpsData {
|
|
public final boolean deltaPicOrderAlwaysZeroFlag;
|
|
public final boolean frameMbsOnlyFlag;
|
|
public final int frameNumLength;
|
|
public final int height;
|
|
public final int picOrderCntLsbLength;
|
|
public final int picOrderCountType;
|
|
public final float pixelWidthAspectRatio;
|
|
public final boolean separateColorPlaneFlag;
|
|
public final int seqParameterSetId;
|
|
public final int width;
|
|
|
|
public SpsData(int i, int i2, int i3, float f, boolean z, boolean z2, int i4, int i5, int i6, boolean z3) {
|
|
this.seqParameterSetId = i;
|
|
this.width = i2;
|
|
this.height = i3;
|
|
this.pixelWidthAspectRatio = f;
|
|
this.separateColorPlaneFlag = z;
|
|
this.frameMbsOnlyFlag = z2;
|
|
this.frameNumLength = i4;
|
|
this.picOrderCountType = i5;
|
|
this.picOrderCntLsbLength = i6;
|
|
this.deltaPicOrderAlwaysZeroFlag = z3;
|
|
}
|
|
}
|
|
|
|
public static final class PpsData {
|
|
public final boolean bottomFieldPicOrderInFramePresentFlag;
|
|
public final int picParameterSetId;
|
|
public final int seqParameterSetId;
|
|
|
|
public PpsData(int i, int i2, boolean z) {
|
|
this.picParameterSetId = i;
|
|
this.seqParameterSetId = i2;
|
|
this.bottomFieldPicOrderInFramePresentFlag = z;
|
|
}
|
|
}
|
|
|
|
public static int unescapeStream(byte[] bArr, int i) {
|
|
int i2;
|
|
synchronized (scratchEscapePositionsLock) {
|
|
int i3 = 0;
|
|
int i4 = 0;
|
|
while (i3 < i) {
|
|
try {
|
|
i3 = findNextUnescapeIndex(bArr, i3, i);
|
|
if (i3 < i) {
|
|
int[] iArr = scratchEscapePositions;
|
|
if (iArr.length <= i4) {
|
|
scratchEscapePositions = Arrays.copyOf(iArr, iArr.length * 2);
|
|
}
|
|
scratchEscapePositions[i4] = i3;
|
|
i3 += 3;
|
|
i4++;
|
|
}
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
i2 = i - i4;
|
|
int i5 = 0;
|
|
int i6 = 0;
|
|
for (int i7 = 0; i7 < i4; i7++) {
|
|
int i8 = scratchEscapePositions[i7] - i6;
|
|
System.arraycopy(bArr, i6, bArr, i5, i8);
|
|
int i9 = i5 + i8;
|
|
int i10 = i9 + 1;
|
|
bArr[i9] = 0;
|
|
i5 = i9 + 2;
|
|
bArr[i10] = 0;
|
|
i6 += i8 + 3;
|
|
}
|
|
System.arraycopy(bArr, i6, bArr, i5, i2 - i5);
|
|
}
|
|
return i2;
|
|
}
|
|
|
|
public static void discardToSps(ByteBuffer byteBuffer) {
|
|
int position = byteBuffer.position();
|
|
int i = 0;
|
|
int i2 = 0;
|
|
while (true) {
|
|
int i3 = i + 1;
|
|
if (i3 < position) {
|
|
int i4 = byteBuffer.get(i) & 255;
|
|
if (i2 == 3) {
|
|
if (i4 == 1 && (byteBuffer.get(i3) & Ascii.US) == 7) {
|
|
ByteBuffer duplicate = byteBuffer.duplicate();
|
|
duplicate.position(i - 3);
|
|
duplicate.limit(position);
|
|
byteBuffer.position(0);
|
|
byteBuffer.put(duplicate);
|
|
return;
|
|
}
|
|
} else if (i4 == 0) {
|
|
i2++;
|
|
}
|
|
if (i4 != 0) {
|
|
i2 = 0;
|
|
}
|
|
i = i3;
|
|
} else {
|
|
byteBuffer.clear();
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
public static boolean isNalUnitSei(String str, byte b) {
|
|
if ("video/avc".equals(str) && (b & Ascii.US) == 6) {
|
|
return true;
|
|
}
|
|
return "video/hevc".equals(str) && ((b & 126) >> 1) == 39;
|
|
}
|
|
|
|
public static int getNalUnitType(byte[] bArr, int i) {
|
|
return bArr[i + 3] & Ascii.US;
|
|
}
|
|
|
|
public static int getH265NalUnitType(byte[] bArr, int i) {
|
|
return (bArr[i + 3] & 126) >> 1;
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:28:0x00d9 */
|
|
/* JADX WARN: Removed duplicated region for block: B:31:0x00e7 */
|
|
/* JADX WARN: Removed duplicated region for block: B:48:0x012d */
|
|
/* JADX WARN: Removed duplicated region for block: B:52:0x013f */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public static com.mbridge.msdk.playercommon.exoplayer2.util.NalUnitUtil.SpsData parseSpsNalUnit(byte[] r19, int r20, int r21) {
|
|
/*
|
|
Method dump skipped, instructions count: 360
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.mbridge.msdk.playercommon.exoplayer2.util.NalUnitUtil.parseSpsNalUnit(byte[], int, int):com.mbridge.msdk.playercommon.exoplayer2.util.NalUnitUtil$SpsData");
|
|
}
|
|
|
|
public static PpsData parsePpsNalUnit(byte[] bArr, int i, int i2) {
|
|
ParsableNalUnitBitArray parsableNalUnitBitArray = new ParsableNalUnitBitArray(bArr, i, i2);
|
|
parsableNalUnitBitArray.skipBits(8);
|
|
int readUnsignedExpGolombCodedInt = parsableNalUnitBitArray.readUnsignedExpGolombCodedInt();
|
|
int readUnsignedExpGolombCodedInt2 = parsableNalUnitBitArray.readUnsignedExpGolombCodedInt();
|
|
parsableNalUnitBitArray.skipBit();
|
|
return new PpsData(readUnsignedExpGolombCodedInt, readUnsignedExpGolombCodedInt2, parsableNalUnitBitArray.readBit());
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:56:0x0079, code lost:
|
|
|
|
r9 = true;
|
|
*/
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public static int findNalUnit(byte[] r8, int r9, int r10, boolean[] r11) {
|
|
/*
|
|
Method dump skipped, instructions count: 188
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.mbridge.msdk.playercommon.exoplayer2.util.NalUnitUtil.findNalUnit(byte[], int, int, boolean[]):int");
|
|
}
|
|
|
|
public static void clearPrefixFlags(boolean[] zArr) {
|
|
zArr[0] = false;
|
|
zArr[1] = false;
|
|
zArr[2] = false;
|
|
}
|
|
|
|
private static int findNextUnescapeIndex(byte[] bArr, int i, int i2) {
|
|
while (i < i2 - 2) {
|
|
if (bArr[i] == 0 && bArr[i + 1] == 0 && bArr[i + 2] == 3) {
|
|
return i;
|
|
}
|
|
i++;
|
|
}
|
|
return i2;
|
|
}
|
|
|
|
private static void skipScalingList(ParsableNalUnitBitArray parsableNalUnitBitArray, int i) {
|
|
int i2 = 8;
|
|
int i3 = 8;
|
|
for (int i4 = 0; i4 < i; i4++) {
|
|
if (i2 != 0) {
|
|
i2 = ((parsableNalUnitBitArray.readSignedExpGolombCodedInt() + i3) + 256) % 256;
|
|
}
|
|
if (i2 != 0) {
|
|
i3 = i2;
|
|
}
|
|
}
|
|
}
|
|
|
|
private NalUnitUtil() {
|
|
}
|
|
}
|