mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-12 01:30:49 +01:00
Add Blitz Games .ima and improve decoder [Lilo & Stitch (PC)]
This commit is contained in:
parent
de294a5a5e
commit
badf3477e3
@ -255,8 +255,8 @@ static void blitz_ima_expand_nibble(VGMSTREAMCHANNEL * stream, off_t byte_offset
|
||||
delta = (step >> 1) + delta * step; /* custom */
|
||||
sample_decoded += delta;
|
||||
|
||||
/* somehow the exe tries to clamp hist, but actually doesn't (bug?),
|
||||
* not sure if pcm buffer would be clamped outside though */
|
||||
/* in Zapper somehow the exe tries to clamp hist but actually doesn't (bug? not in Lilo & Stitch),
|
||||
* seems the pcm buffer must be clamped outside though to fix some scratchiness */
|
||||
*hist1 = sample_decoded;//clamp16(sample_decoded);
|
||||
*step_index += IMA_IndexTable[sample_nibble];
|
||||
if (*step_index < 0) *step_index=0;
|
||||
@ -445,7 +445,7 @@ void decode_blitz_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channels
|
||||
int nibble_shift = (i&1?4:0); //low nibble first
|
||||
|
||||
blitz_ima_expand_nibble(stream, byte_offset,nibble_shift, &hist1, &step_index);
|
||||
outbuf[sample_count] = (short)(hist1);
|
||||
outbuf[sample_count] = (short)clamp16(hist1);
|
||||
}
|
||||
|
||||
stream->adpcm_history1_32 = hist1;
|
||||
|
@ -198,6 +198,7 @@ static const char* extension_list[] = {
|
||||
"ikm",
|
||||
"ild",
|
||||
"ilv", //txth/reserved [Star Wars Episode III (PS2)]
|
||||
"ima",
|
||||
"imc",
|
||||
"int",
|
||||
"isd",
|
||||
@ -1192,6 +1193,7 @@ static const meta_info meta_info_list[] = {
|
||||
{meta_XAVS, "Reflections XAVS header"},
|
||||
{meta_PSF, "Pivotal PSF header"},
|
||||
{meta_DSP_ITL_i, "Infernal .ITL DSP header"},
|
||||
{meta_IMA, "Blitz Games .IMA header"},
|
||||
|
||||
};
|
||||
|
||||
|
@ -708,6 +708,10 @@
|
||||
RelativePath=".\meta\nub_idsp.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\ima.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\imc.c"
|
||||
>
|
||||
|
@ -164,6 +164,7 @@
|
||||
<ClCompile Include="meta\ezw.c" />
|
||||
<ClCompile Include="meta\ffmpeg.c" />
|
||||
<ClCompile Include="meta\g1l.c" />
|
||||
<ClCompile Include="meta\ima.c" />
|
||||
<ClCompile Include="meta\imc.c" />
|
||||
<ClCompile Include="meta\ios_psnd.c" />
|
||||
<ClCompile Include="meta\ktss.c" />
|
||||
|
@ -1447,6 +1447,9 @@
|
||||
<ClCompile Include="meta\ios_psnd.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meta\ima.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meta\imc.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
52
src/meta/ima.c
Normal file
52
src/meta/ima.c
Normal file
@ -0,0 +1,52 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
|
||||
/* .IMA - Blitz Games early games [Lilo & Stitch: Trouble in Paradise (PC)] */
|
||||
VGMSTREAM * init_vgmstream_ima(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
int loop_flag, channel_count, num_samples, sample_rate;
|
||||
|
||||
|
||||
/* checks */
|
||||
if (!check_extensions(streamFile, "ima"))
|
||||
goto fail;
|
||||
|
||||
if (read_32bitBE(0x00,streamFile) != 0x02000000) /* version? */
|
||||
goto fail;
|
||||
if (read_32bitBE(0x04,streamFile) != 0)
|
||||
goto fail;
|
||||
|
||||
num_samples = read_32bitLE(0x08, streamFile);
|
||||
channel_count = read_32bitLE(0x0c,streamFile);
|
||||
sample_rate = read_32bitLE(0x10, streamFile);
|
||||
|
||||
loop_flag = 0;
|
||||
start_offset = 0x14;
|
||||
|
||||
if (channel_count > 1) /* unknown interleave */
|
||||
goto fail;
|
||||
if (num_samples != ima_bytes_to_samples(get_streamfile_size(streamFile) - start_offset, channel_count))
|
||||
goto fail;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count, loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->meta_type = meta_IMA;
|
||||
vgmstream->sample_rate = sample_rate;
|
||||
|
||||
vgmstream->coding_type = coding_BLITZ_IMA;
|
||||
vgmstream->layout_type = layout_none;
|
||||
|
||||
vgmstream->num_samples = num_samples;
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
@ -858,4 +858,6 @@ VGMSTREAM * init_vgmstream_psf_single(STREAMFILE * streamFile);
|
||||
VGMSTREAM * init_vgmstream_psf_segmented(STREAMFILE * streamFile);
|
||||
VGMSTREAM * init_vgmstream_sch(STREAMFILE * streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_ima(STREAMFILE * streamFile);
|
||||
|
||||
#endif /*_META_H*/
|
||||
|
@ -472,6 +472,7 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = {
|
||||
init_vgmstream_psf_segmented,
|
||||
init_vgmstream_dsp_itl,
|
||||
init_vgmstream_sch,
|
||||
init_vgmstream_ima,
|
||||
|
||||
/* 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 */
|
||||
|
@ -714,6 +714,7 @@ typedef enum {
|
||||
meta_XAVS,
|
||||
meta_PSF,
|
||||
meta_DSP_ITL_i,
|
||||
meta_IMA,
|
||||
|
||||
} meta_t;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user