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 |
(...skipping 16 matching lines...) Expand all Loading... |
27 constexpr size_t kSubBlockSize = 16; | 27 constexpr size_t kSubBlockSize = 16; |
28 | 28 |
29 constexpr size_t NumBandsForRate(int sample_rate_hz) { | 29 constexpr size_t NumBandsForRate(int sample_rate_hz) { |
30 return static_cast<size_t>(sample_rate_hz == 8000 ? 1 | 30 return static_cast<size_t>(sample_rate_hz == 8000 ? 1 |
31 : sample_rate_hz / 16000); | 31 : sample_rate_hz / 16000); |
32 } | 32 } |
33 constexpr int LowestBandRate(int sample_rate_hz) { | 33 constexpr int LowestBandRate(int sample_rate_hz) { |
34 return sample_rate_hz == 8000 ? sample_rate_hz : 16000; | 34 return sample_rate_hz == 8000 ? sample_rate_hz : 16000; |
35 } | 35 } |
36 | 36 |
| 37 constexpr bool ValidFullBandRate(int sample_rate_hz) { |
| 38 return sample_rate_hz == 8000 || sample_rate_hz == 16000 || |
| 39 sample_rate_hz == 32000 || sample_rate_hz == 48000; |
| 40 } |
| 41 |
37 static_assert(1 == NumBandsForRate(8000), "Number of bands for 8 kHz"); | 42 static_assert(1 == NumBandsForRate(8000), "Number of bands for 8 kHz"); |
38 static_assert(1 == NumBandsForRate(16000), "Number of bands for 16 kHz"); | 43 static_assert(1 == NumBandsForRate(16000), "Number of bands for 16 kHz"); |
39 static_assert(2 == NumBandsForRate(32000), "Number of bands for 32 kHz"); | 44 static_assert(2 == NumBandsForRate(32000), "Number of bands for 32 kHz"); |
40 static_assert(3 == NumBandsForRate(48000), "Number of bands for 48 kHz"); | 45 static_assert(3 == NumBandsForRate(48000), "Number of bands for 48 kHz"); |
41 | 46 |
42 static_assert(8000 == LowestBandRate(8000), "Sample rate of band 0 for 8 kHz"); | 47 static_assert(8000 == LowestBandRate(8000), "Sample rate of band 0 for 8 kHz"); |
43 static_assert(16000 == LowestBandRate(16000), | 48 static_assert(16000 == LowestBandRate(16000), |
44 "Sample rate of band 0 for 16 kHz"); | 49 "Sample rate of band 0 for 16 kHz"); |
45 static_assert(16000 == LowestBandRate(32000), | 50 static_assert(16000 == LowestBandRate(32000), |
46 "Sample rate of band 0 for 32 kHz"); | 51 "Sample rate of band 0 for 32 kHz"); |
47 static_assert(16000 == LowestBandRate(48000), | 52 static_assert(16000 == LowestBandRate(48000), |
48 "Sample rate of band 0 for 48 kHz"); | 53 "Sample rate of band 0 for 48 kHz"); |
49 | 54 |
| 55 static_assert(ValidFullBandRate(8000), |
| 56 "Test that 8 kHz is a valid sample rate"); |
| 57 static_assert(ValidFullBandRate(16000), |
| 58 "Test that 16 kHz is a valid sample rate"); |
| 59 static_assert(ValidFullBandRate(32000), |
| 60 "Test that 32 kHz is a valid sample rate"); |
| 61 static_assert(ValidFullBandRate(48000), |
| 62 "Test that 48 kHz is a valid sample rate"); |
| 63 static_assert(!ValidFullBandRate(8001), |
| 64 "Test that 8001 Hz is not a valid sample rate"); |
| 65 |
50 } // namespace webrtc | 66 } // namespace webrtc |
51 | 67 |
52 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_AEC3_CONSTANTS_H_ | 68 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_AEC3_CONSTANTS_H_ |
OLD | NEW |