blob: 054b0d8afd8fcf0086bac867c67f2aa1cef8dc42 [file] [log] [blame]
peahd0263542017-01-03 04:20:34 -08001/*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_AEC3_CONSTANTS_H_
12#define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_AEC3_CONSTANTS_H_
13
14#include <stddef.h>
15
16namespace webrtc {
17
18constexpr size_t kFftLengthBy2 = 64;
19constexpr size_t kFftLengthBy2Plus1 = kFftLengthBy2 + 1;
20constexpr size_t kFftLength = 2 * kFftLengthBy2;
21
22constexpr size_t kMaxNumBands = 3;
23constexpr size_t kSubFrameLength = 80;
24
25constexpr size_t kBlockSize = kFftLengthBy2;
26constexpr size_t kExtendedBlockSize = 2 * kFftLengthBy2;
27constexpr size_t kSubBlockSize = 16;
28
29constexpr size_t NumBandsForRate(int sample_rate_hz) {
30 return static_cast<size_t>(sample_rate_hz == 8000 ? 1
31 : sample_rate_hz / 16000);
32}
33constexpr int LowestBandRate(int sample_rate_hz) {
34 return sample_rate_hz == 8000 ? sample_rate_hz : 16000;
35}
36
peah21920892017-02-08 05:08:56 -080037constexpr 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
peahd0263542017-01-03 04:20:34 -080042static_assert(1 == NumBandsForRate(8000), "Number of bands for 8 kHz");
43static_assert(1 == NumBandsForRate(16000), "Number of bands for 16 kHz");
44static_assert(2 == NumBandsForRate(32000), "Number of bands for 32 kHz");
45static_assert(3 == NumBandsForRate(48000), "Number of bands for 48 kHz");
46
47static_assert(8000 == LowestBandRate(8000), "Sample rate of band 0 for 8 kHz");
48static_assert(16000 == LowestBandRate(16000),
49 "Sample rate of band 0 for 16 kHz");
50static_assert(16000 == LowestBandRate(32000),
51 "Sample rate of band 0 for 32 kHz");
52static_assert(16000 == LowestBandRate(48000),
53 "Sample rate of band 0 for 48 kHz");
54
peah21920892017-02-08 05:08:56 -080055static_assert(ValidFullBandRate(8000),
56 "Test that 8 kHz is a valid sample rate");
57static_assert(ValidFullBandRate(16000),
58 "Test that 16 kHz is a valid sample rate");
59static_assert(ValidFullBandRate(32000),
60 "Test that 32 kHz is a valid sample rate");
61static_assert(ValidFullBandRate(48000),
62 "Test that 48 kHz is a valid sample rate");
63static_assert(!ValidFullBandRate(8001),
64 "Test that 8001 Hz is not a valid sample rate");
65
peahd0263542017-01-03 04:20:34 -080066} // namespace webrtc
67
68#endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_AEC3_CONSTANTS_H_