mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-19 16:08:40 +01:00
Fixed Ubi alt IMA decoding [Splinter Cell: Essentials (PSP)]
This commit is contained in:
parent
1a0913d90d
commit
b0b7b20bf4
@ -11,7 +11,7 @@
|
||||
* - expand type: IMA style or variations; low or high nibble first
|
||||
*/
|
||||
|
||||
static const int ADPCMTable[89] = {
|
||||
static const int ADPCMTable[90] = {
|
||||
7, 8, 9, 10, 11, 12, 13, 14,
|
||||
16, 17, 19, 21, 23, 25, 28, 31,
|
||||
34, 37, 41, 45, 50, 55, 60, 66,
|
||||
@ -23,7 +23,9 @@ static const int ADPCMTable[89] = {
|
||||
3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484,
|
||||
7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
|
||||
15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794,
|
||||
32767
|
||||
32767,
|
||||
|
||||
0 /* garbage value for Ubisoft IMA (see blocked_ubi_sce.c) */
|
||||
};
|
||||
|
||||
static const int IMA_IndexTable[16] = {
|
||||
@ -1054,10 +1056,14 @@ void decode_ubi_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspa
|
||||
|
||||
if (has_header) {
|
||||
first_sample -= 10; //todo fix hack (needed to adjust nibble offset below)
|
||||
}
|
||||
|
||||
if (step_index < 0) step_index=0;
|
||||
if (step_index > 88) step_index=88;
|
||||
if (step_index < 0) step_index = 0;
|
||||
if (step_index > 88) step_index = 88;
|
||||
} else {
|
||||
if (step_index < 0) step_index = 0;
|
||||
if (step_index > 89) step_index = 89;
|
||||
}
|
||||
|
||||
|
||||
for (i = first_sample; i < first_sample + samples_to_do; i++, sample_count += channelspacing) {
|
||||
off_t byte_offset = channelspacing == 1 ?
|
||||
|
@ -44,13 +44,13 @@ void block_update_ubi_sce(off_t block_offset, VGMSTREAM* vgmstream) {
|
||||
vgmstream->ch[i].adpcm_step_index = read_32bitLE(block_offset + header_size * i + 0x04, sf);
|
||||
vgmstream->ch[i].adpcm_history1_32 = read_32bitLE(block_offset + header_size * i + 0x08, sf);
|
||||
|
||||
/* TODO figure out
|
||||
* First step seems to always be a special value for the decoder, unsure of meaning.
|
||||
* 0 = too quiet and max = 88 = waveform starts a bit off and clicky. First hist is usually +-1,
|
||||
* other frames look, fine not sure what are they aiming for.
|
||||
*/
|
||||
/* First step is always 0x500, not sure if it's a bug or a feature but the game just takes it as is and
|
||||
* ends up reading 0 from out-of-bounds memory area which causes a pop at the start. Yikes.
|
||||
* It gets clampled later so the rest of the sound plays ok.
|
||||
* We put 89 here as our special index which contains 0 to simulate this.
|
||||
*/
|
||||
if (vgmstream->ch[i].adpcm_step_index == 0x500) {
|
||||
vgmstream->ch[i].adpcm_step_index = 88;
|
||||
vgmstream->ch[i].adpcm_step_index = 89;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user