OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 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 |
11 #include "webrtc/modules/audio_processing/aec3/render_buffer.h" | 11 #include "webrtc/modules/audio_processing/aec3/render_buffer.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 | 14 |
15 #include "webrtc/base/checks.h" | 15 #include "webrtc/base/checks.h" |
16 #include "webrtc/modules/audio_processing/aec3/aec3_common.h" | 16 #include "webrtc/modules/audio_processing/aec3/aec3_common.h" |
17 | 17 |
18 namespace webrtc { | 18 namespace webrtc { |
19 | 19 |
20 RenderBuffer::RenderBuffer(Aec3Optimization optimization, | 20 RenderBuffer::RenderBuffer(Aec3Optimization optimization, |
21 size_t num_bands, | 21 size_t num_bands, |
22 size_t num_partitions, | 22 size_t num_partitions, |
23 const std::vector<size_t> num_ffts_for_spectral_sums) | 23 const std::vector<size_t> num_ffts_for_spectral_sums) |
24 : optimization_(optimization), | 24 : optimization_(optimization), |
25 fft_buffer_(num_partitions), | 25 fft_buffer_(num_partitions), |
26 spectrum_buffer_(num_partitions, std::array<float, kFftLengthBy2Plus1>()), | 26 spectrum_buffer_(num_partitions, std::array<float, kFftLengthBy2Plus1>()), |
27 spectral_sums_(num_ffts_for_spectral_sums.size(), | 27 spectral_sums_(num_ffts_for_spectral_sums.size(), |
28 std::array<float, kFftLengthBy2Plus1>()), | 28 std::array<float, kFftLengthBy2Plus1>()), |
29 last_block_(num_bands, std::vector<float>(kBlockSize, 0.f)), | 29 last_block_(num_bands, std::vector<float>(kBlockSize, 0.f)) { |
30 fft_() { | |
31 // Current implementation only allows a maximum of one spectral sum lengths. | 30 // Current implementation only allows a maximum of one spectral sum lengths. |
32 RTC_DCHECK_EQ(1, num_ffts_for_spectral_sums.size()); | 31 RTC_DCHECK_EQ(1, num_ffts_for_spectral_sums.size()); |
33 spectral_sums_length_ = num_ffts_for_spectral_sums[0]; | 32 spectral_sums_length_ = num_ffts_for_spectral_sums[0]; |
34 RTC_DCHECK_GE(fft_buffer_.size(), spectral_sums_length_); | 33 RTC_DCHECK_GE(fft_buffer_.size(), spectral_sums_length_); |
35 | 34 |
36 Clear(); | 35 Clear(); |
37 } | 36 } |
38 | 37 |
39 RenderBuffer::~RenderBuffer() = default; | 38 RenderBuffer::~RenderBuffer() = default; |
40 | 39 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 85 |
87 for (size_t k = 0; k < spectral_sums_[0].size(); ++k) { | 86 for (size_t k = 0; k < spectral_sums_[0].size(); ++k) { |
88 spectral_sums_[0][k] += spectrum[k]; | 87 spectral_sums_[0][k] += spectrum[k]; |
89 } | 88 } |
90 | 89 |
91 position = position < (fft_buffer_.size() - 1) ? position + 1 : 0; | 90 position = position < (fft_buffer_.size() - 1) ? position + 1 : 0; |
92 } | 91 } |
93 } | 92 } |
94 | 93 |
95 } // namespace webrtc | 94 } // namespace webrtc |
OLD | NEW |