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

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

Issue 2678423005: Finalization of the first version of EchoCanceller 3 (Closed)
Patch Set: Fixed compilation error 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 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_ADAPTIVE_FIR_FILTER_H_
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_ADAPTIVE_FIR_FILTER_H_
13
14 #include <array>
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/aec3_common.h"
21 #include "webrtc/modules/audio_processing/aec3/aec3_fft.h"
22 #include "webrtc/modules/audio_processing/aec3/fft_buffer.h"
23 #include "webrtc/modules/audio_processing/aec3/fft_data.h"
24 #include "webrtc/modules/audio_processing/logging/apm_data_dumper.h"
25
26 namespace webrtc {
27 namespace aec3 {
28 // Adapts the filter partitions.
29 void AdaptPartitions(const FftBuffer& X_buffer,
30 const FftData& G,
31 rtc::ArrayView<FftData> H);
32 #if defined(WEBRTC_ARCH_X86_FAMILY)
33 void AdaptPartitions_SSE2(const FftBuffer& X_buffer,
34 const FftData& G,
35 rtc::ArrayView<FftData> H);
36 #endif
37
38 // Produces the filter output.
39 void ApplyFilter(const FftBuffer& X_buffer,
40 rtc::ArrayView<const FftData> H,
41 FftData* S);
42 #if defined(WEBRTC_ARCH_X86_FAMILY)
43 void ApplyFilter_SSE2(const FftBuffer& X_buffer,
44 rtc::ArrayView<const FftData> H,
45 FftData* S);
46 #endif
47
48 } // namespace aec3
49
50 // Provides a frequency domain adaptive filter functionality.
51 class AdaptiveFirFilter {
52 public:
53 AdaptiveFirFilter(size_t size_partitions,
54 bool use_filter_statistics,
55 Aec3Optimization optimization,
56 ApmDataDumper* data_dumper);
57
58 ~AdaptiveFirFilter();
59
60 // Produces the output of the filter.
61 void Filter(const FftBuffer& X_buffer, FftData* S) const;
62
63 // Adapts the filter.
64 void Adapt(const FftBuffer& X_buffer, const FftData& G);
65
66 // Receives reports that known echo path changes have occured and adjusts
67 // the filter adaptation accordingly.
68 void HandleEchoPathChange();
69
70 // Returns the filter size.
71 size_t SizePartitions() const { return H_.size(); }
72
73 // Returns the filter based echo return loss. This method can only be used if
74 // the usage of filter statistics has been specified during the creation of
75 // the adaptive filter.
76 const std::array<float, kFftLengthBy2Plus1>& Erl() const {
77 RTC_DCHECK(erl_) << "The filter must be created with use_filter_statistics "
78 "set to true in order to be able to call retrieve the "
79 "ERL.";
80 return *erl_;
81 }
82
83 // Returns the frequency responses for the filter partitions. This method can
84 // only be used if the usage of filter statistics has been specified during
85 // the creation of the adaptive filter.
86 const std::vector<std::array<float, kFftLengthBy2Plus1>>&
87 FilterFrequencyResponse() const {
88 RTC_DCHECK(H2_) << "The filter must be created with use_filter_statistics "
89 "set to true in order to be able to call retrieve the "
90 "filter frequency responde.";
91 return *H2_;
92 }
93
94 void DumpFilter(const char* name) {
95 for (auto& H : H_) {
96 data_dumper_->DumpRaw(name, H.re);
97 data_dumper_->DumpRaw(name, H.im);
98 }
99 }
100
101 private:
102 ApmDataDumper* const data_dumper_;
103 const Aec3Fft fft_;
104 const Aec3Optimization optimization_;
105 std::vector<FftData> H_;
106 std::unique_ptr<std::vector<std::array<float, kFftLengthBy2Plus1>>> H2_;
107 std::unique_ptr<std::array<float, kFftLengthBy2Plus1>> erl_;
108 size_t partition_to_constrain_ = 0;
109
110 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(AdaptiveFirFilter);
111 };
112
113 } // namespace webrtc
114
115 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_ADAPTIVE_FIR_FILTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698