Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: webrtc/modules/audio_processing/aec/aec_core.cc

Issue 1739993003: Adding fraction of filter divergence in AEC metrics. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: addressing Per's comments Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/aec/aec_core.cc
diff --git a/webrtc/modules/audio_processing/aec/aec_core.cc b/webrtc/modules/audio_processing/aec/aec_core.cc
index 1b5f03fec4e7a255f25c681218bbb7470ebc0770..7fdf8b62958f33072920c6924ed1a9d4ebcb9f95 100644
--- a/webrtc/modules/audio_processing/aec/aec_core.cc
+++ b/webrtc/modules/audio_processing/aec/aec_core.cc
@@ -50,6 +50,12 @@ static const int subCountLen = 4;
static const int countLen = 50;
static const int kDelayMetricsAggregationWindow = 1250; // 5 seconds at 16 kHz.
+// Diverge metric is based on audio level, which gets updated which every
tlegrand-webrtc 2016/03/17 12:28:39 You haven't addressed my comments from Patch Set 1
minyue-webrtc 2016/04/03 21:42:06 Sorry, I might have missed it. Now it is addressed
+// |subCountLen + 1| * 10 milliseconds. Diverge metric takes the statistics of
+// |kDivergeMetricAggregationWindow| samples. Current value corresponds to 0.5
+// seconds at 16 kHz.
+static const int kDivergeMetricAggregationWindow = 25;
+
// Quantities to control H band scaling for SWB input
static const float cnScaleHband = 0.4f; // scale for comfort noise in H band.
// Initial bin for averaging nlp gain in low band
@@ -556,6 +562,8 @@ static void InitMetrics(AecCore* self) {
InitStats(&self->erle);
InitStats(&self->aNlp);
InitStats(&self->rerl);
+
+ self->fraction_filter_divergent->Clear();
}
static float CalculatePower(const float* in, size_t num_samples) {
@@ -613,6 +621,16 @@ static void UpdateMetrics(AecCore* aec) {
aec->stateCounter++;
}
+ if (aec->linoutlevel.sfrcounter == 0) {
+ const float level_increase =
+ aec->linoutlevel.framelevel - aec->nearlevel.framelevel;
+ // Level increase should be, in principle, negative, when the filter
+ // does not diverge. Here we allow some margin (0.001 * near end level) and
+ // numerical error (1.0).
+ aec->fraction_filter_divergent->AddSample(level_increase >
+ std::max(0.001 * aec->nearlevel.framelevel, 1.0) ? 1.0 : 0.0);
+ }
+
if (aec->farlevel.frcounter == 0) {
if (aec->farlevel.minlevel < noisyPower) {
actThreshold = actThresholdClean;
@@ -1365,7 +1383,7 @@ static void ProcessBlock(AecCore* aec) {
AecCore* WebRtcAec_CreateAec() {
int i;
- AecCore* aec = reinterpret_cast<AecCore*>(malloc(sizeof(AecCore)));
+ AecCore* aec = new AecCore;
if (!aec) {
return NULL;
}
@@ -1429,6 +1447,14 @@ AecCore* WebRtcAec_CreateAec() {
WebRtcAec_FreeAec(aec);
return NULL;
}
+
+ aec->fraction_filter_divergent.reset(
+ new webrtc::MeanCalculator(kDivergeMetricAggregationWindow));
tlegrand-webrtc 2016/03/17 12:28:39 Do you need webrtc:: here? Looks like we are in th
minyue-webrtc 2016/04/03 21:42:05 True. the namespace was added recently. now I can
+ if (aec->fraction_filter_divergent.get() == nullptr) {
tlegrand-webrtc 2016/03/17 12:28:39 Can you explain what happens here?
minyue-webrtc 2016/04/03 21:42:06 This is to check if the memory is allocated correc
+ WebRtcAec_FreeAec(aec);
+ return NULL;
+ }
+
#ifdef WEBRTC_ANDROID
aec->delay_agnostic_enabled = 1; // DA-AEC enabled by default.
// DA-AEC assumes the system is causal from the beginning and will self adjust

Powered by Google App Engine
This is Rietveld 408576698