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_POWER_ECHO_MODEL_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_POWER_ECHO_MODEL_H_ |
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_POWER_ECHO_MODEL_H_ | 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_POWER_ECHO_MODEL_H_ |
13 | 13 |
14 #include <array> | 14 #include <array> |
15 | 15 |
16 #include "webrtc/base/constructormagic.h" | 16 #include "webrtc/base/constructormagic.h" |
17 #include "webrtc/base/optional.h" | 17 #include "webrtc/base/optional.h" |
18 #include "webrtc/modules/audio_processing/aec3/aec3_common.h" | 18 #include "webrtc/modules/audio_processing/aec3/aec3_common.h" |
19 #include "webrtc/modules/audio_processing/aec3/aec_state.h" | 19 #include "webrtc/modules/audio_processing/aec3/aec_state.h" |
20 #include "webrtc/modules/audio_processing/aec3/echo_path_variability.h" | 20 #include "webrtc/modules/audio_processing/aec3/echo_path_variability.h" |
21 #include "webrtc/modules/audio_processing/aec3/fft_buffer.h" | 21 #include "webrtc/modules/audio_processing/aec3/render_buffer.h" |
22 | 22 |
23 namespace webrtc { | 23 namespace webrtc { |
24 | 24 |
25 // Provides an echo model based on power spectral estimates that estimates the | 25 // Provides an echo model based on power spectral estimates that estimates the |
26 // echo spectrum. | 26 // echo spectrum. |
27 class PowerEchoModel { | 27 class PowerEchoModel { |
28 public: | 28 public: |
29 PowerEchoModel(); | 29 PowerEchoModel(); |
30 ~PowerEchoModel(); | 30 ~PowerEchoModel(); |
31 | 31 |
32 // Ajusts the model according to echo path changes. | 32 // Ajusts the model according to echo path changes. |
33 void HandleEchoPathChange(const EchoPathVariability& variability); | 33 void HandleEchoPathChange(const EchoPathVariability& variability); |
34 | 34 |
35 // Updates the echo model and estimates the echo spectrum. | 35 // Updates the echo model and estimates the echo spectrum. |
36 void EstimateEcho( | 36 void EstimateEcho( |
37 const FftBuffer& render_buffer, | 37 const RenderBuffer& render_buffer, |
38 const std::array<float, kFftLengthBy2Plus1>& capture_spectrum, | 38 const std::array<float, kFftLengthBy2Plus1>& capture_spectrum, |
39 const AecState& aec_state, | 39 const AecState& aec_state, |
40 std::array<float, kFftLengthBy2Plus1>* echo_spectrum); | 40 std::array<float, kFftLengthBy2Plus1>* echo_spectrum); |
41 | 41 |
42 // Returns the minimum required farend buffer length. | 42 // Returns the minimum required farend buffer length. |
43 size_t MinFarendBufferLength() const { return kRenderBufferSize; } | 43 size_t MinFarendBufferLength() const { return kRenderBufferSize; } |
44 | 44 |
45 private: | 45 private: |
46 // Provides a float value that is coupled with a counter. | 46 // Provides a float value that is coupled with a counter. |
47 struct CountedFloat { | 47 struct CountedFloat { |
48 CountedFloat() : value(0.f), counter(0) {} | 48 CountedFloat() : value(0.f), counter(0) {} |
49 CountedFloat(float value, int counter) : value(value), counter(counter) {} | 49 CountedFloat(float value, int counter) : value(value), counter(counter) {} |
50 float value; | 50 float value; |
51 int counter; | 51 int counter; |
52 }; | 52 }; |
53 | 53 |
54 const size_t kRenderBufferSize = 100; | 54 const size_t kRenderBufferSize = 100; |
55 std::array<CountedFloat, kFftLengthBy2Plus1> H2_; | 55 std::array<CountedFloat, kFftLengthBy2Plus1> H2_; |
56 | 56 |
57 RTC_DISALLOW_COPY_AND_ASSIGN(PowerEchoModel); | 57 RTC_DISALLOW_COPY_AND_ASSIGN(PowerEchoModel); |
58 }; | 58 }; |
59 } // namespace webrtc | 59 } // namespace webrtc |
60 | 60 |
61 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_POWER_ECHO_MODEL_H_ | 61 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_POWER_ECHO_MODEL_H_ |
OLD | NEW |