Reland "Calculating ERLE in AEC more properly."

The original CL (https://codereview.webrtc.org/1644133002/) had an error in the unittest and did not get landed. This CL is to reland it,

BUG=

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

Cr-Commit-Position: refs/heads/master@{#11844}
This commit is contained in:
minyue 2016-03-02 06:56:46 -08:00 committed by Commit bot
parent 4fa7ecad12
commit 7b19b08c18
2 changed files with 8 additions and 18 deletions

View File

@ -689,12 +689,11 @@ static void UpdateMetrics(AecCore* aec) {
// ERLE
// subtract noise power
suppressedEcho = 2 * (aec->nlpoutlevel.averagelevel -
safety * aec->nlpoutlevel.minlevel);
suppressedEcho = aec->nlpoutlevel.averagelevel -
safety * aec->nlpoutlevel.minlevel;
dtmp = 10 * static_cast<float>(log10(aec->nearlevel.averagelevel /
(2 * aec->nlpoutlevel.averagelevel) +
1e-10f));
aec->nlpoutlevel.averagelevel + 1e-10f));
dtmp2 = 10 * static_cast<float>(log10(echo / suppressedEcho + 1e-10f));
dtmp = dtmp2;
@ -1139,16 +1138,6 @@ static void EchoSuppression(AecCore* aec,
// Inverse error fft.
ScaledInverseFft(efw, fft, 2.0f, 1);
// TODO(bjornv): Investigate how to take the windowing below into account if
// needed.
if (aec->metricsMode == 1) {
// Note that we have a scaling by two in the time domain |eBuf|.
// In addition the time domain signal is windowed before transformation,
// losing half the energy on the average. We take care of the first
// scaling only in UpdateMetrics().
UpdateLevel(&aec->nlpoutlevel, CalculatePower(fft, PART_LEN2));
}
// Overlap and add to obtain output.
for (i = 0; i < PART_LEN; i++) {
output[i] = (fft[i] * WebRtcAec_sqrtHanning[i] +
@ -1358,6 +1347,7 @@ static void ProcessBlock(AecCore* aec) {
EchoSuppression(aec, farend_ptr, echo_subtractor_output, output, outputH_ptr);
if (aec->metricsMode == 1) {
UpdateLevel(&aec->nlpoutlevel, CalculatePower(output, PART_LEN));
UpdateMetrics(aec);
}

View File

@ -204,10 +204,10 @@ int16_t MaxAudioFrame(const AudioFrame& frame) {
#if defined(WEBRTC_AUDIOPROC_FLOAT_PROFILE)
void TestStats(const AudioProcessing::Statistic& test,
const audioproc::Test::Statistic& reference) {
EXPECT_NEAR(reference.instant(), test.instant, 1);
EXPECT_EQ(reference.average(), test.average);
EXPECT_EQ(reference.maximum(), test.maximum);
EXPECT_NEAR(reference.minimum(), test.minimum, 1);
EXPECT_NEAR(reference.instant(), test.instant, 2);
EXPECT_NEAR(reference.average(), test.average, 2);
EXPECT_NEAR(reference.maximum(), test.maximum, 3);
EXPECT_NEAR(reference.minimum(), test.minimum, 2);
}
void WriteStatsMessage(const AudioProcessing::Statistic& output,