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 #include "LVM_Types.h"
22 
23 /**********************************************************************************
24     VARIOUS FUNCTIONS
25 ***********************************************************************************/
26 
27 void LoadConst_Float(          const LVM_FLOAT val,
28                                LVM_FLOAT *dst,
29                                LVM_INT16 n );
30 
31 void Copy_Float(                 const LVM_FLOAT *src,
32                                  LVM_FLOAT *dst,
33                                  LVM_INT16 n );
34 #ifdef SUPPORT_MC
35 void Copy_Float_Mc_Stereo(       const LVM_FLOAT *src,
36                                  LVM_FLOAT *dst,
37                                  LVM_INT16 NrFrames,
38                                  LVM_INT32 NrChannels);
39 void Copy_Float_Stereo_Mc(       const LVM_FLOAT *src,
40                                  LVM_FLOAT *StereoOut,
41                                  LVM_FLOAT *dst,
42                                  LVM_INT16 NrFrames,
43                                  LVM_INT32 NrChannels);
44 #endif
45 
46 /*********************************************************************************
47  * note: In Mult3s_16x16() saturation of result is not taken care when           *
48  *       overflow occurs.                                                        *
49  *       For example when *src = 0x8000, val = *0x8000                           *
50  *       The function gives the output as 0x8000 instead of 0x7fff               *
51  *       This is the only case which will give wrong result.                     *
52  *       For more information refer to Vector_Arithmetic.doc in /doc folder      *
53  *********************************************************************************/
54 void Mult3s_Float(            const LVM_FLOAT *src,
55                               const LVM_FLOAT val,
56                               LVM_FLOAT *dst,
57                               LVM_INT16 n);
58 
59 /*********************************************************************************
60  * note: In Mult3s_32x16() saturation of result is not taken care when           *
61  *       overflow occurs.                                                        *
62  *       For example when *src = 0x8000000, val = *0x8000                        *
63  *       The function gives the output as 0x8000000 instead of 0x7fffffff        *
64  *       This is the only extreme condition which is giving unexpected result    *
65  *       For more information refer to Vector_Arithmetic.doc in /doc folder      *
66  *********************************************************************************/
67 void Mult3s_32x16(            const LVM_INT32  *src,
68                               const LVM_INT16 val,
69                                     LVM_INT32  *dst,
70                                     LVM_INT16 n);
71 void DelayMix_Float(const LVM_FLOAT *src,           /* Source 1, to be delayed */
72                     LVM_FLOAT *delay,         /* Delay buffer */
73                     LVM_INT16 size,           /* Delay size */
74                     LVM_FLOAT *dst,           /* Source/destination */
75                     LVM_INT16 *pOffset,       /* Delay offset */
76                     LVM_INT16 n)  ;            /* Number of stereo samples */
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 void Add2_Sat_Float(          const LVM_FLOAT *src,
83                               LVM_FLOAT *dst,
84                               LVM_INT16 n );
85 void Mac3s_Sat_Float(         const LVM_FLOAT *src,
86                               const LVM_FLOAT val,
87                               LVM_FLOAT *dst,
88                               LVM_INT16 n);
89 void DelayAllPass_Sat_32x16To32(    LVM_INT32  *delay,              /* Delay buffer */
90                                     LVM_UINT16 size,                /* Delay size */
91                                     LVM_INT16 coeff,                /* All pass filter coefficient */
92                                     LVM_UINT16 DelayOffset,         /* Simple delay offset */
93                                     LVM_UINT16 *pAllPassOffset,     /* All pass filter delay offset */
94                                     LVM_INT32  *dst,                /* Source/destination */
95                                     LVM_INT16 n);
96 
97 /**********************************************************************************
98     SHIFT FUNCTIONS
99 ***********************************************************************************/
100 void Shift_Sat_Float (const   LVM_INT16   val,
101                       const   LVM_FLOAT   *src,
102                       LVM_FLOAT   *dst,
103                       LVM_INT16   n);
104 /**********************************************************************************
105     AUDIO FORMAT CONVERSION FUNCTIONS
106 ***********************************************************************************/
107 void MonoTo2I_Float( const LVM_FLOAT     *src,
108                      LVM_FLOAT     *dst,
109                      LVM_INT16 n);
110 void From2iToMono_Float(         const LVM_FLOAT  *src,
111                                  LVM_FLOAT  *dst,
112                                  LVM_INT16 n);
113 #ifdef SUPPORT_MC
114 void FromMcToMono_Float(const LVM_FLOAT *src,
115                         LVM_FLOAT *dst,
116                         LVM_INT16 NrFrames,
117                         LVM_INT16 NrChannels);
118 #endif
119 void MSTo2i_Sat_Float(        const LVM_FLOAT *srcM,
120                               const LVM_FLOAT *srcS,
121                               LVM_FLOAT *dst,
122                               LVM_INT16 n );
123 void From2iToMS_Float(        const LVM_FLOAT *src,
124                               LVM_FLOAT *dstM,
125                               LVM_FLOAT *dstS,
126                               LVM_INT16 n );
127 void JoinTo2i_Float(          const LVM_FLOAT  *srcL,
128                               const LVM_FLOAT  *srcR,
129                               LVM_FLOAT  *dst,
130                               LVM_INT16 n );
131 
132 /**********************************************************************************
133     DATA TYPE CONVERSION FUNCTIONS
134 ***********************************************************************************/
135 
136 void Int16LShiftToInt32_16x32(const LVM_INT16 *src,
137                                     LVM_INT32  *dst,
138                                     LVM_INT16 n,
139                                     LVM_INT16 shift );
140 
141 void Int32RShiftToInt16_Sat_32x16(const  LVM_INT32  *src,
142                                     LVM_INT16 *dst,
143                                     LVM_INT16 n,
144                                     LVM_INT16 shift );
145 
146 /**********************************************************************************/
147 
148 #endif  /* _VECTOR_ARITHMETIC_H_ */
149 
150 /**********************************************************************************/
151