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 :
12 : /*
13 : * This file contains implementations of the iLBC specific functions
14 : * WebRtcSpl_ReverseOrderMultArrayElements()
15 : * WebRtcSpl_ElementwiseVectorMult()
16 : * WebRtcSpl_AddVectorsAndShift()
17 : * WebRtcSpl_AddAffineVectorToVector()
18 : * WebRtcSpl_AffineTransformVector()
19 : *
20 : */
21 :
22 : #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
23 :
24 0 : void WebRtcSpl_ReverseOrderMultArrayElements(int16_t *out, const int16_t *in,
25 : const int16_t *win,
26 : size_t vector_length,
27 : int16_t right_shifts)
28 : {
29 : size_t i;
30 0 : int16_t *outptr = out;
31 0 : const int16_t *inptr = in;
32 0 : const int16_t *winptr = win;
33 0 : for (i = 0; i < vector_length; i++)
34 : {
35 0 : *outptr++ = (int16_t)((*inptr++ * *winptr--) >> right_shifts);
36 : }
37 0 : }
38 :
39 0 : void WebRtcSpl_ElementwiseVectorMult(int16_t *out, const int16_t *in,
40 : const int16_t *win, size_t vector_length,
41 : int16_t right_shifts)
42 : {
43 : size_t i;
44 0 : int16_t *outptr = out;
45 0 : const int16_t *inptr = in;
46 0 : const int16_t *winptr = win;
47 0 : for (i = 0; i < vector_length; i++)
48 : {
49 0 : *outptr++ = (int16_t)((*inptr++ * *winptr++) >> right_shifts);
50 : }
51 0 : }
52 :
53 0 : void WebRtcSpl_AddVectorsAndShift(int16_t *out, const int16_t *in1,
54 : const int16_t *in2, size_t vector_length,
55 : int16_t right_shifts)
56 : {
57 : size_t i;
58 0 : int16_t *outptr = out;
59 0 : const int16_t *in1ptr = in1;
60 0 : const int16_t *in2ptr = in2;
61 0 : for (i = vector_length; i > 0; i--)
62 : {
63 0 : (*outptr++) = (int16_t)(((*in1ptr++) + (*in2ptr++)) >> right_shifts);
64 : }
65 0 : }
66 :
67 0 : void WebRtcSpl_AddAffineVectorToVector(int16_t *out, int16_t *in,
68 : int16_t gain, int32_t add_constant,
69 : int16_t right_shifts,
70 : size_t vector_length)
71 : {
72 : size_t i;
73 :
74 0 : for (i = 0; i < vector_length; i++)
75 : {
76 0 : out[i] += (int16_t)((in[i] * gain + add_constant) >> right_shifts);
77 : }
78 0 : }
79 :
80 0 : void WebRtcSpl_AffineTransformVector(int16_t *out, int16_t *in,
81 : int16_t gain, int32_t add_constant,
82 : int16_t right_shifts, size_t vector_length)
83 : {
84 : size_t i;
85 :
86 0 : for (i = 0; i < vector_length; i++)
87 : {
88 0 : out[i] = (int16_t)((in[i] * gain + add_constant) >> right_shifts);
89 : }
90 0 : }
|