mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-12 01:30:49 +01:00
Added FWSE format
This commit is contained in:
parent
d170b10812
commit
10ab263092
@ -20,6 +20,7 @@ void decode_wv6_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspa
|
||||
void decode_alp_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
|
||||
void decode_ffta2_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
|
||||
void decode_blitz_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
|
||||
void decode_mtf_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
|
||||
|
||||
void decode_ms_ima(VGMSTREAM * vgmstream,VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do,int channel);
|
||||
void decode_ref_ima(VGMSTREAM * vgmstream, VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do,int channel);
|
||||
|
@ -263,6 +263,26 @@ static void blitz_ima_expand_nibble(VGMSTREAMCHANNEL * stream, off_t byte_offset
|
||||
if (*step_index > 88) *step_index=88;
|
||||
}
|
||||
|
||||
static const int CIMAADPCM_INDEX_TABLE[16] = {8, 6, 4, 2, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, 2, 4, 6, 8};
|
||||
|
||||
/* Capcom's MT Framework modified IMA, reverse engineered from the exe */
|
||||
static void mtf_ima_expand_nibble(VGMSTREAMCHANNEL * stream, off_t byte_offset, int nibble_shift, int32_t * hist1, int32_t * step_index) {
|
||||
int sample_nibble, sample_decoded, step, delta;
|
||||
|
||||
sample_nibble = (read_8bit(byte_offset,stream->streamfile) >> nibble_shift) & 0xf;
|
||||
sample_decoded = *hist1;
|
||||
step = ADPCMTable[*step_index];
|
||||
|
||||
delta = step * (2 * sample_nibble - 15);
|
||||
sample_decoded += delta;
|
||||
|
||||
*hist1 = sample_decoded;
|
||||
*step_index += CIMAADPCM_INDEX_TABLE[sample_nibble];
|
||||
if (*step_index < 0) *step_index=0;
|
||||
if (*step_index > 88) *step_index=88;
|
||||
}
|
||||
|
||||
/* ************************************ */
|
||||
/* DVI/IMA */
|
||||
/* ************************************ */
|
||||
@ -298,6 +318,30 @@ void decode_standard_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int chann
|
||||
stream->adpcm_step_index = step_index;
|
||||
}
|
||||
|
||||
void decode_mtf_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) {
|
||||
int i, sample_count = 0;
|
||||
int32_t hist1 = stream->adpcm_history1_32;
|
||||
int step_index = stream->adpcm_step_index;
|
||||
|
||||
/* external interleave */
|
||||
|
||||
/* no header (external setup), pre-clamp for wrong values */
|
||||
if (step_index < 0) step_index=0;
|
||||
if (step_index > 88) step_index=88;
|
||||
|
||||
/* decode nibbles (layout: varies) */
|
||||
for (i = first_sample; i < first_sample + samples_to_do; i++, sample_count += channelspacing) {
|
||||
off_t byte_offset = stream->offset + i/2;
|
||||
int nibble_shift = ((i&1) ? 0:4);
|
||||
|
||||
mtf_ima_expand_nibble(stream, byte_offset,nibble_shift, &hist1, &step_index);
|
||||
outbuf[sample_count] = clamp16(hist1 >> 4);
|
||||
}
|
||||
|
||||
stream->adpcm_history1_32 = hist1;
|
||||
stream->adpcm_step_index = step_index;
|
||||
}
|
||||
|
||||
void decode_3ds_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) {
|
||||
int i, sample_count;
|
||||
int32_t hist1 = stream->adpcm_history1_32;
|
||||
|
@ -172,6 +172,7 @@ static const char* extension_list[] = {
|
||||
"fsb",
|
||||
"fsv",
|
||||
"fwav",
|
||||
"fwse",
|
||||
|
||||
"g1l",
|
||||
"gbts",
|
||||
@ -692,6 +693,7 @@ static const coding_info coding_info_list[] = {
|
||||
{coding_ALP_IMA, "High Voltage ALP 4-bit IMA ADPCM"},
|
||||
{coding_FFTA2_IMA, "Final Fantasy Tactics A2 4-bit IMA ADPCM"},
|
||||
{coding_BLITZ_IMA, "Blitz Games 4-bit IMA ADPCM"},
|
||||
{coding_MTF_IMA, "MT Framework 4-bit IMA ADPCM"},
|
||||
|
||||
{coding_MS_IMA, "Microsoft 4-bit IMA ADPCM"},
|
||||
{coding_XBOX_IMA, "XBOX 4-bit IMA ADPCM"},
|
||||
@ -1254,6 +1256,7 @@ static const meta_info meta_info_list[] = {
|
||||
{meta_ISB, "Creative ISACT header"},
|
||||
{meta_XSSB, "Artoon XSSB header"},
|
||||
{meta_XMA_UE3, "Unreal Engine XMA header"},
|
||||
{meta_FWSE, "MT Framework FWSE header"},
|
||||
{meta_FDA, "Relic FDA header"},
|
||||
|
||||
};
|
||||
|
@ -680,6 +680,10 @@
|
||||
RelativePath=".\meta\fsb_encrypted.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\fwse.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\g1l.c"
|
||||
>
|
||||
|
@ -168,6 +168,7 @@
|
||||
<ClCompile Include="meta\excitebots.c" />
|
||||
<ClCompile Include="meta\ezw.c" />
|
||||
<ClCompile Include="meta\ffmpeg.c" />
|
||||
<ClCompile Include="meta\fwse.c" />
|
||||
<ClCompile Include="meta\g1l.c" />
|
||||
<ClCompile Include="meta\ima.c" />
|
||||
<ClCompile Include="meta\imc.c" />
|
||||
|
@ -436,6 +436,9 @@
|
||||
<ClCompile Include="meta\fsb_encrypted.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meta\fwse.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meta\gca.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
51
src/meta/fwse.c
Normal file
51
src/meta/fwse.c
Normal file
@ -0,0 +1,51 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
/* FWSE - Capcom's MT Framework V1.x sound file */
|
||||
VGMSTREAM *init_vgmstream_fwse(STREAMFILE *streamFile) {
|
||||
VGMSTREAM *vgmstream = NULL;
|
||||
uint32_t version, file_size, buffer_offset,
|
||||
channel_count, sample_count, sample_rate;
|
||||
|
||||
if (!check_extensions(streamFile,"fwse"))
|
||||
goto fail;
|
||||
|
||||
if ((read_32bitLE(0x00,streamFile)) != 0x45535746)
|
||||
goto fail;
|
||||
|
||||
version = read_32bitLE(0x04,streamFile);
|
||||
|
||||
if (version != 2)
|
||||
goto fail;
|
||||
|
||||
file_size = read_32bitLE(0x08,streamFile);
|
||||
buffer_offset = read_32bitLE(0x0C,streamFile);
|
||||
channel_count = read_32bitLE(0x10,streamFile);
|
||||
|
||||
if (channel_count > 1)
|
||||
goto fail;
|
||||
|
||||
sample_count = read_32bitLE(0x14,streamFile);
|
||||
sample_rate = read_32bitLE(0x18,streamFile);
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count, 0);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->meta_type = meta_FWSE;
|
||||
vgmstream->sample_rate = sample_rate;
|
||||
vgmstream->num_samples = sample_count;
|
||||
vgmstream->coding_type = coding_MTF_IMA;
|
||||
vgmstream->layout_type = channel_count == 1 ? layout_none : layout_interleave;
|
||||
vgmstream->interleave_block_size = 1;
|
||||
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream,streamFile,buffer_offset))
|
||||
goto fail;
|
||||
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
@ -877,6 +877,8 @@ VGMSTREAM* init_vgmstream_xma_ue3(STREAMFILE *sf);
|
||||
|
||||
VGMSTREAM* init_vgmstream_csb(STREAMFILE *sf);
|
||||
|
||||
VGMSTREAM *init_vgmstream_fwse(STREAMFILE *streamFile);
|
||||
|
||||
VGMSTREAM* init_vgmstream_fda(STREAMFILE *sf);
|
||||
|
||||
#endif /*_META_H*/
|
||||
|
@ -486,6 +486,7 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = {
|
||||
init_vgmstream_xssb,
|
||||
init_vgmstream_xma_ue3,
|
||||
init_vgmstream_csb,
|
||||
init_vgmstream_fwse,
|
||||
init_vgmstream_fda,
|
||||
|
||||
/* lowest priority metas (should go after all metas, and TXTH should go before raw formats) */
|
||||
@ -1174,6 +1175,7 @@ int get_vgmstream_samples_per_frame(VGMSTREAM * vgmstream) {
|
||||
case coding_UBI_IMA:
|
||||
case coding_OKI16:
|
||||
case coding_OKI4S:
|
||||
case coding_MTF_IMA:
|
||||
return 1;
|
||||
case coding_PCM4:
|
||||
case coding_PCM4_U:
|
||||
@ -1368,6 +1370,7 @@ int get_vgmstream_frame_size(VGMSTREAM * vgmstream) {
|
||||
case coding_PCFX:
|
||||
case coding_OKI16:
|
||||
case coding_OKI4S:
|
||||
case coding_MTF_IMA:
|
||||
return 0x01;
|
||||
case coding_MS_IMA:
|
||||
case coding_RAD_IMA:
|
||||
@ -1840,6 +1843,12 @@ void decode_vgmstream(VGMSTREAM * vgmstream, int samples_written, int samples_to
|
||||
is_stereo, is_high_first);
|
||||
}
|
||||
break;
|
||||
case coding_MTF_IMA:
|
||||
for (ch = 0; ch < vgmstream->channels; ch++) {
|
||||
decode_mtf_ima(&vgmstream->ch[ch],buffer+samples_written*vgmstream->channels+ch,
|
||||
vgmstream->channels,vgmstream->samples_into_block,samples_to_do);
|
||||
}
|
||||
break;
|
||||
case coding_3DS_IMA:
|
||||
for (ch = 0; ch < vgmstream->channels; ch++) {
|
||||
decode_3ds_ima(&vgmstream->ch[ch],buffer+samples_written*vgmstream->channels+ch,
|
||||
|
@ -143,6 +143,7 @@ typedef enum {
|
||||
coding_AWC_IMA, /* Rockstar AWC IMA ADPCM */
|
||||
coding_UBI_IMA, /* Ubisoft IMA ADPCM */
|
||||
coding_H4M_IMA, /* H4M IMA ADPCM (stereo or mono, high nibble first) */
|
||||
coding_MTF_IMA, /* Capcom MT Framework IMA ADPCM */
|
||||
|
||||
coding_MSADPCM, /* Microsoft ADPCM (stereo/mono) */
|
||||
coding_MSADPCM_int, /* Microsoft ADPCM (mono) */
|
||||
@ -719,6 +720,7 @@ typedef enum {
|
||||
meta_ISB,
|
||||
meta_XSSB,
|
||||
meta_XMA_UE3,
|
||||
meta_FWSE,
|
||||
meta_FDA,
|
||||
|
||||
} meta_t;
|
||||
|
Loading…
Reference in New Issue
Block a user