mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-28 16:30:54 +01:00
commit
a5843ef470
@ -510,43 +510,41 @@ void decode_eacs_ima(VGMSTREAM * vgmstream, sample * outbuf, int channelspacing,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void decode_ima(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) {
|
void decode_ima(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
int32_t sample_count=0;
|
int32_t sample_count = 0;
|
||||||
int32_t hist1=stream->adpcm_history1_32;
|
int32_t hist1 = stream->adpcm_history1_32;
|
||||||
int step_index = stream->adpcm_step_index;
|
int step_index = stream->adpcm_step_index;
|
||||||
|
|
||||||
for (i=first_sample,sample_count=0; i<first_sample+samples_to_do; i++,sample_count+=channelspacing) {
|
for (i = first_sample, sample_count = 0; i<first_sample + samples_to_do; i++, sample_count += channelspacing) {
|
||||||
int step = ADPCMTable[step_index];
|
int step = ADPCMTable[step_index];
|
||||||
uint8_t sample_byte;
|
uint8_t sample_byte;
|
||||||
int sample_nibble;
|
int sample_nibble;
|
||||||
int sample_decoded;
|
int sample_decoded;
|
||||||
int delta;
|
int delta;
|
||||||
|
|
||||||
sample_byte = read_8bit(stream->offset+i/2,stream->streamfile);
|
sample_byte = read_8bit(stream->offset + i / 2, stream->streamfile);
|
||||||
sample_nibble = (sample_byte >> (i&1?4:0))&0xf;
|
sample_nibble = (sample_byte >> (i & 1 ? 4 : 0)) & 0xf;
|
||||||
|
|
||||||
sample_decoded = hist1;
|
sample_decoded = hist1 << 3;
|
||||||
delta = step >> 3;
|
|
||||||
if (sample_nibble & 1) delta += step >> 2;
|
|
||||||
if (sample_nibble & 2) delta += step >> 1;
|
|
||||||
if (sample_nibble & 4) delta += step;
|
|
||||||
if (sample_nibble & 8)
|
|
||||||
sample_decoded -= delta;
|
|
||||||
else
|
|
||||||
sample_decoded += delta;
|
|
||||||
|
|
||||||
hist1=clamp16(sample_decoded);
|
delta = step * (sample_nibble & 7) * 2 + step;
|
||||||
|
if (sample_nibble & 8)
|
||||||
|
sample_decoded -= delta;
|
||||||
|
else
|
||||||
|
sample_decoded += delta;
|
||||||
|
|
||||||
step_index += IMA_IndexTable[sample_nibble&0x7];
|
hist1 = clamp16(sample_decoded >> 3);
|
||||||
if (step_index < 0) step_index=0;
|
|
||||||
if (step_index > 88) step_index=88;
|
|
||||||
|
|
||||||
outbuf[sample_count]=(short)(hist1);
|
step_index += IMA_IndexTable[sample_nibble & 0x7];
|
||||||
}
|
if (step_index < 0) step_index = 0;
|
||||||
|
if (step_index > 88) step_index = 88;
|
||||||
|
|
||||||
stream->adpcm_history1_32=hist1;
|
outbuf[sample_count] = (short)(hist1);
|
||||||
stream->adpcm_step_index=step_index;
|
}
|
||||||
|
|
||||||
|
stream->adpcm_history1_32 = hist1;
|
||||||
|
stream->adpcm_step_index = step_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
void decode_apple_ima4(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) {
|
void decode_apple_ima4(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) {
|
||||||
|
Loading…
Reference in New Issue
Block a user