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

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

Issue 2678423005: Finalization of the first version of EchoCanceller 3 (Closed)
Patch Set: Fixed failing unittest Created 3 years, 10 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
(Empty)
1
hlundin-webrtc 2017/02/21 09:40:03 Blank line inserted.
peah-webrtc 2017/02/21 23:00:40 Done.
2 /*
3 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
4 *
5 * Use of this source code is governed by a BSD-style license
6 * that can be found in the LICENSE file in the root of the source
7 * tree. An additional intellectual property rights grant can be found
8 * in the file PATENTS. All contributing project authors may
9 * be found in the AUTHORS file in the root of the source tree.
10 */
11
12 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_FFT_BUFFER_H_
13 #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_FFT_BUFFER_H_
14
15 #include <memory>
16 #include <vector>
17
18 #include "webrtc/base/array_view.h"
19 #include "webrtc/base/constructormagic.h"
20 #include "webrtc/modules/audio_processing/aec3/fft_data.h"
21
22 namespace webrtc {
23
24 // Provides a circular buffer for 128 point real-valued FFT data.
25 class FftBuffer {
26 public:
27 // The constructor takes as parameters the size of the buffer, as well as a
28 // vector containing the number of FFTs that will be included in the spectral
29 // sums in the call to SpectralSum.
30 FftBuffer(Aec3Optimization optimization,
31 size_t size,
32 const std::vector<size_t> num_ffts_for_spectral_sums);
33 ~FftBuffer();
34
35 // Insert an FFT into the buffer.
36 void Insert(const FftData& fft);
37
38 // Get the spectrum from one of the FFTs in the buffer
39 const std::array<float, kFftLengthBy2Plus1>& Spectrum(
40 size_t buffer_offset_ffts) const {
41 return spectrum_buffer_[(position_ + buffer_offset_ffts) %
42 fft_buffer_.size()];
43 }
44
45 // Returns the sum of the spectrums for a certain number of FFTs.
46 const std::array<float, kFftLengthBy2Plus1>& SpectralSum(
47 size_t num_ffts) const {
48 RTC_DCHECK_EQ(spectral_sums_length_, num_ffts);
49 return spectral_sums_[0];
50 }
51
52 // Returns the circular buffer.
53 rtc::ArrayView<const FftData> Buffer() const { return fft_buffer_; }
54
55 // Returns the current position in the circular buffer
56 size_t Position() const { return position_; }
57
58 private:
59 const Aec3Optimization optimization_;
60 std::vector<FftData> fft_buffer_;
61 std::vector<std::array<float, kFftLengthBy2Plus1>> spectrum_buffer_;
62 size_t spectral_sums_length_;
63 std::vector<std::array<float, kFftLengthBy2Plus1>> spectral_sums_;
64 size_t position_ = 0;
65
66 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(FftBuffer);
67 };
68
69 } // namespace webrtc
70
71 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_FFT_BUFFER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698