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

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

Issue 1454983006: Ducking fix #2: Removed the aec state as an input parameter to the FilterFar function. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@Aec_Code_Cleanup_CL
Patch Set: Corrected line alignment Created 5 years 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 return aRe * bIm + aIm * bRe; 144 return aRe * bIm + aIm * bRe;
145 } 145 }
146 146
147 static int CmpFloat(const void* a, const void* b) { 147 static int CmpFloat(const void* a, const void* b) {
148 const float* da = (const float*)a; 148 const float* da = (const float*)a;
149 const float* db = (const float*)b; 149 const float* db = (const float*)b;
150 150
151 return (*da > *db) - (*da < *db); 151 return (*da > *db) - (*da < *db);
152 } 152 }
153 153
154 static void FilterFar(AecCore* aec, float yf[2][PART_LEN1]) { 154 static void FilterFar(int num_partitions,
155 int x_fft_buffer_block_pos,
156 float x_fft_buffer[2][kExtendedNumPartitions * PART_LEN1],
157 float h_fft_buffer[2][kExtendedNumPartitions * PART_LEN1],
158 float y_fft[2][PART_LEN1]) {
155 int i; 159 int i;
156 for (i = 0; i < aec->num_partitions; i++) { 160 for (i = 0; i < num_partitions; i++) {
157 int j; 161 int j;
158 int xPos = (i + aec->xfBufBlockPos) * PART_LEN1; 162 int x_pos = (i + x_fft_buffer_block_pos) * PART_LEN1;
159 int pos = i * PART_LEN1; 163 int pos = i * PART_LEN1;
160 // Check for wrap 164 // Check for wrapped buffer.
161 if (i + aec->xfBufBlockPos >= aec->num_partitions) { 165 if (i + x_fft_buffer_block_pos >= num_partitions) {
162 xPos -= aec->num_partitions * (PART_LEN1); 166 x_pos -= num_partitions * (PART_LEN1);
163 } 167 }
164 168
165 for (j = 0; j < PART_LEN1; j++) { 169 for (j = 0; j < PART_LEN1; j++) {
166 yf[0][j] += MulRe(aec->xfBuf[0][xPos + j], 170 y_fft[0][j] += MulRe(x_fft_buffer[0][x_pos + j],
167 aec->xfBuf[1][xPos + j], 171 x_fft_buffer[1][x_pos + j],
168 aec->wfBuf[0][pos + j], 172 h_fft_buffer[0][pos + j],
169 aec->wfBuf[1][pos + j]); 173 h_fft_buffer[1][pos + j]);
170 yf[1][j] += MulIm(aec->xfBuf[0][xPos + j], 174 y_fft[1][j] += MulIm(x_fft_buffer[0][x_pos + j],
171 aec->xfBuf[1][xPos + j], 175 x_fft_buffer[1][x_pos + j],
172 aec->wfBuf[0][pos + j], 176 h_fft_buffer[0][pos + j],
173 aec->wfBuf[1][pos + j]); 177 h_fft_buffer[1][pos + j]);
174 } 178 }
175 } 179 }
176 } 180 }
177 181
178 static void ScaleErrorSignal(int extended_filter_enabled, 182 static void ScaleErrorSignal(int extended_filter_enabled,
179 float normal_mu, 183 float normal_mu,
180 float normal_error_threshold, 184 float normal_error_threshold,
181 float *x_pow, 185 float *x_pow,
182 float ef[2][PART_LEN1]) { 186 float ef[2][PART_LEN1]) {
183 const float mu = extended_filter_enabled ? kExtendedMu : normal_mu; 187 const float mu = extended_filter_enabled ? kExtendedMu : normal_mu;
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 float yf[2][PART_LEN1]; 968 float yf[2][PART_LEN1];
965 float fft[PART_LEN2]; 969 float fft[PART_LEN2];
966 float y[PART_LEN]; 970 float y[PART_LEN];
967 float e[PART_LEN]; 971 float e[PART_LEN];
968 float ef[2][PART_LEN1]; 972 float ef[2][PART_LEN1];
969 float scale; 973 float scale;
970 int i; 974 int i;
971 memset(yf, 0, sizeof(yf)); 975 memset(yf, 0, sizeof(yf));
972 976
973 // Produce frequency domain echo estimate. 977 // Produce frequency domain echo estimate.
974 WebRtcAec_FilterFar(aec, yf); 978 WebRtcAec_FilterFar(aec->num_partitions,
979 aec->xfBufBlockPos,
980 aec->xfBuf,
981 aec->wfBuf,
982 yf);
975 983
976 // Inverse fft to obtain echo estimate and error. 984 // Inverse fft to obtain echo estimate and error.
977 FrequencyToTime(yf, fft); 985 FrequencyToTime(yf, fft);
978 986
979 // Extract the output signal and compute the time-domain error. 987 // Extract the output signal and compute the time-domain error.
980 scale = 2.0f / PART_LEN2; 988 scale = 2.0f / PART_LEN2;
981 for (i = 0; i < PART_LEN; ++i) { 989 for (i = 0; i < PART_LEN; ++i) {
982 y[i] = fft[PART_LEN + i] * scale; // fft scaling. 990 y[i] = fft[PART_LEN + i] * scale; // fft scaling.
983 e[i] = nearend_ptr[i] - y[i]; 991 e[i] = nearend_ptr[i] - y[i];
984 } 992 }
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after
1939 int WebRtcAec_extended_filter_enabled(AecCore* self) { 1947 int WebRtcAec_extended_filter_enabled(AecCore* self) {
1940 return self->extended_filter_enabled; 1948 return self->extended_filter_enabled;
1941 } 1949 }
1942 1950
1943 int WebRtcAec_system_delay(AecCore* self) { return self->system_delay; } 1951 int WebRtcAec_system_delay(AecCore* self) { return self->system_delay; }
1944 1952
1945 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) { 1953 void WebRtcAec_SetSystemDelay(AecCore* self, int delay) {
1946 assert(delay >= 0); 1954 assert(delay >= 0);
1947 self->system_delay = delay; 1955 self->system_delay = delay;
1948 } 1956 }
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