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

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

Issue 1936203002: Made the method PartitionDelay independent of the AEC state. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@RefactorAec3_CL
Patch Set: Rebase 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
« no previous file with comments | « no previous file | webrtc/modules/audio_processing/aec/aec_core_internal.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 // Suppress error signal 322 // Suppress error signal
323 efw[0][i] *= hNl[i]; 323 efw[0][i] *= hNl[i];
324 efw[1][i] *= hNl[i]; 324 efw[1][i] *= hNl[i];
325 325
326 // Ooura fft returns incorrect sign on imaginary component. It matters here 326 // Ooura fft returns incorrect sign on imaginary component. It matters here
327 // because we are making an additive change with comfort noise. 327 // because we are making an additive change with comfort noise.
328 efw[1][i] *= -1; 328 efw[1][i] *= -1;
329 } 329 }
330 } 330 }
331 331
332 static int PartitionDelay(const AecCore* aec) { 332 static int PartitionDelay(int num_partitions,
333 float h_fft_buf[2]
334 [kExtendedNumPartitions * PART_LEN1]) {
333 // Measures the energy in each filter partition and returns the partition with 335 // Measures the energy in each filter partition and returns the partition with
334 // highest energy. 336 // highest energy.
335 // TODO(bjornv): Spread computational cost by computing one partition per 337 // TODO(bjornv): Spread computational cost by computing one partition per
336 // block? 338 // block?
337 float wfEnMax = 0; 339 float wfEnMax = 0;
338 int i; 340 int i;
339 int delay = 0; 341 int delay = 0;
340 342
341 for (i = 0; i < aec->num_partitions; i++) { 343 for (i = 0; i < num_partitions; i++) {
342 int j; 344 int j;
343 int pos = i * PART_LEN1; 345 int pos = i * PART_LEN1;
344 float wfEn = 0; 346 float wfEn = 0;
345 for (j = 0; j < PART_LEN1; j++) { 347 for (j = 0; j < PART_LEN1; j++) {
346 wfEn += aec->wfBuf[0][pos + j] * aec->wfBuf[0][pos + j] + 348 wfEn += h_fft_buf[0][pos + j] * h_fft_buf[0][pos + j] +
347 aec->wfBuf[1][pos + j] * aec->wfBuf[1][pos + j]; 349 h_fft_buf[1][pos + j] * h_fft_buf[1][pos + j];
348 } 350 }
349 351
350 if (wfEn > wfEnMax) { 352 if (wfEn > wfEnMax) {
351 wfEnMax = wfEn; 353 wfEnMax = wfEn;
352 delay = i; 354 delay = i;
353 } 355 }
354 } 356 }
355 return delay; 357 return delay;
356 } 358 }
357 359
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 WindowData(fft, farend); 1048 WindowData(fft, farend);
1047 Fft(fft, xfw); 1049 Fft(fft, xfw);
1048 xfw_ptr = &xfw[0][0]; 1050 xfw_ptr = &xfw[0][0];
1049 1051
1050 // Buffer far. 1052 // Buffer far.
1051 memcpy(aec->xfwBuf, xfw_ptr, sizeof(float) * 2 * PART_LEN1); 1053 memcpy(aec->xfwBuf, xfw_ptr, sizeof(float) * 2 * PART_LEN1);
1052 1054
1053 aec->delayEstCtr++; 1055 aec->delayEstCtr++;
1054 if (aec->delayEstCtr == delayEstInterval) { 1056 if (aec->delayEstCtr == delayEstInterval) {
1055 aec->delayEstCtr = 0; 1057 aec->delayEstCtr = 0;
1056 aec->delayIdx = WebRtcAec_PartitionDelay(aec); 1058 aec->delayIdx = WebRtcAec_PartitionDelay(aec->num_partitions, aec->wfBuf);
1057 } 1059 }
1058 1060
1059 // Use delayed far. 1061 // Use delayed far.
1060 memcpy(xfw, aec->xfwBuf + aec->delayIdx * PART_LEN1, 1062 memcpy(xfw, aec->xfwBuf + aec->delayIdx * PART_LEN1,
1061 sizeof(xfw[0][0]) * 2 * PART_LEN1); 1063 sizeof(xfw[0][0]) * 2 * PART_LEN1);
1062 1064
1063 WebRtcAec_SubbandCoherence(aec->mult, aec->extended_filter_enabled == 1, efw, 1065 WebRtcAec_SubbandCoherence(aec->mult, aec->extended_filter_enabled == 1, efw,
1064 dfw, xfw, fft, cohde, cohxd, &aec->coherence_state, 1066 dfw, xfw, fft, cohde, cohxd, &aec->coherence_state,
1065 &aec->divergeState, 1067 &aec->divergeState,
1066 &aec->extreme_filter_divergence); 1068 &aec->extreme_filter_divergence);
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
1958 1960
1959 int WebRtcAec_system_delay(AecCore* self) { 1961 int WebRtcAec_system_delay(AecCore* self) {
1960 return self->system_delay; 1962 return self->system_delay;
1961 } 1963 }
1962 1964
1963 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { 1965 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) {
1964 assert(delay >= 0); 1966 assert(delay >= 0);
1965 self->system_delay = delay; 1967 self->system_delay = delay;
1966 } 1968 }
1967 } // namespace webrtc 1969 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/audio_processing/aec/aec_core_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698