mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-02-07 15:01:24 +01:00
Fix some .MSB+MSH
This commit is contained in:
parent
20e1ade300
commit
d6e3e8dac9
@ -358,7 +358,7 @@ size_t ps_find_padding(STREAMFILE *streamFile, off_t start_offset, size_t data_s
|
|||||||
size_t interleave_consumed = 0;
|
size_t interleave_consumed = 0;
|
||||||
|
|
||||||
|
|
||||||
if (data_size == 0 || channels == 0 || (channels > 0 && interleave == 0))
|
if (data_size == 0 || channels == 0 || (channels > 1 && interleave == 0))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
offset = start_offset + data_size;
|
offset = start_offset + data_size;
|
||||||
|
@ -8,7 +8,9 @@ VGMSTREAM* init_vgmstream_msb_msh(STREAMFILE* sf) {
|
|||||||
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, channels, sample_rate;
|
int loop_flag, channels, sample_rate;
|
||||||
|
int32_t loop_start, loop_end;
|
||||||
int total_subsongs, target_subsong = sf->stream_index;
|
int total_subsongs, target_subsong = sf->stream_index;
|
||||||
|
uint32_t config;
|
||||||
|
|
||||||
|
|
||||||
/* checks */
|
/* checks */
|
||||||
@ -20,12 +22,12 @@ VGMSTREAM* init_vgmstream_msb_msh(STREAMFILE* sf) {
|
|||||||
|
|
||||||
if (read_u32le(0x00,sh) != get_streamfile_size(sh))
|
if (read_u32le(0x00,sh) != get_streamfile_size(sh))
|
||||||
goto fail;
|
goto fail;
|
||||||
/* 0x04: unknown */
|
/* 0x04: flags? (0x04/34*/
|
||||||
|
|
||||||
/* parse entries */
|
/* parse entries */
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int entries = read_s32le(0x08,sh);
|
int entries = read_s32le(0x08,sh); /* may be less than file size, or include dummies (all dummies is possible too) */
|
||||||
|
|
||||||
total_subsongs = 0;
|
total_subsongs = 0;
|
||||||
if (target_subsong == 0) target_subsong = 1;
|
if (target_subsong == 0) target_subsong = 1;
|
||||||
@ -45,15 +47,20 @@ VGMSTREAM* init_vgmstream_msb_msh(STREAMFILE* sf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
loop_flag = 0;
|
|
||||||
channels = 1;
|
|
||||||
|
|
||||||
stream_size = read_u32le(header_offset+0x00, sh);
|
stream_size = read_u32le(header_offset+0x00, sh);
|
||||||
if (read_u32le(header_offset+0x04, sh) != 0) /* stereo flag? */
|
config = read_u32le(header_offset+0x04, sh); /* volume (0~100), null, null, loop (0/1) */
|
||||||
goto fail;
|
|
||||||
start_offset = read_u32le(header_offset+0x08, sh);
|
start_offset = read_u32le(header_offset+0x08, sh);
|
||||||
sample_rate = read_u32le(header_offset+0x0c, sh); /* Ace Combat 2 seems to set wrong values but probably their bug */
|
sample_rate = read_u32le(header_offset+0x0c, sh); /* Ace Combat 2 seems to set wrong values but probably their bug */
|
||||||
|
|
||||||
|
loop_flag = (config & 1);
|
||||||
|
channels = 1;
|
||||||
|
|
||||||
|
/* rare [Dr. Seuss Cat in the Hat (PS2)] */
|
||||||
|
if (loop_flag) {
|
||||||
|
/* when loop is set ADPCM has loop flags, but rarely appear too without loop set */
|
||||||
|
loop_flag = ps_find_loop_offsets(sf, start_offset, stream_size, channels, 0, &loop_start, &loop_end);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* build the VGMSTREAM */
|
/* build the VGMSTREAM */
|
||||||
vgmstream = allocate_vgmstream(channels, loop_flag);
|
vgmstream = allocate_vgmstream(channels, loop_flag);
|
||||||
@ -62,6 +69,8 @@ VGMSTREAM* init_vgmstream_msb_msh(STREAMFILE* sf) {
|
|||||||
vgmstream->meta_type = meta_MSB_MSH;
|
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, channels);
|
vgmstream->num_samples = ps_bytes_to_samples(stream_size, channels);
|
||||||
|
vgmstream->loop_start_sample = loop_start;
|
||||||
|
vgmstream->loop_end_sample = loop_end;
|
||||||
|
|
||||||
vgmstream->num_streams = total_subsongs;
|
vgmstream->num_streams = total_subsongs;
|
||||||
vgmstream->stream_size = stream_size;
|
vgmstream->stream_size = stream_size;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user