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

Side by Side Diff: webrtc/modules/audio_processing/aec3/matched_filter.cc

Issue 3007833002: Further utilizing the AEC3 config struct for constants (Closed)
Patch Set: Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2017 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 #include "webrtc/modules/audio_processing/aec3/matched_filter.h" 10 #include "webrtc/modules/audio_processing/aec3/matched_filter.h"
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 x_start_index = x_start_index > 0 ? x_start_index - 1 : x.size() - 1; 284 x_start_index = x_start_index > 0 ? x_start_index - 1 : x.size() - 1;
285 } 285 }
286 } 286 }
287 287
288 } // namespace aec3 288 } // namespace aec3
289 289
290 MatchedFilter::MatchedFilter(ApmDataDumper* data_dumper, 290 MatchedFilter::MatchedFilter(ApmDataDumper* data_dumper,
291 Aec3Optimization optimization, 291 Aec3Optimization optimization,
292 size_t window_size_sub_blocks, 292 size_t window_size_sub_blocks,
293 int num_matched_filters, 293 int num_matched_filters,
294 size_t alignment_shift_sub_blocks) 294 size_t alignment_shift_sub_blocks,
295 float excitation_limit)
295 : data_dumper_(data_dumper), 296 : data_dumper_(data_dumper),
296 optimization_(optimization), 297 optimization_(optimization),
297 filter_intra_lag_shift_(alignment_shift_sub_blocks * kSubBlockSize), 298 filter_intra_lag_shift_(alignment_shift_sub_blocks * kSubBlockSize),
298 filters_(num_matched_filters, 299 filters_(num_matched_filters,
299 std::vector<float>(window_size_sub_blocks * kSubBlockSize, 0.f)), 300 std::vector<float>(window_size_sub_blocks * kSubBlockSize, 0.f)),
300 lag_estimates_(num_matched_filters) { 301 lag_estimates_(num_matched_filters),
302 excitation_limit_(excitation_limit) {
301 RTC_DCHECK(data_dumper); 303 RTC_DCHECK(data_dumper);
302 RTC_DCHECK_LT(0, window_size_sub_blocks); 304 RTC_DCHECK_LT(0, window_size_sub_blocks);
303 } 305 }
304 306
305 MatchedFilter::~MatchedFilter() = default; 307 MatchedFilter::~MatchedFilter() = default;
306 308
307 void MatchedFilter::Reset() { 309 void MatchedFilter::Reset() {
308 for (auto& f : filters_) { 310 for (auto& f : filters_) {
309 std::fill(f.begin(), f.end(), 0.f); 311 std::fill(f.begin(), f.end(), 0.f);
310 } 312 }
311 313
312 for (auto& l : lag_estimates_) { 314 for (auto& l : lag_estimates_) {
313 l = MatchedFilter::LagEstimate(); 315 l = MatchedFilter::LagEstimate();
314 } 316 }
315 } 317 }
316 318
317 void MatchedFilter::Update(const DownsampledRenderBuffer& render_buffer, 319 void MatchedFilter::Update(const DownsampledRenderBuffer& render_buffer,
318 const std::array<float, kSubBlockSize>& capture) { 320 const std::array<float, kSubBlockSize>& capture) {
319 const std::array<float, kSubBlockSize>& y = capture; 321 const std::array<float, kSubBlockSize>& y = capture;
320 322
321 const float x2_sum_threshold = filters_[0].size() * 150.f * 150.f; 323 const float x2_sum_threshold =
324 filters_[0].size() * excitation_limit_ * excitation_limit_;
322 325
323 // Apply all matched filters. 326 // Apply all matched filters.
324 size_t alignment_shift = 0; 327 size_t alignment_shift = 0;
325 for (size_t n = 0; n < filters_.size(); ++n) { 328 for (size_t n = 0; n < filters_.size(); ++n) {
326 float error_sum = 0.f; 329 float error_sum = 0.f;
327 bool filters_updated = false; 330 bool filters_updated = false;
328 331
329 size_t x_start_index = 332 size_t x_start_index =
330 (render_buffer.position + alignment_shift + kSubBlockSize - 1) % 333 (render_buffer.position + alignment_shift + kSubBlockSize - 1) %
331 render_buffer.buffer.size(); 334 render_buffer.buffer.size();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 break; 392 break;
390 default: 393 default:
391 RTC_DCHECK(false); 394 RTC_DCHECK(false);
392 } 395 }
393 396
394 alignment_shift += filter_intra_lag_shift_; 397 alignment_shift += filter_intra_lag_shift_;
395 } 398 }
396 } 399 }
397 400
398 } // namespace webrtc 401 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/aec3/matched_filter.h ('k') | webrtc/modules/audio_processing/aec3/matched_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698