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

Side by Side Diff: webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.cc

Issue 1841323002: Fix division by zero in NonlinearBeamformer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Remove TODO Created 4 years, 8 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/beamformer/nonlinear_beamformer_unittest.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) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 float rpsiw, 464 float rpsiw,
465 float ratio_rxiw_rxim, 465 float ratio_rxiw_rxim,
466 float rmw_r) { 466 float rmw_r) {
467 float rpsim = Norm(interf_cov_mat, eig_m_); 467 float rpsim = Norm(interf_cov_mat, eig_m_);
468 468
469 float ratio = 0.f; 469 float ratio = 0.f;
470 if (rpsim > 0.f) { 470 if (rpsim > 0.f) {
471 ratio = rpsiw / rpsim; 471 ratio = rpsiw / rpsim;
472 } 472 }
473 473
474 return (1.f - std::min(kCutOffConstant, ratio / rmw_r)) / 474 float numerator = 1.f - kCutOffConstant;
475 (1.f - std::min(kCutOffConstant, ratio / ratio_rxiw_rxim)); 475 if (rmw_r > 0.f) {
476 numerator = 1.f - std::min(kCutOffConstant, ratio / rmw_r);
477 }
478
479 float denominator = 1.f - kCutOffConstant;
480 if (ratio_rxiw_rxim > 0.f) {
481 denominator = 1.f - std::min(kCutOffConstant, ratio / ratio_rxiw_rxim);
482 }
483
484 return numerator / denominator;
476 } 485 }
477 486
478 void NonlinearBeamformer::ApplyMasks(const complex_f* const* input, 487 void NonlinearBeamformer::ApplyMasks(const complex_f* const* input,
479 complex_f* const* output) { 488 complex_f* const* output) {
480 complex_f* output_channel = output[0]; 489 complex_f* output_channel = output[0];
481 for (size_t f_ix = 0; f_ix < kNumFreqBins; ++f_ix) { 490 for (size_t f_ix = 0; f_ix < kNumFreqBins; ++f_ix) {
482 output_channel[f_ix] = complex_f(0.f, 0.f); 491 output_channel[f_ix] = complex_f(0.f, 0.f);
483 492
484 const complex_f* delay_sum_mask_els = 493 const complex_f* delay_sum_mask_els =
485 normalized_delay_sum_masks_[f_ix].elements()[0]; 494 normalized_delay_sum_masks_[f_ix].elements()[0];
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 new_mask_ + high_mean_end_bin_ + 1); 570 new_mask_ + high_mean_end_bin_ + 1);
562 if (new_mask_[quantile] > kMaskTargetThreshold) { 571 if (new_mask_[quantile] > kMaskTargetThreshold) {
563 is_target_present_ = true; 572 is_target_present_ = true;
564 interference_blocks_count_ = 0; 573 interference_blocks_count_ = 0;
565 } else { 574 } else {
566 is_target_present_ = interference_blocks_count_++ < hold_target_blocks_; 575 is_target_present_ = interference_blocks_count_++ < hold_target_blocks_;
567 } 576 }
568 } 577 }
569 578
570 } // namespace webrtc 579 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/audio_processing/beamformer/nonlinear_beamformer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698