| OLD | NEW |
| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 NoiseSuppressionImpl::~NoiseSuppressionImpl() {} | 56 NoiseSuppressionImpl::~NoiseSuppressionImpl() {} |
| 57 | 57 |
| 58 int NoiseSuppressionImpl::AnalyzeCaptureAudio(AudioBuffer* audio) { | 58 int NoiseSuppressionImpl::AnalyzeCaptureAudio(AudioBuffer* audio) { |
| 59 #if defined(WEBRTC_NS_FLOAT) | 59 #if defined(WEBRTC_NS_FLOAT) |
| 60 if (!is_component_enabled()) { | 60 if (!is_component_enabled()) { |
| 61 return apm_->kNoError; | 61 return apm_->kNoError; |
| 62 } | 62 } |
| 63 assert(audio->num_frames_per_band() <= 160); | 63 assert(audio->num_frames_per_band() <= 160); |
| 64 assert(audio->num_channels() == num_handles()); | 64 assert(audio->num_channels() == num_handles()); |
| 65 | 65 |
| 66 for (int i = 0; i < num_handles(); ++i) { | 66 for (size_t i = 0; i < num_handles(); ++i) { |
| 67 Handle* my_handle = static_cast<Handle*>(handle(i)); | 67 Handle* my_handle = static_cast<Handle*>(handle(i)); |
| 68 | 68 |
| 69 WebRtcNs_Analyze(my_handle, audio->split_bands_const_f(i)[kBand0To8kHz]); | 69 WebRtcNs_Analyze(my_handle, audio->split_bands_const_f(i)[kBand0To8kHz]); |
| 70 } | 70 } |
| 71 #endif | 71 #endif |
| 72 return apm_->kNoError; | 72 return apm_->kNoError; |
| 73 } | 73 } |
| 74 | 74 |
| 75 int NoiseSuppressionImpl::ProcessCaptureAudio(AudioBuffer* audio) { | 75 int NoiseSuppressionImpl::ProcessCaptureAudio(AudioBuffer* audio) { |
| 76 if (!is_component_enabled()) { | 76 if (!is_component_enabled()) { |
| 77 return apm_->kNoError; | 77 return apm_->kNoError; |
| 78 } | 78 } |
| 79 assert(audio->num_frames_per_band() <= 160); | 79 assert(audio->num_frames_per_band() <= 160); |
| 80 assert(audio->num_channels() == num_handles()); | 80 assert(audio->num_channels() == num_handles()); |
| 81 | 81 |
| 82 for (int i = 0; i < num_handles(); ++i) { | 82 for (size_t i = 0; i < num_handles(); ++i) { |
| 83 Handle* my_handle = static_cast<Handle*>(handle(i)); | 83 Handle* my_handle = static_cast<Handle*>(handle(i)); |
| 84 #if defined(WEBRTC_NS_FLOAT) | 84 #if defined(WEBRTC_NS_FLOAT) |
| 85 WebRtcNs_Process(my_handle, | 85 WebRtcNs_Process(my_handle, |
| 86 audio->split_bands_const_f(i), | 86 audio->split_bands_const_f(i), |
| 87 audio->num_bands(), | 87 audio->num_bands(), |
| 88 audio->split_bands_f(i)); | 88 audio->split_bands_f(i)); |
| 89 #elif defined(WEBRTC_NS_FIXED) | 89 #elif defined(WEBRTC_NS_FIXED) |
| 90 WebRtcNsx_Process(my_handle, | 90 WebRtcNsx_Process(my_handle, |
| 91 audio->split_bands_const(i), | 91 audio->split_bands_const(i), |
| 92 audio->num_bands(), | 92 audio->num_bands(), |
| (...skipping 22 matching lines...) Expand all Loading... |
| 115 return Configure(); | 115 return Configure(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 NoiseSuppression::Level NoiseSuppressionImpl::level() const { | 118 NoiseSuppression::Level NoiseSuppressionImpl::level() const { |
| 119 return level_; | 119 return level_; |
| 120 } | 120 } |
| 121 | 121 |
| 122 float NoiseSuppressionImpl::speech_probability() const { | 122 float NoiseSuppressionImpl::speech_probability() const { |
| 123 #if defined(WEBRTC_NS_FLOAT) | 123 #if defined(WEBRTC_NS_FLOAT) |
| 124 float probability_average = 0.0f; | 124 float probability_average = 0.0f; |
| 125 for (int i = 0; i < num_handles(); i++) { | 125 for (size_t i = 0; i < num_handles(); i++) { |
| 126 Handle* my_handle = static_cast<Handle*>(handle(i)); | 126 Handle* my_handle = static_cast<Handle*>(handle(i)); |
| 127 probability_average += WebRtcNs_prior_speech_probability(my_handle); | 127 probability_average += WebRtcNs_prior_speech_probability(my_handle); |
| 128 } | 128 } |
| 129 return probability_average / num_handles(); | 129 return probability_average / num_handles(); |
| 130 #elif defined(WEBRTC_NS_FIXED) | 130 #elif defined(WEBRTC_NS_FIXED) |
| 131 // Currently not available for the fixed point implementation. | 131 // Currently not available for the fixed point implementation. |
| 132 return apm_->kUnsupportedFunctionError; | 132 return apm_->kUnsupportedFunctionError; |
| 133 #endif | 133 #endif |
| 134 } | 134 } |
| 135 | 135 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 162 int NoiseSuppressionImpl::ConfigureHandle(void* handle) const { | 162 int NoiseSuppressionImpl::ConfigureHandle(void* handle) const { |
| 163 #if defined(WEBRTC_NS_FLOAT) | 163 #if defined(WEBRTC_NS_FLOAT) |
| 164 return WebRtcNs_set_policy(static_cast<Handle*>(handle), | 164 return WebRtcNs_set_policy(static_cast<Handle*>(handle), |
| 165 MapSetting(level_)); | 165 MapSetting(level_)); |
| 166 #elif defined(WEBRTC_NS_FIXED) | 166 #elif defined(WEBRTC_NS_FIXED) |
| 167 return WebRtcNsx_set_policy(static_cast<Handle*>(handle), | 167 return WebRtcNsx_set_policy(static_cast<Handle*>(handle), |
| 168 MapSetting(level_)); | 168 MapSetting(level_)); |
| 169 #endif | 169 #endif |
| 170 } | 170 } |
| 171 | 171 |
| 172 int NoiseSuppressionImpl::num_handles_required() const { | 172 size_t NoiseSuppressionImpl::num_handles_required() const { |
| 173 return apm_->num_output_channels(); | 173 return apm_->num_output_channels(); |
| 174 } | 174 } |
| 175 | 175 |
| 176 int NoiseSuppressionImpl::GetHandleError(void* handle) const { | 176 int NoiseSuppressionImpl::GetHandleError(void* handle) const { |
| 177 // The NS has no get_error() function. | 177 // The NS has no get_error() function. |
| 178 assert(handle != NULL); | 178 assert(handle != NULL); |
| 179 return apm_->kUnspecifiedError; | 179 return apm_->kUnspecifiedError; |
| 180 } | 180 } |
| 181 } // namespace webrtc | 181 } // namespace webrtc |
| OLD | NEW |