Home | History | Annotate | Download | only in aacdec
      1 /* ------------------------------------------------------------------
      2  * Copyright (C) 1998-2009 PacketVideo
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
     13  * express or implied.
     14  * See the License for the specific language governing permissions
     15  * and limitations under the License.
     16  * -------------------------------------------------------------------
     17  */
     18 /*
     19 
     20  Pathname: ./c/include/fxp_mul32_c_equivalent.h
     21 
     22 ------------------------------------------------------------------------------
     23  REVISION HISTORY
     24 
     25  Who:                                       Date:
     26  Description:
     27 ------------------------------------------------------------------------------
     28  INCLUDE DESCRIPTION
     29 
     30 ------------------------------------------------------------------------------
     31 */
     32 
     33 #ifndef FXP_MUL32_C_EQUIVALENT
     34 #define FXP_MUL32_C_EQUIVALENT
     35 
     36 
     37 #ifdef __cplusplus
     38 extern "C"
     39 {
     40 #endif
     41 
     42 
     43 #include "pv_audio_type_defs.h"
     44 
     45 
     46 #if defined(C_EQUIVALENT)
     47 
     48 #define preload_cache( a)
     49 
     50     __inline  Int32 shft_lft_1(Int32 L_var1)
     51     {
     52         if (((L_var1 << 1) >> 1) == L_var1)
     53             L_var1 <<= 1;
     54         else
     55             L_var1 = ((L_var1 >> 31) ^ INT32_MAX);
     56 
     57         return (L_var1);
     58 
     59     }
     60 
     61 
     62     __inline  Int32 fxp_mul_16_by_16bb(Int32 L_var1,  Int32 L_var2)
     63     {
     64         L_var2 = (L_var2 << 16) >> 16;
     65         L_var1 = (L_var1 << 16) >> 16;
     66 
     67         L_var1 *= L_var2;
     68 
     69         return L_var1;
     70 
     71     }
     72 
     73 
     74 #define fxp_mul_16_by_16(a, b)  fxp_mul_16_by_16bb(  a, b)
     75 
     76 
     77     __inline  Int32 fxp_mul_16_by_16tb(Int32 L_var1,  Int32 L_var2)
     78     {
     79         L_var2 = (L_var2 << 16) >> 16;
     80         L_var1 =  L_var1 >> 16;
     81 
     82         L_var1 *= L_var2;
     83 
     84         return L_var1;
     85 
     86     }
     87 
     88 
     89     __inline  Int32 fxp_mul_16_by_16bt(Int32 L_var1,  Int32 L_var2)
     90     {
     91         L_var2 = L_var2 >> 16;
     92         L_var1 = (L_var1 << 16) >> 16;
     93 
     94         L_var1 *= L_var2;
     95 
     96         return L_var1;
     97 
     98     }
     99 
    100 
    101     __inline  Int32 fxp_mul_16_by_16tt(Int32 L_var1,  Int32 L_var2)
    102     {
    103         L_var2 = L_var2 >> 16;
    104         L_var1 = L_var1 >> 16;
    105 
    106         L_var1 *= L_var2;
    107 
    108         return L_var1;
    109 
    110     }
    111 
    112     __inline  Int32 fxp_mac_16_by_16(Int16 L_var1,  Int16 L_var2, Int32 L_add)
    113     {
    114 
    115         L_add += L_var1 * L_var2;
    116 
    117         return L_add;
    118 
    119     }
    120 
    121 
    122 
    123 
    124 
    125     __inline  Int32 fxp_mac_16_by_16_bb(Int16 L_var1,  Int32 L_var2, Int32 L_add)
    126     {
    127         L_var2 = (L_var2 << 16) >> 16;
    128 
    129         L_add += L_var1 * L_var2;
    130 
    131         return L_add;
    132 
    133     }
    134 
    135 
    136     __inline  Int32 fxp_mac_16_by_16_bt(Int16 L_var1,  Int32 L_var2, Int32 L_add)
    137     {
    138         L_var2 = L_var2 >> 16;
    139 
    140         L_add += L_var1 * L_var2;
    141 
    142         return L_add;
    143 
    144     }
    145 
    146 
    147 
    148 
    149 
    150     __inline  Int32 cmplx_mul32_by_16(Int32 x, const Int32 y, Int32 exp_jw)
    151     {
    152         Int32  rTmp0 = (Int16)(exp_jw >> 16);
    153         Int32  iTmp0 = exp_jw;
    154         Int32  z;
    155 
    156         z  = (Int32)(((int64_t)x * (rTmp0 << 16)) >> 32);
    157         z += (Int32)(((int64_t)y * (iTmp0 << 16)) >> 32);
    158 
    159         return (z);
    160     }
    161 
    162 
    163     __inline  Int32 fxp_mul32_by_16(Int32 L_var1, const Int32 L_var2)
    164     {
    165         Int32  z;
    166 
    167         z = (Int32)(((int64_t) L_var1 * (L_var2 << 16)) >> 32);
    168         return(z);
    169     }
    170 
    171 
    172 #define fxp_mul32_by_16b( a, b)   fxp_mul32_by_16( a, b)
    173 
    174 
    175     __inline  Int32 fxp_mul32_by_16t(Int32 L_var1, const Int32 L_var2)
    176     {
    177         Int32  rTmp0 = (Int16)(L_var2 >> 16);
    178         Int32  z;
    179 
    180         z = (Int32)(((int64_t) L_var1 * (rTmp0 << 16)) >> 32);
    181 
    182         return(z);
    183     }
    184 
    185 
    186     __inline  Int32 fxp_mac32_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
    187     {
    188         Int32  rTmp0 = L_var2 << 16;
    189 
    190         L_add += (Int32)(((int64_t) L_var1 * rTmp0) >> 32);
    191 
    192         return(L_add);
    193     }
    194 
    195     __inline  int64_t fxp_mac64_Q31(int64_t sum, const Int32 L_var1, const Int32 L_var2)
    196     {
    197         sum += (int64_t)L_var1 * L_var2;
    198         return (sum);
    199     }
    200 
    201     __inline Int32 fxp_mul32_Q31(const Int32 a, const Int32 b)
    202     {
    203         return (Int32)(((int64_t)(a) * b) >> 32);
    204     }
    205 
    206     __inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b)
    207     {
    208         return (L_add + (Int32)(((int64_t)(a) * b) >> 32));
    209     }
    210 
    211     __inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b)
    212     {
    213         return (L_sub - (Int32)(((int64_t)(a) * b) >> 32));
    214     }
    215 
    216 
    217     __inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b)
    218     {
    219         return (Int32)(((int64_t)(a) * b) >> 30);
    220     }
    221 
    222     __inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add)
    223     {
    224         return (L_add + (Int32)(((int64_t)(a) * b) >> 30));
    225     }
    226 
    227 
    228     __inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b)
    229     {
    230         return (Int32)(((int64_t)(a) * b) >> 29);
    231     }
    232 
    233     __inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add)
    234     {
    235         return (L_add + (Int32)(((int64_t)(a) * b) >> 29));
    236     }
    237 
    238     __inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub)
    239     {
    240         return (L_sub - (Int32)(((int64_t)(a) * b) >> 29));
    241     }
    242 
    243 
    244     __inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b)
    245     {
    246         return (Int32)(((int64_t)(a) * b) >> 28);
    247     }
    248 
    249     __inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b)
    250     {
    251         return (Int32)(((int64_t)(a) * b) >> 27);
    252     }
    253 
    254     __inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b)
    255     {
    256         return (Int32)(((int64_t)(a) * b) >> 26);
    257     }
    258 
    259     __inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b)
    260     {
    261         return (Int32)(((int64_t)(a) * b) >> 20);
    262     }
    263 
    264     __inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b)
    265     {
    266         return (Int32)(((int64_t)(a) * b) >> 15);
    267     }
    268 
    269     __inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b)
    270     {
    271         return (Int32)(((int64_t)(a) * b) >> 14);
    272     }
    273 
    274 
    275 
    276 #endif
    277 
    278 
    279 #ifdef __cplusplus
    280 }
    281 #endif
    282 
    283 
    284 #endif   /*  FXP_MUL32  */
    285 
    286