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

93 lines
3.7 KiB
Java

package androidx.media3.extractor;
import androidx.media3.common.ParserException;
import androidx.media3.common.util.CodecSpecificDataUtil;
import androidx.media3.common.util.ParsableByteArray;
import androidx.media3.container.NalUnitUtil;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes2.dex */
public final class AvcConfig {
public final String codecs;
public final int colorRange;
public final int colorSpace;
public final int colorTransfer;
public final int height;
public final List<byte[]> initializationData;
public final int nalUnitLengthFieldLength;
public final float pixelWidthHeightRatio;
public final int width;
public static AvcConfig parse(ParsableByteArray parsableByteArray) throws ParserException {
int i;
int i2;
int i3;
int i4;
int i5;
float f;
String str;
try {
parsableByteArray.skipBytes(4);
int readUnsignedByte = (parsableByteArray.readUnsignedByte() & 3) + 1;
if (readUnsignedByte == 3) {
throw new IllegalStateException();
}
ArrayList arrayList = new ArrayList();
int readUnsignedByte2 = parsableByteArray.readUnsignedByte() & 31;
for (int i6 = 0; i6 < readUnsignedByte2; i6++) {
arrayList.add(buildNalUnitForChild(parsableByteArray));
}
int readUnsignedByte3 = parsableByteArray.readUnsignedByte();
for (int i7 = 0; i7 < readUnsignedByte3; i7++) {
arrayList.add(buildNalUnitForChild(parsableByteArray));
}
if (readUnsignedByte2 > 0) {
NalUnitUtil.SpsData parseSpsNalUnit = NalUnitUtil.parseSpsNalUnit((byte[]) arrayList.get(0), readUnsignedByte, ((byte[]) arrayList.get(0)).length);
int i8 = parseSpsNalUnit.width;
int i9 = parseSpsNalUnit.height;
int i10 = parseSpsNalUnit.colorSpace;
int i11 = parseSpsNalUnit.colorRange;
int i12 = parseSpsNalUnit.colorTransfer;
float f2 = parseSpsNalUnit.pixelWidthHeightRatio;
str = CodecSpecificDataUtil.buildAvcCodecString(parseSpsNalUnit.profileIdc, parseSpsNalUnit.constraintsFlagsAndReservedZero2Bits, parseSpsNalUnit.levelIdc);
i4 = i11;
i5 = i12;
f = f2;
i = i8;
i2 = i9;
i3 = i10;
} else {
i = -1;
i2 = -1;
i3 = -1;
i4 = -1;
i5 = -1;
f = 1.0f;
str = null;
}
return new AvcConfig(arrayList, readUnsignedByte, i, i2, i3, i4, i5, f, str);
} catch (ArrayIndexOutOfBoundsException e) {
throw ParserException.createForMalformedContainer("Error parsing AVC config", e);
}
}
private AvcConfig(List<byte[]> list, int i, int i2, int i3, int i4, int i5, int i6, float f, String str) {
this.initializationData = list;
this.nalUnitLengthFieldLength = i;
this.width = i2;
this.height = i3;
this.colorSpace = i4;
this.colorRange = i5;
this.colorTransfer = i6;
this.pixelWidthHeightRatio = f;
this.codecs = str;
}
private static byte[] buildNalUnitForChild(ParsableByteArray parsableByteArray) {
int readUnsignedShort = parsableByteArray.readUnsignedShort();
int position = parsableByteArray.getPosition();
parsableByteArray.skipBytes(readUnsignedShort);
return CodecSpecificDataUtil.buildNalUnit(parsableByteArray.getData(), position, readUnsignedShort);
}
}