Chromium Code Reviews| 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..145c86c6537d8a2883fdebc6bd42f8c37c3cf709 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::noise_estimate() { |
|
hlundin-webrtc
2016/02/09 15:33:51
Rename function to NoiseEstimate, to reflect the f
aluebs-webrtc
2016/02/09 17:48:49
Good idea. Done.
|
| + 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 << 17); |
| + 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 |