Recover Files v1.3.9版本的 MD5 值为:27a8b2c239c6cb7111d74d6bb07d21b2
以下内容为反编译后的 MatroskaExtractor.java 源代码,内容仅作参考
package com.mbridge.msdk.playercommon.exoplayer2.extractor.mkv;
import android.support.v4.media.c;
import android.support.v4.media.f;
import android.util.Pair;
import android.util.SparseArray;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.mbridge.msdk.playercommon.exoplayer2.Format;
import com.mbridge.msdk.playercommon.exoplayer2.ParserException;
import com.mbridge.msdk.playercommon.exoplayer2.audio.Ac3Util;
import com.mbridge.msdk.playercommon.exoplayer2.drm.DrmInitData;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.ChunkIndex;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.Extractor;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.ExtractorInput;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.ExtractorOutput;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.ExtractorsFactory;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.PositionHolder;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.SeekMap;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.TrackOutput;
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
import com.mbridge.msdk.playercommon.exoplayer2.util.LongArray;
import com.mbridge.msdk.playercommon.exoplayer2.util.MimeTypes;
import com.mbridge.msdk.playercommon.exoplayer2.util.NalUnitUtil;
import com.mbridge.msdk.playercommon.exoplayer2.util.ParsableByteArray;
import com.mbridge.msdk.playercommon.exoplayer2.util.Util;
import com.mbridge.msdk.playercommon.exoplayer2.video.AvcConfig;
import com.mbridge.msdk.playercommon.exoplayer2.video.ColorInfo;
import com.mbridge.msdk.playercommon.exoplayer2.video.HevcConfig;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
import w9.b;
public final class MatroskaExtractor implements Extractor {
private static final int BLOCK_STATE_DATA = 2;
private static final int BLOCK_STATE_HEADER = 1;
private static final int BLOCK_STATE_START = 0;
private static final String CODEC_ID_AAC = "A_AAC";
private static final String CODEC_ID_AC3 = "A_AC3";
private static final String CODEC_ID_ACM = "A_MS/ACM";
private static final String CODEC_ID_ASS = "S_TEXT/ASS";
private static final String CODEC_ID_DTS = "A_DTS";
private static final String CODEC_ID_DTS_EXPRESS = "A_DTS/EXPRESS";
private static final String CODEC_ID_DTS_LOSSLESS = "A_DTS/LOSSLESS";
private static final String CODEC_ID_DVBSUB = "S_DVBSUB";
private static final String CODEC_ID_E_AC3 = "A_EAC3";
private static final String CODEC_ID_FLAC = "A_FLAC";
private static final String CODEC_ID_FOURCC = "V_MS/VFW/FOURCC";
private static final String CODEC_ID_H264 = "V_MPEG4/ISO/AVC";
private static final String CODEC_ID_H265 = "V_MPEGH/ISO/HEVC";
private static final String CODEC_ID_MP2 = "A_MPEG/L2";
private static final String CODEC_ID_MP3 = "A_MPEG/L3";
private static final String CODEC_ID_MPEG2 = "V_MPEG2";
private static final String CODEC_ID_MPEG4_AP = "V_MPEG4/ISO/AP";
private static final String CODEC_ID_MPEG4_ASP = "V_MPEG4/ISO/ASP";
private static final String CODEC_ID_MPEG4_SP = "V_MPEG4/ISO/SP";
private static final String CODEC_ID_OPUS = "A_OPUS";
private static final String CODEC_ID_PCM_INT_LIT = "A_PCM/INT/LIT";
private static final String CODEC_ID_PGS = "S_HDMV/PGS";
private static final String CODEC_ID_SUBRIP = "S_TEXT/UTF8";
private static final String CODEC_ID_THEORA = "V_THEORA";
private static final String CODEC_ID_TRUEHD = "A_TRUEHD";
private static final String CODEC_ID_VOBSUB = "S_VOBSUB";
private static final String CODEC_ID_VORBIS = "A_VORBIS";
private static final String CODEC_ID_VP8 = "V_VP8";
private static final String CODEC_ID_VP9 = "V_VP9";
private static final String DOC_TYPE_MATROSKA = "matroska";
private static final String DOC_TYPE_WEBM = "webm";
private static final int ENCRYPTION_IV_SIZE = 8;
public static final int FLAG_DISABLE_SEEK_FOR_CUES = 1;
private static final int FOURCC_COMPRESSION_DIVX = 1482049860;
private static final int FOURCC_COMPRESSION_VC1 = 826496599;
private static final int ID_AUDIO = 225;
private static final int ID_AUDIO_BIT_DEPTH = 25188;
private static final int ID_BLOCK = 161;
private static final int ID_BLOCK_DURATION = 155;
private static final int ID_BLOCK_GROUP = 160;
private static final int ID_CHANNELS = 159;
private static final int ID_CLUSTER = 524531317;
private static final int ID_CODEC_DELAY = 22186;
private static final int ID_CODEC_ID = 134;
private static final int ID_CODEC_PRIVATE = 25506;
private static final int ID_COLOUR = 21936;
private static final int ID_COLOUR_PRIMARIES = 21947;
private static final int ID_COLOUR_RANGE = 21945;
private static final int ID_COLOUR_TRANSFER = 21946;
private static final int ID_CONTENT_COMPRESSION = 20532;
private static final int ID_CONTENT_COMPRESSION_ALGORITHM = 16980;
private static final int ID_CONTENT_COMPRESSION_SETTINGS = 16981;
private static final int ID_CONTENT_ENCODING = 25152;
private static final int ID_CONTENT_ENCODINGS = 28032;
private static final int ID_CONTENT_ENCODING_ORDER = 20529;
private static final int ID_CONTENT_ENCODING_SCOPE = 20530;
private static final int ID_CONTENT_ENCRYPTION = 20533;
private static final int ID_CONTENT_ENCRYPTION_AES_SETTINGS = 18407;
private static final int ID_CONTENT_ENCRYPTION_AES_SETTINGS_CIPHER_MODE = 18408;
private static final int ID_CONTENT_ENCRYPTION_ALGORITHM = 18401;
private static final int ID_CONTENT_ENCRYPTION_KEY_ID = 18402;
private static final int ID_CUES = 475249515;
private static final int ID_CUE_CLUSTER_POSITION = 241;
private static final int ID_CUE_POINT = 187;
private static final int ID_CUE_TIME = 179;
private static final int ID_CUE_TRACK_POSITIONS = 183;
private static final int ID_DEFAULT_DURATION = 2352003;
private static final int ID_DISPLAY_HEIGHT = 21690;
private static final int ID_DISPLAY_UNIT = 21682;
private static final int ID_DISPLAY_WIDTH = 21680;
private static final int ID_DOC_TYPE = 17026;
private static final int ID_DOC_TYPE_READ_VERSION = 17029;
private static final int ID_DURATION = 17545;
private static final int ID_EBML = 440786851;
private static final int ID_EBML_READ_VERSION = 17143;
private static final int ID_FLAG_DEFAULT = 136;
private static final int ID_FLAG_FORCED = 21930;
private static final int ID_INFO = 357149030;
private static final int ID_LANGUAGE = 2274716;
private static final int ID_LUMNINANCE_MAX = 21977;
private static final int ID_LUMNINANCE_MIN = 21978;
private static final int ID_MASTERING_METADATA = 21968;
private static final int ID_MAX_CLL = 21948;
private static final int ID_MAX_FALL = 21949;
private static final int ID_PIXEL_HEIGHT = 186;
private static final int ID_PIXEL_WIDTH = 176;
private static final int ID_PRIMARY_B_CHROMATICITY_X = 21973;
private static final int ID_PRIMARY_B_CHROMATICITY_Y = 21974;
private static final int ID_PRIMARY_G_CHROMATICITY_X = 21971;
private static final int ID_PRIMARY_G_CHROMATICITY_Y = 21972;
private static final int ID_PRIMARY_R_CHROMATICITY_X = 21969;
private static final int ID_PRIMARY_R_CHROMATICITY_Y = 21970;
private static final int ID_PROJECTION = 30320;
private static final int ID_PROJECTION_PRIVATE = 30322;
private static final int ID_REFERENCE_BLOCK = 251;
private static final int ID_SAMPLING_FREQUENCY = 181;
private static final int ID_SEEK = 19899;
private static final int ID_SEEK_HEAD = 290298740;
private static final int ID_SEEK_ID = 21419;
private static final int ID_SEEK_POSITION = 21420;
private static final int ID_SEEK_PRE_ROLL = 22203;
private static final int ID_SEGMENT = 408125543;
private static final int ID_SEGMENT_INFO = 357149030;
private static final int ID_SIMPLE_BLOCK = 163;
private static final int ID_STEREO_MODE = 21432;
private static final int ID_TIMECODE_SCALE = 2807729;
private static final int ID_TIME_CODE = 231;
private static final int ID_TRACKS = 374648427;
private static final int ID_TRACK_ENTRY = 174;
private static final int ID_TRACK_NUMBER = 215;
private static final int ID_TRACK_TYPE = 131;
private static final int ID_VIDEO = 224;
private static final int ID_WHITE_POINT_CHROMATICITY_X = 21975;
private static final int ID_WHITE_POINT_CHROMATICITY_Y = 21976;
private static final int LACING_EBML = 3;
private static final int LACING_FIXED_SIZE = 2;
private static final int LACING_NONE = 0;
private static final int LACING_XIPH = 1;
private static final int OPUS_MAX_INPUT_SIZE = 5760;
private static final int SSA_PREFIX_END_TIMECODE_OFFSET = 21;
private static final String SSA_TIMECODE_FORMAT = "%01d:%02d:%02d:%02d";
private static final long SSA_TIMECODE_LAST_VALUE_SCALING_FACTOR = 10000;
private static final int SUBRIP_PREFIX_END_TIMECODE_OFFSET = 19;
private static final String SUBRIP_TIMECODE_FORMAT = "%02d:%02d:%02d,%03d";
private static final long SUBRIP_TIMECODE_LAST_VALUE_SCALING_FACTOR = 1000;
private static final String TAG = "MatroskaExtractor";
private static final int TRACK_TYPE_AUDIO = 2;
private static final int UNSET_ENTRY_ID = -1;
private static final int VORBIS_MAX_INPUT_SIZE = 8192;
private static final int WAVE_FORMAT_EXTENSIBLE = 65534;
private static final int WAVE_FORMAT_PCM = 1;
private static final int WAVE_FORMAT_SIZE = 18;
private long blockDurationUs;
private int blockFlags;
private int blockLacingSampleCount;
private int blockLacingSampleIndex;
private int[] blockLacingSampleSizes;
private int blockState;
private long blockTimeUs;
private int blockTrackNumber;
private int blockTrackNumberLength;
private long clusterTimecodeUs;
private LongArray cueClusterPositions;
private LongArray cueTimesUs;
private long cuesContentPosition;
private Track currentTrack;
private long durationTimecode;
private long durationUs;
private final ParsableByteArray encryptionInitializationVector;
private final ParsableByteArray encryptionSubsampleData;
private ByteBuffer encryptionSubsampleDataBuffer;
private ExtractorOutput extractorOutput;
private final ParsableByteArray nalLength;
private final ParsableByteArray nalStartCode;
private final EbmlReader reader;
private int sampleBytesRead;
private int sampleBytesWritten;
private int sampleCurrentNalBytesRemaining;
private boolean sampleEncodingHandled;
private boolean sampleInitializationVectorRead;
private int samplePartitionCount;
private boolean samplePartitionCountRead;
private boolean sampleRead;
private boolean sampleSeenReferenceBlock;
private byte sampleSignalByte;
private boolean sampleSignalByteRead;
private final ParsableByteArray sampleStrippedBytes;
private final ParsableByteArray scratch;
private int seekEntryId;
private final ParsableByteArray seekEntryIdBytes;
private long seekEntryPosition;
private boolean seekForCues;
private final boolean seekForCuesEnabled;
private long seekPositionAfterBuildingCues;
private boolean seenClusterPositionForCurrentCuePoint;
private long segmentContentPosition;
private long segmentContentSize;
private boolean sentSeekMap;
private final ParsableByteArray subtitleSample;
private long timecodeScale;
private final SparseArray<Track> tracks;
private final VarintReader varintReader;
private final ParsableByteArray vorbisNumPageSamples;
public static final ExtractorsFactory FACTORY = new ExtractorsFactory() {
@Override
public Extractor[] createExtractors() {
return new Extractor[]{new MatroskaExtractor()};
}
};
private static final byte[] SUBRIP_PREFIX = {49, 10, 48, 48, 58, 48, 48, 58, 48, 48, 44, 48, 48, 48, 32, 45, 45, 62, 32, 48, 48, 58, 48, 48, 58, 48, 48, 44, 48, 48, 48, 10};
private static final byte[] SUBRIP_TIMECODE_EMPTY = {32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32};
private static final byte[] SSA_DIALOGUE_FORMAT = Util.getUtf8Bytes("Format: Start, End, ReadOrder, Layer, Style, Name, MarginL, MarginR, MarginV, Effect, Text");
private static final byte[] SSA_PREFIX = {68, 105, 97, 108, 111, 103, 117, 101, 58, 32, 48, 58, 48, 48, 58, 48, 48, 58, 48, 48, 44, 48, 58, 48, 48, 58, 48, 48, 58, 48, 48, 44};
private static final byte[] SSA_TIMECODE_EMPTY = {32, 32, 32, 32, 32, 32, 32, 32, 32, 32};
private static final UUID WAVE_SUBFORMAT_PCM = new UUID(72057594037932032L, -9223371306706625679L);
public @interface Flags {
}
public final class InnerEbmlReaderOutput implements EbmlReaderOutput {
private InnerEbmlReaderOutput() {
}
@Override
public final void binaryElement(int i10, int i11, ExtractorInput extractorInput) throws IOException, InterruptedException {
MatroskaExtractor.this.binaryElement(i10, i11, extractorInput);
}
@Override
public final void endMasterElement(int i10) throws ParserException {
MatroskaExtractor.this.endMasterElement(i10);
}
@Override
public final void floatElement(int i10, double d10) throws ParserException {
MatroskaExtractor.this.floatElement(i10, d10);
}
@Override
public final int getElementType(int i10) {
switch (i10) {
case 131:
case 136:
case 155:
case 159:
case 176:
case 179:
case 186:
case 215:
case MatroskaExtractor.ID_TIME_CODE:
case MatroskaExtractor.ID_CUE_CLUSTER_POSITION:
case 251:
case MatroskaExtractor.ID_CONTENT_COMPRESSION_ALGORITHM:
case MatroskaExtractor.ID_DOC_TYPE_READ_VERSION:
case MatroskaExtractor.ID_EBML_READ_VERSION:
case MatroskaExtractor.ID_CONTENT_ENCRYPTION_ALGORITHM:
case MatroskaExtractor.ID_CONTENT_ENCRYPTION_AES_SETTINGS_CIPHER_MODE:
case MatroskaExtractor.ID_CONTENT_ENCODING_ORDER:
case MatroskaExtractor.ID_CONTENT_ENCODING_SCOPE:
case MatroskaExtractor.ID_SEEK_POSITION:
case MatroskaExtractor.ID_STEREO_MODE:
case MatroskaExtractor.ID_DISPLAY_WIDTH:
case MatroskaExtractor.ID_DISPLAY_UNIT:
case MatroskaExtractor.ID_DISPLAY_HEIGHT:
case MatroskaExtractor.ID_FLAG_FORCED:
case MatroskaExtractor.ID_COLOUR_RANGE:
case MatroskaExtractor.ID_COLOUR_TRANSFER:
case MatroskaExtractor.ID_COLOUR_PRIMARIES:
case MatroskaExtractor.ID_MAX_CLL:
case MatroskaExtractor.ID_MAX_FALL:
case MatroskaExtractor.ID_CODEC_DELAY:
case MatroskaExtractor.ID_SEEK_PRE_ROLL:
case MatroskaExtractor.ID_AUDIO_BIT_DEPTH:
case MatroskaExtractor.ID_DEFAULT_DURATION:
case MatroskaExtractor.ID_TIMECODE_SCALE:
return 2;
case 134:
case 17026:
case MatroskaExtractor.ID_LANGUAGE:
return 3;
case 160:
case 174:
case 183:
case 187:
case 224:
case 225:
case MatroskaExtractor.ID_CONTENT_ENCRYPTION_AES_SETTINGS:
case MatroskaExtractor.ID_SEEK:
case MatroskaExtractor.ID_CONTENT_COMPRESSION:
case MatroskaExtractor.ID_CONTENT_ENCRYPTION:
case MatroskaExtractor.ID_COLOUR:
case MatroskaExtractor.ID_MASTERING_METADATA:
case MatroskaExtractor.ID_CONTENT_ENCODING:
case MatroskaExtractor.ID_CONTENT_ENCODINGS:
case MatroskaExtractor.ID_PROJECTION:
case MatroskaExtractor.ID_SEEK_HEAD:
case 357149030:
case MatroskaExtractor.ID_TRACKS:
case MatroskaExtractor.ID_SEGMENT:
case MatroskaExtractor.ID_EBML:
case MatroskaExtractor.ID_CUES:
case MatroskaExtractor.ID_CLUSTER:
return 1;
case 161:
case 163:
case MatroskaExtractor.ID_CONTENT_COMPRESSION_SETTINGS:
case MatroskaExtractor.ID_CONTENT_ENCRYPTION_KEY_ID:
case MatroskaExtractor.ID_SEEK_ID:
case MatroskaExtractor.ID_CODEC_PRIVATE:
case MatroskaExtractor.ID_PROJECTION_PRIVATE:
return 4;
case 181:
case MatroskaExtractor.ID_DURATION:
case MatroskaExtractor.ID_PRIMARY_R_CHROMATICITY_X:
case MatroskaExtractor.ID_PRIMARY_R_CHROMATICITY_Y:
case MatroskaExtractor.ID_PRIMARY_G_CHROMATICITY_X:
case MatroskaExtractor.ID_PRIMARY_G_CHROMATICITY_Y:
case MatroskaExtractor.ID_PRIMARY_B_CHROMATICITY_X:
case MatroskaExtractor.ID_PRIMARY_B_CHROMATICITY_Y:
case MatroskaExtractor.ID_WHITE_POINT_CHROMATICITY_X:
case MatroskaExtractor.ID_WHITE_POINT_CHROMATICITY_Y:
case MatroskaExtractor.ID_LUMNINANCE_MAX:
case MatroskaExtractor.ID_LUMNINANCE_MIN:
return 5;
default:
return 0;
}
}
@Override
public final void integerElement(int i10, long j10) throws ParserException {
MatroskaExtractor.this.integerElement(i10, j10);
}
@Override
public final boolean isLevel1Element(int i10) {
if (i10 != 357149030 && i10 != MatroskaExtractor.ID_CLUSTER && i10 != MatroskaExtractor.ID_CUES && i10 != MatroskaExtractor.ID_TRACKS) {
return false;
}
return true;
}
@Override
public final void startMasterElement(int i10, long j10, long j11) throws ParserException {
MatroskaExtractor.this.startMasterElement(i10, j10, j11);
}
@Override
public final void stringElement(int i10, String str) throws ParserException {
MatroskaExtractor.this.stringElement(i10, str);
}
}
public static final class Track {
private static final int DEFAULT_MAX_CLL = 1000;
private static final int DEFAULT_MAX_FALL = 200;
private static final int DISPLAY_UNIT_PIXELS = 0;
private static final int MAX_CHROMATICITY = 50000;
public int audioBitDepth;
public int channelCount;
public long codecDelayNs;
public String codecId;
public byte[] codecPrivate;
public int colorRange;
public int colorSpace;
public int colorTransfer;
public TrackOutput.CryptoData cryptoData;
public int defaultSampleDurationNs;
public int displayHeight;
public int displayUnit;
public int displayWidth;
public DrmInitData drmInitData;
public boolean flagDefault;
public boolean flagForced;
public boolean hasColorInfo;
public boolean hasContentEncryption;
public int height;
private String language;
public int maxContentLuminance;
public int maxFrameAverageLuminance;
public float maxMasteringLuminance;
public float minMasteringLuminance;
public int nalUnitLengthFieldLength;
public int number;
public TrackOutput output;
public float primaryBChromaticityX;
public float primaryBChromaticityY;
public float primaryGChromaticityX;
public float primaryGChromaticityY;
public float primaryRChromaticityX;
public float primaryRChromaticityY;
public byte[] projectionData;
public int sampleRate;
public byte[] sampleStrippedBytes;
public long seekPreRollNs;
public int stereoMode;
public TrueHdSampleRechunker trueHdSampleRechunker;
public int type;
public float whitePointChromaticityX;
public float whitePointChromaticityY;
public int width;
private Track() {
this.width = -1;
this.height = -1;
this.displayWidth = -1;
this.displayHeight = -1;
this.displayUnit = 0;
this.projectionData = null;
this.stereoMode = -1;
this.hasColorInfo = false;
this.colorSpace = -1;
this.colorTransfer = -1;
this.colorRange = -1;
this.maxContentLuminance = 1000;
this.maxFrameAverageLuminance = 200;
this.primaryRChromaticityX = -1.0f;
this.primaryRChromaticityY = -1.0f;
this.primaryGChromaticityX = -1.0f;
this.primaryGChromaticityY = -1.0f;
this.primaryBChromaticityX = -1.0f;
this.primaryBChromaticityY = -1.0f;
this.whitePointChromaticityX = -1.0f;
this.whitePointChromaticityY = -1.0f;
this.maxMasteringLuminance = -1.0f;
this.minMasteringLuminance = -1.0f;
this.channelCount = 1;
this.audioBitDepth = -1;
this.sampleRate = 8000;
this.codecDelayNs = 0L;
this.seekPreRollNs = 0L;
this.flagDefault = true;
this.language = "eng";
}
private byte[] getHdrStaticInfo() {
if (this.primaryRChromaticityX != -1.0f && this.primaryRChromaticityY != -1.0f && this.primaryGChromaticityX != -1.0f && this.primaryGChromaticityY != -1.0f && this.primaryBChromaticityX != -1.0f && this.primaryBChromaticityY != -1.0f && this.whitePointChromaticityX != -1.0f && this.whitePointChromaticityY != -1.0f && this.maxMasteringLuminance != -1.0f && this.minMasteringLuminance != -1.0f) {
byte[] bArr = new byte[25];
ByteBuffer wrap = ByteBuffer.wrap(bArr);
wrap.put((byte) 0);
wrap.putShort((short) ((this.primaryRChromaticityX * 50000.0f) + 0.5f));
wrap.putShort((short) ((this.primaryRChromaticityY * 50000.0f) + 0.5f));
wrap.putShort((short) ((this.primaryGChromaticityX * 50000.0f) + 0.5f));
wrap.putShort((short) ((this.primaryGChromaticityY * 50000.0f) + 0.5f));
wrap.putShort((short) ((this.primaryBChromaticityX * 50000.0f) + 0.5f));
wrap.putShort((short) ((this.primaryBChromaticityY * 50000.0f) + 0.5f));
wrap.putShort((short) ((this.whitePointChromaticityX * 50000.0f) + 0.5f));
wrap.putShort((short) ((this.whitePointChromaticityY * 50000.0f) + 0.5f));
wrap.putShort((short) (this.maxMasteringLuminance + 0.5f));
wrap.putShort((short) (this.minMasteringLuminance + 0.5f));
wrap.putShort((short) this.maxContentLuminance);
wrap.putShort((short) this.maxFrameAverageLuminance);
return bArr;
}
return null;
}
private static Pair<String, List<byte[]>> parseFourCcPrivate(ParsableByteArray parsableByteArray) throws ParserException {
try {
parsableByteArray.skipBytes(16);
long readLittleEndianUnsignedInt = parsableByteArray.readLittleEndianUnsignedInt();
if (readLittleEndianUnsignedInt == 1482049860) {
return new Pair<>("video/3gpp", null);
}
if (readLittleEndianUnsignedInt == 826496599) {
byte[] bArr = parsableByteArray.data;
for (int position = parsableByteArray.getPosition() + 20; position < bArr.length - 4; position++) {
if (bArr[position] == 0 && bArr[position + 1] == 0 && bArr[position + 2] == 1 && bArr[position + 3] == 15) {
return new Pair<>("video/wvc1", Collections.singletonList(Arrays.copyOfRange(bArr, position, bArr.length)));
}
}
throw new ParserException("Failed to find FourCC VC1 initialization data");
}
return new Pair<>("video/x-unknown", null);
} catch (ArrayIndexOutOfBoundsException unused) {
throw new ParserException("Error parsing FourCC private data");
}
}
private static boolean parseMsAcmCodecPrivate(ParsableByteArray parsableByteArray) throws ParserException {
try {
int readLittleEndianUnsignedShort = parsableByteArray.readLittleEndianUnsignedShort();
if (readLittleEndianUnsignedShort == 1) {
return true;
}
if (readLittleEndianUnsignedShort != 65534) {
return false;
}
parsableByteArray.setPosition(24);
if (parsableByteArray.readLong() == MatroskaExtractor.WAVE_SUBFORMAT_PCM.getMostSignificantBits()) {
if (parsableByteArray.readLong() == MatroskaExtractor.WAVE_SUBFORMAT_PCM.getLeastSignificantBits()) {
return true;
}
}
return false;
} catch (ArrayIndexOutOfBoundsException unused) {
throw new ParserException("Error parsing MS/ACM codec private");
}
}
private static List<byte[]> parseVorbisCodecPrivate(byte[] bArr) throws ParserException {
int i10;
int i11;
try {
if (bArr[0] == 2) {
int i12 = 0;
int i13 = 1;
while (true) {
i10 = bArr[i13];
if (i10 != -1) {
break;
}
i12 += 255;
i13++;
}
int i14 = i13 + 1;
int i15 = i12 + i10;
int i16 = 0;
while (true) {
i11 = bArr[i14];
if (i11 != -1) {
break;
}
i16 += 255;
i14++;
}
int i17 = i14 + 1;
int i18 = i16 + i11;
if (bArr[i17] == 1) {
byte[] bArr2 = new byte[i15];
System.arraycopy(bArr, i17, bArr2, 0, i15);
int i19 = i17 + i15;
if (bArr[i19] == 3) {
int i20 = i19 + i18;
if (bArr[i20] == 5) {
byte[] bArr3 = new byte[bArr.length - i20];
System.arraycopy(bArr, i20, bArr3, 0, bArr.length - i20);
ArrayList arrayList = new ArrayList(2);
arrayList.add(bArr2);
arrayList.add(bArr3);
return arrayList;
}
throw new ParserException("Error parsing vorbis codec private");
}
throw new ParserException("Error parsing vorbis codec private");
}
throw new ParserException("Error parsing vorbis codec private");
}
throw new ParserException("Error parsing vorbis codec private");
} catch (ArrayIndexOutOfBoundsException unused) {
throw new ParserException("Error parsing vorbis codec private");
}
}
public final void initializeOutput(ExtractorOutput extractorOutput, int i10) throws ParserException {
char c10;
List<byte[]> list;
int pcmEncoding;
int i11;
int i12;
int i13;
List<byte[]> list2;
List<byte[]> list3;
List<byte[]> list4;
Format createImageSampleFormat;
float f10;
ColorInfo colorInfo;
int i14;
List<byte[]> list5;
String str = this.codecId;
str.getClass();
int i15 = 1;
int i16 = 0;
switch (str.hashCode()) {
case -2095576542:
if (str.equals(MatroskaExtractor.CODEC_ID_MPEG4_AP)) {
c10 = 0;
break;
}
c10 = 65535;
break;
case -2095575984:
if (str.equals(MatroskaExtractor.CODEC_ID_MPEG4_SP)) {
c10 = 1;
break;
}
c10 = 65535;
break;
case -1985379776:
if (str.equals(MatroskaExtractor.CODEC_ID_ACM)) {
c10 = 2;
break;
}
c10 = 65535;
break;
case -1784763192:
if (str.equals(MatroskaExtractor.CODEC_ID_TRUEHD)) {
c10 = 3;
break;
}
c10 = 65535;
break;
case -1730367663:
if (str.equals(MatroskaExtractor.CODEC_ID_VORBIS)) {
c10 = 4;
break;
}
c10 = 65535;
break;
case -1482641358:
if (str.equals(MatroskaExtractor.CODEC_ID_MP2)) {
c10 = 5;
break;
}
c10 = 65535;
break;
case -1482641357:
if (str.equals(MatroskaExtractor.CODEC_ID_MP3)) {
c10 = 6;
break;
}
c10 = 65535;
break;
case -1373388978:
if (str.equals(MatroskaExtractor.CODEC_ID_FOURCC)) {
c10 = 7;
break;
}
c10 = 65535;
break;
case -933872740:
if (str.equals(MatroskaExtractor.CODEC_ID_DVBSUB)) {
c10 = '\b';
break;
}
c10 = 65535;
break;
case -538363189:
if (str.equals(MatroskaExtractor.CODEC_ID_MPEG4_ASP)) {
c10 = '\t';
break;
}
c10 = 65535;
break;
case -538363109:
if (str.equals(MatroskaExtractor.CODEC_ID_H264)) {
c10 = '\n';
break;
}
c10 = 65535;
break;
case -425012669:
if (str.equals(MatroskaExtractor.CODEC_ID_VOBSUB)) {
c10 = 11;
break;
}
c10 = 65535;
break;
case -356037306:
if (str.equals(MatroskaExtractor.CODEC_ID_DTS_LOSSLESS)) {
c10 = '\f';
break;
}
c10 = 65535;
break;
case 62923557:
if (str.equals(MatroskaExtractor.CODEC_ID_AAC)) {
c10 = '\r';
break;
}
c10 = 65535;
break;
case 62923603:
if (str.equals(MatroskaExtractor.CODEC_ID_AC3)) {
c10 = 14;
break;
}
c10 = 65535;
break;
case 62927045:
if (str.equals(MatroskaExtractor.CODEC_ID_DTS)) {
c10 = 15;
break;
}
c10 = 65535;
break;
case 82338133:
if (str.equals(MatroskaExtractor.CODEC_ID_VP8)) {
c10 = 16;
break;
}
c10 = 65535;
break;
case 82338134:
if (str.equals(MatroskaExtractor.CODEC_ID_VP9)) {
c10 = 17;
break;
}
c10 = 65535;
break;
case 99146302:
if (str.equals(MatroskaExtractor.CODEC_ID_PGS)) {
c10 = 18;
break;
}
c10 = 65535;
break;
case 444813526:
if (str.equals(MatroskaExtractor.CODEC_ID_THEORA)) {
c10 = 19;
break;
}
c10 = 65535;
break;
case 542569478:
if (str.equals(MatroskaExtractor.CODEC_ID_DTS_EXPRESS)) {
c10 = 20;
break;
}
c10 = 65535;
break;
case 725957860:
if (str.equals(MatroskaExtractor.CODEC_ID_PCM_INT_LIT)) {
c10 = 21;
break;
}
c10 = 65535;
break;
case 738597099:
if (str.equals(MatroskaExtractor.CODEC_ID_ASS)) {
c10 = 22;
break;
}
c10 = 65535;
break;
case 855502857:
if (str.equals(MatroskaExtractor.CODEC_ID_H265)) {
c10 = 23;
break;
}
c10 = 65535;
break;
case 1422270023:
if (str.equals(MatroskaExtractor.CODEC_ID_SUBRIP)) {
c10 = 24;
break;
}
c10 = 65535;
break;
case 1809237540:
if (str.equals(MatroskaExtractor.CODEC_ID_MPEG2)) {
c10 = 25;
break;
}
c10 = 65535;
break;
case 1950749482:
if (str.equals(MatroskaExtractor.CODEC_ID_E_AC3)) {
c10 = 26;
break;
}
c10 = 65535;
break;
case 1950789798:
if (str.equals(MatroskaExtractor.CODEC_ID_FLAC)) {
c10 = 27;
break;
}
c10 = 65535;
break;
case 1951062397:
if (str.equals(MatroskaExtractor.CODEC_ID_OPUS)) {
c10 = b.f40805n;
break;
}
c10 = 65535;
break;
default:
c10 = 65535;
break;
}
String str2 = "audio/raw";
switch (c10) {
case 0:
case 1:
case '\t':
byte[] bArr = this.codecPrivate;
if (bArr == null) {
list = null;
} else {
list = Collections.singletonList(bArr);
}
str2 = "video/mp4v-es";
list3 = list;
i12 = -1;
i13 = -1;
list4 = list3;
int i17 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
i16 = 2;
}
int i18 = i17 | i16;
if (MimeTypes.isAudio(str2)) {
createImageSampleFormat = Format.createAudioSampleFormat(Integer.toString(i10), str2, null, -1, i13, this.channelCount, this.sampleRate, i12, list4, this.drmInitData, i18, this.language);
} else if (MimeTypes.isVideo(str2)) {
if (this.displayUnit == 0) {
int i19 = this.displayWidth;
if (i19 == -1) {
i19 = this.width;
}
this.displayWidth = i19;
int i20 = this.displayHeight;
if (i20 == -1) {
i20 = this.height;
}
this.displayHeight = i20;
}
if (this.displayWidth != -1 && (i14 = this.displayHeight) != -1) {
f10 = (this.height * r2) / (this.width * i14);
} else {
f10 = -1.0f;
}
float f11 = f10;
if (this.hasColorInfo) {
colorInfo = new ColorInfo(this.colorSpace, this.colorRange, this.colorTransfer, getHdrStaticInfo());
} else {
colorInfo = null;
}
createImageSampleFormat = Format.createVideoSampleFormat(Integer.toString(i10), str2, null, -1, i13, this.width, this.height, -1.0f, list4, -1, f11, this.projectionData, this.stereoMode, colorInfo, this.drmInitData);
i15 = 2;
} else {
if ("application/x-subrip".equals(str2)) {
createImageSampleFormat = Format.createTextSampleFormat(Integer.toString(i10), str2, i18, this.language, this.drmInitData);
} else if ("text/x-ssa".equals(str2)) {
ArrayList arrayList = new ArrayList(2);
arrayList.add(MatroskaExtractor.SSA_DIALOGUE_FORMAT);
arrayList.add(this.codecPrivate);
createImageSampleFormat = Format.createTextSampleFormat(Integer.toString(i10), str2, null, -1, i18, this.language, -1, this.drmInitData, Long.MAX_VALUE, arrayList);
} else {
if (!"application/vobsub".equals(str2) && !"application/pgs".equals(str2) && !"application/dvbsubs".equals(str2)) {
throw new ParserException("Unexpected MIME type.");
}
createImageSampleFormat = Format.createImageSampleFormat(Integer.toString(i10), str2, null, -1, i18, list4, this.language, this.drmInitData);
}
i15 = 3;
}
TrackOutput track = extractorOutput.track(this.number, i15);
this.output = track;
track.format(createImageSampleFormat);
return;
case 2:
if (parseMsAcmCodecPrivate(new ParsableByteArray(this.codecPrivate))) {
pcmEncoding = Util.getPcmEncoding(this.audioBitDepth);
break;
}
i12 = -1;
i13 = -1;
str2 = "audio/x-unknown";
list4 = null;
int i172 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
}
int i182 = i172 | i16;
if (MimeTypes.isAudio(str2)) {
}
TrackOutput track2 = extractorOutput.track(this.number, i15);
this.output = track2;
track2.format(createImageSampleFormat);
return;
case 3:
this.trueHdSampleRechunker = new TrueHdSampleRechunker();
str2 = "audio/true-hd";
i12 = -1;
i13 = -1;
list4 = null;
int i1722 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
}
int i1822 = i1722 | i16;
if (MimeTypes.isAudio(str2)) {
}
TrackOutput track22 = extractorOutput.track(this.number, i15);
this.output = track22;
track22.format(createImageSampleFormat);
return;
case 4:
str2 = "audio/vorbis";
i11 = 8192;
list5 = parseVorbisCodecPrivate(this.codecPrivate);
i12 = -1;
i13 = i11;
list4 = list5;
int i17222 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
}
int i18222 = i17222 | i16;
if (MimeTypes.isAudio(str2)) {
}
TrackOutput track222 = extractorOutput.track(this.number, i15);
this.output = track222;
track222.format(createImageSampleFormat);
return;
case 5:
str2 = "audio/mpeg-L2";
i12 = -1;
i13 = 4096;
list4 = null;
int i172222 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
}
int i182222 = i172222 | i16;
if (MimeTypes.isAudio(str2)) {
}
TrackOutput track2222 = extractorOutput.track(this.number, i15);
this.output = track2222;
track2222.format(createImageSampleFormat);
return;
case 6:
str2 = "audio/mpeg";
i12 = -1;
i13 = 4096;
list4 = null;
int i1722222 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
}
int i1822222 = i1722222 | i16;
if (MimeTypes.isAudio(str2)) {
}
TrackOutput track22222 = extractorOutput.track(this.number, i15);
this.output = track22222;
track22222.format(createImageSampleFormat);
return;
case 7:
Pair<String, List<byte[]>> parseFourCcPrivate = parseFourCcPrivate(new ParsableByteArray(this.codecPrivate));
str2 = (String) parseFourCcPrivate.first;
list3 = (List) parseFourCcPrivate.second;
i12 = -1;
i13 = -1;
list4 = list3;
int i17222222 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
}
int i18222222 = i17222222 | i16;
if (MimeTypes.isAudio(str2)) {
}
TrackOutput track222222 = extractorOutput.track(this.number, i15);
this.output = track222222;
track222222.format(createImageSampleFormat);
return;
case '\b':
byte[] bArr2 = this.codecPrivate;
str2 = "application/dvbsubs";
list3 = Collections.singletonList(new byte[]{bArr2[0], bArr2[1], bArr2[2], bArr2[3]});
i12 = -1;
i13 = -1;
list4 = list3;
int i172222222 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
}
int i182222222 = i172222222 | i16;
if (MimeTypes.isAudio(str2)) {
}
TrackOutput track2222222 = extractorOutput.track(this.number, i15);
this.output = track2222222;
track2222222.format(createImageSampleFormat);
return;
case '\n':
AvcConfig parse = AvcConfig.parse(new ParsableByteArray(this.codecPrivate));
list2 = parse.initializationData;
this.nalUnitLengthFieldLength = parse.nalUnitLengthFieldLength;
str2 = "video/avc";
list3 = list2;
i12 = -1;
i13 = -1;
list4 = list3;
int i1722222222 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
}
int i1822222222 = i1722222222 | i16;
if (MimeTypes.isAudio(str2)) {
}
TrackOutput track22222222 = extractorOutput.track(this.number, i15);
this.output = track22222222;
track22222222.format(createImageSampleFormat);
return;
case 11:
i12 = -1;
i13 = -1;
str2 = "application/vobsub";
list4 = Collections.singletonList(this.codecPrivate);
int i17222222222 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
}
int i18222222222 = i17222222222 | i16;
if (MimeTypes.isAudio(str2)) {
}
TrackOutput track222222222 = extractorOutput.track(this.number, i15);
this.output = track222222222;
track222222222.format(createImageSampleFormat);
return;
case '\f':
str2 = "audio/vnd.dts.hd";
i12 = -1;
i13 = -1;
list4 = null;
int i172222222222 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
}
int i182222222222 = i172222222222 | i16;
if (MimeTypes.isAudio(str2)) {
}
TrackOutput track2222222222 = extractorOutput.track(this.number, i15);
this.output = track2222222222;
track2222222222.format(createImageSampleFormat);
return;
case '\r':
str2 = "audio/mp4a-latm";
list3 = Collections.singletonList(this.codecPrivate);
i12 = -1;
i13 = -1;
list4 = list3;
int i1722222222222 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
}
int i1822222222222 = i1722222222222 | i16;
if (MimeTypes.isAudio(str2)) {
}
TrackOutput track22222222222 = extractorOutput.track(this.number, i15);
this.output = track22222222222;
track22222222222.format(createImageSampleFormat);
return;
case 14:
str2 = "audio/ac3";
i12 = -1;
i13 = -1;
list4 = null;
int i17222222222222 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
}
int i18222222222222 = i17222222222222 | i16;
if (MimeTypes.isAudio(str2)) {
}
TrackOutput track222222222222 = extractorOutput.track(this.number, i15);
this.output = track222222222222;
track222222222222.format(createImageSampleFormat);
return;
case 15:
case 20:
str2 = "audio/vnd.dts";
i12 = -1;
i13 = -1;
list4 = null;
int i172222222222222 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
}
int i182222222222222 = i172222222222222 | i16;
if (MimeTypes.isAudio(str2)) {
}
TrackOutput track2222222222222 = extractorOutput.track(this.number, i15);
this.output = track2222222222222;
track2222222222222.format(createImageSampleFormat);
return;
case 16:
str2 = "video/x-vnd.on2.vp8";
i12 = -1;
i13 = -1;
list4 = null;
int i1722222222222222 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
}
int i1822222222222222 = i1722222222222222 | i16;
if (MimeTypes.isAudio(str2)) {
}
TrackOutput track22222222222222 = extractorOutput.track(this.number, i15);
this.output = track22222222222222;
track22222222222222.format(createImageSampleFormat);
return;
case 17:
str2 = "video/x-vnd.on2.vp9";
i12 = -1;
i13 = -1;
list4 = null;
int i17222222222222222 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
}
int i18222222222222222 = i17222222222222222 | i16;
if (MimeTypes.isAudio(str2)) {
}
TrackOutput track222222222222222 = extractorOutput.track(this.number, i15);
this.output = track222222222222222;
track222222222222222.format(createImageSampleFormat);
return;
case 18:
i12 = -1;
i13 = -1;
str2 = "application/pgs";
list4 = null;
int i172222222222222222 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
}
int i182222222222222222 = i172222222222222222 | i16;
if (MimeTypes.isAudio(str2)) {
}
TrackOutput track2222222222222222 = extractorOutput.track(this.number, i15);
this.output = track2222222222222222;
track2222222222222222.format(createImageSampleFormat);
return;
case 19:
str2 = "video/x-unknown";
i12 = -1;
i13 = -1;
list4 = null;
int i1722222222222222222 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
}
int i1822222222222222222 = i1722222222222222222 | i16;
if (MimeTypes.isAudio(str2)) {
}
TrackOutput track22222222222222222 = extractorOutput.track(this.number, i15);
this.output = track22222222222222222;
track22222222222222222.format(createImageSampleFormat);
return;
case 21:
pcmEncoding = Util.getPcmEncoding(this.audioBitDepth);
break;
case 22:
i12 = -1;
i13 = -1;
str2 = "text/x-ssa";
list4 = null;
int i17222222222222222222 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
}
int i18222222222222222222 = i17222222222222222222 | i16;
if (MimeTypes.isAudio(str2)) {
}
TrackOutput track222222222222222222 = extractorOutput.track(this.number, i15);
this.output = track222222222222222222;
track222222222222222222.format(createImageSampleFormat);
return;
case 23:
HevcConfig parse2 = HevcConfig.parse(new ParsableByteArray(this.codecPrivate));
list2 = parse2.initializationData;
this.nalUnitLengthFieldLength = parse2.nalUnitLengthFieldLength;
str2 = "video/hevc";
list3 = list2;
i12 = -1;
i13 = -1;
list4 = list3;
int i172222222222222222222 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
}
int i182222222222222222222 = i172222222222222222222 | i16;
if (MimeTypes.isAudio(str2)) {
}
TrackOutput track2222222222222222222 = extractorOutput.track(this.number, i15);
this.output = track2222222222222222222;
track2222222222222222222.format(createImageSampleFormat);
return;
case 24:
i12 = -1;
i13 = -1;
str2 = "application/x-subrip";
list4 = null;
int i1722222222222222222222 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
}
int i1822222222222222222222 = i1722222222222222222222 | i16;
if (MimeTypes.isAudio(str2)) {
}
TrackOutput track22222222222222222222 = extractorOutput.track(this.number, i15);
this.output = track22222222222222222222;
track22222222222222222222.format(createImageSampleFormat);
return;
case 25:
str2 = "video/mpeg2";
i12 = -1;
i13 = -1;
list4 = null;
int i17222222222222222222222 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
}
int i18222222222222222222222 = i17222222222222222222222 | i16;
if (MimeTypes.isAudio(str2)) {
}
TrackOutput track222222222222222222222 = extractorOutput.track(this.number, i15);
this.output = track222222222222222222222;
track222222222222222222222.format(createImageSampleFormat);
return;
case 26:
str2 = "audio/eac3";
i12 = -1;
i13 = -1;
list4 = null;
int i172222222222222222222222 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
}
int i182222222222222222222222 = i172222222222222222222222 | i16;
if (MimeTypes.isAudio(str2)) {
}
TrackOutput track2222222222222222222222 = extractorOutput.track(this.number, i15);
this.output = track2222222222222222222222;
track2222222222222222222222.format(createImageSampleFormat);
return;
case 27:
str2 = "audio/flac";
list3 = Collections.singletonList(this.codecPrivate);
i12 = -1;
i13 = -1;
list4 = list3;
int i1722222222222222222222222 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
}
int i1822222222222222222222222 = i1722222222222222222222222 | i16;
if (MimeTypes.isAudio(str2)) {
}
TrackOutput track22222222222222222222222 = extractorOutput.track(this.number, i15);
this.output = track22222222222222222222222;
track22222222222222222222222.format(createImageSampleFormat);
return;
case 28:
ArrayList arrayList2 = new ArrayList(3);
arrayList2.add(this.codecPrivate);
arrayList2.add(ByteBuffer.allocate(8).order(ByteOrder.nativeOrder()).putLong(this.codecDelayNs).array());
arrayList2.add(ByteBuffer.allocate(8).order(ByteOrder.nativeOrder()).putLong(this.seekPreRollNs).array());
str2 = "audio/opus";
i11 = MatroskaExtractor.OPUS_MAX_INPUT_SIZE;
list5 = arrayList2;
i12 = -1;
i13 = i11;
list4 = list5;
int i17222222222222222222222222 = (this.flagDefault ? 1 : 0) | 0;
if (this.flagForced) {
}
int i18222222222222222222222222 = i17222222222222222222222222 | i16;
if (MimeTypes.isAudio(str2)) {
}
TrackOutput track222222222222222222222222 = extractorOutput.track(this.number, i15);
this.output = track222222222222222222222222;
track222222222222222222222222.format(createImageSampleFormat);
return;
default:
throw new ParserException("Unrecognized codec identifier.");
}
}
public final void outputPendingSampleMetadata() {
TrueHdSampleRechunker trueHdSampleRechunker = this.trueHdSampleRechunker;
if (trueHdSampleRechunker != null) {
trueHdSampleRechunker.outputPendingSampleMetadata(this);
}
}
public final void reset() {
TrueHdSampleRechunker trueHdSampleRechunker = this.trueHdSampleRechunker;
if (trueHdSampleRechunker != null) {
trueHdSampleRechunker.reset();
}
}
}
public static final class TrueHdSampleRechunker {
private int blockFlags;
private int chunkSize;
private boolean foundSyncframe;
private int sampleCount;
private final byte[] syncframePrefix = new byte[10];
private long timeUs;
public final void outputPendingSampleMetadata(Track track) {
if (this.foundSyncframe && this.sampleCount > 0) {
track.output.sampleMetadata(this.timeUs, this.blockFlags, this.chunkSize, 0, track.cryptoData);
this.sampleCount = 0;
}
}
public final void reset() {
this.foundSyncframe = false;
}
public final void sampleMetadata(Track track, long j10) {
if (!this.foundSyncframe) {
return;
}
int i10 = this.sampleCount;
int i11 = i10 + 1;
this.sampleCount = i11;
if (i10 == 0) {
this.timeUs = j10;
}
if (i11 < 16) {
return;
}
track.output.sampleMetadata(this.timeUs, this.blockFlags, this.chunkSize, 0, track.cryptoData);
this.sampleCount = 0;
}
public final void startSample(ExtractorInput extractorInput, int i10, int i11) throws IOException, InterruptedException {
if (!this.foundSyncframe) {
extractorInput.peekFully(this.syncframePrefix, 0, 10);
extractorInput.resetPeekPosition();
if (Ac3Util.parseTrueHdSyncframeAudioSampleCount(this.syncframePrefix) == -1) {
return;
}
this.foundSyncframe = true;
this.sampleCount = 0;
}
if (this.sampleCount == 0) {
this.blockFlags = i10;
this.chunkSize = 0;
}
this.chunkSize += i11;
}
}
public MatroskaExtractor() {
this(0);
}
private SeekMap buildSeekMap() {
LongArray longArray;
LongArray longArray2;
if (this.segmentContentPosition != -1 && this.durationUs != -9223372036854775807L && (longArray = this.cueTimesUs) != null && longArray.size() != 0 && (longArray2 = this.cueClusterPositions) != null && longArray2.size() == this.cueTimesUs.size()) {
int size = this.cueTimesUs.size();
int[] iArr = new int[size];
long[] jArr = new long[size];
long[] jArr2 = new long[size];
long[] jArr3 = new long[size];
int i10 = 0;
for (int i11 = 0; i11 < size; i11++) {
jArr3[i11] = this.cueTimesUs.get(i11);
jArr[i11] = this.cueClusterPositions.get(i11) + this.segmentContentPosition;
}
while (true) {
int i12 = size - 1;
if (i10 < i12) {
int i13 = i10 + 1;
iArr[i10] = (int) (jArr[i13] - jArr[i10]);
jArr2[i10] = jArr3[i13] - jArr3[i10];
i10 = i13;
} else {
iArr[i12] = (int) ((this.segmentContentPosition + this.segmentContentSize) - jArr[i12]);
jArr2[i12] = this.durationUs - jArr3[i12];
this.cueTimesUs = null;
this.cueClusterPositions = null;
return new ChunkIndex(iArr, jArr, jArr2, jArr3);
}
}
} else {
this.cueTimesUs = null;
this.cueClusterPositions = null;
return new SeekMap.Unseekable(this.durationUs);
}
}
private void commitSampleToOutput(Track track, long j10) {
TrueHdSampleRechunker trueHdSampleRechunker = track.trueHdSampleRechunker;
if (trueHdSampleRechunker != null) {
trueHdSampleRechunker.sampleMetadata(track, j10);
} else {
if (CODEC_ID_SUBRIP.equals(track.codecId)) {
commitSubtitleSample(track, SUBRIP_TIMECODE_FORMAT, 19, 1000L, SUBRIP_TIMECODE_EMPTY);
} else if (CODEC_ID_ASS.equals(track.codecId)) {
commitSubtitleSample(track, SSA_TIMECODE_FORMAT, 21, 10000L, SSA_TIMECODE_EMPTY);
}
track.output.sampleMetadata(j10, this.blockFlags, this.sampleBytesWritten, 0, track.cryptoData);
}
this.sampleRead = true;
resetSample();
}
private void commitSubtitleSample(Track track, String str, int i10, long j10, byte[] bArr) {
setSampleDuration(this.subtitleSample.data, this.blockDurationUs, str, i10, j10, bArr);
TrackOutput trackOutput = track.output;
ParsableByteArray parsableByteArray = this.subtitleSample;
trackOutput.sampleData(parsableByteArray, parsableByteArray.limit());
this.sampleBytesWritten = this.subtitleSample.limit() + this.sampleBytesWritten;
}
private static int[] ensureArrayCapacity(int[] iArr, int i10) {
if (iArr == null) {
return new int[i10];
}
if (iArr.length >= i10) {
return iArr;
}
return new int[Math.max(iArr.length * 2, i10)];
}
private static boolean isCodecSupported(String str) {
if (!CODEC_ID_VP8.equals(str) && !CODEC_ID_VP9.equals(str) && !CODEC_ID_MPEG2.equals(str) && !CODEC_ID_MPEG4_SP.equals(str) && !CODEC_ID_MPEG4_ASP.equals(str) && !CODEC_ID_MPEG4_AP.equals(str) && !CODEC_ID_H264.equals(str) && !CODEC_ID_H265.equals(str) && !CODEC_ID_FOURCC.equals(str) && !CODEC_ID_THEORA.equals(str) && !CODEC_ID_OPUS.equals(str) && !CODEC_ID_VORBIS.equals(str) && !CODEC_ID_AAC.equals(str) && !CODEC_ID_MP2.equals(str) && !CODEC_ID_MP3.equals(str) && !CODEC_ID_AC3.equals(str) && !CODEC_ID_E_AC3.equals(str) && !CODEC_ID_TRUEHD.equals(str) && !CODEC_ID_DTS.equals(str) && !CODEC_ID_DTS_EXPRESS.equals(str) && !CODEC_ID_DTS_LOSSLESS.equals(str) && !CODEC_ID_FLAC.equals(str) && !CODEC_ID_ACM.equals(str) && !CODEC_ID_PCM_INT_LIT.equals(str) && !CODEC_ID_SUBRIP.equals(str) && !CODEC_ID_ASS.equals(str) && !CODEC_ID_VOBSUB.equals(str) && !CODEC_ID_PGS.equals(str) && !CODEC_ID_DVBSUB.equals(str)) {
return false;
}
return true;
}
private boolean maybeSeekForCues(PositionHolder positionHolder, long j10) {
if (this.seekForCues) {
this.seekPositionAfterBuildingCues = j10;
positionHolder.position = this.cuesContentPosition;
this.seekForCues = false;
return true;
}
if (this.sentSeekMap) {
long j11 = this.seekPositionAfterBuildingCues;
if (j11 != -1) {
positionHolder.position = j11;
this.seekPositionAfterBuildingCues = -1L;
return true;
}
}
return false;
}
private void readScratch(ExtractorInput extractorInput, int i10) throws IOException, InterruptedException {
if (this.scratch.limit() >= i10) {
return;
}
if (this.scratch.capacity() < i10) {
ParsableByteArray parsableByteArray = this.scratch;
byte[] bArr = parsableByteArray.data;
parsableByteArray.reset(Arrays.copyOf(bArr, Math.max(bArr.length * 2, i10)), this.scratch.limit());
}
ParsableByteArray parsableByteArray2 = this.scratch;
extractorInput.readFully(parsableByteArray2.data, parsableByteArray2.limit(), i10 - this.scratch.limit());
this.scratch.setLimit(i10);
}
private int readToOutput(ExtractorInput extractorInput, TrackOutput trackOutput, int i10) throws IOException, InterruptedException {
int sampleData;
int bytesLeft = this.sampleStrippedBytes.bytesLeft();
if (bytesLeft > 0) {
sampleData = Math.min(i10, bytesLeft);
trackOutput.sampleData(this.sampleStrippedBytes, sampleData);
} else {
sampleData = trackOutput.sampleData(extractorInput, i10, false);
}
this.sampleBytesRead += sampleData;
this.sampleBytesWritten += sampleData;
return sampleData;
}
private void readToTarget(ExtractorInput extractorInput, byte[] bArr, int i10, int i11) throws IOException, InterruptedException {
int min = Math.min(i11, this.sampleStrippedBytes.bytesLeft());
extractorInput.readFully(bArr, i10 + min, i11 - min);
if (min > 0) {
this.sampleStrippedBytes.readBytes(bArr, i10, min);
}
this.sampleBytesRead += i11;
}
private void resetSample() {
this.sampleBytesRead = 0;
this.sampleBytesWritten = 0;
this.sampleCurrentNalBytesRemaining = 0;
this.sampleEncodingHandled = false;
this.sampleSignalByteRead = false;
this.samplePartitionCountRead = false;
this.samplePartitionCount = 0;
this.sampleSignalByte = (byte) 0;
this.sampleInitializationVectorRead = false;
this.sampleStrippedBytes.reset();
}
private long scaleTimecodeToUs(long j10) throws ParserException {
long j11 = this.timecodeScale;
if (j11 != -9223372036854775807L) {
return Util.scaleLargeTimestamp(j10, j11, 1000L);
}
throw new ParserException("Can't scale timecode prior to timecodeScale being set.");
}
private static void setSampleDuration(byte[] bArr, long j10, String str, int i10, long j11, byte[] bArr2) {
byte[] utf8Bytes;
if (j10 == -9223372036854775807L) {
utf8Bytes = bArr2;
} else {
int i11 = (int) (j10 / 3600000000L);
long j12 = j10 - ((i11 * 3600) * 1000000);
int i12 = (int) (j12 / 60000000);
long j13 = j12 - ((i12 * 60) * 1000000);
int i13 = (int) (j13 / 1000000);
utf8Bytes = Util.getUtf8Bytes(String.format(Locale.US, str, Integer.valueOf(i11), Integer.valueOf(i12), Integer.valueOf(i13), Integer.valueOf((int) ((j13 - (i13 * 1000000)) / j11))));
}
System.arraycopy(utf8Bytes, 0, bArr, i10, bArr2.length);
}
private void writeSampleData(ExtractorInput extractorInput, Track track, int i10) throws IOException, InterruptedException {
boolean z10;
boolean z11;
int i11;
if (CODEC_ID_SUBRIP.equals(track.codecId)) {
writeSubtitleSampleData(extractorInput, SUBRIP_PREFIX, i10);
return;
}
if (CODEC_ID_ASS.equals(track.codecId)) {
writeSubtitleSampleData(extractorInput, SSA_PREFIX, i10);
return;
}
TrackOutput trackOutput = track.output;
boolean z12 = true;
if (!this.sampleEncodingHandled) {
if (track.hasContentEncryption) {
this.blockFlags &= -1073741825;
int i12 = 128;
if (!this.sampleSignalByteRead) {
extractorInput.readFully(this.scratch.data, 0, 1);
this.sampleBytesRead++;
byte b10 = this.scratch.data[0];
if ((b10 & 128) != 128) {
this.sampleSignalByte = b10;
this.sampleSignalByteRead = true;
} else {
throw new ParserException("Extension bit is set in signal byte");
}
}
byte b11 = this.sampleSignalByte;
if ((b11 & 1) == 1) {
z10 = true;
} else {
z10 = false;
}
if (z10) {
if ((b11 & 2) == 2) {
z11 = true;
} else {
z11 = false;
}
this.blockFlags |= 1073741824;
if (!this.sampleInitializationVectorRead) {
extractorInput.readFully(this.encryptionInitializationVector.data, 0, 8);
this.sampleBytesRead += 8;
this.sampleInitializationVectorRead = true;
ParsableByteArray parsableByteArray = this.scratch;
byte[] bArr = parsableByteArray.data;
if (!z11) {
i12 = 0;
}
bArr[0] = (byte) (i12 | 8);
parsableByteArray.setPosition(0);
trackOutput.sampleData(this.scratch, 1);
this.sampleBytesWritten++;
this.encryptionInitializationVector.setPosition(0);
trackOutput.sampleData(this.encryptionInitializationVector, 8);
this.sampleBytesWritten += 8;
}
if (z11) {
if (!this.samplePartitionCountRead) {
extractorInput.readFully(this.scratch.data, 0, 1);
this.sampleBytesRead++;
this.scratch.setPosition(0);
this.samplePartitionCount = this.scratch.readUnsignedByte();
this.samplePartitionCountRead = true;
}
int i13 = this.samplePartitionCount * 4;
this.scratch.reset(i13);
extractorInput.readFully(this.scratch.data, 0, i13);
this.sampleBytesRead += i13;
short s10 = (short) ((this.samplePartitionCount / 2) + 1);
int i14 = (s10 * 6) + 2;
ByteBuffer byteBuffer = this.encryptionSubsampleDataBuffer;
if (byteBuffer == null || byteBuffer.capacity() < i14) {
this.encryptionSubsampleDataBuffer = ByteBuffer.allocate(i14);
}
this.encryptionSubsampleDataBuffer.position(0);
this.encryptionSubsampleDataBuffer.putShort(s10);
int i15 = 0;
int i16 = 0;
while (true) {
i11 = this.samplePartitionCount;
if (i15 >= i11) {
break;
}
int readUnsignedIntToInt = this.scratch.readUnsignedIntToInt();
if (i15 % 2 == 0) {
this.encryptionSubsampleDataBuffer.putShort((short) (readUnsignedIntToInt - i16));
} else {
this.encryptionSubsampleDataBuffer.putInt(readUnsignedIntToInt - i16);
}
i15++;
i16 = readUnsignedIntToInt;
}
int i17 = (i10 - this.sampleBytesRead) - i16;
if (i11 % 2 == 1) {
this.encryptionSubsampleDataBuffer.putInt(i17);
} else {
this.encryptionSubsampleDataBuffer.putShort((short) i17);
this.encryptionSubsampleDataBuffer.putInt(0);
}
this.encryptionSubsampleData.reset(this.encryptionSubsampleDataBuffer.array(), i14);
trackOutput.sampleData(this.encryptionSubsampleData, i14);
this.sampleBytesWritten += i14;
}
}
} else {
byte[] bArr2 = track.sampleStrippedBytes;
if (bArr2 != null) {
this.sampleStrippedBytes.reset(bArr2, bArr2.length);
}
}
this.sampleEncodingHandled = true;
}
int limit = this.sampleStrippedBytes.limit() + i10;
if (!CODEC_ID_H264.equals(track.codecId) && !CODEC_ID_H265.equals(track.codecId)) {
if (track.trueHdSampleRechunker != null) {
if (this.sampleStrippedBytes.limit() != 0) {
z12 = false;
}
Assertions.checkState(z12);
track.trueHdSampleRechunker.startSample(extractorInput, this.blockFlags, limit);
}
while (true) {
int i18 = this.sampleBytesRead;
if (i18 >= limit) {
break;
} else {
readToOutput(extractorInput, trackOutput, limit - i18);
}
}
} else {
byte[] bArr3 = this.nalLength.data;
bArr3[0] = 0;
bArr3[1] = 0;
bArr3[2] = 0;
int i19 = track.nalUnitLengthFieldLength;
int i20 = 4 - i19;
while (this.sampleBytesRead < limit) {
int i21 = this.sampleCurrentNalBytesRemaining;
if (i21 == 0) {
readToTarget(extractorInput, bArr3, i20, i19);
this.nalLength.setPosition(0);
this.sampleCurrentNalBytesRemaining = this.nalLength.readUnsignedIntToInt();
this.nalStartCode.setPosition(0);
trackOutput.sampleData(this.nalStartCode, 4);
this.sampleBytesWritten += 4;
} else {
this.sampleCurrentNalBytesRemaining = i21 - readToOutput(extractorInput, trackOutput, i21);
}
}
}
if (CODEC_ID_VORBIS.equals(track.codecId)) {
this.vorbisNumPageSamples.setPosition(0);
trackOutput.sampleData(this.vorbisNumPageSamples, 4);
this.sampleBytesWritten += 4;
}
}
private void writeSubtitleSampleData(ExtractorInput extractorInput, byte[] bArr, int i10) throws IOException, InterruptedException {
int length = bArr.length + i10;
if (this.subtitleSample.capacity() < length) {
this.subtitleSample.data = Arrays.copyOf(bArr, length + i10);
} else {
System.arraycopy(bArr, 0, this.subtitleSample.data, 0, bArr.length);
}
extractorInput.readFully(this.subtitleSample.data, bArr.length, i10);
this.subtitleSample.reset(length);
}
public final void binaryElement(int i10, int i11, ExtractorInput extractorInput) throws IOException, InterruptedException {
long j10;
int i12;
int i13;
int i14;
boolean z10;
int i15;
int i16;
int i17 = 163;
int i18 = 0;
char c10 = 1;
if (i10 != 161 && i10 != 163) {
if (i10 != ID_CONTENT_COMPRESSION_SETTINGS) {
if (i10 != ID_CONTENT_ENCRYPTION_KEY_ID) {
if (i10 != ID_SEEK_ID) {
if (i10 != ID_CODEC_PRIVATE) {
if (i10 == ID_PROJECTION_PRIVATE) {
byte[] bArr = new byte[i11];
this.currentTrack.projectionData = bArr;
extractorInput.readFully(bArr, 0, i11);
return;
}
throw new ParserException(c.a("Unexpected id: ", i10));
}
byte[] bArr2 = new byte[i11];
this.currentTrack.codecPrivate = bArr2;
extractorInput.readFully(bArr2, 0, i11);
return;
}
Arrays.fill(this.seekEntryIdBytes.data, (byte) 0);
extractorInput.readFully(this.seekEntryIdBytes.data, 4 - i11, i11);
this.seekEntryIdBytes.setPosition(0);
this.seekEntryId = (int) this.seekEntryIdBytes.readUnsignedInt();
return;
}
byte[] bArr3 = new byte[i11];
extractorInput.readFully(bArr3, 0, i11);
this.currentTrack.cryptoData = new TrackOutput.CryptoData(1, bArr3, 0, 0);
return;
}
byte[] bArr4 = new byte[i11];
this.currentTrack.sampleStrippedBytes = bArr4;
extractorInput.readFully(bArr4, 0, i11);
return;
}
if (this.blockState == 0) {
this.blockTrackNumber = (int) this.varintReader.readUnsignedVarint(extractorInput, false, true, 8);
this.blockTrackNumberLength = this.varintReader.getLastLength();
this.blockDurationUs = -9223372036854775807L;
this.blockState = 1;
this.scratch.reset();
}
Track track = this.tracks.get(this.blockTrackNumber);
if (track == null) {
extractorInput.skipFully(i11 - this.blockTrackNumberLength);
this.blockState = 0;
return;
}
if (this.blockState == 1) {
readScratch(extractorInput, 3);
int i19 = (this.scratch.data[2] & 6) >> 1;
byte b10 = 255;
if (i19 == 0) {
this.blockLacingSampleCount = 1;
int[] ensureArrayCapacity = ensureArrayCapacity(this.blockLacingSampleSizes, 1);
this.blockLacingSampleSizes = ensureArrayCapacity;
ensureArrayCapacity[0] = (i11 - this.blockTrackNumberLength) - 3;
} else if (i10 == 163) {
int i20 = 4;
readScratch(extractorInput, 4);
int i21 = (this.scratch.data[3] & 255) + 1;
this.blockLacingSampleCount = i21;
int[] ensureArrayCapacity2 = ensureArrayCapacity(this.blockLacingSampleSizes, i21);
this.blockLacingSampleSizes = ensureArrayCapacity2;
if (i19 == 2) {
int i22 = (i11 - this.blockTrackNumberLength) - 4;
int i23 = this.blockLacingSampleCount;
Arrays.fill(ensureArrayCapacity2, 0, i23, i22 / i23);
} else if (i19 == 1) {
int i24 = 0;
int i25 = 0;
while (true) {
i12 = this.blockLacingSampleCount;
if (i24 >= i12 - 1) {
break;
}
this.blockLacingSampleSizes[i24] = 0;
do {
i20++;
readScratch(extractorInput, i20);
i13 = this.scratch.data[i20 - 1] & 255;
int[] iArr = this.blockLacingSampleSizes;
i14 = iArr[i24] + i13;
iArr[i24] = i14;
} while (i13 == 255);
i25 += i14;
i24++;
}
this.blockLacingSampleSizes[i12 - 1] = ((i11 - this.blockTrackNumberLength) - i20) - i25;
} else {
if (i19 == 3) {
int i26 = 0;
int i27 = 1;
int i28 = 0;
while (true) {
int i29 = this.blockLacingSampleCount;
if (i18 < i29 - 1) {
this.blockLacingSampleSizes[i18] = i26;
i20++;
readScratch(extractorInput, i20);
int i30 = i20 - 1;
if (this.scratch.data[i30] != 0) {
while (true) {
if (i26 < 8) {
int i31 = i27 << (7 - i26);
if ((this.scratch.data[i30] & i31) != 0) {
i20 += i26;
readScratch(extractorInput, i20);
j10 = (~i31) & this.scratch.data[i30] & b10;
for (int i32 = i30 + 1; i32 < i20; i32++) {
j10 = (j10 << 8) | (b10 & this.scratch.data[i32]);
b10 = 255;
}
if (i18 > 0) {
j10 -= (1 << ((i26 * 7) + 6)) - 1;
}
} else {
i26++;
i27 = 1;
b10 = 255;
}
} else {
j10 = 0;
break;
}
}
if (j10 < -2147483648L || j10 > 2147483647L) {
break;
}
int i33 = (int) j10;
int[] iArr2 = this.blockLacingSampleSizes;
if (i18 != 0) {
i33 += iArr2[i18 - 1];
}
iArr2[i18] = i33;
i28 += i33;
i18++;
i26 = 0;
i27 = 1;
b10 = 255;
} else {
throw new ParserException("No valid varint length mask found");
}
} else {
this.blockLacingSampleSizes[i29 - 1] = ((i11 - this.blockTrackNumberLength) - i20) - i28;
c10 = 1;
break;
}
}
throw new ParserException("EBML lacing sample size out of range.");
}
throw new ParserException(c.a("Unexpected lacing value: ", i19));
}
} else {
throw new ParserException("Lacing only supported in SimpleBlocks.");
}
byte[] bArr5 = this.scratch.data;
this.blockTimeUs = this.clusterTimecodeUs + scaleTimecodeToUs((bArr5[c10] & 255) | (bArr5[0] << 8));
byte b11 = this.scratch.data[2];
if ((b11 & 8) == 8) {
z10 = true;
} else {
z10 = false;
}
if (track.type != 2 && (i10 != 163 || (b11 & 128) != 128)) {
i15 = 0;
} else {
i15 = 1;
}
if (z10) {
i16 = Integer.MIN_VALUE;
} else {
i16 = 0;
}
this.blockFlags = i15 | i16;
this.blockState = 2;
this.blockLacingSampleIndex = 0;
i17 = 163;
}
if (i10 != i17) {
writeSampleData(extractorInput, track, this.blockLacingSampleSizes[0]);
return;
}
while (true) {
int i34 = this.blockLacingSampleIndex;
if (i34 < this.blockLacingSampleCount) {
writeSampleData(extractorInput, track, this.blockLacingSampleSizes[i34]);
commitSampleToOutput(track, this.blockTimeUs + ((this.blockLacingSampleIndex * track.defaultSampleDurationNs) / 1000));
this.blockLacingSampleIndex++;
} else {
this.blockState = 0;
return;
}
}
}
public final void endMasterElement(int i10) throws ParserException {
if (i10 != 160) {
if (i10 != 174) {
if (i10 != ID_SEEK) {
if (i10 != ID_CONTENT_ENCODING) {
if (i10 != ID_CONTENT_ENCODINGS) {
if (i10 != 357149030) {
if (i10 != ID_TRACKS) {
if (i10 == ID_CUES && !this.sentSeekMap) {
this.extractorOutput.seekMap(buildSeekMap());
this.sentSeekMap = true;
return;
}
return;
}
if (this.tracks.size() != 0) {
this.extractorOutput.endTracks();
return;
}
throw new ParserException("No valid tracks were found");
}
if (this.timecodeScale == -9223372036854775807L) {
this.timecodeScale = 1000000L;
}
long j10 = this.durationTimecode;
if (j10 != -9223372036854775807L) {
this.durationUs = scaleTimecodeToUs(j10);
return;
}
return;
}
Track track = this.currentTrack;
if (track.hasContentEncryption && track.sampleStrippedBytes != null) {
throw new ParserException("Combining encryption and compression is not supported");
}
return;
}
Track track2 = this.currentTrack;
if (track2.hasContentEncryption) {
if (track2.cryptoData != null) {
track2.drmInitData = new DrmInitData(new DrmInitData.SchemeData(C.UUID_NIL, "video/webm", this.currentTrack.cryptoData.encryptionKey));
return;
}
throw new ParserException("Encrypted Track found but ContentEncKeyID was not found");
}
return;
}
int i11 = this.seekEntryId;
if (i11 != -1) {
long j11 = this.seekEntryPosition;
if (j11 != -1) {
if (i11 == ID_CUES) {
this.cuesContentPosition = j11;
return;
}
return;
}
}
throw new ParserException("Mandatory element SeekID or SeekPosition not found");
}
if (isCodecSupported(this.currentTrack.codecId)) {
Track track3 = this.currentTrack;
track3.initializeOutput(this.extractorOutput, track3.number);
SparseArray<Track> sparseArray = this.tracks;
Track track4 = this.currentTrack;
sparseArray.put(track4.number, track4);
}
this.currentTrack = null;
return;
}
if (this.blockState != 2) {
return;
}
if (!this.sampleSeenReferenceBlock) {
this.blockFlags |= 1;
}
commitSampleToOutput(this.tracks.get(this.blockTrackNumber), this.blockTimeUs);
this.blockState = 0;
}
public final void floatElement(int i10, double d10) {
if (i10 != 181) {
if (i10 != ID_DURATION) {
switch (i10) {
case ID_PRIMARY_R_CHROMATICITY_X:
this.currentTrack.primaryRChromaticityX = (float) d10;
return;
case ID_PRIMARY_R_CHROMATICITY_Y:
this.currentTrack.primaryRChromaticityY = (float) d10;
return;
case ID_PRIMARY_G_CHROMATICITY_X:
this.currentTrack.primaryGChromaticityX = (float) d10;
return;
case ID_PRIMARY_G_CHROMATICITY_Y:
this.currentTrack.primaryGChromaticityY = (float) d10;
return;
case ID_PRIMARY_B_CHROMATICITY_X:
this.currentTrack.primaryBChromaticityX = (float) d10;
return;
case ID_PRIMARY_B_CHROMATICITY_Y:
this.currentTrack.primaryBChromaticityY = (float) d10;
return;
case ID_WHITE_POINT_CHROMATICITY_X:
this.currentTrack.whitePointChromaticityX = (float) d10;
return;
case ID_WHITE_POINT_CHROMATICITY_Y:
this.currentTrack.whitePointChromaticityY = (float) d10;
return;
case ID_LUMNINANCE_MAX:
this.currentTrack.maxMasteringLuminance = (float) d10;
return;
case ID_LUMNINANCE_MIN:
this.currentTrack.minMasteringLuminance = (float) d10;
return;
default:
return;
}
}
this.durationTimecode = (long) d10;
return;
}
this.currentTrack.sampleRate = (int) d10;
}
@Override
public final void init(ExtractorOutput extractorOutput) {
this.extractorOutput = extractorOutput;
}
public final void integerElement(int i10, long j10) throws ParserException {
if (i10 != ID_CONTENT_ENCODING_ORDER) {
if (i10 != ID_CONTENT_ENCODING_SCOPE) {
boolean z10 = false;
switch (i10) {
case 131:
this.currentTrack.type = (int) j10;
return;
case 136:
Track track = this.currentTrack;
if (j10 == 1) {
z10 = true;
}
track.flagDefault = z10;
return;
case 155:
this.blockDurationUs = scaleTimecodeToUs(j10);
return;
case 159:
this.currentTrack.channelCount = (int) j10;
return;
case 176:
this.currentTrack.width = (int) j10;
return;
case 179:
this.cueTimesUs.add(scaleTimecodeToUs(j10));
return;
case 186:
this.currentTrack.height = (int) j10;
return;
case 215:
this.currentTrack.number = (int) j10;
return;
case ID_TIME_CODE:
this.clusterTimecodeUs = scaleTimecodeToUs(j10);
return;
case ID_CUE_CLUSTER_POSITION:
if (!this.seenClusterPositionForCurrentCuePoint) {
this.cueClusterPositions.add(j10);
this.seenClusterPositionForCurrentCuePoint = true;
return;
}
return;
case 251:
this.sampleSeenReferenceBlock = true;
return;
case ID_CONTENT_COMPRESSION_ALGORITHM:
if (j10 != 3) {
throw new ParserException(u.b.a("ContentCompAlgo ", j10, " not supported"));
}
return;
case ID_DOC_TYPE_READ_VERSION:
if (j10 < 1 || j10 > 2) {
throw new ParserException(u.b.a("DocTypeReadVersion ", j10, " not supported"));
}
return;
case ID_EBML_READ_VERSION:
if (j10 != 1) {
throw new ParserException(u.b.a("EBMLReadVersion ", j10, " not supported"));
}
return;
case ID_CONTENT_ENCRYPTION_ALGORITHM:
if (j10 != 5) {
throw new ParserException(u.b.a("ContentEncAlgo ", j10, " not supported"));
}
return;
case ID_CONTENT_ENCRYPTION_AES_SETTINGS_CIPHER_MODE:
if (j10 != 1) {
throw new ParserException(u.b.a("AESSettingsCipherMode ", j10, " not supported"));
}
return;
case ID_SEEK_POSITION:
this.seekEntryPosition = j10 + this.segmentContentPosition;
return;
case ID_STEREO_MODE:
int i11 = (int) j10;
if (i11 != 0) {
if (i11 != 1) {
if (i11 != 3) {
if (i11 == 15) {
this.currentTrack.stereoMode = 3;
return;
}
return;
}
this.currentTrack.stereoMode = 1;
return;
}
this.currentTrack.stereoMode = 2;
return;
}
this.currentTrack.stereoMode = 0;
return;
case ID_DISPLAY_WIDTH:
this.currentTrack.displayWidth = (int) j10;
return;
case ID_DISPLAY_UNIT:
this.currentTrack.displayUnit = (int) j10;
return;
case ID_DISPLAY_HEIGHT:
this.currentTrack.displayHeight = (int) j10;
return;
case ID_FLAG_FORCED:
Track track2 = this.currentTrack;
if (j10 == 1) {
z10 = true;
}
track2.flagForced = z10;
return;
case ID_CODEC_DELAY:
this.currentTrack.codecDelayNs = j10;
return;
case ID_SEEK_PRE_ROLL:
this.currentTrack.seekPreRollNs = j10;
return;
case ID_AUDIO_BIT_DEPTH:
this.currentTrack.audioBitDepth = (int) j10;
return;
case ID_DEFAULT_DURATION:
this.currentTrack.defaultSampleDurationNs = (int) j10;
return;
case ID_TIMECODE_SCALE:
this.timecodeScale = j10;
return;
default:
switch (i10) {
case ID_COLOUR_RANGE:
int i12 = (int) j10;
if (i12 != 1) {
if (i12 == 2) {
this.currentTrack.colorRange = 1;
return;
}
return;
}
this.currentTrack.colorRange = 2;
return;
case ID_COLOUR_TRANSFER:
int i13 = (int) j10;
if (i13 != 1) {
if (i13 != 16) {
if (i13 != 18) {
if (i13 != 6 && i13 != 7) {
return;
}
} else {
this.currentTrack.colorTransfer = 7;
return;
}
} else {
this.currentTrack.colorTransfer = 6;
return;
}
}
this.currentTrack.colorTransfer = 3;
return;
case ID_COLOUR_PRIMARIES:
Track track3 = this.currentTrack;
track3.hasColorInfo = true;
int i14 = (int) j10;
if (i14 != 1) {
if (i14 != 9) {
if (i14 == 4 || i14 == 5 || i14 == 6 || i14 == 7) {
track3.colorSpace = 2;
return;
}
return;
}
track3.colorSpace = 6;
return;
}
track3.colorSpace = 1;
return;
case ID_MAX_CLL:
this.currentTrack.maxContentLuminance = (int) j10;
return;
case ID_MAX_FALL:
this.currentTrack.maxFrameAverageLuminance = (int) j10;
return;
default:
return;
}
}
}
if (j10 != 1) {
throw new ParserException(u.b.a("ContentEncodingScope ", j10, " not supported"));
}
return;
}
if (j10 == 0) {
} else {
throw new ParserException(u.b.a("ContentEncodingOrder ", j10, " not supported"));
}
}
@Override
public final int read(ExtractorInput extractorInput, PositionHolder positionHolder) throws IOException, InterruptedException {
this.sampleRead = false;
boolean z10 = true;
while (z10 && !this.sampleRead) {
z10 = this.reader.read(extractorInput);
if (z10 && maybeSeekForCues(positionHolder, extractorInput.getPosition())) {
return 1;
}
}
if (z10) {
return 0;
}
for (int i10 = 0; i10 < this.tracks.size(); i10++) {
this.tracks.valueAt(i10).outputPendingSampleMetadata();
}
return -1;
}
@Override
public final void seek(long j10, long j11) {
this.clusterTimecodeUs = -9223372036854775807L;
this.blockState = 0;
this.reader.reset();
this.varintReader.reset();
resetSample();
for (int i10 = 0; i10 < this.tracks.size(); i10++) {
this.tracks.valueAt(i10).reset();
}
}
@Override
public final boolean sniff(ExtractorInput extractorInput) throws IOException, InterruptedException {
return new Sniffer().sniff(extractorInput);
}
public final void startMasterElement(int i10, long j10, long j11) throws ParserException {
if (i10 != 160) {
if (i10 != 174) {
if (i10 != 187) {
if (i10 != ID_SEEK) {
if (i10 != ID_CONTENT_ENCRYPTION) {
if (i10 != ID_MASTERING_METADATA) {
if (i10 != ID_SEGMENT) {
if (i10 != ID_CUES) {
if (i10 == ID_CLUSTER && !this.sentSeekMap) {
if (this.seekForCuesEnabled && this.cuesContentPosition != -1) {
this.seekForCues = true;
return;
} else {
this.extractorOutput.seekMap(new SeekMap.Unseekable(this.durationUs));
this.sentSeekMap = true;
return;
}
}
return;
}
this.cueTimesUs = new LongArray();
this.cueClusterPositions = new LongArray();
return;
}
long j12 = this.segmentContentPosition;
if (j12 != -1 && j12 != j10) {
throw new ParserException("Multiple Segment elements not supported");
}
this.segmentContentPosition = j10;
this.segmentContentSize = j11;
return;
}
this.currentTrack.hasColorInfo = true;
return;
}
this.currentTrack.hasContentEncryption = true;
return;
}
this.seekEntryId = -1;
this.seekEntryPosition = -1L;
return;
}
this.seenClusterPositionForCurrentCuePoint = false;
return;
}
this.currentTrack = new Track();
return;
}
this.sampleSeenReferenceBlock = false;
}
public final void stringElement(int i10, String str) throws ParserException {
if (i10 != 134) {
if (i10 != 17026) {
if (i10 == ID_LANGUAGE) {
this.currentTrack.language = str;
return;
}
return;
} else {
if (!DOC_TYPE_WEBM.equals(str) && !DOC_TYPE_MATROSKA.equals(str)) {
throw new ParserException(f.a("DocType ", str, " not supported"));
}
return;
}
}
this.currentTrack.codecId = str;
}
public MatroskaExtractor(int i10) {
this(new DefaultEbmlReader(), i10);
}
public MatroskaExtractor(EbmlReader ebmlReader, int i10) {
this.segmentContentPosition = -1L;
this.timecodeScale = -9223372036854775807L;
this.durationTimecode = -9223372036854775807L;
this.durationUs = -9223372036854775807L;
this.cuesContentPosition = -1L;
this.seekPositionAfterBuildingCues = -1L;
this.clusterTimecodeUs = -9223372036854775807L;
this.reader = ebmlReader;
ebmlReader.init(new InnerEbmlReaderOutput());
this.seekForCuesEnabled = (i10 & 1) == 0;
this.varintReader = new VarintReader();
this.tracks = new SparseArray<>();
this.scratch = new ParsableByteArray(4);
this.vorbisNumPageSamples = new ParsableByteArray(ByteBuffer.allocate(4).putInt(-1).array());
this.seekEntryIdBytes = new ParsableByteArray(4);
this.nalStartCode = new ParsableByteArray(NalUnitUtil.NAL_START_CODE);
this.nalLength = new ParsableByteArray(4);
this.sampleStrippedBytes = new ParsableByteArray();
this.subtitleSample = new ParsableByteArray();
this.encryptionInitializationVector = new ParsableByteArray(8);
this.encryptionSubsampleData = new ParsableByteArray();
}
@Override
public final void release() {
}
}