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

Unified Diff: webrtc/modules/audio_processing/noise_suppression_impl.cc

Issue 1654443004: Surface the noise estimate of the NS to be used by other components (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix normalization factor Created 4 years, 10 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/noise_suppression_impl.cc
diff --git a/webrtc/modules/audio_processing/noise_suppression_impl.cc b/webrtc/modules/audio_processing/noise_suppression_impl.cc
index de7e856676ef14e86bebe2a53511d16f7a204943..400e8e449d12d35c1bc193a427d326d7ff7858eb 100644
--- a/webrtc/modules/audio_processing/noise_suppression_impl.cc
+++ b/webrtc/modules/audio_processing/noise_suppression_impl.cc
@@ -172,4 +172,30 @@ float NoiseSuppressionImpl::speech_probability() const {
return AudioProcessing::kUnsupportedFunctionError;
#endif
}
+
+std::vector<float> NoiseSuppressionImpl::NoiseEstimate() {
+ rtc::CritScope cs(crit_);
+ std::vector<float> noise_estimate;
+#if defined(WEBRTC_NS_FLOAT)
+ noise_estimate.assign(WebRtcNs_num_freq(), 0.f);
+ for (auto& suppressor : suppressors_) {
+ const float* noise = WebRtcNs_noise_estimate(suppressor->state());
+ for (size_t i = 0; i < noise_estimate.size(); ++i) {
+ noise_estimate[i] += noise[i] / suppressors_.size();
+ }
+ }
+#elif defined(WEBRTC_NS_FIXED)
+ const float kNormalizationFactor = 1.f / (1 << 8);
+ noise_estimate.assign(WebRtcNsx_num_freq(), 0.f);
+ for (auto& suppressor : suppressors_) {
+ const uint32_t* noise = WebRtcNsx_noise_estimate(suppressor->state());
+ for (size_t i = 0; i < noise_estimate.size(); ++i) {
+ noise_estimate[i] += kNormalizationFactor *
+ static_cast<float>(noise[i]) / suppressors_.size();
+ }
+ }
+#endif
+ return noise_estimate;
+}
+
} // namespace webrtc
« no previous file with comments | « webrtc/modules/audio_processing/noise_suppression_impl.h ('k') | webrtc/modules/audio_processing/ns/noise_suppression.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698