• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2004-2010 NXP Software
3  * Copyright (C) 2010 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _VECTOR_ARITHMETIC_H_
19 #define _VECTOR_ARITHMETIC_H_
20 
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif /* __cplusplus */
25 
26 #include "LVM_Types.h"
27 
28 /**********************************************************************************
29     VARIOUS FUNCTIONS
30 ***********************************************************************************/
31 
32 void LoadConst_16(            const LVM_INT16 val,
33                                     LVM_INT16 *dst,
34                                     LVM_INT16 n );
35 
36 void LoadConst_32(            const LVM_INT32 val,
37                                     LVM_INT32 *dst,
38                                     LVM_INT16 n );
39 
40 void Copy_16(                 const LVM_INT16 *src,
41                                     LVM_INT16 *dst,
42                                     LVM_INT16 n );
43 
44 /*********************************************************************************
45  * note: In Mult3s_16x16() saturation of result is not taken care when           *
46  *       overflow occurs.                                                        *
47  *       For example when *src = 0x8000, val = *0x8000                           *
48  *       The function gives the output as 0x8000 instead of 0x7fff               *
49  *       This is the only case which will give wrong result.                     *
50  *       For more information refer to Vector_Arithmetic.doc in /doc folder      *
51  *********************************************************************************/
52 void Mult3s_16x16(            const LVM_INT16 *src,
53                               const LVM_INT16 val,
54                                     LVM_INT16 *dst,
55                                     LVM_INT16 n);
56 
57 /*********************************************************************************
58  * note: In Mult3s_32x16() saturation of result is not taken care when           *
59  *       overflow occurs.                                                        *
60  *       For example when *src = 0x8000000, val = *0x8000                        *
61  *       The function gives the output as 0x8000000 instead of 0x7fffffff        *
62  *       This is the only extreme condition which is giving unexpected result    *
63  *       For more information refer to Vector_Arithmetic.doc in /doc folder      *
64  *********************************************************************************/
65 void Mult3s_32x16(            const LVM_INT32  *src,
66                               const LVM_INT16 val,
67                                     LVM_INT32  *dst,
68                                     LVM_INT16 n);
69 
70 void DelayMix_16x16(          const LVM_INT16 *src,
71                                     LVM_INT16 *delay,
72                                     LVM_INT16 size,
73                                     LVM_INT16 *dst,
74                                     LVM_INT16 *pOffset,
75                                     LVM_INT16 n);
76 
77 void DelayWrite_32(           const LVM_INT32  *src,               /* Source 1, to be delayed */
78                                     LVM_INT32  *delay,             /* Delay buffer */
79                                     LVM_UINT16 size,               /* Delay size */
80                                     LVM_UINT16 *pOffset,           /* Delay offset */
81                                     LVM_INT16 n);
82 
83 void Add2_Sat_16x16(          const LVM_INT16 *src,
84                                     LVM_INT16 *dst,
85                                     LVM_INT16 n );
86 
87 void Add2_Sat_32x32(          const LVM_INT32  *src,
88                                     LVM_INT32  *dst,
89                                     LVM_INT16 n );
90 
91 void Mac3s_Sat_16x16(         const LVM_INT16 *src,
92                               const LVM_INT16 val,
93                                     LVM_INT16 *dst,
94                                     LVM_INT16 n);
95 
96 void Mac3s_Sat_32x16(         const LVM_INT32  *src,
97                               const LVM_INT16 val,
98                                     LVM_INT32  *dst,
99                                     LVM_INT16 n);
100 
101 void DelayAllPass_Sat_32x16To32(    LVM_INT32  *delay,              /* Delay buffer */
102                                     LVM_UINT16 size,                /* Delay size */
103                                     LVM_INT16 coeff,                /* All pass filter coefficient */
104                                     LVM_UINT16 DelayOffset,         /* Simple delay offset */
105                                     LVM_UINT16 *pAllPassOffset,     /* All pass filter delay offset */
106                                     LVM_INT32  *dst,                /* Source/destination */
107                                     LVM_INT16 n);
108 
109 /**********************************************************************************
110     SHIFT FUNCTIONS
111 ***********************************************************************************/
112 
113 void Shift_Sat_v16xv16 (      const LVM_INT16 val,
114                               const LVM_INT16 *src,
115                                     LVM_INT16 *dst,
116                                     LVM_INT16 n);
117 
118 void Shift_Sat_v32xv32 (      const LVM_INT16 val,
119                               const LVM_INT32 *src,
120                                     LVM_INT32 *dst,
121                                     LVM_INT16 n);
122 
123 /**********************************************************************************
124     AUDIO FORMAT CONVERSION FUNCTIONS
125 ***********************************************************************************/
126 
127 void MonoTo2I_16(             const LVM_INT16 *src,
128                                     LVM_INT16 *dst,
129                                     LVM_INT16 n);
130 
131 void MonoTo2I_32(             const LVM_INT32  *src,
132                                     LVM_INT32  *dst,
133                                     LVM_INT16 n);
134 
135 void From2iToMono_32(         const LVM_INT32  *src,
136                                     LVM_INT32  *dst,
137                                     LVM_INT16 n);
138 
139 void MSTo2i_Sat_16x16(        const LVM_INT16 *srcM,
140                               const LVM_INT16 *srcS,
141                                     LVM_INT16 *dst,
142                                     LVM_INT16 n );
143 
144 void From2iToMS_16x16(        const LVM_INT16 *src,
145                                     LVM_INT16 *dstM,
146                                     LVM_INT16 *dstS,
147                                     LVM_INT16 n );
148 
149 void From2iToMono_16(         const LVM_INT16 *src,
150                                     LVM_INT16 *dst,
151                                     LVM_INT16 n);
152 
153 void JoinTo2i_32x32(          const LVM_INT32  *srcL,
154                               const LVM_INT32  *srcR,
155                                     LVM_INT32  *dst,
156                                     LVM_INT16 n );
157 
158 /**********************************************************************************
159     DATA TYPE CONVERSION FUNCTIONS
160 ***********************************************************************************/
161 
162 void Int16LShiftToInt32_16x32(const LVM_INT16 *src,
163                                     LVM_INT32  *dst,
164                                     LVM_INT16 n,
165                                     LVM_INT16 shift );
166 
167 void Int32RShiftToInt16_Sat_32x16(const  LVM_INT32  *src,
168                                     LVM_INT16 *dst,
169                                     LVM_INT16 n,
170                                     LVM_INT16 shift );
171 
172 #ifdef __cplusplus
173 }
174 #endif /* __cplusplus */
175 
176 
177 /**********************************************************************************/
178 
179 #endif  /* _VECTOR_ARITHMETIC_H_ */
180 
181 /**********************************************************************************/
182