sof: drc: Use one_over_attack_frames in replace of attack_frames

Replaced the config coefficient "attack_frames" by "one_over_attack_frames"
(=1/attack_frames). It is because only "one_over_attack_frames" is used by
firmware and it could save a division operand by the replacement.

Signed-off-by: Pin-chih Lin <johnylin@google.com>
This commit is contained in:
Pin-chih Lin 2020-10-19 11:16:35 +08:00 committed by Curtis Malainey
parent 03b1fba732
commit 91998d7d01
3 changed files with 4 additions and 4 deletions

View File

@ -138,7 +138,7 @@ static void drc_update_envelope(struct drc_state *state, const struct sof_drc_pa
const float kC = Q_CONVERT_QTOF(p->kC, 12);
const float kD = Q_CONVERT_QTOF(p->kD, 12);
const float kE = Q_CONVERT_QTOF(p->kE, 12);
const float attack_frames = Q_CONVERT_QTOF(p->attack_frames, 20);
const float one_over_attack_frames = Q_CONVERT_QTOF(p->one_over_attack_frames, 30);
/* Calculate desired gain */
float desired_gain = Q_CONVERT_QTOF(state->detector_average, 30);
@ -212,7 +212,7 @@ static void drc_update_envelope(struct drc_state *state, const struct sof_drc_pa
MAX(0.5f, Q_CONVERT_QTOF(state->max_attack_compression_diff_db, 24));
x = 0.25f / eff_atten_diff_db;
envelope_rate = 1 - warp_powf(x, 1 / attack_frames);
envelope_rate = 1 - warp_powf(x, one_over_attack_frames);
}
state->envelope_rate = Q_CONVERT_FLOAT(envelope_rate, 30);

View File

@ -45,7 +45,7 @@ struct sof_drc_params {
int32_t ratio_base; /* Q2.30 */
int32_t master_linear_gain; /* Q8.24 */
int32_t attack_frames; /* Q12.20 */
int32_t one_over_attack_frames; /* Q2.30 */
int32_t sat_release_frames_inv_neg; /* Q2.30 */
int32_t sat_release_rate_at_neg_two_db; /* Q2.30 */

View File

@ -1,7 +1,7 @@
# Exported Control Bytes 03-Nov-2020
CONTROLBYTES_PRIV(DRC_priv,
` bytes "0x53,0x4f,0x46,0x00,0x00,0x00,0x00,0x00,'
` 0x6c,0x00,0x00,0x00,0x00,0x10,0x01,0x03,'
` 0x6c,0x00,0x00,0x00,0x00,0x20,0x01,0x03,'
` 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,'
` 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,'
` 0x6c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,'