mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-07-08 14:57:30 +07:00
Pass BIK reference to child BinkAudio for flags and version validation
This commit is contained in:
@ -114,7 +114,7 @@ public class BIK {
|
||||
for (int i = 0, s = numTracks; i < s; i++) {
|
||||
try {
|
||||
MDC.put("track", i);
|
||||
tracks[i] = new BinkAudio(in);
|
||||
tracks[i] = new BinkAudio(this, in);
|
||||
} finally {
|
||||
MDC.remove("track");
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ public class BinkAudio {
|
||||
private final int[] BANDS;
|
||||
private final float[][] PREVIOUS = new float[MAX_CHANNELS][BLOCK_MAX_SIZE >>> 4];
|
||||
|
||||
final BIK bik;
|
||||
final short numChannels;
|
||||
final int sampleRate;
|
||||
final int flags;
|
||||
@ -48,7 +49,9 @@ public class BinkAudio {
|
||||
|
||||
boolean first;
|
||||
|
||||
BinkAudio(ByteInput in) {
|
||||
BinkAudio(BIK bik, ByteInput in) {
|
||||
this.bik = bik;
|
||||
|
||||
log.trace("slicing {} bytes", SIZE);
|
||||
in = in.readSlice(SIZE);
|
||||
|
||||
@ -122,6 +125,12 @@ public class BinkAudio {
|
||||
return (flags & FLAG_AUDIO_STEREO) == 0;
|
||||
}
|
||||
|
||||
static float readFloat29(BitInput bits) {
|
||||
int power = bits.read31u(5);
|
||||
float f = FastMath.scalb(bits.read31u(23), power - 23);
|
||||
return bits.readBoolean() ? -f : f;
|
||||
}
|
||||
|
||||
void decode(BitInput bits, float[][] out) {
|
||||
int ch, i, j, k;
|
||||
float q;
|
||||
@ -143,11 +152,12 @@ public class BinkAudio {
|
||||
// parse coefficients
|
||||
i = 2;
|
||||
while (i < frameLen) {
|
||||
assert bik.version == 'i';
|
||||
{
|
||||
int v = bits.read1();
|
||||
if (v != 0) {
|
||||
v = bits.read7u(4);
|
||||
j = i + RLE[v] << 3;
|
||||
j = i + RLE[v] * 8;
|
||||
} else {
|
||||
j = i + 8;
|
||||
}
|
||||
@ -202,10 +212,4 @@ public class BinkAudio {
|
||||
|
||||
first = false;
|
||||
}
|
||||
|
||||
static float readFloat29(BitInput bits) {
|
||||
int power = bits.read32(5);
|
||||
float f = FastMath.scalb(bits.read32(23), power - 23);
|
||||
return bits.readBoolean() ? f : -f;
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ public class VideoPlayer implements Disposable {
|
||||
private int frame;
|
||||
private float time, nextFrame;
|
||||
private ExecutorService audioStreams;
|
||||
// FIXME: child threads should throw an error to parent?
|
||||
|
||||
public VideoPlayer() {
|
||||
|
||||
|
Reference in New Issue
Block a user