This commit is contained in:
bnnm 2021-01-24 20:36:59 +01:00
parent d71c280729
commit c246311359
4 changed files with 156 additions and 159 deletions

View File

@ -925,7 +925,7 @@ static const meta_info meta_info_list[] = {
{meta_PS2_EXST, "Sony EXST header"}, {meta_PS2_EXST, "Sony EXST header"},
{meta_SVAG_KCET, "Konami SVAG header"}, {meta_SVAG_KCET, "Konami SVAG header"},
{meta_PS_HEADERLESS, "Headerless PS-ADPCM raw header"}, {meta_PS_HEADERLESS, "Headerless PS-ADPCM raw header"},
{meta_PS2_MIB_MIH, "Sony MultiStream MIH+MIB header"}, {meta_MIB_MIH, "Sony MultiStream MIH+MIB header"},
{meta_DSP_MPDSP, "Single DSP header stereo by .mpdsp extension"}, {meta_DSP_MPDSP, "Single DSP header stereo by .mpdsp extension"},
{meta_PS2_MIC, "KOEI .MIC header"}, {meta_PS2_MIC, "KOEI .MIC header"},
{meta_DSP_JETTERS, "Double DSP header stereo by _lr.dsp extension"}, {meta_DSP_JETTERS, "Double DSP header stereo by _lr.dsp extension"},

View File

@ -1,72 +1,72 @@
#include "meta.h" #include "meta.h"
#include "../coding/coding.h" #include "../coding/coding.h"
/* MIB+MIH - SCEE MultiStream interleaved bank (header+data) [namCollection: Ace Combat 2 (PS2), Rampage: Total Destruction (PS2)] */ /* MIB+MIH - SCEE MultiStream interleaved bank (header+data) [namCollection: Ace Combat 2 (PS2), Rampage: Total Destruction (PS2)] */
VGMSTREAM * init_vgmstream_mib_mih(STREAMFILE *streamFile) { VGMSTREAM* init_vgmstream_mib_mih(STREAMFILE* sf) {
VGMSTREAM * vgmstream = NULL; VGMSTREAM* vgmstream = NULL;
STREAMFILE * streamHeader = NULL; STREAMFILE* sh = NULL;
off_t header_offset, start_offset; off_t header_offset, start_offset;
size_t data_size, frame_size, frame_last, frame_count, name_size; size_t data_size, frame_size, frame_last, frame_count;
int channel_count, loop_flag, sample_rate; int channels, loop_flag, sample_rate;
/* check extension */ /* check extension */
if (!check_extensions(streamFile, "mib")) if (!check_extensions(sf, "mib"))
goto fail; goto fail;
streamHeader = open_streamfile_by_ext(streamFile,"mih"); sh = open_streamfile_by_ext(sf,"mih");
if (!streamHeader) goto fail; if (!sh) goto fail;
header_offset = 0x00; header_offset = 0x00;
if (read_32bitLE(0x00,streamHeader) != 0x40) { /* header size */ if (read_u32le(0x00,sh) != 0x40) { /* header size */
name_size = read_32bitLE(0x00, streamHeader); /* Marc Ecko's Getting Up (PS2) has a name at the start (hack, not standard .mib+mih) */
if (read_32bitLE(0x04 + name_size, streamHeader) == 0x40 && size_t name_size = read_u32le(0x00, sh);
read_32bitLE(0x04 + name_size + 0x04, streamHeader) == 0x40) { if (read_u32le(0x04 + name_size, sh) == 0x40 &&
/* Marc Ecko's Getting Up (PS2) has a name at the start */ read_u32le(0x04 + name_size + 0x04, sh) == 0x40) {
header_offset = 0x04 + name_size + 0x04; header_offset = 0x04 + name_size + 0x04;
} else { } else {
goto fail; goto fail;
} }
} }
loop_flag = 0; /* MIB+MIH don't loop (nor use PS-ADPCM flags) per spec */ loop_flag = 0; /* MIB+MIH don't loop (nor use PS-ADPCM flags) per spec */
start_offset = 0x00; start_offset = 0x00;
/* 0x04: padding size (always 0x20, MIH header must be multiple of 0x40) */ /* 0x04: padding size (always 0x20, MIH header must be multiple of 0x40) */
frame_last = (uint32_t)read_32bitLE(header_offset + 0x05,streamHeader) & 0x00FFFFFF; /* 24b */ frame_last = read_u32le(header_offset + 0x05,sh) & 0x00FFFFFF; /* 24b */
channel_count = read_32bitLE(header_offset + 0x08,streamHeader); channels = read_u32le(header_offset + 0x08,sh);
sample_rate = read_32bitLE(header_offset + 0x0c,streamHeader); sample_rate = read_u32le(header_offset + 0x0c,sh);
frame_size = read_32bitLE(header_offset + 0x10,streamHeader); frame_size = read_u32le(header_offset + 0x10,sh);
frame_count = read_32bitLE(header_offset + 0x14,streamHeader); frame_count = read_u32le(header_offset + 0x14,sh);
if (frame_count == 0) { /* rarely [Gladius (PS2)] */ if (frame_count == 0) { /* rarely [Gladius (PS2)] */
frame_count = get_streamfile_size(streamFile) / (frame_size * channel_count); frame_count = get_streamfile_size(sf) / (frame_size * channels);
} }
data_size = frame_count * frame_size; data_size = frame_count * frame_size;
if (frame_last) if (frame_last)
data_size -= frame_size - frame_last; /* last frame has less usable data */ data_size -= frame_size - frame_last; /* last frame has less usable data */
data_size *= channel_count; data_size *= channels;
/* 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->sample_rate = sample_rate; vgmstream->meta_type = meta_MIB_MIH;
vgmstream->num_samples = ps_bytes_to_samples(data_size, channel_count); vgmstream->sample_rate = sample_rate;
vgmstream->num_samples = ps_bytes_to_samples(data_size, channels);
vgmstream->meta_type = meta_PS2_MIB_MIH;
vgmstream->coding_type = coding_PSX; vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_interleave; vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = frame_size; vgmstream->interleave_block_size = frame_size;
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset)) if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail; goto fail;
close_streamfile(streamHeader); close_streamfile(sh);
return vgmstream; return vgmstream;
fail: fail:
close_streamfile(streamHeader); close_streamfile(sh);
close_vgmstream(vgmstream); close_vgmstream(vgmstream);
return NULL; return NULL;
} }

View File

@ -1,85 +1,82 @@
#include "meta.h" #include "meta.h"
#include "../coding/coding.h" #include "../coding/coding.h"
/* MSB+MSH - SCEE MultiStream flat bank [namCollection: Ace Combat 2 (PS2) sfx, EyeToy Play (PS2)] */ /* MSB+MSH - SCEE MultiStream flat bank [namCollection: Ace Combat 2 (PS2) sfx, EyeToy Play (PS2)] */
VGMSTREAM * init_vgmstream_msb_msh(STREAMFILE *streamFile) { VGMSTREAM* init_vgmstream_msb_msh(STREAMFILE* sf) {
VGMSTREAM * vgmstream = NULL; VGMSTREAM* vgmstream = NULL;
STREAMFILE * streamHeader = NULL; STREAMFILE* sh = NULL;
off_t start_offset, header_offset = 0; off_t start_offset, header_offset = 0;
size_t stream_size; size_t stream_size;
int loop_flag = 0, channel_count, sample_rate; int loop_flag, channels, sample_rate;
int total_subsongs, target_subsong = streamFile->stream_index; int total_subsongs, target_subsong = sf->stream_index;
/* checks */ /* checks */
if (!check_extensions(streamFile, "msb")) if (!check_extensions(sf, "msb"))
goto fail; goto fail;
streamHeader = open_streamfile_by_ext(streamFile, "msh"); sh = open_streamfile_by_ext(sf, "msh");
if (!streamHeader) goto fail; if (!sh) goto fail;
if (read_32bitLE(0x00,streamHeader) != get_streamfile_size(streamHeader)) if (read_u32le(0x00,sh) != get_streamfile_size(sh))
goto fail; goto fail;
/* 0x04: unknown */ /* 0x04: unknown */
/* parse entries */ /* parse entries */
{ {
int i; int i;
int entries = read_32bitLE(0x08,streamHeader); int entries = read_s32le(0x08,sh);
total_subsongs = 0; total_subsongs = 0;
if (target_subsong == 0) target_subsong = 1; if (target_subsong == 0) target_subsong = 1;
for (i = 0; i < entries; i++) { for (i = 0; i < entries; i++) {
if (read_32bitLE(0x0c + 0x10*i, streamHeader) == 0) /* size 0 = empty entry */ if (read_u32le(0x0c + 0x10*i, sh) == 0) /* size 0 = empty entry */
continue; continue;
total_subsongs++; total_subsongs++;
if (total_subsongs == target_subsong && !header_offset) { if (total_subsongs == target_subsong && !header_offset) {
header_offset = 0x0c + 0x10*i; header_offset = 0x0c + 0x10*i;
} }
} }
if (!header_offset) goto fail; if (!header_offset) goto fail;
if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail; if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail;
} }
loop_flag = 0;
loop_flag = 0; channels = 1;
channel_count = 1;
stream_size = read_u32le(header_offset+0x00, sh);
stream_size = read_32bitLE(header_offset+0x00, streamHeader); if (read_u32le(header_offset+0x04, sh) != 0) /* stereo flag? */
if (read_32bitLE(header_offset+0x04, streamHeader) != 0) /* stereo flag? */ goto fail;
goto fail; start_offset = read_u32le(header_offset+0x08, sh);
start_offset = read_32bitLE(header_offset+0x08, streamHeader); sample_rate = read_u32le(header_offset+0x0c, sh); /* Ace Combat 2 seems to set wrong values but probably their bug */
sample_rate = read_32bitLE(header_offset+0x0c, streamHeader); /* Ace Combat 2 seems to set wrong values but probably their bug */
/* build the VGMSTREAM */
/* build the VGMSTREAM */ vgmstream = allocate_vgmstream(channels, loop_flag);
vgmstream = allocate_vgmstream(channel_count,loop_flag); if (!vgmstream) goto fail;
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_MSB_MSH;
vgmstream->sample_rate = sample_rate; vgmstream->sample_rate = sample_rate;
vgmstream->num_samples = ps_bytes_to_samples(stream_size,channel_count); vgmstream->num_samples = ps_bytes_to_samples(stream_size, channels);
vgmstream->num_streams = total_subsongs; vgmstream->num_streams = total_subsongs;
vgmstream->stream_size = stream_size; vgmstream->stream_size = stream_size;
vgmstream->meta_type = meta_MSB_MSH;
vgmstream->coding_type = coding_PSX;
vgmstream->coding_type = coding_PSX; vgmstream->layout_type = layout_interleave;
vgmstream->layout_type = layout_interleave; vgmstream->interleave_block_size = 0x10;
vgmstream->interleave_block_size = 0x10;
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail;
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset)) close_streamfile(sh);
goto fail; return vgmstream;
close_streamfile(streamHeader); fail:
return vgmstream; close_streamfile(sh);
close_vgmstream(vgmstream);
fail: return NULL;
close_streamfile(streamHeader); }
close_vgmstream(vgmstream);
return NULL;
}

View File

@ -362,7 +362,7 @@ typedef enum {
meta_PS2_EXST, /* Shadow of Colossus EXST */ meta_PS2_EXST, /* Shadow of Colossus EXST */
meta_SVAG_KCET, meta_SVAG_KCET,
meta_PS_HEADERLESS, /* headerless PS-ADPCM */ meta_PS_HEADERLESS, /* headerless PS-ADPCM */
meta_PS2_MIB_MIH, /* MIB File + MIH Header*/ meta_MIB_MIH,
meta_PS2_MIC, /* KOEI MIC File */ meta_PS2_MIC, /* KOEI MIC File */
meta_PS2_VAGi, /* VAGi Interleaved File */ meta_PS2_VAGi, /* VAGi Interleaved File */
meta_PS2_VAGp, /* VAGp Mono File */ meta_PS2_VAGp, /* VAGp Mono File */