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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 (aec->sd[i] * aec->se[i] + 1e-10f); | 425 (aec->sd[i] * aec->se[i] + 1e-10f); |
426 cohxd[i] = | 426 cohxd[i] = |
427 (aec->sxd[i][0] * aec->sxd[i][0] + aec->sxd[i][1] * aec->sxd[i][1]) / | 427 (aec->sxd[i][0] * aec->sxd[i][0] + aec->sxd[i][1] * aec->sxd[i][1]) / |
428 (aec->sx[i] * aec->sd[i] + 1e-10f); | 428 (aec->sx[i] * aec->sd[i] + 1e-10f); |
429 } | 429 } |
430 } | 430 } |
431 | 431 |
432 static void GetHighbandGain(const float* lambda, float* nlpGainHband) { | 432 static void GetHighbandGain(const float* lambda, float* nlpGainHband) { |
433 int i; | 433 int i; |
434 | 434 |
435 nlpGainHband[0] = (float)0.0; | 435 *nlpGainHband = (float)0.0; |
436 for (i = freqAvgIc; i < PART_LEN1 - 1; i++) { | 436 for (i = freqAvgIc; i < PART_LEN1 - 1; i++) { |
437 nlpGainHband[0] += lambda[i]; | 437 *nlpGainHband += lambda[i]; |
438 } | 438 } |
439 nlpGainHband[0] /= (float)(PART_LEN1 - 1 - freqAvgIc); | 439 *nlpGainHband /= (float)(PART_LEN1 - 1 - freqAvgIc); |
440 } | 440 } |
441 | 441 |
442 static void ComfortNoise(AecCore* aec, | 442 static void ComfortNoise(AecCore* aec, |
443 float efw[2][PART_LEN1], | 443 float efw[2][PART_LEN1], |
444 complex_t* comfortNoiseHband, | 444 complex_t* comfortNoiseHband, |
445 const float* noisePow, | 445 const float* noisePow, |
446 const float* lambda) { | 446 const float* lambda) { |
447 int i, num; | 447 int i, num; |
448 float rand[PART_LEN]; | 448 float rand[PART_LEN]; |
449 float noise, noiseAvg, tmp, tmpAvg; | 449 float noise, noiseAvg, tmp, tmpAvg; |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 // Windowed echo suppressor output ffts. | 1049 // Windowed echo suppressor output ffts. |
1050 WindowData(fft, aec->eBuf); | 1050 WindowData(fft, aec->eBuf); |
1051 aec_rdft_forward_128(fft); | 1051 aec_rdft_forward_128(fft); |
1052 StoreAsComplex(fft, efw); | 1052 StoreAsComplex(fft, efw); |
1053 | 1053 |
1054 aec->delayEstCtr++; | 1054 aec->delayEstCtr++; |
1055 if (aec->delayEstCtr == delayEstInterval) { | 1055 if (aec->delayEstCtr == delayEstInterval) { |
1056 aec->delayEstCtr = 0; | 1056 aec->delayEstCtr = 0; |
1057 } | 1057 } |
1058 | 1058 |
1059 // initialize comfort noise for H band | |
1060 memset(comfortNoiseHband, 0, sizeof(comfortNoiseHband)); | |
1061 nlpGainHband = (float)0.0; | |
1062 dtmp = (float)0.0; | |
1063 | |
1064 // We should always have at least one element stored in |far_buf|. | 1059 // We should always have at least one element stored in |far_buf|. |
1065 assert(WebRtc_available_read(aec->far_buf_windowed) > 0); | 1060 assert(WebRtc_available_read(aec->far_buf_windowed) > 0); |
1066 // NLP | 1061 // NLP |
1067 WebRtc_ReadBuffer(aec->far_buf_windowed, (void**)&xfw_ptr, &xfw[0][0], 1); | 1062 WebRtc_ReadBuffer(aec->far_buf_windowed, (void**)&xfw_ptr, &xfw[0][0], 1); |
1068 | 1063 |
1069 // TODO(bjornv): Investigate if we can reuse |far_buf_windowed| instead of | 1064 // TODO(bjornv): Investigate if we can reuse |far_buf_windowed| instead of |
1070 // |xfwBuf|. | 1065 // |xfwBuf|. |
1071 // Buffer far. | 1066 // Buffer far. |
1072 memcpy(aec->xfwBuf, xfw_ptr, sizeof(float) * 2 * PART_LEN1); | 1067 memcpy(aec->xfwBuf, xfw_ptr, sizeof(float) * 2 * PART_LEN1); |
1073 | 1068 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 // Smooth the overdrive. | 1169 // Smooth the overdrive. |
1175 if (aec->overDrive < aec->overDriveSm) { | 1170 if (aec->overDrive < aec->overDriveSm) { |
1176 aec->overDriveSm = 0.99f * aec->overDriveSm + 0.01f * aec->overDrive; | 1171 aec->overDriveSm = 0.99f * aec->overDriveSm + 0.01f * aec->overDrive; |
1177 } else { | 1172 } else { |
1178 aec->overDriveSm = 0.9f * aec->overDriveSm + 0.1f * aec->overDrive; | 1173 aec->overDriveSm = 0.9f * aec->overDriveSm + 0.1f * aec->overDrive; |
1179 } | 1174 } |
1180 | 1175 |
1181 WebRtcAec_OverdriveAndSuppress(aec, hNl, hNlFb, efw); | 1176 WebRtcAec_OverdriveAndSuppress(aec, hNl, hNlFb, efw); |
1182 | 1177 |
1183 // Add comfort noise. | 1178 // Add comfort noise. |
| 1179 memset(comfortNoiseHband, 0, sizeof(comfortNoiseHband)); |
1184 WebRtcAec_ComfortNoise(aec, efw, comfortNoiseHband, aec->noisePow, hNl); | 1180 WebRtcAec_ComfortNoise(aec, efw, comfortNoiseHband, aec->noisePow, hNl); |
1185 | 1181 |
1186 // TODO(bjornv): Investigate how to take the windowing below into account if | 1182 // TODO(bjornv): Investigate how to take the windowing below into account if |
1187 // needed. | 1183 // needed. |
1188 if (aec->metricsMode == 1) { | 1184 if (aec->metricsMode == 1) { |
1189 // Note that we have a scaling by two in the time domain |eBuf|. | 1185 // Note that we have a scaling by two in the time domain |eBuf|. |
1190 // In addition the time domain signal is windowed before transformation, | 1186 // In addition the time domain signal is windowed before transformation, |
1191 // losing half the energy on the average. We take care of the first | 1187 // losing half the energy on the average. We take care of the first |
1192 // scaling only in UpdateMetrics(). | 1188 // scaling only in UpdateMetrics(). |
1193 UpdateLevel(&aec->nlpoutlevel, efw); | 1189 UpdateLevel(&aec->nlpoutlevel, efw); |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1983 int WebRtcAec_extended_filter_enabled(AecCore* self) { | 1979 int WebRtcAec_extended_filter_enabled(AecCore* self) { |
1984 return self->extended_filter_enabled; | 1980 return self->extended_filter_enabled; |
1985 } | 1981 } |
1986 | 1982 |
1987 int WebRtcAec_system_delay(AecCore* self) { return self->system_delay; } | 1983 int WebRtcAec_system_delay(AecCore* self) { return self->system_delay; } |
1988 | 1984 |
1989 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { | 1985 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { |
1990 assert(delay >= 0); | 1986 assert(delay >= 0); |
1991 self->system_delay = delay; | 1987 self->system_delay = delay; |
1992 } | 1988 } |
OLD | NEW |