mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-17 23:36:41 +01:00
Prepare RIFF/FSB5/SXD/UBI_RAKI/WWISE/XVAG/GTD for ATRAC9
This commit is contained in:
parent
ef3ba857f5
commit
5be6d14b4c
@ -221,11 +221,29 @@ static VGMSTREAM * init_vgmstream_eaaudiocore_header(STREAMFILE * streamHead, ST
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0 //todo unknown variation
|
||||
#ifdef VGM_USE_ATRAC9
|
||||
case 0x0a: { /* EATrax */
|
||||
atrac9_config cfg = {0};
|
||||
|
||||
cfg.channels = vgmstream->channels;
|
||||
cfg.config_data = read_32bitBE(header_offset + 0x08,streamHead);
|
||||
/* 0x0c: data size without blocks?, 0x10: frame size? (same as config data?) */
|
||||
|
||||
vgmstream->codec_data = init_atrac9(&cfg);
|
||||
if (!vgmstream->codec_data) goto fail;
|
||||
vgmstream->coding_type = coding_ATRAC9;
|
||||
vgmstream->layout_type = layout_blocked_ea_sns;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
case 0x00: /* "NONE" (internal 'codec not set' flag) */
|
||||
case 0x01: /* not used/reserved? Gca0/MP30/P6L0/P2B0/P2L0/P8S0/P8U0/PFN0? */
|
||||
case 0x08: /* ? */
|
||||
case 0x09: /* EASpeex (libspeex variant, base versions vary: 1.0.5, 1.2beta3) */
|
||||
case 0x0a: /* EATrax (ATRAC9 variant, has deflated fillers a la EA-XMA) */
|
||||
case 0x0b: /* ? */
|
||||
case 0x0c: /* EAOpus (inside each SNS/SPS block is 16b frame size + standard? Opus packet) */
|
||||
case 0x0d: /* ? */
|
||||
|
@ -6,13 +6,12 @@
|
||||
VGMSTREAM * init_vgmstream_fsb5(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
off_t StartOffset = 0, NameOffset = 0;
|
||||
off_t SampleHeaderStart = 0, DSPInfoStart = 0;
|
||||
off_t SampleHeaderStart = 0, ExtraInfoStart = 0;
|
||||
size_t SampleHeaderLength, NameTableLength, SampleDataLength, BaseHeaderLength, StreamSize = 0;
|
||||
|
||||
uint32_t NumSamples = 0, LoopStart = 0, LoopEnd = 0;
|
||||
int LoopFlag = 0, ChannelCount = 0, SampleRate = 0, CodingID;
|
||||
int TotalStreams, TargetStream = streamFile->stream_index;
|
||||
uint32_t VorbisSetupId = 0;
|
||||
int i;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
@ -116,15 +115,16 @@ VGMSTREAM * init_vgmstream_fsb5(STREAMFILE *streamFile) {
|
||||
case 0x06: /* XMA seek table */
|
||||
/* no need for it */
|
||||
break;
|
||||
case 0x07: /* DSP Info (Coeffs) */
|
||||
DSPInfoStart = ExtraFlagStart + 0x04;
|
||||
case 0x07: /* DSP coeffs */
|
||||
ExtraInfoStart = ExtraFlagStart + 0x04;
|
||||
break;
|
||||
case 0x09: /* ATRAC9 data */
|
||||
case 0x09: /* ATRAC9 config */
|
||||
ExtraInfoStart = ExtraFlagStart + 0x04;
|
||||
break;
|
||||
case 0x0a: /* XWMA data */
|
||||
break;
|
||||
case 0x0b: /* Vorbis data */
|
||||
VorbisSetupId = (uint32_t)read_32bitLE(ExtraFlagStart+0x04,streamFile); /* crc32? */
|
||||
case 0x0b: /* Vorbis setup ID and seek table */
|
||||
ExtraInfoStart = ExtraFlagStart + 0x04;
|
||||
/* seek table format:
|
||||
* 0x08: table_size (total_entries = seek_table_size / (4+4)), not counting this value; can be 0
|
||||
* 0x0C: sample number (only some samples are saved in the table)
|
||||
@ -221,7 +221,7 @@ VGMSTREAM * init_vgmstream_fsb5(STREAMFILE *streamFile) {
|
||||
vgmstream->layout_type = layout_none;
|
||||
vgmstream->interleave_block_size = 0x02;
|
||||
|
||||
dsp_read_coefs_be(vgmstream,streamFile,DSPInfoStart,0x2E);
|
||||
dsp_read_coefs_be(vgmstream,streamFile,ExtraInfoStart,0x2E);
|
||||
break;
|
||||
|
||||
case 0x07: /* FMOD_SOUND_FORMAT_IMAADPCM */
|
||||
@ -272,8 +272,20 @@ VGMSTREAM * init_vgmstream_fsb5(STREAMFILE *streamFile) {
|
||||
case 0x0C: /* FMOD_SOUND_FORMAT_CELT */
|
||||
goto fail;
|
||||
|
||||
case 0x0D: /* FMOD_SOUND_FORMAT_AT9 */
|
||||
goto fail;
|
||||
#ifdef VGM_USE_ATRAC9
|
||||
case 0x0D: {/* FMOD_SOUND_FORMAT_AT9 */
|
||||
atrac9_config cfg = {0};
|
||||
|
||||
cfg.channels = vgmstream->channels;
|
||||
cfg.config_data = read_32bitBE(ExtraInfoStart,streamFile);
|
||||
|
||||
vgmstream->codec_data = init_atrac9(&cfg);
|
||||
if (!vgmstream->codec_data) goto fail;
|
||||
vgmstream->coding_type = coding_ATRAC9;
|
||||
vgmstream->layout_type = layout_none;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
case 0x0E: /* FMOD_SOUND_FORMAT_XWMA */
|
||||
goto fail;
|
||||
@ -284,7 +296,7 @@ VGMSTREAM * init_vgmstream_fsb5(STREAMFILE *streamFile) {
|
||||
|
||||
cfg.channels = vgmstream->channels;
|
||||
cfg.sample_rate = vgmstream->sample_rate;
|
||||
cfg.setup_id = VorbisSetupId;
|
||||
cfg.setup_id = read_32bitLE(ExtraInfoStart,streamFile);
|
||||
|
||||
vgmstream->layout_type = layout_none;
|
||||
vgmstream->coding_type = coding_VORBIS_custom;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
typedef enum { XMA2 } gtd_codec;
|
||||
typedef enum { XMA2, ATRAC9 } gtd_codec;
|
||||
|
||||
/* GTD - found in Knights Contract (X360, PS3), Valhalla Knights 3 (PSV) */
|
||||
VGMSTREAM * init_vgmstream_gtd(STREAMFILE *streamFile) {
|
||||
@ -10,6 +10,7 @@ VGMSTREAM * init_vgmstream_gtd(STREAMFILE *streamFile) {
|
||||
size_t data_size, chunk_size;
|
||||
int loop_flag, channel_count, sample_rate;
|
||||
int num_samples, loop_start_sample, loop_end_sample;
|
||||
uint32_t at9_config_data;
|
||||
gtd_codec codec;
|
||||
|
||||
|
||||
@ -34,30 +35,41 @@ VGMSTREAM * init_vgmstream_gtd(STREAMFILE *streamFile) {
|
||||
data_size = read_32bitBE(0x5c,streamFile);
|
||||
/* 0x34(18): null, 0x54(4): seek table offset, 0x58(4): seek table size, 0x5c(8): null, 0x64: seek table */
|
||||
|
||||
stpr_offset = read_32bitBE(chunk_offset+0x54,streamFile) + read_32bitBE(chunk_offset+0x58,streamFile);;
|
||||
stpr_offset = read_32bitBE(chunk_offset+0x54,streamFile) + read_32bitBE(chunk_offset+0x58,streamFile);
|
||||
if (read_32bitBE(stpr_offset,streamFile) == 0x53545052) { /* "STPR" */
|
||||
name_offset = stpr_offset + 0xB8; /* there are offsets fields but seems to work */
|
||||
}
|
||||
|
||||
codec = XMA2;
|
||||
}
|
||||
else if (0x34 + read_32bitLE(0x30,streamFile) + read_32bitLE(0x0c,streamFile) == get_streamfile_size(streamFile)) { /* ATRAC9 */
|
||||
|
||||
data_size = read_32bitLE(0x0c,streamFile);
|
||||
start_offset = 0x34 + read_32bitLE(0x30,streamFile);
|
||||
channel_count = read_32bitLE(0x10,streamFile);
|
||||
sample_rate = read_32bitLE(0x14,streamFile);
|
||||
at9_config_data = read_32bitBE(0x28,streamFile);
|
||||
/* 0x18-0x28: fixed/unknown values */
|
||||
|
||||
stpr_offset = 0x2c;
|
||||
if (read_32bitBE(stpr_offset,streamFile) == 0x53545052) { /* "STPR" */
|
||||
name_offset = stpr_offset + 0xE8; /* there are offsets fields but seems to work */
|
||||
}
|
||||
|
||||
codec = ATRAC9;
|
||||
}
|
||||
else {
|
||||
/* there are PSV (LE, ATRAC9 data) and PS3 (MSF inside?) variations, somewhat-but-not-quite similar */
|
||||
|
||||
/* for PSV: */
|
||||
/* 0x0c: data_size, 0x10: channles, 0x14: sample rate, 0x18-0x2c: fixed and unknown values */
|
||||
/* 0x2c: STPR chunk, with name_offset at + 0xE8 */
|
||||
|
||||
/* apparently there is a PS3 variation (MSF inside?) */
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->sample_rate = sample_rate;
|
||||
vgmstream->num_samples = num_samples;
|
||||
vgmstream->loop_start_sample = loop_start_sample;
|
||||
vgmstream->loop_end_sample = loop_end_sample;
|
||||
vgmstream->meta_type = meta_GTD;
|
||||
@ -77,9 +89,29 @@ VGMSTREAM * init_vgmstream_gtd(STREAMFILE *streamFile) {
|
||||
if ( !vgmstream->codec_data ) goto fail;
|
||||
vgmstream->coding_type = coding_FFmpeg;
|
||||
vgmstream->layout_type = layout_none;
|
||||
|
||||
vgmstream->num_samples = num_samples;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef VGM_USE_ATRAC9
|
||||
case ATRAC9: {
|
||||
atrac9_config cfg = {0};
|
||||
|
||||
cfg.channels = vgmstream->channels;
|
||||
cfg.config_data = at9_config_data;
|
||||
|
||||
vgmstream->codec_data = init_atrac9(&cfg);
|
||||
if (!vgmstream->codec_data) goto fail;
|
||||
vgmstream->coding_type = coding_ATRAC9;
|
||||
vgmstream->layout_type = layout_none;
|
||||
|
||||
vgmstream->num_samples = atrac9_bytes_to_samples(data_size, vgmstream->codec_data);
|
||||
break;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
|
@ -183,6 +183,19 @@ static int read_fmt(int big_endian, STREAMFILE * streamFile, off_t current_chunk
|
||||
goto fail;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ATRAC9 GUID 47E142D2-36BA-4d8d-88FC-61654F8C836C (D242E147 BA368D4D 88FC6165 4F8C836C) */
|
||||
if (read_32bitBE(current_chunk+0x20,streamFile) == 0xD242E147 &&
|
||||
read_32bitBE(current_chunk+0x24,streamFile) == 0xBA368D4D &&
|
||||
read_32bitBE(current_chunk+0x28,streamFile) == 0x88FC6165 &&
|
||||
read_32bitBE(current_chunk+0x2c,streamFile) == 0x4F8C836C) {
|
||||
#ifdef VGM_USE_ATRAC9
|
||||
fmt->coding_type = coding_ATRAC9;
|
||||
#else
|
||||
goto fail;
|
||||
#endif
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -218,7 +231,7 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) {
|
||||
off_t mwv_ctrl_offset = -1;
|
||||
int sns = 0; /* Ubisoft .sns LyN engine (Red Steel 2, Just Dance 3) */
|
||||
int at3 = 0; /* Sony ATRAC3 / ATRAC3plus */
|
||||
|
||||
int at9 = 0; /* Sony ATRAC9 */
|
||||
|
||||
/* check extension, case insensitive
|
||||
* .da: The Great Battle VI (PS), .cd: Exector (PS), .med: Psi Ops (PC) */
|
||||
@ -231,12 +244,13 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) {
|
||||
else if ( check_extensions(streamFile, "sns") ) {
|
||||
sns = 1;
|
||||
}
|
||||
#if defined(VGM_USE_MAIATRAC3PLUS) || defined(VGM_USE_FFMPEG)
|
||||
/* .rws: Climax games (Silent Hill Origins PSP, Oblivion PSP), .aud: EA Replay */
|
||||
else if ( check_extensions(streamFile, "at3,rws,aud") ) {
|
||||
at3 = 1;
|
||||
}
|
||||
#endif
|
||||
else if ( check_extensions(streamFile, "at9") ) {
|
||||
at9 = 1;
|
||||
}
|
||||
else {
|
||||
goto fail;
|
||||
}
|
||||
@ -323,10 +337,10 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) {
|
||||
case 0x66616374: /* fact */
|
||||
if (sns && chunk_size == 0x10) {
|
||||
fact_sample_count = read_32bitLE(current_chunk+0x08, streamFile);
|
||||
} else if (at3 && chunk_size == 0x08) {
|
||||
} else if ((at3 || at9) && chunk_size == 0x08) {
|
||||
fact_sample_count = read_32bitLE(current_chunk+0x08, streamFile);
|
||||
fact_sample_skip = read_32bitLE(current_chunk+0x0c, streamFile);
|
||||
} else if (at3 && chunk_size == 0x0c) {
|
||||
} else if ((at3 || at9) && chunk_size == 0x0c) {
|
||||
fact_sample_count = read_32bitLE(current_chunk+0x08, streamFile);
|
||||
fact_sample_skip = read_32bitLE(current_chunk+0x10, streamFile);
|
||||
}
|
||||
@ -453,6 +467,27 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) {
|
||||
vgmstream->num_samples = fact_sample_count + fact_sample_skip;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef VGM_USE_ATRAC9
|
||||
case coding_ATRAC9: {
|
||||
atrac9_config cfg = {0};
|
||||
|
||||
cfg.channels = vgmstream->channels;
|
||||
cfg.config_data = read_32bitBE(fmt.offset+0x08+0x2c,streamFile);
|
||||
cfg.encoder_delay = fact_sample_skip;
|
||||
|
||||
vgmstream->codec_data = init_atrac9(&cfg);
|
||||
if (!vgmstream->codec_data) goto fail;
|
||||
|
||||
vgmstream->num_samples = fact_sample_count;
|
||||
/* RIFF loop/sample values are absolute (with skip samples), adjust */
|
||||
if (loop_flag) {
|
||||
loop_start_offset -= fact_sample_skip;
|
||||
loop_end_offset -= fact_sample_skip;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
goto fail;
|
||||
@ -473,6 +508,9 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) {
|
||||
#endif
|
||||
#ifdef VGM_USE_MAIATRAC3PLUS
|
||||
case coding_AT3plus:
|
||||
#endif
|
||||
#ifdef VGM_USE_ATRAC9
|
||||
case coding_ATRAC9:
|
||||
#endif
|
||||
vgmstream->layout_type = layout_none;
|
||||
vgmstream->interleave_block_size = fmt.block_size;
|
||||
|
@ -1,16 +1,18 @@
|
||||
#include "meta.h"
|
||||
#include "../util.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
|
||||
/* SXD - Sony's SDK format? (cousin of SGXD) [Gravity Rush, Freedom Wars, Soul Sacrifice PSV] */
|
||||
/* SXD - Sony/SCE's SNDX lib format (cousin of SGXD) [Gravity Rush, Freedom Wars, Soul Sacrifice PSV] */
|
||||
VGMSTREAM * init_vgmstream_sxd(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
STREAMFILE * streamHeader = NULL;
|
||||
off_t start_offset, chunk_offset, first_offset = 0x60, name_offset = 0;
|
||||
size_t chunk_size;
|
||||
|
||||
int is_separate;
|
||||
int loop_flag, channels, type;
|
||||
int loop_flag, channels, codec;
|
||||
int sample_rate, num_samples, loop_start_sample, loop_end_sample;
|
||||
uint32_t at9_config_data = 0;
|
||||
int total_streams, target_stream = streamFile->stream_index;
|
||||
|
||||
|
||||
@ -33,8 +35,7 @@ VGMSTREAM * init_vgmstream_sxd(STREAMFILE *streamFile) {
|
||||
|
||||
|
||||
/* typical chunks: NAME, WAVE and many control chunks (SXDs don't need to contain any sound data) */
|
||||
/* WAVE chunk (0 + streams + 4*streams table + streams * variable? + optional padding) */
|
||||
if (!find_chunk_le(streamHeader, 0x57415645,first_offset,0, &chunk_offset,NULL)) goto fail; /* "WAVE" */
|
||||
if (!find_chunk_le(streamHeader, 0x57415645,first_offset,0, &chunk_offset,&chunk_size)) goto fail; /* "WAVE" */
|
||||
|
||||
/* check multi-streams (usually only in SFX containers) */
|
||||
total_streams = read_32bitLE(chunk_offset+0x04,streamHeader);
|
||||
@ -43,53 +44,60 @@ VGMSTREAM * init_vgmstream_sxd(STREAMFILE *streamFile) {
|
||||
|
||||
/* read stream header */
|
||||
{
|
||||
off_t table_offset, header_offset, stream_offset, data_offset;
|
||||
int i;
|
||||
off_t table_offset, header_offset, stream_offset;
|
||||
|
||||
/* get target offset using table of relative offsets within WAVE */
|
||||
table_offset = chunk_offset + 0x08 + 4*(target_stream-1);
|
||||
header_offset = table_offset + read_32bitLE(table_offset,streamHeader);
|
||||
|
||||
type = read_32bitLE(header_offset+0x00,streamHeader);
|
||||
/* 0x04 (1): unk (HEVAG: 21, ATRAC9: 42 */
|
||||
/* 0x00(4): type/location? (00/01=sxd/RAM?, 02/03=sxd2/stream?) */
|
||||
codec = read_8bit (header_offset+0x04,streamHeader);
|
||||
channels = read_8bit (header_offset+0x05,streamHeader);
|
||||
sample_rate = read_32bitLE(header_offset+0x08,streamHeader);
|
||||
/* 0x0c (4): unk size? */
|
||||
/* 0x10 (4): ? + volume? + pan? (can be 0 for music) */
|
||||
/* 0x0c(4): unknown size? (0x4000/0x3999/0x3333/etc, not related to extra data) */
|
||||
/* 0x10(4): ? + volume? + pan? (can be 0 for music) */
|
||||
num_samples = read_32bitLE(header_offset+0x14,streamHeader);
|
||||
loop_start_sample = read_32bitLE(header_offset+0x18,streamHeader);
|
||||
loop_end_sample = read_32bitLE(header_offset+0x1c,streamHeader);
|
||||
/* 0x20 (4): data size */
|
||||
/* 0x24 (-): extra data, variable size and format dependant
|
||||
(ATRAC9 can contain truncated part of the data, for preloading I guess) */
|
||||
/* 0x20(4): data size */
|
||||
stream_offset = read_32bitLE(header_offset+0x24,streamHeader);
|
||||
|
||||
/* Extra data, variable sized and uses some kind of TLVs (HEVAG's is optional and much smaller).
|
||||
* One tag seems to add a small part of the ATRAC9 data, for RAM preloding I guess. */
|
||||
if (codec == 0x42) {
|
||||
off_t extra_offset = header_offset+0x28;
|
||||
off_t max_offset = chunk_offset + chunk_size;
|
||||
|
||||
/* manually try to find certain tag, no idea about the actual format
|
||||
* (most variable in Soul Sacrifice; extra size isn't found in the SXD AFAIK) */
|
||||
while (extra_offset < max_offset) {
|
||||
uint32_t tag = read_32bitBE(extra_offset, streamHeader);
|
||||
if (tag == 0x0A010000 || tag == 0x0A010600) {
|
||||
at9_config_data = read_32bitLE(extra_offset+0x04,streamHeader); /* yes, LE */
|
||||
break;
|
||||
}
|
||||
|
||||
extra_offset += 0x04;
|
||||
}
|
||||
if (!at9_config_data)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
loop_flag = loop_start_sample != -1 && loop_end_sample != -1;
|
||||
|
||||
/* calc stream offset by reading stream sizes */
|
||||
stream_offset = 0;
|
||||
for (i = 0; i < total_streams; i++) {
|
||||
off_t subtable_offset, subheader_offset;
|
||||
if (i == target_stream-1) break;
|
||||
|
||||
subtable_offset = chunk_offset + 0x08 + 4*(i);
|
||||
subheader_offset = subtable_offset + read_32bitLE(subtable_offset,streamHeader);
|
||||
stream_offset += read_32bitLE(subheader_offset+0x20,streamHeader); /* data size */
|
||||
}
|
||||
|
||||
/* from current offset in sxd, absolute in sxd2 */
|
||||
if (is_separate) {
|
||||
data_offset = first_offset;
|
||||
start_offset = stream_offset;
|
||||
} else {
|
||||
if (!find_chunk_le(streamHeader, 0x44415441,first_offset,0, &data_offset,NULL)) goto fail; /* "DATA" */
|
||||
data_offset += 0x08;
|
||||
start_offset = header_offset+0x24 + stream_offset;
|
||||
}
|
||||
|
||||
start_offset = data_offset + stream_offset;
|
||||
}
|
||||
|
||||
/* get stream name (NAME is tied to REQD/cues, and SFX cues repeat WAVEs, but should work ok for streams) */
|
||||
if (is_separate && find_chunk_le(streamHeader, 0x4E414D45,first_offset,0, &chunk_offset,NULL)) { /* "NAME" */
|
||||
/* table: relative offset (32b) + hash? (32b) + cue index (32b) */
|
||||
int i;
|
||||
int num_entries = read_16bitLE(chunk_offset+0x04,streamHeader); /*can be more than streams */
|
||||
int num_entries = read_16bitLE(chunk_offset+0x04,streamHeader); /* can be bigger than streams */
|
||||
for (i = 0; i < num_entries; i++) {
|
||||
uint32_t index = (uint32_t)read_32bitLE(chunk_offset+0x08 + 0x08 + i*0x0c,streamHeader);
|
||||
if (index+1 == target_stream) {
|
||||
@ -113,18 +121,30 @@ VGMSTREAM * init_vgmstream_sxd(STREAMFILE *streamFile) {
|
||||
if (name_offset)
|
||||
read_string(vgmstream->stream_name,STREAM_NAME_SIZE, name_offset,streamHeader);
|
||||
|
||||
switch (type) {
|
||||
case 0x01: /* HEVAG */
|
||||
switch (codec) {
|
||||
case 0x21: /* HEVAG */
|
||||
vgmstream->coding_type = coding_HEVAG;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x10;
|
||||
break;
|
||||
|
||||
case 0x03: /* ATRAC9 */
|
||||
goto fail;
|
||||
#ifdef VGM_USE_ATRAC9
|
||||
case 0x42: { /* ATRAC9 */
|
||||
atrac9_config cfg = {0};
|
||||
|
||||
cfg.channels = vgmstream->channels;
|
||||
cfg.config_data = at9_config_data;
|
||||
|
||||
vgmstream->codec_data = init_atrac9(&cfg);
|
||||
if (!vgmstream->codec_data) goto fail;
|
||||
vgmstream->coding_type = coding_ATRAC9;
|
||||
vgmstream->layout_type = layout_none;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
default:
|
||||
VGM_LOG("SXD: unknown codec %i", type);
|
||||
VGM_LOG("SXD: unknown codec 0x%x", codec);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ VGMSTREAM * init_vgmstream_ubi_raki(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
off_t start_offset, off, fmt_offset;
|
||||
size_t header_size, data_size;
|
||||
int little_endian;
|
||||
int big_endian;
|
||||
int loop_flag, channel_count, block_align, bits_per_sample;
|
||||
uint32_t platform, type;
|
||||
|
||||
@ -28,25 +28,33 @@ VGMSTREAM * init_vgmstream_ubi_raki(STREAMFILE *streamFile) {
|
||||
else
|
||||
goto fail;
|
||||
|
||||
/* endianness is given with the platform field, but this is more versatile */
|
||||
little_endian = read_32bitBE(off+0x10,streamFile) > 0x00ffffff;
|
||||
if (little_endian) {
|
||||
read_32bit = read_32bitLE;
|
||||
read_16bit = read_16bitLE;
|
||||
} else {
|
||||
read_32bit = read_32bitBE;
|
||||
read_16bit = read_16bitBE;
|
||||
}
|
||||
|
||||
/* 0x04: version? (0x00, 0x07, 0x0a, etc); */
|
||||
platform = read_32bitBE(off+0x08,streamFile); /* string */
|
||||
type = read_32bitBE(off+0x0c,streamFile); /* string */
|
||||
|
||||
switch(platform) {
|
||||
case 0x57696920: /* "Wii " */
|
||||
case 0x43616665: /* "Cafe" */
|
||||
case 0x50533320: /* "PS3 " */
|
||||
case 0x58333630: /* "X360" */
|
||||
big_endian = 1;
|
||||
read_32bit = read_32bitBE;
|
||||
read_16bit = read_16bitBE;
|
||||
break;
|
||||
default:
|
||||
big_endian = 0;
|
||||
read_32bit = read_32bitLE;
|
||||
read_16bit = read_16bitLE;
|
||||
break;
|
||||
}
|
||||
|
||||
header_size = read_32bit(off+0x10,streamFile);
|
||||
start_offset = read_32bit(off+0x14,streamFile);
|
||||
/* 0x18: number of chunks */
|
||||
/* 0x1c: unk */
|
||||
|
||||
/* The first chunk is always "fmt" and points to a RIFF "fmt" chunk (even for WiiU or PS3) */
|
||||
/* the format has a chunk offset table, and the first one always "fmt" and points
|
||||
* to a RIFF "fmt" chunk (even for WiiU or PS3) */
|
||||
if (read_32bitBE(off+0x20,streamFile) != 0x666D7420) goto fail; /*"fmt "*/
|
||||
fmt_offset = read_32bit(off+0x24,streamFile);
|
||||
//fmt_size = read_32bit(off+0x28,streamFile);
|
||||
@ -114,7 +122,7 @@ VGMSTREAM * init_vgmstream_ubi_raki(STREAMFILE *streamFile) {
|
||||
{
|
||||
/* get coef offsets; could check "dspL" and "dspR" chunks after "fmt " better but whatevs (only "dspL" if mono) */
|
||||
off_t dsp_coefs = read_32bitBE(off+0x30,streamFile); /* after "dspL"; spacing is consistent but could vary */
|
||||
dsp_read_coefs(vgmstream,streamFile, dsp_coefs+0x1c, 0x60, !little_endian);
|
||||
dsp_read_coefs(vgmstream,streamFile, dsp_coefs+0x1c, 0x60, big_endian);
|
||||
/* dsp_coefs + 0x00-0x1c: ? (special coefs or adpcm history?) */
|
||||
}
|
||||
|
||||
@ -123,7 +131,7 @@ VGMSTREAM * init_vgmstream_ubi_raki(STREAMFILE *streamFile) {
|
||||
|
||||
#ifdef VGM_USE_MPEG
|
||||
case 0x505333206D703320: { /* "PS3 mp3 " */
|
||||
/* chunks: "MARK" optional seek table), "STRG" (optional description), "Msf " ("data" equivalent) */
|
||||
/* chunks: "MARK" (optional seek table), "STRG" (optional description), "Msf " ("data" equivalent) */
|
||||
vgmstream->codec_data = init_mpeg_codec_data(streamFile, start_offset, &vgmstream->coding_type, vgmstream->channels);
|
||||
if (!vgmstream->codec_data) goto fail;
|
||||
vgmstream->layout_type = layout_none;
|
||||
@ -153,9 +161,25 @@ VGMSTREAM * init_vgmstream_ubi_raki(STREAMFILE *streamFile) {
|
||||
}
|
||||
#endif
|
||||
|
||||
case 0x5649544161743920: /*"VITAat9 "*/
|
||||
#ifdef VGM_USE_ATRAC9
|
||||
case 0x5649544161743920: { /*"VITAat9 "*/
|
||||
/* chunks: "fact" (equivalent to a RIFF "fact", num_samples + skip_samples), "data" */
|
||||
goto fail;
|
||||
atrac9_config cfg = {0};
|
||||
|
||||
cfg.channels = vgmstream->channels;
|
||||
cfg.config_data = read_32bitBE(fmt_offset+0x2c,streamFile);
|
||||
cfg.encoder_delay = read_32bit(fmt_offset+0x3c,streamFile);
|
||||
|
||||
vgmstream->codec_data = init_atrac9(&cfg);
|
||||
if (!vgmstream->codec_data) goto fail;
|
||||
vgmstream->coding_type = coding_ATRAC9;
|
||||
vgmstream->layout_type = layout_none;
|
||||
|
||||
/* could get the "fact" offset but seems it always follows "fmt " */
|
||||
vgmstream->num_samples = read_32bit(fmt_offset+0x34,streamFile);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
default:
|
||||
VGM_LOG("RAKI: unknown platform %x and type %x\n", platform, type);
|
||||
|
@ -528,9 +528,24 @@ VGMSTREAM * init_vgmstream_wwise(STREAMFILE *streamFile) {
|
||||
vgmstream->num_samples = ps_bytes_to_samples(ww.data_size, ww.channels);
|
||||
break;
|
||||
|
||||
case ATRAC9: /* PSV/PS4 */
|
||||
VGM_LOG("WWISE: ATRAC9 found (unsupported)\n");
|
||||
goto fail;
|
||||
#ifdef VGM_USE_ATRAC9
|
||||
case ATRAC9: { /* PSV/PS4 */
|
||||
atrac9_config cfg = {0};
|
||||
if (ww.extra_size != 0x12) goto fail;
|
||||
|
||||
cfg.channels = vgmstream->channels;
|
||||
cfg.config_data = read_32bitBE(ww.fmt_offset+0x18,streamFile);
|
||||
cfg.encoder_delay = read_32bit(ww.fmt_offset+0x20,streamFile);
|
||||
|
||||
vgmstream->codec_data = init_atrac9(&cfg);
|
||||
if (!vgmstream->codec_data) goto fail;
|
||||
vgmstream->coding_type = coding_ATRAC9;
|
||||
vgmstream->layout_type = layout_none;
|
||||
|
||||
vgmstream->num_samples = read_32bit(ww.fmt_offset+0x1c,streamFile);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
default:
|
||||
goto fail;
|
||||
|
@ -4,16 +4,18 @@
|
||||
|
||||
static int ps_adpcm_find_loop_offsets(STREAMFILE *streamFile, int channel_count, off_t start_offset, off_t * loop_start, off_t * loop_end);
|
||||
|
||||
/* XVAG - Sony's (second party?) format (God of War III, Ratchet & Clank Future, The Last of Us, Uncharted) */
|
||||
/* XVAG - Sony's Scream Tool/Stream Creator format (God of War III, Ratchet & Clank Future, The Last of Us, Uncharted) */
|
||||
VGMSTREAM * init_vgmstream_xvag(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
int32_t (*read_32bit)(off_t,STREAMFILE*) = NULL;
|
||||
int loop_flag = 0, channel_count, codec;
|
||||
int big_endian;
|
||||
int sample_rate, num_samples, multiplier;
|
||||
int total_subsongs = 0, target_subsong = streamFile->stream_index;
|
||||
|
||||
off_t start_offset, loop_start, loop_end, chunk_offset;
|
||||
off_t first_offset = 0x20;
|
||||
int little_endian;
|
||||
int sample_rate, num_samples, multiplier;
|
||||
size_t chunk_size;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
if (!check_extensions(streamFile,"xvag")) goto fail;
|
||||
@ -22,18 +24,20 @@ VGMSTREAM * init_vgmstream_xvag(STREAMFILE *streamFile) {
|
||||
if (read_32bitBE(0x00,streamFile) != 0x58564147) /* "XVAG" */
|
||||
goto fail;
|
||||
|
||||
little_endian = read_8bit(0x07,streamFile)==0; /* empty start_offset > little endian */
|
||||
if (little_endian) {
|
||||
read_32bit = read_32bitLE;
|
||||
} else {
|
||||
/* empty start_offset > little endian (also, XVAGs of the same game can use BE or LE, oddly enough) */
|
||||
big_endian = read_8bit(0x07,streamFile) != 0;
|
||||
if (big_endian) {
|
||||
read_32bit = read_32bitBE;
|
||||
} else {
|
||||
read_32bit = read_32bitLE;
|
||||
}
|
||||
|
||||
start_offset = read_32bit(0x04,streamFile);
|
||||
/* 0x08: flags? (&0x01=big endian?) 0x0a: version (chunk sizes vary) */
|
||||
|
||||
/* "fmat": base format */
|
||||
if (!find_chunk(streamFile, 0x666D6174,first_offset,0, &chunk_offset,NULL, !little_endian, 1)) goto fail; /*"fmat"*/
|
||||
if (!find_chunk(streamFile, 0x666D6174,first_offset,0, &chunk_offset,&chunk_size, big_endian, 1)) /*"fmat"*/
|
||||
goto fail;
|
||||
channel_count = read_32bit(chunk_offset+0x00,streamFile);
|
||||
codec = read_32bit(chunk_offset+0x04,streamFile);
|
||||
num_samples = read_32bit(chunk_offset+0x08,streamFile);
|
||||
@ -41,13 +45,21 @@ VGMSTREAM * init_vgmstream_xvag(STREAMFILE *streamFile) {
|
||||
multiplier = read_32bit(chunk_offset+0x10,streamFile);
|
||||
sample_rate = read_32bit(chunk_offset+0x14,streamFile);
|
||||
/* 0x18: datasize */
|
||||
if (chunk_size > 0x1c) {
|
||||
total_subsongs = read_32bit(chunk_offset+0x1c,streamFile); /* number of interleaved subsongs */
|
||||
/* 0x20: number of multichannel substreams (for MPEG) */
|
||||
|
||||
if (target_subsong == 0) target_subsong = 1;
|
||||
if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail;
|
||||
}
|
||||
|
||||
|
||||
/* other chunks: */
|
||||
/* "cpan": pan/volume per channel */
|
||||
/* "0000": end chunk before start_offset */
|
||||
|
||||
//if ((uint16_t)read_16bitBE(start_offset,streamFile)==0xFFFB) codec = 0x08;
|
||||
if (codec == 0x06) { /* todo not sure if there are any looping XVAGs */
|
||||
/* some XVAG seem to do full loops, this should detect them as looping */
|
||||
if (codec == 0x06) {
|
||||
loop_flag = ps_adpcm_find_loop_offsets(streamFile, channel_count, start_offset, &loop_start, &loop_end);
|
||||
}
|
||||
|
||||
@ -57,6 +69,7 @@ VGMSTREAM * init_vgmstream_xvag(STREAMFILE *streamFile) {
|
||||
|
||||
vgmstream->sample_rate = sample_rate;
|
||||
vgmstream->num_samples = num_samples;
|
||||
vgmstream->num_streams = total_subsongs;
|
||||
vgmstream->meta_type = meta_XVAG;
|
||||
|
||||
switch (codec) {
|
||||
@ -86,8 +99,8 @@ VGMSTREAM * init_vgmstream_xvag(STREAMFILE *streamFile) {
|
||||
|
||||
/* "mpin": mpeg info */
|
||||
/* 0x00/04: mpeg version/layer? other: unknown or repeats of "fmat" */
|
||||
if (!find_chunk(streamFile, 0x6D70696E,first_offset,0, &chunk_offset,NULL, !little_endian, 1))
|
||||
goto fail; /*"mpin"*/
|
||||
if (!find_chunk(streamFile, 0x6D70696E,first_offset,0, &chunk_offset,NULL, big_endian, 1)) /*"mpin"*/
|
||||
goto fail;
|
||||
|
||||
cfg.chunk_size = read_32bit(chunk_offset+0x1c,streamFile); /* fixed frame size */
|
||||
cfg.interleave = cfg.chunk_size * multiplier;
|
||||
@ -99,11 +112,39 @@ VGMSTREAM * init_vgmstream_xvag(STREAMFILE *streamFile) {
|
||||
}
|
||||
#endif
|
||||
|
||||
case 0x09: { /* ATRAC9: Sly Cooper and the Thievius Raccoonus */
|
||||
#ifdef VGM_USE_ATRAC9
|
||||
case 0x09: { /* ATRAC9: Sly Cooper and the Thievius Raccoonus, The Last of Us Remastered */
|
||||
atrac9_config cfg = {0};
|
||||
|
||||
/* "a9in": ATRAC9 info */
|
||||
/* 0x00: block align, 0x04: samples per block, 0x0c: fact num_samples (no change), 0x10: encoder delay1 */
|
||||
if (!find_chunk(streamFile, 0x6139696E,first_offset,0, &chunk_offset,NULL, big_endian, 1)) /*"a9in"*/
|
||||
goto fail;
|
||||
|
||||
cfg.channels = vgmstream->channels;
|
||||
cfg.config_data = read_32bitBE(chunk_offset+0x08,streamFile);
|
||||
cfg.encoder_delay = read_32bit(chunk_offset+0x14,streamFile);
|
||||
|
||||
/* Sly Cooper interleaves 'multiplier' superframes per subsong (all share config_data) */
|
||||
cfg.interleave_skip = read_32bit(chunk_offset+0x00,streamFile) * multiplier;
|
||||
cfg.subsong_skip = total_subsongs;
|
||||
start_offset += (target_subsong-1) * cfg.interleave_skip * (cfg.subsong_skip-1);
|
||||
|
||||
/* The Last of Us Remastered has an AT9 RIFF header inside (same values, can be ignored) */
|
||||
if (read_32bitBE(start_offset+0x00, streamFile) == 0x00000000 &&
|
||||
read_32bitBE(start_offset+0x9c, streamFile) == 0x52494646) { /*"RIFF"*/
|
||||
if (!find_chunk(streamFile, 0x64617461,start_offset+0x9c+0x0c,0, &start_offset,NULL, big_endian, 0)) /*"data"*/
|
||||
goto fail;
|
||||
}
|
||||
|
||||
vgmstream->codec_data = init_atrac9(&cfg);
|
||||
if (!vgmstream->codec_data) goto fail;
|
||||
vgmstream->coding_type = coding_ATRAC9;
|
||||
vgmstream->layout_type = layout_none;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user