OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2017 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 #include "webrtc/modules/audio_processing/aec3/decimator_by_4.h" | |
11 | |
12 #include "webrtc/base/checks.h" | |
13 | |
14 namespace webrtc { | |
15 namespace { | |
16 | |
17 // [B,A] = butter(2,1500/16000) which are the same as [B,A] = | |
18 // butter(2,750/8000). | |
19 const CascadedBiQuadFilter::BiQuadCoefficients kLowPassFilterCoefficients = { | |
20 {0.0179f, 0.0357f, 0.0179f}, | |
21 {-1.5879f, 0.6594f}}; | |
22 | |
23 } // namespace | |
24 | |
25 DecimatorBy4::DecimatorBy4() | |
26 : low_pass_filter_(kLowPassFilterCoefficients, 3) {} | |
27 | |
28 void DecimatorBy4::Decimate(rtc::ArrayView<const float> in, | |
29 std::array<float, kSubBlockSize>* out) { | |
30 RTC_DCHECK_EQ(kBlockSize, in.size()); | |
31 RTC_DCHECK(out); | |
32 std::array<float, kBlockSize> x; | |
hlundin-webrtc
2017/02/06 09:13:18
What is the cost of this allocation? The same as f
aleloi
2017/02/06 09:24:42
It's statically allocated: http://stackoverflow.co
hlundin-webrtc
2017/02/06 10:26:36
Thanks. No problems then.
peah-webrtc
2017/02/06 11:25:38
Afaics, std::array is a template that encapsulates
| |
33 | |
34 // Limit the frequency content of the signal to avoid aliasing. | |
35 low_pass_filter_.Process(in, x); | |
36 | |
37 // Downsample the signal. | |
38 for (size_t j = 0, k = 0; j < out->size(); ++j, k += 4) { | |
39 RTC_DCHECK_GT(kBlockSize, k); | |
40 (*out)[j] = x[k]; | |
41 } | |
42 } | |
43 | |
44 } // namespace webrtc | |
OLD | NEW |