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..097aae7dc9369e679d8eb60692c6a3e91adf27ed 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. |
| +// Divergence metric is based on audio level, which gets updated every |
| +// |kCountLen + 1| * 10 milliseconds. Divergence 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 |
|
peah-webrtc
2016/04/05 09:15:52
I'd prefer to have the comments outside of the con
minyue-webrtc
2016/04/05 09:50:31
Done.
|
| + // 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_divergent.Reset(); |
| } |
| static float CalculatePower(const float* in, size_t num_samples) { |
| @@ -605,6 +615,19 @@ static void UpdateMetrics(AecCore* aec) { |
| aec->stateCounter++; |
| } |
| + if (aec->linoutlevel.framelevel.EndOfBlock()) { |
| + const float near_level = aec->nearlevel.framelevel.GetLatestMean(); |
| + const float level_increase = |
| + aec->linoutlevel.framelevel.GetLatestMean() - near_level; |
| + const bool audible = aec->nlpoutlevel.framelevel.GetLatestMean() > |
|
peah-webrtc
2016/04/05 09:15:52
The audible flag basically checks wether the NLP m
minyue-webrtc
2016/04/05 09:50:31
how about nlpout_active?
peah-webrtc
2016/04/05 10:42:03
That is also vague to me. Do you mean that the NLP
minyue-webrtc
2016/04/05 12:29:12
I used nlpout_active to tell if the final output s
|
| + 100.0 * aec->nlpoutlevel.minlevel; |
|
minyue-webrtc
2016/04/04 15:07:44
I found that 100.0 might be a bit large. I prefer
peah-webrtc
2016/04/05 09:15:52
What do you mean here? Do you want to keep it 100
minyue-webrtc
2016/04/05 09:50:31
I want to change to 40, which gave a bit better re
peah-webrtc
2016/04/05 10:42:03
Acknowledged.
|
| + // Level increase should be, in principle, negative, when the filter |
| + // does not diverge. Here we allow some margin (0.01 * near end level) and |
| + // numerical error (1.0). |
| + aec->fraction_filter_divergent.AddValue(audible && |
|
peah-webrtc
2016/04/05 09:15:52
What about renaming fraction_filter_divergent to f
peah-webrtc
2016/04/05 09:15:52
Here the fraction_filter_divergent object is only
minyue-webrtc
2016/04/05 09:50:31
I agree that BlockMeanCalculator is for floating p
minyue-webrtc
2016/04/05 09:50:31
Tina also wanted to drop "fraction". My idea is th
peah-webrtc
2016/04/05 10:42:03
I think it would be better to use a proper counter
peah-webrtc
2016/04/05 10:42:03
Lets go with that, or with divergent_filter_fracti
minyue-webrtc
2016/04/05 12:29:12
Then I prefer to add a new class: BlockFractionCal
|
| + level_increase > std::max(0.01 * near_level, 1.0) ? 1.0 : 0.0); |
| + } |
| + |
| if (aec->farlevel.averagelevel.EndOfBlock()) { |
| if (aec->farlevel.minlevel < noisyPower) { |
| actThreshold = actThresholdClean; |