OLD | NEW |
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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 complex<float> result = complex<float>(0.f, 0.f); | 113 complex<float> result = complex<float>(0.f, 0.f); |
114 for (int i = 0; i < lhs.num_columns(); ++i) { | 114 for (int i = 0; i < lhs.num_columns(); ++i) { |
115 result += conj(lhs_elements[0][i]) * rhs_elements[0][i]; | 115 result += conj(lhs_elements[0][i]) * rhs_elements[0][i]; |
116 } | 116 } |
117 | 117 |
118 return result; | 118 return result; |
119 } | 119 } |
120 | 120 |
121 // Works for positive numbers only. | 121 // Works for positive numbers only. |
122 int Round(float x) { | 122 int Round(float x) { |
123 return std::floor(x + 0.5f); | 123 return static_cast<int>(std::floor(x + 0.5f)); |
124 } | 124 } |
125 | 125 |
126 // Calculates the sum of absolute values of a complex matrix. | 126 // Calculates the sum of absolute values of a complex matrix. |
127 float SumAbs(const ComplexMatrix<float>& mat) { | 127 float SumAbs(const ComplexMatrix<float>& mat) { |
128 float sum_abs = 0.f; | 128 float sum_abs = 0.f; |
129 const complex<float>* const* mat_els = mat.elements(); | 129 const complex<float>* const* mat_els = mat.elements(); |
130 for (int i = 0; i < mat.num_rows(); ++i) { | 130 for (int i = 0; i < mat.num_rows(); ++i) { |
131 for (int j = 0; j < mat.num_columns(); ++j) { | 131 for (int j = 0; j < mat.num_columns(); ++j) { |
132 sum_abs += std::abs(mat_els[i][j]); | 132 sum_abs += std::abs(mat_els[i][j]); |
133 } | 133 } |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 // Downward smoothing: | 457 // Downward smoothing: |
458 // high_mean_end_bin_ | 458 // high_mean_end_bin_ |
459 // v | 459 // v |
460 // |------|------------|------| | 460 // |------|------------|------| |
461 // ^<------------------^ | 461 // ^<------------------^ |
462 std::copy(time_smooth_mask_, time_smooth_mask_ + kNumFreqBins, final_mask_); | 462 std::copy(time_smooth_mask_, time_smooth_mask_ + kNumFreqBins, final_mask_); |
463 for (int i = low_mean_start_bin_; i < kNumFreqBins; ++i) { | 463 for (int i = low_mean_start_bin_; i < kNumFreqBins; ++i) { |
464 final_mask_[i] = kMaskFrequencySmoothAlpha * final_mask_[i] + | 464 final_mask_[i] = kMaskFrequencySmoothAlpha * final_mask_[i] + |
465 (1 - kMaskFrequencySmoothAlpha) * final_mask_[i - 1]; | 465 (1 - kMaskFrequencySmoothAlpha) * final_mask_[i - 1]; |
466 } | 466 } |
467 for (int i = high_mean_end_bin_; i >= 0; --i) { | 467 for (int i = high_mean_end_bin_ + 1; i > 0; --i) { |
468 final_mask_[i] = kMaskFrequencySmoothAlpha * final_mask_[i] + | 468 final_mask_[i - 1] = kMaskFrequencySmoothAlpha * final_mask_[i - 1] + |
469 (1 - kMaskFrequencySmoothAlpha) * final_mask_[i + 1]; | 469 (1 - kMaskFrequencySmoothAlpha) * final_mask_[i]; |
470 } | 470 } |
471 } | 471 } |
472 | 472 |
473 // Apply low frequency correction to time_smooth_mask_. | 473 // Apply low frequency correction to time_smooth_mask_. |
474 void NonlinearBeamformer::ApplyLowFrequencyCorrection() { | 474 void NonlinearBeamformer::ApplyLowFrequencyCorrection() { |
475 const float low_frequency_mask = | 475 const float low_frequency_mask = |
476 MaskRangeMean(low_mean_start_bin_, low_mean_end_bin_ + 1); | 476 MaskRangeMean(low_mean_start_bin_, low_mean_end_bin_ + 1); |
477 std::fill(time_smooth_mask_, time_smooth_mask_ + low_mean_start_bin_, | 477 std::fill(time_smooth_mask_, time_smooth_mask_ + low_mean_start_bin_, |
478 low_frequency_mask); | 478 low_frequency_mask); |
479 } | 479 } |
(...skipping 23 matching lines...) Expand all Loading... |
503 new_mask_ + high_mean_end_bin_ + 1); | 503 new_mask_ + high_mean_end_bin_ + 1); |
504 if (new_mask_[quantile] > kMaskTargetThreshold) { | 504 if (new_mask_[quantile] > kMaskTargetThreshold) { |
505 is_target_present_ = true; | 505 is_target_present_ = true; |
506 interference_blocks_count_ = 0; | 506 interference_blocks_count_ = 0; |
507 } else { | 507 } else { |
508 is_target_present_ = interference_blocks_count_++ < hold_target_blocks_; | 508 is_target_present_ = interference_blocks_count_++ < hold_target_blocks_; |
509 } | 509 } |
510 } | 510 } |
511 | 511 |
512 } // namespace webrtc | 512 } // namespace webrtc |
OLD | NEW |