summaryrefslogtreecommitdiffstats
path: root/media/libeffects/lvm/lib/Common/lib/VectorArithmetic.h
blob: 2b791bdd6832ed5bdf0625e4bf695907d84e7237 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*
 * Copyright (C) 2004-2010 NXP Software
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _VECTOR_ARITHMETIC_H_
#define _VECTOR_ARITHMETIC_H_


#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#include "LVM_Types.h"

/**********************************************************************************
    VARIOUS FUNCTIONS
***********************************************************************************/

void LoadConst_16(            const LVM_INT16 val,
                                    LVM_INT16 *dst,
                                    LVM_INT16 n );

void LoadConst_32(            const LVM_INT32 val,
                                    LVM_INT32 *dst,
                                    LVM_INT16 n );

void Copy_16(                 const LVM_INT16 *src,
                                    LVM_INT16 *dst,
                                    LVM_INT16 n );

/*********************************************************************************
 * note: In Mult3s_16x16() saturation of result is not taken care when           *
 *       overflow occurs.                                                        *
 *       For example when *src = 0x8000, val = *0x8000                           *
 *       The function gives the output as 0x8000 instead of 0x7fff               *
 *       This is the only case which will give wrong result.                     *
 *       For more information refer to Vector_Arithmetic.doc in /doc folder      *
 *********************************************************************************/
void Mult3s_16x16(            const LVM_INT16 *src,
                              const LVM_INT16 val,
                                    LVM_INT16 *dst,
                                    LVM_INT16 n);

/*********************************************************************************
 * note: In Mult3s_32x16() saturation of result is not taken care when           *
 *       overflow occurs.                                                        *
 *       For example when *src = 0x8000000, val = *0x8000                        *
 *       The function gives the output as 0x8000000 instead of 0x7fffffff        *
 *       This is the only extreme condition which is giving unexpected result    *
 *       For more information refer to Vector_Arithmetic.doc in /doc folder      *
 *********************************************************************************/
void Mult3s_32x16(            const LVM_INT32  *src,
                              const LVM_INT16 val,
                                    LVM_INT32  *dst,
                                    LVM_INT16 n);

void DelayMix_16x16(          const LVM_INT16 *src,
                                    LVM_INT16 *delay,
                                    LVM_INT16 size,
                                    LVM_INT16 *dst,
                                    LVM_INT16 *pOffset,
                                    LVM_INT16 n);

void DelayWrite_32(           const LVM_INT32  *src,               /* Source 1, to be delayed */
                                    LVM_INT32  *delay,             /* Delay buffer */
                                    LVM_UINT16 size,               /* Delay size */
                                    LVM_UINT16 *pOffset,           /* Delay offset */
                                    LVM_INT16 n);

void Add2_Sat_16x16(          const LVM_INT16 *src,
                                    LVM_INT16 *dst,
                                    LVM_INT16 n );

void Add2_Sat_32x32(          const LVM_INT32  *src,
                                    LVM_INT32  *dst,
                                    LVM_INT16 n );

void Mac3s_Sat_16x16(         const LVM_INT16 *src,
                              const LVM_INT16 val,
                                    LVM_INT16 *dst,
                                    LVM_INT16 n);

void Mac3s_Sat_32x16(         const LVM_INT32  *src,
                              const LVM_INT16 val,
                                    LVM_INT32  *dst,
                                    LVM_INT16 n);

void DelayAllPass_Sat_32x16To32(    LVM_INT32  *delay,              /* Delay buffer */
                                    LVM_UINT16 size,                /* Delay size */
                                    LVM_INT16 coeff,                /* All pass filter coefficient */
                                    LVM_UINT16 DelayOffset,         /* Simple delay offset */
                                    LVM_UINT16 *pAllPassOffset,     /* All pass filter delay offset */
                                    LVM_INT32  *dst,                /* Source/destination */
                                    LVM_INT16 n);

/**********************************************************************************
    SHIFT FUNCTIONS
***********************************************************************************/

void Shift_Sat_v16xv16 (      const LVM_INT16 val,
                              const LVM_INT16 *src,
                                    LVM_INT16 *dst,
                                    LVM_INT16 n);

void Shift_Sat_v32xv32 (      const LVM_INT16 val,
                              const LVM_INT32 *src,
                                    LVM_INT32 *dst,
                                    LVM_INT16 n);

/**********************************************************************************
    AUDIO FORMAT CONVERSION FUNCTIONS
***********************************************************************************/

void MonoTo2I_16(             const LVM_INT16 *src,
                                    LVM_INT16 *dst,
                                    LVM_INT16 n);

void MonoTo2I_32(             const LVM_INT32  *src,
                                    LVM_INT32  *dst,
                                    LVM_INT16 n);

void From2iToMono_32(         const LVM_INT32  *src,
                                    LVM_INT32  *dst,
                                    LVM_INT16 n);

void MSTo2i_Sat_16x16(        const LVM_INT16 *srcM,
                              const LVM_INT16 *srcS,
                                    LVM_INT16 *dst,
                                    LVM_INT16 n );

void From2iToMS_16x16(        const LVM_INT16 *src,
                                    LVM_INT16 *dstM,
                                    LVM_INT16 *dstS,
                                    LVM_INT16 n );

void From2iToMono_16(         const LVM_INT16 *src,
                                    LVM_INT16 *dst,
                                    LVM_INT16 n);

void JoinTo2i_32x32(          const LVM_INT32  *srcL,
                              const LVM_INT32  *srcR,
                                    LVM_INT32  *dst,
                                    LVM_INT16 n );

/**********************************************************************************
    DATA TYPE CONVERSION FUNCTIONS
***********************************************************************************/

void Int16LShiftToInt32_16x32(const LVM_INT16 *src,
                                    LVM_INT32  *dst,
                                    LVM_INT16 n,
                                    LVM_INT16 shift );

void Int32RShiftToInt16_Sat_32x16(const  LVM_INT32  *src,
                                    LVM_INT16 *dst,
                                    LVM_INT16 n,
                                    LVM_INT16 shift );

#ifdef __cplusplus
}
#endif /* __cplusplus */


/**********************************************************************************/

#endif  /* _VECTOR_ARITHMETIC_H_ */

/**********************************************************************************/