adding svag support - fixing implicit warning on vs2005 for ps2_xxx functions

git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@114 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
fastelbja 2008-05-13 19:53:31 +00:00
parent b97479a9d7
commit b1aaf2ba85
14 changed files with 242 additions and 130 deletions

View File

@ -51,6 +51,8 @@ File types supported by this version of vgmstream:
- .xa (CD-ROM XA audio) - .xa (CD-ROM XA audio)
- .rxw (PSX ADPCM) - .rxw (PSX ADPCM)
- .int (16 bit PCM) - .int (16 bit PCM)
- .sts (PSX ADPCM)
- .svag (PSX ADPCM)
Enjoy! Enjoy!
-hcs -hcs

View File

@ -34,7 +34,8 @@ META_OBJS=meta/adx_header.o \
meta/psx_cdxa.o \ meta/psx_cdxa.o \
meta/ps2_rxw.o \ meta/ps2_rxw.o \
meta/ps2_int.o \ meta/ps2_int.o \
meta/ps2_exst.o meta/ps2_exst.o \
meta/ps2_svag.o
OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS) OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS)

View File

@ -16,15 +16,22 @@ void decode_psx(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing,
short scale; short scale;
int i; int i;
int32_t sample_count; int32_t sample_count;
uint8_t flag;
int framesin = first_sample/28; int framesin = first_sample/28;
predict_nr = read_8bit(stream->offset+framesin*16,stream->streamfile) >> 4; predict_nr = read_8bit(stream->offset+framesin*16,stream->streamfile) >> 4;
shift_factor = read_8bit(stream->offset+framesin*16,stream->streamfile) & 0xf; shift_factor = read_8bit(stream->offset+framesin*16,stream->streamfile) & 0xf;
flag = read_8bit(stream->offset+framesin*16+1,stream->streamfile);
first_sample = first_sample % 28; first_sample = first_sample % 28;
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) {
sample=0;
if(flag!=0x07) {
short sample_byte = (short)read_8bit(stream->offset+(framesin*16)+2+i/2,stream->streamfile); short sample_byte = (short)read_8bit(stream->offset+(framesin*16)+2+i/2,stream->streamfile);
scale = ((i&1 ? scale = ((i&1 ?
@ -32,8 +39,9 @@ void decode_psx(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing,
sample_byte & 0x0f)<<12); sample_byte & 0x0f)<<12);
sample=(int)((scale >> shift_factor)+hist1*VAG_f[predict_nr][0]+hist2*VAG_f[predict_nr][1]); sample=(int)((scale >> shift_factor)+hist1*VAG_f[predict_nr][0]+hist2*VAG_f[predict_nr][1]);
outbuf[sample_count] = clamp16(sample); }
outbuf[sample_count] = clamp16(sample);
hist2=hist1; hist2=hist1;
hist1=sample; hist1=sample;
} }

View File

@ -262,6 +262,10 @@
RelativePath=".\meta\ps2_rxw.c" RelativePath=".\meta\ps2_rxw.c"
> >
</File> </File>
<File
RelativePath=".\meta\ps2_svag.c"
>
</File>
<File <File
RelativePath=".\meta\psx_cdxa.c" RelativePath=".\meta\psx_cdxa.c"
> >

View File

@ -45,4 +45,6 @@ VGMSTREAM * init_vgmstream_ps2_int(const char * const filename);
VGMSTREAM * init_vgmstream_ps2_exst(const char * const filename); VGMSTREAM * init_vgmstream_ps2_exst(const char * const filename);
VGMSTREAM * init_vgmstream_ps2_svag(const char * const filename);
#endif #endif

View File

@ -79,7 +79,7 @@ VGMSTREAM * init_vgmstream_ps2_ads(const char * const filename) {
vgmstream->ch[i].channel_start_offset= vgmstream->ch[i].channel_start_offset=
vgmstream->ch[i].offset= vgmstream->ch[i].offset=
0x28+vgmstream->interleave_block_size*i; (off_t)(0x28+vgmstream->interleave_block_size*i);
} }
} }

View File

@ -71,7 +71,7 @@ VGMSTREAM * init_vgmstream_ps2_exst(const char * const filename) {
vgmstream->ch[i].channel_start_offset= vgmstream->ch[i].channel_start_offset=
vgmstream->ch[i].offset= vgmstream->ch[i].offset=
0x800+vgmstream->interleave_block_size*i; (off_t)(0x800+vgmstream->interleave_block_size*i);
} }
} }

View File

@ -34,7 +34,7 @@ VGMSTREAM * init_vgmstream_ps2_int(const char * const filename) {
vgmstream->channels = 2; vgmstream->channels = 2;
vgmstream->sample_rate = 48000; vgmstream->sample_rate = 48000;
vgmstream->coding_type = coding_PCM16LE; vgmstream->coding_type = coding_PCM16LE;
vgmstream->num_samples = get_streamfile_size(infile)/4; vgmstream->num_samples = (int32_t)(get_streamfile_size(infile)/4);
vgmstream->interleave_block_size = 0x200; vgmstream->interleave_block_size = 0x200;
vgmstream->layout_type = layout_interleave; vgmstream->layout_type = layout_interleave;
vgmstream->meta_type = meta_PS2_RAW; vgmstream->meta_type = meta_PS2_RAW;

View File

@ -62,7 +62,7 @@ VGMSTREAM * init_vgmstream_ps2_npsf(const char * const filename) {
vgmstream->ch[i].channel_start_offset= vgmstream->ch[i].channel_start_offset=
vgmstream->ch[i].offset= vgmstream->ch[i].offset=
start_offset+vgmstream->interleave_block_size*i; (off_t)(start_offset+vgmstream->interleave_block_size*i);
} }
} }

View File

@ -64,7 +64,7 @@ VGMSTREAM * init_vgmstream_ps2_rxw(const char * const filename) {
vgmstream->ch[i].channel_start_offset= vgmstream->ch[i].channel_start_offset=
vgmstream->ch[i].offset= vgmstream->ch[i].offset=
start_offset+vgmstream->interleave_block_size*i; (off_t)(start_offset+vgmstream->interleave_block_size*i);
} }
} }

88
src/meta/ps2_svag.c Normal file
View File

@ -0,0 +1,88 @@
#include "meta.h"
#include "../util.h"
/* SVAG
PS2 SVAG format is an interleaved format found in many konami Games
The header start with a Svag id and have the sentence :
"ALL RIGHTS RESERVED.KONAMITYO Sound Design Dept. "
or "ALL RIGHTS RESERVED.KCE-Tokyo Sound Design Dept. "
2008-05-13 - Fastelbja : First version ...
Thx to HCS for his awesome work on shortblock interleave
*/
VGMSTREAM * init_vgmstream_ps2_svag(const char * const filename) {
VGMSTREAM * vgmstream = NULL;
STREAMFILE * infile = NULL;
int loop_flag=0;
int channel_count;
int i;
/* check extension, case insensitive */
if (strcasecmp("svag",filename_extension(filename))) goto fail;
/* try to open the file for header reading */
infile = open_streamfile(filename);
if (!infile) goto fail;
/* check SVAG Header */
if (read_32bitBE(0x00,infile) != 0x53766167)
goto fail;
/* check loop */
loop_flag = (read_32bitLE(0x14,infile)==1);
channel_count=read_16bitLE(0x0C,infile);
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
vgmstream->channels = read_16bitLE(0x0C,infile);
vgmstream->sample_rate = read_32bitLE(0x08,infile);
/* Compression Scheme */
vgmstream->coding_type = coding_PSX;
vgmstream->num_samples = read_32bitLE(0x04,infile)/16*28/vgmstream->channels;
/* Get loop point values */
if(vgmstream->loop_flag) {
vgmstream->loop_start_sample = read_32bitLE(0x18,infile)/16*28;
vgmstream->loop_end_sample = read_32bitLE(0x04,infile)/16*28/vgmstream->channels;
}
vgmstream->interleave_block_size = read_32bitLE(0x10,infile);
/* There's no value on header to get the smallblock_size length */
/* so we add to calculate it based upon the file length, which can broke things */
/* with bad ripped stuff ... */
vgmstream->interleave_smallblock_size = ((get_streamfile_size(infile)-0x800)%(2*vgmstream->interleave_block_size))/2;
vgmstream->layout_type = layout_interleave_shortblock;
vgmstream->meta_type = meta_PS2_SVAG;
close_streamfile(infile); infile=NULL;
/* open the file for reading by each channel */
{
for (i=0;i<channel_count;i++) {
vgmstream->ch[i].streamfile = open_streamfile_buffer(filename,0x8000);
if (!vgmstream->ch[i].streamfile) goto fail;
vgmstream->ch[i].channel_start_offset=
vgmstream->ch[i].offset=
(off_t)(0x800+vgmstream->interleave_block_size*i);
}
}
return vgmstream;
/* clean up anything we may have opened */
fail:
if (infile) close_streamfile(infile);
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}

View File

@ -15,7 +15,7 @@
* List of functions that will recognize files. These should correspond pretty * List of functions that will recognize files. These should correspond pretty
* directly to the metadata types * directly to the metadata types
*/ */
#define INIT_VGMSTREAM_FCNS 21 #define INIT_VGMSTREAM_FCNS 22
VGMSTREAM * (*init_vgmstream_fcns[INIT_VGMSTREAM_FCNS])(const char * const) = { VGMSTREAM * (*init_vgmstream_fcns[INIT_VGMSTREAM_FCNS])(const char * const) = {
init_vgmstream_adx, /* 0 */ init_vgmstream_adx, /* 0 */
init_vgmstream_brstm, /* 1 */ init_vgmstream_brstm, /* 1 */
@ -38,6 +38,7 @@ VGMSTREAM * (*init_vgmstream_fcns[INIT_VGMSTREAM_FCNS])(const char * const) = {
init_vgmstream_ps2_int, /* 18 */ init_vgmstream_ps2_int, /* 18 */
init_vgmstream_ngc_dsp_stm, /* 19 */ init_vgmstream_ngc_dsp_stm, /* 19 */
init_vgmstream_ps2_exst, /* 20 */ init_vgmstream_ps2_exst, /* 20 */
init_vgmstream_ps2_svag, /* 21 */
}; };
@ -602,6 +603,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
case meta_PS2_EXST: case meta_PS2_EXST:
snprintf(temp,TEMPSIZE,"EXST File (Shadow of the Colossus)"); snprintf(temp,TEMPSIZE,"EXST File (Shadow of the Colossus)");
break; break;
case meta_PS2_SVAG:
snprintf(temp,TEMPSIZE,"Konami SVAG Audio File");
break;
default: default:
snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET"); snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET");
} }

View File

@ -79,6 +79,8 @@ typedef enum {
meta_PS2_RXW, /* Sony Arc The Lad Sound File */ meta_PS2_RXW, /* Sony Arc The Lad Sound File */
meta_PS2_RAW, /* RAW Interleaved Format */ meta_PS2_RAW, /* RAW Interleaved Format */
meta_PS2_EXST, /* Shadow of Colossus EXST */ meta_PS2_EXST, /* Shadow of Colossus EXST */
meta_PS2_SVAG, /* Konami SVAG */
meta_PSX_XA, /* CD-XA with RIFF header */ meta_PSX_XA, /* CD-XA with RIFF header */
} meta_t; } meta_t;

View File

@ -45,7 +45,7 @@ int fade_samples = 0;
#define EXTENSION_LIST_SIZE 1024 #define EXTENSION_LIST_SIZE 1024
char working_extension_list[EXTENSION_LIST_SIZE] = {0}; char working_extension_list[EXTENSION_LIST_SIZE] = {0};
#define EXTENSION_COUNT 19 #define EXTENSION_COUNT 20
char * extension_list[EXTENSION_COUNT] = { char * extension_list[EXTENSION_COUNT] = {
"adx\0ADX Audio File (*.ADX)\0", "adx\0ADX Audio File (*.ADX)\0",
"afc\0AFC Audio File (*.AFC)\0", "afc\0AFC Audio File (*.AFC)\0",
@ -66,6 +66,7 @@ char * extension_list[EXTENSION_COUNT] = {
"rxw\0PS2 RXWS File (*.RXW)\0", "rxw\0PS2 RXWS File (*.RXW)\0",
"int\0PS2 RAW Interleaved PCM (*.INT)\0", "int\0PS2 RAW Interleaved PCM (*.INT)\0",
"sts\0PS2 EXST Audio File (*.STS)\0", "sts\0PS2 EXST Audio File (*.STS)\0",
"svag\0PS2 SVAG Audio File (*.SVAG)\0",
}; };
/* stubs, we don't do anything fancy yet */ /* stubs, we don't do anything fancy yet */