Merge branch 'master' of https://github.com/kode54/vgmstream into test

This commit is contained in:
bnnm 2019-01-02 11:10:14 +01:00
commit 7211e0e0ec
4 changed files with 136 additions and 64 deletions

View File

@ -365,20 +365,23 @@ fail:
/* EA MAP/MUS combo - used in some old games for interactive music info */
VGMSTREAM * init_vgmstream_ea_map_mus(STREAMFILE *streamFile) {
uint8_t num_sounds, num_userdata;
uint8_t version, num_sounds, num_userdata, userdata_size;
off_t section_offset, schl_offset;
STREAMFILE *musFile = NULL;
VGMSTREAM *vgmstream = NULL;
int target_stream = streamFile->stream_index;
/* check extension */
if (!check_extensions(streamFile, "map,lin"))
if (!check_extensions(streamFile, "map,lin,mpf"))
goto fail;
/* always big endian */
if (read_32bitBE(0x00, streamFile) != 0x50464478) /* "PFDx" */
goto fail;
version = read_8bit(0x04, streamFile);
if (version > 1) goto fail;
musFile = open_streamfile_by_ext(streamFile, "mus");
if (!musFile) goto fail;
@ -392,6 +395,7 @@ VGMSTREAM * init_vgmstream_ea_map_mus(STREAMFILE *streamFile) {
* 0x0c: section 1 start
*/
num_sounds = read_8bit(0x06, streamFile);
userdata_size = read_8bit(0x07, streamFile);
num_userdata = read_8bit(0x0b, streamFile);
section_offset = 0x0c;
@ -399,7 +403,7 @@ VGMSTREAM * init_vgmstream_ea_map_mus(STREAMFILE *streamFile) {
section_offset += num_sounds * 0x1c;
/* section 2: userdata, specific to game and track */
section_offset += num_userdata * 0x10;
section_offset += num_userdata * userdata_size;
if (target_stream == 0) target_stream = 1;
if (target_stream < 0 || num_sounds == 0 || target_stream > num_sounds)
@ -425,14 +429,15 @@ fail:
/* EA MPF/MUS combo - used in newer 6th gen games for storing music */
VGMSTREAM * init_vgmstream_ea_mpf_mus(STREAMFILE *streamFile) {
off_t section_offset, entry_offset, subentry_num, eof_offset, schl_offset;
off_t section_offset, entry_offset, subentry_num, eof_offset, off_mult, schl_offset;
size_t sec2_size;
uint16_t sec1_num;
uint8_t version, sub_version, sec2_num;
uint8_t version, sub_version, sec2_num, sec3_num, sec4_num;
int32_t(*read_32bit)(off_t, STREAMFILE*);
int16_t(*read_16bit)(off_t, STREAMFILE*);
STREAMFILE *musFile = NULL;
VGMSTREAM *vgmstream = NULL;
int target_stream = streamFile->stream_index, total_streams;
int target_stream = streamFile->stream_index, total_streams, big_endian;
/* check extension */
if (!check_extensions(streamFile, "mpf"))
@ -442,23 +447,77 @@ VGMSTREAM * init_vgmstream_ea_mpf_mus(STREAMFILE *streamFile) {
if (read_32bitBE(0x00, streamFile) == 0x50464478) { /* "PFDx" */
read_32bit = read_32bitBE;
read_16bit = read_16bitBE;
big_endian = 1;
} else if (read_32bitBE(0x00, streamFile) == 0x78444650) { /* "xDFP" */
read_32bit = read_32bitLE;
read_16bit = read_16bitLE;
big_endian = 0;
} else {
goto fail;
}
musFile = open_streamfile_by_ext(streamFile, "mus");
if (!musFile) goto fail;
version = read_8bit(0x04, streamFile);
sub_version = read_8bit(0x05, streamFile);
if (version < 0x04 || version > 0x05) goto fail;
if (version == 0x05 && sub_version > 0x02) goto fail; /* newer version using SNR/SNS */
if (version < 3 || version > 5) goto fail;
if (version == 5 && sub_version > 2) goto fail; /* newer version using SNR/SNS */
if (version == 0x04) {
musFile = open_streamfile_by_ext(streamFile, "mus");
if (!musFile) goto fail;
/* HACK: number of sub-entries is stored in bitstreams that are different in LE and BE */
/* I can't figure it out, so let's just use a workaround for now */
if (version == 3 && sub_version == 1) { /* SSX Tricky /*
/* we need to go through the first two sections to find sound table */
sec1_num = read_16bit(0x12, streamFile);
sec2_size = read_8bit(0x0e, streamFile);
sec2_num = read_8bit(0x0f, streamFile);
sec3_num = read_8bit(0x10, streamFile);
sec4_num = read_8bit(0x11, streamFile);
/* get the last entry offset */
section_offset = 0x24;
entry_offset = read_16bit(section_offset + (sec1_num - 1) * 0x02, streamFile) * 0x04;
subentry_num = read_8bit(entry_offset + 0x0b, streamFile);
section_offset = entry_offset + 0x0c + subentry_num * 0x04;
section_offset += align_size_to_block(sec2_num * sec2_size, 0x04);
section_offset += sec3_num * 0x04;
section_offset += sec4_num * 0x04;
entry_offset = read_32bit(section_offset, streamFile) * 0x04;
section_offset = read_32bit(entry_offset + 0x00, streamFile) * 0x04;
eof_offset = get_streamfile_size(streamFile);
total_streams = (eof_offset - section_offset) / 0x08;
off_mult = 0x04;
} else if (version == 3 && sub_version == 4) { /* Harry Potter and the Chamber of Secrets */
sec1_num = read_16bit(0x12, streamFile);
sec2_size = read_8bit(0x0e, streamFile);
sec2_num = read_8bit(0x0f, streamFile);
sec3_num = read_8bit(0x10, streamFile);
sec4_num = read_8bit(0x11, streamFile);
/* get the last entry offset */
section_offset = 0x24;
entry_offset = read_16bit(section_offset + (sec1_num - 1) * 0x02, streamFile) * 0x04;
if (big_endian) {
subentry_num = (read_32bitBE(entry_offset + 0x04, streamFile) >> 19) & 0xFF;
} else {
subentry_num = (read_32bitBE(entry_offset + 0x04, streamFile) >> 16) & 0xFF;
}
section_offset = entry_offset + 0x0c + subentry_num * 0x04;
section_offset += align_size_to_block(sec2_num * sec2_size, 0x04);
section_offset += sec3_num * 0x04;
section_offset += sec4_num * 0x04;
entry_offset = read_32bit(section_offset, streamFile) * 0x04;
section_offset = read_32bit(entry_offset + 0x00, streamFile) * 0x04;
eof_offset = read_32bit(entry_offset + 0x04, streamFile) * 0x04;
total_streams = (eof_offset - section_offset) / 0x08;
off_mult = 0x04;
} else if (version == 4) { /* SSX 3, Need for Speed: Underground 2 /*
/* we need to go through the first two sections to find sound table */
sec1_num = read_16bit(0x12, streamFile);
sec2_num = read_8bit(0x0f, streamFile);
@ -466,10 +525,7 @@ VGMSTREAM * init_vgmstream_ea_mpf_mus(STREAMFILE *streamFile) {
/* get the last entry offset */
section_offset = 0x20;
entry_offset = read_16bit(section_offset + (sec1_num - 1) * 0x02, streamFile) * 0x04;
/* HACK: there's some weird bitstream here that's stored differently in LE and BE */
/* I can't figure it out, so let's just use a workaround for now */
if (read_32bitBE(0x00, streamFile) == 0x50464478) {
if (big_endian) {
subentry_num = (read_32bitBE(entry_offset + 0x04, streamFile) >> 15) & 0xFF;
} else {
subentry_num = (read_32bitBE(entry_offset + 0x04, streamFile) >> 20) & 0xFF;
@ -477,30 +533,33 @@ VGMSTREAM * init_vgmstream_ea_mpf_mus(STREAMFILE *streamFile) {
section_offset = entry_offset + 0x10 + subentry_num * 0x04;
entry_offset = read_16bit(section_offset + (sec2_num - 1) * 0x02, streamFile) * 0x04;
/* more weird stuff */
if (read_32bitBE(0x00, streamFile) == 0x50464478) {
if (big_endian) {
subentry_num = (read_32bitBE(entry_offset + 0x0c, streamFile) >> 10) & 0xFF;
} else {
subentry_num = (read_32bitBE(entry_offset + 0x0c, streamFile) >> 8) & 0xFF;
}
section_offset = entry_offset + 0x10 + subentry_num * 0x10;
entry_offset = read_32bit(section_offset, streamFile) * 0x04;
section_offset = read_32bit(entry_offset + 0x00, streamFile) * 0x04;
eof_offset = read_32bit(entry_offset + 0x04, streamFile) * 0x04;
total_streams = (eof_offset - section_offset) / 0x08;
} else if (version == 0x05) {
off_mult = 0x80;
} else if (version == 5) { /* Need for Speed: Most Wanted, Need for Speed: Carbon */
section_offset = read_32bit(0x34, streamFile);
eof_offset = read_32bit(0x38, streamFile);
total_streams = (eof_offset - section_offset) / 0x08;
off_mult = 0x80;
} else {
goto fail;
}
if (target_stream == 0) target_stream = 1;
if (target_stream < 0 || total_streams == 0 || target_stream > total_streams)
goto fail;
schl_offset = read_32bit(section_offset + (target_stream - 1) * 0x08 + 0x00, streamFile) * 0x80;
schl_offset = read_32bit(section_offset + (target_stream - 1) * 0x08 + 0x00, streamFile) * off_mult;
if (read_32bitBE(schl_offset, musFile) != EA_BLOCKID_HEADER)
goto fail;

View File

@ -4,43 +4,46 @@
/* AWB subkey tables */
static const uint16_t subkeys_dgl[] = { /* Dragalia Lost (Cygames) [iOS/Android] */
0x0165,0x0192,0x01E8,0x0240,0x026B,0x02B8,0x0348,0x055E,0x0595,0x05DC,0x0606,0x0636,0x0690,0x06A4,0x06B3,0x0760,
0x076E,0x076F,0x07A6,0x07AA,0x07B4,0x080D,0x082B,0x084C,0x0859,0x085B,0x0864,0x0865,0x0873,0x088A,0x089B,0x08A5,
0x08A7,0x08C3,0x08C6,0x08D5,0x08D8,0x08E0,0x08E8,0x08EF,0x08F0,0x0908,0x090B,0x0916,0x0919,0x0923,0x0926,0x0929,
0x092C,0x092D,0x092F,0x0942,0x0944,0x094C,0x094E,0x0957,0x095F,0x0963,0x0964,0x096C,0x097B,0x097D,0x0988,0x099E,
0x09AE,0x09C1,0x09C2,0x09C5,0x09C8,0x09D7,0x09FF,0x0A00,0x0A02,0x0A12,0x0A16,0x0A19,0x0A25,0x0A2A,0x0A2F,0x0A30,
0x0A31,0x0A3F,0x0A41,0x0A53,0x0A63,0x0A65,0x0A6D,0x0A73,0x0A77,0x0A99,0x0A9A,0x0AA5,0x0AB8,0x0AC2,0x0AC5,0x0ACC,
0x0AE0,0x0AE3,0x0AEC,0x0B09,0x0B0C,0x0B5B,0x0B6F,0x0B7C,0x0B8D,0x0BA1,0x0BB0,0x0BBE,0x0BC9,0x0BDE,0x0BEF,0x0C04,
0x0C0F,0x0C30,0x0C8B,0x0C9A,0x0C9F,0x0CA9,0x0CB9,0x0D71,0x0DB0,0x0DCF,0x0DD4,0x0DE6,0x0E1C,0x0E66,0x0E9D,0x0EAF,
0x0EBB,0x0FDA,0x102F,0x103A,0x1074,0x10BF,0x10C7,0x1107,0x113A,0x116F,0x11A6,0x11FB,0x130E,0x1335,0x135B,0x13C0,
0x1474,0x1538,0x1585,0x15AD,0x15E1,0x1748,0x1892,0x18A4,0x1944,0x19F3,0x1A47,0x1A5B,0x1A89,0x1AAC,0x1C31,0x1C3B,
0x1C7C,0x1C7E,0x1D01,0x1D0C,0x1D5A,0x1E88,0x1F0A,0x1FC2,0x2000,0x2007,0x208C,0x20E9,0x2160,0x216E,0x21CA,0x221E,
0x2265,0x2275,0x2277,0x22C4,0x22FA,0x2379,0x23C9,0x23D8,0x2415,0x243C,0x245A,0x24AD,0x24CD,0x2540,0x2632,0x264C,
0x269B,0x26B5,0x26C5,0x26FC,0x2701,0x274D,0x2777,0x27EE,0x284B,0x288C,0x28A9,0x28B6,0x292B,0x2930,0x29B0,0x29D9,
0x2A0A,0x2A47,0x2A55,0x2A5D,0x2ADB,0x2AE7,0x2D08,0x2DB0,0x2DB7,0x2DC3,0x2E6E,0x2E75,0x2E9E,0x2EB6,0x2ED8,0x2F64,
0x2F66,0x2F72,0x30BB,0x30CA,0x30E6,0x3160,0x3218,0x32E8,0x333F,0x33BE,0x355A,0x357D,0x35DD,0x3619,0x36AA,0x3738,
0x3752,0x3804,0x380C,0x3920,0x39DB,0x3C7B,0x3CA3,0x3D50,0x3EB2,0x3EF2,0x3F42,0x3F79,0x4000,0x403D,0x40BF,0x40DE,
0x413E,0x414F,0x41A3,0x42EA,0x434A,0x43D3,0x43E9,0x4411,0x4541,0x4751,0x4793,0x487A,0x48D7,0x49B4,0x49E3,0x4B0E,
0x4B8D,0x4C49,0x4C72,0x4D44,0x4D86,0x4DEA,0x4DF5,0x4E40,0x4F60,0x4FF2,0x5220,0x5493,0x54CE,0x552C,0x559B,0x5639,
0x567C,0x56A1,0x56EE,0x5794,0x582E,0x5846,0x586A,0x58B1,0x58C3,0x59A5,0x59EF,0x5A86,0x5B49,0x5B5C,0x5B90,0x5BCF,
0x5C38,0x5C75,0x5C83,0x5D61,0x5DE0,0x5E47,0x5E57,0x6000,0x601F,0x6071,0x6104,0x6188,0x61B2,0x61EB,0x6226,0x627D,
0x62F9,0x63DE,0x645F,0x64D3,0x659D,0x65D3,0x65D4,0x65F2,0x6631,0x6914,0x6990,0x6993,0x6A52,0x6A85,0x6B16,0x6BF6,
0x6CD6,0x6CE3,0x6CF9,0x6CFA,0x6D0E,0x6D16,0x6D3E,0x6D80,0x6DCF,0x6E73,0x6EC5,0x6F14,0x6FD0,0x7033,0x704C,0x7098,
0x7242,0x7278,0x7319,0x7427,0x7432,0x747F,0x7484,0x749D,0x74D7,0x74D8,0x756A,0x7576,0x7588,0x75A9,0x764D,0x773C,
0x7895,0x78B0,0x78F3,0x7976,0x798F,0x79F9,0x7A1D,0x7A24,0x7A47,0x7B64,0x7BBC,0x7C2E,0x7CBA,0x7D0D,0x7D12,0x7E66,
0x7EB5,0x7EBA,0x7EC5,0x7F1B,0x7F26,0x7F5F,0x7FC1,0x7FCE,0x7FFC,0x8000,0x8075,0x80B2,0x80FF,0x81C8,0x826C,0x8274,
0x82B5,0x8412,0x8458,0x8467,0x8533,0x8577,0x85FF,0x8658,0x86E3,0x86E6,0x878E,0x885E,0x8A7E,0x8B1F,0x8B25,0x8B33,
0x8B4D,0x8B80,0x8BFF,0x8C38,0x8D46,0x8D8B,0x8E10,0x8E79,0x8FF1,0x9000,0x9029,0x9082,0x924A,0x92F8,0x9342,0x940C,
0x94B9,0x9580,0x95ED,0x9630,0x97D1,0x97FC,0x9810,0x9825,0x9861,0x98FB,0x990E,0x9970,0x9A37,0x9B36,0x9B67,0x9FA3,
0xA000,0xA0A3,0xA1C6,0xA27A,0xA2FB,0xA3AB,0xA3C2,0xA4E1,0xA548,0xA553,0xA585,0xA6A7,0xA71C,0xA723,0xA7D6,0xA894,
0xA8BF,0xA8E0,0xA90A,0xAA3A,0xAA57,0xAADF,0xAAF4,0xAB0B,0xABF3,0xAC0C,0xAC55,0xAD00,0xADC4,0xADF1,0xAE02,0xAE16,
0xAE6A,0xAEA7,0xAEB6,0xB073,0xB122,0xB14B,0xB175,0xB177,0xB25D,0xB262,0xB332,0xB378,0xB400,0xB52E,0xB54B,0xB592,
0xB59C,0xB5AD,0xB5CE,0xB5D5,0xB613,0xB65D,0xB79F,0xB89D,0xB907,0xBC78,0xBCCC,0xBDBF,0xBE21,0xBF21,0xBF64,0xC13F,
0xC2EA,0xC303,0xC385,0xC3C9,0xC3D8,0xC452,0xC5CB,0xC5EB,0xC655,0xC67B,0xC6D9,0xC728,0xC8A8,0xCAF6,0xCDAC,0xCDF7,
0xD075,0xD163,0xD203,0xD410,0xD49E,0xD718,0xD876,0xD99C,0xDA29,0xDAA7,0xDBA0,0xDC8F,0xDCFA,0xDD3D,0xDD55,0xDE02,
0xDE30,0xE000,0xE02E,0xE073,0xE1C5,0xE1CD,0xE288,0xE3AE,0xE597,0xE5E3,0xE652,0xE775,0xE930,0xE947,0xEC15,0xEC1B,
0xED0A,0xED93,0xED95,0xEDC2,0xEFA6,0xEFB6,0xF049,0xF0C7,0xF107,0xF41F,0xF558,0xF5C8,0xF7DC,0xF7ED,0xF89E,0xF8B2,
0xF9C9,0xFAAA,0xFB77,0xFCAF,0xFD01,0xFD13,0xFD57,0xFD68,0xFDDB,0xFE07,0xFF43,0xFF65,0xFF85,0xFF8B,0xFF9A,0xFFD0,
0x0152,0x0165,0x0192,0x01E8,0x0240,0x026B,0x02B8,0x0348,0x055E,0x0595,0x05DC,0x0606,0x0636,0x0690,0x06A1,0x06A4,
0x06B3,0x0760,0x0767,0x076E,0x076F,0x07A6,0x07AA,0x07B4,0x07CC,0x080D,0x082B,0x084C,0x0859,0x085B,0x0861,0x0864,
0x0865,0x0873,0x088A,0x089B,0x08A5,0x08A7,0x08C3,0x08C6,0x08D5,0x08D8,0x08E0,0x08E8,0x08EF,0x08F0,0x0908,0x090B,
0x0916,0x0919,0x0923,0x0926,0x0929,0x092C,0x092D,0x092F,0x0942,0x0944,0x094C,0x094E,0x0957,0x095F,0x0963,0x0964,
0x096C,0x097B,0x097D,0x0988,0x099E,0x09AE,0x09C1,0x09C2,0x09C5,0x09C8,0x09D7,0x09FF,0x0A00,0x0A02,0x0A12,0x0A16,
0x0A19,0x0A25,0x0A2A,0x0A2F,0x0A30,0x0A31,0x0A3F,0x0A41,0x0A53,0x0A63,0x0A65,0x0A6D,0x0A73,0x0A77,0x0A99,0x0A9A,
0x0AA5,0x0AA8,0x0AB8,0x0AC2,0x0AC5,0x0ACC,0x0AE0,0x0AE3,0x0AEC,0x0B09,0x0B0C,0x0B35,0x0B5B,0x0B6F,0x0B7C,0x0B8D,
0x0BA1,0x0BB0,0x0BBE,0x0BC9,0x0BDE,0x0BEF,0x0C04,0x0C0F,0x0C30,0x0C8B,0x0C9A,0x0C9F,0x0CA9,0x0CB9,0x0D71,0x0DB0,
0x0DCF,0x0DD4,0x0DE6,0x0E1C,0x0E66,0x0E9D,0x0EAF,0x0EBB,0x0FDA,0x102F,0x103A,0x1074,0x10BF,0x10C7,0x1107,0x113A,
0x116F,0x11A6,0x11FB,0x1220,0x130E,0x1335,0x135B,0x13C0,0x1474,0x1538,0x1585,0x15AD,0x15E1,0x1748,0x1892,0x18A4,
0x1944,0x197A,0x19F3,0x1A47,0x1A5B,0x1A89,0x1AAC,0x1C31,0x1C3B,0x1C7C,0x1C7E,0x1D01,0x1D0C,0x1D5A,0x1E1E,0x1E88,
0x1F0A,0x1FC2,0x2000,0x2007,0x208C,0x20E9,0x20EE,0x2160,0x216E,0x21CA,0x221E,0x2265,0x2275,0x2277,0x22C4,0x22FA,
0x2330,0x2379,0x23C9,0x23D8,0x2415,0x243C,0x245A,0x24AD,0x24CD,0x2540,0x2632,0x264C,0x269B,0x26B5,0x26C5,0x26FC,
0x2701,0x274D,0x274E,0x2777,0x27EE,0x284B,0x288C,0x28A9,0x28B6,0x292B,0x2930,0x29B0,0x29B2,0x29D9,0x2A0A,0x2A47,
0x2A55,0x2A5D,0x2ADB,0x2AE7,0x2D08,0x2DB0,0x2DB7,0x2DC3,0x2E6E,0x2E75,0x2E9E,0x2EB6,0x2ED8,0x2F64,0x2F66,0x2F72,
0x30BB,0x30CA,0x30E6,0x3160,0x3218,0x32E8,0x333F,0x338B,0x33BE,0x355A,0x357D,0x35DD,0x3619,0x36AA,0x3738,0x3752,
0x37DE,0x3804,0x380C,0x3920,0x39DB,0x3C7B,0x3CA3,0x3D50,0x3EB2,0x3EF2,0x3F42,0x3F79,0x4000,0x403D,0x40BF,0x40DE,
0x413E,0x414F,0x41A3,0x42EA,0x434A,0x43D3,0x43E9,0x4411,0x4541,0x4751,0x4793,0x47DF,0x4840,0x487A,0x48D7,0x49B4,
0x49E3,0x4B0E,0x4B21,0x4B8D,0x4C49,0x4C72,0x4D44,0x4D86,0x4DEA,0x4DF5,0x4E40,0x4F60,0x4F92,0x4FF2,0x5220,0x5493,
0x54CE,0x552C,0x559B,0x5639,0x567C,0x56A1,0x56EE,0x5794,0x582E,0x5846,0x586A,0x58B1,0x58C3,0x59A5,0x59EF,0x5A86,
0x5B19,0x5B49,0x5B5C,0x5B90,0x5BCF,0x5C38,0x5C75,0x5C83,0x5D61,0x5DE0,0x5E47,0x5E57,0x5ED5,0x6000,0x601F,0x6071,
0x6104,0x6188,0x6191,0x61B2,0x61EB,0x6226,0x627D,0x62F9,0x63DE,0x645F,0x64D3,0x659D,0x65D3,0x65D4,0x65F2,0x6631,
0x6914,0x6990,0x6993,0x6A52,0x6A85,0x6B16,0x6BF6,0x6CD6,0x6CE3,0x6CF9,0x6CFA,0x6D0E,0x6D16,0x6D3E,0x6D80,0x6DCF,
0x6E73,0x6EC5,0x6F14,0x6FD0,0x7033,0x704C,0x7098,0x7242,0x7278,0x7319,0x7427,0x7432,0x747F,0x7484,0x749D,0x74D7,
0x74D8,0x756A,0x7576,0x7588,0x75A9,0x764D,0x773C,0x7766,0x7895,0x78B0,0x78F3,0x7976,0x798F,0x79E7,0x79F9,0x7A1D,
0x7A24,0x7A47,0x7B64,0x7BBC,0x7C2E,0x7CBA,0x7D0D,0x7D12,0x7E66,0x7EB5,0x7EBA,0x7EC5,0x7F1B,0x7F26,0x7F5F,0x7FC1,
0x7FCE,0x7FFC,0x8000,0x8075,0x80B2,0x80FF,0x81C8,0x826C,0x8274,0x82B5,0x8412,0x8458,0x8467,0x8533,0x8577,0x85FF,
0x8658,0x86E3,0x86E6,0x878E,0x885E,0x8A7E,0x8B1F,0x8B25,0x8B33,0x8B4D,0x8B80,0x8BFF,0x8C38,0x8D46,0x8D8B,0x8E10,
0x8E79,0x8F01,0x8FF1,0x9000,0x9029,0x9082,0x924A,0x92F8,0x9342,0x940C,0x94B9,0x9580,0x95ED,0x9630,0x97D1,0x97FC,
0x9810,0x9825,0x9861,0x98FB,0x990E,0x9970,0x9A37,0x9B36,0x9B67,0x9FA3,0x9FF2,0xA000,0xA0A3,0xA1C6,0xA27A,0xA2FB,
0xA3AB,0xA3C2,0xA4E1,0xA548,0xA553,0xA585,0xA6A7,0xA71C,0xA723,0xA77E,0xA7D6,0xA894,0xA8BF,0xA8E0,0xA90A,0xAA3A,
0xAA57,0xAADF,0xAAF4,0xAB0B,0xABF3,0xAC0C,0xAC23,0xAC55,0xAD00,0xADC4,0xADF1,0xAE02,0xAE16,0xAE6A,0xAEA7,0xAEB6,
0xB040,0xB073,0xB122,0xB14B,0xB175,0xB177,0xB25D,0xB262,0xB332,0xB378,0xB400,0xB52E,0xB54B,0xB592,0xB59C,0xB5AD,
0xB5CE,0xB5D3,0xB5D5,0xB613,0xB65D,0xB79F,0xB89D,0xB907,0xBC78,0xBCCC,0xBDBF,0xBE21,0xBF21,0xBF64,0xC13F,0xC2EA,
0xC303,0xC385,0xC3C9,0xC3D8,0xC452,0xC5CB,0xC5EB,0xC655,0xC67B,0xC6D9,0xC728,0xC8A8,0xCAF6,0xCDAC,0xCDF7,0xD075,
0xD163,0xD203,0xD410,0xD49E,0xD718,0xD876,0xD99C,0xDA29,0xDAA7,0xDBA0,0xDC8F,0xDCFA,0xDD3D,0xDD55,0xDE02,0xDE30,
0xE000,0xE02E,0xE073,0xE1C5,0xE1CD,0xE288,0xE3AE,0xE597,0xE5E3,0xE652,0xE775,0xE930,0xE947,0xEC15,0xEC1B,0xED0A,
0xED93,0xED95,0xEDC2,0xEF7F,0xEFA6,0xEFB6,0xF049,0xF0C7,0xF107,0xF41F,0xF558,0xF5C8,0xF7DC,0xF7ED,0xF89E,0xF8B2,
0xF9C9,0xFAAA,0xFB77,0xFCAF,0xFCCA,0xFD01,0xFD13,0xFD57,0xFD68,0xFDDB,0xFE07,0xFF43,0xFF65,0xFF85,0xFF8B,0xFF9A,
0xFFD0,
};
#if 0

View File

@ -480,7 +480,7 @@ static VGMSTREAM * init_vgmstream_ubi_sb_main(ubi_sb_header *sb, STREAMFILE *str
case FMT_XMA1: {
ffmpeg_codec_data *ffmpeg_data;
uint8_t buf[0x100];
uint32_t sec1_num, sec2_num, sec3_num;
uint32_t sec1_num, sec2_num, sec3_num, num_frames, bits_per_frame;
uint8_t flag;
size_t bytes, frame_size, chunk_size, header_size, data_size;
off_t header_offset;
@ -493,12 +493,22 @@ static VGMSTREAM * init_vgmstream_ubi_sb_main(ubi_sb_header *sb, STREAMFILE *str
sec2_num = read_32bitBE(header_offset + 0x24, streamData); /* number of XMA frames */
sec1_num = read_32bitBE(header_offset + 0x28, streamData);
sec3_num = read_32bitBE(header_offset + 0x2c, streamData);
if (flag == 0x04)
sec1_num--;
num_frames = sec2_num;
bits_per_frame = 4;
header_size = 0x30 + sec1_num * 0x04 + align_size_to_bytes(sec2_num / 0x02, 0x04) + sec3_num * 0x08;
if (flag == 0x04) {
sec1_num--;
sec2_num += 4;
} else if (flag == 0x02) {
bits_per_frame = 2;
}
header_size = 0x30;
header_size += sec1_num * 0x04;
header_size += align_size_to_block(sec2_num * bits_per_frame, 32) / 8; /* bitstream with 4 or 2 bits for each frame */
header_size += sec3_num * 0x08;
start_offset += header_size;
data_size = sec2_num * 0x800;
data_size = num_frames * 0x800;
bytes = ffmpeg_make_riff_xma_from_fmt_chunk(buf, 0x100, header_offset, chunk_size, data_size, streamData, 1);

View File

@ -202,7 +202,7 @@ static inline int guess_endianness32bit(off_t offset, STREAMFILE * streamfile) {
return ((uint32_t)read_32bitLE(offset,streamfile) > (uint32_t)read_32bitBE(offset,streamfile)) ? 1 : 0;
}
static inline size_t align_size_to_bytes(size_t value, size_t block_align) {
static inline size_t align_size_to_block(size_t value, size_t block_align) {
size_t extra_size = value % block_align;
if (extra_size == 0) return value;
return (value + block_align - extra_size);