add GCSW support

git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@65 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
halleyscometsw 2008-04-02 17:50:50 +00:00
parent a7ffeb2822
commit 74e68edbfb
5 changed files with 92 additions and 2 deletions

View File

@ -23,7 +23,8 @@ META_OBJS=meta/adx_header.o \
meta/rsf.o \
meta/rs03.o \
meta/ngc_dsp_std.o \
meta/Cstr.o
meta/Cstr.o \
meta/gcsw.o
OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS)

73
src/meta/gcsw.c Normal file
View File

@ -0,0 +1,73 @@
#include "gcsw.h"
#include "../util.h"
VGMSTREAM * init_vgmstream_gcsw(const char * const filename) {
VGMSTREAM * vgmstream = NULL;
STREAMFILE * infile = NULL;
coding_t coding_type;
int channel_count;
int loop_flag;
size_t max_block;
/* check extension, case insensitive */
if (strcasecmp("gcw",filename_extension(filename))) goto fail;
/* try to open the file for header reading */
infile = open_streamfile(filename);
if (!infile) goto fail;
/* check header */
if ((uint32_t)read_32bitBE(0,infile)!=0x47435357) /* "GCSW" */
goto fail;
/* check type details */
/* guess */
loop_flag = read_32bitBE(0x1c,infile);
channel_count = read_32bitBE(0xc,infile);
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
vgmstream->num_samples = read_32bitBE(0x10,infile);
vgmstream->sample_rate = read_32bitBE(0x8,infile);
/* channels and loop flag are set by allocate_vgmstream */
vgmstream->loop_start_sample = read_32bitBE(0x14,infile);
vgmstream->loop_end_sample = read_32bitBE(0x18,infile);
vgmstream->coding_type = coding_PCM16BE;
vgmstream->layout_type = layout_interleave;
vgmstream->meta_type = meta_GCSW;
vgmstream->interleave_block_size = 0x8000;
close_streamfile(infile); infile=NULL;
/* open the file for reading by each channel */
{
int i;
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=
0x20+0x8000*i;
}
}
return vgmstream;
/* clean up anything we may have opened */
fail:
if (infile) close_streamfile(infile);
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}

8
src/meta/gcsw.h Normal file
View File

@ -0,0 +1,8 @@
#include "../vgmstream.h"
#ifndef _GCSW_H
#define _GCSW_H
VGMSTREAM * init_vgmstream_gcsw(const char * const filename);
#endif

View File

@ -14,6 +14,7 @@
#include "meta/rs03.h"
#include "meta/ngc_dsp_std.h"
#include "meta/Cstr.h"
#include "meta/gcsw.h"
#include "layout/interleave.h"
#include "layout/nolayout.h"
#include "layout/blocked.h"
@ -29,7 +30,7 @@
* List of functions that will recognize files. These should correspond pretty
* directly to the metadata types
*/
#define INIT_VGMSTREAM_FCNS 12
#define INIT_VGMSTREAM_FCNS 13
VGMSTREAM * (*init_vgmstream_fcns[INIT_VGMSTREAM_FCNS])(const char * const) = {
init_vgmstream_adx,
init_vgmstream_brstm,
@ -43,6 +44,7 @@ VGMSTREAM * (*init_vgmstream_fcns[INIT_VGMSTREAM_FCNS])(const char * const) = {
init_vgmstream_rs03,
init_vgmstream_ngc_dsp_std,
init_vgmstream_Cstr,
init_vgmstream_gcsw,
};
@ -93,6 +95,8 @@ VGMSTREAM * allocate_vgmstream(int channel_count, int looped) {
VGMSTREAMCHANNEL * start_channels;
VGMSTREAMCHANNEL * loop_channels;
if (channel_count <= 0) return NULL;
vgmstream = calloc(1,sizeof(VGMSTREAM));
if (!vgmstream) return NULL;
@ -541,6 +545,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
case meta_DSP_CSTR:
snprintf(temp,TEMPSIZE,"Namco Cstr header");
break;
case meta_GCSW:
snprintf(temp,TEMPSIZE,"GCSW header");
break;
default:
snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET");
}

View File

@ -75,6 +75,7 @@ typedef enum {
meta_kRAW, /* almost headerless PCM */
meta_RSF, /* Retro Studios RSF, no header (.rsf) */
meta_HALPST, /* HAL Labs HALPST */
meta_GCSW, /* GCSW (PCM) */
} meta_t;
typedef struct {