Rabbit-R1/android (non root)/java/sources/androidx/media3/extractor/TrueHdSampleRechunker.java

60 lines
2 KiB
Java
Raw Normal View History

2024-05-21 16:08:36 -05:00
package androidx.media3.extractor;
import androidx.media3.common.util.Assertions;
import androidx.media3.extractor.TrackOutput;
import java.io.IOException;
/* loaded from: classes2.dex */
public final class TrueHdSampleRechunker {
private int chunkFlags;
private int chunkOffset;
private int chunkSampleCount;
private int chunkSize;
private long chunkTimeUs;
private boolean foundSyncframe;
private final byte[] syncframePrefix = new byte[10];
public void reset() {
this.foundSyncframe = false;
this.chunkSampleCount = 0;
}
public void startSample(ExtractorInput extractorInput) throws IOException {
if (this.foundSyncframe) {
return;
}
extractorInput.peekFully(this.syncframePrefix, 0, 10);
extractorInput.resetPeekPosition();
if (Ac3Util.parseTrueHdSyncframeAudioSampleCount(this.syncframePrefix) == 0) {
return;
}
this.foundSyncframe = true;
}
public void sampleMetadata(TrackOutput trackOutput, long j, int i, int i2, int i3, TrackOutput.CryptoData cryptoData) {
Assertions.checkState(this.chunkOffset <= i2 + i3, "TrueHD chunk samples must be contiguous in the sample queue.");
if (this.foundSyncframe) {
int i4 = this.chunkSampleCount;
int i5 = i4 + 1;
this.chunkSampleCount = i5;
if (i4 == 0) {
this.chunkTimeUs = j;
this.chunkFlags = i;
this.chunkSize = 0;
}
this.chunkSize += i2;
this.chunkOffset = i3;
if (i5 >= 16) {
outputPendingSampleMetadata(trackOutput, cryptoData);
}
}
}
public void outputPendingSampleMetadata(TrackOutput trackOutput, TrackOutput.CryptoData cryptoData) {
if (this.chunkSampleCount > 0) {
trackOutput.sampleMetadata(this.chunkTimeUs, this.chunkFlags, this.chunkSize, this.chunkOffset, cryptoData);
this.chunkSampleCount = 0;
}
}
}