whitespace cleanup (tabs to spaces, unix line endings), and one unused variable

git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@83 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
halleyscometsw 2008-05-04 22:10:30 +00:00
parent 24ca1a20ef
commit 33b3a3c87e
5 changed files with 64 additions and 65 deletions

View File

@ -1,40 +1,40 @@
#include "psx_decoder.h"
#include "../util.h"
double VAG_f[5][2] = { { 0.0 , 0.0 },
{ 60.0 / 64.0 , 0.0 },
{ 115.0 / 64.0 , -52.0 / 64.0 },
{ 98.0 / 64.0 , -55.0 / 64.0 } ,
{ 122.0 / 64.0 , -60.0 / 64.0 } } ;
double VAG_f[5][2] = { { 0.0 , 0.0 },
{ 60.0 / 64.0 , 0.0 },
{ 115.0 / 64.0 , -52.0 / 64.0 },
{ 98.0 / 64.0 , -55.0 / 64.0 } ,
{ 122.0 / 64.0 , -60.0 / 64.0 } } ;
void decode_psx(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) {
int predict_nr, shift_factor, sample;
int16_t hist1=stream->adpcm_history1_16;
int16_t hist2=stream->adpcm_history2_16;
int scale;
int i;
int32_t sample_count;
predict_nr = read_8bit(stream->offset,stream->streamfile) >> 4;
shift_factor = read_8bit(stream->offset,stream->streamfile) & 0xf;
for (i=first_sample,sample_count=0; i<first_sample+samples_to_do; i++,sample_count+=channelspacing) {
int sample_byte = (short)read_8bit(stream->offset+2+i/2,stream->streamfile);
scale = (short)((i&1 ?
sample_byte >> 4 :
sample_byte & 0x0f)<<12);
sample=(int)((scale >> shift_factor)+hist1*VAG_f[predict_nr][0]+hist2*VAG_f[predict_nr][1]);
outbuf[sample_count] = clamp16(sample);
hist2=hist1;
hist1=sample;
}
stream->adpcm_history1_16=hist1;
stream->adpcm_history2_16=hist2;
}
int predict_nr, shift_factor, sample;
int16_t hist1=stream->adpcm_history1_16;
int16_t hist2=stream->adpcm_history2_16;
int scale;
int i;
int32_t sample_count;
predict_nr = read_8bit(stream->offset,stream->streamfile) >> 4;
shift_factor = read_8bit(stream->offset,stream->streamfile) & 0xf;
for (i=first_sample,sample_count=0; i<first_sample+samples_to_do; i++,sample_count+=channelspacing) {
int sample_byte = (short)read_8bit(stream->offset+2+i/2,stream->streamfile);
scale = (short)((i&1 ?
sample_byte >> 4 :
sample_byte & 0x0f)<<12);
sample=(int)((scale >> shift_factor)+hist1*VAG_f[predict_nr][0]+hist2*VAG_f[predict_nr][1]);
outbuf[sample_count] = clamp16(sample);
hist2=hist1;
hist1=sample;
}
stream->adpcm_history1_16=hist1;
stream->adpcm_history2_16=hist2;
}

View File

@ -6,4 +6,4 @@
void decode_psx(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
#endif
#endif

View File

@ -8,13 +8,12 @@ VGMSTREAM * init_vgmstream_ps2_ads(const char * const filename) {
STREAMFILE * infile = NULL;
int loop_flag=0;
int channel_count;
off_t start_offset;
int channel_count;
int i;
/* check extension, case insensitive */
if (strcasecmp("ads",filename_extension(filename)) &&
strcasecmp("ss2",filename_extension(filename))) goto fail;
strcasecmp("ss2",filename_extension(filename))) goto fail;
/* try to open the file for header reading */
infile = open_streamfile(filename);
@ -31,41 +30,41 @@ VGMSTREAM * init_vgmstream_ps2_ads(const char * const filename) {
/* check if file is not corrupt */
if (get_streamfile_size(infile)<(size_t)(read_32bitLE(0x24,infile) + 0x28))
goto fail;
/* check loop */
loop_flag = (read_32bitLE(0x18,infile)!=0xFFFFFFFF);
/* check loop */
loop_flag = (read_32bitLE(0x18,infile)!=0xFFFFFFFF);
channel_count=read_32bitLE(0x10,infile);
/* build the VGMSTREAM */
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
vgmstream->channels = read_32bitLE(0x10,infile);
/* fill in the vital statistics */
vgmstream->channels = read_32bitLE(0x10,infile);
vgmstream->sample_rate = read_32bitLE(0x0C,infile);
/* Check for Compression Scheme */
vgmstream->coding_type = coding_PSX;
/* Check for Compression Scheme */
vgmstream->coding_type = coding_PSX;
vgmstream->num_samples = read_32bitLE(0x24,infile)/16*28/vgmstream->channels;
/* SS2 container with RAW Interleaved PCM */
if (read_32bitLE(0x08,infile)==0x01) {
vgmstream->coding_type=coding_PCM16LE;
vgmstream->num_samples = read_32bitLE(0x24,infile)/2/vgmstream->channels;
}
/* SS2 container with RAW Interleaved PCM */
if (read_32bitLE(0x08,infile)==0x01) {
vgmstream->coding_type=coding_PCM16LE;
vgmstream->num_samples = read_32bitLE(0x24,infile)/2/vgmstream->channels;
}
/* Get loop point values */
if(vgmstream->loop_flag) {
vgmstream->loop_start_sample = read_32bitLE(0x18,infile);
vgmstream->loop_end_sample = read_32bitLE(0x1C,infile);
}
/* Get loop point values */
if(vgmstream->loop_flag) {
vgmstream->loop_start_sample = read_32bitLE(0x18,infile);
vgmstream->loop_end_sample = read_32bitLE(0x1C,infile);
}
/* don't know why, but it does happen, in ps2 too :( */
if (vgmstream->loop_end_sample > vgmstream->num_samples)
vgmstream->loop_end_sample = vgmstream->num_samples;
vgmstream->interleave_block_size = read_32bitLE(0x14,infile);
vgmstream->interleave_block_size = read_32bitLE(0x14,infile);
vgmstream->layout_type = layout_interleave;
vgmstream->meta_type = meta_PS2_SShd;

View File

@ -52,7 +52,7 @@ VGMSTREAM * (*init_vgmstream_fcns[INIT_VGMSTREAM_FCNS])(const char * const) = {
init_vgmstream_ngc_dsp_std,
init_vgmstream_Cstr,
init_vgmstream_gcsw,
init_vgmstream_ps2_ads,
init_vgmstream_ps2_ads,
};
@ -196,8 +196,8 @@ int get_vgmstream_samples_per_frame(VGMSTREAM * vgmstream) {
return 1;
case coding_NGC_AFC:
return 16;
case coding_PSX:
return 28;
case coding_PSX:
return 28;
default:
return 0;
}
@ -231,8 +231,8 @@ int get_vgmstream_frame_size(VGMSTREAM * vgmstream) {
return 0;
case coding_NGC_AFC:
return 9;
case coding_PSX:
return 16;
case coding_PSX:
return 16;
default:
return 0;
}

View File

@ -58,8 +58,8 @@ char * extension_list[EXTENSION_COUNT] = {
"rsf\0RSF Audio File (*.RSF)\0",
"dsp\0DSP Audio File (*.DSP)\0",
"gcw\0GCW Audio File (*.GCW)\0",
"ads\0PS2 ADS Audio File (*.ADS)\0",
"ss2\0PS2 SS2 Audio File (*.SS2)\0",
"ads\0PS2 ADS Audio File (*.ADS)\0",
"ss2\0PS2 SS2 Audio File (*.SS2)\0",
};
/* stubs, we don't do anything fancy yet */