OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 <assert.h> | |
11 | 10 |
| 11 #include "webrtc/base/checks.h" |
12 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" | 12 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" |
13 | 13 |
14 // TODO(bjornv): Change the return type to report errors. | 14 // TODO(bjornv): Change the return type to report errors. |
15 | 15 |
16 void WebRtcSpl_FilterARFastQ12(const int16_t* data_in, | 16 void WebRtcSpl_FilterARFastQ12(const int16_t* data_in, |
17 int16_t* data_out, | 17 int16_t* data_out, |
18 const int16_t* __restrict coefficients, | 18 const int16_t* __restrict coefficients, |
19 size_t coefficients_length, | 19 size_t coefficients_length, |
20 size_t data_length) { | 20 size_t data_length) { |
21 size_t i = 0; | 21 size_t i = 0; |
22 size_t j = 0; | 22 size_t j = 0; |
23 | 23 |
24 assert(data_length > 0); | 24 RTC_DCHECK_GT(data_length, 0); |
25 assert(coefficients_length > 1); | 25 RTC_DCHECK_GT(coefficients_length, 1); |
26 | 26 |
27 for (i = 0; i < data_length; i++) { | 27 for (i = 0; i < data_length; i++) { |
28 int32_t output = 0; | 28 int32_t output = 0; |
29 int32_t sum = 0; | 29 int32_t sum = 0; |
30 | 30 |
31 for (j = coefficients_length - 1; j > 0; j--) { | 31 for (j = coefficients_length - 1; j > 0; j--) { |
32 sum += coefficients[j] * data_out[i - j]; | 32 sum += coefficients[j] * data_out[i - j]; |
33 } | 33 } |
34 | 34 |
35 output = coefficients[0] * data_in[i]; | 35 output = coefficients[0] * data_in[i]; |
36 output -= sum; | 36 output -= sum; |
37 | 37 |
38 // Saturate and store the output. | 38 // Saturate and store the output. |
39 output = WEBRTC_SPL_SAT(134215679, output, -134217728); | 39 output = WEBRTC_SPL_SAT(134215679, output, -134217728); |
40 data_out[i] = (int16_t)((output + 2048) >> 12); | 40 data_out[i] = (int16_t)((output + 2048) >> 12); |
41 } | 41 } |
42 } | 42 } |
OLD | NEW |