Chromium Code Reviews| 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 e23a79312b05beb9c7904c103c605a5d454b3e69..289482abdc43d8ec70f2057b58454f0ade86b07c 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 size_t kSubCountLen = 4; |
| static const size_t kCountLen = 50; |
| static const int kDelayMetricsAggregationWindow = 1250; // 5 seconds at 16 kHz. |
| +// Diverge metric is based on audio level, which gets updated which every |
| +// |kCountLen + 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 |
| @@ -151,15 +157,17 @@ __inline static float MulIm(float aRe, float aIm, float bRe, float bIm) { |
| } |
| PowerLevel::PowerLevel() |
| -// TODO(minyue): Due to a legacy bug, |framelevel| and |averagelevel| use a |
| -// window, of which the length is 1 unit longer than indicated. Remove "+1" |
| -// when the code is refactored. |
| -: framelevel(kSubCountLen + 1), |
| - averagelevel(kCountLen + 1) { |
| + // TODO(minyue): Due to a legacy bug, |framelevel| and |averagelevel| use a |
| + // window, of which the length is 1 unit longer than indicated. Remove "+1" |
| + // when the code is refactored. |
| + : framelevel(kSubCountLen + 1), |
| + averagelevel(kCountLen + 1) { |
| } |
| // TODO(minyue): Moving some initialization from WebRtcAec_CreateAec() to ctor. |
| -AecCore::AecCore() = default; |
| +AecCore::AecCore() |
| + : fraction_filter_divergent(kDivergeMetricAggregationWindow) { |
| +} |
| static int CmpFloat(const void* a, const void* b) { |
| const float* da = (const float*)a; |
| @@ -562,6 +570,8 @@ static void InitMetrics(AecCore* self) { |
| InitStats(&self->erle); |
| InitStats(&self->aNlp); |
| InitStats(&self->rerl); |
| + |
| + self->fraction_filter_diverge.Reset(); |
|
minyue-webrtc
2016/04/03 21:42:06
this should be "divergent". It is fixed in the nex
|
| } |
| static float CalculatePower(const float* in, size_t num_samples) { |
| @@ -605,6 +615,17 @@ static void UpdateMetrics(AecCore* aec) { |
| aec->stateCounter++; |
| } |
| + if (aec->linoutlevel.framelevel.EndOfBlock()) { |
| + const float level_increase = aec->linoutlevel.framelevel.GetLatestMean() - |
| + aec->nearlevel.framelevel.GetLatestMean(); |
| + // 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.AddValue(level_increase > |
| + std::max(0.001 * aec->nearlevel.framelevel.GetLatestMean(), 1.0) ? |
| + 1.0 : 0.0); |
| + } |
| + |
| if (aec->farlevel.averagelevel.EndOfBlock()) { |
| if (aec->farlevel.minlevel < noisyPower) { |
| actThreshold = actThresholdClean; |