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