OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 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 #include "webrtc/modules/audio_processing/aec3/decimator_by_4.h" | 10 #include "webrtc/modules/audio_processing/aec3/decimator_by_4.h" |
11 | 11 |
12 #include "webrtc/base/checks.h" | 12 #include "webrtc/base/checks.h" |
13 | 13 |
14 namespace webrtc { | 14 namespace webrtc { |
15 namespace { | 15 namespace { |
16 | 16 |
17 // [B,A] = butter(2,1500/16000) which are the same as [B,A] = | 17 // [B,A] = butter(2,1500/16000) which are the same as [B,A] = |
18 // butter(2,750/8000). | 18 // butter(2,750/8000). |
19 const CascadedBiQuadFilter::BiQuadCoefficients kLowPassFilterCoefficients = { | 19 const CascadedBiQuadFilter::BiQuadCoefficients kLowPassFilterCoefficients = { |
20 {0.0179f, 0.0357f, 0.0179f}, | 20 {0.0179f, 0.0357f, 0.0179f}, |
21 {-1.5879f, 0.6594f}}; | 21 {-1.5879f, 0.6594f}}; |
22 | 22 |
23 } // namespace | 23 } // namespace |
24 | 24 |
25 DecimatorBy4::DecimatorBy4() | 25 DecimatorBy4::DecimatorBy4() |
26 : low_pass_filter_(kLowPassFilterCoefficients, 3) {} | 26 : low_pass_filter_(kLowPassFilterCoefficients, 3) {} |
27 | 27 |
28 void DecimatorBy4::Decimate(rtc::ArrayView<const float> in, | 28 void DecimatorBy4::Decimate(rtc::ArrayView<const float> in, |
29 std::array<float, kSubBlockSize>* out) { | 29 rtc::ArrayView<float> out) { |
30 RTC_DCHECK_EQ(kBlockSize, in.size()); | 30 RTC_DCHECK_EQ(kBlockSize, in.size()); |
31 RTC_DCHECK(out); | 31 RTC_DCHECK_EQ(kSubBlockSize, out.size()); |
32 std::array<float, kBlockSize> x; | 32 std::array<float, kBlockSize> x; |
33 | 33 |
34 // Limit the frequency content of the signal to avoid aliasing. | 34 // Limit the frequency content of the signal to avoid aliasing. |
35 low_pass_filter_.Process(in, x); | 35 low_pass_filter_.Process(in, x); |
36 | 36 |
37 // Downsample the signal. | 37 // Downsample the signal. |
38 for (size_t j = 0, k = 0; j < out->size(); ++j, k += 4) { | 38 for (size_t j = 0, k = 0; j < out.size(); ++j, k += 4) { |
39 RTC_DCHECK_GT(kBlockSize, k); | 39 RTC_DCHECK_GT(kBlockSize, k); |
40 (*out)[j] = x[k]; | 40 out[j] = x[k]; |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 } // namespace webrtc | 44 } // namespace webrtc |
OLD | NEW |