* Version 0.4 Leaky Normalized LMS - pre whitening algorithm
*/
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
#include <math.h>
#include <string.h>
+#include <stdint.h>
#include <pulse/xmalloc.h>
#include "adrian-aec.h"
#ifndef DISABLE_ORC
-#include "adrian-aec-orc-orc-gen.h"
+#include "adrian-aec-orc-gen.h"
#endif
#ifdef __SSE__
return sum0 + sum1;
}
-static REAL dotp_sse(REAL a[], REAL b[]) __attribute__((noinline));
static REAL dotp_sse(REAL a[], REAL b[])
{
#ifdef __SSE__
a->hangover = 0;
memset(a->x, 0, sizeof(a->x));
memset(a->xf, 0, sizeof(a->xf));
- memset(a->w, 0, sizeof(a->w));
+ memset(a->w_arr, 0, sizeof(a->w_arr));
a->j = NLMS_EXT;
a->delta = 0.0f;
AEC_setambient(a, NoiseFloor);
a->dumpcnt = 0;
memset(a->ws, 0, sizeof(a->ws));
- if (have_vector)
+ if (have_vector) {
+ /* Get a 16-byte aligned location */
+ a->w = (REAL *) (((uintptr_t) a->w_arr) + (((uintptr_t) a->w_arr) % 16));
a->dotp = dotp_sse;
- else
+ } else {
+ /* We don't care about alignment, just use the array as-is */
+ a->w = a->w_arr;
a->dotp = dotp;
+ }
return a;
}
// mapped to 1.0 with a limited linear function.
static float AEC_dtd(AEC *a, REAL d, REAL x)
{
- float stepsize;
- float ratio, M;
+ float ratio, stepsize;
// fast near-end and far-end average
a->dfast += ALPHAFAST * (fabsf(d) - a->dfast);
// ratio of NFRs
ratio = (a->dfast * a->xslow) / (a->dslow * a->xfast);
- // begrenzte lineare Kennlinie
- M = (STEPY2 - STEPY1) / (STEPX2 - STEPX1);
- if (ratio < STEPX1) {
+ // Linear interpolation with clamping at the limits
+ if (ratio < STEPX1)
stepsize = STEPY1;
- } else if (ratio > STEPX2) {
+ else if (ratio > STEPX2)
stepsize = STEPY2;
- } else {
- // Punktrichtungsform einer Geraden
- stepsize = M * (ratio - STEPX1) + STEPY1;
- }
+ else
+ stepsize = STEPY1 + (STEPY2 - STEPY1) * (ratio - STEPX1) / (STEPX2 - STEPX1);
return stepsize;
}