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

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

Issue 2800033003: Fixing sample-rate dependent band-split filter issues in AEC3 (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | webrtc/modules/audio_processing/audio_processing_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 constexpr float kFixedEchoPathGain = 100; 61 constexpr float kFixedEchoPathGain = 100;
62 62
63 constexpr size_t kRenderDelayBufferSize = 63 constexpr size_t kRenderDelayBufferSize =
64 (3 * kDownsampledRenderBufferSize) / (4 * kSubBlockSize); 64 (3 * kDownsampledRenderBufferSize) / (4 * kSubBlockSize);
65 65
66 constexpr size_t kMaxApiCallsJitterBlocks = 20; 66 constexpr size_t kMaxApiCallsJitterBlocks = 20;
67 constexpr size_t kRenderTransferQueueSize = kMaxApiCallsJitterBlocks / 2; 67 constexpr size_t kRenderTransferQueueSize = kMaxApiCallsJitterBlocks / 2;
68 static_assert(2 * kRenderTransferQueueSize >= kMaxApiCallsJitterBlocks, 68 static_assert(2 * kRenderTransferQueueSize >= kMaxApiCallsJitterBlocks,
69 "Requirement to ensure buffer overflow detection"); 69 "Requirement to ensure buffer overflow detection");
70 70
71 // TODO(peah): Integrate this with how it is done inside audio_processing_impl.
71 constexpr size_t NumBandsForRate(int sample_rate_hz) { 72 constexpr size_t NumBandsForRate(int sample_rate_hz) {
73 #ifdef WEBRTC_ARCH_ARM_FAMILY
74 return std::min(2, static_cast<size_t>(
hlundin-webrtc 2017/04/07 09:55:06 I think this would be more readable as return sta
hlundin-webrtc 2017/04/07 09:56:35 My bad. How about return static_cast<size_t>(sampl
peah-webrtc 2017/04/07 10:00:16 Awesome! Much better! Done.
75 sample_rate_hz == 8000 ? 1 : sample_rate_hz / 16000));
76 #else
72 return static_cast<size_t>(sample_rate_hz == 8000 ? 1 77 return static_cast<size_t>(sample_rate_hz == 8000 ? 1
73 : sample_rate_hz / 16000); 78 : sample_rate_hz / 16000);
79 #endif
74 } 80 }
75 constexpr int LowestBandRate(int sample_rate_hz) { 81 constexpr int LowestBandRate(int sample_rate_hz) {
76 return sample_rate_hz == 8000 ? sample_rate_hz : 16000; 82 return sample_rate_hz == 8000 ? sample_rate_hz : 16000;
77 } 83 }
78 84
79 constexpr bool ValidFullBandRate(int sample_rate_hz) { 85 constexpr bool ValidFullBandRate(int sample_rate_hz) {
80 return sample_rate_hz == 8000 || sample_rate_hz == 16000 || 86 return sample_rate_hz == 8000 || sample_rate_hz == 16000 ||
81 sample_rate_hz == 32000 || sample_rate_hz == 48000; 87 sample_rate_hz == 32000 || sample_rate_hz == 48000;
82 } 88 }
83 89
84 // Detects what kind of optimizations to use for the code. 90 // Detects what kind of optimizations to use for the code.
85 Aec3Optimization DetectOptimization(); 91 Aec3Optimization DetectOptimization();
86 92
87 static_assert(1 == NumBandsForRate(8000), "Number of bands for 8 kHz"); 93 static_assert(1 == NumBandsForRate(8000), "Number of bands for 8 kHz");
88 static_assert(1 == NumBandsForRate(16000), "Number of bands for 16 kHz"); 94 static_assert(1 == NumBandsForRate(16000), "Number of bands for 16 kHz");
89 static_assert(2 == NumBandsForRate(32000), "Number of bands for 32 kHz"); 95 static_assert(2 == NumBandsForRate(32000), "Number of bands for 32 kHz");
96 #ifdef WEBRTC_ARCH_ARM_FAMILY
97 static_assert(2 == NumBandsForRate(48000), "Number of bands for 48 kHz");
98 #else
90 static_assert(3 == NumBandsForRate(48000), "Number of bands for 48 kHz"); 99 static_assert(3 == NumBandsForRate(48000), "Number of bands for 48 kHz");
100 #endif
91 101
92 static_assert(8000 == LowestBandRate(8000), "Sample rate of band 0 for 8 kHz"); 102 static_assert(8000 == LowestBandRate(8000), "Sample rate of band 0 for 8 kHz");
93 static_assert(16000 == LowestBandRate(16000), 103 static_assert(16000 == LowestBandRate(16000),
94 "Sample rate of band 0 for 16 kHz"); 104 "Sample rate of band 0 for 16 kHz");
95 static_assert(16000 == LowestBandRate(32000), 105 static_assert(16000 == LowestBandRate(32000),
96 "Sample rate of band 0 for 32 kHz"); 106 "Sample rate of band 0 for 32 kHz");
97 static_assert(16000 == LowestBandRate(48000), 107 static_assert(16000 == LowestBandRate(48000),
98 "Sample rate of band 0 for 48 kHz"); 108 "Sample rate of band 0 for 48 kHz");
99 109
100 static_assert(ValidFullBandRate(8000), 110 static_assert(ValidFullBandRate(8000),
101 "Test that 8 kHz is a valid sample rate"); 111 "Test that 8 kHz is a valid sample rate");
102 static_assert(ValidFullBandRate(16000), 112 static_assert(ValidFullBandRate(16000),
103 "Test that 16 kHz is a valid sample rate"); 113 "Test that 16 kHz is a valid sample rate");
104 static_assert(ValidFullBandRate(32000), 114 static_assert(ValidFullBandRate(32000),
105 "Test that 32 kHz is a valid sample rate"); 115 "Test that 32 kHz is a valid sample rate");
106 static_assert(ValidFullBandRate(48000), 116 static_assert(ValidFullBandRate(48000),
107 "Test that 48 kHz is a valid sample rate"); 117 "Test that 48 kHz is a valid sample rate");
108 static_assert(!ValidFullBandRate(8001), 118 static_assert(!ValidFullBandRate(8001),
109 "Test that 8001 Hz is not a valid sample rate"); 119 "Test that 8001 Hz is not a valid sample rate");
110 120
111 } // namespace webrtc 121 } // namespace webrtc
112 122
113 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_AEC3_COMMON_H_ 123 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_AEC3_COMMON_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/audio_processing/audio_processing_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698