Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(347)

Side by Side Diff: webrtc/modules/audio_processing/aec/aec_core.cc

Issue 1943753002: Separated the functionalities in the OverdriveAndSuppress method in the AEC into two methods (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@RefactorAec5_CL
Patch Set: Added the changes into the MIPS code as well Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 // Number of partitions forming the NLP's "preferred" bands. 133 // Number of partitions forming the NLP's "preferred" bands.
134 enum { kPrefBandSize = 24 }; 134 enum { kPrefBandSize = 24 };
135 135
136 #ifdef WEBRTC_AEC_DEBUG_DUMP 136 #ifdef WEBRTC_AEC_DEBUG_DUMP
137 extern int webrtc_aec_instance_count; 137 extern int webrtc_aec_instance_count;
138 #endif 138 #endif
139 139
140 WebRtcAecFilterFar WebRtcAec_FilterFar; 140 WebRtcAecFilterFar WebRtcAec_FilterFar;
141 WebRtcAecScaleErrorSignal WebRtcAec_ScaleErrorSignal; 141 WebRtcAecScaleErrorSignal WebRtcAec_ScaleErrorSignal;
142 WebRtcAecFilterAdaptation WebRtcAec_FilterAdaptation; 142 WebRtcAecFilterAdaptation WebRtcAec_FilterAdaptation;
143 WebRtcAecOverdriveAndSuppress WebRtcAec_OverdriveAndSuppress; 143 WebRtcAecOverdrive WebRtcAec_Overdrive;
144 WebRtcAecSuppress WebRtcAec_Suppress;
144 WebRtcAecComputeCoherence WebRtcAec_ComputeCoherence; 145 WebRtcAecComputeCoherence WebRtcAec_ComputeCoherence;
145 WebRtcAecUpdateCoherenceSpectra WebRtcAec_UpdateCoherenceSpectra; 146 WebRtcAecUpdateCoherenceSpectra WebRtcAec_UpdateCoherenceSpectra;
146 WebRtcAecStoreAsComplex WebRtcAec_StoreAsComplex; 147 WebRtcAecStoreAsComplex WebRtcAec_StoreAsComplex;
147 WebRtcAecPartitionDelay WebRtcAec_PartitionDelay; 148 WebRtcAecPartitionDelay WebRtcAec_PartitionDelay;
148 WebRtcAecWindowData WebRtcAec_WindowData; 149 WebRtcAecWindowData WebRtcAec_WindowData;
149 150
150 __inline static float MulRe(float aRe, float aIm, float bRe, float bIm) { 151 __inline static float MulRe(float aRe, float aIm, float bRe, float bIm) {
151 return aRe * bRe - aIm * bIm; 152 return aRe * bRe - aIm * bIm;
152 } 153 }
153 154
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 h_fft_buf[0][pos] += fft[0]; 307 h_fft_buf[0][pos] += fft[0];
307 h_fft_buf[0][pos + PART_LEN] += fft[1]; 308 h_fft_buf[0][pos + PART_LEN] += fft[1];
308 309
309 for (j = 1; j < PART_LEN; j++) { 310 for (j = 1; j < PART_LEN; j++) {
310 h_fft_buf[0][pos + j] += fft[2 * j]; 311 h_fft_buf[0][pos + j] += fft[2 * j];
311 h_fft_buf[1][pos + j] += fft[2 * j + 1]; 312 h_fft_buf[1][pos + j] += fft[2 * j + 1];
312 } 313 }
313 } 314 }
314 } 315 }
315 316
316 static void OverdriveAndSuppress(float overdrive_scaling, 317 static void Overdrive(float overdrive_scaling,
317 float hNl[PART_LEN1], 318 const float hNlFb,
318 const float hNlFb, 319 float hNl[PART_LEN1]) {
319 float efw[2][PART_LEN1]) { 320 for (int i = 0; i < PART_LEN1; ++i) {
320 int i;
321 for (i = 0; i < PART_LEN1; i++) {
322 // Weight subbands 321 // Weight subbands
323 if (hNl[i] > hNlFb) { 322 if (hNl[i] > hNlFb) {
324 hNl[i] = WebRtcAec_weightCurve[i] * hNlFb + 323 hNl[i] = WebRtcAec_weightCurve[i] * hNlFb +
325 (1 - WebRtcAec_weightCurve[i]) * hNl[i]; 324 (1 - WebRtcAec_weightCurve[i]) * hNl[i];
326 } 325 }
327 hNl[i] = powf(hNl[i], overdrive_scaling * WebRtcAec_overDriveCurve[i]); 326 hNl[i] = powf(hNl[i], overdrive_scaling * WebRtcAec_overDriveCurve[i]);
327 }
328 }
328 329
330 static void Suppress(float hNl[PART_LEN1], float efw[2][PART_LEN1]) {
hlundin-webrtc 2016/05/03 08:22:29 hNl should be const.
peah-webrtc 2016/05/07 21:26:15 Done.
331 for (int i = 0; i < PART_LEN1; ++i) {
329 // Suppress error signal 332 // Suppress error signal
330 efw[0][i] *= hNl[i]; 333 efw[0][i] *= hNl[i];
331 efw[1][i] *= hNl[i]; 334 efw[1][i] *= hNl[i];
332 335
333 // Ooura fft returns incorrect sign on imaginary component. It matters here 336 // Ooura fft returns incorrect sign on imaginary component. It matters here
334 // because we are making an additive change with comfort noise. 337 // because we are making an additive change with comfort noise.
335 efw[1][i] *= -1; 338 efw[1][i] *= -1;
336 } 339 }
337 } 340 }
338 341
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 1159
1157 // Smooth the overdrive. 1160 // Smooth the overdrive.
1158 if (aec->overDrive < aec->overdrive_scaling) { 1161 if (aec->overDrive < aec->overdrive_scaling) {
1159 aec->overdrive_scaling = 1162 aec->overdrive_scaling =
1160 0.99f * aec->overdrive_scaling + 0.01f * aec->overDrive; 1163 0.99f * aec->overdrive_scaling + 0.01f * aec->overDrive;
1161 } else { 1164 } else {
1162 aec->overdrive_scaling = 1165 aec->overdrive_scaling =
1163 0.9f * aec->overdrive_scaling + 0.1f * aec->overDrive; 1166 0.9f * aec->overdrive_scaling + 0.1f * aec->overDrive;
1164 } 1167 }
1165 1168
1166 WebRtcAec_OverdriveAndSuppress(aec->overdrive_scaling, hNl, hNlFb, efw); 1169 WebRtcAec_Overdrive(aec->overdrive_scaling, hNlFb, hNl);
1170 WebRtcAec_Suppress(hNl, efw);
1167 1171
1168 // Add comfort noise. 1172 // Add comfort noise.
1169 ComfortNoise(aec, efw, comfortNoiseHband, aec->noisePow, hNl); 1173 ComfortNoise(aec, efw, comfortNoiseHband, aec->noisePow, hNl);
1170 1174
1171 // Inverse error fft. 1175 // Inverse error fft.
1172 ScaledInverseFft(efw, fft, 2.0f, 1); 1176 ScaledInverseFft(efw, fft, 2.0f, 1);
1173 1177
1174 // Overlap and add to obtain output. 1178 // Overlap and add to obtain output.
1175 for (i = 0; i < PART_LEN; i++) { 1179 for (i = 0; i < PART_LEN; i++) {
1176 output[i] = (fft[i] * WebRtcAec_sqrtHanning[i] + 1180 output[i] = (fft[i] * WebRtcAec_sqrtHanning[i] +
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 WebRtc_set_lookahead(aec->delay_estimator, kLookaheadBlocks); 1488 WebRtc_set_lookahead(aec->delay_estimator, kLookaheadBlocks);
1485 #endif 1489 #endif
1486 aec->extended_filter_enabled = 0; 1490 aec->extended_filter_enabled = 0;
1487 aec->aec3_enabled = 0; 1491 aec->aec3_enabled = 0;
1488 aec->refined_adaptive_filter_enabled = false; 1492 aec->refined_adaptive_filter_enabled = false;
1489 1493
1490 // Assembly optimization 1494 // Assembly optimization
1491 WebRtcAec_FilterFar = FilterFar; 1495 WebRtcAec_FilterFar = FilterFar;
1492 WebRtcAec_ScaleErrorSignal = ScaleErrorSignal; 1496 WebRtcAec_ScaleErrorSignal = ScaleErrorSignal;
1493 WebRtcAec_FilterAdaptation = FilterAdaptation; 1497 WebRtcAec_FilterAdaptation = FilterAdaptation;
1494 WebRtcAec_OverdriveAndSuppress = OverdriveAndSuppress; 1498 WebRtcAec_Overdrive = Overdrive;
1499 WebRtcAec_Suppress = Suppress;
1495 WebRtcAec_ComputeCoherence = ComputeCoherence; 1500 WebRtcAec_ComputeCoherence = ComputeCoherence;
1496 WebRtcAec_UpdateCoherenceSpectra = UpdateCoherenceSpectra; 1501 WebRtcAec_UpdateCoherenceSpectra = UpdateCoherenceSpectra;
1497 WebRtcAec_StoreAsComplex = StoreAsComplex; 1502 WebRtcAec_StoreAsComplex = StoreAsComplex;
1498 WebRtcAec_PartitionDelay = PartitionDelay; 1503 WebRtcAec_PartitionDelay = PartitionDelay;
1499 WebRtcAec_WindowData = WindowData; 1504 WebRtcAec_WindowData = WindowData;
1500 1505
1501 #if defined(WEBRTC_ARCH_X86_FAMILY) 1506 #if defined(WEBRTC_ARCH_X86_FAMILY)
1502 if (WebRtc_GetCPUInfo(kSSE2)) { 1507 if (WebRtc_GetCPUInfo(kSSE2)) {
1503 WebRtcAec_InitAec_SSE2(); 1508 WebRtcAec_InitAec_SSE2();
1504 } 1509 }
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
1991 1996
1992 int WebRtcAec_system_delay(AecCore* self) { 1997 int WebRtcAec_system_delay(AecCore* self) {
1993 return self->system_delay; 1998 return self->system_delay;
1994 } 1999 }
1995 2000
1996 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { 2001 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) {
1997 assert(delay >= 0); 2002 assert(delay >= 0);
1998 self->system_delay = delay; 2003 self->system_delay = delay;
1999 } 2004 }
2000 } // namespace webrtc 2005 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698