mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-30 11:02:31 -06:00
104 lines
3.9 KiB
Java
104 lines
3.9 KiB
Java
|
package androidx.media3.extractor.mp3;
|
||
|
|
||
|
import androidx.media3.common.util.Log;
|
||
|
import androidx.media3.common.util.ParsableByteArray;
|
||
|
import androidx.media3.common.util.Util;
|
||
|
import androidx.media3.extractor.MpegAudioUtil;
|
||
|
import androidx.media3.extractor.SeekMap;
|
||
|
import androidx.media3.extractor.SeekPoint;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
final class VbriSeeker implements Seeker {
|
||
|
private static final String TAG = "VbriSeeker";
|
||
|
private final long dataEndPosition;
|
||
|
private final long durationUs;
|
||
|
private final long[] positions;
|
||
|
private final long[] timesUs;
|
||
|
|
||
|
@Override // androidx.media3.extractor.mp3.Seeker
|
||
|
public long getDataEndPosition() {
|
||
|
return this.dataEndPosition;
|
||
|
}
|
||
|
|
||
|
@Override // androidx.media3.extractor.SeekMap
|
||
|
public long getDurationUs() {
|
||
|
return this.durationUs;
|
||
|
}
|
||
|
|
||
|
@Override // androidx.media3.extractor.SeekMap
|
||
|
public boolean isSeekable() {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public static VbriSeeker create(long j, long j2, MpegAudioUtil.Header header, ParsableByteArray parsableByteArray) {
|
||
|
int readUnsignedByte;
|
||
|
parsableByteArray.skipBytes(10);
|
||
|
int readInt = parsableByteArray.readInt();
|
||
|
if (readInt <= 0) {
|
||
|
return null;
|
||
|
}
|
||
|
int i = header.sampleRate;
|
||
|
long scaleLargeTimestamp = Util.scaleLargeTimestamp(readInt, (i >= 32000 ? 1152 : 576) * 1000000, i);
|
||
|
int readUnsignedShort = parsableByteArray.readUnsignedShort();
|
||
|
int readUnsignedShort2 = parsableByteArray.readUnsignedShort();
|
||
|
int readUnsignedShort3 = parsableByteArray.readUnsignedShort();
|
||
|
parsableByteArray.skipBytes(2);
|
||
|
long j3 = j2 + header.frameSize;
|
||
|
long[] jArr = new long[readUnsignedShort];
|
||
|
long[] jArr2 = new long[readUnsignedShort];
|
||
|
int i2 = 0;
|
||
|
long j4 = j2;
|
||
|
while (i2 < readUnsignedShort) {
|
||
|
int i3 = readUnsignedShort2;
|
||
|
long j5 = j3;
|
||
|
jArr[i2] = (i2 * scaleLargeTimestamp) / readUnsignedShort;
|
||
|
jArr2[i2] = Math.max(j4, j5);
|
||
|
if (readUnsignedShort3 == 1) {
|
||
|
readUnsignedByte = parsableByteArray.readUnsignedByte();
|
||
|
} else if (readUnsignedShort3 == 2) {
|
||
|
readUnsignedByte = parsableByteArray.readUnsignedShort();
|
||
|
} else if (readUnsignedShort3 == 3) {
|
||
|
readUnsignedByte = parsableByteArray.readUnsignedInt24();
|
||
|
} else {
|
||
|
if (readUnsignedShort3 != 4) {
|
||
|
return null;
|
||
|
}
|
||
|
readUnsignedByte = parsableByteArray.readUnsignedIntToInt();
|
||
|
}
|
||
|
j4 += readUnsignedByte * i3;
|
||
|
i2++;
|
||
|
jArr = jArr;
|
||
|
readUnsignedShort2 = i3;
|
||
|
j3 = j5;
|
||
|
}
|
||
|
long[] jArr3 = jArr;
|
||
|
if (j != -1 && j != j4) {
|
||
|
Log.w(TAG, "VBRI data size mismatch: " + j + ", " + j4);
|
||
|
}
|
||
|
return new VbriSeeker(jArr3, jArr2, scaleLargeTimestamp, j4);
|
||
|
}
|
||
|
|
||
|
private VbriSeeker(long[] jArr, long[] jArr2, long j, long j2) {
|
||
|
this.timesUs = jArr;
|
||
|
this.positions = jArr2;
|
||
|
this.durationUs = j;
|
||
|
this.dataEndPosition = j2;
|
||
|
}
|
||
|
|
||
|
@Override // androidx.media3.extractor.SeekMap
|
||
|
public SeekMap.SeekPoints getSeekPoints(long j) {
|
||
|
int binarySearchFloor = Util.binarySearchFloor(this.timesUs, j, true, true);
|
||
|
SeekPoint seekPoint = new SeekPoint(this.timesUs[binarySearchFloor], this.positions[binarySearchFloor]);
|
||
|
if (seekPoint.timeUs >= j || binarySearchFloor == this.timesUs.length - 1) {
|
||
|
return new SeekMap.SeekPoints(seekPoint);
|
||
|
}
|
||
|
int i = binarySearchFloor + 1;
|
||
|
return new SeekMap.SeekPoints(seekPoint, new SeekPoint(this.timesUs[i], this.positions[i]));
|
||
|
}
|
||
|
|
||
|
@Override // androidx.media3.extractor.mp3.Seeker
|
||
|
public long getTimeUs(long j) {
|
||
|
return this.timesUs[Util.binarySearchFloor(this.positions, j, true, true)];
|
||
|
}
|
||
|
}
|