fixed mono XA decoding

git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@146 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
fastelbja 2008-05-17 15:34:17 +00:00
parent 16c9bf0c0b
commit f5dccfc3d7
2 changed files with 15 additions and 6 deletions

View File

@ -20,7 +20,11 @@ int CLAMP(int value, int Minim, int Maxim)
return value;
}
static uint8_t get_high_nibble=1;
static int get_high_nibble = 1;
void init_get_high_nibble() {
get_high_nibble=1;
}
void decode_xa(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) {
@ -33,15 +37,16 @@ void decode_xa(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, i
int i;
int32_t sample_count;
int framesin = first_sample / 28;
int framesin = first_sample / (56 / channelspacing);
get_high_nibble=!get_high_nibble;
first_sample = first_sample % 28;
if(!first_sample)
get_high_nibble=!get_high_nibble;
predict_nr = read_8bit(stream->offset+HeadTable[framesin]+get_high_nibble,stream->streamfile) >> 4;
shift_factor = read_8bit(stream->offset+HeadTable[framesin]+get_high_nibble,stream->streamfile) & 0xf;
first_sample = first_sample % 28;
for (i=first_sample,sample_count=0; i<first_sample+samples_to_do; i++,sample_count+=channelspacing) {
short sample_byte = (short)read_8bit(stream->offset+16+framesin+(i*4),stream->streamfile);

View File

@ -1,12 +1,16 @@
#include "layout.h"
#include "../vgmstream.h"
extern void init_get_high_nibble();
/* set up for the block at the given offset */
void xa_block_update(off_t block_offset, VGMSTREAM * vgmstream) {
int i;
int8_t currentChannel=0;
int8_t subAudio=0;
init_get_high_nibble();
if(vgmstream->samples_into_block!=0)
// don't change this variable in the init process