Chromium Code Reviews| Index: webrtc/modules/audio_processing/aec3/render_buffer.cc |
| diff --git a/webrtc/modules/audio_processing/aec3/fft_buffer.cc b/webrtc/modules/audio_processing/aec3/render_buffer.cc |
| similarity index 64% |
| rename from webrtc/modules/audio_processing/aec3/fft_buffer.cc |
| rename to webrtc/modules/audio_processing/aec3/render_buffer.cc |
| index 6542d108ef99d9c363ef715af2ace132c03b656b..5d80ee365b17028b2bc79b2e885b03e8a89970da 100644 |
| --- a/webrtc/modules/audio_processing/aec3/fft_buffer.cc |
| +++ b/webrtc/modules/audio_processing/aec3/render_buffer.cc |
| @@ -8,7 +8,7 @@ |
| * be found in the AUTHORS file in the root of the source tree. |
| */ |
| -#include "webrtc/modules/audio_processing/aec3/fft_buffer.h" |
| +#include "webrtc/modules/audio_processing/aec3/render_buffer.h" |
| #include <algorithm> |
| @@ -17,19 +17,28 @@ |
| namespace webrtc { |
| -FftBuffer::FftBuffer(Aec3Optimization optimization, |
| - size_t num_partitions, |
| - const std::vector<size_t> num_ffts_for_spectral_sums) |
| +RenderBuffer::RenderBuffer(Aec3Optimization optimization, |
| + size_t num_bands, |
| + size_t num_partitions, |
| + const std::vector<size_t> num_ffts_for_spectral_sums) |
| : optimization_(optimization), |
| fft_buffer_(num_partitions), |
| spectrum_buffer_(num_partitions, std::array<float, kFftLengthBy2Plus1>()), |
| spectral_sums_(num_ffts_for_spectral_sums.size(), |
| - std::array<float, kFftLengthBy2Plus1>()) { |
| + std::array<float, kFftLengthBy2Plus1>()), |
| + last_block_(num_bands, std::vector<float>(kBlockSize, 0.f)) { |
| // Current implementation only allows a maximum of one spectral sum lengths. |
| RTC_DCHECK_EQ(1, num_ffts_for_spectral_sums.size()); |
| spectral_sums_length_ = num_ffts_for_spectral_sums[0]; |
| RTC_DCHECK_GE(fft_buffer_.size(), spectral_sums_length_); |
| + Clear(); |
| +} |
| + |
| +RenderBuffer::~RenderBuffer() = default; |
| + |
| +void RenderBuffer::Clear() { |
| + position_ = 0; |
| for (auto& sum : spectral_sums_) { |
| sum.fill(0.f); |
| } |
| @@ -41,17 +50,28 @@ FftBuffer::FftBuffer(Aec3Optimization optimization, |
| for (auto& fft : fft_buffer_) { |
| fft.Clear(); |
| } |
| + |
| + for (auto& b : last_block_) { |
| + std::fill(b.begin(), b.end(), 0.f); |
| + } |
| } |
| -FftBuffer::~FftBuffer() = default; |
| +void RenderBuffer::Insert(const std::vector<std::vector<float>>& block) { |
| + // Compute the FFT of the data in the lowest band. |
|
ivoc
2017/03/31 13:58:31
A DCHECK to verify the size of block would be usef
peah-webrtc
2017/04/03 08:02:33
Done.
|
| + FftData X; |
| + fft_.PaddedFft(block[0], last_block_[0], &X); |
| + |
| + // Copy the last render frame. |
| + for (size_t k = 0; k < block.size(); ++k) { |
| + std::copy(block[k].begin(), block[k].end(), last_block_[k].begin()); |
|
ivoc
2017/03/31 13:58:31
A DHECK for the size of block[k] would be good.
peah-webrtc
2017/04/03 08:02:33
Done.
|
| + } |
| -void FftBuffer::Insert(const FftData& fft) { |
| - // Insert the fft into the buffer. |
| + // Insert X into the buffer. |
| position_ = (position_ - 1 + fft_buffer_.size()) % fft_buffer_.size(); |
| - fft_buffer_[position_].Assign(fft); |
| + fft_buffer_[position_].Assign(X); |
| // Compute and insert the spectrum for the FFT into the spectrum buffer. |
| - fft.Spectrum(optimization_, &spectrum_buffer_[position_]); |
| + X.Spectrum(optimization_, &spectrum_buffer_[position_]); |
| // Pre-compute and cachec the spectral sums. |
|
ivoc
2017/03/31 13:58:31
cache
peah-webrtc
2017/04/03 08:02:33
Done.
|
| std::copy(spectrum_buffer_[position_].begin(), |