Merge pull request #1214 from NicknineTheEagle/ea

EA MPF: Fixed v4 parsing
This commit is contained in:
NicknineTheEagle 2022-09-02 06:22:12 +03:00 committed by GitHub
commit d2cecba34d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 17 deletions

View File

@ -756,7 +756,7 @@ VGMSTREAM* init_vgmstream_ea_mpf_mus_eaac(STREAMFILE* sf) {
for (i = 0; i < ram_segments; i++) {
entry_offset = table_offset + (bnk_sound_index + i) * 0x0c;
snr_offset = read_u32(entry_offset + 0x04, sf_mus);
data_s->segments[i] = init_vgmstream_eaaudiocore_header(sf_mus, sf_mus,
data_s->segments[i] = init_vgmstream_eaaudiocore_header(sf_mus, NULL,
snr_offset, 0,
meta_EA_SNR_SNS, 0);
if (!data_s->segments[i]) goto fail;

View File

@ -132,7 +132,7 @@ typedef struct {
size_t stream_size;
} ea_header;
static VGMSTREAM* parse_schl_block(STREAMFILE* sf, off_t offset, int standalone);
static VGMSTREAM* parse_schl_block(STREAMFILE* sf, off_t offset);
static VGMSTREAM* parse_bnk_header(STREAMFILE* sf, off_t offset, int target_stream, int is_embedded);
static int parse_variable_header(STREAMFILE* sf, ea_header* ea, off_t begin_offset, int max_length, int bnk_version);
static uint32_t read_patch(STREAMFILE* sf, off_t* offset);
@ -184,7 +184,7 @@ VGMSTREAM* init_vgmstream_ea_schl(STREAMFILE* sf) {
/* Stream is divided into blocks/chunks: SCHl=audio header, SCCl=count of SCDl, SCDl=data xN, SCLl=loop end, SCEl=end.
* Video uses picture blocks (MVhd/MV0K/etc) and sometimes multiaudio blocks (SHxx/SCxx/SDxx/SExx where xx=language).
* The number/size is affected by: block rate setting, sample rate, channels, CPU location (SPU/main/DSP/others), etc */
return parse_schl_block(sf, 0x00, 1);
return parse_schl_block(sf, 0x00);
fail:
return NULL;
@ -275,7 +275,7 @@ VGMSTREAM* init_vgmstream_ea_schl_video(STREAMFILE* sf) {
if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail;
vgmstream = parse_schl_block(sf, start_offset, 1);
vgmstream = parse_schl_block(sf, start_offset);
if (!vgmstream) goto fail;
vgmstream->num_streams = total_subsongs;
@ -428,7 +428,7 @@ VGMSTREAM* init_vgmstream_ea_abk(STREAMFILE* sf) {
if (read_32bitBE(schl_offset, astData) != EA_BLOCKID_HEADER)
goto fail;
vgmstream = parse_schl_block(astData, schl_offset, 0);
vgmstream = parse_schl_block(astData, schl_offset);
if (!vgmstream)
goto fail;
@ -455,9 +455,9 @@ VGMSTREAM* init_vgmstream_ea_abk(STREAMFILE* sf) {
if (!data_s) goto fail;
/* load intro and loop segments */
data_s->segments[0] = parse_schl_block(astData, schl_offset, 0);
data_s->segments[0] = parse_schl_block(astData, schl_offset);
if (!data_s->segments[0]) goto fail;
data_s->segments[1] = parse_schl_block(astData, schl_loop_offset, 0);
data_s->segments[1] = parse_schl_block(astData, schl_loop_offset);
if (!data_s->segments[1]) goto fail;
/* setup segmented VGMSTREAMs */
@ -545,7 +545,7 @@ VGMSTREAM *init_vgmstream_ea_hdr_dat(STREAMFILE *sf) {
/* offsets are always big endian */
sound_offset = read_u16be(0x0C + (0x02 + userdata_size) * (target_stream - 1), sf) * offset_mult;
if (read_u32be(sound_offset, sf_dat) == EA_BLOCKID_HEADER) { /* "SCHl" */
vgmstream = parse_schl_block(sf_dat, sound_offset, 0);
vgmstream = parse_schl_block(sf_dat, sound_offset);
if (!vgmstream)
goto fail;
} else if (read_u32be(sound_offset, sf_dat) == 0x56414770) { /* "VAGp" */
@ -633,7 +633,7 @@ VGMSTREAM* init_vgmstream_ea_hdr_dat_v2(STREAMFILE* sf) {
if (read_u32be(sound_offset, sf_dat) != EA_BLOCKID_HEADER)
goto fail;
vgmstream = parse_schl_block(sf_dat, sound_offset, 0);
vgmstream = parse_schl_block(sf_dat, sound_offset);
if (!vgmstream)
goto fail;
@ -803,7 +803,7 @@ VGMSTREAM* init_vgmstream_ea_map_mus(STREAMFILE* sf) {
if (read_32bitBE(schl_offset, sf_mus) != EA_BLOCKID_HEADER)
goto fail;
vgmstream = parse_schl_block(sf_mus, schl_offset, 0);
vgmstream = parse_schl_block(sf_mus, schl_offset);
if (!vgmstream)
goto fail;
@ -943,10 +943,8 @@ VGMSTREAM* init_vgmstream_ea_mpf_mus(STREAMFILE* sf) {
}
section_offset = entry_offset + 0x10 + subentry_num * 0x10;
/* TODO: verify this */
section_offset = read_u32(section_offset, sf) * 0x04;
section_offset += num_routers * 0x04;
section_offset += num_vars * 0x04;
section_offset = read_u32(section_offset, sf) * 0x04;
tracks_table = section_offset;
samples_table = tracks_table + (num_tracks + 1) * 0x04;
@ -1050,7 +1048,7 @@ VGMSTREAM* init_vgmstream_ea_mpf_mus(STREAMFILE* sf) {
if (version == 5) {
track_checksum = read_u32be(entry_offset + 0x14 + 0x10 * bnk_index, sf);
if (read_u32be(0x00, sf_mus) != track_checksum)
if (track_checksum && read_u32be(0x00, sf_mus) != track_checksum)
goto fail;
}
@ -1086,11 +1084,11 @@ VGMSTREAM* init_vgmstream_ea_mpf_mus(STREAMFILE* sf) {
if (version == 5 && track_checksum && read_u32be(0x00, sf_mus) != track_checksum)
goto fail;
sound_offset *= off_mult;;
sound_offset *= off_mult;
if (read_u32be(sound_offset, sf_mus) != EA_BLOCKID_HEADER)
goto fail;
vgmstream = parse_schl_block(sf_mus, sound_offset, 0);
vgmstream = parse_schl_block(sf_mus, sound_offset);
}
if (!vgmstream)
@ -1109,7 +1107,7 @@ fail:
}
/* EA SCHl with variable header - from EA games (roughly 1997~2010); generated by EA Canada's sx.exe/Sound eXchange */
static VGMSTREAM* parse_schl_block(STREAMFILE* sf, off_t offset, int standalone) {
static VGMSTREAM* parse_schl_block(STREAMFILE* sf, off_t offset) {
off_t start_offset, header_offset;
size_t header_size;
uint32_t header_id;