Fix some .smp [Guilty Party (Wii)]

This commit is contained in:
bnnm 2020-12-13 20:39:50 +01:00
parent 62a5f46d43
commit b03109e0dc

View File

@ -3,42 +3,52 @@
/* .smp - Terminal Reality's Infernal Engine 'samples' [Ghostbusters: The Video Game (PS2/PS3/X360/PC/PSP), Chandragupta (PS2/PSP)] */ /* .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* init_vgmstream_smp(STREAMFILE* sf) {
VGMSTREAM * vgmstream = NULL; VGMSTREAM* vgmstream = NULL;
off_t start_offset; off_t start_offset, extra_offset;
int loop_flag, channel_count, sample_rate, codec, version, num_samples, bps; int loop_flag, channels, sample_rate, codec, version, num_samples, bps;
size_t data_size; size_t data_size;
/* checks */ /* checks */
if (!check_extensions(streamFile, "smp")) if (!check_extensions(sf, "smp"))
goto fail; goto fail;
version = read_32bitLE(0x00,streamFile); version = read_u32le(0x00,sf);
if (version != 0x05 && /* Ghostbusters (PS2), Mushroom Men (Wii) */ if (version != 0x05 && /* Ghostbusters (PS2), Mushroom Men (Wii) */
version != 0x06 && /* Ghostbusters (PS3/X360/PC) */ version != 0x06 && /* Ghostbusters (PS3/X360/PC) */
version != 0x07 && /* Ghostbusters (PSP) */ version != 0x07 && /* Ghostbusters (PSP) */
version != 0x08) /* Chandragupta (PS2/PSP), Street Cricket Champions 1/2 (PSP) */ version != 0x08) /* Chandragupta (PS2/PSP), Street Cricket Champions 1/2 (PSP), Guilty Party (Wii) */
goto fail; goto fail;
/* 0x04~14: guid? */ /* 0x04~14: guid? */
if (read_32bitLE(0x14,streamFile) != 0) /* reserved? */ if (read_u32le(0x14,sf) != 0) /* reserved? */
goto fail; goto fail;
num_samples = read_32bitLE(0x18,streamFile); num_samples = read_s32le(0x18,sf);
start_offset = read_32bitLE(0x1c,streamFile); start_offset = read_u32le(0x1c,sf);
data_size = read_32bitLE(0x20,streamFile); data_size = read_u32le(0x20,sf);
codec = read_32bitLE(0x24,streamFile); codec = read_u32le(0x24,sf);
channel_count = read_32bitLE(0x28,streamFile); /* smaller header found in Guilty Party (Wii) */
bps = read_32bitLE(0x2c,streamFile); if (version == 0x08 && start_offset == 0x80) {
sample_rate = read_32bitLE(0x30,streamFile); channels = read_u8(0x28,sf);
bps = read_u8(0x29,sf);
sample_rate = read_u16le(0x2a,sf);
extra_offset = 0x2c; /* coefs only */
}
else {
channels = read_u32le(0x28,sf);
bps = read_u32le(0x2c,sf);
sample_rate = read_u32le(0x30,sf);
extra_offset = 0x34 + 0x1c; /* standard DSP header, but LE */
}
loop_flag = 0; loop_flag = 0;
if (start_offset + data_size != get_streamfile_size(streamFile)) if (start_offset + data_size != get_streamfile_size(sf))
goto fail; goto fail;
/* build the VGMSTREAM */ /* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count, loop_flag); vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail; if (!vgmstream) goto fail;
vgmstream->meta_type = meta_SMP; vgmstream->meta_type = meta_SMP;
@ -54,7 +64,7 @@ VGMSTREAM * init_vgmstream_smp(STREAMFILE *streamFile) {
block_align = 0x98 * vgmstream->channels; block_align = 0x98 * vgmstream->channels;
encoder_delay = 0; /* 1024 looks ok, but num_samples needs to be adjusted too */ encoder_delay = 0; /* 1024 looks ok, but num_samples needs to be adjusted too */
vgmstream->codec_data = init_ffmpeg_atrac3_raw(streamFile, start_offset,data_size, vgmstream->num_samples,vgmstream->channels,vgmstream->sample_rate, block_align, encoder_delay); vgmstream->codec_data = init_ffmpeg_atrac3_raw(sf, start_offset,data_size, vgmstream->num_samples,vgmstream->channels,vgmstream->sample_rate, block_align, encoder_delay);
if (!vgmstream->codec_data) goto fail; if (!vgmstream->codec_data) goto fail;
vgmstream->coding_type = coding_FFmpeg; vgmstream->coding_type = coding_FFmpeg;
vgmstream->layout_type = layout_none; vgmstream->layout_type = layout_none;
@ -64,27 +74,27 @@ VGMSTREAM * init_vgmstream_smp(STREAMFILE *streamFile) {
case 0x02: case 0x02:
if (bps != 4) goto fail; if (bps != 4) goto fail;
if (channel_count > 1) goto fail; /* not known */ if (channels > 1) goto fail; /* not known */
/* 0x34: standard DSP header, but LE */
vgmstream->coding_type = coding_NGC_DSP; vgmstream->coding_type = coding_NGC_DSP;
vgmstream->layout_type = layout_none; vgmstream->layout_type = layout_none;
dsp_read_coefs_le(vgmstream,streamFile,0x50,0x00); dsp_read_coefs_le(vgmstream, sf, extra_offset, 0x00);
//todo adpcm hist
break; break;
case 0x04: case 0x04:
if (bps != 4) goto fail; if (bps != 4) goto fail;
if (!msadpcm_check_coefs(streamFile, 0x36)) if (!msadpcm_check_coefs(sf, 0x36))
goto fail; goto fail;
vgmstream->coding_type = coding_MSADPCM; vgmstream->coding_type = coding_MSADPCM;
vgmstream->layout_type = layout_none; vgmstream->layout_type = layout_none;
vgmstream->frame_size = 0x86*channel_count; vgmstream->frame_size = 0x86*channels;
break; break;
case 0x06: case 0x06:
if (bps != 4) goto fail; if (bps != 4) goto fail;
if (channel_count > 1) goto fail; /* not known */ if (channels > 1) goto fail; /* not known */
vgmstream->coding_type = coding_PSX; vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_none; vgmstream->layout_type = layout_none;
@ -102,12 +112,12 @@ VGMSTREAM * init_vgmstream_smp(STREAMFILE *streamFile) {
block_count = data_size / block_size + (data_size % block_size ? 1 : 0); /* @0x54(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); 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); vgmstream->codec_data = init_ffmpeg_header_offset(sf, buf,bytes, start_offset,data_size);
if (!vgmstream->codec_data) goto fail; if (!vgmstream->codec_data) goto fail;
vgmstream->coding_type = coding_FFmpeg; vgmstream->coding_type = coding_FFmpeg;
vgmstream->layout_type = layout_none; vgmstream->layout_type = layout_none;
//xma_fix_raw_samples(vgmstream, streamFile, start_offset,data_size, 0, ); //todo //xma_fix_raw_samples(vgmstream, sf, start_offset,data_size, 0, ); //todo
break; break;
} }
#endif #endif
@ -117,7 +127,7 @@ VGMSTREAM * init_vgmstream_smp(STREAMFILE *streamFile) {
} }
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset)) if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail; goto fail;
return vgmstream; return vgmstream;