AEC3: Avoid heap-allocations in sums of the values in nested vectors

This CL avoids the head-allocations done in a sum of the squared values
in a nested vector.

Bug: webrtc:11361, chromium:1052086
Change-Id: I698b855bdd54df2147ef3b6d5e3d401401228d76
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168543
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30520}
This commit is contained in:
Per Åhgren
2020-02-13 21:08:54 +01:00
committed by Commit Bot
parent cddfc46db6
commit 0618cbc989

View File

@ -390,8 +390,8 @@ bool SuppressionGain::LowNoiseRenderDetector::Detect(
const std::vector<std::vector<std::vector<float>>>& render) {
float x2_sum = 0.f;
float x2_max = 0.f;
for (auto x_ch : render[0]) {
for (auto x_k : x_ch) {
for (const auto& x_ch : render[0]) {
for (const auto& x_k : x_ch) {
const float x2 = x_k * x_k;
x2_sum += x2;
x2_max = std::max(x2_max, x2);