summaryrefslogtreecommitdiff
path: root/libavfilter/af_sofalizer.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2015-12-16 14:44:20 +0100
committerPaul B Mahol <onemda@gmail.com>2015-12-16 15:00:14 +0100
commitfa2c1eab95557ea9a1cbfa560178d9e3f4b452b2 (patch)
tree2697dfba7b9c2d02b28fc893948f9c5658615850 /libavfilter/af_sofalizer.c
parenta2f2abc88920dd62a6a8423e2ec5b8f22efb0d17 (diff)
avfilter/af_sofalizer: use SIMD in compensate_volume()
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavfilter/af_sofalizer.c')
-rw-r--r--libavfilter/af_sofalizer.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/libavfilter/af_sofalizer.c b/libavfilter/af_sofalizer.c
index 6bf4306489..b2ba52508e 100644
--- a/libavfilter/af_sofalizer.c
+++ b/libavfilter/af_sofalizer.c
@@ -567,7 +567,7 @@ static int compensate_volume(AVFilterContext *ctx)
float compensate;
float energy = 0;
float *ir;
- int m, j;
+ int m;
if (s->sofa.ncid) {
/* 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);
/* get energy of that IR and compensate volume */
ir = sofa->data_ir + 2 * m * sofa->n_samples;
- for (j = 0; j < sofa->n_samples; j++) {
- energy += *(ir + j) * *(ir + j);
+ if (sofa->n_samples & 31) {
+ 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));
av_log(ctx, AV_LOG_DEBUG, "Compensate-factor: %f\n", compensate);
ir = sofa->data_ir;
- for (j = 0; j < sofa->n_samples * sofa->m_dim * 2; j++) {
- ir[j] *= compensate; /* apply volume compensation to IRs */
- }
+ /* apply volume compensation to IRs */
+ s->fdsp->vector_fmul_scalar(ir, ir, compensate, sofa->n_samples * sofa->m_dim * 2);
+ emms_c();
}
return 0;