Merge pull request #3 from soneek/master

hcs's update for IMA decoder
This commit is contained in:
Chris Moeller 2014-06-01 20:12:32 -07:00
commit a5843ef470

View File

@ -512,41 +512,39 @@ 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) {
int i;
int32_t sample_count=0;
int32_t hist1=stream->adpcm_history1_32;
int32_t sample_count = 0;
int32_t hist1 = stream->adpcm_history1_32;
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];
uint8_t sample_byte;
int sample_nibble;
int sample_decoded;
int delta;
sample_byte = read_8bit(stream->offset+i/2,stream->streamfile);
sample_nibble = (sample_byte >> (i&1?4:0))&0xf;
sample_byte = read_8bit(stream->offset + i / 2, stream->streamfile);
sample_nibble = (sample_byte >> (i & 1 ? 4 : 0)) & 0xf;
sample_decoded = hist1;
delta = step >> 3;
if (sample_nibble & 1) delta += step >> 2;
if (sample_nibble & 2) delta += step >> 1;
if (sample_nibble & 4) delta += step;
sample_decoded = hist1 << 3;
delta = step * (sample_nibble & 7) * 2 + step;
if (sample_nibble & 8)
sample_decoded -= delta;
else
sample_decoded += delta;
hist1=clamp16(sample_decoded);
hist1 = clamp16(sample_decoded >> 3);
step_index += IMA_IndexTable[sample_nibble&0x7];
if (step_index < 0) step_index=0;
if (step_index > 88) step_index=88;
step_index += IMA_IndexTable[sample_nibble & 0x7];
if (step_index < 0) step_index = 0;
if (step_index > 88) step_index = 88;
outbuf[sample_count]=(short)(hist1);
outbuf[sample_count] = (short)(hist1);
}
stream->adpcm_history1_32=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) {