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

Unified Diff: webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer.cc

Issue 2104273002: Add logging to Intelligibility Enhancer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebasing Created 4 years, 6 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
« no previous file with comments | « webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer.cc
diff --git a/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer.cc b/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer.cc
index 63bb1b9b767dfd7259ec72538d2ae847daa02175..f3d023ec620212142d41458e9c04070ad3dd1aae 100644
--- a/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer.cc
+++ b/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer.cc
@@ -17,6 +17,7 @@
#include <numeric>
#include "webrtc/base/checks.h"
+#include "webrtc/base/logging.h"
#include "webrtc/common_audio/include/audio_util.h"
#include "webrtc/common_audio/window_generator.h"
@@ -90,6 +91,7 @@ IntelligibilityEnhancer::IntelligibilityEnhancer(int sample_rate_hz,
snr_(kMaxActiveSNR),
is_active_(false),
num_chunks_(0u),
+ num_active_chunks_(0u),
noise_estimation_buffer_(num_noise_bins),
noise_estimation_queue_(kMaxNumNoiseEstimatesToBuffer,
std::vector<float>(num_noise_bins),
@@ -110,6 +112,14 @@ IntelligibilityEnhancer::IntelligibilityEnhancer(int sample_rate_hz,
kbd_window.data(), window_size, window_size / 2, this));
}
+IntelligibilityEnhancer::~IntelligibilityEnhancer() {
+ // Don't rely on this log, since the destructor isn't called when the app/tab
+ // is killed.
+ LOG(LS_INFO) << "Intelligibility Enhancer was active for "
+ << static_cast<float>(num_active_chunks_) / num_chunks_
+ << "% of the call.";
+}
+
void IntelligibilityEnhancer::SetCaptureNoiseEstimate(
std::vector<float> noise, float gain) {
RTC_DCHECK_EQ(noise.size(), num_noise_bins_);
@@ -145,25 +155,29 @@ void IntelligibilityEnhancer::ProcessAudioBlock(
clear_power_estimator_.Step(in_block[0]);
}
SnrBasedEffectActivation();
- if (is_active_ && num_chunks_++ % kGainUpdatePeriod == 0) {
- MapToErbBands(clear_power_estimator_.power().data(), render_filter_bank_,
- filtered_clear_pow_.data());
- MapToErbBands(noise_power_estimator_.power().data(), capture_filter_bank_,
- filtered_noise_pow_.data());
- SolveForGainsGivenLambda(kLambdaTop, start_freq_, gains_eq_.data());
- const float power_target = std::accumulate(
- filtered_clear_pow_.data(),
- filtered_clear_pow_.data() + bank_size_,
- 0.f);
- const float power_top =
- DotProduct(gains_eq_.data(), filtered_clear_pow_.data(), bank_size_);
- SolveForGainsGivenLambda(kLambdaBot, start_freq_, gains_eq_.data());
- const float power_bot =
- DotProduct(gains_eq_.data(), filtered_clear_pow_.data(), bank_size_);
- if (power_target >= power_bot && power_target <= power_top) {
- SolveForLambda(power_target);
- UpdateErbGains();
- } // Else experiencing power underflow, so do nothing.
+ ++num_chunks_;
+ if (is_active_) {
+ ++num_active_chunks_;
+ if (num_chunks_ % kGainUpdatePeriod == 0) {
+ MapToErbBands(clear_power_estimator_.power().data(), render_filter_bank_,
+ filtered_clear_pow_.data());
+ MapToErbBands(noise_power_estimator_.power().data(), capture_filter_bank_,
+ filtered_noise_pow_.data());
+ SolveForGainsGivenLambda(kLambdaTop, start_freq_, gains_eq_.data());
+ const float power_target = std::accumulate(
+ filtered_clear_pow_.data(),
+ filtered_clear_pow_.data() + bank_size_,
+ 0.f);
+ const float power_top =
+ DotProduct(gains_eq_.data(), filtered_clear_pow_.data(), bank_size_);
+ SolveForGainsGivenLambda(kLambdaBot, start_freq_, gains_eq_.data());
+ const float power_bot =
+ DotProduct(gains_eq_.data(), filtered_clear_pow_.data(), bank_size_);
+ if (power_target >= power_bot && power_target <= power_top) {
+ SolveForLambda(power_target);
+ UpdateErbGains();
+ } // Else experiencing power underflow, so do nothing.
+ }
}
for (size_t i = 0; i < in_channels; ++i) {
gain_applier_.Apply(in_block[i], out_block[i]);
@@ -181,6 +195,8 @@ void IntelligibilityEnhancer::SnrBasedEffectActivation() {
(noise_power + std::numeric_limits<float>::epsilon());
if (is_active_) {
if (snr_ > kMaxActiveSNR) {
+ LOG(LS_INFO) << "Intelligibility Enhancer was deactivated at chunk "
+ << num_chunks_;
is_active_ = false;
// Set the target gains to unity.
float* gains = gain_applier_.target();
@@ -189,7 +205,11 @@ void IntelligibilityEnhancer::SnrBasedEffectActivation() {
}
}
} else {
- is_active_ = snr_ < kMinInactiveSNR;
+ if (snr_ < kMinInactiveSNR) {
+ LOG(LS_INFO) << "Intelligibility Enhancer was activated at chunk "
+ << num_chunks_;
+ is_active_ = true;
+ }
}
}
« no previous file with comments | « webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698