OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 return aRe * bIm + aIm * bRe; | 144 return aRe * bIm + aIm * bRe; |
145 } | 145 } |
146 | 146 |
147 static int CmpFloat(const void* a, const void* b) { | 147 static int CmpFloat(const void* a, const void* b) { |
148 const float* da = (const float*)a; | 148 const float* da = (const float*)a; |
149 const float* db = (const float*)b; | 149 const float* db = (const float*)b; |
150 | 150 |
151 return (*da > *db) - (*da < *db); | 151 return (*da > *db) - (*da < *db); |
152 } | 152 } |
153 | 153 |
154 static void FilterFar(AecCore* aec, float yf[2][PART_LEN1]) { | 154 static void FilterFar(int num_partitions, |
| 155 int xfBufBlockPos, |
| 156 float xfBuf[2][kExtendedNumPartitions * PART_LEN1], |
| 157 float wfBuf[2][kExtendedNumPartitions * PART_LEN1], |
| 158 float yf[2][PART_LEN1]) { |
155 int i; | 159 int i; |
156 for (i = 0; i < aec->num_partitions; i++) { | 160 for (i = 0; i < num_partitions; i++) { |
157 int j; | 161 int j; |
158 int xPos = (i + aec->xfBufBlockPos) * PART_LEN1; | 162 int xPos = (i + xfBufBlockPos) * PART_LEN1; |
159 int pos = i * PART_LEN1; | 163 int pos = i * PART_LEN1; |
160 // Check for wrap | 164 // Check for wrap |
161 if (i + aec->xfBufBlockPos >= aec->num_partitions) { | 165 if (i + xfBufBlockPos >= num_partitions) { |
162 xPos -= aec->num_partitions * (PART_LEN1); | 166 xPos -= num_partitions * (PART_LEN1); |
163 } | 167 } |
164 | 168 |
165 for (j = 0; j < PART_LEN1; j++) { | 169 for (j = 0; j < PART_LEN1; j++) { |
166 yf[0][j] += MulRe(aec->xfBuf[0][xPos + j], | 170 yf[0][j] += MulRe(xfBuf[0][xPos + j], |
167 aec->xfBuf[1][xPos + j], | 171 xfBuf[1][xPos + j], |
168 aec->wfBuf[0][pos + j], | 172 wfBuf[0][pos + j], |
169 aec->wfBuf[1][pos + j]); | 173 wfBuf[1][pos + j]); |
170 yf[1][j] += MulIm(aec->xfBuf[0][xPos + j], | 174 yf[1][j] += MulIm(xfBuf[0][xPos + j], |
171 aec->xfBuf[1][xPos + j], | 175 xfBuf[1][xPos + j], |
172 aec->wfBuf[0][pos + j], | 176 wfBuf[0][pos + j], |
173 aec->wfBuf[1][pos + j]); | 177 wfBuf[1][pos + j]); |
174 } | 178 } |
175 } | 179 } |
176 } | 180 } |
177 | 181 |
178 static void ScaleErrorSignal(int extended_filter_enabled, | 182 static void ScaleErrorSignal(int extended_filter_enabled, |
179 float normal_mu, | 183 float normal_mu, |
180 float normal_error_threshold, | 184 float normal_error_threshold, |
181 float *xPow, | 185 float *xPow, |
182 float ef[2][PART_LEN1]) { | 186 float ef[2][PART_LEN1]) { |
183 const float mu = extended_filter_enabled ? kExtendedMu : normal_mu; | 187 const float mu = extended_filter_enabled ? kExtendedMu : normal_mu; |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 float yf[2][PART_LEN1]; | 967 float yf[2][PART_LEN1]; |
964 float fft[PART_LEN2]; | 968 float fft[PART_LEN2]; |
965 float y[PART_LEN]; | 969 float y[PART_LEN]; |
966 float e[PART_LEN]; | 970 float e[PART_LEN]; |
967 float ef[2][PART_LEN1]; | 971 float ef[2][PART_LEN1]; |
968 float scale; | 972 float scale; |
969 int i; | 973 int i; |
970 memset(yf, 0, sizeof(yf)); | 974 memset(yf, 0, sizeof(yf)); |
971 | 975 |
972 // Produce echo estimate. | 976 // Produce echo estimate. |
973 WebRtcAec_FilterFar(aec, yf); | 977 WebRtcAec_FilterFar(aec->num_partitions, |
| 978 aec->xfBufBlockPos, |
| 979 aec->xfBuf, |
| 980 aec->wfBuf, |
| 981 yf); |
974 | 982 |
975 // Inverse fft to obtain echo estimate and error. | 983 // Inverse fft to obtain echo estimate and error. |
976 FrequencyToTime(yf, fft); | 984 FrequencyToTime(yf, fft); |
977 | 985 |
978 // Extract the output signal and compute the time-domain error | 986 // Extract the output signal and compute the time-domain error |
979 scale = 2.0f / PART_LEN2; | 987 scale = 2.0f / PART_LEN2; |
980 for (i = 0; i < PART_LEN; i++) { | 988 for (i = 0; i < PART_LEN; i++) { |
981 y[i] = fft[PART_LEN + i] * scale; // fft scaling | 989 y[i] = fft[PART_LEN + i] * scale; // fft scaling |
982 } | 990 } |
983 | 991 |
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1942 int WebRtcAec_extended_filter_enabled(AecCore* self) { | 1950 int WebRtcAec_extended_filter_enabled(AecCore* self) { |
1943 return self->extended_filter_enabled; | 1951 return self->extended_filter_enabled; |
1944 } | 1952 } |
1945 | 1953 |
1946 int WebRtcAec_system_delay(AecCore* self) { return self->system_delay; } | 1954 int WebRtcAec_system_delay(AecCore* self) { return self->system_delay; } |
1947 | 1955 |
1948 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { | 1956 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { |
1949 assert(delay >= 0); | 1957 assert(delay >= 0); |
1950 self->system_delay = delay; | 1958 self->system_delay = delay; |
1951 } | 1959 } |
OLD | NEW |