mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-24 23:10:10 +01:00
Merge pull request #1321 from bnnm/nus3audio-etc
- Fix some .HXX [XIII Early beta (Xbox)] - Fix some .nus3audio with dummy entries - Add BNSF in .nus3audio [Gundam Ex. Vs 2 (AC)]
This commit is contained in:
commit
aae7fa9ae9
@ -1,43 +1,43 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
typedef enum { IDSP, OPUS, RIFF, } nus3audio_codec;
|
||||
typedef enum { IDSP, OPUS, RIFF, BNSF, } nus3audio_codec;
|
||||
|
||||
/* .nus3audio - Namco's newest newest audio container [Super Smash Bros. Ultimate (Switch), Mobile Suit Gundam: Extreme Vs. Maxi Boost ON (PS4)] */
|
||||
VGMSTREAM* init_vgmstream_nus3audio(STREAMFILE* sf) {
|
||||
VGMSTREAM* vgmstream = NULL;
|
||||
STREAMFILE* temp_sf = NULL;
|
||||
off_t subfile_offset = 0, name_offset = 0;
|
||||
size_t subfile_size = 0;
|
||||
uint32_t subfile_offset = 0, subfile_size = 0, name_offset = 0;
|
||||
nus3audio_codec codec;
|
||||
const char* fake_ext = NULL;
|
||||
int total_subsongs, target_subsong = sf->stream_index, found = 0;
|
||||
|
||||
|
||||
/* checks */
|
||||
if (!check_extensions(sf, "nus3audio"))
|
||||
goto fail;
|
||||
if (read_u32be(0x00,sf) != 0x4E555333) /* "NUS3" */
|
||||
if (!is_id32be(0x00,sf, "NUS3"))
|
||||
goto fail;
|
||||
if (read_u32le(0x04,sf) + 0x08 != get_streamfile_size(sf))
|
||||
goto fail;
|
||||
if (read_u32be(0x08,sf) != 0x41554449) /* "AUDI" */
|
||||
if (!is_id32be(0x08,sf, "AUDI"))
|
||||
goto fail;
|
||||
|
||||
if (!check_extensions(sf, "nus3audio"))
|
||||
goto fail;
|
||||
|
||||
|
||||
/* parse existing chunks */
|
||||
{
|
||||
off_t offset = 0x0c;
|
||||
size_t file_size = get_streamfile_size(sf);
|
||||
uint32_t offset = 0x0c;
|
||||
uint32_t file_size = get_streamfile_size(sf);
|
||||
uint32_t codec_id = 0;
|
||||
|
||||
total_subsongs = 0;
|
||||
|
||||
while (offset < file_size) {
|
||||
uint32_t chunk_id = read_u32be(offset+0x00, sf);
|
||||
size_t chunk_size = read_u32le(offset+0x04, sf);
|
||||
uint32_t chunk_type = read_u32be(offset+0x00, sf);
|
||||
uint32_t chunk_size = read_u32le(offset+0x04, sf);
|
||||
|
||||
switch(chunk_id) {
|
||||
switch(chunk_type) {
|
||||
case 0x494E4458: /* "INDX": audio index */
|
||||
total_subsongs = read_u32le(offset+0x08 + 0x00,sf);
|
||||
if (target_subsong == 0) target_subsong = 1;
|
||||
@ -70,8 +70,8 @@ VGMSTREAM* init_vgmstream_nus3audio(STREAMFILE* sf) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* handle dummy entries, ex. Gundam EvM (PS4) */
|
||||
if (subfile_offset == 0 && subfile_size == 0) {
|
||||
/* handle dummy entries (offset may be 0 or first entry), ex. Gundam EvM (PS4) */
|
||||
if (subfile_size == 0) {
|
||||
vgmstream = init_vgmstream_silence(0, 0, 0);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
@ -80,7 +80,7 @@ VGMSTREAM* init_vgmstream_nus3audio(STREAMFILE* sf) {
|
||||
|
||||
return vgmstream;
|
||||
}
|
||||
|
||||
|
||||
|
||||
codec_id = read_u32be(subfile_offset, sf);
|
||||
switch(codec_id) {
|
||||
@ -96,8 +96,12 @@ VGMSTREAM* init_vgmstream_nus3audio(STREAMFILE* sf) {
|
||||
codec = RIFF;
|
||||
fake_ext = "wav";
|
||||
break;
|
||||
case 0x424E5346: /* "BNSF" [gundam Extreme Vs 2 (AC)-multichannel] */
|
||||
codec = BNSF;
|
||||
fake_ext = "bnsf";
|
||||
break;
|
||||
default:
|
||||
VGM_LOG("NUS3AUDIO: unknown codec %x\n", codec_id);
|
||||
vgm_logi("NUS3AUDIO: unknown codec (report)\n");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
@ -120,6 +124,10 @@ VGMSTREAM* init_vgmstream_nus3audio(STREAMFILE* sf) {
|
||||
vgmstream = init_vgmstream_riff(temp_sf);
|
||||
if (!vgmstream) goto fail;
|
||||
break;
|
||||
case BNSF:
|
||||
vgmstream = init_vgmstream_bnsf(temp_sf);
|
||||
if (!vgmstream) goto fail;
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
@ -136,5 +144,3 @@ fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -423,14 +423,28 @@ static int parse_header(ubi_hx_header* hx, STREAMFILE* sf, uint32_t offset, uint
|
||||
if ((strcmp(hx->class_name, "CXBoxStaticHWWaveFileIdObj") == 0 ||
|
||||
strcmp(hx->class_name, "CXBoxStreamHWWaveFileIdObj") == 0) && !hx->big_endian) {
|
||||
/* micro header: some mix of channels + block size + sample rate + flags, unsure of which bits */
|
||||
hx->codec = XIMA;
|
||||
|
||||
/* 0x00: ? */
|
||||
hx->channels = read_u8(offset + 0x01, sf); /* upper 2 bits? */
|
||||
switch(hx->channels) {
|
||||
case 0x48: hx->channels = 1; break;
|
||||
case 0x90: hx->channels = 2; break;
|
||||
uint8_t flags = read_u8(offset + 0x01, sf);
|
||||
switch(flags) {
|
||||
case 0x05: // b00000101 /* XIII (Xbox)-beta 2002-12 */
|
||||
hx->channels = 1;
|
||||
hx->codec = PCM;
|
||||
break;
|
||||
case 0x09: // b00001001 /* XIII (Xbox)-beta 2002-12 */
|
||||
hx->channels = 2;
|
||||
hx->codec = PCM;
|
||||
break;
|
||||
case 0x48: // b01001000
|
||||
hx->channels = 1;
|
||||
hx->codec = XIMA;
|
||||
break;
|
||||
case 0x90: // b10010000
|
||||
hx->channels = 2;
|
||||
hx->codec = XIMA;
|
||||
break;
|
||||
default:
|
||||
VGM_LOG("ubi hx: channel type %x\n", hx->channels);
|
||||
VGM_LOG("ubi hx: channel flags %x\n", flags);
|
||||
goto fail;
|
||||
}
|
||||
hx->sample_rate = (read_u16(offset + 0x02, sf) & 0x7FFFu) << 1u; /* ??? */
|
||||
|
Loading…
Reference in New Issue
Block a user