OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 |
11 /* | 11 /* |
12 * The core AEC algorithm, which is presented with time-aligned signals. | 12 * The core AEC algorithm, which is presented with time-aligned signals. |
13 */ | 13 */ |
14 | 14 |
15 #include "webrtc/modules/audio_processing/aec/aec_core.h" | 15 #include "webrtc/modules/audio_processing/aec/aec_core.h" |
16 | 16 |
17 #include <math.h> | 17 #include <math.h> |
18 | 18 |
19 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" | 19 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" |
20 #include "webrtc/modules/audio_processing/aec/aec_core_internal.h" | 20 #include "webrtc/modules/audio_processing/aec/aec_core_internal.h" |
21 #include "webrtc/modules/audio_processing/aec/aec_rdft.h" | 21 #include "webrtc/modules/audio_processing/aec/aec_rdft.h" |
22 | 22 |
23 static const int flagHbandCn = 1; // flag for adding comfort noise in H band | 23 static const int flagHbandCn = 1; // flag for adding comfort noise in H band |
24 extern const float WebRtcAec_weightCurve[65]; | 24 extern const float WebRtcAec_weightCurve[65]; |
25 extern const float WebRtcAec_overDriveCurve[65]; | 25 extern const float WebRtcAec_overDriveCurve[65]; |
26 | 26 |
27 void WebRtcAec_ComfortNoise_mips(AecCore* aec, | 27 void WebRtcAec_ComfortNoise_mips(AecCore* aec, |
28 float efw[2][PART_LEN1], | 28 float efw[2][PART_LEN1], |
29 complex_t* comfortNoiseHband, | 29 float comfortNoiseHband[2][PART_LEN1], |
30 const float* noisePow, | 30 const float* noisePow, |
31 const float* lambda) { | 31 const float* lambda) { |
32 int i, num; | 32 int i, num; |
33 float rand[PART_LEN]; | 33 float rand[PART_LEN]; |
34 float noise, noiseAvg, tmp, tmpAvg; | 34 float noise, noiseAvg, tmp, tmpAvg; |
35 int16_t randW16[PART_LEN]; | 35 int16_t randW16[PART_LEN]; |
36 complex_t u[PART_LEN1]; | 36 complex_t u[PART_LEN1]; |
37 | 37 |
38 const float pi2 = 6.28318530717959f; | 38 const float pi2 = 6.28318530717959f; |
39 const float pi2t = pi2 / 32768; | 39 const float pi2t = pi2 / 32768; |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 tmp = sqrtf(WEBRTC_SPL_MAX(1 - lambda[PART_LEN] * lambda[PART_LEN], 0)); | 267 tmp = sqrtf(WEBRTC_SPL_MAX(1 - lambda[PART_LEN] * lambda[PART_LEN], 0)); |
268 //tmp = 1 - lambda[i]; | 268 //tmp = 1 - lambda[i]; |
269 efw[0][PART_LEN] += tmp * u[PART_LEN][0]; | 269 efw[0][PART_LEN] += tmp * u[PART_LEN][0]; |
270 efw[1][PART_LEN] += tmp * u[PART_LEN][1]; | 270 efw[1][PART_LEN] += tmp * u[PART_LEN][1]; |
271 | 271 |
272 // For H band comfort noise | 272 // For H band comfort noise |
273 // TODO: don't compute noise and "tmp" twice. Use the previous results. | 273 // TODO: don't compute noise and "tmp" twice. Use the previous results. |
274 noiseAvg = 0.0; | 274 noiseAvg = 0.0; |
275 tmpAvg = 0.0; | 275 tmpAvg = 0.0; |
276 num = 0; | 276 num = 0; |
277 if ((aec->sampFreq == 32000 || aec->sampFreq == 48000) && flagHbandCn == 1) { | 277 if (aec->num_bands > 1 && flagHbandCn == 1) { |
minyue-webrtc
2015/12/04 09:49:44
Interesting, MIPS was different here, was there a
peah-webrtc
2015/12/04 23:02:48
I think it is just an error. As far as I know, num
| |
278 for (i = 0; i < PART_LEN; i++) { | 278 for (i = 0; i < PART_LEN; i++) { |
279 rand[i] = ((float)randW16[i]) / 32768; | 279 rand[i] = ((float)randW16[i]) / 32768; |
280 } | 280 } |
281 | 281 |
282 // average noise scale | 282 // average noise scale |
283 // average over second half of freq spectrum (i.e., 4->8khz) | 283 // average over second half of freq spectrum (i.e., 4->8khz) |
284 // TODO: we shouldn't need num. We know how many elements we're summing. | 284 // TODO: we shouldn't need num. We know how many elements we're summing. |
285 for (i = PART_LEN1 >> 1; i < PART_LEN1; i++) { | 285 for (i = PART_LEN1 >> 1; i < PART_LEN1; i++) { |
286 num++; | 286 num++; |
287 noiseAvg += sqrtf(noisePow[i]); | 287 noiseAvg += sqrtf(noisePow[i]); |
(...skipping 19 matching lines...) Expand all Loading... | |
307 tmp = pi2 * rand[i - 1]; | 307 tmp = pi2 * rand[i - 1]; |
308 | 308 |
309 // Use average noise for H band | 309 // Use average noise for H band |
310 u[i][0] = noiseAvg * (float)cos(tmp); | 310 u[i][0] = noiseAvg * (float)cos(tmp); |
311 u[i][1] = -noiseAvg * (float)sin(tmp); | 311 u[i][1] = -noiseAvg * (float)sin(tmp); |
312 } | 312 } |
313 u[PART_LEN][1] = 0; | 313 u[PART_LEN][1] = 0; |
314 | 314 |
315 for (i = 0; i < PART_LEN1; i++) { | 315 for (i = 0; i < PART_LEN1; i++) { |
316 // Use average NLP weight for H band | 316 // Use average NLP weight for H band |
317 comfortNoiseHband[i][0] = tmpAvg * u[i][0]; | 317 comfortNoiseHband[0][i] = tmpAvg * u[i][0]; |
318 comfortNoiseHband[i][1] = tmpAvg * u[i][1]; | 318 comfortNoiseHband[1][i] = tmpAvg * u[i][1]; |
319 } | 319 } |
320 } | 320 } |
321 else { | |
minyue-webrtc
2015/12/04 09:49:44
321 to 320
peah-webrtc
2015/12/04 23:02:48
Done.
| |
322 memset(comfortNoiseHband, 0, | |
323 2 * PART_LEN1 * sizeof(comfortNoiseHband[0][0])); | |
hlundin-webrtc
2015/12/04 11:01:39
... and sizeof(comfortNoiseHband)
peah-webrtc
2015/12/04 23:02:48
As stated in the other place for this, that does n
hlundin-webrtc
2015/12/08 11:52:52
Acknowledged.
| |
324 } | |
321 } | 325 } |
322 | 326 |
323 void WebRtcAec_FilterFar_mips( | 327 void WebRtcAec_FilterFar_mips( |
324 int num_partitions, | 328 int num_partitions, |
325 int x_fft_buf_block_pos, | 329 int x_fft_buf_block_pos, |
326 float x_fft_buf[2][kExtendedNumPartitions * PART_LEN1], | 330 float x_fft_buf[2][kExtendedNumPartitions * PART_LEN1], |
327 float h_fft_buf[2][kExtendedNumPartitions * PART_LEN1], | 331 float h_fft_buf[2][kExtendedNumPartitions * PART_LEN1], |
328 float y_fft[2][PART_LEN1]) { | 332 float y_fft[2][PART_LEN1]) { |
329 int i; | 333 int i; |
330 for (i = 0; i < num_partitions; i++) { | 334 for (i = 0; i < num_partitions; i++) { |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
776 ); | 780 ); |
777 } | 781 } |
778 | 782 |
779 void WebRtcAec_InitAec_mips(void) { | 783 void WebRtcAec_InitAec_mips(void) { |
780 WebRtcAec_FilterFar = WebRtcAec_FilterFar_mips; | 784 WebRtcAec_FilterFar = WebRtcAec_FilterFar_mips; |
781 WebRtcAec_FilterAdaptation = WebRtcAec_FilterAdaptation_mips; | 785 WebRtcAec_FilterAdaptation = WebRtcAec_FilterAdaptation_mips; |
782 WebRtcAec_ScaleErrorSignal = WebRtcAec_ScaleErrorSignal_mips; | 786 WebRtcAec_ScaleErrorSignal = WebRtcAec_ScaleErrorSignal_mips; |
783 WebRtcAec_ComfortNoise = WebRtcAec_ComfortNoise_mips; | 787 WebRtcAec_ComfortNoise = WebRtcAec_ComfortNoise_mips; |
784 WebRtcAec_OverdriveAndSuppress = WebRtcAec_OverdriveAndSuppress_mips; | 788 WebRtcAec_OverdriveAndSuppress = WebRtcAec_OverdriveAndSuppress_mips; |
785 } | 789 } |
OLD | NEW |