Merge pull request #346 from bnnm/smp-sb

smp sb
This commit is contained in:
Christopher Snowhill 2019-01-04 20:02:49 -08:00 committed by GitHub
commit 28c27bc12a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 1047 additions and 991 deletions

View File

@ -907,7 +907,7 @@ static const meta_info meta_info_list[] = {
{meta_PS2_JOE, "Asobo Studio .JOE header"},
{meta_VGS, "Guitar Hero VGS Header"},
{meta_DC_DCSW_DCS, "Evil Twin DCS file with helper"},
{meta_WII_SMP, "SMP DSP Header"},
{meta_SMP, "Infernal Engine .smp header"},
{meta_MUL, "Crystal Dynamics .MUL header"},
{meta_THP, "THP Movie File Format Header"},
{meta_STS_WII, "Shikigami no Shiro (WII) Header"},
@ -969,7 +969,6 @@ static const meta_info meta_info_list[] = {
{meta_PS2_GCM, "GCM 'MCG' Header"},
{meta_PS2_SMPL, "Homura SMPL header"},
{meta_PS2_MSA, "Success .MSA header"},
{meta_PC_SMP, "Ghostbusters .smp Header"},
{meta_NGC_PDT, "Hudson .PDT header"},
{meta_NGC_RKV, "Legacy of Kain - Blood Omen 2 RKV GC header"},
{meta_DSP_DDSP, ".DDSP header"},

View File

@ -922,10 +922,6 @@
RelativePath=".\meta\pc_mxst.c"
>
</File>
<File
RelativePath=".\meta\pc_smp.c"
>
</File>
<File
RelativePath=".\meta\pc_snds.c"
>
@ -1390,6 +1386,10 @@
RelativePath=".\meta\smc_smh.c"
>
</File>
<File
RelativePath=".\meta\smp.c"
>
</File>
<File
RelativePath=".\meta\smv.c"
>
@ -1550,10 +1550,6 @@
RelativePath=".\meta\wii_ras.c"
>
</File>
<File
RelativePath=".\meta\wii_smp.c"
>
</File>
<File
RelativePath=".\meta\wii_sng.c"
>

View File

@ -336,7 +336,6 @@
<ClCompile Include="meta\p3d.c" />
<ClCompile Include="meta\pc_al2.c" />
<ClCompile Include="meta\pc_mxst.c" />
<ClCompile Include="meta\pc_smp.c" />
<ClCompile Include="meta\sab.c" />
<ClCompile Include="meta\pc_xa30.c" />
<ClCompile Include="meta\pcm_sre.c" />
@ -434,6 +433,7 @@
<ClCompile Include="meta\sfl.c" />
<ClCompile Include="meta\sli.c" />
<ClCompile Include="meta\smc_smh.c" />
<ClCompile Include="meta\smp.c" />
<ClCompile Include="meta\smv.c" />
<ClCompile Include="meta\sps_n1.c" />
<ClCompile Include="meta\spt_spd.c" />
@ -466,7 +466,6 @@
<ClCompile Include="meta\wii_04sw.c" />
<ClCompile Include="meta\wii_bns.c" />
<ClCompile Include="meta\wii_mus.c" />
<ClCompile Include="meta\wii_smp.c" />
<ClCompile Include="meta\wii_sng.c" />
<ClCompile Include="meta\wii_sts.c" />
<ClCompile Include="meta\ws_aud.c" />

View File

@ -565,9 +565,6 @@
<ClCompile Include="meta\pc_mxst.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\pc_smp.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\sab.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
@ -859,6 +856,9 @@
<ClCompile Include="meta\smc_smh.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\smp.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\smv.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
@ -955,9 +955,6 @@
<ClCompile Include="meta\wii_mus.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\wii_smp.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\wii_sng.c">
<Filter>meta\Source Files</Filter>
</ClCompile>

View File

@ -133,53 +133,6 @@ fail:
return NULL;
}
/* .SPS - from Frostbite engine games, v1 header */
VGMSTREAM * init_vgmstream_ea_sps_fb(STREAMFILE *streamFile) { //todo remove in the future, use better extractors
VGMSTREAM * vgmstream = NULL;
off_t start_offset = 0, header_offset = 0, sps_offset, max_offset;
/* checks */
/* should be .sps once extracted (filenames are hashed) */
if (!check_extensions(streamFile,"sps"))
goto fail;
if (read_32bitBE(0x00,streamFile) != 0x011006C0 && /* Need for Speed: The Run (PS3), Need for Speed: Rivals (PS4) */
read_32bitBE(0x00,streamFile) != 0x01100180 && /* Need for Speed: The Run (X360) */
read_32bitBE(0x00,streamFile) != 0x01100000) /* Need for Speed: The Run (PC) */
goto fail;
/* file has a Frostbite descriptor (SoundWaveAsset segments) data before actual .sps, exact size unknown.
* 0x00: segments/flags/sizes? 0x04: SegmentLength?, 0x08: SeekTableOffset?, 0x0c: mini SPS header
* rest: unknown fields? may be padded? (ex. 0x22 > 0x24, 0x1d > 0x20 */
/* actual offsets are probably somewhere but for now just manually search. */
sps_offset = read_32bitBE(0x08, streamFile); /* seek table, number of entries unknown */
max_offset = sps_offset + 0x3000;
if (max_offset > get_streamfile_size(streamFile))
max_offset = get_streamfile_size(streamFile);
/* find .sps start block */
while (sps_offset < max_offset) {
if ((read_32bitBE(sps_offset, streamFile) & 0xFFFFFF00) == 0x48000000) {
header_offset = sps_offset + 0x04;
start_offset = sps_offset + (read_32bitBE(sps_offset, streamFile) & 0x00FFFFFF);
break;
}
sps_offset += 0x04;
}
if (!start_offset)
goto fail; /* not found */
vgmstream = init_vgmstream_eaaudiocore_header(streamFile, streamFile, header_offset, start_offset, meta_EA_SPS);
if (!vgmstream) goto fail;
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}
/* EA ABK - ABK header seems to be same as in the old games but the sound table is different and it contains SNR/SNS sounds instead */
VGMSTREAM * init_vgmstream_ea_abk_new(STREAMFILE *streamFile) {
int is_dupe, total_sounds = 0, target_stream = streamFile->stream_index;
@ -467,9 +420,8 @@ VGMSTREAM * init_vgmstream_ea_mpf_mus_new(STREAMFILE *streamFile) {
uint32_t num_sounds;
uint8_t version, sub_version, block_id;
off_t table_offset, entry_offset, snr_offset, sns_offset;
size_t snr_size, sns_size;
size_t /*snr_size,*/ sns_size;
int32_t(*read_32bit)(off_t, STREAMFILE*);
int16_t(*read_16bit)(off_t, STREAMFILE*);
STREAMFILE *musFile = NULL;
VGMSTREAM *vgmstream = NULL;
int target_stream = streamFile->stream_index;
@ -481,10 +433,8 @@ VGMSTREAM * init_vgmstream_ea_mpf_mus_new(STREAMFILE *streamFile) {
/* detect endianness */
if (read_32bitBE(0x00, streamFile) == 0x50464478) { /* "PFDx" */
read_32bit = read_32bitBE;
read_16bit = read_16bitBE;
} else if (read_32bitBE(0x00, streamFile) == 0x78444650) { /* "xDFP" */
read_32bit = read_32bitLE;
read_16bit = read_16bitLE;
} else {
goto fail;
}
@ -520,7 +470,7 @@ VGMSTREAM * init_vgmstream_ea_mpf_mus_new(STREAMFILE *streamFile) {
entry_offset = table_offset + (target_stream - 1) * 0x1c;
snr_offset = read_32bit(entry_offset + 0x08, musFile) * 0x10;
sns_offset = read_32bit(entry_offset + 0x0c, musFile) * 0x80;
snr_size = read_32bit(entry_offset + 0x10, musFile);
//snr_size = read_32bit(entry_offset + 0x10, musFile);
sns_size = read_32bit(entry_offset + 0x14, musFile);
block_id = read_8bit(sns_offset, musFile);

View File

@ -360,8 +360,6 @@ VGMSTREAM * init_vgmstream_vgs(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_dc_dcsw_dcs(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_wii_smp(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_mul(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_thp(STREAMFILE *streamFile);
@ -476,8 +474,6 @@ VGMSTREAM * init_vgmstream_ps2_voi(STREAMFILE* streamFile);
VGMSTREAM * init_vgmstream_ps2_khv(STREAMFILE* streamFile);
VGMSTREAM * init_vgmstream_pc_smp(STREAMFILE* streamFile);
VGMSTREAM * init_vgmstream_ngc_rkv(STREAMFILE* streamFile);
VGMSTREAM * init_vgmstream_p3d(STREAMFILE* streamFile);
@ -736,8 +732,6 @@ VGMSTREAM * init_vgmstream_txtp(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_smc_smh(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_ea_sps_fb(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_ppst(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_opus_sps_n1_segmented(STREAMFILE *streamFile);
@ -827,4 +821,6 @@ VGMSTREAM * init_vgmstream_nus3audio(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_imc(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_imc_container(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_smp(STREAMFILE * streamFile);
#endif /*_META_H*/

View File

@ -1,93 +0,0 @@
#include "meta.h"
#include "../layout/layout.h"
#include "../util.h"
/* .smp file, with MS ADPCM. From Ghostbusters (PC). */
VGMSTREAM * init_vgmstream_pc_smp(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[PATH_LIMIT];
int channel_count;
off_t start_offset;
int interleave;
int loop_flag = 0;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("smp",filename_extension(filename))) goto fail;
/* 6? */
if (6 != read_32bitLE(0,streamFile)) goto fail;
if (0 != read_32bitLE(0x14,streamFile)) goto fail;
if (4 != read_32bitLE(0x24,streamFile)) goto fail;
if (4 != read_32bitLE(0x2C,streamFile)) goto fail;
start_offset = read_32bitLE(0x1c, streamFile);
/* check body start + body size = total size */
if (start_offset + read_32bitLE(0x20,streamFile) != get_streamfile_size(streamFile)) goto fail;
/* might also be codec id? */
channel_count = read_32bitLE(0x28,streamFile);
if (channel_count != 1 && channel_count != 2) goto fail;
/* verify MS ADPCM codec setup */
{
int i;
/* coefficients and statement of 0x100 samples per block?? */
static const uint8_t ms_setup[0x20] = {
0x00,0x01,0x07,0x00,0x00,0x01,0x00,0x00,
0x00,0x02,0x00,0xFF,0x00,0x00,0x00,0x00,
0xC0,0x00,0x40,0x00,0xF0,0x00,0x00,0x00,
0xCC,0x01,0x30,0xFF,0x88,0x01,0x18,0xFF};
for (i = 0; i < 0x20; i++)
{
if ((uint8_t)read_8bit(0x34+i,streamFile) != ms_setup[i]) goto fail;
}
/* verify padding */
for (i = 0x20; i+0x34 < start_offset; i++)
{
if (read_8bit(0x34+i,streamFile) != 0) goto fail;
}
}
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
vgmstream->num_samples = read_32bitLE(0x18,streamFile);
vgmstream->sample_rate = read_32bitLE(0x30,streamFile);
vgmstream->coding_type = coding_MSADPCM;
vgmstream->layout_type = layout_none; // MS ADPCM does own interleave
interleave = 0x86*channel_count;
vgmstream->interleave_block_size = interleave;
vgmstream->meta_type = meta_PC_SMP;
/* open the file, set up each channel */
{
int i;
vgmstream->ch[0].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
if (!vgmstream->ch[0].streamfile) goto fail;
for (i=0;i<channel_count;i++) {
vgmstream->ch[i].streamfile = vgmstream->ch[0].streamfile;
vgmstream->ch[i].offset = vgmstream->ch[i].channel_start_offset =
start_offset;
}
}
return vgmstream;
/* clean up anything we may have opened */
fail:
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}

130
src/meta/smp.c Normal file
View File

@ -0,0 +1,130 @@
#include "meta.h"
#include "../coding/coding.h"
/* .smp - Terminal Reality's Infernal Engine 'samples' [Ghostbusters: The Video Game (PS2/PS3/X360/PC/PSP), Chandragupta (PS2/PSP)] */
VGMSTREAM * init_vgmstream_smp(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
off_t start_offset;
int loop_flag, channel_count, sample_rate, codec, version, num_samples, bps;
size_t data_size;
/* checks */
if (!check_extensions(streamFile, "smp"))
goto fail;
version = read_32bitLE(0x00,streamFile);
if (version != 0x05 && /* Ghostbusters (PS2), Mushroom Men (Wii) */
version != 0x06 && /* Ghostbusters (PS3/X360/PC) */
version != 0x07 && /* Ghostbusters (PSP) */
version != 0x08) /* Chandragupta (PS2/PSP), Street Cricket Champions 1/2 (PSP) */
goto fail;
/* 0x04~14: guid? */
if (read_32bitLE(0x14,streamFile) != 0) /* reserved? */
goto fail;
num_samples = read_32bitLE(0x18,streamFile);
start_offset = read_32bitLE(0x1c,streamFile);
data_size = read_32bitLE(0x20,streamFile);
codec = read_32bitLE(0x24,streamFile);
channel_count = read_32bitLE(0x28,streamFile);
bps = read_32bitLE(0x2c,streamFile);
sample_rate = read_32bitLE(0x30,streamFile);
loop_flag = 0;
if (start_offset + data_size != get_streamfile_size(streamFile))
goto fail;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count, loop_flag);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_SMP;
vgmstream->sample_rate = sample_rate;
vgmstream->num_samples = num_samples;
switch(codec) {
#ifdef VGM_USE_FFMPEG
case 0x01: {
uint8_t buf[0x100];
int bytes, block_size, joint_stereo, skip_samples;
if (bps != 16) goto fail;
block_size = 0x98 * vgmstream->channels;
joint_stereo = 0;
skip_samples = 0; /* unknown */
bytes = ffmpeg_make_riff_atrac3(buf,sizeof(buf), vgmstream->num_samples, data_size, vgmstream->channels, vgmstream->sample_rate, block_size, joint_stereo, skip_samples);
vgmstream->codec_data = init_ffmpeg_header_offset(streamFile, buf,bytes, start_offset,data_size);
if (!vgmstream->codec_data) goto fail;
vgmstream->coding_type = coding_FFmpeg;
vgmstream->layout_type = layout_none;
break;
}
#endif
case 0x02:
if (bps != 4) goto fail;
if (channel_count > 1) goto fail; /* not known */
/* 0x34: standard DSP header, but LE */
vgmstream->coding_type = coding_NGC_DSP;
vgmstream->layout_type = layout_none;
dsp_read_coefs_le(vgmstream,streamFile,0x50,0x00);
break;
case 0x04:
if (bps != 4) goto fail;
/* 0x34: standard MSADPCM coef table */
vgmstream->coding_type = coding_MSADPCM;
vgmstream->layout_type = layout_none;
vgmstream->interleave_block_size = 0x86*channel_count;
break;
case 0x06:
if (bps != 4) goto fail;
if (channel_count > 1) goto fail; /* not known */
vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_none;
break;
#ifdef VGM_USE_FFMPEG
case 0x07: {
uint8_t buf[0x100];
int bytes, block_size, block_count;
if (bps != 16) goto fail;
/* 0x34(0x28): XMA config/table? */
block_size = 0x8000; /* assumed, @0x3e(2)? */
block_count = data_size / block_size + (data_size % block_size ? 1 : 0); /* @0x54(2)? */
bytes = ffmpeg_make_riff_xma2(buf,0x100, vgmstream->num_samples, data_size, vgmstream->channels, vgmstream->sample_rate, block_count, block_size);
vgmstream->codec_data = init_ffmpeg_header_offset(streamFile, buf,bytes, start_offset,data_size);
if (!vgmstream->codec_data) goto fail;
vgmstream->coding_type = coding_FFmpeg;
vgmstream->layout_type = layout_none;
//xma_fix_raw_samples(vgmstream, streamFile, start_offset,data_size, 0, ); //todo
break;
}
#endif
default:
goto fail;
}
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
goto fail;
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,75 +0,0 @@
#include "meta.h"
#include "../util.h"
/* SMP (Mushroom Men: The Spore Wars ) */
VGMSTREAM * init_vgmstream_wii_smp(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[PATH_LIMIT];
off_t start_offset;
int loop_flag = 0;
int channel_count;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("smp",filename_extension(filename))) goto fail;
/* check header */
if (read_32bitBE(0x00,streamFile) != 0x05000000) /* 0x05000000 */
goto fail;
loop_flag = 0;
channel_count = read_32bitLE(0x28,streamFile);
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
start_offset = read_32bitLE(0x1C,streamFile);
vgmstream->channels = channel_count;
vgmstream->sample_rate = read_32bitLE(0x30,streamFile);
vgmstream->coding_type = coding_NGC_DSP;
vgmstream->num_samples = read_32bitLE(0x34,streamFile)/2;
if (loop_flag) {
vgmstream->loop_start_sample = 0;
vgmstream->loop_end_sample = read_32bitLE(0x34,streamFile)/2;
}
/* We have no interleave, so we have no layout */
vgmstream->layout_type = layout_none;
vgmstream->meta_type = meta_WII_SMP;
/* 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;
}
}
/*Retrieving the coef table...
This game has an exception, the coefs are stored in Little Endian... */
{
int i;
for (i=0;i<16;i++) {
vgmstream->ch[0].adpcm_coef[i] = read_16bitLE(0x50+i*2,streamFile);
}
}
return vgmstream;
/* clean up anything we may have opened */
fail:
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}

View File

@ -409,7 +409,7 @@ VGMSTREAM * init_vgmstream_xwb(STREAMFILE *streamFile) {
xwb.fix_xma_num_samples = 0;
}
}
VGM_LOG("fix: num=%i, loop=%i\n", xwb.fix_xma_num_samples,xwb.fix_xma_loop_samples);
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(xwb.channels,xwb.loop_flag);

View File

@ -192,7 +192,6 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = {
init_vgmstream_ps2_joe,
init_vgmstream_vgs,
init_vgmstream_dc_dcsw_dcs,
init_vgmstream_wii_smp,
init_vgmstream_mul,
init_vgmstream_thp,
init_vgmstream_wii_sts,
@ -255,7 +254,6 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = {
init_vgmstream_ps2_msa,
init_vgmstream_ps2_voi,
init_vgmstream_ps2_khv,
init_vgmstream_pc_smp,
init_vgmstream_ngc_rkv,
init_vgmstream_dsp_ddsp,
init_vgmstream_p3d,
@ -407,7 +405,6 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = {
init_vgmstream_msb_msh,
init_vgmstream_txtp,
init_vgmstream_smc_smh,
init_vgmstream_ea_sps_fb,
init_vgmstream_ppst,
init_vgmstream_opus_sps_n1_segmented,
init_vgmstream_ubi_bao_pk,
@ -462,6 +459,7 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = {
init_vgmstream_nus3audio,
init_vgmstream_imc,
init_vgmstream_imc_container,
init_vgmstream_smp,
/* lowest priority metas (should go after all metas, and TXTH should go before raw formats) */
init_vgmstream_txth, /* proper parsers should supersede TXTH, once added */

View File

@ -439,7 +439,7 @@ typedef enum {
meta_ZWDSP, /* Zack and Wiki */
meta_VGS, /* Guitar Hero Encore - Rocks the 80s */
meta_DC_DCSW_DCS, /* Evil Twin - Cypriens Chronicles (DC) */
meta_WII_SMP, /* Mushroom Men - The Spore Wars */
meta_SMP,
meta_WII_SNG, /* Excite Trucks */
meta_MUL,
meta_SAT_BAKA, /* Crypt Killer */
@ -531,7 +531,6 @@ typedef enum {
meta_PS2_MSA, /* Psyvariar -Complete Edition- */
meta_PS2_VOI, /* RAW Danger (Zettaizetsumei Toshi 2 - Itetsuita Kiokutachi) [PS2] */
meta_PS2_KHV, /* Kingdom Hearts 2 VAG streams */
meta_PC_SMP, /* Ghostbusters PC .smp */
meta_P3D, /* Prototype P3D */
meta_PS2_TK1, /* Tekken (NamCollection) */
meta_NGC_RKV, /* Legacy of Kain - Blood Omen 2 (GC) */