mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-28 18:12:31 -06:00
1172 lines
56 KiB
Java
1172 lines
56 KiB
Java
package androidx.media3.extractor.mp4;
|
|
|
|
import android.util.Pair;
|
|
import androidx.media3.common.ColorInfo;
|
|
import androidx.media3.common.DrmInitData;
|
|
import androidx.media3.common.Format;
|
|
import androidx.media3.common.Metadata;
|
|
import androidx.media3.common.MimeTypes;
|
|
import androidx.media3.common.ParserException;
|
|
import androidx.media3.common.util.Assertions;
|
|
import androidx.media3.common.util.Log;
|
|
import androidx.media3.common.util.ParsableByteArray;
|
|
import androidx.media3.common.util.Util;
|
|
import androidx.media3.container.CreationTime;
|
|
import androidx.media3.container.MdtaMetadataEntry;
|
|
import androidx.media3.container.Mp4LocationData;
|
|
import androidx.media3.extractor.AvcConfig;
|
|
import androidx.media3.extractor.DolbyVisionConfig;
|
|
import androidx.media3.extractor.ExtractorUtil;
|
|
import androidx.media3.extractor.GaplessInfoHolder;
|
|
import androidx.media3.extractor.HevcConfig;
|
|
import androidx.media3.extractor.metadata.mp4.SmtaMetadataEntry;
|
|
import androidx.media3.extractor.mp4.Atom;
|
|
import androidx.work.WorkRequest;
|
|
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
|
|
import com.google.common.base.Function;
|
|
import com.google.common.collect.ImmutableList;
|
|
import com.google.common.primitives.Ints;
|
|
import java.nio.ByteBuffer;
|
|
import java.nio.ByteOrder;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
|
|
/* loaded from: classes2.dex */
|
|
final class AtomParsers {
|
|
private static final int MAX_GAPLESS_TRIM_SIZE_SAMPLES = 4;
|
|
private static final String TAG = "AtomParsers";
|
|
private static final int TYPE_clcp = 1668047728;
|
|
private static final int TYPE_mdta = 1835299937;
|
|
private static final int TYPE_meta = 1835365473;
|
|
private static final int TYPE_nclc = 1852009571;
|
|
private static final int TYPE_nclx = 1852009592;
|
|
private static final int TYPE_sbtl = 1935832172;
|
|
private static final int TYPE_soun = 1936684398;
|
|
private static final int TYPE_subt = 1937072756;
|
|
private static final int TYPE_text = 1952807028;
|
|
private static final int TYPE_vide = 1986618469;
|
|
private static final byte[] opusMagic = Util.getUtf8Bytes("OpusHead");
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* loaded from: classes2.dex */
|
|
public interface SampleSizeBox {
|
|
int getFixedSampleSize();
|
|
|
|
int getSampleCount();
|
|
|
|
int readNextSampleSize();
|
|
}
|
|
|
|
private static boolean canTrimSamplesWithTimestampChange(int i) {
|
|
return i != 1;
|
|
}
|
|
|
|
private static int getTrackTypeForHdlr(int i) {
|
|
if (i == TYPE_soun) {
|
|
return 1;
|
|
}
|
|
if (i == TYPE_vide) {
|
|
return 2;
|
|
}
|
|
if (i == TYPE_text || i == TYPE_sbtl || i == TYPE_subt || i == TYPE_clcp) {
|
|
return 3;
|
|
}
|
|
return i == 1835365473 ? 5 : -1;
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
public static final class UdtaInfo {
|
|
public final Metadata metaMetadata;
|
|
public final Metadata smtaMetadata;
|
|
public final Metadata xyzMetadata;
|
|
|
|
public UdtaInfo(Metadata metadata, Metadata metadata2, Metadata metadata3) {
|
|
this.metaMetadata = metadata;
|
|
this.smtaMetadata = metadata2;
|
|
this.xyzMetadata = metadata3;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
public static final class MvhdInfo {
|
|
public final Metadata metadata;
|
|
public final long timescale;
|
|
|
|
public MvhdInfo(Metadata metadata, long j) {
|
|
this.metadata = metadata;
|
|
this.timescale = j;
|
|
}
|
|
}
|
|
|
|
public static List<TrackSampleTable> parseTraks(Atom.ContainerAtom containerAtom, GaplessInfoHolder gaplessInfoHolder, long j, DrmInitData drmInitData, boolean z, boolean z2, Function<Track, Track> function) throws ParserException {
|
|
Track apply;
|
|
ArrayList arrayList = new ArrayList();
|
|
for (int i = 0; i < containerAtom.containerChildren.size(); i++) {
|
|
Atom.ContainerAtom containerAtom2 = containerAtom.containerChildren.get(i);
|
|
if (containerAtom2.type == 1953653099 && (apply = function.apply(parseTrak(containerAtom2, (Atom.LeafAtom) Assertions.checkNotNull(containerAtom.getLeafAtomOfType(1836476516)), j, drmInitData, z, z2))) != null) {
|
|
arrayList.add(parseStbl(apply, (Atom.ContainerAtom) Assertions.checkNotNull(((Atom.ContainerAtom) Assertions.checkNotNull(((Atom.ContainerAtom) Assertions.checkNotNull(containerAtom2.getContainerAtomOfType(1835297121))).getContainerAtomOfType(1835626086))).getContainerAtomOfType(1937007212)), gaplessInfoHolder));
|
|
}
|
|
}
|
|
return arrayList;
|
|
}
|
|
|
|
public static UdtaInfo parseUdta(Atom.LeafAtom leafAtom) {
|
|
ParsableByteArray parsableByteArray = leafAtom.data;
|
|
parsableByteArray.setPosition(8);
|
|
Metadata metadata = null;
|
|
Metadata metadata2 = null;
|
|
Metadata metadata3 = null;
|
|
while (parsableByteArray.bytesLeft() >= 8) {
|
|
int position = parsableByteArray.getPosition();
|
|
int readInt = parsableByteArray.readInt();
|
|
int readInt2 = parsableByteArray.readInt();
|
|
if (readInt2 == 1835365473) {
|
|
parsableByteArray.setPosition(position);
|
|
metadata = parseUdtaMeta(parsableByteArray, position + readInt);
|
|
} else if (readInt2 == 1936553057) {
|
|
parsableByteArray.setPosition(position);
|
|
metadata2 = parseSmta(parsableByteArray, position + readInt);
|
|
} else if (readInt2 == -1451722374) {
|
|
metadata3 = parseXyz(parsableByteArray);
|
|
}
|
|
parsableByteArray.setPosition(position + readInt);
|
|
}
|
|
return new UdtaInfo(metadata, metadata2, metadata3);
|
|
}
|
|
|
|
public static MvhdInfo parseMvhd(ParsableByteArray parsableByteArray) {
|
|
long j;
|
|
parsableByteArray.setPosition(8);
|
|
if (Atom.parseFullAtomVersion(parsableByteArray.readInt()) == 0) {
|
|
j = parsableByteArray.readUnsignedInt();
|
|
parsableByteArray.skipBytes(4);
|
|
} else {
|
|
long readLong = parsableByteArray.readLong();
|
|
parsableByteArray.skipBytes(8);
|
|
j = readLong;
|
|
}
|
|
return new MvhdInfo(new Metadata(new CreationTime((j - 2082844800) * 1000)), parsableByteArray.readUnsignedInt());
|
|
}
|
|
|
|
public static Metadata parseMdtaFromMeta(Atom.ContainerAtom containerAtom) {
|
|
Atom.LeafAtom leafAtomOfType = containerAtom.getLeafAtomOfType(1751411826);
|
|
Atom.LeafAtom leafAtomOfType2 = containerAtom.getLeafAtomOfType(1801812339);
|
|
Atom.LeafAtom leafAtomOfType3 = containerAtom.getLeafAtomOfType(1768715124);
|
|
if (leafAtomOfType == null || leafAtomOfType2 == null || leafAtomOfType3 == null || parseHdlr(leafAtomOfType.data) != TYPE_mdta) {
|
|
return null;
|
|
}
|
|
ParsableByteArray parsableByteArray = leafAtomOfType2.data;
|
|
parsableByteArray.setPosition(12);
|
|
int readInt = parsableByteArray.readInt();
|
|
String[] strArr = new String[readInt];
|
|
for (int i = 0; i < readInt; i++) {
|
|
int readInt2 = parsableByteArray.readInt();
|
|
parsableByteArray.skipBytes(4);
|
|
strArr[i] = parsableByteArray.readString(readInt2 - 8);
|
|
}
|
|
ParsableByteArray parsableByteArray2 = leafAtomOfType3.data;
|
|
parsableByteArray2.setPosition(8);
|
|
ArrayList arrayList = new ArrayList();
|
|
while (parsableByteArray2.bytesLeft() > 8) {
|
|
int position = parsableByteArray2.getPosition();
|
|
int readInt3 = parsableByteArray2.readInt();
|
|
int readInt4 = parsableByteArray2.readInt() - 1;
|
|
if (readInt4 >= 0 && readInt4 < readInt) {
|
|
MdtaMetadataEntry parseMdtaMetadataEntryFromIlst = MetadataUtil.parseMdtaMetadataEntryFromIlst(parsableByteArray2, position + readInt3, strArr[readInt4]);
|
|
if (parseMdtaMetadataEntryFromIlst != null) {
|
|
arrayList.add(parseMdtaMetadataEntryFromIlst);
|
|
}
|
|
} else {
|
|
Log.w(TAG, "Skipped metadata with unknown key index: " + readInt4);
|
|
}
|
|
parsableByteArray2.setPosition(position + readInt3);
|
|
}
|
|
if (arrayList.isEmpty()) {
|
|
return null;
|
|
}
|
|
return new Metadata(arrayList);
|
|
}
|
|
|
|
public static void maybeSkipRemainingMetaAtomHeaderBytes(ParsableByteArray parsableByteArray) {
|
|
int position = parsableByteArray.getPosition();
|
|
parsableByteArray.skipBytes(4);
|
|
if (parsableByteArray.readInt() != 1751411826) {
|
|
position += 4;
|
|
}
|
|
parsableByteArray.setPosition(position);
|
|
}
|
|
|
|
private static Track parseTrak(Atom.ContainerAtom containerAtom, Atom.LeafAtom leafAtom, long j, DrmInitData drmInitData, boolean z, boolean z2) throws ParserException {
|
|
Atom.LeafAtom leafAtom2;
|
|
long j2;
|
|
long[] jArr;
|
|
long[] jArr2;
|
|
Atom.ContainerAtom containerAtomOfType;
|
|
Pair<long[], long[]> parseEdts;
|
|
Atom.ContainerAtom containerAtom2 = (Atom.ContainerAtom) Assertions.checkNotNull(containerAtom.getContainerAtomOfType(1835297121));
|
|
int trackTypeForHdlr = getTrackTypeForHdlr(parseHdlr(((Atom.LeafAtom) Assertions.checkNotNull(containerAtom2.getLeafAtomOfType(1751411826))).data));
|
|
if (trackTypeForHdlr == -1) {
|
|
return null;
|
|
}
|
|
TkhdData parseTkhd = parseTkhd(((Atom.LeafAtom) Assertions.checkNotNull(containerAtom.getLeafAtomOfType(1953196132))).data);
|
|
if (j == -9223372036854775807L) {
|
|
leafAtom2 = leafAtom;
|
|
j2 = parseTkhd.duration;
|
|
} else {
|
|
leafAtom2 = leafAtom;
|
|
j2 = j;
|
|
}
|
|
long j3 = parseMvhd(leafAtom2.data).timescale;
|
|
long scaleLargeTimestamp = j2 != -9223372036854775807L ? Util.scaleLargeTimestamp(j2, 1000000L, j3) : -9223372036854775807L;
|
|
Atom.ContainerAtom containerAtom3 = (Atom.ContainerAtom) Assertions.checkNotNull(((Atom.ContainerAtom) Assertions.checkNotNull(containerAtom2.getContainerAtomOfType(1835626086))).getContainerAtomOfType(1937007212));
|
|
Pair<Long, String> parseMdhd = parseMdhd(((Atom.LeafAtom) Assertions.checkNotNull(containerAtom2.getLeafAtomOfType(1835296868))).data);
|
|
Atom.LeafAtom leafAtomOfType = containerAtom3.getLeafAtomOfType(1937011556);
|
|
if (leafAtomOfType == null) {
|
|
throw ParserException.createForMalformedContainer("Malformed sample table (stbl) missing sample description (stsd)", null);
|
|
}
|
|
StsdData parseStsd = parseStsd(leafAtomOfType.data, parseTkhd.id, parseTkhd.rotationDegrees, (String) parseMdhd.second, drmInitData, z2);
|
|
if (z || (containerAtomOfType = containerAtom.getContainerAtomOfType(1701082227)) == null || (parseEdts = parseEdts(containerAtomOfType)) == null) {
|
|
jArr = null;
|
|
jArr2 = null;
|
|
} else {
|
|
long[] jArr3 = (long[]) parseEdts.first;
|
|
jArr2 = (long[]) parseEdts.second;
|
|
jArr = jArr3;
|
|
}
|
|
if (parseStsd.format == null) {
|
|
return null;
|
|
}
|
|
return new Track(parseTkhd.id, trackTypeForHdlr, ((Long) parseMdhd.first).longValue(), j3, scaleLargeTimestamp, parseStsd.format, parseStsd.requiredSampleTransformation, parseStsd.trackEncryptionBoxes, parseStsd.nalUnitLengthFieldLength, jArr, jArr2);
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:100:0x044c */
|
|
/* JADX WARN: Removed duplicated region for block: B:103:0x0451 */
|
|
/* JADX WARN: Removed duplicated region for block: B:105:0x0458 */
|
|
/* JADX WARN: Removed duplicated region for block: B:107:0x045e */
|
|
/* JADX WARN: Removed duplicated region for block: B:109:0x0464 */
|
|
/* JADX WARN: Removed duplicated region for block: B:113:0x0474 */
|
|
/* JADX WARN: Removed duplicated region for block: B:138:0x0467 */
|
|
/* JADX WARN: Removed duplicated region for block: B:139:0x0460 */
|
|
/* JADX WARN: Removed duplicated region for block: B:140:0x045b */
|
|
/* JADX WARN: Removed duplicated region for block: B:141:0x0454 */
|
|
/* JADX WARN: Removed duplicated region for block: B:142:0x03c3 */
|
|
/* JADX WARN: Removed duplicated region for block: B:74:0x03c1 */
|
|
/* JADX WARN: Removed duplicated region for block: B:78:0x03df */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
private static androidx.media3.extractor.mp4.TrackSampleTable parseStbl(androidx.media3.extractor.mp4.Track r37, androidx.media3.extractor.mp4.Atom.ContainerAtom r38, androidx.media3.extractor.GaplessInfoHolder r39) throws androidx.media3.common.ParserException {
|
|
/*
|
|
Method dump skipped, instructions count: 1349
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.media3.extractor.mp4.AtomParsers.parseStbl(androidx.media3.extractor.mp4.Track, androidx.media3.extractor.mp4.Atom$ContainerAtom, androidx.media3.extractor.GaplessInfoHolder):androidx.media3.extractor.mp4.TrackSampleTable");
|
|
}
|
|
|
|
private static Metadata parseUdtaMeta(ParsableByteArray parsableByteArray, int i) {
|
|
parsableByteArray.skipBytes(8);
|
|
maybeSkipRemainingMetaAtomHeaderBytes(parsableByteArray);
|
|
while (parsableByteArray.getPosition() < i) {
|
|
int position = parsableByteArray.getPosition();
|
|
int readInt = parsableByteArray.readInt();
|
|
if (parsableByteArray.readInt() == 1768715124) {
|
|
parsableByteArray.setPosition(position);
|
|
return parseIlst(parsableByteArray, position + readInt);
|
|
}
|
|
parsableByteArray.setPosition(position + readInt);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private static Metadata parseIlst(ParsableByteArray parsableByteArray, int i) {
|
|
parsableByteArray.skipBytes(8);
|
|
ArrayList arrayList = new ArrayList();
|
|
while (parsableByteArray.getPosition() < i) {
|
|
Metadata.Entry parseIlstElement = MetadataUtil.parseIlstElement(parsableByteArray);
|
|
if (parseIlstElement != null) {
|
|
arrayList.add(parseIlstElement);
|
|
}
|
|
}
|
|
if (arrayList.isEmpty()) {
|
|
return null;
|
|
}
|
|
return new Metadata(arrayList);
|
|
}
|
|
|
|
private static Metadata parseXyz(ParsableByteArray parsableByteArray) {
|
|
short readShort = parsableByteArray.readShort();
|
|
parsableByteArray.skipBytes(2);
|
|
String readString = parsableByteArray.readString(readShort);
|
|
int max = Math.max(readString.lastIndexOf(43), readString.lastIndexOf(45));
|
|
try {
|
|
return new Metadata(new Mp4LocationData(Float.parseFloat(readString.substring(0, max)), Float.parseFloat(readString.substring(max, readString.length() - 1))));
|
|
} catch (IndexOutOfBoundsException | NumberFormatException unused) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
private static Metadata parseSmta(ParsableByteArray parsableByteArray, int i) {
|
|
parsableByteArray.skipBytes(12);
|
|
while (parsableByteArray.getPosition() < i) {
|
|
int position = parsableByteArray.getPosition();
|
|
int readInt = parsableByteArray.readInt();
|
|
if (parsableByteArray.readInt() == 1935766900) {
|
|
if (readInt < 14) {
|
|
return null;
|
|
}
|
|
parsableByteArray.skipBytes(5);
|
|
int readUnsignedByte = parsableByteArray.readUnsignedByte();
|
|
if (readUnsignedByte != 12 && readUnsignedByte != 13) {
|
|
return null;
|
|
}
|
|
float f = readUnsignedByte == 12 ? 240.0f : 120.0f;
|
|
parsableByteArray.skipBytes(1);
|
|
return new Metadata(new SmtaMetadataEntry(f, parsableByteArray.readUnsignedByte()));
|
|
}
|
|
parsableByteArray.setPosition(position + readInt);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private static TkhdData parseTkhd(ParsableByteArray parsableByteArray) {
|
|
long j;
|
|
parsableByteArray.setPosition(8);
|
|
int parseFullAtomVersion = Atom.parseFullAtomVersion(parsableByteArray.readInt());
|
|
parsableByteArray.skipBytes(parseFullAtomVersion == 0 ? 8 : 16);
|
|
int readInt = parsableByteArray.readInt();
|
|
parsableByteArray.skipBytes(4);
|
|
int position = parsableByteArray.getPosition();
|
|
int i = parseFullAtomVersion == 0 ? 4 : 8;
|
|
int i2 = 0;
|
|
int i3 = 0;
|
|
while (true) {
|
|
j = -9223372036854775807L;
|
|
if (i3 < i) {
|
|
if (parsableByteArray.getData()[position + i3] != -1) {
|
|
long readUnsignedInt = parseFullAtomVersion == 0 ? parsableByteArray.readUnsignedInt() : parsableByteArray.readUnsignedLongToLong();
|
|
if (readUnsignedInt != 0) {
|
|
j = readUnsignedInt;
|
|
}
|
|
} else {
|
|
i3++;
|
|
}
|
|
} else {
|
|
parsableByteArray.skipBytes(i);
|
|
break;
|
|
}
|
|
}
|
|
parsableByteArray.skipBytes(16);
|
|
int readInt2 = parsableByteArray.readInt();
|
|
int readInt3 = parsableByteArray.readInt();
|
|
parsableByteArray.skipBytes(4);
|
|
int readInt4 = parsableByteArray.readInt();
|
|
int readInt5 = parsableByteArray.readInt();
|
|
if (readInt2 == 0 && readInt3 == 65536 && readInt4 == -65536 && readInt5 == 0) {
|
|
i2 = 90;
|
|
} else if (readInt2 == 0 && readInt3 == -65536 && readInt4 == 65536 && readInt5 == 0) {
|
|
i2 = SubsamplingScaleImageView.ORIENTATION_270;
|
|
} else if (readInt2 == -65536 && readInt3 == 0 && readInt4 == 0 && readInt5 == -65536) {
|
|
i2 = SubsamplingScaleImageView.ORIENTATION_180;
|
|
}
|
|
return new TkhdData(readInt, j, i2);
|
|
}
|
|
|
|
private static int parseHdlr(ParsableByteArray parsableByteArray) {
|
|
parsableByteArray.setPosition(16);
|
|
return parsableByteArray.readInt();
|
|
}
|
|
|
|
private static Pair<Long, String> parseMdhd(ParsableByteArray parsableByteArray) {
|
|
parsableByteArray.setPosition(8);
|
|
int parseFullAtomVersion = Atom.parseFullAtomVersion(parsableByteArray.readInt());
|
|
parsableByteArray.skipBytes(parseFullAtomVersion == 0 ? 8 : 16);
|
|
long readUnsignedInt = parsableByteArray.readUnsignedInt();
|
|
parsableByteArray.skipBytes(parseFullAtomVersion == 0 ? 4 : 8);
|
|
int readUnsignedShort = parsableByteArray.readUnsignedShort();
|
|
return Pair.create(Long.valueOf(readUnsignedInt), "" + ((char) (((readUnsignedShort >> 10) & 31) + 96)) + ((char) (((readUnsignedShort >> 5) & 31) + 96)) + ((char) ((readUnsignedShort & 31) + 96)));
|
|
}
|
|
|
|
private static StsdData parseStsd(ParsableByteArray parsableByteArray, int i, int i2, String str, DrmInitData drmInitData, boolean z) throws ParserException {
|
|
int i3;
|
|
parsableByteArray.setPosition(12);
|
|
int readInt = parsableByteArray.readInt();
|
|
StsdData stsdData = new StsdData(readInt);
|
|
for (int i4 = 0; i4 < readInt; i4++) {
|
|
int position = parsableByteArray.getPosition();
|
|
int readInt2 = parsableByteArray.readInt();
|
|
ExtractorUtil.checkContainerInput(readInt2 > 0, "childAtomSize must be positive");
|
|
int readInt3 = parsableByteArray.readInt();
|
|
if (readInt3 == 1635148593 || readInt3 == 1635148595 || readInt3 == 1701733238 || readInt3 == 1831958048 || readInt3 == 1836070006 || readInt3 == 1752589105 || readInt3 == 1751479857 || readInt3 == 1932670515 || readInt3 == 1211250227 || readInt3 == 1987063864 || readInt3 == 1987063865 || readInt3 == 1635135537 || readInt3 == 1685479798 || readInt3 == 1685479729 || readInt3 == 1685481573 || readInt3 == 1685481521) {
|
|
i3 = position;
|
|
parseVideoSampleEntry(parsableByteArray, readInt3, i3, readInt2, i, i2, drmInitData, stsdData, i4);
|
|
} else if (readInt3 == 1836069985 || readInt3 == 1701733217 || readInt3 == 1633889587 || readInt3 == 1700998451 || readInt3 == 1633889588 || readInt3 == 1835823201 || readInt3 == 1685353315 || readInt3 == 1685353317 || readInt3 == 1685353320 || readInt3 == 1685353324 || readInt3 == 1685353336 || readInt3 == 1935764850 || readInt3 == 1935767394 || readInt3 == 1819304813 || readInt3 == 1936684916 || readInt3 == 1953984371 || readInt3 == 778924082 || readInt3 == 778924083 || readInt3 == 1835557169 || readInt3 == 1835560241 || readInt3 == 1634492771 || readInt3 == 1634492791 || readInt3 == 1970037111 || readInt3 == 1332770163 || readInt3 == 1716281667) {
|
|
i3 = position;
|
|
parseAudioSampleEntry(parsableByteArray, readInt3, position, readInt2, i, str, z, drmInitData, stsdData, i4);
|
|
} else {
|
|
if (readInt3 == 1414810956 || readInt3 == 1954034535 || readInt3 == 2004251764 || readInt3 == 1937010800 || readInt3 == 1664495672) {
|
|
parseTextSampleEntry(parsableByteArray, readInt3, position, readInt2, i, str, stsdData);
|
|
} else if (readInt3 == 1835365492) {
|
|
parseMetaDataSampleEntry(parsableByteArray, readInt3, position, i, stsdData);
|
|
} else if (readInt3 == 1667329389) {
|
|
stsdData.format = new Format.Builder().setId(i).setSampleMimeType("application/x-camera-motion").build();
|
|
}
|
|
i3 = position;
|
|
}
|
|
parsableByteArray.setPosition(i3 + readInt2);
|
|
}
|
|
return stsdData;
|
|
}
|
|
|
|
private static void parseTextSampleEntry(ParsableByteArray parsableByteArray, int i, int i2, int i3, int i4, String str, StsdData stsdData) {
|
|
parsableByteArray.setPosition(i2 + 16);
|
|
String str2 = "application/ttml+xml";
|
|
ImmutableList immutableList = null;
|
|
long j = Long.MAX_VALUE;
|
|
if (i != 1414810956) {
|
|
if (i == 1954034535) {
|
|
int i5 = i3 - 16;
|
|
byte[] bArr = new byte[i5];
|
|
parsableByteArray.readBytes(bArr, 0, i5);
|
|
immutableList = ImmutableList.of(bArr);
|
|
str2 = "application/x-quicktime-tx3g";
|
|
} else if (i == 2004251764) {
|
|
str2 = "application/x-mp4-vtt";
|
|
} else if (i == 1937010800) {
|
|
j = 0;
|
|
} else if (i == 1664495672) {
|
|
stsdData.requiredSampleTransformation = 1;
|
|
str2 = "application/x-mp4-cea-608";
|
|
} else {
|
|
throw new IllegalStateException();
|
|
}
|
|
}
|
|
stsdData.format = new Format.Builder().setId(i4).setSampleMimeType(str2).setLanguage(str).setSubsampleOffsetUs(j).setInitializationData(immutableList).build();
|
|
}
|
|
|
|
private static void parseVideoSampleEntry(ParsableByteArray parsableByteArray, int i, int i2, int i3, int i4, int i5, DrmInitData drmInitData, StsdData stsdData, int i6) throws ParserException {
|
|
String str;
|
|
DrmInitData drmInitData2;
|
|
int i7;
|
|
int i8;
|
|
float f;
|
|
List<byte[]> list;
|
|
int i9;
|
|
int i10;
|
|
String str2;
|
|
int i11;
|
|
int i12;
|
|
int i13;
|
|
String str3;
|
|
int i14 = i2;
|
|
int i15 = i3;
|
|
DrmInitData drmInitData3 = drmInitData;
|
|
StsdData stsdData2 = stsdData;
|
|
parsableByteArray.setPosition(i14 + 16);
|
|
parsableByteArray.skipBytes(16);
|
|
int readUnsignedShort = parsableByteArray.readUnsignedShort();
|
|
int readUnsignedShort2 = parsableByteArray.readUnsignedShort();
|
|
parsableByteArray.skipBytes(50);
|
|
int position = parsableByteArray.getPosition();
|
|
int i16 = i;
|
|
if (i16 == 1701733238) {
|
|
Pair<Integer, TrackEncryptionBox> parseSampleEntryEncryptionData = parseSampleEntryEncryptionData(parsableByteArray, i14, i15);
|
|
if (parseSampleEntryEncryptionData != null) {
|
|
i16 = ((Integer) parseSampleEntryEncryptionData.first).intValue();
|
|
drmInitData3 = drmInitData3 == null ? null : drmInitData3.copyWithSchemeType(((TrackEncryptionBox) parseSampleEntryEncryptionData.second).schemeType);
|
|
stsdData2.trackEncryptionBoxes[i6] = (TrackEncryptionBox) parseSampleEntryEncryptionData.second;
|
|
}
|
|
parsableByteArray.setPosition(position);
|
|
}
|
|
String str4 = "video/3gpp";
|
|
String str5 = i16 == 1831958048 ? "video/mpeg" : i16 == 1211250227 ? "video/3gpp" : null;
|
|
float f2 = 1.0f;
|
|
String str6 = null;
|
|
List<byte[]> list2 = null;
|
|
byte[] bArr = null;
|
|
int i17 = -1;
|
|
int i18 = -1;
|
|
int i19 = -1;
|
|
int i20 = -1;
|
|
ByteBuffer byteBuffer = null;
|
|
EsdsData esdsData = null;
|
|
boolean z = false;
|
|
while (position - i14 < i15) {
|
|
parsableByteArray.setPosition(position);
|
|
int position2 = parsableByteArray.getPosition();
|
|
int readInt = parsableByteArray.readInt();
|
|
if (readInt == 0) {
|
|
str = str4;
|
|
if (parsableByteArray.getPosition() - i14 == i15) {
|
|
break;
|
|
}
|
|
} else {
|
|
str = str4;
|
|
}
|
|
ExtractorUtil.checkContainerInput(readInt > 0, "childAtomSize must be positive");
|
|
int readInt2 = parsableByteArray.readInt();
|
|
if (readInt2 == 1635148611) {
|
|
ExtractorUtil.checkContainerInput(str5 == null, null);
|
|
parsableByteArray.setPosition(position2 + 8);
|
|
AvcConfig parse = AvcConfig.parse(parsableByteArray);
|
|
list2 = parse.initializationData;
|
|
stsdData2.nalUnitLengthFieldLength = parse.nalUnitLengthFieldLength;
|
|
if (!z) {
|
|
f2 = parse.pixelWidthHeightRatio;
|
|
}
|
|
str6 = parse.codecs;
|
|
i11 = parse.colorSpace;
|
|
i12 = parse.colorRange;
|
|
i13 = parse.colorTransfer;
|
|
str3 = "video/avc";
|
|
} else if (readInt2 == 1752589123) {
|
|
ExtractorUtil.checkContainerInput(str5 == null, null);
|
|
parsableByteArray.setPosition(position2 + 8);
|
|
HevcConfig parse2 = HevcConfig.parse(parsableByteArray);
|
|
list2 = parse2.initializationData;
|
|
stsdData2.nalUnitLengthFieldLength = parse2.nalUnitLengthFieldLength;
|
|
if (!z) {
|
|
f2 = parse2.pixelWidthHeightRatio;
|
|
}
|
|
str6 = parse2.codecs;
|
|
i11 = parse2.colorSpace;
|
|
i12 = parse2.colorRange;
|
|
i13 = parse2.colorTransfer;
|
|
str3 = "video/hevc";
|
|
} else {
|
|
if (readInt2 == 1685480259 || readInt2 == 1685485123) {
|
|
drmInitData2 = drmInitData3;
|
|
i7 = readUnsignedShort2;
|
|
i8 = i16;
|
|
f = f2;
|
|
list = list2;
|
|
i9 = i18;
|
|
i10 = i20;
|
|
DolbyVisionConfig parse3 = DolbyVisionConfig.parse(parsableByteArray);
|
|
if (parse3 != null) {
|
|
str6 = parse3.codecs;
|
|
str5 = "video/dolby-vision";
|
|
}
|
|
} else {
|
|
if (readInt2 == 1987076931) {
|
|
ExtractorUtil.checkContainerInput(str5 == null, null);
|
|
str2 = i16 == 1987063864 ? "video/x-vnd.on2.vp8" : "video/x-vnd.on2.vp9";
|
|
parsableByteArray.setPosition(position2 + 12);
|
|
parsableByteArray.skipBytes(2);
|
|
boolean z2 = (parsableByteArray.readUnsignedByte() & 1) != 0;
|
|
int readUnsignedByte = parsableByteArray.readUnsignedByte();
|
|
int readUnsignedByte2 = parsableByteArray.readUnsignedByte();
|
|
i18 = ColorInfo.isoColorPrimariesToColorSpace(readUnsignedByte);
|
|
i19 = z2 ? 1 : 2;
|
|
i20 = ColorInfo.isoTransferCharacteristicsToColorTransfer(readUnsignedByte2);
|
|
} else if (readInt2 == 1635135811) {
|
|
ExtractorUtil.checkContainerInput(str5 == null, null);
|
|
str2 = "video/av01";
|
|
} else if (readInt2 == 1668050025) {
|
|
if (byteBuffer == null) {
|
|
byteBuffer = allocateHdrStaticInfo();
|
|
}
|
|
ByteBuffer byteBuffer2 = byteBuffer;
|
|
byteBuffer2.position(21);
|
|
byteBuffer2.putShort(parsableByteArray.readShort());
|
|
byteBuffer2.putShort(parsableByteArray.readShort());
|
|
byteBuffer = byteBuffer2;
|
|
drmInitData2 = drmInitData3;
|
|
i7 = readUnsignedShort2;
|
|
i8 = i16;
|
|
position += readInt;
|
|
i14 = i2;
|
|
i15 = i3;
|
|
stsdData2 = stsdData;
|
|
str4 = str;
|
|
i16 = i8;
|
|
drmInitData3 = drmInitData2;
|
|
readUnsignedShort2 = i7;
|
|
} else if (readInt2 == 1835295606) {
|
|
if (byteBuffer == null) {
|
|
byteBuffer = allocateHdrStaticInfo();
|
|
}
|
|
ByteBuffer byteBuffer3 = byteBuffer;
|
|
short readShort = parsableByteArray.readShort();
|
|
short readShort2 = parsableByteArray.readShort();
|
|
short readShort3 = parsableByteArray.readShort();
|
|
i8 = i16;
|
|
short readShort4 = parsableByteArray.readShort();
|
|
short readShort5 = parsableByteArray.readShort();
|
|
drmInitData2 = drmInitData3;
|
|
short readShort6 = parsableByteArray.readShort();
|
|
List<byte[]> list3 = list2;
|
|
short readShort7 = parsableByteArray.readShort();
|
|
float f3 = f2;
|
|
short readShort8 = parsableByteArray.readShort();
|
|
long readUnsignedInt = parsableByteArray.readUnsignedInt();
|
|
long readUnsignedInt2 = parsableByteArray.readUnsignedInt();
|
|
i7 = readUnsignedShort2;
|
|
byteBuffer3.position(1);
|
|
byteBuffer3.putShort(readShort5);
|
|
byteBuffer3.putShort(readShort6);
|
|
byteBuffer3.putShort(readShort);
|
|
byteBuffer3.putShort(readShort2);
|
|
byteBuffer3.putShort(readShort3);
|
|
byteBuffer3.putShort(readShort4);
|
|
byteBuffer3.putShort(readShort7);
|
|
byteBuffer3.putShort(readShort8);
|
|
byteBuffer3.putShort((short) (readUnsignedInt / WorkRequest.MIN_BACKOFF_MILLIS));
|
|
byteBuffer3.putShort((short) (readUnsignedInt2 / WorkRequest.MIN_BACKOFF_MILLIS));
|
|
byteBuffer = byteBuffer3;
|
|
list2 = list3;
|
|
f2 = f3;
|
|
position += readInt;
|
|
i14 = i2;
|
|
i15 = i3;
|
|
stsdData2 = stsdData;
|
|
str4 = str;
|
|
i16 = i8;
|
|
drmInitData3 = drmInitData2;
|
|
readUnsignedShort2 = i7;
|
|
} else {
|
|
drmInitData2 = drmInitData3;
|
|
i7 = readUnsignedShort2;
|
|
i8 = i16;
|
|
f = f2;
|
|
list = list2;
|
|
if (readInt2 == 1681012275) {
|
|
ExtractorUtil.checkContainerInput(str5 == null, null);
|
|
str5 = str;
|
|
} else if (readInt2 == 1702061171) {
|
|
ExtractorUtil.checkContainerInput(str5 == null, null);
|
|
esdsData = parseEsdsFromParent(parsableByteArray, position2);
|
|
String str7 = esdsData.mimeType;
|
|
byte[] bArr2 = esdsData.initializationData;
|
|
list2 = bArr2 != null ? ImmutableList.of(bArr2) : list;
|
|
str5 = str7;
|
|
f2 = f;
|
|
position += readInt;
|
|
i14 = i2;
|
|
i15 = i3;
|
|
stsdData2 = stsdData;
|
|
str4 = str;
|
|
i16 = i8;
|
|
drmInitData3 = drmInitData2;
|
|
readUnsignedShort2 = i7;
|
|
} else if (readInt2 == 1885434736) {
|
|
f2 = parsePaspFromParent(parsableByteArray, position2);
|
|
list2 = list;
|
|
z = true;
|
|
position += readInt;
|
|
i14 = i2;
|
|
i15 = i3;
|
|
stsdData2 = stsdData;
|
|
str4 = str;
|
|
i16 = i8;
|
|
drmInitData3 = drmInitData2;
|
|
readUnsignedShort2 = i7;
|
|
} else if (readInt2 == 1937126244) {
|
|
bArr = parseProjFromParent(parsableByteArray, position2, readInt);
|
|
} else if (readInt2 == 1936995172) {
|
|
int readUnsignedByte3 = parsableByteArray.readUnsignedByte();
|
|
parsableByteArray.skipBytes(3);
|
|
if (readUnsignedByte3 == 0) {
|
|
int readUnsignedByte4 = parsableByteArray.readUnsignedByte();
|
|
if (readUnsignedByte4 == 0) {
|
|
i17 = 0;
|
|
} else if (readUnsignedByte4 == 1) {
|
|
i17 = 1;
|
|
} else if (readUnsignedByte4 == 2) {
|
|
i17 = 2;
|
|
} else if (readUnsignedByte4 == 3) {
|
|
i17 = 3;
|
|
}
|
|
}
|
|
} else {
|
|
i9 = i18;
|
|
if (readInt2 == 1668246642) {
|
|
i10 = i20;
|
|
if (i9 == -1 && i10 == -1) {
|
|
int readInt3 = parsableByteArray.readInt();
|
|
if (readInt3 == TYPE_nclx || readInt3 == TYPE_nclc) {
|
|
int readUnsignedShort3 = parsableByteArray.readUnsignedShort();
|
|
int readUnsignedShort4 = parsableByteArray.readUnsignedShort();
|
|
parsableByteArray.skipBytes(2);
|
|
boolean z3 = readInt == 19 && (parsableByteArray.readUnsignedByte() & 128) != 0;
|
|
i18 = ColorInfo.isoColorPrimariesToColorSpace(readUnsignedShort3);
|
|
i19 = z3 ? 1 : 2;
|
|
i20 = ColorInfo.isoTransferCharacteristicsToColorTransfer(readUnsignedShort4);
|
|
} else {
|
|
Log.w(TAG, "Unsupported color type: " + Atom.getAtomTypeString(readInt3));
|
|
}
|
|
}
|
|
} else {
|
|
i10 = i20;
|
|
}
|
|
}
|
|
list2 = list;
|
|
f2 = f;
|
|
position += readInt;
|
|
i14 = i2;
|
|
i15 = i3;
|
|
stsdData2 = stsdData;
|
|
str4 = str;
|
|
i16 = i8;
|
|
drmInitData3 = drmInitData2;
|
|
readUnsignedShort2 = i7;
|
|
}
|
|
str5 = str2;
|
|
drmInitData2 = drmInitData3;
|
|
i7 = readUnsignedShort2;
|
|
i8 = i16;
|
|
position += readInt;
|
|
i14 = i2;
|
|
i15 = i3;
|
|
stsdData2 = stsdData;
|
|
str4 = str;
|
|
i16 = i8;
|
|
drmInitData3 = drmInitData2;
|
|
readUnsignedShort2 = i7;
|
|
}
|
|
i20 = i10;
|
|
i18 = i9;
|
|
list2 = list;
|
|
f2 = f;
|
|
position += readInt;
|
|
i14 = i2;
|
|
i15 = i3;
|
|
stsdData2 = stsdData;
|
|
str4 = str;
|
|
i16 = i8;
|
|
drmInitData3 = drmInitData2;
|
|
readUnsignedShort2 = i7;
|
|
}
|
|
i20 = i13;
|
|
drmInitData2 = drmInitData3;
|
|
i7 = readUnsignedShort2;
|
|
i18 = i11;
|
|
i8 = i16;
|
|
i19 = i12;
|
|
str5 = str3;
|
|
position += readInt;
|
|
i14 = i2;
|
|
i15 = i3;
|
|
stsdData2 = stsdData;
|
|
str4 = str;
|
|
i16 = i8;
|
|
drmInitData3 = drmInitData2;
|
|
readUnsignedShort2 = i7;
|
|
}
|
|
DrmInitData drmInitData4 = drmInitData3;
|
|
int i21 = readUnsignedShort2;
|
|
float f4 = f2;
|
|
List<byte[]> list4 = list2;
|
|
int i22 = i18;
|
|
int i23 = i20;
|
|
if (str5 == null) {
|
|
return;
|
|
}
|
|
Format.Builder drmInitData5 = new Format.Builder().setId(i4).setSampleMimeType(str5).setCodecs(str6).setWidth(readUnsignedShort).setHeight(i21).setPixelWidthHeightRatio(f4).setRotationDegrees(i5).setProjectionData(bArr).setStereoMode(i17).setInitializationData(list4).setDrmInitData(drmInitData4);
|
|
int i24 = i19;
|
|
if (i22 != -1 || i24 != -1 || i23 != -1 || byteBuffer != null) {
|
|
drmInitData5.setColorInfo(new ColorInfo(i22, i24, i23, byteBuffer != null ? byteBuffer.array() : null));
|
|
}
|
|
if (esdsData != null) {
|
|
drmInitData5.setAverageBitrate(Ints.saturatedCast(esdsData.bitrate)).setPeakBitrate(Ints.saturatedCast(esdsData.peakBitrate));
|
|
}
|
|
stsdData.format = drmInitData5.build();
|
|
}
|
|
|
|
private static ByteBuffer allocateHdrStaticInfo() {
|
|
return ByteBuffer.allocate(25).order(ByteOrder.LITTLE_ENDIAN);
|
|
}
|
|
|
|
private static void parseMetaDataSampleEntry(ParsableByteArray parsableByteArray, int i, int i2, int i3, StsdData stsdData) {
|
|
parsableByteArray.setPosition(i2 + 16);
|
|
if (i == 1835365492) {
|
|
parsableByteArray.readNullTerminatedString();
|
|
String readNullTerminatedString = parsableByteArray.readNullTerminatedString();
|
|
if (readNullTerminatedString != null) {
|
|
stsdData.format = new Format.Builder().setId(i3).setSampleMimeType(readNullTerminatedString).build();
|
|
}
|
|
}
|
|
}
|
|
|
|
private static Pair<long[], long[]> parseEdts(Atom.ContainerAtom containerAtom) {
|
|
Atom.LeafAtom leafAtomOfType = containerAtom.getLeafAtomOfType(1701606260);
|
|
if (leafAtomOfType == null) {
|
|
return null;
|
|
}
|
|
ParsableByteArray parsableByteArray = leafAtomOfType.data;
|
|
parsableByteArray.setPosition(8);
|
|
int parseFullAtomVersion = Atom.parseFullAtomVersion(parsableByteArray.readInt());
|
|
int readUnsignedIntToInt = parsableByteArray.readUnsignedIntToInt();
|
|
long[] jArr = new long[readUnsignedIntToInt];
|
|
long[] jArr2 = new long[readUnsignedIntToInt];
|
|
for (int i = 0; i < readUnsignedIntToInt; i++) {
|
|
jArr[i] = parseFullAtomVersion == 1 ? parsableByteArray.readUnsignedLongToLong() : parsableByteArray.readUnsignedInt();
|
|
jArr2[i] = parseFullAtomVersion == 1 ? parsableByteArray.readLong() : parsableByteArray.readInt();
|
|
if (parsableByteArray.readShort() != 1) {
|
|
throw new IllegalArgumentException("Unsupported media rate.");
|
|
}
|
|
parsableByteArray.skipBytes(2);
|
|
}
|
|
return Pair.create(jArr, jArr2);
|
|
}
|
|
|
|
private static float parsePaspFromParent(ParsableByteArray parsableByteArray, int i) {
|
|
parsableByteArray.setPosition(i + 8);
|
|
return parsableByteArray.readUnsignedIntToInt() / parsableByteArray.readUnsignedIntToInt();
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:26:0x0166 */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
private static void parseAudioSampleEntry(androidx.media3.common.util.ParsableByteArray r22, int r23, int r24, int r25, int r26, java.lang.String r27, boolean r28, androidx.media3.common.DrmInitData r29, androidx.media3.extractor.mp4.AtomParsers.StsdData r30, int r31) throws androidx.media3.common.ParserException {
|
|
/*
|
|
Method dump skipped, instructions count: 878
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.media3.extractor.mp4.AtomParsers.parseAudioSampleEntry(androidx.media3.common.util.ParsableByteArray, int, int, int, int, java.lang.String, boolean, androidx.media3.common.DrmInitData, androidx.media3.extractor.mp4.AtomParsers$StsdData, int):void");
|
|
}
|
|
|
|
private static int findBoxPosition(ParsableByteArray parsableByteArray, int i, int i2, int i3) throws ParserException {
|
|
int position = parsableByteArray.getPosition();
|
|
ExtractorUtil.checkContainerInput(position >= i2, null);
|
|
while (position - i2 < i3) {
|
|
parsableByteArray.setPosition(position);
|
|
int readInt = parsableByteArray.readInt();
|
|
ExtractorUtil.checkContainerInput(readInt > 0, "childAtomSize must be positive");
|
|
if (parsableByteArray.readInt() == i) {
|
|
return position;
|
|
}
|
|
position += readInt;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
private static EsdsData parseEsdsFromParent(ParsableByteArray parsableByteArray, int i) {
|
|
parsableByteArray.setPosition(i + 12);
|
|
parsableByteArray.skipBytes(1);
|
|
parseExpandableClassSize(parsableByteArray);
|
|
parsableByteArray.skipBytes(2);
|
|
int readUnsignedByte = parsableByteArray.readUnsignedByte();
|
|
if ((readUnsignedByte & 128) != 0) {
|
|
parsableByteArray.skipBytes(2);
|
|
}
|
|
if ((readUnsignedByte & 64) != 0) {
|
|
parsableByteArray.skipBytes(parsableByteArray.readUnsignedByte());
|
|
}
|
|
if ((readUnsignedByte & 32) != 0) {
|
|
parsableByteArray.skipBytes(2);
|
|
}
|
|
parsableByteArray.skipBytes(1);
|
|
parseExpandableClassSize(parsableByteArray);
|
|
String mimeTypeFromMp4ObjectType = MimeTypes.getMimeTypeFromMp4ObjectType(parsableByteArray.readUnsignedByte());
|
|
if ("audio/mpeg".equals(mimeTypeFromMp4ObjectType) || "audio/vnd.dts".equals(mimeTypeFromMp4ObjectType) || "audio/vnd.dts.hd".equals(mimeTypeFromMp4ObjectType)) {
|
|
return new EsdsData(mimeTypeFromMp4ObjectType, null, -1L, -1L);
|
|
}
|
|
parsableByteArray.skipBytes(4);
|
|
long readUnsignedInt = parsableByteArray.readUnsignedInt();
|
|
long readUnsignedInt2 = parsableByteArray.readUnsignedInt();
|
|
parsableByteArray.skipBytes(1);
|
|
int parseExpandableClassSize = parseExpandableClassSize(parsableByteArray);
|
|
byte[] bArr = new byte[parseExpandableClassSize];
|
|
parsableByteArray.readBytes(bArr, 0, parseExpandableClassSize);
|
|
return new EsdsData(mimeTypeFromMp4ObjectType, bArr, readUnsignedInt2 > 0 ? readUnsignedInt2 : -1L, readUnsignedInt > 0 ? readUnsignedInt : -1L);
|
|
}
|
|
|
|
private static Pair<Integer, TrackEncryptionBox> parseSampleEntryEncryptionData(ParsableByteArray parsableByteArray, int i, int i2) throws ParserException {
|
|
Pair<Integer, TrackEncryptionBox> parseCommonEncryptionSinfFromParent;
|
|
int position = parsableByteArray.getPosition();
|
|
while (position - i < i2) {
|
|
parsableByteArray.setPosition(position);
|
|
int readInt = parsableByteArray.readInt();
|
|
ExtractorUtil.checkContainerInput(readInt > 0, "childAtomSize must be positive");
|
|
if (parsableByteArray.readInt() == 1936289382 && (parseCommonEncryptionSinfFromParent = parseCommonEncryptionSinfFromParent(parsableByteArray, position, readInt)) != null) {
|
|
return parseCommonEncryptionSinfFromParent;
|
|
}
|
|
position += readInt;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
static Pair<Integer, TrackEncryptionBox> parseCommonEncryptionSinfFromParent(ParsableByteArray parsableByteArray, int i, int i2) throws ParserException {
|
|
int i3 = i + 8;
|
|
int i4 = -1;
|
|
int i5 = 0;
|
|
String str = null;
|
|
Integer num = null;
|
|
while (i3 - i < i2) {
|
|
parsableByteArray.setPosition(i3);
|
|
int readInt = parsableByteArray.readInt();
|
|
int readInt2 = parsableByteArray.readInt();
|
|
if (readInt2 == 1718775137) {
|
|
num = Integer.valueOf(parsableByteArray.readInt());
|
|
} else if (readInt2 == 1935894637) {
|
|
parsableByteArray.skipBytes(4);
|
|
str = parsableByteArray.readString(4);
|
|
} else if (readInt2 == 1935894633) {
|
|
i4 = i3;
|
|
i5 = readInt;
|
|
}
|
|
i3 += readInt;
|
|
}
|
|
if (!"cenc".equals(str) && !"cbc1".equals(str) && !"cens".equals(str) && !"cbcs".equals(str)) {
|
|
return null;
|
|
}
|
|
ExtractorUtil.checkContainerInput(num != null, "frma atom is mandatory");
|
|
ExtractorUtil.checkContainerInput(i4 != -1, "schi atom is mandatory");
|
|
TrackEncryptionBox parseSchiFromParent = parseSchiFromParent(parsableByteArray, i4, i5, str);
|
|
ExtractorUtil.checkContainerInput(parseSchiFromParent != null, "tenc atom is mandatory");
|
|
return Pair.create(num, (TrackEncryptionBox) Util.castNonNull(parseSchiFromParent));
|
|
}
|
|
|
|
private static TrackEncryptionBox parseSchiFromParent(ParsableByteArray parsableByteArray, int i, int i2, String str) {
|
|
int i3;
|
|
int i4;
|
|
int i5 = i + 8;
|
|
while (true) {
|
|
byte[] bArr = null;
|
|
if (i5 - i >= i2) {
|
|
return null;
|
|
}
|
|
parsableByteArray.setPosition(i5);
|
|
int readInt = parsableByteArray.readInt();
|
|
if (parsableByteArray.readInt() == 1952804451) {
|
|
int parseFullAtomVersion = Atom.parseFullAtomVersion(parsableByteArray.readInt());
|
|
parsableByteArray.skipBytes(1);
|
|
if (parseFullAtomVersion == 0) {
|
|
parsableByteArray.skipBytes(1);
|
|
i4 = 0;
|
|
i3 = 0;
|
|
} else {
|
|
int readUnsignedByte = parsableByteArray.readUnsignedByte();
|
|
i3 = readUnsignedByte & 15;
|
|
i4 = (readUnsignedByte & 240) >> 4;
|
|
}
|
|
boolean z = parsableByteArray.readUnsignedByte() == 1;
|
|
int readUnsignedByte2 = parsableByteArray.readUnsignedByte();
|
|
byte[] bArr2 = new byte[16];
|
|
parsableByteArray.readBytes(bArr2, 0, 16);
|
|
if (z && readUnsignedByte2 == 0) {
|
|
int readUnsignedByte3 = parsableByteArray.readUnsignedByte();
|
|
bArr = new byte[readUnsignedByte3];
|
|
parsableByteArray.readBytes(bArr, 0, readUnsignedByte3);
|
|
}
|
|
return new TrackEncryptionBox(z, str, readUnsignedByte2, bArr2, i4, i3, bArr);
|
|
}
|
|
i5 += readInt;
|
|
}
|
|
}
|
|
|
|
private static byte[] parseProjFromParent(ParsableByteArray parsableByteArray, int i, int i2) {
|
|
int i3 = i + 8;
|
|
while (i3 - i < i2) {
|
|
parsableByteArray.setPosition(i3);
|
|
int readInt = parsableByteArray.readInt();
|
|
if (parsableByteArray.readInt() == 1886547818) {
|
|
return Arrays.copyOfRange(parsableByteArray.getData(), i3, readInt + i3);
|
|
}
|
|
i3 += readInt;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private static int parseExpandableClassSize(ParsableByteArray parsableByteArray) {
|
|
int readUnsignedByte = parsableByteArray.readUnsignedByte();
|
|
int i = readUnsignedByte & 127;
|
|
while ((readUnsignedByte & 128) == 128) {
|
|
readUnsignedByte = parsableByteArray.readUnsignedByte();
|
|
i = (i << 7) | (readUnsignedByte & 127);
|
|
}
|
|
return i;
|
|
}
|
|
|
|
private static boolean canApplyEditWithGaplessInfo(long[] jArr, long j, long j2, long j3) {
|
|
int length = jArr.length - 1;
|
|
return jArr[0] <= j2 && j2 < jArr[Util.constrainValue(4, 0, length)] && jArr[Util.constrainValue(jArr.length - 4, 0, length)] < j3 && j3 <= j;
|
|
}
|
|
|
|
private AtomParsers() {
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* loaded from: classes2.dex */
|
|
public static final class ChunkIterator {
|
|
private final ParsableByteArray chunkOffsets;
|
|
private final boolean chunkOffsetsAreLongs;
|
|
public int index;
|
|
public final int length;
|
|
private int nextSamplesPerChunkChangeIndex;
|
|
public int numSamples;
|
|
public long offset;
|
|
private int remainingSamplesPerChunkChanges;
|
|
private final ParsableByteArray stsc;
|
|
|
|
public ChunkIterator(ParsableByteArray parsableByteArray, ParsableByteArray parsableByteArray2, boolean z) throws ParserException {
|
|
this.stsc = parsableByteArray;
|
|
this.chunkOffsets = parsableByteArray2;
|
|
this.chunkOffsetsAreLongs = z;
|
|
parsableByteArray2.setPosition(12);
|
|
this.length = parsableByteArray2.readUnsignedIntToInt();
|
|
parsableByteArray.setPosition(12);
|
|
this.remainingSamplesPerChunkChanges = parsableByteArray.readUnsignedIntToInt();
|
|
ExtractorUtil.checkContainerInput(parsableByteArray.readInt() == 1, "first_chunk must be 1");
|
|
this.index = -1;
|
|
}
|
|
|
|
public boolean moveNext() {
|
|
long readUnsignedInt;
|
|
int i = this.index + 1;
|
|
this.index = i;
|
|
if (i == this.length) {
|
|
return false;
|
|
}
|
|
if (this.chunkOffsetsAreLongs) {
|
|
readUnsignedInt = this.chunkOffsets.readUnsignedLongToLong();
|
|
} else {
|
|
readUnsignedInt = this.chunkOffsets.readUnsignedInt();
|
|
}
|
|
this.offset = readUnsignedInt;
|
|
if (this.index == this.nextSamplesPerChunkChangeIndex) {
|
|
this.numSamples = this.stsc.readUnsignedIntToInt();
|
|
this.stsc.skipBytes(4);
|
|
int i2 = this.remainingSamplesPerChunkChanges - 1;
|
|
this.remainingSamplesPerChunkChanges = i2;
|
|
this.nextSamplesPerChunkChangeIndex = i2 > 0 ? this.stsc.readUnsignedIntToInt() - 1 : -1;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* loaded from: classes2.dex */
|
|
public static final class TkhdData {
|
|
private final long duration;
|
|
private final int id;
|
|
private final int rotationDegrees;
|
|
|
|
public TkhdData(int i, long j, int i2) {
|
|
this.id = i;
|
|
this.duration = j;
|
|
this.rotationDegrees = i2;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* loaded from: classes2.dex */
|
|
public static final class StsdData {
|
|
public static final int STSD_HEADER_SIZE = 8;
|
|
public Format format;
|
|
public int nalUnitLengthFieldLength;
|
|
public int requiredSampleTransformation = 0;
|
|
public final TrackEncryptionBox[] trackEncryptionBoxes;
|
|
|
|
public StsdData(int i) {
|
|
this.trackEncryptionBoxes = new TrackEncryptionBox[i];
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* loaded from: classes2.dex */
|
|
public static final class EsdsData {
|
|
private final long bitrate;
|
|
private final byte[] initializationData;
|
|
private final String mimeType;
|
|
private final long peakBitrate;
|
|
|
|
public EsdsData(String str, byte[] bArr, long j, long j2) {
|
|
this.mimeType = str;
|
|
this.initializationData = bArr;
|
|
this.bitrate = j;
|
|
this.peakBitrate = j2;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public static final class StszSampleSizeBox implements SampleSizeBox {
|
|
private final ParsableByteArray data;
|
|
private final int fixedSampleSize;
|
|
private final int sampleCount;
|
|
|
|
@Override // androidx.media3.extractor.mp4.AtomParsers.SampleSizeBox
|
|
public int getFixedSampleSize() {
|
|
return this.fixedSampleSize;
|
|
}
|
|
|
|
@Override // androidx.media3.extractor.mp4.AtomParsers.SampleSizeBox
|
|
public int getSampleCount() {
|
|
return this.sampleCount;
|
|
}
|
|
|
|
public StszSampleSizeBox(Atom.LeafAtom leafAtom, Format format) {
|
|
ParsableByteArray parsableByteArray = leafAtom.data;
|
|
this.data = parsableByteArray;
|
|
parsableByteArray.setPosition(12);
|
|
int readUnsignedIntToInt = parsableByteArray.readUnsignedIntToInt();
|
|
if ("audio/raw".equals(format.sampleMimeType)) {
|
|
int pcmFrameSize = Util.getPcmFrameSize(format.pcmEncoding, format.channelCount);
|
|
if (readUnsignedIntToInt == 0 || readUnsignedIntToInt % pcmFrameSize != 0) {
|
|
Log.w(AtomParsers.TAG, "Audio sample size mismatch. stsd sample size: " + pcmFrameSize + ", stsz sample size: " + readUnsignedIntToInt);
|
|
readUnsignedIntToInt = pcmFrameSize;
|
|
}
|
|
}
|
|
this.fixedSampleSize = readUnsignedIntToInt == 0 ? -1 : readUnsignedIntToInt;
|
|
this.sampleCount = parsableByteArray.readUnsignedIntToInt();
|
|
}
|
|
|
|
@Override // androidx.media3.extractor.mp4.AtomParsers.SampleSizeBox
|
|
public int readNextSampleSize() {
|
|
int i = this.fixedSampleSize;
|
|
return i == -1 ? this.data.readUnsignedIntToInt() : i;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public static final class Stz2SampleSizeBox implements SampleSizeBox {
|
|
private int currentByte;
|
|
private final ParsableByteArray data;
|
|
private final int fieldSize;
|
|
private final int sampleCount;
|
|
private int sampleIndex;
|
|
|
|
@Override // androidx.media3.extractor.mp4.AtomParsers.SampleSizeBox
|
|
public int getFixedSampleSize() {
|
|
return -1;
|
|
}
|
|
|
|
@Override // androidx.media3.extractor.mp4.AtomParsers.SampleSizeBox
|
|
public int getSampleCount() {
|
|
return this.sampleCount;
|
|
}
|
|
|
|
public Stz2SampleSizeBox(Atom.LeafAtom leafAtom) {
|
|
ParsableByteArray parsableByteArray = leafAtom.data;
|
|
this.data = parsableByteArray;
|
|
parsableByteArray.setPosition(12);
|
|
this.fieldSize = parsableByteArray.readUnsignedIntToInt() & 255;
|
|
this.sampleCount = parsableByteArray.readUnsignedIntToInt();
|
|
}
|
|
|
|
@Override // androidx.media3.extractor.mp4.AtomParsers.SampleSizeBox
|
|
public int readNextSampleSize() {
|
|
int i = this.fieldSize;
|
|
if (i == 8) {
|
|
return this.data.readUnsignedByte();
|
|
}
|
|
if (i == 16) {
|
|
return this.data.readUnsignedShort();
|
|
}
|
|
int i2 = this.sampleIndex;
|
|
this.sampleIndex = i2 + 1;
|
|
if (i2 % 2 != 0) {
|
|
return this.currentByte & 15;
|
|
}
|
|
int readUnsignedByte = this.data.readUnsignedByte();
|
|
this.currentByte = readUnsignedByte;
|
|
return (readUnsignedByte & 240) >> 4;
|
|
}
|
|
}
|
|
}
|