Fix some SFH/SSPR

This commit is contained in:
bnnm 2023-06-03 17:56:19 +02:00
parent 288d1e57d0
commit d5e567072b
2 changed files with 74 additions and 56 deletions

View File

@ -1,46 +1,65 @@
#include "meta.h" #include "meta.h"
#include "../coding/coding.h" #include "../coding/coding.h"
#include "sfh_streamfile.h" #include "sfh_streamfile.h"
typedef VGMSTREAM* (*init_vgmstream_t)(STREAMFILE*);
/* .SFH - Capcom wrapper [Devil May Cry 4 Demo (PS3), Jojo's Bizarre Adventure HD (PS3)] */
VGMSTREAM * init_vgmstream_sfh(STREAMFILE *streamFile) {
VGMSTREAM *vgmstream = NULL; /* .SFH - Capcom wrapper used with common audio extensions [Devil May Cry 4 Demo (PS3), Jojo's Bizarre Adventure HD (PS3), Sengoku Basara 4 Sumeragi (PS3)] */
STREAMFILE *temp_streamFile = NULL; VGMSTREAM* init_vgmstream_sfh(STREAMFILE* sf) {
uint32_t version; VGMSTREAM* vgmstream = NULL;
size_t clean_size, block_size; STREAMFILE* temp_sf = NULL;
init_vgmstream_t init_vgmstream = NULL;
/* check extensions */
if ( !check_extensions(streamFile,"at3"))
goto fail; /* checks */
if (!is_id32be(0x00, sf, "\0SFH"))
if (read_32bitBE(0x00, streamFile) != 0x00534648) /* "\0SFH" */ return NULL;
goto fail; if (!check_extensions(sf,"at3,sspr"))
if (read_32bitBE(0x10, streamFile) != 0x52494646) /* "RIFF" */ return NULL;
goto fail;
/* mini header */
/* mini header */ uint32_t version = read_u32be(0x04,sf);
version = read_32bitBE(0x04,streamFile); uint32_t clean_size = read_u32be(0x08,sf); /* there is padding data at the end */
clean_size = read_32bitBE(0x08,streamFile); /* there is padding data at the end */ /* 0x0c: always 0 */
/* 0x0c: always 0 */
char* extension;
switch(version) { uint32_t header_id = read_u32be(0x10,sf);
case 0x00010000: block_size = 0x10010; break; /* DMC4 Demo (not retail) */ switch(header_id) {
case 0x00010001: block_size = 0x20000; break; /* Jojo */ case 0x52494646: // RIFF
default: goto fail; init_vgmstream = init_vgmstream_riff;
} extension = "at3";
break;
temp_streamFile = setup_sfh_streamfile(streamFile, 0x00, block_size, clean_size, "at3");
if (!temp_streamFile) goto fail; case 0x53535052: // SSPR
init_vgmstream = init_vgmstream_sspr;
vgmstream = init_vgmstream_riff(temp_streamFile); extension = "sspr";
if (!vgmstream) goto fail; break;
close_streamfile(temp_streamFile); case 0x00434C44: // \0CLD (.dlcp)
return vgmstream; case 0x00435241: // \0CRA (.arc)
default:
fail: goto fail;
close_streamfile(temp_streamFile); }
close_vgmstream(vgmstream);
return NULL; uint32_t block_size;
} switch(version) {
case 0x00010000: block_size = 0x10010; break; /* DMC4 Demo (not retail) */
case 0x00010001: block_size = 0x20000; break; /* Jojo, SB4 */
default: goto fail;
}
temp_sf = setup_sfh_streamfile(sf, 0x00, block_size, clean_size, extension);
if (!temp_sf) goto fail;
vgmstream = init_vgmstream(temp_sf);
if (!vgmstream) goto fail;
close_streamfile(temp_sf);
return vgmstream;
fail:
close_streamfile(temp_sf);
close_vgmstream(vgmstream);
return NULL;
}

View File

@ -6,23 +6,22 @@
VGMSTREAM* init_vgmstream_sspr(STREAMFILE* sf) { VGMSTREAM* init_vgmstream_sspr(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL; VGMSTREAM* vgmstream = NULL;
STREAMFILE* temp_sf = NULL; STREAMFILE* temp_sf = NULL;
uint32_t name_offset, subfile_offset, subfile_size, name_size;
int big_endian;
int total_subsongs, target_subsong = sf->stream_index;
char* extension;
uint32_t (*read_u32)(off_t,STREAMFILE*) = NULL;
/* checks */ /* checks */
if (!check_extensions(sf,"sspr"))
goto fail;
if (!is_id32be(0x00,sf,"SSPR")) if (!is_id32be(0x00,sf,"SSPR"))
goto fail; return NULL;
if (!check_extensions(sf,"sspr"))
return NULL;
uint32_t name_offset, subfile_offset, subfile_size, name_size;
int total_subsongs, target_subsong = sf->stream_index;
char* extension;
read_u32_t read_u32 = NULL;
/* Simple (audio only) container used some Capcom games (common engine?). /* Simple (audio only) container used some Capcom games (common engine?).
* Some files come with a .stqr with unknown data (cues?). */ * Some files come with a .stqr with unknown data (cues?). */
big_endian = guess_endian32(0x04, sf); /* 0x01 (version?) */ int big_endian = guess_endian32(0x04, sf); /* 0x01 (version?) */
read_u32 = big_endian ? read_u32be : read_u32le; read_u32 = big_endian ? read_u32be : read_u32le;
total_subsongs = read_u32(0x08,sf); total_subsongs = read_u32(0x08,sf);