webRTC中回声消除(AEC)模块编译时aec_rdft.c文件报错:

webRTC中回声消除(AEC)模块编译时aec_rdft.c文件报错。

原因是:

局部变量ip跟全局变量冲突的问题,可以将局部变量重新命名一下,就可以通过编译了。

aec_rdft.c修改以后文件代码为:

/*
* http://www.kurims.kyoto-u.ac.jp/~ooura/fft.html
* Copyright Takuya OOURA, 1996-2001
*
* You may use, copy, modify and distribute this code for any purpose (include
* commercial use) and without fee. Please refer to this package when you modify
* this code.
*
* Changes by the WebRTC authors:
* - Trivial type modifications.
* - Minimal code subset to do rdft of length 128.
* - Optimizations because of known length.
*
* All changes are covered by the WebRTC license and IP grant:
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/ #include "webrtc/modules/audio_processing/aec/aec_rdft.h" #include <math.h> #include "webrtc/system_wrappers/interface/cpu_features_wrapper.h"
#include "webrtc/typedefs.h" // constants shared by all paths (C, SSE2).
float rdft_w[];
// constants used by the C path.
float rdft_wk3ri_first[];
float rdft_wk3ri_second[];
// constants used by SSE2 but initialized in C path.
ALIGN16_BEG float ALIGN16_END rdft_wk1r[];
ALIGN16_BEG float ALIGN16_END rdft_wk2r[];
ALIGN16_BEG float ALIGN16_END rdft_wk3r[];
ALIGN16_BEG float ALIGN16_END rdft_wk1i[];
ALIGN16_BEG float ALIGN16_END rdft_wk2i[];
ALIGN16_BEG float ALIGN16_END rdft_wk3i[];
ALIGN16_BEG float ALIGN16_END cftmdl_wk1r[]; static int ip[]; static void bitrv2_32(int* ip1, float* a) {
const int n = ;
int j, j1, k, k1, m, m2;
float xr, xi, yr, yi; ip1[] = ;
{
int l = n;
m = ;
while ((m << ) < l) {
l >>= ;
for (j = ; j < m; j++) {
ip1[m + j] = ip1[j] + l;
}
m <<= ;
}
}
m2 = * m;
for (k = ; k < m; k++) {
for (j = ; j < k; j++) {
j1 = * j + ip1[k];
k1 = * k + ip1[j];
xr = a[j1];
xi = a[j1 + ];
yr = a[k1];
yi = a[k1 + ];
a[j1] = yr;
a[j1 + ] = yi;
a[k1] = xr;
a[k1 + ] = xi;
j1 += m2;
k1 += * m2;
xr = a[j1];
xi = a[j1 + ];
yr = a[k1];
yi = a[k1 + ];
a[j1] = yr;
a[j1 + ] = yi;
a[k1] = xr;
a[k1 + ] = xi;
j1 += m2;
k1 -= m2;
xr = a[j1];
xi = a[j1 + ];
yr = a[k1];
yi = a[k1 + ];
a[j1] = yr;
a[j1 + ] = yi;
a[k1] = xr;
a[k1 + ] = xi;
j1 += m2;
k1 += * m2;
xr = a[j1];
xi = a[j1 + ];
yr = a[k1];
yi = a[k1 + ];
a[j1] = yr;
a[j1 + ] = yi;
a[k1] = xr;
a[k1 + ] = xi;
}
j1 = * k + m2 + ip1[k];
k1 = j1 + m2;
xr = a[j1];
xi = a[j1 + ];
yr = a[k1];
yi = a[k1 + ];
a[j1] = yr;
a[j1 + ] = yi;
a[k1] = xr;
a[k1 + ] = xi;
}
} static void bitrv2_128(float* a) {
/*
Following things have been attempted but are no faster:
(a) Storing the swap indexes in a LUT (index calculations are done
for 'free' while waiting on memory/L1).
(b) Consolidate the load/store of two consecutive floats by a 64 bit
integer (execution is memory/L1 bound).
(c) Do a mix of floats and 64 bit integer to maximize register
utilization (execution is memory/L1 bound).
(d) Replacing ip[i] by ((k<<31)>>25) + ((k >> 1)<<5).
(e) Hard-coding of the offsets to completely eliminates index
calculations.
*/ unsigned int j, j1, k, k1;
float xr, xi, yr, yi; static const int ip2[] = {, , , };
for (k = ; k < ; k++) {
for (j = ; j < k; j++) {
j1 = * j + ip2[k];
k1 = * k + ip2[j];
xr = a[j1 + ];
xi = a[j1 + ];
yr = a[k1 + ];
yi = a[k1 + ];
a[j1 + ] = yr;
a[j1 + ] = yi;
a[k1 + ] = xr;
a[k1 + ] = xi;
j1 += ;
k1 += ;
xr = a[j1 + ];
xi = a[j1 + ];
yr = a[k1 + ];
yi = a[k1 + ];
a[j1 + ] = yr;
a[j1 + ] = yi;
a[k1 + ] = xr;
a[k1 + ] = xi;
j1 += ;
k1 -= ;
xr = a[j1 + ];
xi = a[j1 + ];
yr = a[k1 + ];
yi = a[k1 + ];
a[j1 + ] = yr;
a[j1 + ] = yi;
a[k1 + ] = xr;
a[k1 + ] = xi;
j1 += ;
k1 += ;
xr = a[j1 + ];
xi = a[j1 + ];
yr = a[k1 + ];
yi = a[k1 + ];
a[j1 + ] = yr;
a[j1 + ] = yi;
a[k1 + ] = xr;
a[k1 + ] = xi;
}
j1 = * k + + ip2[k];
k1 = j1 + ;
xr = a[j1 + ];
xi = a[j1 + ];
yr = a[k1 + ];
yi = a[k1 + ];
a[j1 + ] = yr;
a[j1 + ] = yi;
a[k1 + ] = xr;
a[k1 + ] = xi;
}
} static void makewt_32(void) {
const int nw = ;
int j, nwh;
float delta, x, y; ip[] = nw;
ip[] = ;
nwh = nw >> ;
delta = atanf(1.0f) / nwh;
rdft_w[] = ;
rdft_w[] = ;
rdft_w[nwh] = cosf(delta * nwh);
rdft_w[nwh + ] = rdft_w[nwh];
for (j = ; j < nwh; j += ) {
x = cosf(delta * j);
y = sinf(delta * j);
rdft_w[j] = x;
rdft_w[j + ] = y;
rdft_w[nw - j] = y;
rdft_w[nw - j + ] = x;
}
bitrv2_32(ip + , rdft_w); // pre-calculate constants used by cft1st_128 and cftmdl_128...
cftmdl_wk1r[] = rdft_w[];
cftmdl_wk1r[] = rdft_w[];
cftmdl_wk1r[] = rdft_w[];
cftmdl_wk1r[] = -rdft_w[];
{
int k1; for (k1 = , j = ; j < ; j += , k1 += ) {
const int k2 = * k1;
const float wk2r = rdft_w[k1 + ];
const float wk2i = rdft_w[k1 + ];
float wk1r, wk1i;
// ... scalar version.
wk1r = rdft_w[k2 + ];
wk1i = rdft_w[k2 + ];
rdft_wk3ri_first[k1 + ] = wk1r - * wk2i * wk1i;
rdft_wk3ri_first[k1 + ] = * wk2i * wk1r - wk1i;
wk1r = rdft_w[k2 + ];
wk1i = rdft_w[k2 + ];
rdft_wk3ri_second[k1 + ] = wk1r - * wk2r * wk1i;
rdft_wk3ri_second[k1 + ] = * wk2r * wk1r - wk1i;
// ... vector version.
rdft_wk1r[k2 + ] = rdft_w[k2 + ];
rdft_wk1r[k2 + ] = rdft_w[k2 + ];
rdft_wk1r[k2 + ] = rdft_w[k2 + ];
rdft_wk1r[k2 + ] = rdft_w[k2 + ];
rdft_wk2r[k2 + ] = rdft_w[k1 + ];
rdft_wk2r[k2 + ] = rdft_w[k1 + ];
rdft_wk2r[k2 + ] = -rdft_w[k1 + ];
rdft_wk2r[k2 + ] = -rdft_w[k1 + ];
rdft_wk3r[k2 + ] = rdft_wk3ri_first[k1 + ];
rdft_wk3r[k2 + ] = rdft_wk3ri_first[k1 + ];
rdft_wk3r[k2 + ] = rdft_wk3ri_second[k1 + ];
rdft_wk3r[k2 + ] = rdft_wk3ri_second[k1 + ];
rdft_wk1i[k2 + ] = -rdft_w[k2 + ];
rdft_wk1i[k2 + ] = rdft_w[k2 + ];
rdft_wk1i[k2 + ] = -rdft_w[k2 + ];
rdft_wk1i[k2 + ] = rdft_w[k2 + ];
rdft_wk2i[k2 + ] = -rdft_w[k1 + ];
rdft_wk2i[k2 + ] = rdft_w[k1 + ];
rdft_wk2i[k2 + ] = -rdft_w[k1 + ];
rdft_wk2i[k2 + ] = rdft_w[k1 + ];
rdft_wk3i[k2 + ] = -rdft_wk3ri_first[k1 + ];
rdft_wk3i[k2 + ] = rdft_wk3ri_first[k1 + ];
rdft_wk3i[k2 + ] = -rdft_wk3ri_second[k1 + ];
rdft_wk3i[k2 + ] = rdft_wk3ri_second[k1 + ];
}
}
} static void makect_32(void) {
float* c = rdft_w + ;
const int nc = ;
int j, nch;
float delta; ip[] = nc;
nch = nc >> ;
delta = atanf(1.0f) / nch;
c[] = cosf(delta * nch);
c[nch] = 0.5f * c[];
for (j = ; j < nch; j++) {
c[j] = 0.5f * cosf(delta * j);
c[nc - j] = 0.5f * sinf(delta * j);
}
} static void cft1st_128_C(float* a) {
const int n = ;
int j, k1, k2;
float wk1r, wk1i, wk2r, wk2i, wk3r, wk3i;
float x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; x0r = a[] + a[];
x0i = a[] + a[];
x1r = a[] - a[];
x1i = a[] - a[];
x2r = a[] + a[];
x2i = a[] + a[];
x3r = a[] - a[];
x3i = a[] - a[];
a[] = x0r + x2r;
a[] = x0i + x2i;
a[] = x0r - x2r;
a[] = x0i - x2i;
a[] = x1r - x3i;
a[] = x1i + x3r;
a[] = x1r + x3i;
a[] = x1i - x3r;
wk1r = rdft_w[];
x0r = a[] + a[];
x0i = a[] + a[];
x1r = a[] - a[];
x1i = a[] - a[];
x2r = a[] + a[];
x2i = a[] + a[];
x3r = a[] - a[];
x3i = a[] - a[];
a[] = x0r + x2r;
a[] = x0i + x2i;
a[] = x2i - x0i;
a[] = x0r - x2r;
x0r = x1r - x3i;
x0i = x1i + x3r;
a[] = wk1r * (x0r - x0i);
a[] = wk1r * (x0r + x0i);
x0r = x3i + x1r;
x0i = x3r - x1i;
a[] = wk1r * (x0i - x0r);
a[] = wk1r * (x0i + x0r);
k1 = ;
for (j = ; j < n; j += ) {
k1 += ;
k2 = * k1;
wk2r = rdft_w[k1 + ];
wk2i = rdft_w[k1 + ];
wk1r = rdft_w[k2 + ];
wk1i = rdft_w[k2 + ];
wk3r = rdft_wk3ri_first[k1 + ];
wk3i = rdft_wk3ri_first[k1 + ];
x0r = a[j + ] + a[j + ];
x0i = a[j + ] + a[j + ];
x1r = a[j + ] - a[j + ];
x1i = a[j + ] - a[j + ];
x2r = a[j + ] + a[j + ];
x2i = a[j + ] + a[j + ];
x3r = a[j + ] - a[j + ];
x3i = a[j + ] - a[j + ];
a[j + ] = x0r + x2r;
a[j + ] = x0i + x2i;
x0r -= x2r;
x0i -= x2i;
a[j + ] = wk2r * x0r - wk2i * x0i;
a[j + ] = wk2r * x0i + wk2i * x0r;
x0r = x1r - x3i;
x0i = x1i + x3r;
a[j + ] = wk1r * x0r - wk1i * x0i;
a[j + ] = wk1r * x0i + wk1i * x0r;
x0r = x1r + x3i;
x0i = x1i - x3r;
a[j + ] = wk3r * x0r - wk3i * x0i;
a[j + ] = wk3r * x0i + wk3i * x0r;
wk1r = rdft_w[k2 + ];
wk1i = rdft_w[k2 + ];
wk3r = rdft_wk3ri_second[k1 + ];
wk3i = rdft_wk3ri_second[k1 + ];
x0r = a[j + ] + a[j + ];
x0i = a[j + ] + a[j + ];
x1r = a[j + ] - a[j + ];
x1i = a[j + ] - a[j + ];
x2r = a[j + ] + a[j + ];
x2i = a[j + ] + a[j + ];
x3r = a[j + ] - a[j + ];
x3i = a[j + ] - a[j + ];
a[j + ] = x0r + x2r;
a[j + ] = x0i + x2i;
x0r -= x2r;
x0i -= x2i;
a[j + ] = -wk2i * x0r - wk2r * x0i;
a[j + ] = -wk2i * x0i + wk2r * x0r;
x0r = x1r - x3i;
x0i = x1i + x3r;
a[j + ] = wk1r * x0r - wk1i * x0i;
a[j + ] = wk1r * x0i + wk1i * x0r;
x0r = x1r + x3i;
x0i = x1i - x3r;
a[j + ] = wk3r * x0r - wk3i * x0i;
a[j + ] = wk3r * x0i + wk3i * x0r;
}
} static void cftmdl_128_C(float* a) {
const int l = ;
const int n = ;
const int m = ;
int j0, j1, j2, j3, k, k1, k2, m2;
float wk1r, wk1i, wk2r, wk2i, wk3r, wk3i;
float x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; for (j0 = ; j0 < l; j0 += ) {
j1 = j0 + ;
j2 = j0 + ;
j3 = j0 + ;
x0r = a[j0 + ] + a[j1 + ];
x0i = a[j0 + ] + a[j1 + ];
x1r = a[j0 + ] - a[j1 + ];
x1i = a[j0 + ] - a[j1 + ];
x2r = a[j2 + ] + a[j3 + ];
x2i = a[j2 + ] + a[j3 + ];
x3r = a[j2 + ] - a[j3 + ];
x3i = a[j2 + ] - a[j3 + ];
a[j0 + ] = x0r + x2r;
a[j0 + ] = x0i + x2i;
a[j2 + ] = x0r - x2r;
a[j2 + ] = x0i - x2i;
a[j1 + ] = x1r - x3i;
a[j1 + ] = x1i + x3r;
a[j3 + ] = x1r + x3i;
a[j3 + ] = x1i - x3r;
}
wk1r = rdft_w[];
for (j0 = m; j0 < l + m; j0 += ) {
j1 = j0 + ;
j2 = j0 + ;
j3 = j0 + ;
x0r = a[j0 + ] + a[j1 + ];
x0i = a[j0 + ] + a[j1 + ];
x1r = a[j0 + ] - a[j1 + ];
x1i = a[j0 + ] - a[j1 + ];
x2r = a[j2 + ] + a[j3 + ];
x2i = a[j2 + ] + a[j3 + ];
x3r = a[j2 + ] - a[j3 + ];
x3i = a[j2 + ] - a[j3 + ];
a[j0 + ] = x0r + x2r;
a[j0 + ] = x0i + x2i;
a[j2 + ] = x2i - x0i;
a[j2 + ] = x0r - x2r;
x0r = x1r - x3i;
x0i = x1i + x3r;
a[j1 + ] = wk1r * (x0r - x0i);
a[j1 + ] = wk1r * (x0r + x0i);
x0r = x3i + x1r;
x0i = x3r - x1i;
a[j3 + ] = wk1r * (x0i - x0r);
a[j3 + ] = wk1r * (x0i + x0r);
}
k1 = ;
m2 = * m;
for (k = m2; k < n; k += m2) {
k1 += ;
k2 = * k1;
wk2r = rdft_w[k1 + ];
wk2i = rdft_w[k1 + ];
wk1r = rdft_w[k2 + ];
wk1i = rdft_w[k2 + ];
wk3r = rdft_wk3ri_first[k1 + ];
wk3i = rdft_wk3ri_first[k1 + ];
for (j0 = k; j0 < l + k; j0 += ) {
j1 = j0 + ;
j2 = j0 + ;
j3 = j0 + ;
x0r = a[j0 + ] + a[j1 + ];
x0i = a[j0 + ] + a[j1 + ];
x1r = a[j0 + ] - a[j1 + ];
x1i = a[j0 + ] - a[j1 + ];
x2r = a[j2 + ] + a[j3 + ];
x2i = a[j2 + ] + a[j3 + ];
x3r = a[j2 + ] - a[j3 + ];
x3i = a[j2 + ] - a[j3 + ];
a[j0 + ] = x0r + x2r;
a[j0 + ] = x0i + x2i;
x0r -= x2r;
x0i -= x2i;
a[j2 + ] = wk2r * x0r - wk2i * x0i;
a[j2 + ] = wk2r * x0i + wk2i * x0r;
x0r = x1r - x3i;
x0i = x1i + x3r;
a[j1 + ] = wk1r * x0r - wk1i * x0i;
a[j1 + ] = wk1r * x0i + wk1i * x0r;
x0r = x1r + x3i;
x0i = x1i - x3r;
a[j3 + ] = wk3r * x0r - wk3i * x0i;
a[j3 + ] = wk3r * x0i + wk3i * x0r;
}
wk1r = rdft_w[k2 + ];
wk1i = rdft_w[k2 + ];
wk3r = rdft_wk3ri_second[k1 + ];
wk3i = rdft_wk3ri_second[k1 + ];
for (j0 = k + m; j0 < l + (k + m); j0 += ) {
j1 = j0 + ;
j2 = j0 + ;
j3 = j0 + ;
x0r = a[j0 + ] + a[j1 + ];
x0i = a[j0 + ] + a[j1 + ];
x1r = a[j0 + ] - a[j1 + ];
x1i = a[j0 + ] - a[j1 + ];
x2r = a[j2 + ] + a[j3 + ];
x2i = a[j2 + ] + a[j3 + ];
x3r = a[j2 + ] - a[j3 + ];
x3i = a[j2 + ] - a[j3 + ];
a[j0 + ] = x0r + x2r;
a[j0 + ] = x0i + x2i;
x0r -= x2r;
x0i -= x2i;
a[j2 + ] = -wk2i * x0r - wk2r * x0i;
a[j2 + ] = -wk2i * x0i + wk2r * x0r;
x0r = x1r - x3i;
x0i = x1i + x3r;
a[j1 + ] = wk1r * x0r - wk1i * x0i;
a[j1 + ] = wk1r * x0i + wk1i * x0r;
x0r = x1r + x3i;
x0i = x1i - x3r;
a[j3 + ] = wk3r * x0r - wk3i * x0i;
a[j3 + ] = wk3r * x0i + wk3i * x0r;
}
}
} static void cftfsub_128(float* a) {
int j, j1, j2, j3, l;
float x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; cft1st_128(a);
cftmdl_128(a);
l = ;
for (j = ; j < l; j += ) {
j1 = j + l;
j2 = j1 + l;
j3 = j2 + l;
x0r = a[j] + a[j1];
x0i = a[j + ] + a[j1 + ];
x1r = a[j] - a[j1];
x1i = a[j + ] - a[j1 + ];
x2r = a[j2] + a[j3];
x2i = a[j2 + ] + a[j3 + ];
x3r = a[j2] - a[j3];
x3i = a[j2 + ] - a[j3 + ];
a[j] = x0r + x2r;
a[j + ] = x0i + x2i;
a[j2] = x0r - x2r;
a[j2 + ] = x0i - x2i;
a[j1] = x1r - x3i;
a[j1 + ] = x1i + x3r;
a[j3] = x1r + x3i;
a[j3 + ] = x1i - x3r;
}
} static void cftbsub_128(float* a) {
int j, j1, j2, j3, l;
float x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; cft1st_128(a);
cftmdl_128(a);
l = ; for (j = ; j < l; j += ) {
j1 = j + l;
j2 = j1 + l;
j3 = j2 + l;
x0r = a[j] + a[j1];
x0i = -a[j + ] - a[j1 + ];
x1r = a[j] - a[j1];
x1i = -a[j + ] + a[j1 + ];
x2r = a[j2] + a[j3];
x2i = a[j2 + ] + a[j3 + ];
x3r = a[j2] - a[j3];
x3i = a[j2 + ] - a[j3 + ];
a[j] = x0r + x2r;
a[j + ] = x0i - x2i;
a[j2] = x0r - x2r;
a[j2 + ] = x0i + x2i;
a[j1] = x1r - x3i;
a[j1 + ] = x1i - x3r;
a[j3] = x1r + x3i;
a[j3 + ] = x1i + x3r;
}
} static void rftfsub_128_C(float* a) {
const float* c = rdft_w + ;
int j1, j2, k1, k2;
float wkr, wki, xr, xi, yr, yi; for (j1 = , j2 = ; j2 < ; j1 += , j2 += ) {
k2 = - j2;
k1 = - j1;
wkr = 0.5f - c[k1];
wki = c[j1];
xr = a[j2 + ] - a[k2 + ];
xi = a[j2 + ] + a[k2 + ];
yr = wkr * xr - wki * xi;
yi = wkr * xi + wki * xr;
a[j2 + ] -= yr;
a[j2 + ] -= yi;
a[k2 + ] += yr;
a[k2 + ] -= yi;
}
} static void rftbsub_128_C(float* a) {
const float* c = rdft_w + ;
int j1, j2, k1, k2;
float wkr, wki, xr, xi, yr, yi; a[] = -a[];
for (j1 = , j2 = ; j2 < ; j1 += , j2 += ) {
k2 = - j2;
k1 = - j1;
wkr = 0.5f - c[k1];
wki = c[j1];
xr = a[j2 + ] - a[k2 + ];
xi = a[j2 + ] + a[k2 + ];
yr = wkr * xr + wki * xi;
yi = wkr * xi - wki * xr;
a[j2 + ] = a[j2 + ] - yr;
a[j2 + ] = yi - a[j2 + ];
a[k2 + ] = yr + a[k2 + ];
a[k2 + ] = yi - a[k2 + ];
}
a[] = -a[];
} void aec_rdft_forward_128(float* a) {
float xi;
bitrv2_128(a);
cftfsub_128(a);
rftfsub_128(a);
xi = a[] - a[];
a[] += a[];
a[] = xi;
} void aec_rdft_inverse_128(float* a) {
a[] = 0.5f * (a[] - a[]);
a[] -= a[];
rftbsub_128(a);
bitrv2_128(a);
cftbsub_128(a);
} // code path selection
rft_sub_128_t cft1st_128;
rft_sub_128_t cftmdl_128;
rft_sub_128_t rftfsub_128;
rft_sub_128_t rftbsub_128; void aec_rdft_init(void) {
cft1st_128 = cft1st_128_C;
cftmdl_128 = cftmdl_128_C;
rftfsub_128 = rftfsub_128_C;
rftbsub_128 = rftbsub_128_C;
#if defined(WEBRTC_ARCH_X86_FAMILY)
if (WebRtc_GetCPUInfo(kSSE2)) {
aec_rdft_init_sse2();
}
#endif
// init library constants.
makewt_32();
makect_32();
}
上一篇:C#制作ActiveX控件中调用海康SDK的问题


下一篇:ArcGIS 设置地图显示范围大小(全屏显示)