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

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

Issue 2320833002: Compensate for the IntelligibilityEnhancer processing delay in high bands (Closed)
Patch Set: Implement DelayBuffer helper class Created 4 years, 3 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 GainApplier::~GainApplier() {} 59 GainApplier::~GainApplier() {}
60 60
61 void GainApplier::Apply(const std::complex<float>* in_block, 61 void GainApplier::Apply(const std::complex<float>* in_block,
62 std::complex<float>* out_block) { 62 std::complex<float>* out_block) {
63 for (size_t i = 0; i < num_freqs_; ++i) { 63 for (size_t i = 0; i < num_freqs_; ++i) {
64 current_[i] = UpdateFactor(target_[i], current_[i], relative_change_limit_); 64 current_[i] = UpdateFactor(target_[i], current_[i], relative_change_limit_);
65 out_block[i] = sqrtf(fabsf(current_[i])) * in_block[i]; 65 out_block[i] = sqrtf(fabsf(current_[i])) * in_block[i];
66 } 66 }
67 } 67 }
68 68
69 DelayBuffer::DelayBuffer(size_t delay, size_t num_channels)
70 : buffer(num_channels, std::vector<float>(delay, 0.f)), read_index(0u) {}
71
72 DelayBuffer::~DelayBuffer() {}
73
74 void DelayBuffer::Delay(float* const* data, size_t length) {
75 for (size_t i = 0u; i < length; ++i) {
peah-webrtc 2016/09/16 13:35:56 I think this implementation is more expensive than
aluebs-webrtc 2016/09/17 00:48:48 1) This makes the code less readable, because it r
peah-webrtc 2016/09/17 21:31:29 It may be less readable, but definitely faster. Y
aluebs-webrtc 2016/09/19 19:17:14 There is a tradeoff between memory footprint and s
76 for (size_t j = 0u; j < buffer.size(); ++j) {
77 float swap = data[j][i];
78 data[j][i] = buffer[j][read_index];
79 buffer[j][read_index] = swap;
80 }
81 read_index = (read_index + 1u) % buffer.size();
82 }
83 }
84
69 } // namespace intelligibility 85 } // namespace intelligibility
70 86
71 } // namespace webrtc 87 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698