mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-06 02:14:25 +01:00
commit
48c482bb72
@ -173,25 +173,25 @@ void decode_hevag(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspaci
|
|||||||
if (shift_factor > 12)
|
if (shift_factor > 12)
|
||||||
shift_factor = 9; /* ? */
|
shift_factor = 9; /* ? */
|
||||||
|
|
||||||
|
shift_factor = 20 - shift_factor;
|
||||||
/* decode nibbles */
|
/* decode nibbles */
|
||||||
for (i = first_sample; i < first_sample + samples_to_do; i++) {
|
for (i = first_sample; i < first_sample + samples_to_do; i++) {
|
||||||
int32_t sample = 0, scale = 0;
|
int32_t sample = 0;
|
||||||
|
|
||||||
if (flag < 0x07) { /* with flag 0x07 decoded sample must be 0 */
|
if (flag < 0x07) { /* with flag 0x07 decoded sample must be 0 */
|
||||||
uint8_t nibbles = frame[0x02 + i/2];
|
uint8_t nibbles = frame[0x02 + i/2];
|
||||||
|
|
||||||
scale = i&1 ? /* low nibble first */
|
sample = (i&1 ? /* low nibble first */
|
||||||
get_high_nibble_signed(nibbles):
|
get_high_nibble_signed(nibbles):
|
||||||
get_low_nibble_signed(nibbles);
|
get_low_nibble_signed(nibbles)) << shift_factor; /*scale*/
|
||||||
sample = (hist1 * hevag_coefs[coef_index][0] +
|
sample = ((hist1 * hevag_coefs[coef_index][0] +
|
||||||
hist2 * hevag_coefs[coef_index][1] +
|
hist2 * hevag_coefs[coef_index][1] +
|
||||||
hist3 * hevag_coefs[coef_index][2] +
|
hist3 * hevag_coefs[coef_index][2] +
|
||||||
hist4 * hevag_coefs[coef_index][3] ) / 32;
|
hist4 * hevag_coefs[coef_index][3]) >> 5) + sample;
|
||||||
sample = (sample + (scale << (20 - shift_factor)) + 128) >> 8;
|
sample >>= 8;
|
||||||
sample = clamp16(sample);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
outbuf[sample_count] = sample;
|
outbuf[sample_count] = clamp16(sample); /*clamping*/
|
||||||
sample_count += channelspacing;
|
sample_count += channelspacing;
|
||||||
|
|
||||||
hist4 = hist3;
|
hist4 = hist3;
|
||||||
|
@ -93,22 +93,22 @@ void decode_psx(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing,
|
|||||||
VGM_ASSERT_ONCE(flag > 7,"PS-ADPCM: unknown flag at %x\n", (uint32_t)frame_offset); /* meta should use PSX-badflags */
|
VGM_ASSERT_ONCE(flag > 7,"PS-ADPCM: unknown flag at %x\n", (uint32_t)frame_offset); /* meta should use PSX-badflags */
|
||||||
|
|
||||||
|
|
||||||
|
shift_factor = 20 - shift_factor;
|
||||||
/* decode nibbles */
|
/* decode nibbles */
|
||||||
for (i = first_sample; i < first_sample + samples_to_do; i++) {
|
for (i = first_sample; i < first_sample + samples_to_do; i++) {
|
||||||
int32_t sample = 0;
|
int32_t sample = 0;
|
||||||
|
|
||||||
if (flag < 0x07) { /* with flag 0x07 decoded sample must be 0 */
|
if (flag < 0x07) { /* with flag 0x07 decoded sample must be 0 */
|
||||||
uint8_t nibbles = frame[0x02 + i/2];
|
uint8_t nibbles = frame[0x02 + i/2];
|
||||||
|
|
||||||
sample = i&1 ? /* low nibble first */
|
sample = (i&1 ? /* low nibble first */
|
||||||
(nibbles >> 4) & 0x0f :
|
get_high_nibble_signed(nibbles):
|
||||||
(nibbles >> 0) & 0x0f;
|
get_low_nibble_signed(nibbles)) << shift_factor; /*scale*/
|
||||||
sample = (int16_t)((sample << 12) & 0xf000) >> shift_factor; /* 16b sign extend + scale */
|
sample = sample + (int32_t)((ps_adpcm_coefs_f[coef_index][0]*hist1 + ps_adpcm_coefs_f[coef_index][1]*hist2) * 256.0f);
|
||||||
sample = (int32_t)(sample + ps_adpcm_coefs_f[coef_index][0]*hist1 + ps_adpcm_coefs_f[coef_index][1]*hist2);
|
sample >>= 8;
|
||||||
sample = clamp16(sample);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
outbuf[sample_count] = sample;
|
outbuf[sample_count] = clamp16(sample); /*clamping*/
|
||||||
sample_count += channelspacing;
|
sample_count += channelspacing;
|
||||||
|
|
||||||
hist2 = hist1;
|
hist2 = hist1;
|
||||||
@ -192,7 +192,6 @@ void decode_psx_pivotal(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channe
|
|||||||
uint8_t coef_index, shift_factor;
|
uint8_t coef_index, shift_factor;
|
||||||
int32_t hist1 = stream->adpcm_history1_32;
|
int32_t hist1 = stream->adpcm_history1_32;
|
||||||
int32_t hist2 = stream->adpcm_history2_32;
|
int32_t hist2 = stream->adpcm_history2_32;
|
||||||
float scale;
|
|
||||||
|
|
||||||
|
|
||||||
/* external interleave (variable size), mono */
|
/* external interleave (variable size), mono */
|
||||||
@ -213,21 +212,19 @@ void decode_psx_pivotal(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channe
|
|||||||
if (shift_factor > 12) /* same */
|
if (shift_factor > 12) /* same */
|
||||||
shift_factor = 12;
|
shift_factor = 12;
|
||||||
|
|
||||||
scale = (float)(1.0 / (double)(1 << shift_factor));
|
shift_factor = 20 - shift_factor;
|
||||||
|
|
||||||
|
|
||||||
/* decode nibbles */
|
/* decode nibbles */
|
||||||
for (i = first_sample; i < first_sample + samples_to_do; i++) {
|
for (i = first_sample; i < first_sample + samples_to_do; i++) {
|
||||||
int32_t sample = 0;
|
int32_t sample = 0;
|
||||||
uint8_t nibbles = frame[0x01 + i/2];
|
uint8_t nibbles = frame[0x01 + i/2];
|
||||||
|
|
||||||
sample = !(i&1) ? /* low nibble first */
|
sample = (i&1 ? /* low nibble first */
|
||||||
(nibbles >> 0) & 0x0f :
|
get_high_nibble_signed(nibbles):
|
||||||
(nibbles >> 4) & 0x0f;
|
get_low_nibble_signed(nibbles)) << shift_factor; /*scale*/
|
||||||
sample = (int16_t)((sample << 12) & 0xf000); /* 16b sign extend + default scale */
|
sample = sample + (int32_t)((ps_adpcm_coefs_f[coef_index][0]*hist1 + ps_adpcm_coefs_f[coef_index][1]*hist2) * 256.0f); /* actually substracts negative coefs but whatevs */
|
||||||
sample = sample*scale + ps_adpcm_coefs_f[coef_index][0]*hist1 + ps_adpcm_coefs_f[coef_index][1]*hist2; /* actually substracts negative coefs but whatevs */
|
sample >>= 8;
|
||||||
|
|
||||||
outbuf[sample_count] = clamp16(sample);
|
outbuf[sample_count] = clamp16(sample); /*clamping*/
|
||||||
sample_count += channelspacing;
|
sample_count += channelspacing;
|
||||||
|
|
||||||
hist2 = hist1;
|
hist2 = hist1;
|
||||||
|
Loading…
Reference in New Issue
Block a user