lot of fixes :)

git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@742 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
manakoAT 2010-02-15 09:02:31 +00:00
parent c1f880b158
commit ce3ab5d154
12 changed files with 177 additions and 153 deletions

View File

@ -174,7 +174,7 @@ Xbox IMA ADPCM:
Yamaha ADPCM:
- .adpcm
- .dcs+.wav
- .dcs+.dcsw
- .str
- .spsd

View File

@ -169,7 +169,7 @@ META_OBJS=meta/adx_header.o \
meta/ps2_joe.o \
meta/vgs.o \
meta/vs.o \
meta/dc_wav_dcs.o \
meta/dc_dcsw_dcs.o \
meta/wii_smp.o \
meta/ss_stream.o \
meta/emff.o \

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Version="9,00"
Name="libvgmstream"
ProjectGUID="{54A6AD11-5369-4895-A06F-E255ABB99B11}"
RootNamespace="libvgmstream"
@ -264,6 +264,10 @@
RelativePath=".\meta\dc_asd.c"
>
</File>
<File
RelativePath=".\meta\dc_dcsw_dcs.c"
>
</File>
<File
RelativePath=".\meta\dc_idvi.c"
>
@ -276,10 +280,6 @@
RelativePath=".\meta\dc_str.c"
>
</File>
<File
RelativePath=".\meta\dc_wav_dcs.c"
>
</File>
<File
RelativePath=".\meta\de2.c"
>

View File

@ -126,7 +126,7 @@ libmeta_la_SOURCES += msvp.c
libmeta_la_SOURCES += ps2_joe.c
libmeta_la_SOURCES += vs.c
libmeta_la_SOURCES += vgs.c
libmeta_la_SOURCES += dc_wav_dcs.c
libmeta_la_SOURCES += dc_dcsw_dcs.c
libmeta_la_SOURCES += wii_smp.c
libmeta_la_SOURCES += ss_stream.c
libmeta_la_SOURCES += emff.c

View File

@ -1,17 +1,19 @@
#include "meta.h"
#include "../util.h"
/* WAV+DCS
/* WAV+DCS (DCSW+DCS)
2008-12-06 - manakoAT : Evil Twin - Cypriens Chronicles...
2008-12-07 - manakoAT : Added a function to read the Header file and for
retrieving the channels/frequency, Frequency starts
always at a "data" chunk - 0x0C bytes, Channels
always - 0x0E bytes... */
VGMSTREAM * init_vgmstream_dc_wav_dcs(STREAMFILE *streamFile) {
always - 0x0E bytes...
2010-01-13 - manakoAT : Changed the 'Helper' extension from .wav to .dcws, to prevent conflicts */
VGMSTREAM * init_vgmstream_dc_dcsw_dcs(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
STREAMFILE * streamFileWAV = NULL;
STREAMFILE * streamFileDCSW = NULL;
char filename[260];
char filenameWAV[260];
char filenameDCSW[260];
int i;
int channel_count;
int loop_flag;
@ -26,28 +28,28 @@ VGMSTREAM * init_vgmstream_dc_wav_dcs(STREAMFILE *streamFile) {
if (strcasecmp("dcs",filename_extension(filename))) goto fail;
/* Getting the Header file name... */
strcpy(filenameWAV,filename);
strcpy(filenameWAV+strlen(filenameWAV)-3,"wav");
strcpy(filenameDCSW,filename);
strcpy(filenameDCSW+strlen(filenameDCSW)-3,"dcsw");
/* Look if the Header file is present, else cancel vgmstream */
streamFileWAV = streamFile->open(streamFile,filenameWAV,STREAMFILE_DEFAULT_BUFFER_SIZE);
if (!streamFileWAV) goto fail;
streamFileDCSW = streamFile->open(streamFile,filenameDCSW,STREAMFILE_DEFAULT_BUFFER_SIZE);
if (!streamFileDCSW) goto fail;
/* check header */
if (read_32bitBE(0x00,streamFileWAV) != 0x52494646 || /* "RIFF" */
read_32bitBE(0x08,streamFileWAV) != 0x57415645 || /* "WAVE" */
read_32bitBE(0x0C,streamFileWAV) != 0x34582E76 || /* 0x34582E76 */
read_32bitBE(0x3C,streamFileWAV) != 0x406E616D) /* "@nam" */
if (read_32bitBE(0x00,streamFileDCSW) != 0x52494646 || /* "RIFF" */
read_32bitBE(0x08,streamFileDCSW) != 0x57415645 || /* "WAVE" */
read_32bitBE(0x0C,streamFileDCSW) != 0x34582E76 || /* 0x34582E76 */
read_32bitBE(0x3C,streamFileDCSW) != 0x406E616D) /* "@nam" */
goto fail;
/* scan file until we find a "data" string */
file_size = get_streamfile_size(streamFileWAV);
file_size = get_streamfile_size(streamFileDCSW);
{
current_chunk = 0;
/* Start at 0 and loop until we reached the
file size, or until we found a "data string */
while (!Founddata && current_chunk < file_size) {
dataBuffer = (read_32bitBE(current_chunk,streamFileWAV));
dataBuffer = (read_32bitBE(current_chunk,streamFileDCSW));
if (dataBuffer == 0x64617461) { /* "data" */
/* if "data" string found, retrieve the needed infos */
Founddata = 1;
@ -62,8 +64,8 @@ VGMSTREAM * init_vgmstream_dc_wav_dcs(STREAMFILE *streamFile) {
if (Founddata == 0) {
goto fail;
} else if (Founddata == 1) {
channel_count = (uint16_t)read_16bitLE(current_chunk-0x0E,streamFileWAV);
frequency = read_32bitLE(current_chunk-0x0C,streamFileWAV);
channel_count = (uint16_t)read_16bitLE(current_chunk-0x0E,streamFileDCSW);
frequency = read_32bitLE(current_chunk-0x0C,streamFileDCSW);
}
loop_flag = 0;
@ -91,7 +93,7 @@ VGMSTREAM * init_vgmstream_dc_wav_dcs(STREAMFILE *streamFile) {
}
vgmstream->coding_type = coding_AICA;
vgmstream->meta_type = meta_DC_WAV_DCS;
vgmstream->meta_type = meta_DC_DCSW_DCS;
/* open the file for reading by each channel */
{
@ -105,13 +107,13 @@ VGMSTREAM * init_vgmstream_dc_wav_dcs(STREAMFILE *streamFile) {
}
}
close_streamfile(streamFileWAV); streamFileWAV=NULL;
close_streamfile(streamFileDCSW); streamFileDCSW=NULL;
return vgmstream;
/* clean up anything we may have opened */
fail:
if (streamFileWAV) close_streamfile(streamFileWAV);
if (streamFileDCSW) close_streamfile(streamFileDCSW);
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}

View File

@ -141,6 +141,7 @@ VGMSTREAM * init_vgmstream_fsb4(STREAMFILE *streamFile) {
switch (fsb4_format) {
/* PS2 (Spider Man - Web of Shadows), Speed Racer */
case 0x40008800:
case 0x20008800: // Silent Hill: Shattered Memories
vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x10;

View File

@ -1,34 +1,36 @@
#include "meta.h"
#include "../util.h"
/* FSB3.0 */
/* FSB3.0 & FSB3.1*/
VGMSTREAM * init_vgmstream_fsb3(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[260];
int fsb_headerlen;
int loop_flag;
int channel_count;
int loop_flag;
int channel_count;
off_t start_offset;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("fsb",filename_extension(filename))) goto fail;
if (strcasecmp("fsb",filename_extension(filename)) &&
strcasecmp("lfsb",filename_extension(filename)))
goto fail;
/* check header */
if (read_32bitBE(0x00,streamFile) != 0x46534233) goto fail; /* "FSB3" */
/* "Check if the FSB is used as conatiner or as single file" */
if (read_32bitLE(0x04,streamFile) != 0x1) goto fail;
/* Check if we're dealing with a FSB3.1 file */
/* "Check if the FSB is used as conatiner or as single file" */
if (read_32bitLE(0x04,streamFile) != 0x1) goto fail;
/* Check if we're dealing with a FSB3.0 or FSB3.1 file */
if ((read_32bitBE(0x10,streamFile) != 0x00000300) &&
(read_32bitBE(0x10,streamFile) != 0x01000300))
goto fail;
if (read_32bitBE(0x48,streamFile) == 0x02000806) { // Metroid Prime 3
if (read_32bitBE(0x48,streamFile) == 0x02000806) { // Metroid Prime 3
loop_flag = 1;
} else {
loop_flag = 0; /* (read_32bitLE(0x08,streamFile)!=0); */
loop_flag = 0;
}
channel_count = read_16bitLE(0x56,streamFile);
@ -39,40 +41,61 @@ VGMSTREAM * init_vgmstream_fsb3(STREAMFILE *streamFile) {
if (!vgmstream) goto fail;
// fsb_format = ;
switch (((uint8_t)read_8bit(0x4A, streamFile)) >> 4) {
switch (((uint8_t)read_8bit(0x4A, streamFile)) >> 4) {
case 0x0: // Nintendo DSP
vgmstream->coding_type = coding_NGC_DSP;
vgmstream->layout_type = layout_interleave_byte;
vgmstream->interleave_block_size = 2;
vgmstream->num_samples = (read_32bitLE(0x0C,streamFile))*14/8/channel_count;
if (loop_flag) {
vgmstream->loop_start_sample = read_32bitLE(0x40,streamFile);
vgmstream->loop_end_sample = (read_32bitLE(0x0C,streamFile))*14/8/channel_count;
}
break;
case 0x4: // XBOX IMA ADPCM
vgmstream->coding_type = coding_XBOX;
vgmstream->layout_type = layout_none;
vgmstream->num_samples = read_32bitLE(0x0C,streamFile)*64/36/channel_count;
if (loop_flag) {
vgmstream->loop_start_sample = read_32bitLE(0x40,streamFile);
vgmstream->loop_end_sample = read_32bitLE(0x0C,streamFile)*64/36/channel_count;
}
break;
case 0x8: // PS2 APDCM
vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x10;
vgmstream->num_samples = (read_32bitLE(0x0C,streamFile))*28/16/channel_count;
// Hack to support an illegal coding flag
if (read_32bitBE(0x48,streamFile) == 0x50010000) { // Fantastic 4: Rise of the Silver Surfer
vgmstream->coding_type = coding_PCM16LE;
vgmstream->num_samples = (read_32bitLE(0x0C,streamFile))/2/channel_count;
if (loop_flag) {
vgmstream->loop_start_sample = read_32bitLE(0x40,streamFile);
vgmstream->loop_end_sample = (read_32bitLE(0x0C,streamFile))*28/16/channel_count;
vgmstream->loop_start_sample = 0;
vgmstream->loop_end_sample = (read_32bitLE(0x0C,streamFile))/2/channel_count;
}
break;
default:
goto fail;
}
/* fill in the vital statistics */
if (channel_count == 1) {
vgmstream->layout_type = layout_none;
} else if (channel_count > 1) {
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 2;
}
} else {
vgmstream->coding_type = coding_NGC_DSP;
vgmstream->num_samples = (read_32bitLE(0x0C,streamFile))*14/8/channel_count;
if (loop_flag) {
vgmstream->loop_start_sample = 0;
vgmstream->loop_end_sample = (read_32bitLE(0x0C,streamFile))*14/8/channel_count;
}
if (channel_count == 1) {
vgmstream->layout_type = layout_none;
} else if (channel_count > 1) {
vgmstream->layout_type = layout_interleave_byte;
vgmstream->interleave_block_size = 2;
}
}
break;
case 0x4: // XBOX IMA ADPCM
vgmstream->coding_type = coding_XBOX;
vgmstream->layout_type = layout_none;
vgmstream->num_samples = read_32bitLE(0x0C,streamFile)*64/36/channel_count;
if (loop_flag) {
vgmstream->loop_start_sample = 0;
vgmstream->loop_end_sample = read_32bitLE(0x0C,streamFile)*64/36/channel_count;
}
break;
case 0x8: // PS2 APDCM
vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x10;
vgmstream->num_samples = (read_32bitLE(0x0C,streamFile))*28/16/channel_count;
if (loop_flag) {
vgmstream->loop_start_sample = 0;
vgmstream->loop_end_sample = (read_32bitLE(0x0C,streamFile))*28/16/channel_count;
}
break;
default:
goto fail;
}
/* fill in the vital statistics */
start_offset = fsb_headerlen+0x18;
vgmstream->sample_rate = (read_32bitLE(0x4C, streamFile));
@ -100,7 +123,6 @@ VGMSTREAM * init_vgmstream_fsb3(STREAMFILE *streamFile) {
if (!file) goto fail;
for (i=0;i<channel_count;i++) {
vgmstream->ch[i].streamfile = file;
if (vgmstream->coding_type == coding_XBOX) {
/* xbox interleaving is a little odd */
@ -110,7 +132,6 @@ VGMSTREAM * init_vgmstream_fsb3(STREAMFILE *streamFile) {
start_offset+vgmstream->interleave_block_size*i;
}
vgmstream->ch[i].offset = vgmstream->ch[i].channel_start_offset;
}
}

View File

@ -327,7 +327,7 @@ VGMSTREAM * init_vgmstream_ps2_joe(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_vgs(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_dc_wav_dcs(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_dc_dcsw_dcs(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_wii_smp(STREAMFILE * streamFile);

View File

@ -40,18 +40,18 @@ VGMSTREAM * init_vgmstream_pcm_scd(STREAMFILE *streamFile) {
vgmstream->interleave_block_size = 0x1;
vgmstream->meta_type = meta_PCM_SCD;
/* open the file for reading */
{
int i;
STREAMFILE * file;
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
if (!file) goto fail;
for (i=0;i<channel_count;i++) {
vgmstream->ch[i].streamfile = file;
vgmstream->ch[i].channel_start_offset=
vgmstream->ch[i].offset=start_offset+
vgmstream->interleave_block_size*i;
}
/* open the file for reading */
{
int i;
STREAMFILE * file;
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
if (!file) goto fail;
for (i=0;i<channel_count;i++) {
vgmstream->ch[i].streamfile = file;
vgmstream->ch[i].channel_start_offset=
vgmstream->ch[i].offset=start_offset+
vgmstream->interleave_block_size*i;
}
}
return vgmstream;
@ -63,66 +63,66 @@ fail:
}
/* PCM - Custom header from Konami, which contains only loop infos...
found in: Ephemeral Fantasia [Reiselied]
Yu-Gi-Oh! The Duelists of the Roses [Yu-Gi-Oh! Shin Duel Monsters II]
*/
VGMSTREAM * init_vgmstream_pcm_ps2(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[260];
off_t start_offset;
int loop_flag = 0;
int channel_count;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("pcm",filename_extension(filename))) goto fail;
// if ((read_32bitLE(0x00,streamFile)+0x800) != (get_streamfile_size(streamFile)))
// goto fail;
if ((read_32bitLE(0x00,streamFile)) != (read_32bitLE(0x04,streamFile)*4))
goto fail;
loop_flag = (read_32bitLE(0x08,streamFile) != 0x0);
channel_count = 2;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
start_offset = 0x800;
vgmstream->channels = channel_count;
vgmstream->sample_rate = 22050;
vgmstream->coding_type = coding_PCM16LE;
vgmstream->num_samples = read_32bitLE(0x0,streamFile)/2/channel_count;
if (loop_flag) {
/* PCM - Custom header from Konami, which contains only loop infos...
found in: Ephemeral Fantasia [Reiselied]
Yu-Gi-Oh! The Duelists of the Roses [Yu-Gi-Oh! Shin Duel Monsters II]
*/
VGMSTREAM * init_vgmstream_pcm_ps2(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[260];
off_t start_offset;
int loop_flag = 0;
int channel_count;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("pcm",filename_extension(filename))) goto fail;
// if ((read_32bitLE(0x00,streamFile)+0x800) != (get_streamfile_size(streamFile)))
// goto fail;
if ((read_32bitLE(0x00,streamFile)) != (read_32bitLE(0x04,streamFile)*4))
goto fail;
loop_flag = (read_32bitLE(0x08,streamFile) != 0x0);
channel_count = 2;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
start_offset = 0x800;
vgmstream->channels = channel_count;
vgmstream->sample_rate = 22050;
vgmstream->coding_type = coding_PCM16LE;
vgmstream->num_samples = read_32bitLE(0x0,streamFile)/2/channel_count;
if (loop_flag) {
vgmstream->loop_start_sample = read_32bitLE(0x08,streamFile);
vgmstream->loop_end_sample = read_32bitLE(0x0C,streamFile);
}
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x2;
vgmstream->meta_type = meta_PCM_PS2;
/* open the file for reading */
{
int i;
STREAMFILE * file;
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
if (!file) goto fail;
for (i=0;i<channel_count;i++) {
vgmstream->ch[i].streamfile = file;
vgmstream->ch[i].channel_start_offset=
vgmstream->ch[i].offset=start_offset+
vgmstream->interleave_block_size*i;
}
}
return vgmstream;
/* clean up anything we may have opened */
fail:
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}
vgmstream->loop_end_sample = read_32bitLE(0x0C,streamFile);
}
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x2;
vgmstream->meta_type = meta_PCM_PS2;
/* open the file for reading */
{
int i;
STREAMFILE * file;
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
if (!file) goto fail;
for (i=0;i<channel_count;i++) {
vgmstream->ch[i].streamfile = file;
vgmstream->ch[i].channel_start_offset=
vgmstream->ch[i].offset=start_offset+
vgmstream->interleave_block_size*i;
}
}
return vgmstream;
/* clean up anything we may have opened */
fail:
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}

View File

@ -31,10 +31,10 @@ VGMSTREAM * init_vgmstream_ps2_mihb(STREAMFILE *streamFile) {
vgmstream->channels = channel_count;
vgmstream->sample_rate = read_32bitLE(0x0C,streamFile);
vgmstream->coding_type = coding_PSX;
vgmstream->num_samples = (read_32bitLE(0x10,streamFile))*mib_blocks*channel_count/32*28;
vgmstream->num_samples = ((read_32bitLE(0x10,streamFile))*mib_blocks)*28/16/channel_count;
if (loop_flag) {
vgmstream->loop_start_sample = 0;
vgmstream->loop_end_sample = (read_32bitLE(0x10,streamFile))*mib_blocks*channel_count/32*28;
vgmstream->loop_end_sample = ((read_32bitLE(0x10,streamFile))*mib_blocks)*28/16/channel_count;
}

View File

@ -185,7 +185,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = {
init_vgmstream_ngc_ssm,
init_vgmstream_ps2_joe,
init_vgmstream_vgs,
init_vgmstream_dc_wav_dcs,
init_vgmstream_dc_dcsw_dcs,
init_vgmstream_wii_smp,
init_vgmstream_emff_ps2,
init_vgmstream_emff_ngc,
@ -2227,8 +2227,8 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
case meta_VGS:
snprintf(temp,TEMPSIZE,"Guitar Hero Encore Rocks the 80's Header");
break;
case meta_DC_WAV_DCS:
snprintf(temp,TEMPSIZE,"Evil Twin WAV+DCS Header");
case meta_DC_DCSW_DCS:
snprintf(temp,TEMPSIZE,"Evil Twin DCS file with helper");
break;
case meta_WII_SMP:
snprintf(temp,TEMPSIZE,"SMP DSP Header");

View File

@ -330,7 +330,7 @@ typedef enum {
meta_STR_ASR, /* Donkey Kong Jet Race */
meta_ZWDSP, /* Zack and Wiki */
meta_VGS, /* Guitar Hero Encore - Rocks the 80s */
meta_DC_WAV_DCS, /* Evil Twin - Cypriens Chronicles (DC) */
meta_DC_DCSW_DCS, /* Evil Twin - Cypriens Chronicles (DC) */
meta_WII_SMP, /* Mushroom Men - The Spore Wars */
meta_WII_SNG, /* Excite Trucks */
meta_EMFF_PS2, /* Eidos Music File Format for PS2*/