Added .sdd [Piglet's Big Game (PS2/GC)]

This commit is contained in:
NicknineTheEagle 2024-11-13 01:12:05 +03:00
parent 42842898dd
commit 6fdc2025cd
7 changed files with 111 additions and 0 deletions

View File

@ -499,6 +499,7 @@ static const char* extension_list[] = {
"scd",
"sch",
"sd9",
"sdd",
"sdl",
"sdp", //txth/reserved [Metal Gear Arcade (AC)]
"sdf",
@ -1446,6 +1447,7 @@ static const meta_info meta_info_list[] = {
{meta_EA_SBK, "Electronic Arts SBK header"},
{meta_DSP_ASURA, "Rebellion DSP header"},
{meta_ONGAKUKAN_RIFF_ADP, "Ongakukan RIFF WAVE header"},
{meta_SDD, "Doki Denki DSBH header"},
};
void get_vgmstream_coding_description(VGMSTREAM* vgmstream, char* out, size_t out_size) {

View File

@ -667,6 +667,7 @@
<ClCompile Include="meta\sbk.c" />
<ClCompile Include="meta\scd_pcm.c" />
<ClCompile Include="meta\sd9.c" />
<ClCompile Include="meta\sdd.c" />
<ClCompile Include="meta\sdf.c" />
<ClCompile Include="meta\sdrh.c" />
<ClCompile Include="meta\sdt.c" />

View File

@ -1831,6 +1831,9 @@
<ClCompile Include="meta\sd9.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\sdd.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\sdf.c">
<Filter>meta\Source Files</Filter>
</ClCompile>

View File

@ -1011,4 +1011,6 @@ VGMSTREAM* init_vgmstream_dsp_asura_sfx(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_adp_ongakukan(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_sdd(STREAMFILE* sf);
#endif /*_META_H*/

101
src/meta/sdd.c Normal file
View File

@ -0,0 +1,101 @@
#include "meta.h"
#include "../coding/coding.h"
/* .SDD - from Piglet's Big Game (PS2/GC) */
VGMSTREAM* init_vgmstream_sdd(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
uint32_t header_size, data_size, sample_rate, sound_offset, sound_size;
uint8_t codec, channels;
off_t table_offset, data_offset, entry_offset, name_offset;
size_t name_size;
int target_subsong = sf->stream_index, total_subsongs, loop_flag;
if (!is_id32be(0x00, sf, "DSBH"))
goto fail;
if (!check_extensions(sf, "sdd"))
goto fail;
/* always little endian, even on GC */
header_size = read_u32le(0x04, sf);
table_offset = 0x20;
/* haven't seen any filenames larger than 16 bytes so should be safe */
total_subsongs = (header_size - table_offset) / 0x20;
if (target_subsong == 0) target_subsong = 1;
if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1)
goto fail;
/* get name buffer size */
name_offset = table_offset + (target_subsong - 1) * 0x20;
name_size = read_string(NULL, STREAM_NAME_SIZE, name_offset, sf) + 1;
entry_offset = name_offset + name_size;
codec = read_u8(entry_offset + 0x00, sf);
//bps = read_u8(entry_offset + 0x01, sf);
channels = read_u8(entry_offset + 0x02, sf);
sample_rate = read_u32le(entry_offset + 0x03, sf);
sound_offset = read_u32le(entry_offset + 0x07, sf);
sound_size = read_u32le(entry_offset + 0x0b, sf);
/* no stereo samples seen */
if (channels > 1)
goto fail;
data_offset = header_size;
if (!is_id32be(data_offset, sf, "DSBD"))
goto fail;
data_size = read_u32le(data_offset + 0x04, sf);
if (data_offset + data_size > get_streamfile_size(sf))
goto fail;
sound_offset += data_offset + 0x20;
loop_flag = 0;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_SDD;
vgmstream->sample_rate = sample_rate;
vgmstream->stream_size = sound_size;
vgmstream->num_streams = total_subsongs;
read_string(vgmstream->stream_name, STREAM_NAME_SIZE, name_offset, sf);
switch (codec) {
case 0x01: /* DSP */
/* starts with incomplete DSP header (nibble count not set) */
if (sound_size < 0x60)
goto fail;
vgmstream->coding_type = coding_NGC_DSP;
vgmstream->layout_type = layout_none;
vgmstream->num_samples = read_u32be(sound_offset + 0x00, sf);
/* set coefs and initial history */
dsp_read_coefs_be(vgmstream, sf, sound_offset + 0x1c, 0x00);
vgmstream->ch[0].adpcm_history1_16 = read_u16be(sound_offset + 0x40, sf);
vgmstream->ch[0].adpcm_history2_16 = read_u16be(sound_offset + 0x42, sf);
sound_offset += 0x60;
vgmstream->stream_size -= 0x60;
break;
case 0x03: /* PSX */
vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_none;
vgmstream->num_samples = ps_bytes_to_samples(sound_size, channels);
break;
default:
goto fail;
}
if (!vgmstream_open_stream(vgmstream, sf, sound_offset))
goto fail;
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}

View File

@ -509,6 +509,7 @@ init_vgmstream_t init_vgmstream_functions[] = {
init_vgmstream_dsp_asura_ttss,
init_vgmstream_dsp_asura_sfx,
init_vgmstream_adp_ongakukan,
init_vgmstream_sdd,
/* lower priority metas (no clean header identity, somewhat ambiguous, or need extension/companion file to identify) */
init_vgmstream_agsc,

View File

@ -708,6 +708,7 @@ typedef enum {
meta_EA_SBK,
meta_DSP_ASURA,
meta_ONGAKUKAN_RIFF_ADP,
meta_SDD,
} meta_t;