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

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

Issue 2319693003: Refactoring of the farend buffering scheme inside the AEC (Closed)
Patch Set: Rebase Created 4 years, 3 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.cc » ('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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 }; 76 };
77 77
78 typedef struct PowerLevel { 78 typedef struct PowerLevel {
79 PowerLevel(); 79 PowerLevel();
80 80
81 BlockMeanCalculator framelevel; 81 BlockMeanCalculator framelevel;
82 BlockMeanCalculator averagelevel; 82 BlockMeanCalculator averagelevel;
83 float minlevel; 83 float minlevel;
84 } PowerLevel; 84 } PowerLevel;
85 85
86 class BlockBuffer {
87 public:
88 BlockBuffer();
89 ~BlockBuffer();
90 void ReInit();
91 void Insert(const float block[PART_LEN]);
92 void ExtractExtendedBlock(float extended_block[PART_LEN]);
93 int AdjustSize(int buffer_size_decrease);
94 size_t Size();
95 size_t AvaliableSpace();
96
97 private:
98 RingBuffer* buffer_;
99 };
100
86 class DivergentFilterFraction { 101 class DivergentFilterFraction {
87 public: 102 public:
88 DivergentFilterFraction(); 103 DivergentFilterFraction();
89 104
90 // Reset. 105 // Reset.
91 void Reset(); 106 void Reset();
92 107
93 void AddObservation(const PowerLevel& nearlevel, 108 void AddObservation(const PowerLevel& nearlevel,
94 const PowerLevel& linoutlevel, 109 const PowerLevel& linoutlevel,
95 const PowerLevel& nlpoutlevel); 110 const PowerLevel& nlpoutlevel);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 float overdrive_scaling; 176 float overdrive_scaling;
162 int nlp_mode; 177 int nlp_mode;
163 float outBuf[PART_LEN]; 178 float outBuf[PART_LEN];
164 int delayIdx; 179 int delayIdx;
165 180
166 short stNearState, echoState; 181 short stNearState, echoState;
167 short divergeState; 182 short divergeState;
168 183
169 int xfBufBlockPos; 184 int xfBufBlockPos;
170 185
171 RingBuffer* far_time_buf; 186 BlockBuffer farend_block_buffer_;
172 187
173 int system_delay; // Current system delay buffered in AEC. 188 int system_delay; // Current system delay buffered in AEC.
174 189
175 int mult; // sampling frequency multiple 190 int mult; // sampling frequency multiple
176 int sampFreq = 16000; 191 int sampFreq = 16000;
177 size_t num_bands; 192 size_t num_bands;
178 uint32_t seed; 193 uint32_t seed;
179 194
180 float filter_step_size; // stepsize 195 float filter_step_size; // stepsize
181 float error_threshold; // error threshold 196 float error_threshold; // error threshold
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 void WebRtcAec_FreeAec(AecCore* aec); 254 void WebRtcAec_FreeAec(AecCore* aec);
240 int WebRtcAec_InitAec(AecCore* aec, int sampFreq); 255 int WebRtcAec_InitAec(AecCore* aec, int sampFreq);
241 void WebRtcAec_InitAec_SSE2(void); 256 void WebRtcAec_InitAec_SSE2(void);
242 #if defined(MIPS_FPU_LE) 257 #if defined(MIPS_FPU_LE)
243 void WebRtcAec_InitAec_mips(void); 258 void WebRtcAec_InitAec_mips(void);
244 #endif 259 #endif
245 #if defined(WEBRTC_HAS_NEON) 260 #if defined(WEBRTC_HAS_NEON)
246 void WebRtcAec_InitAec_neon(void); 261 void WebRtcAec_InitAec_neon(void);
247 #endif 262 #endif
248 263
249 void WebRtcAec_BufferFarendPartition(AecCore* aec, const float* farend); 264 void WebRtcAec_BufferFarendBlock(AecCore* aec, const float* farend);
250 void WebRtcAec_ProcessFrames(AecCore* aec, 265 void WebRtcAec_ProcessFrames(AecCore* aec,
251 const float* const* nearend, 266 const float* const* nearend,
252 size_t num_bands, 267 size_t num_bands,
253 size_t num_samples, 268 size_t num_samples,
254 int knownDelay, 269 int knownDelay,
255 float* const* out); 270 float* const* out);
256 271
257 // A helper function to call WebRtc_MoveReadPtr() for all far-end buffers. 272 // A helper function to call adjust the farend buffer size.
258 // Returns the number of elements moved, and adjusts |system_delay| by the 273 // Returns the number of elements the size was decreased with, and adjusts
259 // corresponding amount in ms. 274 // |system_delay| by the corresponding amount in ms.
260 int WebRtcAec_MoveFarReadPtr(AecCore* aec, int elements); 275 int WebRtcAec_AdjustFarendBufferSizeAndSystemDelay(AecCore* aec,
276 int size_decrease);
261 277
262 // Calculates the median, standard deviation and amount of poor values among the 278 // Calculates the median, standard deviation and amount of poor values among the
263 // delay estimates aggregated up to the first call to the function. After that 279 // delay estimates aggregated up to the first call to the function. After that
264 // first call the metrics are aggregated and updated every second. With poor 280 // first call the metrics are aggregated and updated every second. With poor
265 // values we mean values that most likely will cause the AEC to perform poorly. 281 // values we mean values that most likely will cause the AEC to perform poorly.
266 // TODO(bjornv): Consider changing tests and tools to handle constant 282 // TODO(bjornv): Consider changing tests and tools to handle constant
267 // constant aggregation window throughout the session instead. 283 // constant aggregation window throughout the session instead.
268 int WebRtcAec_GetDelayMetricsCore(AecCore* self, 284 int WebRtcAec_GetDelayMetricsCore(AecCore* self,
269 int* median, 285 int* median,
270 int* std, 286 int* std,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 int WebRtcAec_system_delay(AecCore* self); 332 int WebRtcAec_system_delay(AecCore* self);
317 333
318 // Sets the |system_delay| to |value|. Note that if the value is changed 334 // Sets the |system_delay| to |value|. Note that if the value is changed
319 // improperly, there can be a performance regression. So it should be used with 335 // improperly, there can be a performance regression. So it should be used with
320 // care. 336 // care.
321 void WebRtcAec_SetSystemDelay(AecCore* self, int delay); 337 void WebRtcAec_SetSystemDelay(AecCore* self, int delay);
322 338
323 } // namespace webrtc 339 } // namespace webrtc
324 340
325 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_CORE_H_ 341 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC_AEC_CORE_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/audio_processing/aec/aec_core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698