Accept EA SCHl "SHFR" blocks [Medal of Honor (PC) movies]

This commit is contained in:
bnnm 2018-03-29 22:52:15 +02:00
parent 92b9992552
commit 868834d52b
2 changed files with 13 additions and 12 deletions

View File

@ -21,7 +21,7 @@ void block_update_ea_schl(off_t block_offset, VGMSTREAM * vgmstream) {
block_samples = 0;
if (id == 0x5343446C || id == 0x5344454E) { /* "SCDl" "SDEN" audio data */
if (id == 0x5343446C || id == 0x5344454E || id == 0x53444652) { /* "SCDl" "SDEN" "SDFR" audio data */
switch(vgmstream->coding_type) {
case coding_PSX:
block_samples = ps_bytes_to_samples(block_size-0x10, vgmstream->channels);
@ -37,7 +37,7 @@ void block_update_ea_schl(off_t block_offset, VGMSTREAM * vgmstream) {
block_size = 0x04;
}
if (id == 0x5343486C || id == 0x5348454E) { /* "SCHl" "SHEN" end block */
if (id == 0x5343486C || id == 0x5348454E || id == 0x53484652) { /* "SCHl" "SHEN" "SHFR" end block */
new_schl = 1;
}
}
@ -53,8 +53,8 @@ void block_update_ea_schl(off_t block_offset, VGMSTREAM * vgmstream) {
break;
block_offset += block_size;
/* "SCEl" are aligned to 0x80 usually, but causes problems if not 32b-aligned (ex. Need for Speed 2 PC) */
if ((id == 0x5343456C || id == 0x5345454E) && block_offset % 0x04) {
/* "SCEl" "SEEN" "SEFR" are aligned to 0x80 usually, but causes problems if not 32b-aligned (ex. Need for Speed 2 PC) */
if ((id == 0x5343456C || id == 0x5345454E || id == 0x53454652) && block_offset % 0x04) {
block_offset += 0x04 - (block_offset % 0x04);
}
}

View File

@ -92,11 +92,12 @@ VGMSTREAM * init_vgmstream_ea_schl(STREAMFILE *streamFile) {
/* check header */
if (read_32bitBE(0x00,streamFile) != 0x5343486C && /* "SCHl" */
read_32bitBE(0x00,streamFile) != 0x5348454E) /* "SHEN" */
read_32bitBE(0x00,streamFile) != 0x5348454E && /* "SHEN" */
read_32bitBE(0x00,streamFile) != 0x53484652) /* "SHFR" */
goto fail;
/* stream is divided into blocks/chunks: SCHl=audio header, SCCl=count of SCDl, SCDl=data xN, SCLl=loop end, SCEl=end.
* Video uses various blocks (MVhd/MV0K/etc) and sometimes alt audio blocks (SHEN/SDEN/SEEN).
* Video uses various blocks (MVhd/MV0K/etc) and sometimes alt audio blocks (SHxx/SCxx/SDxx/SExx where XX=language, EN/FR).
* The number/size is affected by: block rate setting, sample rate, channels, CPU location (SPU/main/DSP/others), etc */
header_size = read_32bitLE(0x04,streamFile);
@ -769,7 +770,7 @@ static int get_ea_stream_total_samples(STREAMFILE* streamFile, off_t start_offse
block_samples = 0;
if (id == 0x5343446C || id == 0x5344454E) { /* "SCDl" "SDEN" audio data */
if (id == 0x5343446C || id == 0x5344454E || id == 0x53444652) { /* "SCDl" "SDEN" "SDFR" audio data */
switch (ea->codec2) {
case EA_CODEC2_VAG:
block_samples = ps_bytes_to_samples(block_size-0x10, ea->channels);
@ -785,7 +786,7 @@ static int get_ea_stream_total_samples(STREAMFILE* streamFile, off_t start_offse
block_size = 0x04;
}
if (id == 0x5343486C || id == 0x5348454E) { /* "SCHl" "SHEN" end block */
if (id == 0x5343486C || id == 0x5348454E || id == 0x53484652) { /* "SCHl" "SHEN" "SHFR" end block */
new_schl = 1;
}
}
@ -800,8 +801,8 @@ static int get_ea_stream_total_samples(STREAMFILE* streamFile, off_t start_offse
num_samples += block_samples;
block_offset += block_size;
/* "SCEl" are aligned to 0x80 usually, but causes problems if not 32b-aligned (ex. Need for Speed 2 PC) */
if ((id == 0x5343456C || id == 0x5345454E) && block_offset % 0x04) {
/* "SCEl" "SEEN" "SEFR" are aligned to 0x80 usually, but causes problems if not 32b-aligned (ex. Need for Speed 2 PC) */
if ((id == 0x5343456C || id == 0x5345454E || id == 0x53454652) && block_offset % 0x04) {
VGM_LOG_ONCE("EA SCHl: mis-aligned end offset found\n");
block_offset += 0x04 - (block_offset % 0x04);
}
@ -832,10 +833,10 @@ static off_t get_ea_stream_mpeg_start_offset(STREAMFILE* streamFile, off_t start
if (block_size > 0x00F00000) /* size is always LE, except in early SAT/MAC */
block_size = read_32bitBE(block_offset+0x04,streamFile);
if (id == 0x5343446C) { /* "SCDl" data block found */
if (id == 0x5343446C || id == 0x5344454E || id == 0x53444652) { /* "SCDl/SDEN/SDFR" data block found */
off_t offset = read_32bit(block_offset+0x0c,streamFile); /* first value seems ok, second is something else in EALayer3 */
return block_offset + 0x0c + ea->channels*0x04 + offset;
} else if (id == 0x5343436C) { /* "SCCl" data count found */
} else if (id == 0x5343436C || id == 0x5343454E || id == 0x53434652) { /* "SCCl/SCEN/SCFR" data count found */
block_offset += block_size; /* size includes header */
continue;
} else {