mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-02-17 19:19:16 +01:00
Fix references and tweaks
This commit is contained in:
parent
bdd695b9f9
commit
0369a82bfc
@ -6,8 +6,8 @@ VGMSTREAM * init_vgmstream_msf(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
uint32_t data_size, loop_start = 0, loop_end = 0;
|
||||
uint32_t id, codec_id, flags;
|
||||
int loop_flag = 0, channel_count;
|
||||
uint32_t codec, flags;
|
||||
int loop_flag, channel_count, sample_rate;
|
||||
|
||||
|
||||
/* checks */
|
||||
@ -17,19 +17,19 @@ VGMSTREAM * init_vgmstream_msf(STREAMFILE *streamFile) {
|
||||
if (!check_extensions(streamFile,"msf,at3,mp3"))
|
||||
goto fail;
|
||||
|
||||
start_offset = 0x40;
|
||||
|
||||
/* check header "MSF" + version-char, usually:
|
||||
* 0x01, 0x02, 0x30 ("0"), 0x35 ("5"), 0x43 ("C") (last/most common version) */
|
||||
id = read_32bitBE(0x00,streamFile);
|
||||
if ((id & 0xffffff00) != 0x4D534600) goto fail;
|
||||
if ((read_32bitBE(0x00,streamFile) & 0xffffff00) != 0x4D534600) /* "MSF\0" */
|
||||
goto fail;
|
||||
|
||||
start_offset = 0x40;
|
||||
|
||||
codec_id = read_32bitBE(0x04,streamFile);
|
||||
codec = read_32bitBE(0x04,streamFile);
|
||||
channel_count = read_32bitBE(0x08,streamFile);
|
||||
data_size = read_32bitBE(0x0C,streamFile); /* without header */
|
||||
if (data_size == 0xFFFFFFFF) /* unneeded? */
|
||||
data_size = get_streamfile_size(streamFile) - start_offset;
|
||||
sample_rate = read_32bitBE(0x10,streamFile);
|
||||
|
||||
/* byte flags, not in MSFv1 or v2
|
||||
* 0x01/02/04/08: loop marker 0/1/2/3
|
||||
@ -56,17 +56,15 @@ VGMSTREAM * init_vgmstream_msf(STREAMFILE *streamFile) {
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->sample_rate = read_32bitBE(0x10,streamFile);
|
||||
/* sample rate hack for strange MSFv1 files (PS ADPCM only?) */
|
||||
if (vgmstream->sample_rate == 0x00000000)
|
||||
vgmstream->meta_type = meta_MSF;
|
||||
vgmstream->sample_rate = sample_rate;
|
||||
if (vgmstream->sample_rate == 0) /* some MSFv1 (PS-ADPCM only?) [Megazone 23 - Aoi Garland (PS3)] */
|
||||
vgmstream->sample_rate = 48000;
|
||||
|
||||
vgmstream->meta_type = meta_MSF;
|
||||
|
||||
switch (codec_id) {
|
||||
switch (codec) {
|
||||
case 0x00: /* PCM (Big Endian) */
|
||||
case 0x01: { /* PCM (Little Endian) [Smash Cars (PS3)] */
|
||||
vgmstream->coding_type = codec_id==0 ? coding_PCM16BE : coding_PCM16LE;
|
||||
vgmstream->coding_type = codec==0 ? coding_PCM16BE : coding_PCM16LE;
|
||||
vgmstream->layout_type = channel_count == 1 ? layout_none : layout_interleave;
|
||||
vgmstream->interleave_block_size = 2;
|
||||
|
||||
@ -85,7 +83,7 @@ VGMSTREAM * init_vgmstream_msf(STREAMFILE *streamFile) {
|
||||
|
||||
case 0x03: { /* PS ADPCM [Smash Cars (PS3)] */
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
vgmstream->layout_type = channel_count == 1 ? layout_none : layout_interleave;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x10;
|
||||
|
||||
vgmstream->num_samples = ps_bytes_to_samples(data_size, channel_count);
|
||||
@ -105,8 +103,8 @@ VGMSTREAM * init_vgmstream_msf(STREAMFILE *streamFile) {
|
||||
uint8_t buf[100];
|
||||
int32_t bytes, block_size, encoder_delay, joint_stereo;
|
||||
|
||||
block_size = (codec_id==4 ? 0x60 : (codec_id==5 ? 0x98 : 0xC0)) * vgmstream->channels;
|
||||
joint_stereo = (codec_id==4); /* interleaved joint stereo (ch must be even) */
|
||||
block_size = (codec==4 ? 0x60 : (codec==5 ? 0x98 : 0xC0)) * vgmstream->channels;
|
||||
joint_stereo = (codec==4); /* interleaved joint stereo (ch must be even) */
|
||||
|
||||
/* MSF skip samples: from tests with MSEnc and real files (ex. TTT2 eddy.msf v43, v01 demos) seems like 1162 is consistent.
|
||||
* Atelier Rorona bt_normal01 needs it to properly skip the beginning garbage but usually doesn't matter.
|
||||
|
@ -19,7 +19,7 @@ VGMSTREAM * init_vgmstream_msf_banpresto_wmsf(STREAMFILE *streamFile) {
|
||||
temp_streamFile = setup_subfile_streamfile(streamFile, subfile_offset,subfile_size, NULL);
|
||||
if (!temp_streamFile) goto fail;
|
||||
|
||||
vgmstream = init_vgmstream_ps3_msf(temp_streamFile);
|
||||
vgmstream = init_vgmstream_msf(temp_streamFile);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
close_streamfile(temp_streamFile);
|
||||
|
@ -17,9 +17,11 @@ VGMSTREAM * init_vgmstream_mta2(STREAMFILE *streamFile) {
|
||||
|
||||
if (read_32bitBE(0x00,streamFile) != 0x4d544132) /* "MTA2" */
|
||||
goto fail;
|
||||
/* allow truncated files for now? */
|
||||
//if (read_32bitBE(0x04, streamFile) + 0x08 != get_streamfile_size(streamFile))
|
||||
// goto fail;
|
||||
|
||||
/* base header (everything is very similar to MGS3's MTAF but BE) */
|
||||
/* 0x04(4): file size -4-4 (not including block headers in case of KCEJ blocks) */
|
||||
/* 0x08(4): version? (1), 0x0c(52): null */
|
||||
|
||||
/* HEAD chunk */
|
||||
@ -56,15 +58,17 @@ VGMSTREAM * init_vgmstream_mta2(STREAMFILE *streamFile) {
|
||||
|
||||
/* TRKP chunks (x16) */
|
||||
/* just seem to contain pan/vol stuff (0x7f/0x40), TRKP per track (sometimes +1 main track?) */
|
||||
/* there is channel layout bitmask @ 0x0f (ex. 1ch = 0x04, 3ch = 0x07, 4ch = 0x33, 6ch = 0x3f), surely:
|
||||
* FRONT_L = 0x01, FRONT_R = 0x02, FRONT_M = 0x04, BACK_L = 0x08, BACK_R = 0x10, BACK_M = 0x20 */
|
||||
/* there is channel layout bitmask at 0x0f (ex. 1ch = 0x04, 3ch = 0x07, 4ch = 0x33, 6ch = 0x3f), surely:
|
||||
* FL 0x01, FR 0x02, FC = 0x04, BL = 0x08, BR = 0x10, BC = 0x20 */
|
||||
|
||||
start_offset = 0x800;
|
||||
|
||||
/* DATA chunk */
|
||||
if (read_32bitBE(0x7f8, streamFile) != 0x44415441) // "DATA"
|
||||
goto fail;
|
||||
/* 0x7fc: data size (without blocks in case of blocked layout) */
|
||||
//if (read_32bitBE(0x7fc, streamFile) + start_offset != get_streamfile_size(streamFile))
|
||||
// goto fail;
|
||||
|
||||
start_offset = 0x800;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
|
@ -233,7 +233,7 @@ VGMSTREAM * init_vgmstream_ubi_jade(STREAMFILE *streamFile) {
|
||||
temp_streamFile = setup_subfile_streamfile(streamFile, start_offset, data_size, "msf");
|
||||
if (!temp_streamFile) goto fail;
|
||||
|
||||
temp_vgmstream = init_vgmstream_ps3_msf(temp_streamFile);
|
||||
temp_vgmstream = init_vgmstream_msf(temp_streamFile);
|
||||
close_streamfile(temp_streamFile);
|
||||
if (!temp_vgmstream) goto fail;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user