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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 if (!suppressors_.empty()) { 165 if (!suppressors_.empty()) {
166 probability_average /= suppressors_.size(); 166 probability_average /= suppressors_.size();
167 } 167 }
168 return probability_average; 168 return probability_average;
169 #elif defined(WEBRTC_NS_FIXED) 169 #elif defined(WEBRTC_NS_FIXED)
170 // TODO(peah): Returning error code as a float! Remove this. 170 // TODO(peah): Returning error code as a float! Remove this.
171 // Currently not available for the fixed point implementation. 171 // Currently not available for the fixed point implementation.
172 return AudioProcessing::kUnsupportedFunctionError; 172 return AudioProcessing::kUnsupportedFunctionError;
173 #endif 173 #endif
174 } 174 }
175
176 std::vector<float> NoiseSuppressionImpl::NoiseEstimate() {
177 rtc::CritScope cs(crit_);
178 std::vector<float> noise_estimate;
179 #if defined(WEBRTC_NS_FLOAT)
180 noise_estimate.assign(WebRtcNs_num_freq(), 0.f);
181 for (auto& suppressor : suppressors_) {
182 const float* noise = WebRtcNs_noise_estimate(suppressor->state());
183 for (size_t i = 0; i < noise_estimate.size(); ++i) {
184 noise_estimate[i] += noise[i] / suppressors_.size();
185 }
186 }
187 #elif defined(WEBRTC_NS_FIXED)
188 const float kNormalizationFactor = 1.f / (1 << 8);
189 noise_estimate.assign(WebRtcNsx_num_freq(), 0.f);
190 for (auto& suppressor : suppressors_) {
191 const uint32_t* noise = WebRtcNsx_noise_estimate(suppressor->state());
192 for (size_t i = 0; i < noise_estimate.size(); ++i) {
193 noise_estimate[i] += kNormalizationFactor *
194 static_cast<float>(noise[i]) / suppressors_.size();
195 }
196 }
197 #endif
198 return noise_estimate;
199 }
200
175 } // namespace webrtc 201 } // namespace webrtc
OLDNEW
« 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