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