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 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_SUBTRACTOR_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_SUBTRACTOR_H_ |
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_SUBTRACTOR_H_ | 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_SUBTRACTOR_H_ |
13 | 13 |
14 #include <array> | 14 #include <array> |
15 #include <algorithm> | 15 #include <algorithm> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "webrtc/base/constructormagic.h" | 18 #include "webrtc/base/constructormagic.h" |
19 #include "webrtc/modules/audio_processing/aec3/adaptive_fir_filter.h" | 19 #include "webrtc/modules/audio_processing/aec3/adaptive_fir_filter.h" |
20 #include "webrtc/modules/audio_processing/aec3/aec3_common.h" | 20 #include "webrtc/modules/audio_processing/aec3/aec3_common.h" |
21 #include "webrtc/modules/audio_processing/aec3/aec3_fft.h" | 21 #include "webrtc/modules/audio_processing/aec3/aec3_fft.h" |
| 22 #include "webrtc/modules/audio_processing/aec3/aec_state.h" |
22 #include "webrtc/modules/audio_processing/aec3/echo_path_variability.h" | 23 #include "webrtc/modules/audio_processing/aec3/echo_path_variability.h" |
23 #include "webrtc/modules/audio_processing/aec3/main_filter_update_gain.h" | 24 #include "webrtc/modules/audio_processing/aec3/main_filter_update_gain.h" |
24 #include "webrtc/modules/audio_processing/aec3/render_buffer.h" | 25 #include "webrtc/modules/audio_processing/aec3/render_buffer.h" |
25 #include "webrtc/modules/audio_processing/aec3/shadow_filter_update_gain.h" | 26 #include "webrtc/modules/audio_processing/aec3/shadow_filter_update_gain.h" |
26 #include "webrtc/modules/audio_processing/aec3/subtractor_output.h" | 27 #include "webrtc/modules/audio_processing/aec3/subtractor_output.h" |
27 #include "webrtc/modules/audio_processing/logging/apm_data_dumper.h" | 28 #include "webrtc/modules/audio_processing/logging/apm_data_dumper.h" |
28 #include "webrtc/modules/audio_processing/utility/ooura_fft.h" | 29 #include "webrtc/modules/audio_processing/utility/ooura_fft.h" |
29 | 30 |
30 namespace webrtc { | 31 namespace webrtc { |
31 | 32 |
32 // Proves linear echo cancellation functionality | 33 // Proves linear echo cancellation functionality |
33 class Subtractor { | 34 class Subtractor { |
34 public: | 35 public: |
35 Subtractor(ApmDataDumper* data_dumper, Aec3Optimization optimization); | 36 Subtractor(ApmDataDumper* data_dumper, Aec3Optimization optimization); |
36 ~Subtractor(); | 37 ~Subtractor(); |
37 | 38 |
38 // Performs the echo subtraction. | 39 // Performs the echo subtraction. |
39 void Process(const RenderBuffer& render_buffer, | 40 void Process(const RenderBuffer& render_buffer, |
40 const rtc::ArrayView<const float> capture, | 41 const rtc::ArrayView<const float> capture, |
41 const RenderSignalAnalyzer& render_signal_analyzer, | 42 const RenderSignalAnalyzer& render_signal_analyzer, |
42 bool saturation, | 43 const AecState& aec_state, |
43 SubtractorOutput* output); | 44 SubtractorOutput* output); |
44 | 45 |
45 // Returns a vector with the number of blocks included in the render buffer | |
46 // sums. | |
47 std::vector<size_t> NumBlocksInRenderSums() const; | |
48 | |
49 // Returns the minimum required farend buffer length. | |
50 size_t MinFarendBufferLength() const { | |
51 return std::max(kMainFilterSizePartitions, kShadowFilterSizePartitions); | |
52 } | |
53 | |
54 void HandleEchoPathChange(const EchoPathVariability& echo_path_variability); | 46 void HandleEchoPathChange(const EchoPathVariability& echo_path_variability); |
55 | 47 |
56 // Returns the block-wise frequency response of the main adaptive filter. | 48 // Returns the block-wise frequency response of the main adaptive filter. |
57 const std::vector<std::array<float, kFftLengthBy2Plus1>>& | 49 const std::vector<std::array<float, kFftLengthBy2Plus1>>& |
58 FilterFrequencyResponse() const { | 50 FilterFrequencyResponse() const { |
59 return main_filter_.FilterFrequencyResponse(); | 51 return main_filter_.FilterFrequencyResponse(); |
60 } | 52 } |
61 | 53 |
62 private: | 54 private: |
63 const size_t kMainFilterSizePartitions = 12; | |
64 const size_t kShadowFilterSizePartitions = 12; | |
65 | |
66 const Aec3Fft fft_; | 55 const Aec3Fft fft_; |
67 ApmDataDumper* data_dumper_; | 56 ApmDataDumper* data_dumper_; |
68 const Aec3Optimization optimization_; | 57 const Aec3Optimization optimization_; |
69 AdaptiveFirFilter main_filter_; | 58 AdaptiveFirFilter main_filter_; |
70 AdaptiveFirFilter shadow_filter_; | 59 AdaptiveFirFilter shadow_filter_; |
71 MainFilterUpdateGain G_main_; | 60 MainFilterUpdateGain G_main_; |
72 ShadowFilterUpdateGain G_shadow_; | 61 ShadowFilterUpdateGain G_shadow_; |
73 | 62 |
74 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Subtractor); | 63 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Subtractor); |
75 }; | 64 }; |
76 | 65 |
77 } // namespace webrtc | 66 } // namespace webrtc |
78 | 67 |
79 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_SUBTRACTOR_H_ | 68 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_SUBTRACTOR_H_ |
OLD | NEW |