OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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_AEC3_COMMON_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_AEC3_COMMON_H_ |
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_AEC3_COMMON_H_ | 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_AEC3_COMMON_H_ |
13 | 13 |
14 #include <stddef.h> | 14 #include <stddef.h> |
15 #include "webrtc/typedefs.h" | 15 #include "webrtc/typedefs.h" |
16 | 16 |
17 namespace webrtc { | 17 namespace webrtc { |
18 | 18 |
19 #ifdef _MSC_VER /* visual c++ */ | 19 #ifdef _MSC_VER /* visual c++ */ |
20 #define ALIGN16_BEG __declspec(align(16)) | 20 #define ALIGN16_BEG __declspec(align(16)) |
21 #define ALIGN16_END | 21 #define ALIGN16_END |
22 #else /* gcc or icc */ | 22 #else /* gcc or icc */ |
23 #define ALIGN16_BEG | 23 #define ALIGN16_BEG |
24 #define ALIGN16_END __attribute__((aligned(16))) | 24 #define ALIGN16_END __attribute__((aligned(16))) |
25 #endif | 25 #endif |
26 | 26 |
27 enum class Aec3Optimization { kNone, kSse2 }; | 27 enum class Aec3Optimization { kNone, kSse2 }; |
28 | 28 |
29 constexpr int kMetricsReportingIntervalBlocks = 10 * 250; | 29 constexpr int kNumBlocksPerSecond = 250; |
| 30 |
| 31 constexpr int kMetricsReportingIntervalBlocks = 10 * kNumBlocksPerSecond; |
30 constexpr int kMetricsComputationBlocks = 9; | 32 constexpr int kMetricsComputationBlocks = 9; |
31 constexpr int kMetricsCollectionBlocks = | 33 constexpr int kMetricsCollectionBlocks = |
32 kMetricsReportingIntervalBlocks - kMetricsComputationBlocks; | 34 kMetricsReportingIntervalBlocks - kMetricsComputationBlocks; |
33 | 35 |
34 constexpr int kAdaptiveFilterLength = 12; | 36 constexpr int kAdaptiveFilterLength = 12; |
| 37 constexpr int kResidualEchoPowerRenderWindowSize = 30; |
35 | 38 |
36 constexpr size_t kFftLengthBy2 = 64; | 39 constexpr size_t kFftLengthBy2 = 64; |
37 constexpr size_t kFftLengthBy2Plus1 = kFftLengthBy2 + 1; | 40 constexpr size_t kFftLengthBy2Plus1 = kFftLengthBy2 + 1; |
38 constexpr size_t kFftLengthBy2Minus1 = kFftLengthBy2 - 1; | 41 constexpr size_t kFftLengthBy2Minus1 = kFftLengthBy2 - 1; |
39 constexpr size_t kFftLength = 2 * kFftLengthBy2; | 42 constexpr size_t kFftLength = 2 * kFftLengthBy2; |
40 | 43 |
41 constexpr size_t kMaxNumBands = 3; | 44 constexpr size_t kMaxNumBands = 3; |
42 constexpr size_t kSubFrameLength = 80; | 45 constexpr size_t kSubFrameLength = 80; |
43 | 46 |
44 constexpr size_t kBlockSize = kFftLengthBy2; | 47 constexpr size_t kBlockSize = kFftLengthBy2; |
45 constexpr size_t kExtendedBlockSize = 2 * kFftLengthBy2; | 48 constexpr size_t kExtendedBlockSize = 2 * kFftLengthBy2; |
46 constexpr size_t kSubBlockSize = 16; | 49 constexpr size_t kSubBlockSize = 16; |
47 | 50 |
48 constexpr size_t kNumMatchedFilters = 4; | 51 constexpr size_t kNumMatchedFilters = 4; |
49 constexpr size_t kMatchedFilterWindowSizeSubBlocks = 32; | 52 constexpr size_t kMatchedFilterWindowSizeSubBlocks = 32; |
50 constexpr size_t kMatchedFilterAlignmentShiftSizeSubBlocks = | 53 constexpr size_t kMatchedFilterAlignmentShiftSizeSubBlocks = |
51 kMatchedFilterWindowSizeSubBlocks * 3 / 4; | 54 kMatchedFilterWindowSizeSubBlocks * 3 / 4; |
52 constexpr size_t kDownsampledRenderBufferSize = | 55 constexpr size_t kDownsampledRenderBufferSize = |
53 kSubBlockSize * | 56 kSubBlockSize * |
54 (kMatchedFilterAlignmentShiftSizeSubBlocks * kNumMatchedFilters + | 57 (kMatchedFilterAlignmentShiftSizeSubBlocks * kNumMatchedFilters + |
55 kMatchedFilterWindowSizeSubBlocks + | 58 kMatchedFilterWindowSizeSubBlocks + |
56 1); | 59 1); |
57 | 60 |
| 61 constexpr float kFixedEchoPathGain = 100; |
| 62 |
58 constexpr size_t kRenderDelayBufferSize = | 63 constexpr size_t kRenderDelayBufferSize = |
59 (3 * kDownsampledRenderBufferSize) / (4 * kSubBlockSize); | 64 (3 * kDownsampledRenderBufferSize) / (4 * kSubBlockSize); |
60 | 65 |
61 constexpr size_t kMaxApiCallsJitterBlocks = 10; | 66 constexpr size_t kMaxApiCallsJitterBlocks = 10; |
62 constexpr size_t kRenderTransferQueueSize = kMaxApiCallsJitterBlocks / 2; | 67 constexpr size_t kRenderTransferQueueSize = kMaxApiCallsJitterBlocks / 2; |
| 68 static_assert(2 * kRenderTransferQueueSize >= kMaxApiCallsJitterBlocks, |
| 69 "Requirement to ensure buffer overflow detection"); |
63 | 70 |
64 constexpr size_t NumBandsForRate(int sample_rate_hz) { | 71 constexpr size_t NumBandsForRate(int sample_rate_hz) { |
65 return static_cast<size_t>(sample_rate_hz == 8000 ? 1 | 72 return static_cast<size_t>(sample_rate_hz == 8000 ? 1 |
66 : sample_rate_hz / 16000); | 73 : sample_rate_hz / 16000); |
67 } | 74 } |
68 constexpr int LowestBandRate(int sample_rate_hz) { | 75 constexpr int LowestBandRate(int sample_rate_hz) { |
69 return sample_rate_hz == 8000 ? sample_rate_hz : 16000; | 76 return sample_rate_hz == 8000 ? sample_rate_hz : 16000; |
70 } | 77 } |
71 | 78 |
72 constexpr bool ValidFullBandRate(int sample_rate_hz) { | 79 constexpr bool ValidFullBandRate(int sample_rate_hz) { |
(...skipping 24 matching lines...) Expand all Loading... |
97 static_assert(ValidFullBandRate(32000), | 104 static_assert(ValidFullBandRate(32000), |
98 "Test that 32 kHz is a valid sample rate"); | 105 "Test that 32 kHz is a valid sample rate"); |
99 static_assert(ValidFullBandRate(48000), | 106 static_assert(ValidFullBandRate(48000), |
100 "Test that 48 kHz is a valid sample rate"); | 107 "Test that 48 kHz is a valid sample rate"); |
101 static_assert(!ValidFullBandRate(8001), | 108 static_assert(!ValidFullBandRate(8001), |
102 "Test that 8001 Hz is not a valid sample rate"); | 109 "Test that 8001 Hz is not a valid sample rate"); |
103 | 110 |
104 } // namespace webrtc | 111 } // namespace webrtc |
105 | 112 |
106 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_AEC3_COMMON_H_ | 113 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_AEC3_COMMON_H_ |
OLD | NEW |