OLD | NEW |
---|---|
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 Loading... | |
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 |
OLD | NEW |