Merge pull request #449 from bnnm/xwn-xnb

xwb xnb
This commit is contained in:
bnnm 2019-07-28 23:53:18 +02:00 committed by GitHub
commit 8d7570ee2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 10 deletions

View File

@ -83,7 +83,7 @@ VGMSTREAM * init_vgmstream_awb_memory(STREAMFILE *streamFile, STREAMFILE *acbFil
subfile_size = subfile_next - subfile_offset;
}
;VGM_LOG("AWB: subfile offset=%lx + %x\n", subfile_offset, subfile_size);
//;VGM_LOG("AWB: subfile offset=%lx + %x\n", subfile_offset, subfile_size);
/* autodetect as there isn't anything, plus can mix types
* (waveid<>codec info is usually in the companion .acb) */
@ -109,7 +109,7 @@ VGMSTREAM * init_vgmstream_awb_memory(STREAMFILE *streamFile, STREAMFILE *acbFil
}
else if (read_u32be(subfile_offset + 0x08,streamFile) >= 8000 &&
read_u32be(subfile_offset + 0x08,streamFile) <= 48000 &&
read_u16be(subfile_offset + 0x08,streamFile) == 0 &&
read_u16be(subfile_offset + 0x0e,streamFile) == 0 &&
read_u32be(subfile_offset + 0x18,streamFile) == 2 &&
read_u32be(subfile_offset + 0x50,streamFile) == 0) { /* probably should call some check function (type 13) */
type = DSP;

View File

@ -18,7 +18,7 @@ VGMSTREAM * init_vgmstream_xnb(STREAMFILE *streamFile) {
goto fail;
/* XNA Studio platforms: 'w' = Windows, 'm' = Windows Phone 7, 'x' = X360
* MonoGame extensions: 'i' = iOS, 'a' = Android, 'X' = MacOSX, 'P': PS4, etc */
* MonoGame extensions: 'i' = iOS, 'a' = Android, 'X' = MacOSX, 'P' = PS4, 'S' = Switch, etc */
platform = read_8bit(0x03,streamFile);
big_endian = (platform == 'x');
@ -58,7 +58,7 @@ VGMSTREAM * init_vgmstream_xnb(STREAMFILE *streamFile) {
if ( strcmp(reader_name, type_sound) != 0 )
goto fail;
current_offset += reader_string_len + 1;
current_offset += 4; /* reader version */
current_offset += 0x04; /* reader version */
/* shared resource count */
if (read_8bit(current_offset++, streamFile) != 1)
@ -66,13 +66,13 @@ VGMSTREAM * init_vgmstream_xnb(STREAMFILE *streamFile) {
/* shared resource: partial "fmt" chunk */
fmt_chunk_size = read_32bitLE(current_offset, streamFile);
current_offset += 4;
current_offset += 0x04;
{
int32_t (*read_32bit)(off_t,STREAMFILE*) = big_endian ? read_32bitBE : read_32bitLE;
int16_t (*read_16bit)(off_t,STREAMFILE*) = big_endian ? read_16bitBE : read_16bitLE;
codec = read_16bit(current_offset+0x00, streamFile);
codec = (uint16_t)read_16bit(current_offset+0x00, streamFile);
channel_count = read_16bit(current_offset+0x02, streamFile);
sample_rate = read_32bit(current_offset+0x04, streamFile);
/* 0x08: byte rate */
@ -83,12 +83,17 @@ VGMSTREAM * init_vgmstream_xnb(STREAMFILE *streamFile) {
xma2_parse_fmt_chunk_extra(streamFile, current_offset, &loop_flag, &num_samples, &loop_start, &loop_end, big_endian);
xma_chunk_offset = current_offset;
}
if (codec == 0xFFFF) {
if (platform != 'S') goto fail;
sample_rate = read_32bit(current_offset+fmt_chunk_size+0x04+0x08, streamFile);
}
}
current_offset += fmt_chunk_size;
data_size = read_32bitLE(current_offset, streamFile);
current_offset += 4;
current_offset += 0x04;
start_offset = current_offset;
}
@ -151,6 +156,16 @@ VGMSTREAM * init_vgmstream_xnb(STREAMFILE *streamFile) {
break;
}
#endif
case 0xFFFF: /* Eagle Island (Switch) */
vgmstream->coding_type = coding_NGC_DSP;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = data_size / channel_count;
vgmstream->num_samples = read_32bitLE(start_offset + 0x00, streamFile);
//vgmstream->num_samples = dsp_bytes_to_samples(data_size - 0x60*channel_count, channel_count);
dsp_read_coefs(vgmstream,streamFile,start_offset + 0x1c,vgmstream->interleave_block_size,big_endian);
dsp_read_hist (vgmstream,streamFile,start_offset + 0x3c,vgmstream->interleave_block_size,big_endian);
break;
default:
VGM_LOG("XNB: unknown codec 0x%x\n", codec);

View File

@ -326,8 +326,11 @@ VGMSTREAM * init_vgmstream_xwb(STREAMFILE *streamFile) {
}
else if (xwb.version == XACT3_0_MAX && xwb.codec == XMA2
&& xwb.bits_per_sample == 0x01 && xwb.block_align == 0x04
&& xwb.data_size == 0x55951c1c) { /* some kind of id? */
/* Stardew Valley (Switch), full interleaved DSPs (including headers) */
&& read_32bitLE(xwb.stream_offset + 0x08, streamFile) == xwb.sample_rate /* DSP header */
&& read_16bitLE(xwb.stream_offset + 0x0e, streamFile) == 0
&& read_32bitLE(xwb.stream_offset + 0x18, streamFile) == 2
/*&& xwb.data_size == 0x55951c1c*/) { /* some kind of id in Stardew Valley? */
/* Stardew Valley (Switch), Skulls of the Shogun (Switch): full interleaved DSPs (including headers) */
xwb.codec = DSP;
}
else if (xwb.version == XACT3_0_MAX && xwb.codec == XMA2
@ -342,7 +345,7 @@ VGMSTREAM * init_vgmstream_xwb(STREAMFILE *streamFile) {
xwb.loop_flag = (xwb.loop_end > 0 || xwb.loop_end_sample > xwb.loop_start)
&& !(xwb.entry_flags & WAVEBANKENTRY_FLAGS_IGNORELOOP);
/* Oddworld OGG the data_size value is size of uncompressed bytes instead; DSP uses some id/config as value */
/* Oddworld OGG the data_size value is size of uncompressed bytes instead; DSP uses some id/config as value */
if (xwb.codec != OGG && xwb.codec != DSP && xwb.codec != ATRAC9_RIFF) {
/* some low-q rips don't remove padding, relax validation a bit */
if (xwb.data_offset + xwb.stream_size > get_streamfile_size(streamFile))