Name gain shift/scaling better

This commit is contained in:
xperia64
2022-06-20 17:49:23 -04:00
committed by Tillmann Karras
parent 512da86b1a
commit cd77e682ca
2 changed files with 15 additions and 15 deletions

View File

@ -190,16 +190,16 @@ u16 Accelerator::ReadSample(const s16* coefs)
{ {
// Gain seems to only apply for PCM decoding // Gain seems to only apply for PCM decoding
u8 gain_shift = 0; u8 gain_shift = 0;
switch (m_sample_format.gain_cfg) switch (m_sample_format.gain_scale)
{ {
case FormatGainCfg::GainShift11: case FormatGainScale::GainScale2048:
gain_shift = 11; gain_shift = 11; // x / 2048 = x >> 11
break; break;
case FormatGainCfg::GainShift0: case FormatGainScale::GainScale1:
gain_shift = 0; gain_shift = 0; // x / 1 = x >> 0
break; break;
case FormatGainCfg::GainShift16: case FormatGainScale::GainScale65536:
gain_shift = 16; gain_shift = 16; // x / 65536 = x >> 16
break; break;
default: default:
ERROR_LOG_FMT(DSPLLE, "dsp_read_accelerator_sample() invalid gain mode in format {:#x}", ERROR_LOG_FMT(DSPLLE, "dsp_read_accelerator_sample() invalid gain mode in format {:#x}",

View File

@ -70,14 +70,14 @@ protected:
MMIOPCMInc = 3 // PCM reads from ACIN, ACCA increments MMIOPCMInc = 3 // PCM reads from ACIN, ACCA increments
}; };
// When reading samples (at least in PCM mode), they are multiplied by the gain, then shifted // When reading samples (at least in PCM mode), they are multiplied by the gain, then divided by
// right by an amount dependent on this config // the value specified here
enum class FormatGainCfg : u16 enum class FormatGainScale : u16
{ {
GainShift11 = 0, GainScale2048 = 0,
GainShift0 = 1, GainScale1 = 1,
GainShift16 = 2, GainScale65536 = 2,
GainInvalid = 3 GainScaleInvalid = 3
}; };
union SampleFormat union SampleFormat
@ -85,7 +85,7 @@ protected:
u16 hex; u16 hex;
BitField<0, 2, FormatSize> size; BitField<0, 2, FormatSize> size;
BitField<2, 2, FormatDecode> decode; BitField<2, 2, FormatDecode> decode;
BitField<4, 2, FormatGainCfg> gain_cfg; BitField<4, 2, FormatGainScale> gain_scale;
BitField<6, 10, u16> unk; BitField<6, 10, u16> unk;
} m_sample_format{0}; } m_sample_format{0};