Chromium Code Reviews| Index: webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc |
| diff --git a/webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc b/webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc |
| index ed16a61e660e29283e71f0973b6c1b4b4eed46f6..821d15d0c8c38e3f3d3ff0d004e46e227563b891 100644 |
| --- a/webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc |
| +++ b/webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc |
| @@ -31,28 +31,22 @@ float UpdateFactor(float target, float current, float limit) { |
| PowerEstimator::PowerEstimator(size_t num_freqs, |
| float decay) |
| - : magnitude_(new float[num_freqs]()), |
| - power_(new float[num_freqs]()), |
| - num_freqs_(num_freqs), |
| - decay_(decay) { |
| - memset(magnitude_.get(), 0, sizeof(*magnitude_.get()) * num_freqs_); |
| - memset(power_.get(), 0, sizeof(*power_.get()) * num_freqs_); |
| -} |
| + : power_(num_freqs, 0.f), |
| + decay_(decay) {} |
| -// Compute the magnitude from the beginning, with exponential decaying of the |
| -// series data. |
| -void PowerEstimator::Step(const std::complex<float>* data) { |
| - for (size_t i = 0; i < num_freqs_; ++i) { |
| - magnitude_[i] = decay_ * magnitude_[i] + |
| - (1.0f - decay_) * std::abs(data[i]); |
| +// Compute the power from the beginning, with exponential decaying of the series |
| +// data. |
| +void PowerEstimator::Step(const float* data) { |
|
turaj
2016/02/13 00:09:43
This is a utility class so I guess it is fine to b
hlundin-webrtc
2016/02/15 13:05:12
Acknowledged.
aluebs-webrtc
2016/02/19 03:56:31
Done.
|
| + for (size_t i = 0; i < power_.size(); ++i) { |
|
turaj
2016/02/13 00:09:43
maybe a DCHECK that power_ and data are of the sam
hlundin-webrtc
2016/02/15 13:05:12
You don't know the size of |data|.
aluebs-webrtc
2016/02/19 03:56:31
As Henrik points out, the size of data is unknown.
turaj
2016/02/19 16:48:47
Sorry, my mistake, no I don't think it is necessar
|
| + power_[i] = decay_ * power_[i] + (1.f - decay_) * data[i] * data[i]; |
| } |
| } |
| -const float* PowerEstimator::Power() { |
| - for (size_t i = 0; i < num_freqs_; ++i) { |
| - power_[i] = magnitude_[i] * magnitude_[i]; |
| +void PowerEstimator::Step(const std::complex<float>* data) { |
| + for (size_t i = 0; i < power_.size(); ++i) { |
|
turaj
2016/02/13 00:09:43
same comment as line 40.
|
| + power_[i] = decay_ * power_[i] + |
| + (1.f - decay_) * std::abs(data[i]) * std::abs(data[i]); |
| } |
| - return &power_[0]; |
| } |
| GainApplier::GainApplier(size_t freqs, float change_limit) |