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

Side by Side Diff: webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc

Issue 1729753003: Fix the stereo support in IntelligibilityEnhancer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@gains2
Patch Set: Rebasing Created 4 years, 9 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) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 (1.f - decay_) * std::abs(data[i]) * std::abs(data[i]); 47 (1.f - decay_) * std::abs(data[i]) * std::abs(data[i]);
48 } 48 }
49 } 49 }
50 50
51 template class PowerEstimator<float>; 51 template class PowerEstimator<float>;
52 template class PowerEstimator<std::complex<float>>; 52 template class PowerEstimator<std::complex<float>>;
53 53
54 GainApplier::GainApplier(size_t freqs, float relative_change_limit) 54 GainApplier::GainApplier(size_t freqs, float relative_change_limit)
55 : num_freqs_(freqs), 55 : num_freqs_(freqs),
56 relative_change_limit_(relative_change_limit), 56 relative_change_limit_(relative_change_limit),
57 target_(new float[freqs]()), 57 target_(freqs, 1.f),
58 current_(new float[freqs]()) { 58 current_(freqs, 1.f) {}
59 for (size_t i = 0; i < freqs; ++i) {
60 target_[i] = 1.f;
61 current_[i] = 1.f;
62 }
63 }
64 59
65 void GainApplier::Apply(const std::complex<float>* in_block, 60 void GainApplier::Apply(const std::complex<float>* in_block,
66 std::complex<float>* out_block) { 61 std::complex<float>* out_block) {
67 for (size_t i = 0; i < num_freqs_; ++i) { 62 for (size_t i = 0; i < num_freqs_; ++i) {
68 current_[i] = UpdateFactor(target_[i], current_[i], relative_change_limit_); 63 current_[i] = UpdateFactor(target_[i], current_[i], relative_change_limit_);
69 out_block[i] = sqrtf(fabsf(current_[i])) * in_block[i]; 64 out_block[i] = sqrtf(fabsf(current_[i])) * in_block[i];
70 } 65 }
71 } 66 }
72 67
73 } // namespace intelligibility 68 } // namespace intelligibility
74 69
75 } // namespace webrtc 70 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698