mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-29 19:37:30 +01:00
Parse PS3 .bnk properly and remove ps3_klbs.c [L@ve Once (PS3)]
This commit is contained in:
parent
75fb12eed4
commit
925916690a
@ -951,7 +951,6 @@ static const meta_info meta_info_list[] = {
|
||||
{meta_OTNS_ADP, "Omikron: The Nomad Soul ADP header"},
|
||||
{meta_EB_SFX, "Excitebots .sfx header"},
|
||||
{meta_EB_SF0, "assumed Excitebots .sf0 by extension"},
|
||||
{meta_PS3_KLBS, "klBS Header"},
|
||||
{meta_PS2_MTAF, "Konami MTAF header"},
|
||||
{meta_PS2_VAG1, "Konami VAG1 header"},
|
||||
{meta_PS2_VAG2, "Konami VAG2 header"},
|
||||
|
@ -1138,10 +1138,6 @@
|
||||
RelativePath=".\meta\ps3_ivag.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\ps3_klbs.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\ps3_msf.c"
|
||||
>
|
||||
|
@ -167,7 +167,6 @@
|
||||
<ClCompile Include="meta\ps2_strlr.c" />
|
||||
<ClCompile Include="meta\ps2_wmus.c" />
|
||||
<ClCompile Include="meta\ps3_ivag.c" />
|
||||
<ClCompile Include="meta\ps3_klbs.c" />
|
||||
<ClCompile Include="meta\ps3_past.c" />
|
||||
<ClCompile Include="meta\sgxd.c" />
|
||||
<ClCompile Include="meta\sk_aud.c" />
|
||||
|
@ -1252,9 +1252,6 @@
|
||||
<ClCompile Include="meta\excitebots.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meta\ps3_klbs.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="coding\mtaf_decoder.c">
|
||||
<Filter>coding\Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
@ -1,40 +1,55 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
typedef enum { PSX, PCM16, ATRAC9 } bnk_codec;
|
||||
|
||||
/* BNK - Sony's Scream Tool bank format [Puyo Puyo Tetris (PS4), NekoBuro: Cats Block (Vita)] */
|
||||
VGMSTREAM * init_vgmstream_bnk_sony(STREAMFILE *streamFile) {
|
||||
#if 1
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
off_t start_offset, stream_offset, name_offset = 0;
|
||||
size_t stream_size;
|
||||
size_t stream_size, interleave = 0;
|
||||
off_t sblk_offset, data_offset;
|
||||
int channel_count = 0, loop_flag, sample_rate, codec;
|
||||
int version;
|
||||
size_t data_size;
|
||||
int channel_count = 0, loop_flag, sample_rate, version;
|
||||
int loop_start = 0, loop_end = 0;
|
||||
uint32_t atrac9_info = 0;
|
||||
int loop_start = 0, loop_length = 0;
|
||||
|
||||
int total_subsongs, target_subsong = streamFile->stream_index;
|
||||
int32_t (*read_32bit)(off_t,STREAMFILE*) = NULL;
|
||||
int16_t (*read_16bit)(off_t,STREAMFILE*) = NULL;
|
||||
bnk_codec codec;
|
||||
|
||||
|
||||
/* checks */
|
||||
if (!check_extensions(streamFile, "bnk"))
|
||||
goto fail;
|
||||
if (read_32bitBE(0x00,streamFile) != 0x03000000)
|
||||
|
||||
if (read_32bitBE(0x00,streamFile) == 0x00000003 && read_32bitBE(0x04,streamFile) == 0x00000002) { /* PS3 */
|
||||
read_32bit = read_32bitBE;
|
||||
read_16bit = read_16bitBE;
|
||||
}
|
||||
else if (read_32bitBE(0x00,streamFile) == 0x03000000 && read_32bitBE(0x04,streamFile) == 0x02000000) { /* Vita/PS4 */
|
||||
read_32bit = read_32bitLE;
|
||||
read_16bit = read_16bitLE;
|
||||
}
|
||||
else {
|
||||
goto fail;
|
||||
if (read_32bitBE(0x04,streamFile) != 0x02000000)
|
||||
goto fail;
|
||||
sblk_offset = read_32bitLE(0x08,streamFile);
|
||||
/* 0x0c: sblk size */
|
||||
data_offset = read_32bitLE(0x10,streamFile);
|
||||
/* 0x14: data size */
|
||||
}
|
||||
|
||||
sblk_offset = read_32bit(0x08,streamFile);
|
||||
/* 0x0c: sklb size */
|
||||
data_offset = read_32bit(0x10,streamFile);
|
||||
data_size = read_32bit(0x14,streamFile);
|
||||
|
||||
/* SE banks, also used for music. Most table fields seems reserved/defaults and
|
||||
* don't change much between subsongs or files, so they aren't described in detail */
|
||||
|
||||
|
||||
/* SBlk part: parse header */
|
||||
if (read_32bitBE(sblk_offset+0x00,streamFile) != 0x53426C6B) /* "SBlk" */
|
||||
if (read_32bit(sblk_offset+0x00,streamFile) != 0x6B6C4253) /* "SBlk" (sample block?) */
|
||||
goto fail;
|
||||
version = read_32bitLE(sblk_offset+0x04,streamFile);
|
||||
version = read_32bit(sblk_offset+0x04,streamFile);
|
||||
/* 0x08: possibly when version=0x0d, 0x03=Vita, 0x06=PS4 */
|
||||
//;VGM_LOG("BNK: sblk_offset=%lx, data_offset=%lx, version %x\n", sblk_offset, data_offset, version);
|
||||
|
||||
@ -50,18 +65,15 @@ VGMSTREAM * init_vgmstream_bnk_sony(STREAMFILE *streamFile) {
|
||||
|
||||
|
||||
switch(version) {
|
||||
case 0x03: /* L@ove Once - Mermaid's Tears (PS3) */
|
||||
case 0x09: /* Puyo Puyo Tetris (PS4) */
|
||||
section_entries = (uint16_t)read_16bitLE(sblk_offset+0x16,streamFile); /* entry size: ~0x0c */
|
||||
material_entries = (uint16_t)read_16bitLE(sblk_offset+0x18,streamFile); /* entry size: ~0x08 */
|
||||
stream_entries = (uint16_t)read_16bitLE(sblk_offset+0x1a,streamFile); /* entry size: ~0x60 */
|
||||
table1_offset = sblk_offset + read_32bitLE(sblk_offset+0x1c,streamFile);
|
||||
table2_offset = sblk_offset + read_32bitLE(sblk_offset+0x20,streamFile);
|
||||
/* 0x24: null? */
|
||||
/* 0x28: offset to end? */
|
||||
/* 0x2c: offset to table3? */
|
||||
/* 0x30: null? */
|
||||
table3_offset = sblk_offset + read_32bitLE(sblk_offset+0x34,streamFile);
|
||||
table4_offset = sblk_offset + read_32bitLE(sblk_offset+0x38,streamFile);
|
||||
section_entries = (uint16_t)read_16bit(sblk_offset+0x16,streamFile); /* entry size: ~0x0c */
|
||||
material_entries = (uint16_t)read_16bit(sblk_offset+0x18,streamFile); /* entry size: ~0x08 */
|
||||
stream_entries = (uint16_t)read_16bit(sblk_offset+0x1a,streamFile); /* entry size: ~0x60 */
|
||||
table1_offset = sblk_offset + read_32bit(sblk_offset+0x1c,streamFile);
|
||||
table2_offset = sblk_offset + read_32bit(sblk_offset+0x20,streamFile);
|
||||
table3_offset = sblk_offset + read_32bit(sblk_offset+0x34,streamFile);
|
||||
table4_offset = sblk_offset + read_32bit(sblk_offset+0x38,streamFile);
|
||||
|
||||
table1_entry_size = 0x0c;
|
||||
table1_suboffset = 0x08;
|
||||
@ -70,17 +82,13 @@ VGMSTREAM * init_vgmstream_bnk_sony(STREAMFILE *streamFile) {
|
||||
break;
|
||||
|
||||
case 0x0d: /* Polara (Vita), Crypt of the Necrodancer (Vita) */
|
||||
table1_offset = sblk_offset + read_32bitLE(sblk_offset+0x18,streamFile);
|
||||
table2_offset = sblk_offset + read_32bitLE(sblk_offset+0x1c,streamFile);
|
||||
/* 0x20: null? */
|
||||
/* 0x24: offset to end? */
|
||||
/* 0x28: offset to table4? */
|
||||
table3_offset = sblk_offset + read_32bitLE(sblk_offset+0x2c,streamFile);
|
||||
table4_offset = sblk_offset + read_32bitLE(sblk_offset+0x30,streamFile);
|
||||
/* 0x34: null? */
|
||||
section_entries = (uint16_t)read_16bitLE(sblk_offset+0x38,streamFile); /* entry size: ~0x24 */
|
||||
material_entries = (uint16_t)read_16bitLE(sblk_offset+0x3a,streamFile); /* entry size: ~0x08 */
|
||||
stream_entries = (uint16_t)read_16bitLE(sblk_offset+0x3c,streamFile); /* entry size: ~0x90 + variable (sometimes) */
|
||||
table1_offset = sblk_offset + read_32bit(sblk_offset+0x18,streamFile);
|
||||
table2_offset = sblk_offset + read_32bit(sblk_offset+0x1c,streamFile);
|
||||
table3_offset = sblk_offset + read_32bit(sblk_offset+0x2c,streamFile);
|
||||
table4_offset = sblk_offset + read_32bit(sblk_offset+0x30,streamFile);
|
||||
section_entries = (uint16_t)read_16bit(sblk_offset+0x38,streamFile); /* entry size: ~0x24 */
|
||||
material_entries = (uint16_t)read_16bit(sblk_offset+0x3a,streamFile); /* entry size: ~0x08 */
|
||||
stream_entries = (uint16_t)read_16bit(sblk_offset+0x3c,streamFile); /* entry size: ~0x90 + variable (sometimes) */
|
||||
|
||||
table1_entry_size = 0x24;
|
||||
table1_suboffset = 0x0c;
|
||||
@ -93,7 +101,7 @@ VGMSTREAM * init_vgmstream_bnk_sony(STREAMFILE *streamFile) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
//;VGM_LOG("BNK: table offsets=t1=%lx, %lx, %lx, %lx\n", table1_offset,table2_offset,table3_offset,table4_offset);
|
||||
//;VGM_LOG("BNK: table offsets=%lx, %lx, %lx, %lx\n", table1_offset,table2_offset,table3_offset,table4_offset);
|
||||
//;VGM_LOG("BNK: table entries=%i, %i, %i\n", section_entries,material_entries,stream_entries);
|
||||
|
||||
|
||||
@ -108,19 +116,24 @@ VGMSTREAM * init_vgmstream_bnk_sony(STREAMFILE *streamFile) {
|
||||
* - get stream offsets
|
||||
* - find if one section points to the selected material, and get section name = stream name */
|
||||
|
||||
|
||||
/* parse materials */
|
||||
total_subsongs = 0;
|
||||
if (target_subsong == 0) target_subsong = 1;
|
||||
|
||||
for (i = 0; i < material_entries; i++) {
|
||||
uint16_t table2_subtype = (uint16_t)read_16bitLE(table2_offset+(i*0x08)+table2_suboffset+0x02,streamFile);
|
||||
uint32_t table2_value, table2_subinfo, table2_subtype;
|
||||
|
||||
table2_value = (uint32_t)read_32bit(table2_offset+(i*0x08)+table2_suboffset+0x00,streamFile);
|
||||
table2_subinfo = (table2_value >> 0) & 0xFFFF;
|
||||
table2_subtype = (table2_value >> 16) & 0xFFFF;
|
||||
if (table2_subtype != 0x100)
|
||||
continue; /* not sounds */
|
||||
|
||||
total_subsongs++;
|
||||
if (total_subsongs == target_subsong) {
|
||||
table2_entry_offset = (i*0x08);
|
||||
table3_entry_offset = (uint16_t)read_16bitLE(table2_offset+(i*0x08)+table2_suboffset+0x00,streamFile);
|
||||
table3_entry_offset = table2_subinfo;
|
||||
/* continue to count all subsongs*/
|
||||
}
|
||||
}
|
||||
@ -136,106 +149,152 @@ VGMSTREAM * init_vgmstream_bnk_sony(STREAMFILE *streamFile) {
|
||||
|
||||
|
||||
/* parse sounds */
|
||||
stream_offset = read_32bitLE(table3_offset+table3_entry_offset+table3_suboffset+0x00,streamFile);
|
||||
stream_size = read_32bitLE(table3_offset+table3_entry_offset+table3_suboffset+0x04,streamFile);
|
||||
stream_offset = read_32bit(table3_offset+table3_entry_offset+table3_suboffset+0x00,streamFile);
|
||||
stream_size = read_32bit(table3_offset+table3_entry_offset+table3_suboffset+0x04,streamFile);
|
||||
|
||||
/* parse names */
|
||||
switch(version) {
|
||||
//case 0x03: /* different format? */
|
||||
case 0x09:
|
||||
case 0x0d:
|
||||
/* find if this sound has an assigned name in table1 */
|
||||
for (i = 0; i < section_entries; i++) {
|
||||
off_t entry_offset = (uint16_t)read_16bit(table1_offset+(i*table1_entry_size)+table1_suboffset+0x00,streamFile);
|
||||
|
||||
/* find if this sound has an assigned name in table1 */
|
||||
for (i = 0; i < section_entries; i++) {
|
||||
off_t entry_offset = (uint16_t)read_16bitLE(table1_offset+(i*table1_entry_size)+table1_suboffset+0x00,streamFile);
|
||||
/* rarely (ex. Polara sfx) one name applies to multiple materials,
|
||||
* from current entry_offset to next entry_offset (section offsets should be in order) */
|
||||
if (entry_offset <= table2_entry_offset ) {
|
||||
table4_entry_id = i;
|
||||
//break;
|
||||
}
|
||||
}
|
||||
|
||||
/* rarely (ex. Polara sfx) one name applies to multiple materials,
|
||||
* from current entry_offset to next entry_offset (section offsets should be in order) */
|
||||
if (entry_offset <= table2_entry_offset ) {
|
||||
table4_entry_id = i;
|
||||
//break;
|
||||
}
|
||||
}
|
||||
/* table4: */
|
||||
/* 0x00: bank name (optional) */
|
||||
/* 0x08: header size */
|
||||
/* 0x0c: table4 size */
|
||||
/* variable: entries */
|
||||
/* variable: names (null terminated) */
|
||||
table4_entries_offset = table4_offset + read_32bit(table4_offset+0x08, streamFile);
|
||||
table4_names_offset = table4_entries_offset + (0x10*section_entries);
|
||||
//;VGM_LOG("BNK: t4_entries=%lx, t4_names=%lx\n", table4_entries_offset, table4_names_offset);
|
||||
|
||||
/* table4: */
|
||||
/* 0x00: bank name (optional) */
|
||||
/* 0x08: header size */
|
||||
/* 0x0c: table4 size */
|
||||
/* variable: entries */
|
||||
/* variable: names (null terminated) */
|
||||
table4_entries_offset = table4_offset + read_32bitLE(table4_offset+0x08, streamFile);
|
||||
table4_names_offset = table4_entries_offset + (0x10*section_entries);
|
||||
//;VGM_LOG("BNK: t4_entries=%lx, t4_names=%lx\n", table4_entries_offset, table4_names_offset);
|
||||
/* get assigned name from table4 names */
|
||||
for (i = 0; i < section_entries; i++) {
|
||||
int entry_id = read_32bit(table4_entries_offset+(i*0x10)+0x0c, streamFile);
|
||||
if (entry_id == table4_entry_id) {
|
||||
name_offset = table4_names_offset + read_32bit(table4_entries_offset+(i*0x10)+0x00, streamFile);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* get assigned name from table4 names */
|
||||
for (i = 0; i < section_entries; i++) {
|
||||
int entry_id = read_32bitLE(table4_entries_offset+(i*0x10)+0x0c, streamFile);
|
||||
if (entry_id == table4_entry_id) {
|
||||
name_offset = table4_names_offset + read_32bitLE(table4_entries_offset+(i*0x10)+0x00, streamFile);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//;VGM_LOG("BNK: stream_offset=%lx, stream_size=%x, name_offset=%lx\n", stream_offset, stream_size, name_offset);
|
||||
}
|
||||
|
||||
|
||||
/* data part: parse extradata before the codec, very annoying */
|
||||
/* data part: parse extradata before the codec, if needed */
|
||||
{
|
||||
size_t extradata_size = 0;
|
||||
int type, loop_length;
|
||||
size_t extradata_size = 0, postdata_size = 0;
|
||||
start_offset = data_offset + stream_offset;
|
||||
|
||||
switch(version) {
|
||||
case 0x09:
|
||||
codec = read_16bitLE(start_offset+0x00,streamFile);
|
||||
extradata_size = 0x08 + read_32bitLE(start_offset+0x04,streamFile); /* 0x14 for AT9 */
|
||||
case 0x03:
|
||||
sample_rate = 48000; /* seems ok */
|
||||
channel_count = 1;
|
||||
|
||||
switch(codec) {
|
||||
/* hack for PS3 files that use dual subsongs as stereo */
|
||||
if (total_subsongs == 2 && stream_size * 2 == data_size) {
|
||||
channel_count = 2;
|
||||
stream_size = stream_size*channel_count;
|
||||
total_subsongs = 1;
|
||||
}
|
||||
|
||||
interleave = stream_size / channel_count;
|
||||
//postdata_size = 0x10; /* last frame may be garbage */
|
||||
|
||||
loop_flag = ps_find_loop_offsets(streamFile, start_offset, stream_size, channel_count, interleave, &loop_start, &loop_end);
|
||||
loop_flag = (loop_start > 28); /* ignore full loops since they just fadeout + repeat */
|
||||
|
||||
codec = PSX;
|
||||
break;
|
||||
|
||||
case 0x09:
|
||||
type = read_16bit(start_offset+0x00,streamFile);
|
||||
extradata_size = 0x08 + read_32bit(start_offset+0x04,streamFile); /* 0x14 for AT9 */
|
||||
|
||||
switch(type) {
|
||||
#ifdef VGM_USE_ATRAC9
|
||||
case 0x02:
|
||||
case 0x05:
|
||||
if (read_32bitLE(start_offset+0x08,streamFile) + 0x08 != extradata_size) /* repeat? */
|
||||
case 0x02: /* ATRAC9 mono? */
|
||||
case 0x05: /* ATRAC9 stereo? */
|
||||
if (read_32bit(start_offset+0x08,streamFile) + 0x08 != extradata_size) /* repeat? */
|
||||
goto fail;
|
||||
atrac9_info = (uint32_t)read_32bitBE(start_offset+0x0c,streamFile);
|
||||
/* 0x10: null? */
|
||||
loop_length = read_32bitLE(start_offset+0x14,streamFile);
|
||||
loop_start = read_32bitLE(start_offset+0x18,streamFile);
|
||||
loop_length = read_32bit(start_offset+0x14,streamFile);
|
||||
loop_start = read_32bit(start_offset+0x18,streamFile);
|
||||
loop_end = loop_start + loop_length; /* loop_start is -1 if not set */
|
||||
|
||||
/* get from AT9 config just in case, but probably: sr=48000 / codec 0x02=1ch, 0x05=2ch */
|
||||
atrac9_parse_config(atrac9_info, &sample_rate, &channel_count, NULL);
|
||||
codec = ATRAC9;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
VGM_LOG("BNK: unknown type %x\n", type);
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x0d:
|
||||
codec = read_16bitLE(start_offset+0x00,streamFile);
|
||||
if (read_32bitLE(start_offset+0x04,streamFile) != 0x01) /* type? */
|
||||
type = read_16bit(start_offset+0x00,streamFile);
|
||||
if (read_32bit(start_offset+0x04,streamFile) != 0x01) /* type? */
|
||||
goto fail;
|
||||
extradata_size = 0x10 + read_32bitLE(start_offset+0x08,streamFile); /* 0x80 for AT9, 0x10 for PCM */
|
||||
extradata_size = 0x10 + read_32bit(start_offset+0x08,streamFile); /* 0x80 for AT9, 0x10 for PCM */
|
||||
/* 0x0c: null? */
|
||||
|
||||
|
||||
switch(codec) {
|
||||
switch(type) {
|
||||
#ifdef VGM_USE_ATRAC9
|
||||
case 0x02:
|
||||
case 0x05:
|
||||
if (read_32bitLE(start_offset+0x10,streamFile) + 0x10 != extradata_size) /* repeat? */
|
||||
case 0x02: /* ATRAC9 mono? */
|
||||
case 0x05: /* ATRAC9 stereo? */
|
||||
if (read_32bit(start_offset+0x10,streamFile) + 0x10 != extradata_size) /* repeat? */
|
||||
goto fail;
|
||||
atrac9_info = (uint32_t)read_32bitBE(start_offset+0x14,streamFile);
|
||||
/* 0x18: null? */
|
||||
/* 0x1c: channels? */
|
||||
/* 0x20: null? */
|
||||
loop_length = read_32bitLE(start_offset+0x24,streamFile);
|
||||
loop_start = read_32bitLE(start_offset+0x28,streamFile);
|
||||
interleave = 0x02;
|
||||
|
||||
loop_length = read_32bit(start_offset+0x24,streamFile);
|
||||
loop_start = read_32bit(start_offset+0x28,streamFile);
|
||||
loop_end = loop_start + loop_length; /* loop_start is -1 if not set */
|
||||
|
||||
/* get from AT9 config just in case, but probably: sr=48000 / codec 0x02=1ch, 0x05=2ch */
|
||||
atrac9_parse_config(atrac9_info, &sample_rate, &channel_count, NULL);
|
||||
codec = ATRAC9;
|
||||
break;
|
||||
#endif
|
||||
case 0x01:
|
||||
case 0x04:
|
||||
case 0x01: /* PCM16LE mono? (NekoBuro/Polara sfx) */
|
||||
case 0x04: /* PCM16LE stereo? (NekoBuro/Polara sfx) */
|
||||
sample_rate = 48000; /* seems ok */
|
||||
/* 0x10: null? */
|
||||
channel_count = read_32bitLE(start_offset+0x14,streamFile);
|
||||
loop_start = read_32bitLE(start_offset+0x18,streamFile);
|
||||
loop_length = read_32bitLE(start_offset+0x1c,streamFile);
|
||||
channel_count = read_32bit(start_offset+0x14,streamFile);
|
||||
interleave = 0x02;
|
||||
loop_start = read_32bit(start_offset+0x18,streamFile);
|
||||
loop_length = read_32bit(start_offset+0x1c,streamFile);
|
||||
loop_end = loop_start + loop_length; /* loop_start is -1 if not set */
|
||||
|
||||
codec = PCM16;
|
||||
break;
|
||||
|
||||
default:
|
||||
VGM_LOG("BNK: unknown type %x\n", type);
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -245,9 +304,11 @@ VGMSTREAM * init_vgmstream_bnk_sony(STREAMFILE *streamFile) {
|
||||
|
||||
start_offset += extradata_size;
|
||||
stream_size -= extradata_size;
|
||||
stream_size -= postdata_size;
|
||||
//;VGM_LOG("BNK: offset=%lx, size=%x\n", start_offset, stream_size);
|
||||
}
|
||||
|
||||
loop_flag = (loop_start >= 0) && (loop_length > 0); /* loop_start is -1 if not set */
|
||||
loop_flag = (loop_start >= 0) && (loop_end > 0);
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
@ -262,8 +323,7 @@ VGMSTREAM * init_vgmstream_bnk_sony(STREAMFILE *streamFile) {
|
||||
|
||||
switch(codec) {
|
||||
#ifdef VGM_USE_ATRAC9
|
||||
case 0x02: /* ATRAC9 mono? */
|
||||
case 0x05: { /* ATRAC9 stereo? */
|
||||
case ATRAC9: {
|
||||
atrac9_config cfg = {0};
|
||||
|
||||
cfg.channels = vgmstream->channels;
|
||||
@ -277,25 +337,30 @@ VGMSTREAM * init_vgmstream_bnk_sony(STREAMFILE *streamFile) {
|
||||
|
||||
vgmstream->num_samples = atrac9_bytes_to_samples(stream_size, vgmstream->codec_data);
|
||||
vgmstream->loop_start_sample = loop_start;
|
||||
vgmstream->loop_end_sample = loop_start + loop_length;
|
||||
vgmstream->loop_end_sample = loop_end;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case 0x01: /* PCM16LE mono? (NekoBuro/Polara sfx) */
|
||||
case 0x04: /* PCM16LE stereo? (NekoBuro/Polara sfx) */
|
||||
case PCM16:
|
||||
vgmstream->coding_type = coding_PCM16LE;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x02;
|
||||
vgmstream->interleave_block_size = interleave;
|
||||
|
||||
vgmstream->num_samples = pcm_bytes_to_samples(stream_size, vgmstream->channels, 16);
|
||||
vgmstream->loop_start_sample = loop_start;
|
||||
vgmstream->loop_end_sample = loop_start + loop_length;
|
||||
|
||||
vgmstream->loop_end_sample = loop_end;
|
||||
break;
|
||||
|
||||
default:
|
||||
VGM_LOG("BNK: unknown codec %x\n", codec);
|
||||
goto fail;
|
||||
case PSX:
|
||||
vgmstream->sample_rate = 48000;
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = interleave;
|
||||
|
||||
vgmstream->num_samples = ps_bytes_to_samples(stream_size,channel_count);
|
||||
vgmstream->loop_start_sample = loop_start;
|
||||
vgmstream->loop_end_sample = loop_end;
|
||||
break;
|
||||
}
|
||||
|
||||
if (name_offset)
|
||||
|
@ -563,8 +563,6 @@ VGMSTREAM * init_vgmstream_pc_adp_otns(STREAMFILE* streamFile);
|
||||
VGMSTREAM * init_vgmstream_eb_sfx(STREAMFILE* streamFile);
|
||||
VGMSTREAM * init_vgmstream_eb_sf0(STREAMFILE* streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_ps3_klbs(STREAMFILE* streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_ps2_mtaf(STREAMFILE* streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_tun(STREAMFILE* streamFile);
|
||||
|
@ -1,122 +0,0 @@
|
||||
#include "meta.h"
|
||||
#include "../util.h"
|
||||
|
||||
/* .KLBS (L@VE ONCE PS3 */
|
||||
VGMSTREAM * init_vgmstream_ps3_klbs(STREAMFILE *streamFile)
|
||||
{
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
|
||||
size_t fileLength;
|
||||
off_t readOffset = 0;
|
||||
off_t start_offset;
|
||||
off_t loop_start_offset = 0;
|
||||
off_t loop_end_offset = 0;
|
||||
|
||||
uint8_t testBuffer[0x10];
|
||||
int loop_flag = 0;
|
||||
int channel_count;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("bnk",filename_extension(filename))) goto fail;
|
||||
|
||||
/* check header */
|
||||
if (read_32bitBE(0x20,streamFile) != 0x6B6C4253)
|
||||
goto fail;
|
||||
|
||||
// get file length
|
||||
fileLength = get_streamfile_size(streamFile);
|
||||
|
||||
// Find loop start
|
||||
start_offset = read_32bitBE(0x10,streamFile);
|
||||
readOffset = start_offset;
|
||||
|
||||
do {
|
||||
readOffset += (off_t)read_streamfile(testBuffer, readOffset, 0x10, streamFile);
|
||||
|
||||
// Loop Start ...
|
||||
if(testBuffer[0x01] == 0x06)
|
||||
{
|
||||
loop_start_offset = readOffset - 0x10;
|
||||
break;
|
||||
}
|
||||
|
||||
} while (streamFile->get_offset(streamFile)<((int32_t)fileLength));
|
||||
|
||||
// start at last line of file and move up
|
||||
readOffset = (int32_t)fileLength - 0x10;
|
||||
|
||||
// Find loop end
|
||||
do {
|
||||
readOffset -= (off_t)read_streamfile(testBuffer, readOffset, 0x10, streamFile);
|
||||
|
||||
// Loop End ...
|
||||
if((testBuffer[0x01]==0x03) && (testBuffer[0x03]!=0x77))
|
||||
{
|
||||
loop_end_offset = readOffset + 0x20;
|
||||
break;
|
||||
}
|
||||
} while (readOffset > 0);
|
||||
|
||||
// setup loops
|
||||
if (loop_start_offset > 0)
|
||||
{
|
||||
loop_flag = 1;
|
||||
|
||||
// if we have a start loop, use EOF if end loop is not found
|
||||
if (loop_end_offset == 0)
|
||||
{
|
||||
loop_end_offset = (int32_t)fileLength - 0x10;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
loop_flag = 0;
|
||||
}
|
||||
|
||||
channel_count = 2;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = read_32bitBE(0x90, streamFile);
|
||||
vgmstream->meta_type = meta_PS3_KLBS;
|
||||
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = 48000;
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
vgmstream->num_samples = ((vgmstream->interleave_block_size * channel_count)/16/channel_count*28);
|
||||
|
||||
if (loop_flag)
|
||||
{
|
||||
vgmstream->loop_start_sample = loop_start_offset/16/channel_count*28;
|
||||
vgmstream->loop_end_sample = loop_end_offset/16/channel_count*28;
|
||||
}
|
||||
|
||||
/* open the file for reading */
|
||||
{
|
||||
int i;
|
||||
STREAMFILE * file;
|
||||
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
if (!file) goto fail;
|
||||
for (i=0;i<channel_count;i++) {
|
||||
vgmstream->ch[i].streamfile = file;
|
||||
|
||||
vgmstream->ch[i].channel_start_offset=
|
||||
vgmstream->ch[i].offset=start_offset+
|
||||
vgmstream->interleave_block_size*i;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
fail:
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
@ -302,7 +302,6 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = {
|
||||
init_vgmstream_pc_adp_otns,
|
||||
init_vgmstream_eb_sfx,
|
||||
init_vgmstream_eb_sf0,
|
||||
init_vgmstream_ps3_klbs,
|
||||
init_vgmstream_ps2_mtaf,
|
||||
init_vgmstream_tun,
|
||||
init_vgmstream_wpd,
|
||||
|
@ -581,7 +581,6 @@ typedef enum {
|
||||
meta_OTNS_ADP, /* Omikron: The Nomad Soul .adp (PC/DC) */
|
||||
meta_EB_SFX, /* Excitebots .sfx */
|
||||
meta_EB_SF0, /* Excitebots .sf0 */
|
||||
meta_PS3_KLBS, /* L@VE ONCE (PS3) */
|
||||
meta_PS2_MTAF, /* Metal Gear Solid 3 MTAF */
|
||||
meta_PS2_VAG1, /* Metal Gear Solid 3 VAG1 */
|
||||
meta_PS2_VAG2, /* Metal Gear Solid 3 VAG2 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user