Updated VGMStream to r1050-3748-g20e1ade3

CQTexperiment
Christopher Snowhill 2021-06-14 19:54:42 -07:00
parent 11aa63265d
commit 0c648b3b1d
16 changed files with 4398 additions and 4305 deletions

View File

@ -570,6 +570,7 @@ STREAMFILE* ffmpeg_get_streamfile(ffmpeg_codec_data* data);
/* ffmpeg_decoder_utils.c (helper-things) */
ffmpeg_codec_data* init_ffmpeg_atrac3_raw(STREAMFILE* sf, off_t offset, size_t data_size, int sample_count, int channels, int sample_rate, int block_align, int encoder_delay);
ffmpeg_codec_data* init_ffmpeg_atrac3_riff(STREAMFILE* sf, off_t offset, int* out_samples);
ffmpeg_codec_data* init_ffmpeg_aac(STREAMFILE* sf, off_t offset, size_t size);
/* ffmpeg_decoder_custom_opus.c (helper-things) */
@ -655,6 +656,7 @@ size_t ac3_bytes_to_samples(size_t bytes, int full_block_align, int channels);
size_t aac_get_samples(STREAMFILE* sf, off_t start_offset, size_t bytes);
size_t mpeg_get_samples(STREAMFILE* sf, off_t start_offset, size_t bytes);
int32_t mpeg_get_samples_clean(STREAMFILE* sf, off_t start, size_t size, size_t* p_loop_start, size_t* p_loop_end, int is_vbr);
int mpc_get_samples(STREAMFILE* sf, off_t offset, int32_t* p_samples, int32_t* p_delay);
/* helper to pass a wrapped, clamped, fake extension-ed, SF to another meta */

View File

@ -1006,6 +1006,7 @@ size_t aac_get_samples(STREAMFILE* sf, off_t start_offset, size_t bytes) {
if (frame_size <= 0x08)
break;
//;VGM_LOG("AAC: %lx, %x\n", offset, frame_size);
frames++;
offset += frame_size;
}
@ -1013,6 +1014,82 @@ size_t aac_get_samples(STREAMFILE* sf, off_t start_offset, size_t bytes) {
return frames * samples_per_frame;
}
/* variable-sized var reader */
static int mpc_get_size(uint8_t* header, int header_size, int pos, int32_t* p_size) {
uint8_t tmp;
int32_t size = 0;
do {
if (pos >= header_size)
return pos;
tmp = header[pos];
size = (size << 7) | (tmp & 0x7F);
pos++;
}
while((tmp & 0x80));
*p_size = size;
return pos;
}
int mpc_get_samples(STREAMFILE* sf, off_t offset, int32_t* p_samples, int32_t* p_delay) {
uint8_t header[0x20];
int pos, size;
int32_t samples = 0, delay = 0;
if (read_streamfile(header, offset, sizeof(header), sf) != sizeof(header))
goto fail;;
if ((get_u32be(header) & 0xFFFFFF0F) == get_id32be("MP+\x07")) {
samples = get_u32le(header + 0x04) * 1152; /* total frames */
delay = 481; /* MPC_DECODER_SYNTH_DELAY */
samples -= delay;
/* in theory one header field can contain actual delay, not observed */
}
else if (get_u32be(header) == get_id32be("MPCK")) {
/* V8 header is made if mini chunks (16b type, 8b size including type+size):
* - SH: stream header
* - RG: replay gain
* - EI: encoder info
* - SO: seek?
* - ST: stream?
* - AP: audio part start */
if (get_u16be(header + 0x04) != 0x5348)
goto fail;
size = get_u8(header + 0x06);
if (0x04 + size > sizeof(header))
goto fail;
if (get_u8(header + 0x0b) != 0x08)
goto fail;
/* SH chunk: */
/* 0x00: CRC */
/* 0x04: header version (8) */
/* 0x05: samples (variable sized) */
/* 0xNN: "beginning silence" (variable sized) */
/* 0xNN: bitpacked channels/rate/etc */
pos = mpc_get_size(header, sizeof(header), 0x0C, &samples);
pos = mpc_get_size(header, sizeof(header), pos, &delay);
samples -= delay; /* original delay, not SYNTH_DELAY */
delay += 481; /* MPC_DECODER_SYNTH_DELAY */
/* SYNTH_DELAY seems to be forced, but official code isn't very clear (known samples set delay to 0 but need SYNTH DELAY) */
}
else {
goto fail;
}
if (p_samples) *p_samples = samples;
if (p_delay) *p_delay = delay;
return 1;
fail:
return 0;
}
/* ******************************************** */
/* CUSTOM STREAMFILES */
/* ******************************************** */

View File

@ -187,4 +187,24 @@ fail:
return NULL;
}
ffmpeg_codec_data* init_ffmpeg_aac(STREAMFILE* sf, off_t offset, size_t size) {
ffmpeg_codec_data* data = NULL;
data = init_ffmpeg_offset(sf, offset, size);
if (!data) goto fail;
/* seeks to 0 eats first frame for whatever reason */
ffmpeg_set_force_seek(data);
/* raw AAC doesn't set this, while some decoders like FAAD remove 1024,
* but should be handled in container as each encoder uses its own value
* (Apple: 2112, FAAD: probably 1024, etc) */
//ffmpeg_set_skip_samples(data, 1024);
return data;
fail:
free_ffmpeg(data);
return NULL;
}
#endif

View File

@ -252,6 +252,9 @@ static const adxkey_info adxkey9_list[] = {
/* Assault Lily Last Bullet (Android) */
{0x0000,0x0000,0x0000, NULL,6349046567469313}, // 00168E6C99510101 (+ AWB subkeys)
/* maimai DX Splash (AC) */
{0x0000,0x0000,0x0000, NULL,9170825592834449000}, // 7F4551499DF55E68
};
static const int adxkey8_list_count = sizeof(adxkey8_list) / sizeof(adxkey8_list[0]);

View File

@ -23,7 +23,7 @@
#define EA_PLATFORM_X360 0x09
#define EA_PLATFORM_PSP 0x0A
#define EA_PLATFORM_PS3 0x0E /* very rare [Need for Speed: Carbon (PS3)] */
#define EA_PLATFORM_WII 0x10 /* not seen so far */
#define EA_PLATFORM_WII 0x10 /* not seen so far (sx.exe samples ok) */
#define EA_PLATFORM_3DS 0x14
/* codec constants (undefined are probably reserved, ie.- sx.exe encodes PCM24/DVI but no platform decodes them) */
@ -48,19 +48,19 @@
#define EA_CODEC2_S16LE 0x08
#define EA_CODEC2_S8 0x09
#define EA_CODEC2_EAXA 0x0A
//#define EA_CODEC2_U8_INT 0x0B /* not used */
//#define EA_CODEC2_CDXA 0x0C /* not used */
//#define EA_CODEC2_IMA 0x0D /* not used */
//#define EA_CODEC2_LAYER1 0x0E /* not used */
//#define EA_CODEC2_U8_INT 0x0B /* not used (sx.exe internal defs) */
//#define EA_CODEC2_CDXA 0x0C /* not used (sx.exe internal defs) */
//#define EA_CODEC2_IMA 0x0D /* not used (sx.exe internal defs) */
//#define EA_CODEC2_LAYER1 0x0E /* not used (sx.exe internal defs) */
#define EA_CODEC2_LAYER2 0x0F
#define EA_CODEC2_LAYER3 0x10 /* not seen so far but may be used somewhere */
#define EA_CODEC2_GCADPCM 0x12
//#define EA_CODEC2_S24LE_INT 0x13 /* not used */
//#define EA_CODEC2_S24LE_INT 0x13 /* not used (sx.exe internal defs) */
#define EA_CODEC2_XBOXADPCM 0x14
//#define EA_CODEC2_S24BE_INT 0x15 /* not used */
//#define EA_CODEC2_S24BE_INT 0x15 /* not used (sx.exe internal defs) */
#define EA_CODEC2_MT5 0x16
#define EA_CODEC2_EALAYER3 0x17
//#define EA_CODEC2_ATRAC3 0x1A /* not seen so far */
#define EA_CODEC2_ATRAC3 0x1A /* not seen so far (sx.exe samples ok) */
#define EA_CODEC2_ATRAC3PLUS 0x1B
/* Block headers, SCxy - where x is block ID and y is endianness flag (always 'l'?) */
@ -127,7 +127,7 @@ static VGMSTREAM * parse_bnk_header(STREAMFILE* sf, off_t offset, int target_str
static int parse_variable_header(STREAMFILE* sf, ea_header* ea, off_t begin_offset, int max_length, int bnk_version);
static uint32_t read_patch(STREAMFILE* sf, off_t* offset);
static off_t get_ea_stream_mpeg_start_offset(STREAMFILE* sf, off_t start_offset, const ea_header* ea);
static VGMSTREAM * init_vgmstream_ea_variable_header(STREAMFILE* sf, ea_header* ea, off_t start_offset, int is_bnk, int standalone);
static VGMSTREAM* init_vgmstream_ea_variable_header(STREAMFILE* sf, ea_header* ea, off_t start_offset, int is_bnk, int standalone);
static void update_ea_stream_size_and_samples(STREAMFILE* sf, off_t start_offset, VGMSTREAM* vgmstream, int standalone);
/* EA SCHl with variable header - from EA games (roughly 1997~2010); generated by EA Canada's sx.exe/Sound eXchange */
@ -182,7 +182,7 @@ fail:
}
/* EA SCHl inside non-demuxed videos, used in current gen games too */
VGMSTREAM * init_vgmstream_ea_schl_video(STREAMFILE* sf) {
VGMSTREAM* init_vgmstream_ea_schl_video(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
off_t offset = 0, start_offset = 0;
int blocks_done = 0;
@ -277,7 +277,7 @@ fail:
}
/* EA BNK with variable header - from EA games SFXs; also created by sx.exe */
VGMSTREAM * init_vgmstream_ea_bnk(STREAMFILE* sf) {
VGMSTREAM* init_vgmstream_ea_bnk(STREAMFILE* sf) {
int target_stream = sf->stream_index;
/* check extension */
@ -299,7 +299,7 @@ fail:
/* EA ABK - common soundbank format in 6th-gen games, can reference RAM and streamed assets */
/* RAM assets are stored in embedded BNK file */
/* streamed assets are stored externally in AST file (mostly seen in earlier 6th-gen games) */
VGMSTREAM * init_vgmstream_ea_abk(STREAMFILE* sf) {
VGMSTREAM* init_vgmstream_ea_abk(STREAMFILE* sf) {
int bnk_target_stream, is_dupe, total_sounds = 0, target_stream = sf->stream_index;
off_t bnk_offset, modules_table, module_data, player_offset, samples_table, entry_offset, target_entry_offset, schl_offset, schl_loop_offset;
uint32_t i, j, k, num_sounds, num_sample_tables;
@ -561,7 +561,7 @@ fail:
}
/* EA HDR/DAT v2 (2006-2014) */
VGMSTREAM * init_vgmstream_ea_hdr_dat_v2(STREAMFILE* sf) {
VGMSTREAM* init_vgmstream_ea_hdr_dat_v2(STREAMFILE* sf) {
VGMSTREAM *vgmstream;
STREAMFILE *sf_dat = NULL;
int target_stream = sf->stream_index;
@ -646,20 +646,18 @@ static STREAMFILE* open_mapfile_pair(STREAMFILE* sf, int track, int num_tracks)
{"SSX4FE.mpf", "TrackFE.mus"}, /* SSX On Tour */
{"SSX4Path.mpf", "Track.mus"},
{"SSX4.mpf", "moments0.mus,main.mus,load_loop0.mus"}, /* SSX Blur */
{"*.mpf", "*_main.mus"}, /* 007 - Everything or Nothing */
/* TODO: need better wildcard support
{"*.mpf", "*_main.mus"}, /* 007: Everything or Nothing */
/* EA loads pairs manually, so complex cases needs .txtm to map
* NSF2:
* ZTRxxROK.MAP > ZTRxx.TRJ
* ZTRxxTEC.MAP > ZTRxx.TRM
* ZZSHOW.MAP and ZZSHOW2.MAP > ZZSHOW.MUS
* - ZTRxxROK.MAP > ZTRxx.TRJ
* - ZTRxxTEC.MAP > ZTRxx.TRM
* - ZZSHOW.MAP and ZZSHOW2.MAP > ZZSHOW.MUS
* NSF3:
* ZTRxxROK.MAP > ZZZTRxxA.TRJ
* ZTRxxTEC.MAP > ZZZTRxxB.TRM
* ZTR00R0A.MAP and ZTR00R0B.MAP > ZZZTR00A.TRJ
* other extra files that may need the hack below
* - ZTRxxROK.MAP > ZZZTRxxA.TRJ
* - ZTRxxTEC.MAP > ZZZTRxxB.TRM
* - ZTR00R0A.MAP and ZTR00R0B.MAP > ZZZTR00A.TRJ
* SSX 3:
* *.mpf > *.mus,xxloops0.mus
* really need to think of something for this
* - *.mpf > *.mus,xxloops0.mus
*/
};
STREAMFILE* sf_mus = NULL;
@ -744,7 +742,7 @@ static STREAMFILE* open_mapfile_pair(STREAMFILE* sf, int track, int num_tracks)
/* EA MAP/MUS combo - used in older games for interactive music (for EA's PathFinder tool) */
/* seen in Need for Speed II, Need for Speed III: Hot Pursuit, SSX */
VGMSTREAM * init_vgmstream_ea_map_mus(STREAMFILE* sf) {
VGMSTREAM* init_vgmstream_ea_map_mus(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
STREAMFILE* sf_mus = NULL;
uint8_t version, num_sounds, num_events, num_sections;
@ -809,7 +807,7 @@ fail:
}
/* EA MPF/MUS combo - used in 6th gen games for interactive music (for EA's PathFinder tool) */
VGMSTREAM * init_vgmstream_ea_mpf_mus(STREAMFILE* sf) {
VGMSTREAM* init_vgmstream_ea_mpf_mus(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
STREAMFILE* sf_mus = NULL;
segmented_layout_data *data_s = NULL;
@ -843,7 +841,7 @@ VGMSTREAM * init_vgmstream_ea_mpf_mus(STREAMFILE* sf) {
sub_version = read_u8(0x05, sf);
if (version < 3 || version > 5) goto fail;
if (version == 5 && sub_version > 2) goto fail; /* newer version using SNR/SNS */
if (version == 5 && sub_version > 3) goto fail;
num_tracks = read_u8(0x0d, sf);
num_sections = read_u8(0x0e, sf);
@ -1102,7 +1100,7 @@ fail:
}
/* EA SCHl with variable header - from EA games (roughly 1997~2010); generated by EA Canada's sx.exe/Sound eXchange */
static VGMSTREAM * parse_schl_block(STREAMFILE* sf, off_t offset, int standalone) {
static VGMSTREAM* parse_schl_block(STREAMFILE* sf, off_t offset, int standalone) {
off_t start_offset, header_offset;
size_t header_size;
uint32_t header_id;
@ -1138,7 +1136,7 @@ fail:
}
/* EA BNK with variable header - from EA games SFXs; also created by sx.exe */
static VGMSTREAM * parse_bnk_header(STREAMFILE* sf, off_t offset, int target_stream, int is_embedded) {
static VGMSTREAM* parse_bnk_header(STREAMFILE* sf, off_t offset, int target_stream, int is_embedded) {
uint32_t i;
uint16_t num_sounds;
off_t header_offset, start_offset, test_offset, table_offset, entry_offset;
@ -1235,8 +1233,8 @@ fail:
}
/* inits VGMSTREAM from a EA header */
static VGMSTREAM * init_vgmstream_ea_variable_header(STREAMFILE* sf, ea_header* ea, off_t start_offset, int bnk_version, int standalone) {
VGMSTREAM * vgmstream = NULL;
static VGMSTREAM* init_vgmstream_ea_variable_header(STREAMFILE* sf, ea_header* ea, off_t start_offset, int bnk_version, int standalone) {
VGMSTREAM* vgmstream = NULL;
int i, ch;
int is_bnk = bnk_version;
@ -1372,10 +1370,12 @@ static VGMSTREAM * init_vgmstream_ea_variable_header(STREAMFILE* sf, ea_header*
break;
#ifdef VGM_USE_FFMPEG
case EA_CODEC2_ATRAC3PLUS: { /* ATRAC3+ */
/* regular ATRAC3plus chunked in SCxx blocks, including RIFF header [Medal of Honor Heroes 2 (PSP)] */
//case EA_CODEC2_ATRAC3: /* works but commented to catch games using it */
case EA_CODEC2_ATRAC3PLUS: { /* ATRAC3plus [Medal of Honor Heroes 2 (PSP)] */
/* data chunked in SCxx blocks, including RIFF header */
if (!is_bnk) {
STREAMFILE* temp_sf = NULL;
/* remove blocks on reads to feed FFmpeg a clean .at3 */
temp_sf = setup_schl_streamfile(sf, ea->codec2, ea->channels, start_offset, 0);
if (!temp_sf) goto fail;

View File

@ -16,6 +16,7 @@ static void block_callback(STREAMFILE *sf, deblock_io_data *data) {
return;
switch(data->cfg.codec) {
case 0x1a: /* ATRAC3 */
case 0x1b: /* ATRAC3plus */
data->data_size = read_32bitLE(data->physical_offset + 0x0c + 0x04 * data->cfg.channels, sf);
data->skip_size = 0x0c + 0x04 * data->cfg.channels + 0x04;

View File

@ -4,43 +4,46 @@
/* SWVR - from EA games, demuxed from .av/trk/mis/etc [Future Cop L.A.P.D. (PS/PC), Freekstyle (PS2/GC), EA Sports Supercross (PS)] */
VGMSTREAM * init_vgmstream_ea_swvr(STREAMFILE *streamFile) {
VGMSTREAM* init_vgmstream_ea_swvr(STREAMFILE* sf) {
VGMSTREAM * vgmstream = NULL;
off_t start_offset;
int loop_flag = 0, channel_count, sample_rate, big_endian;
int loop_flag = 0, channels, sample_rate, big_endian;
coding_t coding;
uint32_t block_id;
int32_t (*read_32bit)(off_t,STREAMFILE*) = NULL;
int16_t (*read_16bit)(off_t,STREAMFILE*) = NULL;
int total_subsongs, target_subsong = streamFile->stream_index;
int total_subsongs, target_subsong = sf->stream_index;
/* checks */
/* .stream: common (found inside files)
* .str: shortened, probably unnecessary */
if (!check_extensions(streamFile,"stream,str"))
if (!check_extensions(sf,"stream,str"))
goto fail;
/* Files have no actual audio headers, so we inspect the first block for known values.
* Freekstyle uses multiblocks/subsongs (though some subsongs may be clones?) */
/* blocks ids are in machine endianness */
if (read_32bitBE(0x00,streamFile) == 0x52565753) { /* "RVWS" (PS1/PS2/PC) */
if (read_u32be(0x00,sf) == get_id32be("RVWS")) { /* PS1/PS2/PC */
big_endian = 0;
read_32bit = read_32bitLE;
read_16bit = read_16bitLE;
start_offset = read_32bit(0x04, streamFile);
start_offset = read_32bit(0x04, sf);
}
else if (read_32bitBE(0x00,streamFile) == 0x53575652) { /* "SWVR" (GC) */
else if (read_u32be(0x00,sf) == get_id32be("SWVR")) { /* GC */
big_endian = 1;
read_32bit = read_32bitBE;
read_16bit = read_16bitBE;
start_offset = read_32bit(0x04, streamFile);
start_offset = read_32bit(0x04, sf);
}
else if (read_32bitBE(0x00,streamFile) == 0x4D474156) { /* "MGAV", Freekstyle (PS2) raw movies */
else if (read_u32be(0x00,sf) == get_id32be("MGAV")) { /* Freekstyle (PS2) raw movies */
big_endian = 0;
read_32bit = read_32bitLE;
read_16bit = read_16bitLE;
start_offset = 0x00;
}
else if (read_32bitBE(0x00,streamFile) == 0x4453504D) { /* "DSPM", Freekstyle (GC) raw movies */
else if (read_u32be(0x00,sf) == get_id32be("DSPM")) { /* Freekstyle (GC) raw movies */
big_endian = 1;
read_32bit = read_32bitBE;
read_16bit = read_16bitBE;
@ -50,64 +53,81 @@ VGMSTREAM * init_vgmstream_ea_swvr(STREAMFILE *streamFile) {
goto fail;
}
if (read_32bit(start_offset+0x00, streamFile) == 0x50414444) /* "PADD" (Freekstyle) */
start_offset += read_32bit(start_offset+0x04, streamFile);
else if (read_32bit(start_offset+0x10, streamFile) == 0x53484452) /* "SHDR" (Future Cop PC) */
start_offset += read_32bit(start_offset+0x04, streamFile);
if (read_32bit(start_offset+0x00, sf) == get_id32be("PADD")) /* Freekstyle */
start_offset += read_32bit(start_offset+0x04, sf);
if (read_32bit(start_offset+0x00, streamFile) == 0x46494C4C) /* "FILL" (Freekstyle) */
start_offset += read_32bit(start_offset+0x04, streamFile);
if (read_32bit(start_offset+0x00, sf) == get_id32be("FILL")) /* Freekstyle */
start_offset += read_32bit(start_offset+0x04, sf);
total_subsongs = 1;
block_id = read_32bit(start_offset, streamFile);
block_id = read_32bit(start_offset, sf);
/* value after block id (usually at 0x38) is number of blocks of 0x6000 (results in file size, including FILLs) */
/* files are basically headerless so we inspect the first block
* Freekstyle uses multiblocks/subsongs (though some subsongs may be clones?) */
/* intended sample rate for PSX music (verified in emus) should be 14260, but is found in ELF as pitch value
* (ex. Nascar Rumble 0x052C in SLUS_010.68 at 0x000143BC): 0x052C * 44100 / 4096 ~= 14254.98046875hz
* Future Cop PSX pitch looks similar (comparing vs recordings). */
switch(block_id) {
case 0x5641474D: /* "VAGM" */
case 0x5641474D: /* "VAGM" (stereo music) */
coding = coding_PSX;
if (read_16bit(start_offset+0x1a, streamFile) == 0x0024) {
total_subsongs = read_32bit(start_offset+0x0c, streamFile)+1;
sample_rate = 22050;
if (read_16bit(start_offset+0x1a, sf) == 0x0024) {
total_subsongs = read_32bit(start_offset+0x0c, sf)+1;
sample_rate = 22050; /* Freekstyle (PS2) */
}
else {
sample_rate = 14008;
sample_rate = 1324 * 44100 / 4096; /* ~14254 [Future Cop (PS1), Nascar Rumble (PS1), EA Sports Motocross (PS1)] */
}
channel_count = 2;
channels = 2;
break;
case 0x56414742: /* "VAGB" */
case 0x56414742: /* "VAGB" (mono sfx/voices)*/
coding = coding_PSX;
if (read_16bit(start_offset+0x1a, streamFile) == 0x6400) {
sample_rate = 22050;
if (read_16bit(start_offset+0x1a, sf) == 0x6400) {
sample_rate = 22050; /* Freekstyle (PS2) */
}
else {
sample_rate = 14008;
/* approximate as pitches vary per file (ex. Nascar Rumble: engine=3779, heli=22050, commentary=11050) */
sample_rate = 1080 * 44100 / 4096; /* ~11627 [EA Sports Motocross (PS1)] */
}
channel_count = 1;
channels = 1;
break;
case 0x4453504D: /* "DSPM" */
case 0x4453504D: /* "DSPM" (stereo music) */
coding = coding_NGC_DSP;
total_subsongs = read_32bit(start_offset+0x0c, streamFile)+1;
sample_rate = 22050;
channel_count = 2;
total_subsongs = read_32bit(start_offset+0x0c, sf)+1;
sample_rate = 22050; /* Freekstyle (GC) */
channels = 2;
break;
case 0x44535042: /* "DSPB" */
case 0x44535042: /* "DSPB" (mono voices/sfx) */
coding = coding_NGC_DSP;
channel_count = 1;
sample_rate = 22050;
channels = 1;
sample_rate = 22050; /* Freekstyle (GC) */
break;
case 0x4D534943: /* "MSIC" */
case 0x4D534943: /* "MSIC" (stereo music) */
coding = coding_PCM8_U_int;
channel_count = 2;
sample_rate = 14008;
channels = 2;
sample_rate = 14291; /* assumed, by comparing vs PSX output [Future Cop (PC)] */
break;
case 0x53484F43: /* "SHOC" (a generic block but hopefully has PC sounds) */
if (read_32bit(start_offset+0x10, streamFile) == 0x53484F43) { /* SHDR */
coding = coding_PCM8_U_int; //todo there are other codecs
channel_count = 1;
sample_rate = 14008;
if (read_32bit(start_offset+0x10, sf) == get_id32be("SHDR")) { /* Future Cop (PC) */
/* there is a mini header? after SHDR
* 0x00: 5
* 0x04: "snds"
* 0x08: channels?
* 0x0c: data size without blocks/padding
* 0x10: null
* 0x14: null
* 0x18: null
* 0x1c: 1
* 0x20: 1
* 0x24: 0x4F430000 */
if (read_32bit(start_offset+0x18, sf) != get_id32be("snds"))
goto fail;
coding = coding_PCM8_U_int;
channels = 1;
sample_rate = 16000; /* assumed */
}
else {
//todo
/* The Lord of the Rings - The Return of the King (PC) uses IMA for sfx (in non-RVWS chunks)
* and some unknown codec for streams (mixed with strings and cutscene(?) commands) */
goto fail;
}
break;
@ -119,25 +139,25 @@ VGMSTREAM * init_vgmstream_ea_swvr(STREAMFILE *streamFile) {
if (target_subsong == 0) target_subsong = 1;
if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail;
loop_flag = 0;//(channel_count > 1); /* some Future Cop LAPD tracks repeat but other games have fadeouts */
loop_flag = 0;//(channels > 1); /* some Future Cop LAPD tracks repeat but other games have fadeouts */
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_EA_SWVR;
vgmstream->sample_rate = sample_rate;
vgmstream->codec_endian = big_endian;
vgmstream->num_streams = total_subsongs;
vgmstream->stream_size = get_streamfile_size(streamFile) / total_subsongs; /* approx... */
vgmstream->stream_size = get_streamfile_size(sf) / total_subsongs; /* approx... */
vgmstream->coding_type = coding;
vgmstream->layout_type = layout_blocked_ea_swvr;
/* DSP coefs are loaded per block */
/* some files (voices etc) decode with pops but seems a mastering problem */
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
if (!vgmstream_open_stream(vgmstream,sf,start_offset))
goto fail;
/* calc num_samples manually */
@ -155,7 +175,7 @@ VGMSTREAM * init_vgmstream_ea_swvr(STREAMFILE *streamFile) {
}
vgmstream->num_samples += num_samples;
}
while (vgmstream->next_block_offset < get_streamfile_size(streamFile));
while (vgmstream->next_block_offset < get_streamfile_size(sf));
block_update(start_offset, vgmstream);
}

View File

@ -8,7 +8,7 @@ static int find_meta_loops(ffmpeg_codec_data* data, int32_t* p_loop_start, int32
/* parses any format supported by FFmpeg and not handled elsewhere:
* - MP3 (.mp3, .mus): Marc Ecko's Getting Up (PC)
* - MPC (.mpc): Moonshine Runners (PC), Asphalt 7 (PC)
* - MPC (.mpc, mp+): Moonshine Runners (PC), Asphalt 7 (PC)
* - FLAC (.flac): Warcraft 3 Reforged (PC), Call of Duty: Ghosts (PC)
* - DUCK (.wav): Sonic Jam (SAT), Virtua Fighter 2 (SAT)
* - ALAC/AAC (.caf): Chrono Trigger (iOS)
@ -24,7 +24,7 @@ VGMSTREAM* init_vgmstream_ffmpeg(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
ffmpeg_codec_data* data = NULL;
int loop_flag = 0;
int32_t loop_start = 0, loop_end = 0, num_samples = 0;
int32_t loop_start = 0, loop_end = 0, num_samples = 0, encoder_delay = 0;
int total_subsongs, target_subsong = sf->stream_index;
/* no checks */
@ -66,6 +66,11 @@ VGMSTREAM* init_vgmstream_ffmpeg(STREAMFILE* sf) {
/* hack for AAC files (will return 0 samples if not an actual file) */
if (!num_samples && check_extensions(sf, "aac,laac")) {
num_samples = aac_get_samples(sf, 0x00, get_streamfile_size(sf));
if (num_samples > 0) {
/* FFmpeg seeks to 0 eats first frame for whatever reason */
ffmpeg_set_force_seek(data);
}
}
#ifdef VGM_USE_MPEG
@ -76,10 +81,17 @@ VGMSTREAM* init_vgmstream_ffmpeg(STREAMFILE* sf) {
}
#endif
/* hack for MPC, that seeks/resets incorrectly due to seek table shenanigans */
if (read_u32be(0x00, sf) == 0x4D502B07 || /* "MP+\7" (Musepack V7) */
read_u32be(0x00, sf) == 0x4D50434B) { /* "MPCK" (Musepack V8) */
/* hack for MPC */
if (is_id32be(0x00, sf, "MP+\x07") || /* Musepack V7 */
is_id32be(0x00, sf, "MP+\x17") || /* Musepack V7 with flag (seen in FFmpeg) */
is_id32be(0x00, sf, "MPCK")) { /* Musepack V8 */
/* FFmpeg seeks/resets incorrectly due to MPC seek table shenanigans */
ffmpeg_set_force_seek(data);
/* FFmpeg gets this wrong as usual (specially V8 samples) */
mpc_get_samples(sf, 0x00, &num_samples, &encoder_delay);
ffmpeg_set_skip_samples(data, encoder_delay);
}
/* default but often inaccurate when calculated using bitrate (wrong for VBR) */
@ -91,7 +103,7 @@ VGMSTREAM* init_vgmstream_ffmpeg(STREAMFILE* sf) {
/* build VGMSTREAM */
vgmstream = allocate_vgmstream(data->channels, loop_flag);
if (!vgmstream) goto fail;
vgmstream->sample_rate = data->sampleRate;
vgmstream->meta_type = meta_FFMPEG;
vgmstream->coding_type = coding_FFmpeg;
@ -104,14 +116,13 @@ VGMSTREAM* init_vgmstream_ffmpeg(STREAMFILE* sf) {
vgmstream->channel_layout = ffmpeg_get_channel_layout(vgmstream->codec_data);
return vgmstream;
fail:
free_ffmpeg(data);
if (vgmstream) {
vgmstream->codec_data = NULL;
close_vgmstream(vgmstream);
}
return NULL;
}

View File

@ -11,7 +11,7 @@ typedef struct {
/**
* List of known keys, extracted from the game files (mostly found in 2ch.net).
* List of known keys, extracted from the game files (several found in 2ch.net, others from data analisys).
* CRI's tools expect an unsigned 64 bit number string, but keys are commonly found online in hex form.
* Keys only use 56 bits though, so the upper 8 bits can be ignored.
*
@ -401,6 +401,12 @@ static const hcakey_info hcakey_list[] = {
/* Mushoku Tensei: Game ni Nattemo Honki Dasu (Android) */
{12281329554827291428u}, // AA700C292CFCAB24
/* Dragalia Lost (iOS/Android) */
{2967411924141}, // 000002B2E7889CAD
/* maimai DX Splash (AC) */
{9170825592834449000}, // 7F4551499DF55E68
/* D4DJ Groovy Mix (Android) [base files] */
{393410674916959300}, // 0575ACECA945A444
/* D4DJ Groovy Mix (Android) [music_* files, per-song later mixed with subkey] */
@ -627,9 +633,6 @@ static const hcakey_info hcakey_list[] = {
{0xb96786621e27daf3},
{0x1111d6c10e509824},
/* Dragalia Lost (iOS/Android) */
{2967411924141, subkeys_dgl, sizeof(subkeys_dgl) / sizeof(subkeys_dgl[0]) }, // 000002B2E7889CAD
};
#endif/*_HCA_KEYS_H_*/

File diff suppressed because it is too large Load Diff

View File

@ -42,15 +42,16 @@ VGMSTREAM* init_vgmstream_naac(STREAMFILE* sf) {
#ifdef VGM_USE_FFMPEG
{
vgmstream->codec_data = init_ffmpeg_offset(sf, start_offset, data_size);
vgmstream->codec_data = init_ffmpeg_aac(sf, start_offset, data_size);
if (!vgmstream->codec_data) goto fail;
vgmstream->coding_type = coding_FFmpeg;
vgmstream->layout_type = layout_none;
/* observed default, some files start without silence though seems correct when loop_start=0 */
ffmpeg_set_skip_samples(vgmstream->codec_data, 1024); /* raw AAC doesn't set this */
vgmstream->num_samples -= 1024; /* may end with 1024 of silence? */
vgmstream->num_samples -= 1024;
vgmstream->loop_end_sample -= 1024;
/* for some reason last frame is ignored/bugged in various decoders (gives EOF errors) */
}
#else
goto fail;

View File

@ -4,7 +4,7 @@
/* also see init_vgmstream_dsp_sps_n1 and init_vgmstream_opus_sps_n1 */
/* Nippon Ichi SPS wrapper [ClaDun (PSP)] */
/* Nippon Ichi SPS wrapper [ClaDun (PSP), Legasista (PS3)] */
VGMSTREAM* init_vgmstream_sps_n1(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
STREAMFILE* temp_sf = NULL;
@ -14,15 +14,24 @@ VGMSTREAM* init_vgmstream_sps_n1(STREAMFILE* sf) {
VGMSTREAM* (*init_vgmstream_subfile)(STREAMFILE*) = NULL;
const char* extension;
uint32_t (*read_u32)(off_t,STREAMFILE*);
uint16_t (*read_u16)(off_t,STREAMFILE*);
/* checks */
if (!check_extensions(sf,"sps"))
goto fail;
type = read_u32le(0x00,sf);
subfile_size = read_u32le(0x04,sf);
sample_rate = read_u16le(0x08,sf);
if (guess_endianness32bit(0x00, sf)) { /* PS3 */
read_u32 = read_u32be;
read_u16 = read_u16be;
}
else {
read_u32 = read_u32le;
read_u16 = read_u16le;
}
type = read_u32(0x00,sf);
subfile_size = read_u32(0x04,sf);
sample_rate = read_u16(0x08,sf);
/* 0x0a: flag? (stereo?) */
/* 0x0b: flag? */
/* 0x0c: num_samples */

View File

@ -42,14 +42,14 @@ VGMSTREAM* init_vgmstream_strm_abylight(STREAMFILE* sf) {
#ifdef VGM_USE_FFMPEG
{
vgmstream->codec_data = init_ffmpeg_offset(sf, start_offset, data_size);
vgmstream->codec_data = init_ffmpeg_aac(sf, start_offset, data_size);
if (!vgmstream->codec_data) goto fail;
vgmstream->coding_type = coding_FFmpeg;
vgmstream->layout_type = layout_none;
/* apparently none, or maybe ~600 */
//ffmpeg_set_skip_samples(ffmpeg_data, 1024);
//vgmstream->num_samples -= 1024;
/* assumed, maybe a bit more */
ffmpeg_set_skip_samples(vgmstream->codec_data, 1024);
vgmstream->num_samples -= 1024;
}
#else
goto fail;

View File

@ -468,14 +468,18 @@ VGMSTREAM* init_vgmstream_txth(STREAMFILE* sf) {
case coding_FFmpeg: {
ffmpeg_codec_data *ffmpeg_data = NULL;
if (txth.codec == FFMPEG || txth.codec == AC3 || txth.codec == AAC) {
if (txth.codec == FFMPEG || txth.codec == AC3) {
/* default FFmpeg */
ffmpeg_data = init_ffmpeg_offset(txth.sf_body, txth.start_offset,txth.data_size);
if ( !ffmpeg_data ) goto fail;
ffmpeg_data = init_ffmpeg_offset(txth.sf_body, txth.start_offset, txth.data_size);
if (!ffmpeg_data) goto fail;
if (vgmstream->num_samples == 0)
vgmstream->num_samples = ffmpeg_data->totalSamples; /* sometimes works */
}
else if (txth.codec == AAC) {
ffmpeg_data = init_ffmpeg_aac(txth.sf_body, txth.start_offset, txth.data_size);
if (!ffmpeg_data) goto fail;
}
else {
/* fake header FFmpeg */
uint8_t buf[0x100];

View File

@ -1,10 +1,11 @@
#include "meta.h"
#include "../coding/coding.h"
/* VXN - from Gameloft mobile games */
VGMSTREAM* init_vgmstream_vxn(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
int loop_flag = 0, channel_count, codec, sample_rate, block_align, bits, num_samples;
int loop_flag = 0, channels, codec, sample_rate, block_align, bits, num_samples, encoder_delay;
off_t start_offset, stream_offset, chunk_offset, first_offset = 0x00;
size_t stream_size;
int total_subsongs, target_subsong = sf->stream_index;
@ -13,22 +14,32 @@ VGMSTREAM* init_vgmstream_vxn(STREAMFILE* sf) {
if (!check_extensions(sf,"vxn"))
goto fail;
if (read_u32be(0x00,sf) != 0x566F784E) /* "VoxN" */
if (!is_id32be(0x00,sf, "VoxN"))
goto fail;
/* 0x04: chunk size */
/* 0x08: ASCII version? ("0.0.1") */
if (read_u32le(0x10,sf) != get_streamfile_size(sf))
goto fail;
/* 0x14: first MPC data start */
/* header is RIFF-like with many custom chunks */
if (!find_chunk_le(sf, 0x41666D74,first_offset,0, &chunk_offset,NULL)) /* "Afmt" */
goto fail;
codec = read_u16le(chunk_offset+0x00, sf);
channel_count = read_u16le(chunk_offset+0x02, sf);
channels = read_u16le(chunk_offset+0x02, sf);
sample_rate = read_u32le(chunk_offset+0x04, sf);
block_align = read_u16le(chunk_offset+0x08, sf);
bits = read_16bitLE(chunk_offset+0x0a, sf);
bits = read_s16le(chunk_offset+0x0a, sf);
/* files are divided into segment subsongs, often a leadout and loop in that order
* (the "Plst" and "Rule" chunks may have order info) */
/* files are divided into segment subsongs, often a leadout and loop in that order,
* but may also have +15 [Asphalt 9]. Various chunks seem to define how they are used:
* - Rule: optional, not related to number of playlists
* - Plst: sets N playlists + some flags?
* - Stat: N entries (1 per playlist), start? + name (null-terminated, size 0x0C) + sample values?
* - Trsn: optional, transitions for playlists?
* - Grps: N entries (1 per playlist), 0x18 per entry, unknown
* - Gprs: playlist segments, 0x20 per entry, playlist id + segment + null + segment? + flags (0/1/-1)
*/
if (!find_chunk_le(sf, 0x5365676D,first_offset,0, &chunk_offset,NULL)) /* "Segm" */
goto fail;
total_subsongs = read_u32le(chunk_offset+0x00, sf);
@ -45,7 +56,7 @@ VGMSTREAM* init_vgmstream_vxn(STREAMFILE* sf) {
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail;
vgmstream->sample_rate = sample_rate;
@ -85,16 +96,24 @@ VGMSTREAM* init_vgmstream_vxn(STREAMFILE* sf) {
break;
#ifdef VGM_USE_FFMPEG
case 0x0800: /* Musepack (ex. Asphalt Xtreme) */
case 0x0800: /* Musepack (ex. Asphalt Xtreme, Asphalt 9) */
if (bits != -1) goto fail;
vgmstream->codec_data = init_ffmpeg_offset(sf, start_offset,stream_size);
vgmstream->codec_data = init_ffmpeg_offset(sf, start_offset, stream_size);
if (!vgmstream->codec_data) goto fail;
vgmstream->coding_type = coding_FFmpeg;
vgmstream->layout_type = layout_none;
/* unlike standard .mpc, .vxn has no seek table so no need to fix */
//ffmpeg_set_force_seek(vgmstream->codec_data);
encoder_delay = 0;
mpc_get_samples(sf, start_offset, NULL, &encoder_delay);
/* num_samples matches MPC samples */
/* FFmpeg doesn't set encoder delay */
ffmpeg_set_skip_samples(vgmstream->codec_data, encoder_delay);
break;
#endif

View File

@ -109,6 +109,10 @@ VGMSTREAM* init_vgmstream_wwise(STREAMFILE* sf) {
}
vgmstream->num_samples = pcm_bytes_to_samples(ww.data_size, ww.channels, ww.bits_per_sample);
/* truncated .bnk RIFFs that only have header and no data is possible [Metal Gear Solid V (PC)] */
if (ww.truncated && !vgmstream->num_samples)
vgmstream->num_samples = 1; /* force something to avoid broken subsongs */
break;
case IMA: /* common */