| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 {0.92f, 0.08f}}; | 124 {0.92f, 0.08f}}; |
| 125 const float WebRtcAec_kNormalSmoothingCoefficients[2][2] = {{0.9f, 0.1f}, | 125 const float WebRtcAec_kNormalSmoothingCoefficients[2][2] = {{0.9f, 0.1f}, |
| 126 {0.93f, 0.07f}}; | 126 {0.93f, 0.07f}}; |
| 127 | 127 |
| 128 // Number of partitions forming the NLP's "preferred" bands. | 128 // Number of partitions forming the NLP's "preferred" bands. |
| 129 enum { kPrefBandSize = 24 }; | 129 enum { kPrefBandSize = 24 }; |
| 130 | 130 |
| 131 WebRtcAecFilterFar WebRtcAec_FilterFar; | 131 WebRtcAecFilterFar WebRtcAec_FilterFar; |
| 132 WebRtcAecScaleErrorSignal WebRtcAec_ScaleErrorSignal; | 132 WebRtcAecScaleErrorSignal WebRtcAec_ScaleErrorSignal; |
| 133 WebRtcAecFilterAdaptation WebRtcAec_FilterAdaptation; | 133 WebRtcAecFilterAdaptation WebRtcAec_FilterAdaptation; |
| 134 WebRtcAecOverdriveAndSuppress WebRtcAec_OverdriveAndSuppress; | 134 WebRtcAecOverdrive WebRtcAec_Overdrive; |
| 135 WebRtcAecSuppress WebRtcAec_Suppress; |
| 135 WebRtcAecComputeCoherence WebRtcAec_ComputeCoherence; | 136 WebRtcAecComputeCoherence WebRtcAec_ComputeCoherence; |
| 136 WebRtcAecUpdateCoherenceSpectra WebRtcAec_UpdateCoherenceSpectra; | 137 WebRtcAecUpdateCoherenceSpectra WebRtcAec_UpdateCoherenceSpectra; |
| 137 WebRtcAecStoreAsComplex WebRtcAec_StoreAsComplex; | 138 WebRtcAecStoreAsComplex WebRtcAec_StoreAsComplex; |
| 138 WebRtcAecPartitionDelay WebRtcAec_PartitionDelay; | 139 WebRtcAecPartitionDelay WebRtcAec_PartitionDelay; |
| 139 WebRtcAecWindowData WebRtcAec_WindowData; | 140 WebRtcAecWindowData WebRtcAec_WindowData; |
| 140 | 141 |
| 141 __inline static float MulRe(float aRe, float aIm, float bRe, float bIm) { | 142 __inline static float MulRe(float aRe, float aIm, float bRe, float bIm) { |
| 142 return aRe * bRe - aIm * bIm; | 143 return aRe * bRe - aIm * bIm; |
| 143 } | 144 } |
| 144 | 145 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 h_fft_buf[0][pos] += fft[0]; | 301 h_fft_buf[0][pos] += fft[0]; |
| 301 h_fft_buf[0][pos + PART_LEN] += fft[1]; | 302 h_fft_buf[0][pos + PART_LEN] += fft[1]; |
| 302 | 303 |
| 303 for (j = 1; j < PART_LEN; j++) { | 304 for (j = 1; j < PART_LEN; j++) { |
| 304 h_fft_buf[0][pos + j] += fft[2 * j]; | 305 h_fft_buf[0][pos + j] += fft[2 * j]; |
| 305 h_fft_buf[1][pos + j] += fft[2 * j + 1]; | 306 h_fft_buf[1][pos + j] += fft[2 * j + 1]; |
| 306 } | 307 } |
| 307 } | 308 } |
| 308 } | 309 } |
| 309 | 310 |
| 310 static void OverdriveAndSuppress(float overdrive_scaling, | 311 static void Overdrive(float overdrive_scaling, |
| 311 float hNl[PART_LEN1], | 312 const float hNlFb, |
| 312 const float hNlFb, | 313 float hNl[PART_LEN1]) { |
| 313 float efw[2][PART_LEN1]) { | 314 for (int i = 0; i < PART_LEN1; ++i) { |
| 314 int i; | |
| 315 for (i = 0; i < PART_LEN1; i++) { | |
| 316 // Weight subbands | 315 // Weight subbands |
| 317 if (hNl[i] > hNlFb) { | 316 if (hNl[i] > hNlFb) { |
| 318 hNl[i] = WebRtcAec_weightCurve[i] * hNlFb + | 317 hNl[i] = WebRtcAec_weightCurve[i] * hNlFb + |
| 319 (1 - WebRtcAec_weightCurve[i]) * hNl[i]; | 318 (1 - WebRtcAec_weightCurve[i]) * hNl[i]; |
| 320 } | 319 } |
| 321 hNl[i] = powf(hNl[i], overdrive_scaling * WebRtcAec_overDriveCurve[i]); | 320 hNl[i] = powf(hNl[i], overdrive_scaling * WebRtcAec_overDriveCurve[i]); |
| 321 } |
| 322 } |
| 322 | 323 |
| 324 static void Suppress(const float hNl[PART_LEN1], float efw[2][PART_LEN1]) { |
| 325 for (int i = 0; i < PART_LEN1; ++i) { |
| 323 // Suppress error signal | 326 // Suppress error signal |
| 324 efw[0][i] *= hNl[i]; | 327 efw[0][i] *= hNl[i]; |
| 325 efw[1][i] *= hNl[i]; | 328 efw[1][i] *= hNl[i]; |
| 326 | 329 |
| 327 // Ooura fft returns incorrect sign on imaginary component. It matters here | 330 // Ooura fft returns incorrect sign on imaginary component. It matters here |
| 328 // because we are making an additive change with comfort noise. | 331 // because we are making an additive change with comfort noise. |
| 329 efw[1][i] *= -1; | 332 efw[1][i] *= -1; |
| 330 } | 333 } |
| 331 } | 334 } |
| 332 | 335 |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 | 1153 |
| 1151 // Smooth the overdrive. | 1154 // Smooth the overdrive. |
| 1152 if (aec->overDrive < aec->overdrive_scaling) { | 1155 if (aec->overDrive < aec->overdrive_scaling) { |
| 1153 aec->overdrive_scaling = | 1156 aec->overdrive_scaling = |
| 1154 0.99f * aec->overdrive_scaling + 0.01f * aec->overDrive; | 1157 0.99f * aec->overdrive_scaling + 0.01f * aec->overDrive; |
| 1155 } else { | 1158 } else { |
| 1156 aec->overdrive_scaling = | 1159 aec->overdrive_scaling = |
| 1157 0.9f * aec->overdrive_scaling + 0.1f * aec->overDrive; | 1160 0.9f * aec->overdrive_scaling + 0.1f * aec->overDrive; |
| 1158 } | 1161 } |
| 1159 | 1162 |
| 1160 WebRtcAec_OverdriveAndSuppress(aec->overdrive_scaling, hNl, hNlFb, efw); | 1163 WebRtcAec_Overdrive(aec->overdrive_scaling, hNlFb, hNl); |
| 1164 WebRtcAec_Suppress(hNl, efw); |
| 1161 | 1165 |
| 1162 // Add comfort noise. | 1166 // Add comfort noise. |
| 1163 ComfortNoise(aec, efw, comfortNoiseHband, aec->noisePow, hNl); | 1167 ComfortNoise(aec, efw, comfortNoiseHband, aec->noisePow, hNl); |
| 1164 | 1168 |
| 1165 // Inverse error fft. | 1169 // Inverse error fft. |
| 1166 ScaledInverseFft(efw, fft, 2.0f, 1); | 1170 ScaledInverseFft(efw, fft, 2.0f, 1); |
| 1167 | 1171 |
| 1168 // Overlap and add to obtain output. | 1172 // Overlap and add to obtain output. |
| 1169 for (i = 0; i < PART_LEN; i++) { | 1173 for (i = 0; i < PART_LEN; i++) { |
| 1170 output[i] = (fft[i] * WebRtcAec_sqrtHanning[i] + | 1174 output[i] = (fft[i] * WebRtcAec_sqrtHanning[i] + |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1470 WebRtc_set_lookahead(aec->delay_estimator, kLookaheadBlocks); | 1474 WebRtc_set_lookahead(aec->delay_estimator, kLookaheadBlocks); |
| 1471 #endif | 1475 #endif |
| 1472 aec->extended_filter_enabled = 0; | 1476 aec->extended_filter_enabled = 0; |
| 1473 aec->aec3_enabled = 0; | 1477 aec->aec3_enabled = 0; |
| 1474 aec->refined_adaptive_filter_enabled = false; | 1478 aec->refined_adaptive_filter_enabled = false; |
| 1475 | 1479 |
| 1476 // Assembly optimization | 1480 // Assembly optimization |
| 1477 WebRtcAec_FilterFar = FilterFar; | 1481 WebRtcAec_FilterFar = FilterFar; |
| 1478 WebRtcAec_ScaleErrorSignal = ScaleErrorSignal; | 1482 WebRtcAec_ScaleErrorSignal = ScaleErrorSignal; |
| 1479 WebRtcAec_FilterAdaptation = FilterAdaptation; | 1483 WebRtcAec_FilterAdaptation = FilterAdaptation; |
| 1480 WebRtcAec_OverdriveAndSuppress = OverdriveAndSuppress; | 1484 WebRtcAec_Overdrive = Overdrive; |
| 1485 WebRtcAec_Suppress = Suppress; |
| 1481 WebRtcAec_ComputeCoherence = ComputeCoherence; | 1486 WebRtcAec_ComputeCoherence = ComputeCoherence; |
| 1482 WebRtcAec_UpdateCoherenceSpectra = UpdateCoherenceSpectra; | 1487 WebRtcAec_UpdateCoherenceSpectra = UpdateCoherenceSpectra; |
| 1483 WebRtcAec_StoreAsComplex = StoreAsComplex; | 1488 WebRtcAec_StoreAsComplex = StoreAsComplex; |
| 1484 WebRtcAec_PartitionDelay = PartitionDelay; | 1489 WebRtcAec_PartitionDelay = PartitionDelay; |
| 1485 WebRtcAec_WindowData = WindowData; | 1490 WebRtcAec_WindowData = WindowData; |
| 1486 | 1491 |
| 1487 #if defined(WEBRTC_ARCH_X86_FAMILY) | 1492 #if defined(WEBRTC_ARCH_X86_FAMILY) |
| 1488 if (WebRtc_GetCPUInfo(kSSE2)) { | 1493 if (WebRtc_GetCPUInfo(kSSE2)) { |
| 1489 WebRtcAec_InitAec_SSE2(); | 1494 WebRtcAec_InitAec_SSE2(); |
| 1490 } | 1495 } |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1951 | 1956 |
| 1952 int WebRtcAec_system_delay(AecCore* self) { | 1957 int WebRtcAec_system_delay(AecCore* self) { |
| 1953 return self->system_delay; | 1958 return self->system_delay; |
| 1954 } | 1959 } |
| 1955 | 1960 |
| 1956 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { | 1961 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { |
| 1957 assert(delay >= 0); | 1962 assert(delay >= 0); |
| 1958 self->system_delay = delay; | 1963 self->system_delay = delay; |
| 1959 } | 1964 } |
| 1960 } // namespace webrtc | 1965 } // namespace webrtc |
| OLD | NEW |