mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-27 09:32:27 -06:00
63 lines
3.6 KiB
Java
63 lines
3.6 KiB
Java
package androidx.media3.extractor.flac;
|
|
|
|
import androidx.media3.extractor.BinarySearchSeeker;
|
|
import androidx.media3.extractor.ExtractorInput;
|
|
import androidx.media3.extractor.FlacFrameReader;
|
|
import androidx.media3.extractor.FlacStreamMetadata;
|
|
import java.io.IOException;
|
|
import java.util.Objects;
|
|
|
|
/* loaded from: classes2.dex */
|
|
final class FlacBinarySearchSeeker extends BinarySearchSeeker {
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
public FlacBinarySearchSeeker(final FlacStreamMetadata flacStreamMetadata, int i, long j, long j2) {
|
|
super(new BinarySearchSeeker.SeekTimestampConverter() { // from class: androidx.media3.extractor.flac.FlacBinarySearchSeeker$$ExternalSyntheticLambda0
|
|
@Override // androidx.media3.extractor.BinarySearchSeeker.SeekTimestampConverter
|
|
public final long timeUsToTargetTime(long j3) {
|
|
return FlacStreamMetadata.this.getSampleNumber(j3);
|
|
}
|
|
}, new FlacTimestampSeeker(flacStreamMetadata, i), flacStreamMetadata.getDurationUs(), 0L, flacStreamMetadata.totalSamples, j, j2, flacStreamMetadata.getApproxBytesPerFrame(), Math.max(6, flacStreamMetadata.minFrameSize));
|
|
Objects.requireNonNull(flacStreamMetadata);
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
private static final class FlacTimestampSeeker implements BinarySearchSeeker.TimestampSeeker {
|
|
private final FlacStreamMetadata flacStreamMetadata;
|
|
private final int frameStartMarker;
|
|
private final FlacFrameReader.SampleNumberHolder sampleNumberHolder;
|
|
|
|
private FlacTimestampSeeker(FlacStreamMetadata flacStreamMetadata, int i) {
|
|
this.flacStreamMetadata = flacStreamMetadata;
|
|
this.frameStartMarker = i;
|
|
this.sampleNumberHolder = new FlacFrameReader.SampleNumberHolder();
|
|
}
|
|
|
|
@Override // androidx.media3.extractor.BinarySearchSeeker.TimestampSeeker
|
|
public BinarySearchSeeker.TimestampSearchResult searchForTimestamp(ExtractorInput extractorInput, long j) throws IOException {
|
|
long position = extractorInput.getPosition();
|
|
long findNextFrame = findNextFrame(extractorInput);
|
|
long peekPosition = extractorInput.getPeekPosition();
|
|
extractorInput.advancePeekPosition(Math.max(6, this.flacStreamMetadata.minFrameSize));
|
|
long findNextFrame2 = findNextFrame(extractorInput);
|
|
long peekPosition2 = extractorInput.getPeekPosition();
|
|
if (findNextFrame <= j && findNextFrame2 > j) {
|
|
return BinarySearchSeeker.TimestampSearchResult.targetFoundResult(peekPosition);
|
|
}
|
|
if (findNextFrame2 <= j) {
|
|
return BinarySearchSeeker.TimestampSearchResult.underestimatedResult(findNextFrame2, peekPosition2);
|
|
}
|
|
return BinarySearchSeeker.TimestampSearchResult.overestimatedResult(findNextFrame, position);
|
|
}
|
|
|
|
private long findNextFrame(ExtractorInput extractorInput) throws IOException {
|
|
while (extractorInput.getPeekPosition() < extractorInput.getLength() - 6 && !FlacFrameReader.checkFrameHeaderFromPeek(extractorInput, this.flacStreamMetadata, this.frameStartMarker, this.sampleNumberHolder)) {
|
|
extractorInput.advancePeekPosition(1);
|
|
}
|
|
if (extractorInput.getPeekPosition() >= extractorInput.getLength() - 6) {
|
|
extractorInput.advancePeekPosition((int) (extractorInput.getLength() - extractorInput.getPeekPosition()));
|
|
return this.flacStreamMetadata.totalSamples;
|
|
}
|
|
return this.sampleNumberHolder.sampleNumber;
|
|
}
|
|
}
|
|
}
|