| 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_CONSTANTS_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_AEC3_COMMON_H_ |
| 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_AEC3_CONSTANTS_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 | 16 |
| 16 namespace webrtc { | 17 namespace webrtc { |
| 17 | 18 |
| 19 #ifdef _MSC_VER /* visual c++ */ |
| 20 #define ALIGN16_BEG __declspec(align(16)) |
| 21 #define ALIGN16_END |
| 22 #else /* gcc or icc */ |
| 23 #define ALIGN16_BEG |
| 24 #define ALIGN16_END __attribute__((aligned(16))) |
| 25 #endif |
| 26 |
| 27 enum class Aec3Optimization { kNone, kSse2, kNeon }; |
| 28 |
| 18 constexpr size_t kFftLengthBy2 = 64; | 29 constexpr size_t kFftLengthBy2 = 64; |
| 19 constexpr size_t kFftLengthBy2Plus1 = kFftLengthBy2 + 1; | 30 constexpr size_t kFftLengthBy2Plus1 = kFftLengthBy2 + 1; |
| 20 constexpr size_t kFftLength = 2 * kFftLengthBy2; | 31 constexpr size_t kFftLength = 2 * kFftLengthBy2; |
| 21 | 32 |
| 22 constexpr size_t kMaxNumBands = 3; | 33 constexpr size_t kMaxNumBands = 3; |
| 23 constexpr size_t kSubFrameLength = 80; | 34 constexpr size_t kSubFrameLength = 80; |
| 24 | 35 |
| 25 constexpr size_t kBlockSize = kFftLengthBy2; | 36 constexpr size_t kBlockSize = kFftLengthBy2; |
| 26 constexpr size_t kExtendedBlockSize = 2 * kFftLengthBy2; | 37 constexpr size_t kExtendedBlockSize = 2 * kFftLengthBy2; |
| 27 constexpr size_t kSubBlockSize = 16; | 38 constexpr size_t kSubBlockSize = 16; |
| 28 | 39 |
| 29 constexpr size_t NumBandsForRate(int sample_rate_hz) { | 40 constexpr size_t NumBandsForRate(int sample_rate_hz) { |
| 30 return static_cast<size_t>(sample_rate_hz == 8000 ? 1 | 41 return static_cast<size_t>(sample_rate_hz == 8000 ? 1 |
| 31 : sample_rate_hz / 16000); | 42 : sample_rate_hz / 16000); |
| 32 } | 43 } |
| 33 constexpr int LowestBandRate(int sample_rate_hz) { | 44 constexpr int LowestBandRate(int sample_rate_hz) { |
| 34 return sample_rate_hz == 8000 ? sample_rate_hz : 16000; | 45 return sample_rate_hz == 8000 ? sample_rate_hz : 16000; |
| 35 } | 46 } |
| 36 | 47 |
| 37 constexpr bool ValidFullBandRate(int sample_rate_hz) { | 48 constexpr bool ValidFullBandRate(int sample_rate_hz) { |
| 38 return sample_rate_hz == 8000 || sample_rate_hz == 16000 || | 49 return sample_rate_hz == 8000 || sample_rate_hz == 16000 || |
| 39 sample_rate_hz == 32000 || sample_rate_hz == 48000; | 50 sample_rate_hz == 32000 || sample_rate_hz == 48000; |
| 40 } | 51 } |
| 41 | 52 |
| 53 // Detects what kind of optimizations to use for the code. |
| 54 Aec3Optimization DetectOptimization(); |
| 55 |
| 42 static_assert(1 == NumBandsForRate(8000), "Number of bands for 8 kHz"); | 56 static_assert(1 == NumBandsForRate(8000), "Number of bands for 8 kHz"); |
| 43 static_assert(1 == NumBandsForRate(16000), "Number of bands for 16 kHz"); | 57 static_assert(1 == NumBandsForRate(16000), "Number of bands for 16 kHz"); |
| 44 static_assert(2 == NumBandsForRate(32000), "Number of bands for 32 kHz"); | 58 static_assert(2 == NumBandsForRate(32000), "Number of bands for 32 kHz"); |
| 45 static_assert(3 == NumBandsForRate(48000), "Number of bands for 48 kHz"); | 59 static_assert(3 == NumBandsForRate(48000), "Number of bands for 48 kHz"); |
| 46 | 60 |
| 47 static_assert(8000 == LowestBandRate(8000), "Sample rate of band 0 for 8 kHz"); | 61 static_assert(8000 == LowestBandRate(8000), "Sample rate of band 0 for 8 kHz"); |
| 48 static_assert(16000 == LowestBandRate(16000), | 62 static_assert(16000 == LowestBandRate(16000), |
| 49 "Sample rate of band 0 for 16 kHz"); | 63 "Sample rate of band 0 for 16 kHz"); |
| 50 static_assert(16000 == LowestBandRate(32000), | 64 static_assert(16000 == LowestBandRate(32000), |
| 51 "Sample rate of band 0 for 32 kHz"); | 65 "Sample rate of band 0 for 32 kHz"); |
| 52 static_assert(16000 == LowestBandRate(48000), | 66 static_assert(16000 == LowestBandRate(48000), |
| 53 "Sample rate of band 0 for 48 kHz"); | 67 "Sample rate of band 0 for 48 kHz"); |
| 54 | 68 |
| 55 static_assert(ValidFullBandRate(8000), | 69 static_assert(ValidFullBandRate(8000), |
| 56 "Test that 8 kHz is a valid sample rate"); | 70 "Test that 8 kHz is a valid sample rate"); |
| 57 static_assert(ValidFullBandRate(16000), | 71 static_assert(ValidFullBandRate(16000), |
| 58 "Test that 16 kHz is a valid sample rate"); | 72 "Test that 16 kHz is a valid sample rate"); |
| 59 static_assert(ValidFullBandRate(32000), | 73 static_assert(ValidFullBandRate(32000), |
| 60 "Test that 32 kHz is a valid sample rate"); | 74 "Test that 32 kHz is a valid sample rate"); |
| 61 static_assert(ValidFullBandRate(48000), | 75 static_assert(ValidFullBandRate(48000), |
| 62 "Test that 48 kHz is a valid sample rate"); | 76 "Test that 48 kHz is a valid sample rate"); |
| 63 static_assert(!ValidFullBandRate(8001), | 77 static_assert(!ValidFullBandRate(8001), |
| 64 "Test that 8001 Hz is not a valid sample rate"); | 78 "Test that 8001 Hz is not a valid sample rate"); |
| 65 | 79 |
| 66 } // namespace webrtc | 80 } // namespace webrtc |
| 67 | 81 |
| 68 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_AEC3_CONSTANTS_H_ | 82 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_AEC3_COMMON_H_ |
| OLD | NEW |