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: fxp_mul32_msc_evc.h
21
22------------------------------------------------------------------------------
23 REVISION HISTORY
24
25 Who:                                       Date:
26 Description:
27------------------------------------------------------------------------------
28 INCLUDE DESCRIPTION
29
30------------------------------------------------------------------------------
31*/
32
33
34#ifndef FXP_MUL32_MSC_EVC
35#define FXP_MUL32_MSC_EVC
36
37
38#ifdef __cplusplus
39extern "C"
40{
41#endif
42
43
44#include "pv_audio_type_defs.h"
45
46#if defined(PV_ARM_MSC_EVC_V4)
47
48#include "cmnintrin.h"
49
50#define preload_cache( a)
51
52    __inline  Int32 shft_lft_1(Int32 L_var1)
53    {
54        if (((L_var1 << 1) >> 1) == L_var1)
55            L_var1 <<= 1;
56        else
57            L_var1 = ((L_var1 >> 31) ^ INT32_MAX);
58
59        return L_var1;
60
61    }
62
63    __inline  Int32 fxp_mul_16_by_16bb(Int32 L_var1,  Int32 L_var2)
64    {
65        L_var2 = (L_var2 << 16) >> 16;
66        L_var1 = (L_var1 << 16) >> 16;
67
68        return (L_var1*L_var2);
69
70    }
71
72#define fxp_mul_16_by_16(a, b)  fxp_mul_16_by_16bb(  a, b)
73
74    __inline  Int32 fxp_mul_16_by_16tb(Int32 L_var1,  Int32 L_var2)
75    {
76        L_var2 = (L_var2 << 16) >> 16;
77        L_var1 =  L_var1 >> 16;
78
79        return (L_var1*L_var2);
80
81    }
82
83
84    __inline  Int32 fxp_mul_16_by_16bt(Int32 L_var1,  Int32 L_var2)
85    {
86        L_var2 = L_var2 >> 16;
87        L_var1 = (L_var1 << 16) >> 16;
88
89        return (L_var1*L_var2);
90
91    }
92
93
94    __inline  Int32 fxp_mul_16_by_16tt(Int32 L_var1,  Int32 L_var2)
95    {
96        L_var2 = L_var2 >> 16;
97        L_var1 = L_var1 >> 16;
98
99        return (L_var1*L_var2);
100
101    }
102
103    __inline  Int32 fxp_mac_16_by_16(Int16 L_var1,  Int16 L_var2, Int32 L_add)
104    {
105        return (L_add + (L_var1*L_var2));
106    }
107
108
109
110    __inline  Int32 fxp_mac_16_by_16_bb(Int16 L_var1,  Int32 L_var2, Int32 L_add)
111    {
112        L_var2 = (L_var2 << 16) >> 16;
113
114        return (L_add + (L_var1*L_var2));
115
116    }
117
118
119    __inline  Int32 fxp_mac_16_by_16_bt(Int16 L_var1,  Int32 L_var2, Int32 L_add)
120    {
121        L_var2 = L_var2 >> 16;
122
123        return (L_add + (L_var1*L_var2));
124
125    }
126
127
128    __inline  Int32 cmplx_mul32_by_16(Int32 x, const Int32 y, Int32 exp_jw)
129    {
130        Int32  rTmp0 = (exp_jw >> 16) << 16;
131        Int32  iTmp0 = exp_jw << 16;
132        Int32  z;
133
134
135        z  = _MulHigh(rTmp0, x);
136        z += _MulHigh(iTmp0, y);
137
138        return (z);
139    }
140
141
142    __inline  Int32 fxp_mul32_by_16(Int32 L_var1, const Int32 L_var2)
143    {
144        Int32  rTmp0 = L_var2 << 16;
145
146        return(_MulHigh(rTmp0, L_var1));
147    }
148
149#define fxp_mul32_by_16b( a, b)   fxp_mul32_by_16( a, b)
150
151
152    __inline  Int32 fxp_mul32_by_16t(Int32 L_var1, const Int32 L_var2)
153    {
154        Int32  rTmp0 = (Int16)(L_var2 >> 16);
155
156        return(_MulHigh((rTmp0 << 16), L_var1));
157    }
158
159
160    __inline  Int32 fxp_mac32_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
161    {
162
163        Int32  rTmp0 = (L_var2 << 16);
164
165        return(L_add + _MulHigh(rTmp0, L_var1));
166    }
167
168    __inline  int64 fxp_mac64_Q31(int64 sum, const Int32 L_var1, const Int32 L_var2)
169    {
170        sum += (int64)L_var1 * L_var2;
171        return (sum);
172    }
173
174#define fxp_mul32_Q31( a,  b)   _MulHigh( b, a)
175
176    __inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b)
177    {
178        return (L_add + _MulHigh(b, a));
179    }
180
181    __inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b)
182    {
183        return (L_sub - _MulHigh(b, a));
184    }
185
186
187    __inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b)
188    {
189        return (Int32)(((int64)(a) * b) >> 30);
190    }
191
192    __inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add)
193    {
194        return (L_add + (Int32)(((int64)(a) * b) >> 30));
195    }
196
197
198    __inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b)
199    {
200        return (Int32)(((int64)(a) * b) >> 29);
201    }
202
203    __inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add)
204    {
205        return (L_add + (Int32)(((int64)(a) * b) >> 29));
206    }
207
208    __inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub)
209    {
210        return (L_sub - (Int32)(((int64)(a) * b) >> 29));
211    }
212
213
214    __inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b)
215    {
216        return (Int32)(((int64)(a) * b) >> 28);
217    }
218
219    __inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b)
220    {
221        return (Int32)(((int64)(a) * b) >> 27);
222    }
223
224    __inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b)
225    {
226        return (Int32)(((int64)(a) * b) >> 26);
227    }
228
229    __inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b)
230    {
231        return (Int32)(((int64)(a) * b) >> 20);
232    }
233
234    __inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b)
235    {
236        return (Int32)(((int64)(a) * b) >> 15);
237    }
238
239    __inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b)
240    {
241        return (Int32)(((int64)(a) * b) >> 14);
242    }
243
244
245
246#endif
247
248
249#ifdef __cplusplus
250}
251#endif
252
253
254#endif   /*  FXP_MUL32  */
255