AEC3: Correct high-band gain for multi-channel

The high-band gain is corrected by fixing the computation of the
low-band energy

Bug: webrtc:14108
Change-Id: I5033287de57aedcd91bb71623ca2862519ffb35b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/263201
Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36972}
This commit is contained in:
Gustaf Ullberg 2022-05-23 13:57:07 +02:00 committed by WebRTC LUCI CQ
parent c80a182e55
commit fbfe6f08a4

View File

@ -136,11 +136,9 @@ float SuppressionGain::UpperBandsGain(
const auto sum_of_squares = [](float a, float b) { return a + b * b; }; const auto sum_of_squares = [](float a, float b) { return a + b * b; };
float low_band_energy = 0.f; float low_band_energy = 0.f;
for (int ch = 0; ch < num_render_channels; ++ch) { for (int ch = 0; ch < num_render_channels; ++ch) {
// TODO(bugs.webrtc.org/14108): Fix the computation below to compute the const float channel_energy =
// energy for each channel. std::accumulate(render.begin(/*band=*/0, ch),
const float channel_energy = std::accumulate( render.end(/*band=*/0, ch), 0.0f, sum_of_squares);
render.begin(/*band=0*/ 0, /*channel=*/0),
render.end(/*band=0*/ 0, /*channel=*/0), 0.f, sum_of_squares);
low_band_energy = std::max(low_band_energy, channel_energy); low_band_energy = std::max(low_band_energy, channel_energy);
} }
float high_band_energy = 0.f; float high_band_energy = 0.f;