This commit is contained in:
bnnm 2021-06-21 00:30:15 +02:00
parent d49aacbf52
commit 0487cf5435
4 changed files with 236 additions and 237 deletions

View File

@ -3,49 +3,49 @@
/* CSMP - Retro Studios sample [Metroid Prime 3 (Wii), Donkey Kong Country Returns (Wii)] */ /* CSMP - Retro Studios sample [Metroid Prime 3 (Wii), Donkey Kong Country Returns (Wii)] */
VGMSTREAM * init_vgmstream_csmp(STREAMFILE *streamFile) { VGMSTREAM* init_vgmstream_csmp(STREAMFILE* sf) {
VGMSTREAM * vgmstream = NULL; VGMSTREAM* vgmstream = NULL;
off_t start_offset, first_offset = 0x08, chunk_offset; off_t start_offset, first_offset = 0x08, chunk_offset;
int loop_flag, channel_count; int loop_flag, channels;
/* checks */ /* checks */
if (!check_extensions(streamFile, "csmp")) if (!check_extensions(sf, "csmp"))
goto fail; goto fail;
if (read_32bitBE(0x00, streamFile) != 0x43534D50) /* "CSMP" */ if (!is_id32be(0x00, sf, "CSMP"))
goto fail; goto fail;
if (read_32bitBE(0x04, streamFile) != 1) /* version? */ if (read_u32be(0x04, sf) != 1)
goto fail; goto fail;
if (!find_chunk(streamFile, 0x44415441,first_offset,0, &chunk_offset,NULL, 1, 0)) /*"DATA"*/ if (!find_chunk(sf, 0x44415441,first_offset,0, &chunk_offset,NULL, 1, 0)) /*"DATA"*/
goto fail; goto fail;
/* contains standard DSP header, but somehow some validations (start/loop ps) /* contains standard DSP header, but somehow some validations (start/loop ps)
* don't seem to work, so no point to handle as standard DSP */ * don't seem to work, so no point to handle as standard DSP */
channel_count = 1; channels = 1;
loop_flag = read_16bitBE(chunk_offset+0x0c,streamFile); loop_flag = read_s16be(chunk_offset+0x0c,sf);
start_offset = chunk_offset + 0x60; start_offset = chunk_offset + 0x60;
/* 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_CSMP; vgmstream->meta_type = meta_CSMP;
vgmstream->sample_rate = read_32bitBE(chunk_offset+0x08,streamFile); vgmstream->sample_rate = read_s32be(chunk_offset+0x08,sf);
vgmstream->num_samples = read_32bitBE(chunk_offset+0x00,streamFile); vgmstream->num_samples = read_s32be(chunk_offset+0x00,sf);
vgmstream->loop_start_sample = dsp_nibbles_to_samples(read_32bitBE(chunk_offset+0x10,streamFile)); vgmstream->loop_start_sample = dsp_nibbles_to_samples(read_u32be(chunk_offset+0x10,sf));
vgmstream->loop_end_sample = dsp_nibbles_to_samples(read_32bitBE(chunk_offset+0x14,streamFile))+1; vgmstream->loop_end_sample = dsp_nibbles_to_samples(read_u32be(chunk_offset+0x14,sf)) + 1;
if (vgmstream->loop_end_sample > vgmstream->num_samples) /* ? */ if (vgmstream->loop_end_sample > vgmstream->num_samples) /* ? */
vgmstream->loop_end_sample = vgmstream->num_samples; vgmstream->loop_end_sample = vgmstream->num_samples;
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_be(vgmstream, streamFile, chunk_offset+0x1c, 0x00); dsp_read_coefs_be(vgmstream, sf, chunk_offset+0x1c, 0x00);
dsp_read_hist_be(vgmstream, streamFile, chunk_offset+0x40, 0x00); dsp_read_hist_be(vgmstream, sf, chunk_offset+0x40, 0x00);
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset)) if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail; goto fail;
return vgmstream; return vgmstream;

View File

@ -2,61 +2,61 @@
#include "../coding/coding.h" #include "../coding/coding.h"
/* WMSF - Banpresto MSFx wrapper [Dai-2-Ji Super Robot Taisen OG: The Moon Dwellers (PS3)] */ /* WMSF - Banpresto MSFx wrapper [Dai-2-Ji Super Robot Taisen OG: The Moon Dwellers (PS3)] */
VGMSTREAM * init_vgmstream_msf_banpresto_wmsf(STREAMFILE *streamFile) { VGMSTREAM* init_vgmstream_msf_banpresto_wmsf(STREAMFILE* sf) {
VGMSTREAM *vgmstream = NULL; VGMSTREAM* vgmstream = NULL;
STREAMFILE *temp_streamFile = NULL; STREAMFILE* temp_sf = NULL;
off_t subfile_offset = 0x10; off_t subfile_offset = 0x10;
size_t subfile_size = get_streamfile_size(streamFile) - subfile_offset; size_t subfile_size = get_streamfile_size(sf) - subfile_offset;
/* checks */ /* checks */
if ( !check_extensions(streamFile,"msf")) if (!check_extensions(sf,"msf"))
goto fail; goto fail;
if (read_32bitBE(0x00,streamFile) != 0x574D5346) /* "WMSF" */ if (!is_id32be(0x00,sf,"WMSF"))
goto fail; goto fail;
/* 0x04: size, 0x08: flags? 0x0c: null? */ /* 0x04: size, 0x08: flags? 0x0c: null? */
temp_streamFile = setup_subfile_streamfile(streamFile, subfile_offset,subfile_size, NULL); temp_sf = setup_subfile_streamfile(sf, subfile_offset,subfile_size, NULL);
if (!temp_streamFile) goto fail; if (!temp_sf) goto fail;
vgmstream = init_vgmstream_msf(temp_streamFile); vgmstream = init_vgmstream_msf(temp_sf);
if (!vgmstream) goto fail; if (!vgmstream) goto fail;
close_streamfile(temp_streamFile); close_streamfile(temp_sf);
return vgmstream; return vgmstream;
fail: fail:
close_streamfile(temp_streamFile); close_streamfile(temp_sf);
close_vgmstream(vgmstream); close_vgmstream(vgmstream);
return NULL; return NULL;
} }
/* 2MSF - Banpresto RIFF wrapper [Dai-2-Ji Super Robot Taisen OG: The Moon Dwellers (PS4)] */ /* 2MSF - Banpresto RIFF wrapper [Dai-2-Ji Super Robot Taisen OG: The Moon Dwellers (PS4)] */
VGMSTREAM * init_vgmstream_msf_banpresto_2msf(STREAMFILE *streamFile) { VGMSTREAM* init_vgmstream_msf_banpresto_2msf(STREAMFILE *sf) {
VGMSTREAM *vgmstream = NULL; VGMSTREAM* vgmstream = NULL;
STREAMFILE *temp_streamFile = NULL; STREAMFILE*temp_sf = NULL;
off_t subfile_offset = 0x14; off_t subfile_offset = 0x14;
size_t subfile_size = get_streamfile_size(streamFile) - subfile_offset; size_t subfile_size = get_streamfile_size(sf) - subfile_offset;
/* checks */ /* checks */
if ( !check_extensions(streamFile,"at9")) if ( !check_extensions(sf,"at9"))
goto fail; goto fail;
if (read_32bitBE(0x00,streamFile) != 0x324D5346) /* "2MSF" */ if (!is_id32be(0x00,sf,"2MSF"))
goto fail; goto fail;
/* 0x04: size, 0x08: flags? 0x0c: null?, 0x10: 0x01? (BE values even though RIFF is LE) */ /* 0x04: size, 0x08: flags? 0x0c: null?, 0x10: 0x01? (BE values even though RIFF is LE) */
temp_streamFile = setup_subfile_streamfile(streamFile, subfile_offset,subfile_size, NULL); temp_sf = setup_subfile_streamfile(sf, subfile_offset,subfile_size, NULL);
if (!temp_streamFile) goto fail; if (!temp_sf) goto fail;
vgmstream = init_vgmstream_riff(temp_streamFile); vgmstream = init_vgmstream_riff(temp_sf);
if (!vgmstream) goto fail; if (!vgmstream) goto fail;
close_streamfile(temp_streamFile); close_streamfile(temp_sf);
return vgmstream; return vgmstream;
fail: fail:
close_streamfile(temp_streamFile); close_streamfile(temp_sf);
close_vgmstream(vgmstream); close_vgmstream(vgmstream);
return NULL; return NULL;
} }

View File

@ -3,33 +3,33 @@
/* MSFC - Konami (Armature?) variation [Metal Gear Solid 2 HD (PS3), Metal Gear Solid 3 HD (PS3)] */ /* MSFC - Konami (Armature?) variation [Metal Gear Solid 2 HD (PS3), Metal Gear Solid 3 HD (PS3)] */
VGMSTREAM * init_vgmstream_msf_konami(STREAMFILE *streamFile) { VGMSTREAM* init_vgmstream_msf_konami(STREAMFILE* sf) {
VGMSTREAM * vgmstream = NULL; VGMSTREAM* vgmstream = NULL;
off_t start_offset; off_t start_offset;
uint32_t codec; uint32_t codec;
int loop_flag, channel_count, sample_rate; int loop_flag, channels, sample_rate;
size_t data_size; size_t data_size;
/* checks */ /* checks */
if (!check_extensions(streamFile,"msf")) if (!check_extensions(sf,"msf"))
goto fail; goto fail;
if (read_32bitBE(0x00,streamFile) != 0x4D534643) /* "MSFC" */ if (!is_id32be(0x00,sf,"MSFC"))
goto fail; goto fail;
start_offset = 0x20; start_offset = 0x20;
codec = read_32bitBE(0x04,streamFile); codec = read_u32be(0x04,sf);
channel_count = read_32bitBE(0x08,streamFile); channels = read_s32be(0x08,sf);
sample_rate = read_32bitBE(0x0c,streamFile); sample_rate = read_s32be(0x0c,sf);
data_size = read_32bitBE(0x10,streamFile); /* without header */ data_size = read_u32be(0x10,sf); /* without header */
if (data_size + start_offset != get_streamfile_size(streamFile)) if (data_size + start_offset != get_streamfile_size(sf))
goto fail; goto fail;
loop_flag = 0; loop_flag = 0;
/* 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_MSF_KONAMI; vgmstream->meta_type = meta_MSF_KONAMI;
@ -41,14 +41,14 @@ VGMSTREAM * init_vgmstream_msf_konami(STREAMFILE *streamFile) {
vgmstream->layout_type = layout_interleave; vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x10; vgmstream->interleave_block_size = 0x10;
vgmstream->num_samples = ps_bytes_to_samples(data_size, channel_count); vgmstream->num_samples = ps_bytes_to_samples(data_size, channels);
break; break;
default: default:
goto fail; goto fail;
} }
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset)) if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail; goto fail;
return vgmstream; return vgmstream;

View File

@ -3,35 +3,34 @@
/* UE4OPUS - from Unreal Engine 4 games [ARK: Survival Evolved (PC), Fortnite (PC)] */ /* UE4OPUS - from Unreal Engine 4 games [ARK: Survival Evolved (PC), Fortnite (PC)] */
VGMSTREAM * init_vgmstream_ue4opus(STREAMFILE *streamFile) { VGMSTREAM * init_vgmstream_ue4opus(STREAMFILE *sf) {
VGMSTREAM * vgmstream = NULL; VGMSTREAM * vgmstream = NULL;
off_t start_offset; off_t start_offset;
int loop_flag = 0, channel_count, sample_rate, num_samples, skip; int loop_flag = 0, channels, sample_rate, num_samples, skip;
size_t data_size; size_t data_size;
/* checks*/ /* checks*/
/* .opus/lopus: possible real extension /* .opus/lopus: possible real extension
* .ue4opus: header id */ * .ue4opus: header id */
if (!check_extensions(streamFile, "opus,lopus,ue4opus")) if (!check_extensions(sf, "opus,lopus,ue4opus"))
goto fail; goto fail;
if (read_32bitBE(0x00, streamFile) != 0x5545344F && /* "UE4O" */ if (!is_id64be(0x00, sf, "UE4OPUS\0"))
read_32bitBE(0x00, streamFile) != 0x50555300) /* "PUS\0" */
goto fail; goto fail;
sample_rate = (uint16_t)read_16bitLE(0x08, streamFile); sample_rate = read_u16le(0x08, sf);
num_samples = read_32bitLE(0x0a, streamFile); /* may be less or equal to file num_samples */ num_samples = read_s32le(0x0a, sf); /* may be less or equal to file num_samples */
channel_count = read_8bit(0x0e, streamFile); channels = read_u8(0x0e, sf);
/* 0x0f(2): frame count */ /* 0x0f(2): frame count */
loop_flag = 0; loop_flag = 0;
start_offset = 0x11; start_offset = 0x11;
data_size = get_streamfile_size(streamFile) - start_offset; data_size = get_streamfile_size(sf) - start_offset;
/* 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_UE4OPUS; vgmstream->meta_type = meta_UE4OPUS;
@ -40,10 +39,10 @@ VGMSTREAM * init_vgmstream_ue4opus(STREAMFILE *streamFile) {
#ifdef VGM_USE_FFMPEG #ifdef VGM_USE_FFMPEG
{ {
/* usually uses 60ms for music (delay of 360 samples) */ /* usually uses 60ms for music (delay of 360 samples) */
skip = ue4_opus_get_encoder_delay(start_offset, streamFile); skip = ue4_opus_get_encoder_delay(start_offset, sf);
vgmstream->num_samples = num_samples - skip; vgmstream->num_samples = num_samples - skip;
vgmstream->codec_data = init_ffmpeg_ue4_opus(streamFile, start_offset,data_size, vgmstream->channels, skip, vgmstream->sample_rate); vgmstream->codec_data = init_ffmpeg_ue4_opus(sf, start_offset,data_size, vgmstream->channels, skip, vgmstream->sample_rate);
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;
@ -52,7 +51,7 @@ VGMSTREAM * init_vgmstream_ue4opus(STREAMFILE *streamFile) {
goto fail; goto fail;
#endif #endif
if (!vgmstream_open_stream(vgmstream, streamFile, start_offset)) if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail; goto fail;
return vgmstream; return vgmstream;