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 #ifdef BUILD_FLOAT 33 void LoadConst_Float( const LVM_FLOAT val, 34 LVM_FLOAT *dst, 35 LVM_INT16 n ); 36 #else 37 void LoadConst_16( const LVM_INT16 val, 38 LVM_INT16 *dst, 39 LVM_INT16 n ); 40 41 void LoadConst_32( const LVM_INT32 val, 42 LVM_INT32 *dst, 43 LVM_INT16 n ); 44 #endif 45 46 #ifdef BUILD_FLOAT 47 void Copy_Float( const LVM_FLOAT *src, 48 LVM_FLOAT *dst, 49 LVM_INT16 n ); 50 #ifdef SUPPORT_MC 51 void Copy_Float_Mc_Stereo( const LVM_FLOAT *src, 52 LVM_FLOAT *dst, 53 LVM_INT16 NrFrames, 54 LVM_INT32 NrChannels); 55 void Copy_Float_Stereo_Mc( const LVM_FLOAT *src, 56 LVM_FLOAT *dst, 57 LVM_INT16 NrFrames, 58 LVM_INT32 NrChannels); 59 #endif 60 #else 61 void Copy_16( const LVM_INT16 *src, 62 LVM_INT16 *dst, 63 LVM_INT16 n ); 64 #endif 65 66 /********************************************************************************* 67 * note: In Mult3s_16x16() saturation of result is not taken care when * 68 * overflow occurs. * 69 * For example when *src = 0x8000, val = *0x8000 * 70 * The function gives the output as 0x8000 instead of 0x7fff * 71 * This is the only case which will give wrong result. * 72 * For more information refer to Vector_Arithmetic.doc in /doc folder * 73 *********************************************************************************/ 74 #ifdef BUILD_FLOAT 75 void Mult3s_Float( const LVM_FLOAT *src, 76 const LVM_FLOAT val, 77 LVM_FLOAT *dst, 78 LVM_INT16 n); 79 #else 80 void Mult3s_16x16( const LVM_INT16 *src, 81 const LVM_INT16 val, 82 LVM_INT16 *dst, 83 LVM_INT16 n); 84 #endif 85 86 /********************************************************************************* 87 * note: In Mult3s_32x16() saturation of result is not taken care when * 88 * overflow occurs. * 89 * For example when *src = 0x8000000, val = *0x8000 * 90 * The function gives the output as 0x8000000 instead of 0x7fffffff * 91 * This is the only extreme condition which is giving unexpected result * 92 * For more information refer to Vector_Arithmetic.doc in /doc folder * 93 *********************************************************************************/ 94 void Mult3s_32x16( const LVM_INT32 *src, 95 const LVM_INT16 val, 96 LVM_INT32 *dst, 97 LVM_INT16 n); 98 #ifdef BUILD_FLOAT 99 void DelayMix_Float(const LVM_FLOAT *src, /* Source 1, to be delayed */ 100 LVM_FLOAT *delay, /* Delay buffer */ 101 LVM_INT16 size, /* Delay size */ 102 LVM_FLOAT *dst, /* Source/destination */ 103 LVM_INT16 *pOffset, /* Delay offset */ 104 LVM_INT16 n) ; /* Number of stereo samples */ 105 #else 106 void DelayMix_16x16( const LVM_INT16 *src, 107 LVM_INT16 *delay, 108 LVM_INT16 size, 109 LVM_INT16 *dst, 110 LVM_INT16 *pOffset, 111 LVM_INT16 n); 112 #endif 113 void DelayWrite_32( const LVM_INT32 *src, /* Source 1, to be delayed */ 114 LVM_INT32 *delay, /* Delay buffer */ 115 LVM_UINT16 size, /* Delay size */ 116 LVM_UINT16 *pOffset, /* Delay offset */ 117 LVM_INT16 n); 118 #ifdef BUILD_FLOAT 119 void Add2_Sat_Float( const LVM_FLOAT *src, 120 LVM_FLOAT *dst, 121 LVM_INT16 n ); 122 #else 123 void Add2_Sat_16x16( const LVM_INT16 *src, 124 LVM_INT16 *dst, 125 LVM_INT16 n ); 126 127 void Add2_Sat_32x32( const LVM_INT32 *src, 128 LVM_INT32 *dst, 129 LVM_INT16 n ); 130 #endif 131 #ifdef BUILD_FLOAT 132 void Mac3s_Sat_Float( const LVM_FLOAT *src, 133 const LVM_FLOAT val, 134 LVM_FLOAT *dst, 135 LVM_INT16 n); 136 #else 137 void Mac3s_Sat_16x16( const LVM_INT16 *src, 138 const LVM_INT16 val, 139 LVM_INT16 *dst, 140 LVM_INT16 n); 141 142 void Mac3s_Sat_32x16( const LVM_INT32 *src, 143 const LVM_INT16 val, 144 LVM_INT32 *dst, 145 LVM_INT16 n); 146 #endif 147 void DelayAllPass_Sat_32x16To32( LVM_INT32 *delay, /* Delay buffer */ 148 LVM_UINT16 size, /* Delay size */ 149 LVM_INT16 coeff, /* All pass filter coefficient */ 150 LVM_UINT16 DelayOffset, /* Simple delay offset */ 151 LVM_UINT16 *pAllPassOffset, /* All pass filter delay offset */ 152 LVM_INT32 *dst, /* Source/destination */ 153 LVM_INT16 n); 154 155 /********************************************************************************** 156 SHIFT FUNCTIONS 157 ***********************************************************************************/ 158 #ifdef BUILD_FLOAT 159 void Shift_Sat_Float (const LVM_INT16 val, 160 const LVM_FLOAT *src, 161 LVM_FLOAT *dst, 162 LVM_INT16 n); 163 #else 164 void Shift_Sat_v16xv16 ( const LVM_INT16 val, 165 const LVM_INT16 *src, 166 LVM_INT16 *dst, 167 LVM_INT16 n); 168 169 void Shift_Sat_v32xv32 ( const LVM_INT16 val, 170 const LVM_INT32 *src, 171 LVM_INT32 *dst, 172 LVM_INT16 n); 173 #endif 174 /********************************************************************************** 175 AUDIO FORMAT CONVERSION FUNCTIONS 176 ***********************************************************************************/ 177 #ifdef BUILD_FLOAT 178 void MonoTo2I_Float( const LVM_FLOAT *src, 179 LVM_FLOAT *dst, 180 LVM_INT16 n); 181 #else 182 void MonoTo2I_16( const LVM_INT16 *src, 183 LVM_INT16 *dst, 184 LVM_INT16 n); 185 186 void MonoTo2I_32( const LVM_INT32 *src, 187 LVM_INT32 *dst, 188 LVM_INT16 n); 189 #endif 190 #ifdef BUILD_FLOAT 191 void From2iToMono_Float( const LVM_FLOAT *src, 192 LVM_FLOAT *dst, 193 LVM_INT16 n); 194 #ifdef SUPPORT_MC 195 void FromMcToMono_Float(const LVM_FLOAT *src, 196 LVM_FLOAT *dst, 197 LVM_INT16 NrFrames, 198 LVM_INT16 NrChannels); 199 #endif 200 #else 201 void From2iToMono_32( const LVM_INT32 *src, 202 LVM_INT32 *dst, 203 LVM_INT16 n); 204 #endif 205 #ifdef BUILD_FLOAT 206 void MSTo2i_Sat_Float( const LVM_FLOAT *srcM, 207 const LVM_FLOAT *srcS, 208 LVM_FLOAT *dst, 209 LVM_INT16 n ); 210 #else 211 void MSTo2i_Sat_16x16( const LVM_INT16 *srcM, 212 const LVM_INT16 *srcS, 213 LVM_INT16 *dst, 214 LVM_INT16 n ); 215 #endif 216 #ifdef BUILD_FLOAT 217 void From2iToMS_Float( const LVM_FLOAT *src, 218 LVM_FLOAT *dstM, 219 LVM_FLOAT *dstS, 220 LVM_INT16 n ); 221 #else 222 void From2iToMS_16x16( const LVM_INT16 *src, 223 LVM_INT16 *dstM, 224 LVM_INT16 *dstS, 225 LVM_INT16 n ); 226 #endif 227 #ifdef BUILD_FLOAT 228 void JoinTo2i_Float( const LVM_FLOAT *srcL, 229 const LVM_FLOAT *srcR, 230 LVM_FLOAT *dst, 231 LVM_INT16 n ); 232 #else 233 void From2iToMono_16( const LVM_INT16 *src, 234 LVM_INT16 *dst, 235 LVM_INT16 n); 236 void JoinTo2i_32x32( const LVM_INT32 *srcL, 237 const LVM_INT32 *srcR, 238 LVM_INT32 *dst, 239 LVM_INT16 n ); 240 #endif 241 242 /********************************************************************************** 243 DATA TYPE CONVERSION FUNCTIONS 244 ***********************************************************************************/ 245 246 void Int16LShiftToInt32_16x32(const LVM_INT16 *src, 247 LVM_INT32 *dst, 248 LVM_INT16 n, 249 LVM_INT16 shift ); 250 251 void Int32RShiftToInt16_Sat_32x16(const LVM_INT32 *src, 252 LVM_INT16 *dst, 253 LVM_INT16 n, 254 LVM_INT16 shift ); 255 256 #ifdef __cplusplus 257 } 258 #endif /* __cplusplus */ 259 260 261 /**********************************************************************************/ 262 263 #endif /* _VECTOR_ARITHMETIC_H_ */ 264 265 /**********************************************************************************/ 266