1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-28 20:53:54 +02:00

avfilter/af_sofalizer: use SIMD in compensate_volume()

Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
Paul B Mahol 2015-12-16 14:44:20 +01:00
parent a2f2abc889
commit fa2c1eab95

View File

@ -567,7 +567,7 @@ static int compensate_volume(AVFilterContext *ctx)
float compensate; float compensate;
float energy = 0; float energy = 0;
float *ir; float *ir;
int m, j; int m;
if (s->sofa.ncid) { if (s->sofa.ncid) {
/* find IR at front center position in the SOFA file (IR closest to 0°,0°,1m) */ /* find IR at front center position in the SOFA file (IR closest to 0°,0°,1m) */
@ -575,15 +575,17 @@ static int compensate_volume(AVFilterContext *ctx)
m = find_m(s, 0, 0, 1); m = find_m(s, 0, 0, 1);
/* get energy of that IR and compensate volume */ /* get energy of that IR and compensate volume */
ir = sofa->data_ir + 2 * m * sofa->n_samples; ir = sofa->data_ir + 2 * m * sofa->n_samples;
for (j = 0; j < sofa->n_samples; j++) { if (sofa->n_samples & 31) {
energy += *(ir + j) * *(ir + j); energy = avpriv_scalarproduct_float_c(ir, ir, sofa->n_samples);
} else {
energy = s->fdsp->scalarproduct_float(ir, ir, sofa->n_samples);
} }
compensate = 256 / (sofa->n_samples * sqrt(energy)); compensate = 256 / (sofa->n_samples * sqrt(energy));
av_log(ctx, AV_LOG_DEBUG, "Compensate-factor: %f\n", compensate); av_log(ctx, AV_LOG_DEBUG, "Compensate-factor: %f\n", compensate);
ir = sofa->data_ir; ir = sofa->data_ir;
for (j = 0; j < sofa->n_samples * sofa->m_dim * 2; j++) { /* apply volume compensation to IRs */
ir[j] *= compensate; /* apply volume compensation to IRs */ s->fdsp->vector_fmul_scalar(ir, ir, compensate, sofa->n_samples * sofa->m_dim * 2);
} emms_c();
} }
return 0; return 0;