VectorArithmetic.h revision 2c8e5cab3faa6d360e222b7a6c40a80083d021ac
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/**********************************************************************************
19
20     $Author: beq07716 $
21     $Revision: 853 $
22     $Date: 2010-06-16 15:10:28 +0200 (Wed, 16 Jun 2010) $
23
24***********************************************************************************/
25
26#ifndef _VECTOR_ARITHMETIC_H_
27#define _VECTOR_ARITHMETIC_H_
28
29
30#ifdef __cplusplus
31extern "C" {
32#endif /* __cplusplus */
33
34#include "LVM_Types.h"
35
36/**********************************************************************************
37    VARIOUS FUNCTIONS
38***********************************************************************************/
39
40void LoadConst_16(            const LVM_INT16 val,
41                                    LVM_INT16 *dst,
42                                    LVM_INT16 n );
43
44void LoadConst_32(            const LVM_INT32 val,
45                                    LVM_INT32 *dst,
46                                    LVM_INT16 n );
47
48void Copy_16(                 const LVM_INT16 *src,
49                                    LVM_INT16 *dst,
50                                    LVM_INT16 n );
51
52/*********************************************************************************
53 * note: In Mult3s_16x16() saturation of result is not taken care when           *
54 *       overflow occurs.                                                        *
55 *       For example when *src = 0x8000, val = *0x8000                           *
56 *       The function gives the output as 0x8000 instead of 0x7fff               *
57 *       This is the only case which will give wrong result.                     *
58 *       For more information refer to Vector_Arithmetic.doc in /doc folder      *
59 *********************************************************************************/
60void Mult3s_16x16(            const LVM_INT16 *src,
61                              const LVM_INT16 val,
62                                    LVM_INT16 *dst,
63                                    LVM_INT16 n);
64
65/*********************************************************************************
66 * note: In Mult3s_32x16() saturation of result is not taken care when           *
67 *       overflow occurs.                                                        *
68 *       For example when *src = 0x8000000, val = *0x8000                        *
69 *       The function gives the output as 0x8000000 instead of 0x7fffffff        *
70 *       This is the only extreme condition which is giving unexpected result    *
71 *       For more information refer to Vector_Arithmetic.doc in /doc folder      *
72 *********************************************************************************/
73void Mult3s_32x16(            const LVM_INT32  *src,
74                              const LVM_INT16 val,
75                                    LVM_INT32  *dst,
76                                    LVM_INT16 n);
77
78void DelayMix_16x16(          const LVM_INT16 *src,
79                                    LVM_INT16 *delay,
80                                    LVM_INT16 size,
81                                    LVM_INT16 *dst,
82                                    LVM_INT16 *pOffset,
83                                    LVM_INT16 n);
84
85void DelayWrite_32(           const LVM_INT32  *src,               /* Source 1, to be delayed */
86                                    LVM_INT32  *delay,             /* Delay buffer */
87                                    LVM_UINT16 size,               /* Delay size */
88                                    LVM_UINT16 *pOffset,           /* Delay offset */
89                                    LVM_INT16 n);
90
91void Add2_Sat_16x16(          const LVM_INT16 *src,
92                                    LVM_INT16 *dst,
93                                    LVM_INT16 n );
94
95void Add2_Sat_32x32(          const LVM_INT32  *src,
96                                    LVM_INT32  *dst,
97                                    LVM_INT16 n );
98
99void Mac3s_Sat_16x16(         const LVM_INT16 *src,
100                              const LVM_INT16 val,
101                                    LVM_INT16 *dst,
102                                    LVM_INT16 n);
103
104void Mac3s_Sat_32x16(         const LVM_INT32  *src,
105                              const LVM_INT16 val,
106                                    LVM_INT32  *dst,
107                                    LVM_INT16 n);
108
109void DelayAllPass_Sat_32x16To32(    LVM_INT32  *delay,              /* Delay buffer */
110                                    LVM_UINT16 size,                /* Delay size */
111                                    LVM_INT16 coeff,                /* All pass filter coefficient */
112                                    LVM_UINT16 DelayOffset,         /* Simple delay offset */
113                                    LVM_UINT16 *pAllPassOffset,     /* All pass filter delay offset */
114                                    LVM_INT32  *dst,                /* Source/destination */
115                                    LVM_INT16 n);
116
117/**********************************************************************************
118    SHIFT FUNCTIONS
119***********************************************************************************/
120
121void Shift_Sat_v16xv16 (      const LVM_INT16 val,
122                              const LVM_INT16 *src,
123                                    LVM_INT16 *dst,
124                                    LVM_INT16 n);
125
126void Shift_Sat_v32xv32 (      const LVM_INT16 val,
127                              const LVM_INT32 *src,
128                                    LVM_INT32 *dst,
129                                    LVM_INT16 n);
130
131/**********************************************************************************
132    AUDIO FORMAT CONVERSION FUNCTIONS
133***********************************************************************************/
134
135void MonoTo2I_16(             const LVM_INT16 *src,
136                                    LVM_INT16 *dst,
137                                    LVM_INT16 n);
138
139void MonoTo2I_32(             const LVM_INT32  *src,
140                                    LVM_INT32  *dst,
141                                    LVM_INT16 n);
142
143void From2iToMono_32(         const LVM_INT32  *src,
144                                    LVM_INT32  *dst,
145                                    LVM_INT16 n);
146
147void MSTo2i_Sat_16x16(        const LVM_INT16 *srcM,
148                              const LVM_INT16 *srcS,
149                                    LVM_INT16 *dst,
150                                    LVM_INT16 n );
151
152void From2iToMS_16x16(        const LVM_INT16 *src,
153                                    LVM_INT16 *dstM,
154                                    LVM_INT16 *dstS,
155                                    LVM_INT16 n );
156
157void From2iToMono_16(         const LVM_INT16 *src,
158                                    LVM_INT16 *dst,
159                                    LVM_INT16 n);
160
161void JoinTo2i_32x32(          const LVM_INT32  *srcL,
162                              const LVM_INT32  *srcR,
163                                    LVM_INT32  *dst,
164                                    LVM_INT16 n );
165
166/**********************************************************************************
167    DATA TYPE CONVERSION FUNCTIONS
168***********************************************************************************/
169
170void Int16LShiftToInt32_16x32(const LVM_INT16 *src,
171                                    LVM_INT32  *dst,
172                                    LVM_INT16 n,
173                                    LVM_INT16 shift );
174
175void Int32RShiftToInt16_Sat_32x16(const  LVM_INT32  *src,
176                                    LVM_INT16 *dst,
177                                    LVM_INT16 n,
178                                    LVM_INT16 shift );
179
180#ifdef __cplusplus
181}
182#endif /* __cplusplus */
183
184
185/**********************************************************************************/
186
187#endif  /* _VECTOR_ARITHMETIC_H_ */
188
189/**********************************************************************************/
190