Fixing UpdateLevel function in AEC.

From an earlier CL, we start to feed UpdateLevel() with power instead of energy. I found that UpdateLevel() is still taking the input as energy and normalize it. This CL fixes this.

The earlier CL is
https://codereview.webrtc.org/1542573002/

BUG=

Review URL: https://codereview.webrtc.org/1810773003

Cr-Commit-Position: refs/heads/master@{#12084}
This commit is contained in:
minyue 2016-03-22 02:14:53 -07:00 committed by Commit bot
parent 2cb73413f4
commit 6a85d3450c

View File

@ -568,12 +568,12 @@ static float CalculatePower(const float* in, size_t num_samples) {
return energy / num_samples;
}
static void UpdateLevel(PowerLevel* level, float energy) {
level->sfrsum += energy;
static void UpdateLevel(PowerLevel* level, float power) {
level->sfrsum += power;
level->sfrcounter++;
if (level->sfrcounter > subCountLen) {
level->framelevel = level->sfrsum / (subCountLen * PART_LEN);
level->framelevel = level->sfrsum / subCountLen;
level->sfrsum = 0;
level->sfrcounter = 0;
if (level->framelevel > 0) {
@ -600,11 +600,7 @@ static void UpdateMetrics(AecCore* aec) {
const float actThresholdClean = 40.0f;
const float safety = 0.99995f;
// To make noisePower consistent with the legacy code, a factor of
// 2.0f / PART_LEN2 is applied to noisyPower, since the legacy code uses
// the energy of a frame as the audio levels, while the new code uses a
// a per-sample energy (i.e., power).
const float noisyPower = 300000.0f * 2.0f / PART_LEN2;
const float noisyPower = 300000.0f;
float actThreshold;
float echo, suppressedEcho;