| 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) { |
| 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 } else { |
| 321 memset(comfortNoiseHband, 0, |
| 322 2 * PART_LEN1 * sizeof(comfortNoiseHband[0][0])); |
| 320 } | 323 } |
| 321 } | 324 } |
| 322 | 325 |
| 323 void WebRtcAec_FilterFar_mips( | 326 void WebRtcAec_FilterFar_mips( |
| 324 int num_partitions, | 327 int num_partitions, |
| 325 int x_fft_buf_block_pos, | 328 int x_fft_buf_block_pos, |
| 326 float x_fft_buf[2][kExtendedNumPartitions * PART_LEN1], | 329 float x_fft_buf[2][kExtendedNumPartitions * PART_LEN1], |
| 327 float h_fft_buf[2][kExtendedNumPartitions * PART_LEN1], | 330 float h_fft_buf[2][kExtendedNumPartitions * PART_LEN1], |
| 328 float y_fft[2][PART_LEN1]) { | 331 float y_fft[2][PART_LEN1]) { |
| 329 int i; | 332 int i; |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 ); | 779 ); |
| 777 } | 780 } |
| 778 | 781 |
| 779 void WebRtcAec_InitAec_mips(void) { | 782 void WebRtcAec_InitAec_mips(void) { |
| 780 WebRtcAec_FilterFar = WebRtcAec_FilterFar_mips; | 783 WebRtcAec_FilterFar = WebRtcAec_FilterFar_mips; |
| 781 WebRtcAec_FilterAdaptation = WebRtcAec_FilterAdaptation_mips; | 784 WebRtcAec_FilterAdaptation = WebRtcAec_FilterAdaptation_mips; |
| 782 WebRtcAec_ScaleErrorSignal = WebRtcAec_ScaleErrorSignal_mips; | 785 WebRtcAec_ScaleErrorSignal = WebRtcAec_ScaleErrorSignal_mips; |
| 783 WebRtcAec_ComfortNoise = WebRtcAec_ComfortNoise_mips; | 786 WebRtcAec_ComfortNoise = WebRtcAec_ComfortNoise_mips; |
| 784 WebRtcAec_OverdriveAndSuppress = WebRtcAec_OverdriveAndSuppress_mips; | 787 WebRtcAec_OverdriveAndSuppress = WebRtcAec_OverdriveAndSuppress_mips; |
| 785 } | 788 } |
| OLD | NEW |