Merge pull request #1526 from bnnm/master

- Fix some .stx [Phantom Dust Remaster (PC)]
- Add RIFF .SE extension [Rockman X4 (PC)]
This commit is contained in:
bnnm 2024-05-11 15:48:08 +02:00 committed by GitHub
commit a990c971ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 73 additions and 37 deletions

View File

@ -497,6 +497,7 @@ static const char* extension_list[] = {
"sdp", //txth/reserved [Metal Gear Arcade (AC)]
"sdf",
"sdt",
"se",
"seb",
"sed",
"seg",

View File

@ -216,6 +216,9 @@ void block_update(off_t block_offset, VGMSTREAM* vgmstream) {
}
void blocked_count_samples(VGMSTREAM* vgmstream, STREAMFILE* sf, off_t offset) {
if (vgmstream == NULL)
return;
int block_samples;
off_t max_offset = get_streamfile_size(sf);
@ -231,9 +234,11 @@ void blocked_count_samples(VGMSTREAM* vgmstream, STREAMFILE* sf, off_t offset) {
}
else {
switch(vgmstream->coding_type) {
case coding_PCM16LE:
case coding_PCM16_int: block_samples = pcm16_bytes_to_samples(vgmstream->current_block_size, 1); break;
case coding_PCM8_int:
case coding_PCM8_U_int: block_samples = pcm8_bytes_to_samples(vgmstream->current_block_size, 1); break;
case coding_XBOX_IMA_int:
case coding_XBOX_IMA: block_samples = xbox_ima_bytes_to_samples(vgmstream->current_block_size, 1); break;
case coding_NGC_DSP: block_samples = dsp_bytes_to_samples(vgmstream->current_block_size, 1); break;
case coding_PSX: block_samples = ps_bytes_to_samples(vgmstream->current_block_size,1); break;

View File

@ -603,6 +603,7 @@ VGMSTREAM * init_vgmstream_ea_hdr_dat(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_ea_hdr_dat_v2(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_ea_map_mus(STREAMFILE * steeamFile);
VGMSTREAM * init_vgmstream_ea_mpf_mus(STREAMFILE * steeamFile);
VGMSTREAM* load_vgmstream_ea_bnk(STREAMFILE* sf, off_t offset, int target_stream, int is_embedded);
VGMSTREAM * init_vgmstream_ea_schl_fixed(STREAMFILE * streamFile);
@ -1004,7 +1005,6 @@ VGMSTREAM* init_vgmstream_cbx(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_vas_rockstar(STREAMFILE* sf);
VGMSTREAM* load_vgmstream_ea_bnk(STREAMFILE* sf, off_t offset, int target_stream, int is_embedded);
VGMSTREAM* init_vgmstream_ea_sbk(STREAMFILE* sf);
#endif /*_META_H*/

View File

@ -401,8 +401,9 @@ VGMSTREAM* init_vgmstream_riff(STREAMFILE* sf) {
* .caf: Topple (iOS)
* .wax: Lamborghini (Xbox)
* .voi: Sol Trigger (PSP)[ATRAC3]
* .se: Rockman X4 (PC)
*/
if (!check_extensions(sf, "wav,lwav,xwav,mwv,da,dax,cd,med,snd,adx,adp,xss,xsew,adpcm,adw,wd,,sbv,wvx,str,at3,rws,aud,at9,ckd,saf,ima,nsa,pcm,xvag,ogg,logg,p1d,xms,mus,dat,ldat,wma,lwma,caf,wax,voi")) {
if (!check_extensions(sf, "wav,lwav,xwav,mwv,da,dax,cd,med,snd,adx,adp,xss,xsew,adpcm,adw,wd,,sbv,wvx,str,at3,rws,aud,at9,ckd,saf,ima,nsa,pcm,xvag,ogg,logg,p1d,xms,mus,dat,ldat,wma,lwma,caf,wax,voi,se")) {
return NULL;
}

View File

@ -2,35 +2,58 @@
#include "../coding/coding.h"
#include "../layout/layout.h"
/* STHD - Dream Factory .stx [Kakuto Chojin (Xbox)] */
/* STHD - Dream Factory .stx [Kakuto Chojin (Xbox), Dinosaur Hunting (Xbox), Phantom Dust Remaster (PC)] */
VGMSTREAM* init_vgmstream_sthd(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
off_t start_offset;
int loop_flag, channel_count;
uint32_t start_offset;
int loop_flag, channels, sample_rate;
int loop_start_block, loop_end_block;
uint32_t build_date;
/* checks */
if (!is_id32be(0x00,sf, "STHD"))
goto fail;
return NULL;
if (!check_extensions(sf, "stx"))
goto fail;
/* first block has special values */
if (read_u16le(0x04,sf) != 0x0800 ||
read_u32le(0x14,sf) != 0x0000)
goto fail;
return NULL;
/* all blocks have STHD and have these values up to 0x20, size 0x800 */
start_offset = read_u16le(0x04,sf); /* next block in header, data offset in other blocks */
channels = read_s16le(0x06,sf);
build_date = read_u32le(0x08,sf); /* in hex (0x20030610 = 2003-06-10) */
/* 0x0c: ? (1 in Dinosaur Hunting, otherwise 0) */
if (start_offset != 0x0800 || channels > 8)
return NULL;
/* 0x10: total blocks */
/* 0x12: block number */
/* 0x14: null */
/* 0x16: channel size (0 in header block) */
/* 0x18: block number + 1? */
loop_start_block = read_u16le(0x1a,sf);
loop_end_block = read_u16le(0x1c,sf);
loop_flag = loop_start_block != 0xFFFF;
/* may be a bug since STHD blocks don't reach max (loop start seems fine) [Phantom Dust Remaster (PC)] */
if (build_date >= 0x20170000)
loop_end_block--;
/* channel info (first block only), seem to be repeated up to max 8 channels */
sample_rate = read_s32le(0x20, sf);
/* 0x24/28: volume/pan? (not always set) */
/* 0x210: stream name for both channels (same as file) */
channel_count = read_s16le(0x06,sf);
loop_flag = read_s16le(0x18,sf) != -1;
start_offset = read_u16le(0x04,sf);
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count, loop_flag);
vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_STHD;
vgmstream->sample_rate = read_s32le(0x20, sf); /* repeated ~8 times? */
vgmstream->sample_rate = sample_rate;
vgmstream->coding_type = coding_XBOX_IMA_int;
vgmstream->coding_type = build_date >= 0x20170000 ? /* no apparent flags [Phantom Dust Remaster (PC)] */
coding_PCM16LE :
coding_XBOX_IMA_int;
vgmstream->layout_type = layout_blocked_sthd;
if (!vgmstream_open_stream(vgmstream,sf,start_offset))
@ -39,19 +62,27 @@ VGMSTREAM * init_vgmstream_sthd(STREAMFILE *sf) {
/* calc num_samples manually (blocks data varies in size) */
{
/* loop values may change to +1 in first actual block, but this works ok enough */
int loop_start_block = (uint16_t)read_16bitLE(0x1a,sf);
int loop_end_block = (uint16_t)read_16bitLE(0x1c,sf);
int block_count = 1; /* header block = 0 */
vgmstream->next_block_offset = start_offset;
do {
block_update(vgmstream->next_block_offset, vgmstream);
if (vgmstream->current_block_samples < 0 || vgmstream->current_block_size == 0xFFFFFFFF)
break;
if (block_count == loop_start_block)
vgmstream->loop_start_sample = vgmstream->num_samples;
if (block_count == loop_end_block)
vgmstream->loop_end_sample = vgmstream->num_samples;
vgmstream->num_samples += xbox_ima_bytes_to_samples(vgmstream->current_block_size, 1);
int block_samples = 0;
switch(vgmstream->coding_type) {
case coding_PCM16LE: block_samples = pcm16_bytes_to_samples(vgmstream->current_block_size, 1); break;
case coding_XBOX_IMA_int: block_samples = xbox_ima_bytes_to_samples(vgmstream->current_block_size, 1); break;
default: goto fail;
}
vgmstream->num_samples += block_samples;
block_count++;
}
while (vgmstream->next_block_offset < get_streamfile_size(sf));

View File

@ -9,13 +9,13 @@
#define WAVEBANKENTRY_FLAGS_IGNORELOOP 0x00000008 // Used internally when the loop region can't be used (no idea...)
/* the x.x version is just to make it clearer, MS only classifies XACT as 1/2/3 */
#define XACT1_0_MAX 1 /* Project Gotham Racing 2 (v1), Silent Hill 4 (v1), Shin Megami Tensei NINE (v1) */
#define XACT1_1_MAX 3 /* Unreal Championship (v2), The King of Fighters 2003 (v3) */
#define XACT2_0_MAX 34 /* Dead or Alive 4 (v17), Kameo (v23), Table Tennis (v34) */ // v35/36/37 too?
#define XACT2_1_MAX 38 /* Prey (v38) */ // v39 too?
#define XACT2_2_MAX 41 /* Blue Dragon (v40) */
#define XACT3_0_MAX 46 /* Ninja Blade (t43 v42), Persona 4 Ultimax NESSICA (t45 v43) */
#define XACT_TECHLAND 0x10000 /* Sniper Ghost Warrior, Nail'd (PS3/X360), equivalent to XACT3_0 */
#define XACT1_0_MAX 1 /* Project Gotham Racing 2 (Xbox)-v01, Silent Hill 4 (Xbox)-v01, Shin Megami Tensei NINE (Xbox)-v01 */
#define XACT1_1_MAX 3 /* Unreal Championship (Xbox)-v02, The King of Fighters 2003 (Xbox)-v03 */
#define XACT2_0_MAX 34 /* Project Gotham Racing 3 (X360)-v22, Dead or Alive 4 (X360)-v23, Table Tennis (X360)-v34 */ // v35/36/37 too?
#define XACT2_1_MAX 38 /* Prey (X360)-v38 */
#define XACT2_2_MAX 41 /* Just Cause (X360)-v39, Blue Dragon (X360)-v40 */
#define XACT3_0_MAX 46 /* Ninja Blade (X360)-t43-v42, Saints Row 2 (PC)-t44-v42, Persona 4 Ultimax NESSICA (PC)-t45-v43, BlazBlue (X360)-t46-v44 */
#define XACT_TECHLAND 0x10000 /* Sniper Ghost Warrior (PS3/X360), Nail'd (PS3/X360), equivalent to XACT3_0 */
#define XACT_CRACKDOWN 0x87 /* Crackdown 1, equivalent to XACT2_2 */
static const int wma_avg_bps_index[7] = {
@ -91,7 +91,7 @@ VGMSTREAM* init_vgmstream_xwb(STREAMFILE* sf) {
/* checks */
if (!is_id32be(0x00,sf, "WBND") &&
!is_id32le(0x00,sf, "WBND")) /* X360 */
goto fail;
return NULL;
/* .xwb: standard
* .xna: Touhou Makukasai ~ Fantasy Danmaku Festival (PC)
@ -99,7 +99,7 @@ VGMSTREAM* init_vgmstream_xwb(STREAMFILE* sf) {
* .hwb: Burnout Revenge (X360)
* .bd: Fatal Frame 2 (Xbox) */
if (!check_extensions(sf,"xwb,xna,hwb,bd,"))
goto fail;
return NULL;
xwb.little_endian = is_id32be(0x00,sf, "WBND"); /* Xbox/PC */
if (xwb.little_endian) {
@ -409,7 +409,7 @@ VGMSTREAM* init_vgmstream_xwb(STREAMFILE* sf) {
}
else if ((xwb.version <= XACT2_1_MAX && (xwb.codec == XMA1 || xwb.codec == XMA2) && xwb.loop_flag)
|| (xwb.version == XACT_TECHLAND && xwb.codec == XMA2)) {
/* v38: byte offset, v40+: sample offset, v39: ? */
/* v38: byte offset, v39/v40+: sample offset */
/* need to manually find sample offsets, thanks to Microsoft's dumb headers */
ms_sample_data msd = {0};
@ -587,7 +587,6 @@ VGMSTREAM* init_vgmstream_xwb(STREAMFILE* sf) {
break;
}
#ifdef VGM_USE_ATRAC9
case ATRAC9_RIFF: { /* Stardew Valley (Vita) extension */
VGMSTREAM *temp_vgmstream = NULL;
STREAMFILE* temp_sf = NULL;
@ -610,7 +609,6 @@ VGMSTREAM* init_vgmstream_xwb(STREAMFILE* sf) {
close_vgmstream(vgmstream);
return temp_vgmstream;
}
#endif
default:
goto fail;