mirror of https://github.com/thesofproject/sof.git
Volume: optimize volume module for better performance
Volume module support per channel volume adjust, a dedicated circular buffer designed for store per channel gain 4 times for SIMD calculation. However, it is not must to store gain for each time calculation, add a flag to indicate and decide the copy action. Below is the logs for before and after opt, around 5% optimized: perf comp_copy samples 48 period 1000 cpu avg 249 peak 254 perf comp_copy samples 48 period 1000 cpu avg 236 peak 245 Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
This commit is contained in:
parent
14d173b4ae
commit
066818eb08
|
@ -275,6 +275,7 @@ static void volume_ramp(struct processing_module *mod)
|
|||
int i;
|
||||
bool ramp_finished = true;
|
||||
|
||||
cd->copy_gain = true;
|
||||
/* No need to ramp in idle state, jump volume to request. */
|
||||
if (dev->state == COMP_STATE_READY) {
|
||||
for (i = 0; i < PLATFORM_MAX_CHANNELS; i++)
|
||||
|
@ -361,6 +362,7 @@ static void reset_state(struct vol_data *cd)
|
|||
cd->vol_ramp_frames = 0;
|
||||
cd->vol_ramp_elapsed_frames = 0;
|
||||
cd->sample_rate = 0;
|
||||
cd->copy_gain = true;
|
||||
}
|
||||
|
||||
#if CONFIG_IPC_MAJOR_3
|
||||
|
|
|
@ -42,6 +42,7 @@ static void vol_store_gain(struct vol_data *cd, const int channels_count)
|
|||
cd->vol[i + channels_count * 2] = cd->volume[i];
|
||||
cd->vol[i + channels_count * 3] = cd->volume[i];
|
||||
}
|
||||
cd->copy_gain = false;
|
||||
}
|
||||
|
||||
static inline void peak_vol_calc(struct vol_data *cd, ae_f32x2 out_sample, size_t channel)
|
||||
|
@ -84,7 +85,9 @@ static void vol_s24_to_s24_s32(struct processing_module *mod, struct input_strea
|
|||
* error loading of volume gain while the cd->vol would be set
|
||||
* as circular buffer
|
||||
*/
|
||||
vol_store_gain(cd, channels_count);
|
||||
if (cd->copy_gain)
|
||||
vol_store_gain(cd, channels_count);
|
||||
|
||||
buf = (ae_f32x2 *)cd->vol;
|
||||
buf_end = (ae_f32x2 *)(cd->vol + channels_count * 2);
|
||||
vol = (ae_f32x2 *)buf;
|
||||
|
@ -175,7 +178,9 @@ static void vol_s32_to_s24_s32(struct processing_module *mod, struct input_strea
|
|||
* error loading of volume gain while the cd->vol would be set
|
||||
* as circular buffer
|
||||
*/
|
||||
vol_store_gain(cd, channels_count);
|
||||
if (cd->copy_gain)
|
||||
vol_store_gain(cd, channels_count);
|
||||
|
||||
buf = (ae_f32x2 *)cd->vol;
|
||||
buf_end = (ae_f32x2 *)(cd->vol + channels_count * 2);
|
||||
vol = (ae_f32x2 *)buf;
|
||||
|
@ -270,7 +275,9 @@ static void vol_s16_to_s16(struct processing_module *mod, struct input_stream_bu
|
|||
* error loading of volume gain while the cd->vol would be set
|
||||
* as circular buffer
|
||||
*/
|
||||
vol_store_gain(cd, channels_count);
|
||||
if (cd->copy_gain)
|
||||
vol_store_gain(cd, channels_count);
|
||||
|
||||
buf = (ae_f32x2 *)cd->vol;
|
||||
buf_end = (ae_f32x2 *)(cd->vol + channels_count * 4);
|
||||
vol = buf;
|
||||
|
|
|
@ -157,6 +157,7 @@ struct vol_data {
|
|||
vol_scale_func scale_vol; /**< volume processing function */
|
||||
vol_zc_func zc_get; /**< function getting nearest zero crossing frame */
|
||||
vol_ramp_func ramp_func; /**< function for ramp shape */
|
||||
bool copy_gain; /**< control copy gain or not */
|
||||
};
|
||||
|
||||
/** \brief Volume processing functions map. */
|
||||
|
|
Loading…
Reference in New Issue