lavfi: get rid of bespoke double scalar products

release/7.1
Rémi Denis-Courmont 7 months ago
parent 73c278d270
commit b114952030
  1. 14
      libavfilter/aap_template.c
  2. 16
      libavfilter/anlms_template.c
  3. 14
      libavfilter/arls_template.c

@ -36,18 +36,6 @@
#define fn2(a,b) fn3(a,b) #define fn2(a,b) fn3(a,b)
#define fn(a) fn2(a, SAMPLE_FORMAT) #define fn(a) fn2(a, SAMPLE_FORMAT)
#if DEPTH == 64
static double scalarproduct_double(const double *v1, const double *v2, int len)
{
double p = 0.0;
for (int i = 0; i < len; i++)
p += v1[i] * v2[i];
return p;
}
#endif
static ftype fn(fir_sample)(AudioAPContext *s, ftype sample, ftype *delay, static ftype fn(fir_sample)(AudioAPContext *s, ftype sample, ftype *delay,
ftype *coeffs, ftype *tmp, int *offset) ftype *coeffs, ftype *tmp, int *offset)
{ {
@ -60,7 +48,7 @@ static ftype fn(fir_sample)(AudioAPContext *s, ftype sample, ftype *delay,
#if DEPTH == 32 #if DEPTH == 32
output = s->fdsp->scalarproduct_float(delay, tmp, s->kernel_size); output = s->fdsp->scalarproduct_float(delay, tmp, s->kernel_size);
#else #else
output = scalarproduct_double(delay, tmp, s->kernel_size); output = s->fdsp->scalarproduct_double(delay, tmp, s->kernel_size);
#endif #endif
if (--(*offset) < 0) if (--(*offset) < 0)

@ -33,18 +33,6 @@
#define fn2(a,b) fn3(a,b) #define fn2(a,b) fn3(a,b)
#define fn(a) fn2(a, SAMPLE_FORMAT) #define fn(a) fn2(a, SAMPLE_FORMAT)
#if DEPTH == 64
static double scalarproduct_double(const double *v1, const double *v2, int len)
{
double p = 0.0;
for (int i = 0; i < len; i++)
p += v1[i] * v2[i];
return p;
}
#endif
static ftype fn(fir_sample)(AudioNLMSContext *s, ftype sample, ftype *delay, static ftype fn(fir_sample)(AudioNLMSContext *s, ftype sample, ftype *delay,
ftype *coeffs, ftype *tmp, int *offset) ftype *coeffs, ftype *tmp, int *offset)
{ {
@ -58,7 +46,7 @@ static ftype fn(fir_sample)(AudioNLMSContext *s, ftype sample, ftype *delay,
#if DEPTH == 32 #if DEPTH == 32
output = s->fdsp->scalarproduct_float(delay, tmp, s->kernel_size); output = s->fdsp->scalarproduct_float(delay, tmp, s->kernel_size);
#else #else
output = scalarproduct_double(delay, tmp, s->kernel_size); output = s->fdsp->scalarproduct_double(delay, tmp, s->kernel_size);
#endif #endif
if (--(*offset) < 0) if (--(*offset) < 0)
@ -85,7 +73,7 @@ static ftype fn(process_sample)(AudioNLMSContext *s, ftype input, ftype desired,
#if DEPTH == 32 #if DEPTH == 32
sum = s->fdsp->scalarproduct_float(delay, delay, s->kernel_size); sum = s->fdsp->scalarproduct_float(delay, delay, s->kernel_size);
#else #else
sum = scalarproduct_double(delay, delay, s->kernel_size); sum = s->fdsp->scalarproduct_double(delay, delay, s->kernel_size);
#endif #endif
norm = s->eps + sum; norm = s->eps + sum;
b = mu * e / norm; b = mu * e / norm;

@ -39,18 +39,6 @@
#define fn2(a,b) fn3(a,b) #define fn2(a,b) fn3(a,b)
#define fn(a) fn2(a, SAMPLE_FORMAT) #define fn(a) fn2(a, SAMPLE_FORMAT)
#if DEPTH == 64
static double scalarproduct_double(const double *v1, const double *v2, int len)
{
double p = 0.0;
for (int i = 0; i < len; i++)
p += v1[i] * v2[i];
return p;
}
#endif
static ftype fn(fir_sample)(AudioRLSContext *s, ftype sample, ftype *delay, static ftype fn(fir_sample)(AudioRLSContext *s, ftype sample, ftype *delay,
ftype *coeffs, ftype *tmp, int *offset) ftype *coeffs, ftype *tmp, int *offset)
{ {
@ -64,7 +52,7 @@ static ftype fn(fir_sample)(AudioRLSContext *s, ftype sample, ftype *delay,
#if DEPTH == 32 #if DEPTH == 32
output = s->fdsp->scalarproduct_float(delay, tmp, s->kernel_size); output = s->fdsp->scalarproduct_float(delay, tmp, s->kernel_size);
#else #else
output = scalarproduct_double(delay, tmp, s->kernel_size); output = s->fdsp->scalarproduct_double(delay, tmp, s->kernel_size);
#endif #endif
if (--(*offset) < 0) if (--(*offset) < 0)

Loading…
Cancel
Save