Redo Angel STM: add PCM, adjust looping, unify code, add .lstm

This commit is contained in:
bnnm 2017-08-12 18:42:38 +02:00
parent 272b55cb3e
commit ade662e023
12 changed files with 142 additions and 298 deletions

View File

@ -162,6 +162,7 @@ DECLARE_MULTIPLE_FILE_TYPE("LOGG Audio File (*.LOGG)", logg);
DECLARE_MULTIPLE_FILE_TYPE("LPCM Audio File (*.LPCM)", lpcm); DECLARE_MULTIPLE_FILE_TYPE("LPCM Audio File (*.LPCM)", lpcm);
DECLARE_MULTIPLE_FILE_TYPE("LPS Audio File (*.LPS)", lps); DECLARE_MULTIPLE_FILE_TYPE("LPS Audio File (*.LPS)", lps);
DECLARE_MULTIPLE_FILE_TYPE("LSF Audio File (*.LSF)", lsf); DECLARE_MULTIPLE_FILE_TYPE("LSF Audio File (*.LSF)", lsf);
DECLARE_MULTIPLE_FILE_TYPE("LSTM Audio File (*.LSTM)", lstm);
DECLARE_MULTIPLE_FILE_TYPE("LWAV Audio File (*.LWAV)", lwav); DECLARE_MULTIPLE_FILE_TYPE("LWAV Audio File (*.LWAV)", lwav);
DECLARE_MULTIPLE_FILE_TYPE("MATX Audio File (*.MATX)", matx); DECLARE_MULTIPLE_FILE_TYPE("MATX Audio File (*.MATX)", matx);

View File

@ -32,7 +32,7 @@ static const char* extension_list[] = {
//"aiff", //common //"aiff", //common
"aix", "aix",
"akb", "akb",
"amts", "amts", //fake extension (to be removed)
"as4", "as4",
"asd", "asd",
"asf", "asf",
@ -147,14 +147,15 @@ static const char* extension_list[] = {
"kovs", "kovs",
"kraw", "kraw",
"laac", //fake extension, for tri-Ace/FFmpeg "laac", //fake extension, for AAC (tri-Ace/FFmpeg)
"leg", "leg",
"lmp4", //fake extension, for looping "lmp4", //fake extension, for MP4s
"logg", //fake extension, for looping "logg", //fake extension, for OGGs
"lpcm", "lpcm",
"lps", "lps",
"lsf", "lsf",
"lwav", //fake extension, for looping "lstm", //fake extension, for STMs
"lwav", //fake extension, for WAVs
"matx", "matx",
"mc3", "mc3",
@ -187,7 +188,7 @@ static const char* extension_list[] = {
"ndp", "ndp",
"ngca", "ngca",
"nps", "nps",
"npsf", "npsf", //fake extension (to be removed)
"nus3bank", "nus3bank",
"nwa", "nwa",
@ -206,7 +207,7 @@ static const char* extension_list[] = {
"pnb", "pnb",
"pona", "pona",
"pos", "pos",
"ps2stm", "ps2stm", //fake extension (to be removed)
"psh", "psh",
"psnd", "psnd",
"psw", "psw",
@ -266,7 +267,7 @@ static const char* extension_list[] = {
"ster", "ster",
"sth", "sth",
//"stm", //common //"stm", //common
"stma", "stma", //fake extension (to be removed)
"str", "str",
"strm", "strm",
"sts", "sts",
@ -660,7 +661,6 @@ static const meta_info meta_info_list[] = {
{meta_PS2_TEC, "assumed TECMO badflagged stream by .tec extension"}, {meta_PS2_TEC, "assumed TECMO badflagged stream by .tec extension"},
{meta_XBOX_WVS, "Metal Arms WVS Header (XBOX)"}, {meta_XBOX_WVS, "Metal Arms WVS Header (XBOX)"},
{meta_NGC_WVS, "Metal Arms WVS Header (GameCube)"}, {meta_NGC_WVS, "Metal Arms WVS Header (GameCube)"},
{meta_XBOX_STMA, "Midnight Club 2 STMA Header"},
{meta_XBOX_MATX, "assumed Matrix file by .matx extension"}, {meta_XBOX_MATX, "assumed Matrix file by .matx extension"},
{meta_DE2, "gurumin .de2 with embedded funky RIFF"}, {meta_DE2, "gurumin .de2 with embedded funky RIFF"},
{meta_VS, "Men in Black VS Header"}, {meta_VS, "Men in Black VS Header"},
@ -762,7 +762,6 @@ static const meta_info meta_info_list[] = {
{meta_WII_WAS, "WAS (iSWS) DSP header"}, {meta_WII_WAS, "WAS (iSWS) DSP header"},
{meta_XBOX_HLWAV, "Half Life 2 bgm header"}, {meta_XBOX_HLWAV, "Half Life 2 bgm header"},
{meta_STX, "Nintendo .stx header"}, {meta_STX, "Nintendo .stx header"},
{meta_PS2_STM, "Red Dead Revolver .stm (.ps2stm)"},
{meta_MYSPD, "U-Sing .myspd header"}, {meta_MYSPD, "U-Sing .myspd header"},
{meta_HIS, "Her Interactive Sound header"}, {meta_HIS, "Her Interactive Sound header"},
{meta_PS2_AST, "KOEI AST header"}, {meta_PS2_AST, "KOEI AST header"},
@ -874,6 +873,7 @@ static const meta_info meta_info_list[] = {
{meta_EA_BNK, "Electronic Arts BNK header"}, {meta_EA_BNK, "Electronic Arts BNK header"},
{meta_SK_AUD, "Silicon Knights AUD header"}, {meta_SK_AUD, "Silicon Knights AUD header"},
{meta_AHX, "CRI AHX header"}, {meta_AHX, "CRI AHX header"},
{meta_STM, "Angel Studios/Rockstar San Diego STMA header"},
#ifdef VGM_USE_VORBIS #ifdef VGM_USE_VORBIS
{meta_OGG_VORBIS, "Ogg Vorbis"}, {meta_OGG_VORBIS, "Ogg Vorbis"},

View File

@ -878,10 +878,6 @@
RelativePath=".\meta\ps2_ster.c" RelativePath=".\meta\ps2_ster.c"
> >
</File> </File>
<File
RelativePath=".\meta\ps2_stm.c"
>
</File>
<File <File
RelativePath=".\meta\ps2_str.c" RelativePath=".\meta\ps2_str.c"
> >
@ -1102,6 +1098,10 @@
RelativePath=".\meta\ss_stream.c" RelativePath=".\meta\ss_stream.c"
> >
</File> </File>
<File
RelativePath=".\meta\stm.c"
>
</File>
<File <File
RelativePath=".\meta\str_asr.c" RelativePath=".\meta\str_asr.c"
> >
@ -1242,10 +1242,6 @@
RelativePath=".\meta\xbox_ims.c" RelativePath=".\meta\xbox_ims.c"
> >
</File> </File>
<File
RelativePath=".\meta\xbox_stma.c"
>
</File>
<File <File
RelativePath=".\meta\xbox_wavm.c" RelativePath=".\meta\xbox_wavm.c"
> >

View File

@ -328,7 +328,6 @@
<ClCompile Include="meta\ps2_snd.c" /> <ClCompile Include="meta\ps2_snd.c" />
<ClCompile Include="meta\ps2_sps.c" /> <ClCompile Include="meta\ps2_sps.c" />
<ClCompile Include="meta\ps2_ster.c" /> <ClCompile Include="meta\ps2_ster.c" />
<ClCompile Include="meta\ps2_stm.c" />
<ClCompile Include="meta\ps2_str.c" /> <ClCompile Include="meta\ps2_str.c" />
<ClCompile Include="meta\ps2_svag.c" /> <ClCompile Include="meta\ps2_svag.c" />
<ClCompile Include="meta\ps2_svag_snk.c" /> <ClCompile Include="meta\ps2_svag_snk.c" />
@ -374,6 +373,7 @@
<ClCompile Include="meta\sli.c" /> <ClCompile Include="meta\sli.c" />
<ClCompile Include="meta\spt_spd.c" /> <ClCompile Include="meta\spt_spd.c" />
<ClCompile Include="meta\ss_stream.c" /> <ClCompile Include="meta\ss_stream.c" />
<ClCompile Include="meta\stm.c" />
<ClCompile Include="meta\str_asr.c" /> <ClCompile Include="meta\str_asr.c" />
<ClCompile Include="meta\str_snds.c" /> <ClCompile Include="meta\str_snds.c" />
<ClCompile Include="meta\stx.c" /> <ClCompile Include="meta\stx.c" />
@ -400,7 +400,6 @@
<ClCompile Include="meta\xau.c" /> <ClCompile Include="meta\xau.c" />
<ClCompile Include="meta\xbox_hlwav.c" /> <ClCompile Include="meta\xbox_hlwav.c" />
<ClCompile Include="meta\xbox_ims.c" /> <ClCompile Include="meta\xbox_ims.c" />
<ClCompile Include="meta\xbox_stma.c" />
<ClCompile Include="meta\xbox_wavm.c" /> <ClCompile Include="meta\xbox_wavm.c" />
<ClCompile Include="meta\xbox_xmu.c" /> <ClCompile Include="meta\xbox_xmu.c" />
<ClCompile Include="meta\xbox_xvas.c" /> <ClCompile Include="meta\xbox_xvas.c" />

View File

@ -526,9 +526,6 @@
<ClCompile Include="meta\ps2_ster.c"> <ClCompile Include="meta\ps2_ster.c">
<Filter>meta\Source Files</Filter> <Filter>meta\Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="meta\ps2_stm.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\ps2_str.c"> <ClCompile Include="meta\ps2_str.c">
<Filter>meta\Source Files</Filter> <Filter>meta\Source Files</Filter>
</ClCompile> </ClCompile>
@ -664,6 +661,9 @@
<ClCompile Include="meta\ss_stream.c"> <ClCompile Include="meta\ss_stream.c">
<Filter>meta\Source Files</Filter> <Filter>meta\Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="meta\stm.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\str_asr.c"> <ClCompile Include="meta\str_asr.c">
<Filter>meta\Source Files</Filter> <Filter>meta\Source Files</Filter>
</ClCompile> </ClCompile>
@ -748,9 +748,6 @@
<ClCompile Include="meta\xbox_ims.c"> <ClCompile Include="meta\xbox_ims.c">
<Filter>meta\Source Files</Filter> <Filter>meta\Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="meta\xbox_stma.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\xbox_wavm.c"> <ClCompile Include="meta\xbox_wavm.c">
<Filter>meta\Source Files</Filter> <Filter>meta\Source Files</Filter>
</ClCompile> </ClCompile>

View File

@ -88,10 +88,6 @@ VGMSTREAM * init_vgmstream_ps2_vpk(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile); VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_amts(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_xbox_stma(STREAMFILE *streamFile);
#ifdef VGM_USE_VORBIS #ifdef VGM_USE_VORBIS
VGMSTREAM * init_vgmstream_ogg_vorbis(STREAMFILE *streamFile); VGMSTREAM * init_vgmstream_ogg_vorbis(STREAMFILE *streamFile);
@ -462,8 +458,6 @@ VGMSTREAM * init_vgmstream_xbox_hlwav(STREAMFILE* streamFile);
VGMSTREAM * init_vgmstream_stx(STREAMFILE* streamFile); VGMSTREAM * init_vgmstream_stx(STREAMFILE* streamFile);
VGMSTREAM * init_vgmstream_ps2_stm(STREAMFILE* streamFile);
VGMSTREAM * init_vgmstream_myspd(STREAMFILE* streamFile); VGMSTREAM * init_vgmstream_myspd(STREAMFILE* streamFile);
VGMSTREAM * init_vgmstream_his(STREAMFILE* streamFile); VGMSTREAM * init_vgmstream_his(STREAMFILE* streamFile);
@ -686,4 +680,6 @@ VGMSTREAM * init_vgmstream_ea_schl_fixed(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_sk_aud(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_sk_aud(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_stm(STREAMFILE * streamFile);
#endif /*_META_H*/ #endif /*_META_H*/

View File

@ -920,122 +920,6 @@ fail:
return NULL; return NULL;
} }
/* AMTS - .amts files */
VGMSTREAM * init_vgmstream_amts(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[PATH_LIMIT];
off_t start_offset;
off_t interleave;
int channel_count;
struct dsp_header ch0_header,ch1_header;
int i;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("amts",filename_extension(filename))) goto fail;
/* check header magic */
if (read_32bitBE(0x0,streamFile) != 0x414D5453) goto fail; /* "sadb" */
channel_count=read_32bitBE(0x14,streamFile);
start_offset = 0x800;
interleave = read_32bitBE(0x08,streamFile);
if (read_dsp_header(&ch0_header, 0x20, streamFile)) goto fail;
/* check initial predictor/scale */
if (ch0_header.initial_ps != (uint8_t)read_8bit(start_offset,streamFile))
goto fail;
if(channel_count==2) {
if (read_dsp_header(&ch1_header, 0x80, streamFile)) goto fail;
if (ch1_header.initial_ps != (uint8_t)read_8bit(start_offset+interleave,streamFile))
goto fail;
/* check type==0 and gain==0 */
if (ch0_header.format || ch0_header.gain ||
ch1_header.format || ch1_header.gain)
goto fail;
/* check for agreement */
if (
ch0_header.sample_count != ch1_header.sample_count ||
ch0_header.nibble_count != ch1_header.nibble_count ||
ch0_header.sample_rate != ch1_header.sample_rate ||
ch0_header.loop_flag != ch1_header.loop_flag ||
ch0_header.loop_start_offset != ch1_header.loop_start_offset ||
ch0_header.loop_end_offset != ch1_header.loop_end_offset
) goto fail;
if (ch0_header.loop_flag) {
off_t loop_off;
/* check loop predictor/scale */
loop_off = ch0_header.loop_start_offset/16*8;
loop_off = (loop_off/interleave*interleave*2) + (loop_off%interleave);
if (ch0_header.loop_ps != (uint8_t)read_8bit(start_offset+loop_off,streamFile))
goto fail;
if (ch1_header.loop_ps != (uint8_t)read_8bit(start_offset+loop_off+interleave,streamFile))
goto fail;
}
}
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,ch0_header.loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
vgmstream->num_samples = ch0_header.sample_count;
vgmstream->sample_rate = ch0_header.sample_rate;
/* TODO: adjust for interleave? */
vgmstream->loop_start_sample = dsp_nibbles_to_samples(
ch0_header.loop_start_offset);
vgmstream->loop_end_sample = dsp_nibbles_to_samples(
ch0_header.loop_end_offset)+1;
vgmstream->coding_type = coding_NGC_DSP;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = interleave;
vgmstream->meta_type = meta_DSP_AMTS;
/* coeffs */
for (i=0;i<16;i++) {
vgmstream->ch[0].adpcm_coef[i] = ch0_header.coef[i];
vgmstream->ch[1].adpcm_coef[i] = ch1_header.coef[i];
}
/* initial history */
/* always 0 that I've ever seen, but for completeness... */
vgmstream->ch[0].adpcm_history1_16 = ch0_header.initial_hist1;
vgmstream->ch[0].adpcm_history2_16 = ch0_header.initial_hist2;
vgmstream->ch[0].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
if(channel_count==2) {
vgmstream->ch[1].adpcm_history1_16 = ch1_header.initial_hist1;
vgmstream->ch[1].adpcm_history2_16 = ch1_header.initial_hist2;
vgmstream->ch[1].streamfile = vgmstream->ch[0].streamfile;
}
if (!vgmstream->ch[0].streamfile) goto fail;
/* open the file for reading */
for (i=0;i<channel_count;i++) {
vgmstream->ch[i].channel_start_offset=
vgmstream->ch[i].offset=start_offset+i*interleave;
}
return vgmstream;
fail:
/* clean up anything we may have opened */
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}
/* .wsi as found in Alone in the Dark for Wii */ /* .wsi as found in Alone in the Dark for Wii */
/* These appear to be standard .dsp, but interleaved in a blocked format */ /* These appear to be standard .dsp, but interleaved in a blocked format */

View File

@ -1,78 +0,0 @@
#include "meta.h"
#include "../util.h"
/* STM: Red Dead Revolver */
VGMSTREAM * init_vgmstream_ps2_stm(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[PATH_LIMIT];
off_t start_offset;
int loop_flag;
int channel_count;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("ps2stm",filename_extension(filename))) goto fail;
/* check header */
if (read_32bitBE(0x0,streamFile) != 0x53544d41) goto fail;
if (read_32bitBE(0x4,streamFile) != 0x6b690000) goto fail;
/* check bps */
if (read_32bitLE(0x10,streamFile) != 4) goto fail;
loop_flag = read_32bitLE(0x20,streamFile);
channel_count = read_32bitLE(0x14,streamFile);
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
start_offset = 0x800;
vgmstream->sample_rate = (uint16_t)read_32bitLE(0xc,streamFile);
vgmstream->coding_type = coding_DVI_IMA_int;
vgmstream->num_samples = read_32bitLE(0x18,streamFile);
//vgmstream->interleave_block_size = read_32bitLE(0x8,streamFile) / channel_count;
vgmstream->interleave_block_size = 0x40;
if(1 < channel_count)
{
/* not sure if this is right ... */
vgmstream->layout_type = layout_interleave;
} else {
vgmstream->layout_type = layout_none;
}
vgmstream->meta_type = meta_PS2_STM;
if(loop_flag) {
vgmstream->loop_start_sample=read_32bitLE(0x24,streamFile);
vgmstream->loop_end_sample=vgmstream->num_samples;
}
/* 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;
}

118
src/meta/stm.c Normal file
View File

@ -0,0 +1,118 @@
#include "meta.h"
#include "../coding/coding.h"
/* STM - from Angel Studios/Rockstar San Diego games (Red Dead Revolver, Midnight Club 2, TransWorld Surf) */
VGMSTREAM * init_vgmstream_stm(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
off_t start_offset;
int loop_flag = 0, channel_count;
int big_endian, bps, interleave, data_size, loop_start = 0, loop_end = 0;
int32_t (*read_32bit)(off_t,STREAMFILE*) = NULL;
int16_t (*read_16bit)(off_t,STREAMFILE*) = NULL;
/* check extension, case insensitive
* .stm is the real ext but common, rename to .lstm or .stma/amts/ps2stm (older) */
if ( !check_extensions(streamFile,"stm,lstm,stma,amts,ps2stm"))
goto fail;
/* check header */
if ((read_32bitBE(0x00,streamFile) != 0x53544d41) && /* "SMTA" (LE) */
(read_32bitBE(0x00,streamFile) != 0x414D5453)) /* "AMTS" (BE) */
goto fail;
/* 0x04: revision (696F/696B/696A/6969) */
big_endian = (read_32bitBE(0x00,streamFile) == 0x414D5453);
if (big_endian) {
read_32bit = read_32bitBE;
read_16bit = read_16bitBE;
} else {
read_32bit = read_32bitLE;
read_16bit = read_16bitLE;
}
start_offset = 0x800;
interleave = read_32bit(0x08,streamFile);
bps = read_32bit(0x10,streamFile);
channel_count = read_32bit(0x14,streamFile);
data_size = read_32bit(0x18,streamFile);
loop_end = read_32bit(0x1c,streamFile); /* absolute offset */
if (data_size + start_offset != get_streamfile_size(streamFile)) goto fail;
if (big_endian) {
/* GC AMTS have a regular DSP header beyond 0x20, just use what we need, no point on validating all fields */
loop_flag = read_16bit(0x2c,streamFile);
}
else {
/* PS2/Xbox STMA have either loop info or padding beyond 0x20 */
if (read_32bit(0x20,streamFile) == 1) { /* may contain 0xCCCCCCCC garbage */
loop_flag = 1;
loop_start = read_32bit(0x24,streamFile);
/* 0x28 (32b * ch): loop start hist+step per channel */ //todo setup
}
#if 0
/* this works for some files that do full repeats, but also repeats many SFX */
else if (data_size != loop_end && data_size != loop_end - 0x100) { /* data_size vs adjusted loop_end */
loop_flag = 1;
}
#endif
}
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
vgmstream->sample_rate = read_32bit(0xc,streamFile);
vgmstream->meta_type = meta_STM;
vgmstream->layout_type = (channel_count > 1) ? layout_interleave : layout_none;
switch(bps) {
case 4:
if (big_endian) { /* GC DSP ADPCM (TransWorld Surf GC) */
vgmstream->coding_type = coding_NGC_DSP;
vgmstream->interleave_block_size = interleave;
vgmstream->num_samples = read_32bit(0x20,streamFile);
vgmstream->loop_start_sample = dsp_nibbles_to_samples(read_32bit(0x30,streamFile));
vgmstream->loop_end_sample = dsp_nibbles_to_samples(read_32bit(0x34,streamFile))+1;
dsp_read_coefs_be(vgmstream, streamFile, 0x3c, 0x60);
dsp_read_hist_be(vgmstream, streamFile, 0x60, 0x60);
}
else { /* DVI IMA ADPCM (Red Dead Revolver, Midnight Club 2) */
vgmstream->coding_type = coding_DVI_IMA_int;
/* 'interleave not' reliable, strange values and rarely needs 0x80 */
vgmstream->interleave_block_size = (interleave == 0xc000) ? 0x80 : 0x40;
vgmstream->num_samples = ima_bytes_to_samples(data_size, vgmstream->channels);
vgmstream->loop_start_sample = loop_start;
vgmstream->loop_end_sample = ima_bytes_to_samples(loop_end - start_offset, vgmstream->channels);
}
break;
case 16: /* PCM (Spy Hunter 2 PS2, rare) */
vgmstream->coding_type = big_endian ? coding_PCM16BE : coding_PCM16LE;
vgmstream->interleave_block_size = 0x02; /* interleave not always reliable */
vgmstream->num_samples = pcm_bytes_to_samples(data_size, vgmstream->channels, bps);
vgmstream->loop_start_sample = loop_start;
vgmstream->loop_end_sample = pcm_bytes_to_samples(loop_end - start_offset, vgmstream->channels, bps);
break;
default:
VGM_LOG("STM: unknown bps %i\n", bps);
goto fail;
}
if ( !vgmstream_open_stream(vgmstream,streamFile,start_offset) )
goto fail;
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}

View File

@ -1,64 +0,0 @@
#include "meta.h"
#include "../util.h"
/* STMA
STMA (found in Midnight Club 2)
*/
VGMSTREAM * init_vgmstream_xbox_stma(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[PATH_LIMIT];
int loop_flag=0;
int channel_count;
int i;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("stma",filename_extension(filename))) goto fail;
if(read_32bitBE(0x0,streamFile)!=0x53544D41)
goto fail;
loop_flag = ((read_32bitLE(0x20,streamFile)==1) || (read_32bitLE(0x18,streamFile)>read_32bitLE(0x1C,streamFile)));
/* Seems that the loop flag is not allways well defined */
/* Some of the tracks should loop, but without flag set */
channel_count=read_32bitLE(0x14,streamFile);
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
vgmstream->channels = channel_count;
vgmstream->sample_rate = read_32bitLE(0x0C,streamFile);
vgmstream->coding_type = coding_DVI_IMA_int;
vgmstream->num_samples = read_32bitLE(0x18,streamFile)*2/vgmstream->channels;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size=0x40;
vgmstream->meta_type = meta_XBOX_STMA;
if(loop_flag) {
vgmstream->loop_start_sample=read_32bitLE(0x24,streamFile);
vgmstream->loop_end_sample=vgmstream->num_samples;
}
/* open the file for reading by each channel */
{
for (i=0;i<channel_count;i++) {
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,36);
vgmstream->ch[i].offset = 0x800+(i*vgmstream->interleave_block_size);
if (!vgmstream->ch[i].streamfile) goto fail;
}
}
return vgmstream;
/* clean up anything we may have opened */
fail:
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}

View File

@ -47,7 +47,6 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = {
init_vgmstream_ps2_rxws, init_vgmstream_ps2_rxws,
init_vgmstream_ps2_rxw, init_vgmstream_ps2_rxw,
init_vgmstream_ps2_int, init_vgmstream_ps2_int,
init_vgmstream_ngc_dsp_stm,
init_vgmstream_ps2_exst, init_vgmstream_ps2_exst,
init_vgmstream_ps2_svag, init_vgmstream_ps2_svag,
init_vgmstream_ps2_mib, init_vgmstream_ps2_mib,
@ -86,7 +85,6 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = {
init_vgmstream_ws_aud, init_vgmstream_ws_aud,
init_vgmstream_ahx, init_vgmstream_ahx,
init_vgmstream_ivb, init_vgmstream_ivb,
init_vgmstream_amts,
init_vgmstream_svs, init_vgmstream_svs,
init_vgmstream_riff, init_vgmstream_riff,
init_vgmstream_rifx, init_vgmstream_rifx,
@ -139,7 +137,6 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = {
init_vgmstream_ngc_wvs, init_vgmstream_ngc_wvs,
init_vgmstream_dc_str, init_vgmstream_dc_str,
init_vgmstream_dc_str_v2, init_vgmstream_dc_str_v2,
init_vgmstream_xbox_stma,
init_vgmstream_xbox_matx, init_vgmstream_xbox_matx,
init_vgmstream_de2, init_vgmstream_de2,
init_vgmstream_vs, init_vgmstream_vs,
@ -252,7 +249,6 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = {
init_vgmstream_pona_psx, init_vgmstream_pona_psx,
init_vgmstream_xbox_hlwav, init_vgmstream_xbox_hlwav,
init_vgmstream_stx, init_vgmstream_stx,
init_vgmstream_ps2_stm,
init_vgmstream_myspd, init_vgmstream_myspd,
init_vgmstream_his, init_vgmstream_his,
init_vgmstream_ps2_ast, init_vgmstream_ps2_ast,
@ -369,6 +365,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = {
init_vgmstream_ea_bnk, init_vgmstream_ea_bnk,
init_vgmstream_ea_schl_fixed, init_vgmstream_ea_schl_fixed,
init_vgmstream_sk_aud, init_vgmstream_sk_aud,
init_vgmstream_stm,
init_vgmstream_txth, /* should go at the end (lower priority) */ init_vgmstream_txth, /* should go at the end (lower priority) */
#ifdef VGM_USE_FFMPEG #ifdef VGM_USE_FFMPEG
@ -378,7 +375,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = {
/* internal version with all parameters */ /* internal version with all parameters */
VGMSTREAM * init_vgmstream_internal(STREAMFILE *streamFile, int do_dfs) { static VGMSTREAM * init_vgmstream_internal(STREAMFILE *streamFile, int do_dfs) {
int i, fcns_size; int i, fcns_size;
if (!streamFile) if (!streamFile)

View File

@ -265,7 +265,6 @@ typedef enum {
meta_DSP_STR, /* Conan .str files */ meta_DSP_STR, /* Conan .str files */
meta_DSP_SADB, /* .sad */ meta_DSP_SADB, /* .sad */
meta_DSP_WSI, /* .wsi */ meta_DSP_WSI, /* .wsi */
meta_DSP_AMTS, /* .amts */
meta_DSP_WII_IDSP, /* .gcm with IDSP header */ meta_DSP_WII_IDSP, /* .gcm with IDSP header */
meta_DSP_WII_MUS, /* .mus */ meta_DSP_WII_MUS, /* .mus */
meta_DSP_WII_WSD, /* Phantom Brave (WII) */ meta_DSP_WII_WSD, /* Phantom Brave (WII) */
@ -437,7 +436,6 @@ typedef enum {
meta_ADS, /* Gauntlet Dark Legends (GC) */ meta_ADS, /* Gauntlet Dark Legends (GC) */
meta_PS2_SPS, /* Ape Escape 2 */ meta_PS2_SPS, /* Ape Escape 2 */
meta_PS2_XA2_RRP, /* RC Revenge Pro */ meta_PS2_XA2_RRP, /* RC Revenge Pro */
meta_PS2_STM, /* Red Dead Revolver .stm, renamed .ps2stm */
meta_NGC_DSP_KONAMI, /* Konami DSP header, found in various games */ meta_NGC_DSP_KONAMI, /* Konami DSP header, found in various games */
meta_UBI_CKD, /* Ubisoft CKD RIFF header (Rayman Origins Wii) */ meta_UBI_CKD, /* Ubisoft CKD RIFF header (Rayman Origins Wii) */
@ -445,7 +443,6 @@ typedef enum {
meta_XBOX_RIFF, /* XBOX RIFF/WAVE File */ meta_XBOX_RIFF, /* XBOX RIFF/WAVE File */
meta_XBOX_WVS, /* XBOX WVS */ meta_XBOX_WVS, /* XBOX WVS */
meta_NGC_WVS, /* Metal Arms - Glitch in the System */ meta_NGC_WVS, /* Metal Arms - Glitch in the System */
meta_XBOX_STMA, /* XBOX STMA */
meta_XBOX_MATX, /* XBOX MATX */ meta_XBOX_MATX, /* XBOX MATX */
meta_XBOX_XMU, /* XBOX XMU */ meta_XBOX_XMU, /* XBOX XMU */
meta_XBOX_XVAS, /* XBOX VAS */ meta_XBOX_XVAS, /* XBOX VAS */
@ -617,6 +614,7 @@ typedef enum {
meta_TXTH, /* generic text header */ meta_TXTH, /* generic text header */
meta_SK_AUD, /* Silicon Knights .AUD (Eternal Darkness GC) */ meta_SK_AUD, /* Silicon Knights .AUD (Eternal Darkness GC) */
meta_AHX, /* CRI AHX header */ meta_AHX, /* CRI AHX header */
meta_STM, /* Angel Studios/Rockstar San Diego Games */
#ifdef VGM_USE_VORBIS #ifdef VGM_USE_VORBIS
meta_OGG_VORBIS, /* Ogg Vorbis */ meta_OGG_VORBIS, /* Ogg Vorbis */