mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-21 08:43:40 +01:00
Fix some .nus3audio with dummy entries
This commit is contained in:
parent
353b97de5d
commit
43fd6ef309
@ -7,37 +7,37 @@ typedef enum { IDSP, OPUS, RIFF, } nus3audio_codec;
|
||||
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) {
|
||||
@ -97,7 +97,7 @@ VGMSTREAM* init_vgmstream_nus3audio(STREAMFILE* sf) {
|
||||
fake_ext = "wav";
|
||||
break;
|
||||
default:
|
||||
VGM_LOG("NUS3AUDIO: unknown codec %x\n", codec_id);
|
||||
vgm_logi("NUS3AUDIO: unknown codec (report)\n");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
@ -136,5 +136,3 @@ fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user