mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-17 23:36:41 +01:00
Fix PCM SAB/MAB [Chrono Trigger (PC)]
Also rename post_meta/subheader to "extradata" as seen in debug strings from the exes
This commit is contained in:
parent
51aa1660f2
commit
b8641db34c
@ -7,8 +7,8 @@ static STREAMFILE* setup_sead_hca_streamfile(STREAMFILE *streamFile, off_t subfi
|
||||
/* SABF/MABF - Square Enix's "sead" audio games [Dragon Quest Builders (PS3), Dissidia Opera Omnia (mobile), FF XV (PS4)] */
|
||||
VGMSTREAM * init_vgmstream_sqex_sead(STREAMFILE * streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
off_t start_offset, tables_offset, mtrl_offset, meta_offset, post_meta_offset; //, info_offset, name_offset = 0;
|
||||
size_t stream_size, descriptor_size, subheader_size, special_size; //, name_size = 0;
|
||||
off_t start_offset, tables_offset, mtrl_offset, meta_offset, extradata_offset; //, info_offset, name_offset = 0;
|
||||
size_t stream_size, descriptor_size, extradata_size, special_size; //, name_size = 0;
|
||||
|
||||
|
||||
int loop_flag = 0, channel_count, codec, sample_rate, loop_start, loop_end;
|
||||
@ -118,12 +118,12 @@ VGMSTREAM * init_vgmstream_sqex_sead(STREAMFILE * streamFile) {
|
||||
loop_start = read_32bit(meta_offset+0x0c,streamFile); /* in samples but usually ignored */
|
||||
|
||||
loop_end = read_32bit(meta_offset+0x10,streamFile);
|
||||
subheader_size = read_32bit(meta_offset+0x14,streamFile); /* including subfile header */
|
||||
extradata_size = read_32bit(meta_offset+0x14,streamFile); /* including subfile header, can be 0 */
|
||||
stream_size = read_32bit(meta_offset+0x18,streamFile); /* not including subfile header */
|
||||
special_size = read_32bit(meta_offset+0x1c,streamFile);
|
||||
|
||||
loop_flag = (loop_end > 0);
|
||||
post_meta_offset = meta_offset + 0x20;
|
||||
extradata_offset = meta_offset + 0x20;
|
||||
|
||||
|
||||
/** info section (get stream name) **/
|
||||
@ -155,19 +155,32 @@ VGMSTREAM * init_vgmstream_sqex_sead(STREAMFILE * streamFile) {
|
||||
|
||||
switch(codec) {
|
||||
|
||||
case 0x01: { /* PCM [Chrono Trigger sfx (PC)] */
|
||||
start_offset = extradata_offset + extradata_size;
|
||||
|
||||
vgmstream->coding_type = coding_PCM16LE;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x02;
|
||||
|
||||
vgmstream->num_samples = pcm_bytes_to_samples(stream_size, vgmstream->channels, 16);
|
||||
vgmstream->loop_start_sample = loop_start;
|
||||
vgmstream->loop_end_sample = loop_end;
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x02: { /* MSADPCM [Dragon Quest Builders (Vita) sfx] */
|
||||
start_offset = post_meta_offset + subheader_size;
|
||||
start_offset = extradata_offset + extradata_size;
|
||||
|
||||
/* 0x00 (2): null?, 0x02(2): entry size? */
|
||||
vgmstream->coding_type = coding_MSADPCM;
|
||||
vgmstream->layout_type = layout_none;
|
||||
vgmstream->interleave_block_size = read_16bit(post_meta_offset+0x04,streamFile);
|
||||
vgmstream->interleave_block_size = read_16bit(extradata_offset+0x04,streamFile);
|
||||
|
||||
/* much like AKBs, there are slightly different loop values here, probably more accurate
|
||||
* (if no loop, loop_end doubles as num_samples) */
|
||||
vgmstream->num_samples = msadpcm_bytes_to_samples(stream_size, vgmstream->interleave_block_size, vgmstream->channels);
|
||||
vgmstream->loop_start_sample = read_32bit(post_meta_offset+0x08, streamFile); //loop_start
|
||||
vgmstream->loop_end_sample = read_32bit(post_meta_offset+0x0c, streamFile); //loop_end
|
||||
vgmstream->loop_start_sample = read_32bit(extradata_offset+0x08, streamFile); //loop_start
|
||||
vgmstream->loop_end_sample = read_32bit(extradata_offset+0x0c, streamFile); //loop_end
|
||||
break;
|
||||
}
|
||||
|
||||
@ -175,7 +188,7 @@ VGMSTREAM * init_vgmstream_sqex_sead(STREAMFILE * streamFile) {
|
||||
case 0x03: { /* OGG [Final Fantasy XV Benchmark sfx (PC)] */
|
||||
VGMSTREAM *ogg_vgmstream = NULL;
|
||||
vgm_vorbis_info_t inf = {0};
|
||||
off_t subfile_offset = post_meta_offset + subheader_size;
|
||||
off_t subfile_offset = extradata_offset + extradata_size;
|
||||
char filename[PATH_LIMIT];
|
||||
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
@ -206,21 +219,21 @@ VGMSTREAM * init_vgmstream_sqex_sead(STREAMFILE * streamFile) {
|
||||
case 0x04: { /* ATRAC9 [Dragon Quest Builders (Vita), Final Fantaxy XV (PS4)] */
|
||||
atrac9_config cfg = {0};
|
||||
|
||||
start_offset = post_meta_offset + subheader_size;
|
||||
start_offset = extradata_offset + extradata_size;
|
||||
/* post header has various typical ATRAC9 values */
|
||||
cfg.channels = vgmstream->channels;
|
||||
cfg.config_data = read_32bit(post_meta_offset+0x0c,streamFile);
|
||||
cfg.encoder_delay = read_32bit(post_meta_offset+0x18,streamFile);
|
||||
cfg.config_data = read_32bit(extradata_offset+0x0c,streamFile);
|
||||
cfg.encoder_delay = read_32bit(extradata_offset+0x18,streamFile);
|
||||
|
||||
vgmstream->codec_data = init_atrac9(&cfg);
|
||||
if (!vgmstream->codec_data) goto fail;
|
||||
vgmstream->coding_type = coding_ATRAC9;
|
||||
vgmstream->layout_type = layout_none;
|
||||
|
||||
vgmstream->sample_rate = read_32bit(post_meta_offset+0x1c,streamFile); /* SAB's sample rate can be different but it's ignored */
|
||||
vgmstream->num_samples = read_32bit(post_meta_offset+0x10,streamFile); /* loop values above are also weird and ignored */
|
||||
vgmstream->loop_start_sample = read_32bit(post_meta_offset+0x20, streamFile) - (loop_flag ? cfg.encoder_delay : 0); //loop_start
|
||||
vgmstream->loop_end_sample = read_32bit(post_meta_offset+0x24, streamFile) - (loop_flag ? cfg.encoder_delay : 0); //loop_end
|
||||
vgmstream->sample_rate = read_32bit(extradata_offset+0x1c,streamFile); /* SAB's sample rate can be different but it's ignored */
|
||||
vgmstream->num_samples = read_32bit(extradata_offset+0x10,streamFile); /* loop values above are also weird and ignored */
|
||||
vgmstream->loop_start_sample = read_32bit(extradata_offset+0x20, streamFile) - (loop_flag ? cfg.encoder_delay : 0); //loop_start
|
||||
vgmstream->loop_end_sample = read_32bit(extradata_offset+0x24, streamFile) - (loop_flag ? cfg.encoder_delay : 0); //loop_end
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
@ -230,7 +243,7 @@ VGMSTREAM * init_vgmstream_sqex_sead(STREAMFILE * streamFile) {
|
||||
mpeg_codec_data *mpeg_data = NULL;
|
||||
mpeg_custom_config cfg = {0};
|
||||
|
||||
start_offset = post_meta_offset + subheader_size;
|
||||
start_offset = extradata_offset + extradata_size;
|
||||
/* post header is a proper MSF, but sample rate/loops are ignored in favor of SAB's */
|
||||
|
||||
mpeg_data = init_mpeg_custom(streamFile, start_offset, &vgmstream->coding_type, vgmstream->channels, MPEG_STANDARD, &cfg);
|
||||
@ -249,13 +262,13 @@ VGMSTREAM * init_vgmstream_sqex_sead(STREAMFILE * streamFile) {
|
||||
//todo there is no easy way to use the HCA decoder; try subfile hack for now
|
||||
VGMSTREAM *temp_vgmstream = NULL;
|
||||
STREAMFILE *temp_streamFile = NULL;
|
||||
off_t subfile_offset = post_meta_offset + 0x10;
|
||||
size_t subfile_size = stream_size + subheader_size - 0x10;
|
||||
off_t subfile_offset = extradata_offset + 0x10;
|
||||
size_t subfile_size = stream_size + extradata_size - 0x10;
|
||||
|
||||
/* post header: values from the HCA header, in file endianness + HCA header */
|
||||
size_t key_start = special_size & 0xff;
|
||||
size_t header_size = read_16bit(post_meta_offset+0x02, streamFile);
|
||||
int encryption = read_16bit(post_meta_offset+0x0c, streamFile); //maybe 8bit?
|
||||
size_t header_size = read_16bit(extradata_offset+0x02, streamFile);
|
||||
int encryption = read_16bit(extradata_offset+0x0c, streamFile); //maybe 8bit?
|
||||
/* encryption type 0x01 found in Final Fantasy XII TZA (PS4/PC) */
|
||||
|
||||
temp_streamFile = setup_sead_hca_streamfile(streamFile, subfile_offset, subfile_size, encryption, header_size, key_start);
|
||||
|
Loading…
x
Reference in New Issue
Block a user