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

Side by Side Diff: webrtc/modules/audio_processing/aec3/render_buffer.h

Issue 2784023002: Major AEC3 render pipeline changes (Closed)
Patch Set: Disabled one more DEATH test that caused issues due to bug on bots Created 3 years, 8 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) 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 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_FFT_BUFFER_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_RENDER_BUFFER_H_
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_FFT_BUFFER_H_ 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_RENDER_BUFFER_H_
13 13
14 #include <memory> 14 #include <memory>
15 #include <vector> 15 #include <vector>
16 16
17 #include "webrtc/base/array_view.h" 17 #include "webrtc/base/array_view.h"
18 #include "webrtc/base/constructormagic.h" 18 #include "webrtc/base/constructormagic.h"
19 #include "webrtc/modules/audio_processing/aec3/aec3_fft.h"
19 #include "webrtc/modules/audio_processing/aec3/fft_data.h" 20 #include "webrtc/modules/audio_processing/aec3/fft_data.h"
20 21
21 namespace webrtc { 22 namespace webrtc {
22 23
23 // Provides a circular buffer for 128 point real-valued FFT data. 24 // Provides a buffer of the render data for the echo remover.
24 class FftBuffer { 25 class RenderBuffer {
25 public: 26 public:
26 // The constructor takes as parameters the size of the buffer, as well as a 27 // The constructor takes, besides from the other parameters, a vector
27 // vector containing the number of FFTs that will be included in the spectral 28 // containing the number of FFTs that will be included in the spectral sums in
28 // sums in the call to SpectralSum. 29 // the call to SpectralSum.
29 FftBuffer(Aec3Optimization optimization, 30 RenderBuffer(Aec3Optimization optimization,
30 size_t size, 31 size_t num_bands,
31 const std::vector<size_t> num_ffts_for_spectral_sums); 32 size_t size,
32 ~FftBuffer(); 33 const std::vector<size_t> num_ffts_for_spectral_sums);
34 ~RenderBuffer();
33 35
34 // Insert an FFT into the buffer. 36 // Clears the buffer.
35 void Insert(const FftData& fft); 37 void Clear();
38
39 // Insert a block into the buffer.
40 void Insert(const std::vector<std::vector<float>>& block);
41
42 // Gets the last inserted block.
43 const std::vector<std::vector<float>>& MostRecentBlock() const {
44 return last_block_;
45 }
36 46
37 // Get the spectrum from one of the FFTs in the buffer 47 // Get the spectrum from one of the FFTs in the buffer
38 const std::array<float, kFftLengthBy2Plus1>& Spectrum( 48 const std::array<float, kFftLengthBy2Plus1>& Spectrum(
39 size_t buffer_offset_ffts) const { 49 size_t buffer_offset_ffts) const {
40 return spectrum_buffer_[(position_ + buffer_offset_ffts) % 50 return spectrum_buffer_[(position_ + buffer_offset_ffts) %
41 fft_buffer_.size()]; 51 fft_buffer_.size()];
42 } 52 }
43 53
44 // Returns the sum of the spectrums for a certain number of FFTs. 54 // Returns the sum of the spectrums for a certain number of FFTs.
45 const std::array<float, kFftLengthBy2Plus1>& SpectralSum( 55 const std::array<float, kFftLengthBy2Plus1>& SpectralSum(
46 size_t num_ffts) const { 56 size_t num_ffts) const {
47 RTC_DCHECK_EQ(spectral_sums_length_, num_ffts); 57 RTC_DCHECK_EQ(spectral_sums_length_, num_ffts);
48 return spectral_sums_[0]; 58 return spectral_sums_[0];
49 } 59 }
50 60
51 // Returns the circular buffer. 61 // Returns the circular buffer.
52 rtc::ArrayView<const FftData> Buffer() const { return fft_buffer_; } 62 rtc::ArrayView<const FftData> Buffer() const { return fft_buffer_; }
53 63
54 // Returns the current position in the circular buffer 64 // Returns the current position in the circular buffer
55 size_t Position() const { return position_; } 65 size_t Position() const { return position_; }
56 66
57 private: 67 private:
58 const Aec3Optimization optimization_; 68 const Aec3Optimization optimization_;
59 std::vector<FftData> fft_buffer_; 69 std::vector<FftData> fft_buffer_;
60 std::vector<std::array<float, kFftLengthBy2Plus1>> spectrum_buffer_; 70 std::vector<std::array<float, kFftLengthBy2Plus1>> spectrum_buffer_;
61 size_t spectral_sums_length_; 71 size_t spectral_sums_length_;
62 std::vector<std::array<float, kFftLengthBy2Plus1>> spectral_sums_; 72 std::vector<std::array<float, kFftLengthBy2Plus1>> spectral_sums_;
63 size_t position_ = 0; 73 size_t position_ = 0;
64 74 std::vector<std::vector<float>> last_block_;
65 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(FftBuffer); 75 const Aec3Fft fft_;
76 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RenderBuffer);
66 }; 77 };
67 78
68 } // namespace webrtc 79 } // namespace webrtc
69 80
70 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_FFT_BUFFER_H_ 81 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_RENDER_BUFFER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698