mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-27 09:32:27 -06:00
102 lines
4.6 KiB
Java
102 lines
4.6 KiB
Java
package androidx.media3.extractor.ts;
|
|
|
|
import androidx.media3.common.util.ParsableByteArray;
|
|
import androidx.media3.common.util.TimestampAdjuster;
|
|
import androidx.media3.common.util.Util;
|
|
import androidx.media3.extractor.ExtractorOutput;
|
|
import androidx.media3.extractor.ts.TsPayloadReader;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class SectionReader implements TsPayloadReader {
|
|
private static final int DEFAULT_SECTION_BUFFER_LENGTH = 32;
|
|
private static final int MAX_SECTION_LENGTH = 4098;
|
|
private static final int SECTION_HEADER_LENGTH = 3;
|
|
private int bytesRead;
|
|
private final SectionPayloadReader reader;
|
|
private final ParsableByteArray sectionData = new ParsableByteArray(32);
|
|
private boolean sectionSyntaxIndicator;
|
|
private int totalSectionLength;
|
|
private boolean waitingForPayloadStart;
|
|
|
|
@Override // androidx.media3.extractor.ts.TsPayloadReader
|
|
public void seek() {
|
|
this.waitingForPayloadStart = true;
|
|
}
|
|
|
|
public SectionReader(SectionPayloadReader sectionPayloadReader) {
|
|
this.reader = sectionPayloadReader;
|
|
}
|
|
|
|
@Override // androidx.media3.extractor.ts.TsPayloadReader
|
|
public void init(TimestampAdjuster timestampAdjuster, ExtractorOutput extractorOutput, TsPayloadReader.TrackIdGenerator trackIdGenerator) {
|
|
this.reader.init(timestampAdjuster, extractorOutput, trackIdGenerator);
|
|
this.waitingForPayloadStart = true;
|
|
}
|
|
|
|
@Override // androidx.media3.extractor.ts.TsPayloadReader
|
|
public void consume(ParsableByteArray parsableByteArray, int i) {
|
|
boolean z = (i & 1) != 0;
|
|
int position = z ? parsableByteArray.getPosition() + parsableByteArray.readUnsignedByte() : -1;
|
|
if (this.waitingForPayloadStart) {
|
|
if (!z) {
|
|
return;
|
|
}
|
|
this.waitingForPayloadStart = false;
|
|
parsableByteArray.setPosition(position);
|
|
this.bytesRead = 0;
|
|
}
|
|
while (parsableByteArray.bytesLeft() > 0) {
|
|
int i2 = this.bytesRead;
|
|
if (i2 < 3) {
|
|
if (i2 == 0) {
|
|
int readUnsignedByte = parsableByteArray.readUnsignedByte();
|
|
parsableByteArray.setPosition(parsableByteArray.getPosition() - 1);
|
|
if (readUnsignedByte == 255) {
|
|
this.waitingForPayloadStart = true;
|
|
return;
|
|
}
|
|
}
|
|
int min = Math.min(parsableByteArray.bytesLeft(), 3 - this.bytesRead);
|
|
parsableByteArray.readBytes(this.sectionData.getData(), this.bytesRead, min);
|
|
int i3 = this.bytesRead + min;
|
|
this.bytesRead = i3;
|
|
if (i3 == 3) {
|
|
this.sectionData.setPosition(0);
|
|
this.sectionData.setLimit(3);
|
|
this.sectionData.skipBytes(1);
|
|
int readUnsignedByte2 = this.sectionData.readUnsignedByte();
|
|
int readUnsignedByte3 = this.sectionData.readUnsignedByte();
|
|
this.sectionSyntaxIndicator = (readUnsignedByte2 & 128) != 0;
|
|
this.totalSectionLength = (((readUnsignedByte2 & 15) << 8) | readUnsignedByte3) + 3;
|
|
int capacity = this.sectionData.capacity();
|
|
int i4 = this.totalSectionLength;
|
|
if (capacity < i4) {
|
|
this.sectionData.ensureCapacity(Math.min(4098, Math.max(i4, this.sectionData.capacity() * 2)));
|
|
}
|
|
}
|
|
} else {
|
|
int min2 = Math.min(parsableByteArray.bytesLeft(), this.totalSectionLength - this.bytesRead);
|
|
parsableByteArray.readBytes(this.sectionData.getData(), this.bytesRead, min2);
|
|
int i5 = this.bytesRead + min2;
|
|
this.bytesRead = i5;
|
|
int i6 = this.totalSectionLength;
|
|
if (i5 != i6) {
|
|
continue;
|
|
} else {
|
|
if (this.sectionSyntaxIndicator) {
|
|
if (Util.crc32(this.sectionData.getData(), 0, this.totalSectionLength, -1) != 0) {
|
|
this.waitingForPayloadStart = true;
|
|
return;
|
|
}
|
|
this.sectionData.setLimit(this.totalSectionLength - 4);
|
|
} else {
|
|
this.sectionData.setLimit(i6);
|
|
}
|
|
this.sectionData.setPosition(0);
|
|
this.reader.consume(this.sectionData);
|
|
this.bytesRead = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|