OLD | NEW |
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 | 10 |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 aec3::UpdateErlEstimator(H2_, &erl_); | 500 aec3::UpdateErlEstimator(H2_, &erl_); |
501 } | 501 } |
502 } | 502 } |
503 | 503 |
504 // Constrains the a partiton of the frequency domain filter to be limited in | 504 // Constrains the a partiton of the frequency domain filter to be limited in |
505 // time via setting the relevant time-domain coefficients to zero. | 505 // time via setting the relevant time-domain coefficients to zero. |
506 void AdaptiveFirFilter::Constrain() { | 506 void AdaptiveFirFilter::Constrain() { |
507 std::array<float, kFftLength> h; | 507 std::array<float, kFftLength> h; |
508 fft_.Ifft(H_[partition_to_constrain_], &h); | 508 fft_.Ifft(H_[partition_to_constrain_], &h); |
509 | 509 |
510 const float kScale = 1.0f / kFftLengthBy2; | 510 static constexpr float kScale = 1.0f / kFftLengthBy2; |
511 std::for_each(h.begin(), h.begin() + kFftLengthBy2, | 511 std::for_each(h.begin(), h.begin() + kFftLengthBy2, |
512 [kScale](float& a) { a *= kScale; }); | 512 [](float& a) { a *= kScale; }); |
513 std::fill(h.begin() + kFftLengthBy2, h.end(), 0.f); | 513 std::fill(h.begin() + kFftLengthBy2, h.end(), 0.f); |
514 | 514 |
515 std::copy(h.begin(), h.begin() + kFftLengthBy2, | 515 std::copy(h.begin(), h.begin() + kFftLengthBy2, |
516 h_.begin() + partition_to_constrain_ * kFftLengthBy2); | 516 h_.begin() + partition_to_constrain_ * kFftLengthBy2); |
517 | 517 |
518 fft_.Fft(&h, &H_[partition_to_constrain_]); | 518 fft_.Fft(&h, &H_[partition_to_constrain_]); |
519 | 519 |
520 partition_to_constrain_ = partition_to_constrain_ < (H_.size() - 1) | 520 partition_to_constrain_ = partition_to_constrain_ < (H_.size() - 1) |
521 ? partition_to_constrain_ + 1 | 521 ? partition_to_constrain_ + 1 |
522 : 0; | 522 : 0; |
523 } | 523 } |
524 | 524 |
525 } // namespace webrtc | 525 } // namespace webrtc |
OLD | NEW |