mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-18 15:54:05 +01:00
Add .way bgm decoder/meta [Eien no Owari ni (PC)]
This commit is contained in:
parent
e545bfdaae
commit
27fd84ca8c
@ -223,6 +223,8 @@ void decode_xmd(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing,
|
||||
/* derf_decoder */
|
||||
void decode_derf(VGMSTREAMCHANNEL* stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
|
||||
|
||||
/* wady_decoder */
|
||||
void decode_wady(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
|
||||
|
||||
/* circus_decoder */
|
||||
typedef struct circus_codec_data circus_codec_data;
|
||||
|
48
src/coding/wady_decoder.c
Normal file
48
src/coding/wady_decoder.c
Normal file
@ -0,0 +1,48 @@
|
||||
#include "coding.h"
|
||||
|
||||
|
||||
/* originally only positives are stored (pre-init by copying negatives) */
|
||||
static const int wady_table[64+64] = {
|
||||
0, 2, 4, 6, 8, 10, 12, 15,
|
||||
18, 21, 24, 28, 32, 36, 40, 44,
|
||||
49, 54, 59, 64, 70, 76, 82, 88,
|
||||
95, 102, 109, 116, 124, 132, 140, 148,
|
||||
160, 170, 180, 190, 200, 210, 220, 230,
|
||||
240, 255, 270, 285, 300, 320, 340, 360,
|
||||
380, 400, 425, 450, 475, 500, 525, 550,
|
||||
580, 610, 650, 700, 750, 800, 900, 1000,
|
||||
-0, -2, -4, -6, -8, -10, -12, -15,
|
||||
-18, -21, -24, -28, -32, -36, -40, -44,
|
||||
-49, -54, -59, -64, -70, -76, -82, -88,
|
||||
-95, -102,-109,-116,-124,-132,-140,-148,
|
||||
-160,-170,-180,-190,-200,-210,-220,-230,
|
||||
-240,-255,-270,-285,-300,-320,-340,-360,
|
||||
-380,-400,-425,-450,-475,-500,-525,-550,
|
||||
-580,-610,-650,-700,-750,-800,-900,-1000,
|
||||
};
|
||||
|
||||
/* There is another decoding mode mainly for SFX. Uses headered frames/blocks (big),
|
||||
* L-frame then R-frame, DPCM uses another table plus a RLE/LZ-like mode */
|
||||
|
||||
/* Marble engine WADY decoder, decompiled from the exe
|
||||
* (some info from: https://github.com/morkt/GARbro/blob/master/ArcFormats/Marble/AudioWADY.cs) */
|
||||
void decode_wady(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) {
|
||||
int i, sample_pos = 0;
|
||||
off_t frame_offset = stream->offset; /* frame size is 1 */
|
||||
int32_t hist = stream->adpcm_history1_32;
|
||||
int scale = stream->adpcm_scale;
|
||||
|
||||
for (i = first_sample; i < first_sample + samples_to_do; i++) {
|
||||
int8_t code = read_s8(frame_offset + i, stream->streamfile);
|
||||
|
||||
if (code & 0x80)
|
||||
hist = (code << 9); /* PCM */
|
||||
else
|
||||
hist += scale * wady_table[code]; /* DPCM */
|
||||
|
||||
outbuf[sample_pos] = hist; /* no clamp */
|
||||
sample_pos += channelspacing;
|
||||
}
|
||||
|
||||
stream->adpcm_history1_32 = hist;
|
||||
}
|
@ -343,6 +343,7 @@ int get_vgmstream_samples_per_frame(VGMSTREAM* vgmstream) {
|
||||
case coding_CBD2:
|
||||
case coding_ACM:
|
||||
case coding_DERF:
|
||||
case coding_WADY:
|
||||
case coding_NWA:
|
||||
case coding_SASSC:
|
||||
case coding_CIRCUS_ADPCM:
|
||||
@ -540,6 +541,7 @@ int get_vgmstream_frame_size(VGMSTREAM* vgmstream) {
|
||||
case coding_SDX2_int:
|
||||
case coding_CBD2:
|
||||
case coding_DERF:
|
||||
case coding_WADY:
|
||||
case coding_NWA:
|
||||
case coding_SASSC:
|
||||
case coding_CIRCUS_ADPCM:
|
||||
@ -1031,6 +1033,12 @@ void decode_vgmstream(VGMSTREAM* vgmstream, int samples_written, int samples_to_
|
||||
vgmstream->channels, vgmstream->samples_into_block, samples_to_do);
|
||||
}
|
||||
break;
|
||||
case coding_WADY:
|
||||
for (ch = 0; ch < vgmstream->channels; ch++) {
|
||||
decode_wady(&vgmstream->ch[ch], buffer+ch,
|
||||
vgmstream->channels, vgmstream->samples_into_block, samples_to_do);
|
||||
}
|
||||
break;
|
||||
case coding_CIRCUS_ADPCM:
|
||||
for (ch = 0; ch < vgmstream->channels; ch++) {
|
||||
decode_circus_adpcm(&vgmstream->ch[ch], buffer+ch,
|
||||
|
@ -553,6 +553,7 @@ static const char* extension_list[] = {
|
||||
"wavebatch",
|
||||
"wavm",
|
||||
"wavx", //txth/reserved [LEGO Star Wars (Xbox)]
|
||||
"way",
|
||||
"wb",
|
||||
"wb2",
|
||||
"wbd",
|
||||
@ -769,6 +770,7 @@ static const coding_info coding_info_list[] = {
|
||||
{coding_OKI16, "OKI 4-bit ADPCM (16-bit output)"},
|
||||
{coding_OKI4S, "OKI 4-bit ADPCM (4-shift)"},
|
||||
{coding_PTADPCM, "Platinum 4-bit ADPCM"},
|
||||
{coding_IMUSE, "LucasArts iMUSE VIMA ADPCM"},
|
||||
|
||||
{coding_SDX2, "Squareroot-delta-exact (SDX2) 8-bit DPCM"},
|
||||
{coding_SDX2_int, "Squareroot-delta-exact (SDX2) 8-bit DPCM with 1 byte interleave"},
|
||||
@ -776,11 +778,11 @@ static const coding_info coding_info_list[] = {
|
||||
{coding_CBD2_int, "Cuberoot-delta-exact (CBD2) 8-bit DPCM with 1 byte interleave"},
|
||||
{coding_SASSC, "Activision / EXAKT SASSC 8-bit DPCM"},
|
||||
{coding_DERF, "Xilam DERF 8-bit DPCM"},
|
||||
{coding_ACM, "InterPlay ACM"},
|
||||
{coding_WADY, "Marble WADY 8-bit DPCM"},
|
||||
{coding_NWA, "VisualArt's NWA DPCM"},
|
||||
{coding_ACM, "InterPlay ACM"},
|
||||
{coding_CIRCUS_ADPCM, "Circus 8-bit ADPCM"},
|
||||
{coding_UBI_ADPCM, "Ubisoft 4/6-bit ADPCM"},
|
||||
{coding_IMUSE, "LucasArts iMUSE VIMA ADPCM"},
|
||||
|
||||
{coding_EA_MT, "Electronic Arts MicroTalk"},
|
||||
{coding_CIRCUS_VQ, "Circus VQ"},
|
||||
@ -1311,6 +1313,7 @@ static const meta_info meta_info_list[] = {
|
||||
{meta_PCM_SUCCESS, "Success PCM header"},
|
||||
{meta_ADP_KONAMI, "Konami ADP header"},
|
||||
{meta_SDRH, "feelplus SDRH header"},
|
||||
{meta_WADY, "Marble WADY header"},
|
||||
};
|
||||
|
||||
void get_vgmstream_coding_description(VGMSTREAM* vgmstream, char* out, size_t out_size) {
|
||||
|
@ -1782,6 +1782,10 @@
|
||||
RelativePath=".\meta\ubi_jade.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\wady.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\waf.c"
|
||||
>
|
||||
@ -2278,6 +2282,10 @@
|
||||
RelativePath=".\coding\vadpcm_decoder.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\coding\wady_decoder.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\coding\ws_decoder.c"
|
||||
>
|
||||
|
@ -539,6 +539,7 @@
|
||||
<ClCompile Include="meta\vsf_tta.c" />
|
||||
<ClCompile Include="meta\vxn.c" />
|
||||
<ClCompile Include="meta\ubi_jade.c" />
|
||||
<ClCompile Include="meta\wady.c" />
|
||||
<ClCompile Include="meta\waf.c" />
|
||||
<ClCompile Include="meta\wave_segmented.c" />
|
||||
<ClCompile Include="meta\wave.c" />
|
||||
@ -632,6 +633,7 @@
|
||||
<ClCompile Include="coding\vorbis_custom_utils_sk.c" />
|
||||
<ClCompile Include="coding\vorbis_custom_utils_vid1.c" />
|
||||
<ClCompile Include="coding\vorbis_custom_utils_wwise.c" />
|
||||
<ClCompile Include="coding\wady_decoder.c" />
|
||||
<ClCompile Include="coding\ws_decoder.c" />
|
||||
<ClCompile Include="coding\xa_decoder.c" />
|
||||
<ClCompile Include="coding\xmd_decoder.c" />
|
||||
|
@ -1123,6 +1123,9 @@
|
||||
<ClCompile Include="meta\ubi_jade.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meta\wady.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meta\waf.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -1360,6 +1363,9 @@
|
||||
<ClCompile Include="coding\vadpcm_decoder.c">
|
||||
<Filter>coding\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="coding\wady_decoder.c">
|
||||
<Filter>coding\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="coding\ws_decoder.c">
|
||||
<Filter>coding\Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
@ -923,4 +923,6 @@ VGMSTREAM* init_vgmstream_bsf(STREAMFILE* sf);
|
||||
VGMSTREAM* init_vgmstream_xse_new(STREAMFILE* sf);
|
||||
VGMSTREAM* init_vgmstream_xse_old(STREAMFILE* sf);
|
||||
|
||||
VGMSTREAM* init_vgmstream_wady(STREAMFILE* sf);
|
||||
|
||||
#endif /*_META_H*/
|
||||
|
62
src/meta/wady.c
Normal file
62
src/meta/wady.c
Normal file
@ -0,0 +1,62 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
/* WADY - from Marble engine games [Eien no Owari ni (PC), Elf no Futagohime (PC)] */
|
||||
VGMSTREAM* init_vgmstream_wady(STREAMFILE *sf) {
|
||||
VGMSTREAM* vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
int loop_flag, channels, sample_rate, scale, num_samples;
|
||||
size_t codec_size;
|
||||
|
||||
|
||||
/* checks */
|
||||
/* .way/extensionless: found in some bigfiles */
|
||||
if (!check_extensions(sf, "way,"))
|
||||
goto fail;
|
||||
if (read_u32be(0x00,sf) != 0x57414459) /* "WADY" */
|
||||
goto fail;
|
||||
|
||||
/* 0x04: none */
|
||||
scale = read_u8(0x05,sf);
|
||||
channels = read_u16le(0x06,sf);
|
||||
sample_rate = read_s32le(0x08,sf);
|
||||
codec_size = read_u32le(0x0c,sf);
|
||||
num_samples = read_s32le(0x10,sf);
|
||||
/* 0x14: PCM size? */
|
||||
/* 0x18/1c: null */
|
||||
/* 0x20: fmt-like subheader (codec/channels/srate/bitrate/bps/spf) */
|
||||
|
||||
start_offset = 0x30;
|
||||
loop_flag = 0;
|
||||
|
||||
//todo implement
|
||||
/* codec variation used in SFX */
|
||||
if (codec_size + start_offset != get_streamfile_size(sf))
|
||||
goto fail;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channels, loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->meta_type = meta_WADY;
|
||||
vgmstream->sample_rate = sample_rate;
|
||||
vgmstream->coding_type = coding_WADY;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x01;
|
||||
vgmstream->num_samples = num_samples;
|
||||
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < channels; i++) {
|
||||
vgmstream->ch[i].adpcm_scale = scale;
|
||||
}
|
||||
}
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
@ -511,6 +511,7 @@ VGMSTREAM* (*init_vgmstream_functions[])(STREAMFILE* sf) = {
|
||||
init_vgmstream_bsf,
|
||||
init_vgmstream_xse_new,
|
||||
init_vgmstream_xse_old,
|
||||
init_vgmstream_wady,
|
||||
|
||||
/* lowest priority metas (should go after all metas, and TXTH should go before raw formats) */
|
||||
init_vgmstream_txth, /* proper parsers should supersede TXTH, once added */
|
||||
|
@ -177,11 +177,12 @@ typedef enum {
|
||||
coding_SDX2, /* SDX2 2:1 Squareroot-Delta-Exact compression DPCM */
|
||||
coding_SDX2_int, /* SDX2 2:1 Squareroot-Delta-Exact compression with sample-level interleave */
|
||||
coding_CBD2, /* CBD2 2:1 Cuberoot-Delta-Exact compression DPCM */
|
||||
coding_CBD2_int, /* CBD2 2:1 Cuberoot-Delta-Exact compression, with sample-level interleave */
|
||||
coding_CBD2_int, /* CBD2 2:1 Cuberoot-Delta-Exact compression, with sample-level interleave */
|
||||
coding_SASSC, /* Activision EXAKT SASSC 8-bit DPCM */
|
||||
coding_DERF, /* DERF 8-bit DPCM */
|
||||
coding_WADY, /* WADY 8-bit DPCM */
|
||||
coding_NWA, /* VisualArt's NWA DPCM */
|
||||
coding_ACM, /* InterPlay ACM */
|
||||
coding_NWA, /* VisualArt's NWA */
|
||||
coding_CIRCUS_ADPCM, /* Circus 8-bit ADPCM */
|
||||
coding_UBI_ADPCM, /* Ubisoft 4/6-bit ADPCM */
|
||||
|
||||
@ -739,6 +740,7 @@ typedef enum {
|
||||
meta_PCM_SUCCESS,
|
||||
meta_ADP_KONAMI,
|
||||
meta_SDRH,
|
||||
meta_WADY,
|
||||
} meta_t;
|
||||
|
||||
/* standard WAVEFORMATEXTENSIBLE speaker positions */
|
||||
|
Loading…
x
Reference in New Issue
Block a user