mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-12 01:30:49 +01:00
commit
a2fe3aa343
@ -339,6 +339,7 @@ are used in few games.
|
||||
- Paradigm MC3 ADPCM
|
||||
- FMOD FADPCM 4-bit ADPCM
|
||||
- Konami XMD 4-bit ADPCM
|
||||
- Platinum 4-bit ADPCM
|
||||
- Argonaut ASF 4-bit ADPCM
|
||||
- Ocean DSA 4-bit ADPCM
|
||||
- Circus XPCM ADPCM
|
||||
|
@ -183,6 +183,10 @@ void decode_pcfx(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacin
|
||||
void decode_oki16(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel);
|
||||
size_t oki_bytes_to_samples(size_t bytes, int channels);
|
||||
|
||||
/* ptadpcm_decoder */
|
||||
void decode_ptadpcm(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, size_t frame_size);
|
||||
size_t ptadpcm_bytes_to_samples(size_t bytes, int channels, size_t frame_size);
|
||||
|
||||
/* ea_mt_decoder*/
|
||||
ea_mt_codec_data *init_ea_mt(int channels, int type);
|
||||
ea_mt_codec_data *init_ea_mt_loops(int channels, int pcm_blocks, int loop_sample, off_t *loop_offsets);
|
||||
|
98
src/coding/ptadpcm_decoder.c
Normal file
98
src/coding/ptadpcm_decoder.c
Normal file
@ -0,0 +1,98 @@
|
||||
#include "coding.h"
|
||||
|
||||
|
||||
/* a somewhat IMA-like mix of step+step index all in one */
|
||||
static const int32_t ptadpcm_table[(16+16)*16] = { /* 16 of (step+index) + 16 values in a nibble */
|
||||
-14, 2, -10, 2, -7, 1, -5, 1, -3, 0, -2, 0, -1, 0, 0, 0,
|
||||
0, 0, 1, 0, 2, 0, 3, 0, 5, 1, 7, 1, 10, 2, 14, 2,
|
||||
-28, 3, -20, 3, -14, 2, -10, 2, -7, 1, -5, 1, -3, 1, -1, 0,
|
||||
1, 0, 3, 1, 5, 1, 7, 1, 10, 2, 14, 2, 20, 3, 28, 3,
|
||||
-56, 4, -40, 4, -28, 3, -20, 3, -14, 2, -10, 2, -6, 2, -2, 1,
|
||||
2, 1, 6, 2, 10, 2, 14, 2, 20, 3, 28, 3, 40, 4, 56, 4,
|
||||
-112, 5, -80, 5, -56, 4, -40, 4, -28, 3, -20, 3, -12, 3, -4, 2,
|
||||
4, 2, 12, 3, 20, 3, 28, 3, 40, 4, 56, 4, 80, 5, 112, 5,
|
||||
-224, 6, -160, 6, -112, 5, -80, 5, -56, 4, -40, 4, -24, 4, -8, 3,
|
||||
8, 3, 24, 4, 40, 4, 56, 4, 80, 5, 112, 5, 160, 6, 224, 6,
|
||||
-448, 7, -320, 7, -224, 6, -160, 6, -112, 5, -80, 5, -48, 5, -16, 4,
|
||||
16, 4, 48, 5, 80, 5, 112, 5, 160, 6, 224, 6, 320, 7, 448, 7,
|
||||
-896, 8, -640, 8, -448, 7, -320, 7, -224, 6, -160, 6, -96, 6, -32, 5,
|
||||
32, 5, 96, 6, 160, 6, 224, 6, 320, 7, 448, 7, 640, 8, 896, 8,
|
||||
-1792, 9, -1280, 9, -896, 8, -640, 8, -448, 7, -320, 7, -192, 7, -64, 6,
|
||||
64, 6, 192, 7, 320, 7, 448, 7, 640, 8, 896, 8, 1280, 9, 1792, 9,
|
||||
-3584, 10, -2560, 10, -1792, 9, -1280, 9, -896, 8, -640, 8, -384, 8, -128, 7,
|
||||
128, 7, 384, 8, 640, 8, 896, 8, 1280, 9, 1792, 9, 2560, 10, 3584, 10,
|
||||
-7168, 11, -5120, 11, -3584, 10, -2560, 10, -1792, 9, -1280, 9, -768, 9, -256, 8,
|
||||
256, 8, 768, 9, 1280, 9, 1792, 9, 2560, 10, 3584, 10, 5120, 11, 7168, 11,
|
||||
-14336, 11, -10240, 11, -7168, 11, -5120, 11, -3584, 10, -2560, 10, -1536, 10, -512, 9,
|
||||
512, 9, 1536, 10, 2560, 10, 3584, 10, 5120, 11, 7168, 11, 10240, 11, 14336, 11,
|
||||
-28672, 11, -20480, 11, -14336, 11, -10240, 11, -7168, 11, -5120, 11, -3072, 11, -1024, 10,
|
||||
1024, 10, 3072, 11, 5120, 11, 7168, 11, 10240, 11, 14336, 11, 20480, 11, 28672, 11,
|
||||
/* rest is 0s */
|
||||
};
|
||||
|
||||
/* Platinum "PtADPCM" custom ADPCM for Wwise (reverse engineered from .exes). */
|
||||
void decode_ptadpcm(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, size_t frame_size) {
|
||||
off_t frame_offset;
|
||||
int i, frames_in, sample_count = 0, samples_done = 0;
|
||||
size_t bytes_per_frame, samples_per_frame;
|
||||
int16_t hist1, hist2;
|
||||
int index, step;
|
||||
|
||||
/* external interleave (variable size), mono */
|
||||
bytes_per_frame = frame_size;
|
||||
samples_per_frame = 2 + (frame_size - 0x05) * 2;
|
||||
frames_in = first_sample / samples_per_frame;
|
||||
first_sample = first_sample % samples_per_frame;
|
||||
|
||||
/* parse frame header */
|
||||
frame_offset = stream->offset + bytes_per_frame*frames_in;
|
||||
hist2 = read_16bitLE(frame_offset+0x00,stream->streamfile);
|
||||
hist1 = read_16bitLE(frame_offset+0x02,stream->streamfile);
|
||||
index = (uint8_t)read_8bit(frame_offset+0x04,stream->streamfile);
|
||||
|
||||
VGM_ASSERT_ONCE(index > 12, "PTADPCM: incorrect index at %x\n", (uint32_t)frame_offset);
|
||||
|
||||
/* write header samples (needed) */
|
||||
if (sample_count >= first_sample && samples_done < samples_to_do) {
|
||||
outbuf[samples_done * channelspacing] = hist2;
|
||||
samples_done++;
|
||||
}
|
||||
sample_count++;
|
||||
if (sample_count >= first_sample && samples_done < samples_to_do) {
|
||||
outbuf[samples_done * channelspacing] = hist1;
|
||||
samples_done++;
|
||||
}
|
||||
sample_count++;
|
||||
|
||||
/* decode nibbles */
|
||||
for (i = first_sample; i < first_sample + samples_to_do; i++) {
|
||||
int32_t new_sample;
|
||||
uint8_t nibbles = (uint8_t)read_8bit(frame_offset+0x05 + i/2,stream->streamfile);
|
||||
uint8_t nibble;
|
||||
|
||||
nibble = !(i&1) ? /* low nibble first */
|
||||
(nibbles >> 0) & 0xF :
|
||||
(nibbles >> 4) & 0xF;
|
||||
|
||||
step = ptadpcm_table[2*(nibble + 16*index) + 0];
|
||||
index = ptadpcm_table[2*(nibble + 16*index) + 1];
|
||||
new_sample = clamp16(step + 2*hist1 - hist2);
|
||||
|
||||
if (sample_count >= first_sample && samples_done < samples_to_do) {
|
||||
outbuf[samples_done * channelspacing] = new_sample;
|
||||
samples_done++;
|
||||
}
|
||||
sample_count++;
|
||||
|
||||
hist2 = hist1;
|
||||
hist1 = new_sample;
|
||||
}
|
||||
|
||||
//stream->adpcm_history1_32 = hist1;
|
||||
//stream->adpcm_history2_32 = hist2;
|
||||
}
|
||||
|
||||
size_t ptadpcm_bytes_to_samples(size_t bytes, int channels, size_t frame_size) {
|
||||
if (channels <= 0 || frame_size < 0x06) return 0;
|
||||
return (bytes / channels / frame_size) * ((frame_size-0x05) * 2);
|
||||
}
|
@ -201,6 +201,7 @@ static const char* extension_list[] = {
|
||||
"ima",
|
||||
"imc",
|
||||
"int",
|
||||
"is14",
|
||||
"isd",
|
||||
"isws",
|
||||
"itl",
|
||||
@ -306,6 +307,7 @@ static const char* extension_list[] = {
|
||||
"nop",
|
||||
"nps",
|
||||
"npsf", //fake extension/header id for .nps (in bigfiles)
|
||||
"nub",
|
||||
"nus3audio",
|
||||
"nus3bank",
|
||||
"nwa",
|
||||
@ -680,6 +682,7 @@ static const coding_info coding_info_list[] = {
|
||||
{coding_XMD, "Konami XMD 4-bit ADPCM"},
|
||||
{coding_PCFX, "PC-FX 4-bit ADPCM"},
|
||||
{coding_OKI16, "OKI 4-bit ADPCM (16-bit output)"},
|
||||
{coding_PTADPCM, "Platinum 4-bit ADPCM"},
|
||||
|
||||
{coding_SDX2, "Squareroot-delta-exact (SDX2) 8-bit DPCM"},
|
||||
{coding_SDX2_int, "Squareroot-delta-exact (SDX2) 8-bit DPCM with 1 byte interleave"},
|
||||
@ -916,7 +919,7 @@ static const meta_info meta_info_list[] = {
|
||||
{meta_FFXI_BGW, "Square Enix .BGW header"},
|
||||
{meta_FFXI_SPW, "Square Enix .SPW header"},
|
||||
{meta_PS2_ASS, "SystemSoft .ASS header"},
|
||||
{meta_NUB_IDSP, "Namco NUB IDSP header"},
|
||||
{meta_NUB, "Namco NUB header"},
|
||||
{meta_IDSP_NL, "Next Level IDSP header"},
|
||||
{meta_IDSP_IE, "Inevitable Entertainment IDSP Header"},
|
||||
{meta_UBI_JADE, "Ubisoft Jade RIFF header"},
|
||||
@ -1021,7 +1024,6 @@ static const meta_info meta_info_list[] = {
|
||||
{meta_NGC_NST_DSP, "Animaniacs NST header"},
|
||||
{meta_BAF, "Bizarre Creations .baf header"},
|
||||
{meta_MSF, "Sony MSF header"},
|
||||
{meta_NUB_VAG, "Namco NUB VAG header"},
|
||||
{meta_PS3_PAST, "SNDP header"},
|
||||
{meta_SGXD, "Sony SGXD header"},
|
||||
{meta_NGCA, "NGCA header"},
|
||||
@ -1068,7 +1070,6 @@ static const meta_info meta_info_list[] = {
|
||||
{meta_FFMPEG, "FFmpeg supported file format"},
|
||||
{meta_X360_CXS, "tri-Crescendo CXS header"},
|
||||
{meta_AKB, "Square-Enix AKB header"},
|
||||
{meta_NUB_XMA, "Namco NUB XMA header"},
|
||||
{meta_X360_PASX, "Namco PASX header"},
|
||||
{meta_XMA_RIFF, "Microsoft XMA RIFF header"},
|
||||
{meta_X360_AST, "Capcom AST (X360) header"},
|
||||
|
@ -705,7 +705,7 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\nub_idsp.c"
|
||||
RelativePath=".\meta\nub.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
@ -941,14 +941,6 @@
|
||||
<File
|
||||
RelativePath=".\meta\opus.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\nub_vag.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\nub_xma.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\nus3audio.c"
|
||||
@ -2030,10 +2022,14 @@
|
||||
RelativePath=".\coding\psv_decoder.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\coding\psx_decoder.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\coding\psx_decoder.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\coding\ptadpcm_decoder.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\coding\sassc_decoder.c"
|
||||
>
|
||||
|
@ -181,7 +181,6 @@
|
||||
<ClCompile Include="meta\msf_tamasoft.c" />
|
||||
<ClCompile Include="meta\ngca.c" />
|
||||
<ClCompile Include="meta\opus.c" />
|
||||
<ClCompile Include="meta\nub_vag.c" />
|
||||
<ClCompile Include="meta\pc_adp.c" />
|
||||
<ClCompile Include="meta\pc_adp_otns.c" />
|
||||
<ClCompile Include="meta\pc_ast.c" />
|
||||
@ -302,7 +301,7 @@
|
||||
<ClCompile Include="meta\hd3_bd3.c" />
|
||||
<ClCompile Include="meta\his.c" />
|
||||
<ClCompile Include="meta\idsp_ie.c" />
|
||||
<ClCompile Include="meta\nub_idsp.c" />
|
||||
<ClCompile Include="meta\nub.c" />
|
||||
<ClCompile Include="meta\ish_isd.c" />
|
||||
<ClCompile Include="meta\ivaud.c" />
|
||||
<ClCompile Include="meta\ivb.c" />
|
||||
@ -351,7 +350,6 @@
|
||||
<ClCompile Include="meta\ngc_ymf.c" />
|
||||
<ClCompile Include="meta\ngc_ulw.c" />
|
||||
<ClCompile Include="meta\ngc_vid1.c" />
|
||||
<ClCompile Include="meta\nub_xma.c" />
|
||||
<ClCompile Include="meta\nus3audio.c" />
|
||||
<ClCompile Include="meta\nus3bank.c" />
|
||||
<ClCompile Include="meta\nwa.c" />
|
||||
@ -566,6 +564,7 @@
|
||||
<ClCompile Include="coding\pcm_decoder.c" />
|
||||
<ClCompile Include="coding\psv_decoder.c" />
|
||||
<ClCompile Include="coding\psx_decoder.c" />
|
||||
<ClCompile Include="coding\ptadpcm_decoder.c" />
|
||||
<ClCompile Include="coding\sassc_decoder.c" />
|
||||
<ClCompile Include="coding\sdx2_decoder.c" />
|
||||
<ClCompile Include="coding\vorbis_custom_decoder.c" />
|
||||
|
@ -451,7 +451,7 @@
|
||||
<ClCompile Include="meta\his.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meta\nub_idsp.c">
|
||||
<ClCompile Include="meta\nub.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meta\idsp_ie.c">
|
||||
@ -586,9 +586,6 @@
|
||||
<ClCompile Include="meta\ngc_vid1.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meta\nub_xma.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meta\nus3audio.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -1213,6 +1210,9 @@
|
||||
<ClCompile Include="coding\psx_decoder.c">
|
||||
<Filter>coding\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="coding\ptadpcm_decoder.c">
|
||||
<Filter>coding\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="coding\sassc_decoder.c">
|
||||
<Filter>coding\Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -1363,9 +1363,6 @@
|
||||
<ClCompile Include="layout\blocked_xvas.c">
|
||||
<Filter>layout\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meta\nub_vag.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meta\ps3_past.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
@ -284,8 +284,6 @@ VGMSTREAM * init_vgmstream_ps2_omu(STREAMFILE *streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_ps2_xa2(STREAMFILE * streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_nub_idsp(STREAMFILE * streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_idsp_ie(STREAMFILE * streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_ngc_ymf(STREAMFILE * streamFile);
|
||||
@ -498,8 +496,6 @@ VGMSTREAM * init_vgmstream_baf_badrip(STREAMFILE* streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_msf(STREAMFILE* streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_nub_vag(STREAMFILE* streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_ps3_past(STREAMFILE* streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_sgxd(STREAMFILE* streamFile);
|
||||
@ -592,8 +588,6 @@ VGMSTREAM * init_vgmstream_wwise(STREAMFILE *streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_ubi_raki(STREAMFILE* streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_nub_xma(STREAMFILE *streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_x360_pasx(STREAMFILE *streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_sxd(STREAMFILE *streamFile);
|
||||
@ -860,4 +854,12 @@ VGMSTREAM * init_vgmstream_sch(STREAMFILE * streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_ima(STREAMFILE * streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_nub(STREAMFILE * streamFile);
|
||||
VGMSTREAM * init_vgmstream_nub_wav(STREAMFILE * streamFile);
|
||||
VGMSTREAM * init_vgmstream_nub_vag(STREAMFILE* streamFile);
|
||||
VGMSTREAM * init_vgmstream_nub_at3(STREAMFILE * streamFile);
|
||||
VGMSTREAM * init_vgmstream_nub_xma(STREAMFILE *streamFile);
|
||||
VGMSTREAM * init_vgmstream_nub_idsp(STREAMFILE * streamFile);
|
||||
VGMSTREAM * init_vgmstream_nub_is14(STREAMFILE * streamFile);
|
||||
|
||||
#endif /*_META_H*/
|
||||
|
470
src/meta/nub.c
Normal file
470
src/meta/nub.c
Normal file
@ -0,0 +1,470 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
|
||||
static STREAMFILE* make_nub_streamfile(STREAMFILE* streamFile, off_t header_offset, size_t header_size, off_t stream_offset, size_t stream_size, const char* fake_ext);
|
||||
|
||||
/* .nub - Namco's nu Sound v2 audio container */
|
||||
VGMSTREAM * init_vgmstream_nub(STREAMFILE *streamFile) {
|
||||
VGMSTREAM *vgmstream = NULL;
|
||||
STREAMFILE *temp_streamFile = NULL;
|
||||
off_t name_offset = 0;
|
||||
size_t name_size = 0;
|
||||
int total_subsongs, target_subsong = streamFile->stream_index;
|
||||
uint32_t codec;
|
||||
const char* fake_ext;
|
||||
VGMSTREAM*(*init_vgmstream_function)(STREAMFILE *) = NULL;
|
||||
char name[STREAM_NAME_SIZE] = {0};
|
||||
|
||||
|
||||
/* checks */
|
||||
if (!check_extensions(streamFile, "nub"))
|
||||
goto fail;
|
||||
if (read_32bitBE(0x00,streamFile) != 0x00020100) /* v2.1? */
|
||||
goto fail;
|
||||
if (read_32bitBE(0x04,streamFile) != 0x00000000) /* null */
|
||||
goto fail;
|
||||
|
||||
/* parse TOC */
|
||||
{
|
||||
off_t offset, data_start, header_start;
|
||||
off_t header_offset, subheader_start, stream_offset;
|
||||
size_t header_size, subheader_size, stream_size;
|
||||
|
||||
/* - base header */
|
||||
/* 0x08: file id/number */
|
||||
total_subsongs = read_32bitBE(0x0c, streamFile); /* .nub with 0 files do exist */
|
||||
data_start = read_32bitBE(0x10, streamFile);
|
||||
/* 0x14: data end */
|
||||
header_start = read_32bitBE(0x18, streamFile);
|
||||
/* 0x1c: header end */
|
||||
|
||||
if (target_subsong == 0) target_subsong = 1;
|
||||
if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail;
|
||||
|
||||
offset = read_32bitBE(header_start + (target_subsong-1)*0x04, streamFile);
|
||||
|
||||
/* .nus have all headers first then all data, but extractors often just paste them together,
|
||||
* so we'll combine header+data on the fly to make them playable with existing parsers.
|
||||
* As formats inside .nub don't exist as external files, they can be extracted in various
|
||||
* ways so we'll try to match (though BNSF can be found as header+data in some bigfiles too). */
|
||||
|
||||
/* - file header */
|
||||
/* 00: extension (as referenced in companion files with internal filenames, ex. "BGM_MovingDemo1.is14" > "is14") */
|
||||
/* 04: config? */
|
||||
/* 08: header id/number */
|
||||
codec = (uint32_t)read_32bitBE(offset + 0x0c, streamFile);
|
||||
/* 10: null */
|
||||
stream_size = read_32bitBE(offset + 0x14, streamFile); /* 0x10 aligned */
|
||||
stream_offset = read_32bitBE(offset + 0x18, streamFile) + data_start;
|
||||
subheader_size = read_32bitBE(offset + 0x1c, streamFile);
|
||||
/* rest looks like config/volumes/etc */
|
||||
|
||||
subheader_start = 0xBC;
|
||||
header_offset = offset;
|
||||
header_size = align_size_to_block(subheader_start + subheader_size, 0x10);
|
||||
|
||||
switch(codec) {
|
||||
case 0x01: /* "wav\0" */
|
||||
fake_ext = "wav";
|
||||
init_vgmstream_function = init_vgmstream_nub_wav;
|
||||
break;
|
||||
|
||||
case 0x02: /* "vag\0" */
|
||||
fake_ext = "vag";
|
||||
init_vgmstream_function = init_vgmstream_nub_vag;
|
||||
break;
|
||||
|
||||
case 0x03: /* "at3\0" */
|
||||
fake_ext = "at3";
|
||||
init_vgmstream_function = init_vgmstream_nub_at3;
|
||||
break;
|
||||
|
||||
case 0x04: /* "xma\0" (old) */
|
||||
case 0x08: /* "xma\0" (new) */
|
||||
fake_ext = "xma";
|
||||
init_vgmstream_function = init_vgmstream_nub_xma;
|
||||
break;
|
||||
|
||||
case 0x06: /* "idsp" */
|
||||
fake_ext = "idsp";
|
||||
init_vgmstream_function = init_vgmstream_nub_idsp;
|
||||
break;
|
||||
|
||||
case 0x07: /* "is14" */
|
||||
fake_ext = "is14";
|
||||
init_vgmstream_function = init_vgmstream_nub_is14;
|
||||
break;
|
||||
|
||||
case 0x05:
|
||||
default:
|
||||
VGM_LOG("NUB: unknown codec %x\n", codec);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
temp_streamFile = make_nub_streamfile(streamFile, header_offset, header_size, stream_offset, stream_size, fake_ext);
|
||||
if (!temp_streamFile) goto fail;
|
||||
}
|
||||
|
||||
/* get names */
|
||||
{
|
||||
/* file names are in a companion file, rarely [Noby Noby Boy (PS3)] */
|
||||
STREAMFILE *nameFile = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
char basename[255];
|
||||
|
||||
get_streamfile_basename(streamFile, basename, sizeof(basename));
|
||||
snprintf(filename,sizeof(filename), "nuSound2ToneStr%s.bin", basename);
|
||||
|
||||
nameFile = open_streamfile_by_filename(streamFile, filename);
|
||||
if (nameFile && read_32bitBE(0x08, nameFile) == total_subsongs) {
|
||||
off_t header_start = 0x40; /* first name is bank name */
|
||||
char name1[0x20+1] = {0};
|
||||
char name2[0x20+1] = {0};
|
||||
|
||||
name_size = 0x20;
|
||||
name_offset = header_start + (target_subsong-1)*(name_size*2);
|
||||
|
||||
read_string(name1,name_size, name_offset + 0x00, nameFile); /* internal name */
|
||||
read_string(name2,name_size, name_offset + 0x20, nameFile); /* file name */
|
||||
//todo some filenames use shift-jis, not sure what to do
|
||||
|
||||
snprintf(name,sizeof(name), "%s/%s", name1,name2);
|
||||
}
|
||||
close_streamfile(nameFile);
|
||||
}
|
||||
|
||||
/* init the VGMSTREAM */
|
||||
vgmstream = init_vgmstream_function(temp_streamFile);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->num_streams = total_subsongs;
|
||||
if (name[0] != '\0')
|
||||
strcpy(vgmstream->stream_name, name);
|
||||
|
||||
close_streamfile(temp_streamFile);
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_streamfile(temp_streamFile);
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* *********************************************************** */
|
||||
|
||||
static STREAMFILE* make_nub_streamfile(STREAMFILE* streamFile, off_t header_offset, size_t header_size, off_t stream_offset, size_t stream_size, const char* fake_ext) {
|
||||
STREAMFILE *temp_streamFile = NULL, *new_streamFile = NULL;
|
||||
STREAMFILE *segment_streamFiles[2] = {0};
|
||||
int i;
|
||||
|
||||
|
||||
new_streamFile = open_wrap_streamfile(streamFile);
|
||||
if (!new_streamFile) goto fail;
|
||||
segment_streamFiles[0] = new_streamFile;
|
||||
|
||||
new_streamFile = open_wrap_streamfile(streamFile);
|
||||
if (!new_streamFile) goto fail;
|
||||
segment_streamFiles[1] = new_streamFile;
|
||||
|
||||
new_streamFile = open_clamp_streamfile(segment_streamFiles[0], header_offset,header_size);
|
||||
if (!new_streamFile) goto fail;
|
||||
segment_streamFiles[0] = new_streamFile;
|
||||
|
||||
new_streamFile = open_clamp_streamfile(segment_streamFiles[1], stream_offset,stream_size);
|
||||
if (!new_streamFile) goto fail;
|
||||
segment_streamFiles[1] = new_streamFile;
|
||||
|
||||
new_streamFile = open_multifile_streamfile(segment_streamFiles, 2);
|
||||
if (!new_streamFile) goto fail;
|
||||
temp_streamFile = new_streamFile;
|
||||
|
||||
new_streamFile = open_fakename_streamfile(temp_streamFile, NULL, fake_ext);
|
||||
if (!new_streamFile) goto fail;
|
||||
temp_streamFile = new_streamFile;
|
||||
|
||||
return temp_streamFile;
|
||||
|
||||
fail:
|
||||
if (!temp_streamFile) {
|
||||
for (i = 0; i < 2; i++) {
|
||||
close_streamfile(segment_streamFiles[i]);
|
||||
}
|
||||
} else {
|
||||
close_streamfile(temp_streamFile); /* closes all segments */
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* *********************************************************** */
|
||||
|
||||
//todo could be simplified
|
||||
|
||||
/* .nub wav - from Namco NUB archives [Ridge Racer 7 (PS3)] */
|
||||
VGMSTREAM * init_vgmstream_nub_wav(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
int loop_flag, channel_count;
|
||||
|
||||
|
||||
/* checks */
|
||||
if (!check_extensions(streamFile, "wav,lwav"))
|
||||
goto fail;
|
||||
if (read_32bitBE(0x00,streamFile) != 0x77617600) /* "wav\0" "*/
|
||||
goto fail;
|
||||
|
||||
if (read_16bitBE(0xBC+0x00,streamFile) != 0x0001) /* mini "fmt" chunk */
|
||||
goto fail;
|
||||
|
||||
loop_flag = read_32bitBE(0x24,streamFile);
|
||||
channel_count = read_16bitBE(0xBC+0x02,streamFile);
|
||||
start_offset = 0xD0;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->meta_type = meta_NUB;
|
||||
vgmstream->sample_rate = read_32bitBE(0xBC+0x04,streamFile);
|
||||
vgmstream->num_samples = pcm_bytes_to_samples(read_32bitBE(0x14,streamFile), channel_count, 16);
|
||||
vgmstream->loop_start_sample = pcm_bytes_to_samples(read_32bitBE(0x20,streamFile), channel_count, 16);
|
||||
vgmstream->loop_end_sample = pcm_bytes_to_samples(read_32bitBE(0x24,streamFile), channel_count, 16);
|
||||
|
||||
vgmstream->coding_type = coding_PCM16BE;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x02;
|
||||
|
||||
if ( !vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* .nub vag - from Namco NUB archives [Ridge Racer 7 (PS3), Noby Noby Boy (PS3)] */
|
||||
VGMSTREAM * init_vgmstream_nub_vag(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
int loop_flag, channel_count;
|
||||
|
||||
|
||||
/* checks */
|
||||
if ( !check_extensions(streamFile, "vag"))
|
||||
goto fail;
|
||||
if (read_32bitBE(0x00,streamFile) != 0x76616700) /* "vag\0" */
|
||||
goto fail;
|
||||
|
||||
loop_flag = read_32bitBE(0x24,streamFile);
|
||||
channel_count = 1; /* dual file stereo */
|
||||
start_offset = 0xC0;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->meta_type = meta_NUB;
|
||||
vgmstream->sample_rate = read_32bitBE(0xBC,streamFile);
|
||||
vgmstream->num_samples = ps_bytes_to_samples(read_32bitBE(0x14,streamFile), channel_count);
|
||||
vgmstream->loop_start_sample = ps_bytes_to_samples(read_32bitBE(0x20,streamFile), channel_count);
|
||||
vgmstream->loop_end_sample = ps_bytes_to_samples(read_32bitBE(0x24,streamFile), channel_count);
|
||||
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
vgmstream->layout_type = layout_none;
|
||||
vgmstream->allow_dual_stereo = 1;
|
||||
|
||||
if ( !vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* .nub at3 - from Namco NUB archives [Ridge Racer 7 (PS3), Katamari Forever (PS3)] */
|
||||
VGMSTREAM * init_vgmstream_nub_at3(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
STREAMFILE *temp_streamFile = NULL;
|
||||
off_t subfile_offset = 0;
|
||||
size_t subfile_size = 0;
|
||||
|
||||
|
||||
/* checks */
|
||||
if (!check_extensions(streamFile,"at3"))
|
||||
goto fail;
|
||||
if (read_32bitBE(0x00,streamFile) != 0x61743300) /* "at3\0" */
|
||||
goto fail;
|
||||
|
||||
/* mini fmt+fact header, we can use RIFF anyway */
|
||||
subfile_offset = 0x100;
|
||||
subfile_size = read_32bitLE(subfile_offset + 0x04, streamFile) + 0x08; /* RIFF size */
|
||||
|
||||
temp_streamFile = setup_subfile_streamfile(streamFile, subfile_offset,subfile_size, NULL);
|
||||
if (!temp_streamFile) goto fail;
|
||||
|
||||
vgmstream = init_vgmstream_riff(temp_streamFile);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
close_streamfile(temp_streamFile);
|
||||
return vgmstream;
|
||||
fail:
|
||||
close_streamfile(temp_streamFile);
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* .nub xma - from Namco NUB archives [Tekken 6 (X360), Galaga Legions DX (X360)] */
|
||||
VGMSTREAM * init_vgmstream_nub_xma(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
off_t start_offset, chunk_offset;
|
||||
size_t data_size, chunk_size;
|
||||
int loop_flag, channel_count, sample_rate, nus_codec;
|
||||
int num_samples, loop_start_sample, loop_end_sample;
|
||||
|
||||
|
||||
/* checks */
|
||||
if (!check_extensions(streamFile,"xma"))
|
||||
goto fail;
|
||||
if (read_32bitBE(0x00,streamFile) != 0x786D6100) /* "xma\0" */
|
||||
goto fail;
|
||||
|
||||
/* header with a "XMA2" or "fmt " chunk inside */
|
||||
nus_codec = read_32bitBE(0x0C,streamFile);
|
||||
data_size = read_32bitBE(0x14,streamFile);
|
||||
chunk_offset = 0xBC;
|
||||
chunk_size = read_32bitBE(0x24,streamFile);
|
||||
if (nus_codec == 0x4) { /* "XMA2" */
|
||||
xma2_parse_xma2_chunk(streamFile, chunk_offset, &channel_count,&sample_rate, &loop_flag, &num_samples, &loop_start_sample, &loop_end_sample);
|
||||
} else if (nus_codec == 0x8) { /* "fmt " */
|
||||
channel_count = read_16bitBE(chunk_offset+0x02,streamFile);
|
||||
sample_rate = read_32bitBE(chunk_offset+0x04,streamFile);
|
||||
xma2_parse_fmt_chunk_extra(streamFile, chunk_offset, &loop_flag, &num_samples, &loop_start_sample, &loop_end_sample, 1);
|
||||
} else {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
start_offset = 0x100;
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->meta_type = meta_NUB;
|
||||
vgmstream->sample_rate = sample_rate;
|
||||
vgmstream->num_samples = num_samples;
|
||||
vgmstream->loop_start_sample = loop_start_sample;
|
||||
vgmstream->loop_end_sample = loop_end_sample;
|
||||
|
||||
#ifdef VGM_USE_FFMPEG
|
||||
{
|
||||
uint8_t buf[0x100];
|
||||
size_t bytes;
|
||||
|
||||
if (nus_codec == 0x4) { /* "XMA2" */
|
||||
bytes = ffmpeg_make_riff_xma2_from_xma2_chunk(buf,0x100, chunk_offset,chunk_size, data_size, streamFile);
|
||||
} else { /* "fmt " */
|
||||
bytes = ffmpeg_make_riff_xma_from_fmt_chunk(buf,0x100, chunk_offset,chunk_size, data_size, streamFile, 1);
|
||||
}
|
||||
vgmstream->codec_data = init_ffmpeg_header_offset(streamFile, buf,bytes, start_offset,data_size);
|
||||
if ( !vgmstream->codec_data ) goto fail;
|
||||
vgmstream->coding_type = coding_FFmpeg;
|
||||
vgmstream->layout_type = layout_none;
|
||||
|
||||
xma_fix_raw_samples(vgmstream, streamFile, start_offset, data_size, chunk_offset, 1,1); /* samples needs adjustment */
|
||||
}
|
||||
#else
|
||||
goto fail;
|
||||
#endif
|
||||
|
||||
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* .nub idsp - from Namco NUB archives [Soul Calibur Legends (Wii), Sky Crawlers: Innocent Aces (Wii)] */
|
||||
VGMSTREAM * init_vgmstream_nub_idsp(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
int loop_flag, channel_count;
|
||||
|
||||
/* checks */
|
||||
if ( !check_extensions(streamFile,"idsp") )
|
||||
goto fail;
|
||||
|
||||
if (read_32bitBE(0x00,streamFile) != 0x69647370) /* "idsp" */
|
||||
goto fail;
|
||||
if (read_32bitBE(0xBC,streamFile) != 0x49445350) /* "IDSP" (actual header) */
|
||||
goto fail;
|
||||
|
||||
loop_flag = read_32bitBE(0x20,streamFile);
|
||||
channel_count = read_32bitBE(0xC4,streamFile);
|
||||
if (channel_count > 8) goto fail;
|
||||
start_offset = 0x100 + (channel_count * 0x60);
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->meta_type = meta_NUB;
|
||||
vgmstream->sample_rate = read_32bitBE(0xC8,streamFile);
|
||||
vgmstream->num_samples = dsp_bytes_to_samples(read_32bitBE(0x14,streamFile),channel_count);
|
||||
vgmstream->loop_start_sample = read_32bitBE(0xD0,streamFile);
|
||||
vgmstream->loop_end_sample = read_32bitBE(0xD4,streamFile);
|
||||
|
||||
vgmstream->coding_type = coding_NGC_DSP;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = read_32bitBE(0xD8,streamFile);
|
||||
if (vgmstream->interleave_block_size == 0)
|
||||
vgmstream->interleave_block_size = read_32bitBE(0x14,streamFile) / channel_count;
|
||||
|
||||
dsp_read_coefs_be(vgmstream,streamFile,0x118,0x60);
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream, streamFile, start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* .nub is14 - from Namco NUB archives [Tales of Vesperia (PS3)] */
|
||||
VGMSTREAM * init_vgmstream_nub_is14(STREAMFILE *streamFile) {
|
||||
VGMSTREAM *vgmstream = NULL;
|
||||
STREAMFILE *temp_streamFile = NULL;
|
||||
off_t header_offset, stream_offset;
|
||||
size_t header_size, stream_size;
|
||||
|
||||
|
||||
/* checks */
|
||||
if (!check_extensions(streamFile,"is14"))
|
||||
goto fail;
|
||||
if (read_32bitBE(0x00,streamFile) != 0x69733134) /* "is14" */
|
||||
goto fail;
|
||||
|
||||
/* paste header+data together and pass to meta */
|
||||
header_offset = 0xBC;
|
||||
header_size = read_32bitBE(0x1c, streamFile);
|
||||
stream_offset = align_size_to_block(header_offset + header_size, 0x10);
|
||||
stream_size = read_32bitBE(header_offset + header_size - 0x04, streamFile);/* size at 0x14 is padded, use "sdat" size */
|
||||
|
||||
temp_streamFile = make_nub_streamfile(streamFile, header_offset, header_size, stream_offset, stream_size, "bnsf");
|
||||
if (!temp_streamFile) goto fail;
|
||||
|
||||
vgmstream = init_vgmstream_bnsf(temp_streamFile);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
close_streamfile(temp_streamFile);
|
||||
return vgmstream;
|
||||
fail:
|
||||
close_streamfile(temp_streamFile);
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
|
||||
/* "idsp" - from Namco's Wii NUB archives [Soul Calibur Legends (Wii), Sky Crawlers: Innocent Aces (Wii)] */
|
||||
VGMSTREAM * init_vgmstream_nub_idsp(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
int loop_flag, channel_count;
|
||||
|
||||
/* checks */
|
||||
if ( !check_extensions(streamFile,"idsp") )
|
||||
goto fail;
|
||||
|
||||
/* actual header starts at "IDSP", while "idsp" is mostly nub bank stuff */
|
||||
if (read_32bitBE(0x00,streamFile) != 0x69647370) /* "idsp" */
|
||||
goto fail;
|
||||
if (read_32bitBE(0xBC,streamFile) != 0x49445350) /* "IDSP" */
|
||||
goto fail;
|
||||
|
||||
loop_flag = read_32bitBE(0x20,streamFile);
|
||||
channel_count = read_32bitBE(0xC4,streamFile);
|
||||
if (channel_count > 8) goto fail;
|
||||
|
||||
start_offset = 0x100 + (channel_count * 0x60);
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->meta_type = meta_NUB_IDSP;
|
||||
vgmstream->sample_rate = read_32bitBE(0xC8,streamFile);
|
||||
vgmstream->num_samples = dsp_bytes_to_samples(read_32bitBE(0x14,streamFile),channel_count);
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = (read_32bitBE(0xD0,streamFile));
|
||||
vgmstream->loop_end_sample = (read_32bitBE(0xD4,streamFile));
|
||||
}
|
||||
|
||||
vgmstream->coding_type = coding_NGC_DSP;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = read_32bitBE(0xD8,streamFile);
|
||||
if (vgmstream->interleave_block_size == 0)
|
||||
vgmstream->interleave_block_size = (get_streamfile_size(streamFile) - start_offset) / channel_count;
|
||||
|
||||
dsp_read_coefs_be(vgmstream,streamFile,0x118,0x60);
|
||||
|
||||
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
#include "meta.h"
|
||||
#include "../util.h"
|
||||
|
||||
/* vag - from Namco's PS3 NUB archives (Ridge Racer 7) */
|
||||
VGMSTREAM * init_vgmstream_nub_vag(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
int loop_flag, channel_count;
|
||||
|
||||
|
||||
/* check extension, case insensitive */
|
||||
if ( !check_extensions(streamFile, "vag")) goto fail;
|
||||
|
||||
/* check header */
|
||||
if (read_32bitBE(0x00,streamFile) != 0x76616700) /* "vag\0" */
|
||||
goto fail;
|
||||
|
||||
loop_flag = read_32bitBE(0x30,streamFile)==0x3F800000;
|
||||
channel_count = 1; /* dual file stereo */
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->sample_rate = read_32bitBE(0xBC,streamFile);
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
vgmstream->num_samples = read_32bitBE(0x14,streamFile)*28/32*2;
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = read_32bitBE(0x20,streamFile)*28/32*2;
|
||||
vgmstream->loop_end_sample = read_32bitBE(0x24,streamFile)*28/32*2;
|
||||
}
|
||||
|
||||
vgmstream->layout_type = layout_none;
|
||||
vgmstream->meta_type = meta_NUB_VAG;
|
||||
vgmstream->allow_dual_stereo = 1;
|
||||
|
||||
start_offset = 0xC0;
|
||||
|
||||
/* open the file for reading */
|
||||
if ( !vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
/* Namco NUB xma - from Tekken 6, Galaga Legions DX */
|
||||
VGMSTREAM * init_vgmstream_nub_xma(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
off_t start_offset, chunk_offset;
|
||||
size_t data_size, chunk_size;
|
||||
int loop_flag, channel_count, sample_rate, chunk_type;
|
||||
int num_samples, loop_start_sample, loop_end_sample;
|
||||
|
||||
|
||||
/* checks */
|
||||
if ( !check_extensions(streamFile,"xma")) /* (probably meant to be .nub) */
|
||||
goto fail;
|
||||
if (read_32bitBE(0x00,streamFile) != 0x786D6100) /* "xma\0" */
|
||||
goto fail;
|
||||
|
||||
|
||||
/* custom header with a "XMA2" or "fmt " chunk inside; most other values are unknown */
|
||||
chunk_type = read_32bitBE(0xC,streamFile);
|
||||
start_offset = 0x100;
|
||||
data_size = read_32bitBE(0x14,streamFile);
|
||||
chunk_offset = 0xBC;
|
||||
chunk_size = read_32bitBE(0x24,streamFile);
|
||||
if (chunk_type == 0x4) { /* "XMA2" */
|
||||
xma2_parse_xma2_chunk(streamFile, chunk_offset, &channel_count,&sample_rate, &loop_flag, &num_samples, &loop_start_sample, &loop_end_sample);
|
||||
} else if (chunk_type == 0x8) { /* "fmt " */
|
||||
channel_count = read_16bitBE(chunk_offset+0x02,streamFile);
|
||||
sample_rate = read_32bitBE(chunk_offset+0x04,streamFile);
|
||||
xma2_parse_fmt_chunk_extra(streamFile, chunk_offset, &loop_flag, &num_samples, &loop_start_sample, &loop_end_sample, 1);
|
||||
} else {
|
||||
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_NUB_XMA;
|
||||
|
||||
#ifdef VGM_USE_FFMPEG
|
||||
{
|
||||
uint8_t buf[0x100];
|
||||
size_t bytes;
|
||||
|
||||
if (chunk_type == 0x4) { /* "XMA2" */
|
||||
bytes = ffmpeg_make_riff_xma2_from_xma2_chunk(buf,0x100, chunk_offset,chunk_size, data_size, streamFile);
|
||||
} else { /* "fmt " */
|
||||
bytes = ffmpeg_make_riff_xma_from_fmt_chunk(buf,0x100, chunk_offset,chunk_size, data_size, streamFile, 1);
|
||||
}
|
||||
vgmstream->codec_data = init_ffmpeg_header_offset(streamFile, buf,bytes, start_offset,data_size);
|
||||
if ( !vgmstream->codec_data ) goto fail;
|
||||
vgmstream->coding_type = coding_FFmpeg;
|
||||
vgmstream->layout_type = layout_none;
|
||||
|
||||
xma_fix_raw_samples(vgmstream, streamFile, start_offset, data_size, chunk_offset, 1,1); /* samples needs adjustment */
|
||||
}
|
||||
#else
|
||||
goto fail;
|
||||
#endif
|
||||
|
||||
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
* Some info: https://www.audiokinetic.com/en/library/edge/
|
||||
*/
|
||||
typedef enum { PCM, IMA, VORBIS, DSP, XMA2, XWMA, AAC, HEVAG, ATRAC9, OPUS } wwise_codec;
|
||||
typedef enum { PCM, IMA, VORBIS, DSP, XMA2, XWMA, AAC, HEVAG, ATRAC9, OPUSNX, OPUS, PTADPCM } wwise_codec;
|
||||
typedef struct {
|
||||
int big_endian;
|
||||
size_t file_size;
|
||||
@ -73,7 +73,7 @@ VGMSTREAM * init_vgmstream_wwise(STREAMFILE *streamFile) {
|
||||
|
||||
#if 0
|
||||
/* Wwise's RIFF size is often wonky, seemingly depending on codec:
|
||||
* - PCM, IMA, VORBIS, AAC, OPUS: correct
|
||||
* - PCM, IMA/PTADPCM, VORBIS, AAC, OPUSNX/OPUS: correct
|
||||
* - DSP, XWMA, ATRAC9: almost always slightly smaller (around 0x50)
|
||||
* - HEVAG: very off
|
||||
* - XMA2: exact file size
|
||||
@ -172,14 +172,17 @@ VGMSTREAM * init_vgmstream_wwise(STREAMFILE *streamFile) {
|
||||
case 0x0162: ww.codec = XWMA; break; /* WMAPro */
|
||||
case 0x0165: ww.codec = XMA2; break; /* always with the "XMA2" chunk, Wwise doesn't use XMA1 */
|
||||
case 0x0166: ww.codec = XMA2; break;
|
||||
case 0x3039: ww.codec = OPUS; break; /* later renamed to "OPUSNX" */
|
||||
//case 0x3040: ww.codec = OPUS; break; /* same for other platforms, supposedly */
|
||||
case 0xAAC0: ww.codec = AAC; break;
|
||||
case 0xFFF0: ww.codec = DSP; break;
|
||||
case 0xFFFB: ww.codec = HEVAG; break;
|
||||
case 0xFFFC: ww.codec = ATRAC9; break;
|
||||
case 0xFFFE: ww.codec = PCM; break; /* "PCM for Wwise Authoring" */
|
||||
case 0xFFFF: ww.codec = VORBIS; break;
|
||||
case 0x3039: ww.codec = OPUSNX; break; /* later renamed from "OPUS" */
|
||||
#if 0
|
||||
case 0x3040: ww.codec = OPUS; break;
|
||||
case 0x8311: ww.codec = PTADPCM; break;
|
||||
#endif
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
@ -193,12 +196,7 @@ VGMSTREAM * init_vgmstream_wwise(STREAMFILE *streamFile) {
|
||||
/* few older Wwise DSP with num_samples in extra_size [Tony Hawk: Shred (Wii)] */
|
||||
ww.codec = DSP;
|
||||
} else if (ww.block_align == 0x104 * ww.channels) {
|
||||
//ww.codec = SWITCH_ADPCM;
|
||||
/* unknown codec, found in Bayonetta 2 (Switch)
|
||||
* frames of 0x104 per ch, possibly frame header is hist1(2)/hist2(2)/index(1)
|
||||
* (may write 2 header samples + FF*2 nibbles = 0x200 samples per block?)
|
||||
* index only goes up to ~0xb, may be a shift/scale value */
|
||||
goto fail;
|
||||
ww.codec = PTADPCM; /* Bayonetta 2 (Switch) */
|
||||
}
|
||||
}
|
||||
|
||||
@ -561,7 +559,7 @@ VGMSTREAM * init_vgmstream_wwise(STREAMFILE *streamFile) {
|
||||
break;
|
||||
}
|
||||
|
||||
case OPUS: { /* Switch */
|
||||
case OPUSNX: { /* Switch */
|
||||
size_t skip;
|
||||
|
||||
/* values up to 0x14 seem fixed and similar to HEVAG's (block_align 0x02/04, bits_per_sample 0x10) */
|
||||
@ -587,6 +585,25 @@ VGMSTREAM * init_vgmstream_wwise(STREAMFILE *streamFile) {
|
||||
vgmstream->layout_type = layout_none;
|
||||
break;
|
||||
}
|
||||
|
||||
#if 0
|
||||
case OPUS: { /* PC/etc */
|
||||
ffmpeg_codec_data * ffmpeg_data = NULL;
|
||||
if (ww.block_align != 0 || ww.bits_per_sample != 0) goto fail;
|
||||
|
||||
/* extra: size 0x12, unknown values, maybe num_samples/etc */
|
||||
|
||||
ffmpeg_data = init_ffmpeg_offset(streamFile, ww.data_offset,ww.data_size);
|
||||
if (!ffmpeg_data) goto fail;
|
||||
vgmstream->codec_data = ffmpeg_data;
|
||||
vgmstream->coding_type = coding_FFmpeg;
|
||||
vgmstream->layout_type = layout_none;
|
||||
|
||||
vgmstream->num_samples = (int32_t)ffmpeg_data->totalSamples;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
case HEVAG: /* PSV */
|
||||
/* changed values, another bizarre Wwise quirk */
|
||||
@ -626,12 +643,24 @@ VGMSTREAM * init_vgmstream_wwise(STREAMFILE *streamFile) {
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case PTADPCM: /* substitutes IMA as default ADPCM codec */
|
||||
if (ww.bits_per_sample != 4) goto fail;
|
||||
if (ww.block_align != 0x24 * ww.channels && ww.block_align != 0x104 * ww.channels) goto fail;
|
||||
|
||||
vgmstream->coding_type = coding_PTADPCM;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = ww.block_align / ww.channels;
|
||||
//vgmstream->codec_endian = ww.big_endian; //?
|
||||
|
||||
vgmstream->num_samples = ptadpcm_bytes_to_samples(ww.data_size, ww.channels, vgmstream->interleave_block_size);
|
||||
break;
|
||||
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ( !vgmstream_open_stream(vgmstream,streamFile,start_offset) )
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
@ -144,7 +144,6 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = {
|
||||
init_vgmstream_kraw,
|
||||
init_vgmstream_ps2_omu,
|
||||
init_vgmstream_ps2_xa2,
|
||||
init_vgmstream_nub_idsp,
|
||||
init_vgmstream_idsp_nl,
|
||||
init_vgmstream_idsp_ie,
|
||||
init_vgmstream_ngc_ymf,
|
||||
@ -264,7 +263,6 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = {
|
||||
init_vgmstream_baf,
|
||||
init_vgmstream_baf_badrip,
|
||||
init_vgmstream_msf,
|
||||
init_vgmstream_nub_vag,
|
||||
init_vgmstream_ps3_past,
|
||||
init_vgmstream_sgxd,
|
||||
init_vgmstream_ngca,
|
||||
@ -314,7 +312,6 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = {
|
||||
init_vgmstream_wwise,
|
||||
init_vgmstream_ubi_raki,
|
||||
init_vgmstream_x360_pasx,
|
||||
init_vgmstream_nub_xma,
|
||||
init_vgmstream_xma,
|
||||
init_vgmstream_sxd,
|
||||
init_vgmstream_ogl,
|
||||
@ -473,6 +470,13 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = {
|
||||
init_vgmstream_dsp_itl,
|
||||
init_vgmstream_sch,
|
||||
init_vgmstream_ima,
|
||||
init_vgmstream_nub,
|
||||
init_vgmstream_nub_wav,
|
||||
init_vgmstream_nub_vag,
|
||||
init_vgmstream_nub_at3,
|
||||
init_vgmstream_nub_xma,
|
||||
init_vgmstream_nub_idsp,
|
||||
init_vgmstream_nub_is14,
|
||||
|
||||
/* lowest priority metas (should go after all metas, and TXTH should go before raw formats) */
|
||||
init_vgmstream_txth, /* proper parsers should supersede TXTH, once added */
|
||||
@ -1245,6 +1249,8 @@ int get_vgmstream_samples_per_frame(VGMSTREAM * vgmstream) {
|
||||
return 14; /* (0x08 - 0x1) * 2 */
|
||||
case coding_XMD:
|
||||
return (vgmstream->interleave_block_size - 0x06)*2 + 2;
|
||||
case coding_PTADPCM:
|
||||
return (vgmstream->interleave_block_size - 0x05)*2 + 2;
|
||||
case coding_EA_MT:
|
||||
return 0; /* 432, but variable in looped files */
|
||||
case coding_CRI_HCA:
|
||||
@ -1427,6 +1433,8 @@ int get_vgmstream_frame_size(VGMSTREAM * vgmstream) {
|
||||
return 0x08;
|
||||
case coding_XMD:
|
||||
return vgmstream->interleave_block_size;
|
||||
case coding_PTADPCM:
|
||||
return vgmstream->interleave_block_size;
|
||||
case coding_EA_MT:
|
||||
return 0; /* variable (frames of bit counts or PCM frames) */
|
||||
#ifdef VGM_USE_ATRAC9
|
||||
@ -2074,6 +2082,13 @@ void decode_vgmstream(VGMSTREAM * vgmstream, int samples_written, int samples_to
|
||||
vgmstream->interleave_block_size);
|
||||
}
|
||||
break;
|
||||
case coding_PTADPCM:
|
||||
for (ch = 0; ch < vgmstream->channels; ch++) {
|
||||
decode_ptadpcm(&vgmstream->ch[ch],buffer+samples_written*vgmstream->channels+ch,
|
||||
vgmstream->channels,vgmstream->samples_into_block,samples_to_do,
|
||||
vgmstream->interleave_block_size);
|
||||
}
|
||||
break;
|
||||
case coding_PCFX:
|
||||
for (ch = 0; ch < vgmstream->channels; ch++) {
|
||||
decode_pcfx(&vgmstream->ch[ch],buffer+samples_written*vgmstream->channels+ch,
|
||||
|
@ -165,6 +165,7 @@ typedef enum {
|
||||
coding_XMD, /* Konami XMD 4-bit ADPCM */
|
||||
coding_PCFX, /* PC-FX 4-bit ADPCM */
|
||||
coding_OKI16, /* OKI 4-bit ADPCM with 16-bit output */
|
||||
coding_PTADPCM, /* Platinum 4-bit ADPCM */
|
||||
|
||||
/* others */
|
||||
coding_SDX2, /* SDX2 2:1 Squareroot-Delta-Exact compression DPCM */
|
||||
@ -399,7 +400,7 @@ typedef enum {
|
||||
meta_KRAW, /* Geometry Wars - Galaxies */
|
||||
meta_PS2_OMU, /* PS2 Int file with Header */
|
||||
meta_PS2_XA2, /* XG3 Extreme-G Racing */
|
||||
meta_NUB_IDSP, /* Soul Calibur Legends (Wii) */
|
||||
meta_NUB,
|
||||
meta_IDSP_NL, /* Mario Strikers Charged (Wii) */
|
||||
meta_IDSP_IE, /* Defencer (GC) */
|
||||
meta_SPT_SPD, /* Various (SPT+SPT DSP) */
|
||||
@ -545,7 +546,6 @@ typedef enum {
|
||||
meta_XVAG, /* Ratchet & Clank Future: Quest for Booty (PS3) */
|
||||
meta_PS3_CPS, /* Eternal Sonata (PS3) */
|
||||
meta_MSF,
|
||||
meta_NUB_VAG, /* Namco VAG from NUB archives */
|
||||
meta_PS3_PAST, /* Bakugan Battle Brawlers (PS3) */
|
||||
meta_SGXD, /* Sony: Folklore, Genji, Tokyo Jungle (PS3), Brave Story, Kurohyo (PSP) */
|
||||
meta_NGCA, /* GoldenEye 007 (Wii) */
|
||||
@ -590,7 +590,6 @@ typedef enum {
|
||||
meta_FFMPEG, /* any file supported by FFmpeg */
|
||||
meta_X360_CXS, /* Eternal Sonata (Xbox 360) */
|
||||
meta_AKB, /* SQEX iOS */
|
||||
meta_NUB_XMA, /* Namco XMA from NUB archives */
|
||||
meta_X360_PASX, /* Namco PASX (Soul Calibur II HD X360) */
|
||||
meta_XMA_RIFF, /* Microsoft RIFF XMA */
|
||||
meta_X360_AST, /* Dead Rising (X360) */
|
||||
|
Loading…
Reference in New Issue
Block a user