• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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    PacketVideo Corp.
21    MP3 Decoder Library
22 
23    Pathname: ./cpp/include/pv_mp3dec_fxd_op_arm.h
24 
25      Date: 08/20/2007
26 
27 ------------------------------------------------------------------------------
28  REVISION HISTORY
29 
30  Description:
31 ------------------------------------------------------------------------------
32  INCLUDE DESCRIPTION
33 
34  This file select the associated fixed point functions with the OS/ARCH.
35 
36 
37 ------------------------------------------------------------------------------
38 */
39 
40 #ifndef PV_MP3DEC_FXD_OP_ARM
41 #define PV_MP3DEC_FXD_OP_ARM
42 
43 
44 #ifdef __cplusplus
45 extern "C"
46 {
47 #endif
48 
49 #include "pvmp3_audio_type_defs.h"
50 
51 
52 #if (defined(PV_ARM_V5)||defined(PV_ARM_V4))
53 
54 
fxp_mul32_Q30(const Int32 L_var1,const Int32 L_var2)55     __inline  Int32 fxp_mul32_Q30(const Int32 L_var1, const Int32 L_var2)
56     {
57 
58         Int32 result64_hi;
59         Int32 result64_lo;
60         __asm
61         {
62             smull result64_lo, result64_hi, L_var2, L_var1
63             mov   result64_lo, result64_lo, lsr #30
64             add   result64_hi, result64_lo, result64_hi, asl  #2
65         }
66         return (result64_hi);
67     }
68 
fxp_mac32_Q30(const Int32 L_var1,const Int32 L_var2,Int32 L_add)69     __inline  Int32 fxp_mac32_Q30(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
70     {
71         Int32 result64_hi;
72         Int32 result64_lo;
73         __asm
74         {
75             smull result64_lo, result64_hi, L_var2, L_var1
76             add L_add, L_add, result64_hi, asl  #2
77             add L_add, L_add, result64_lo, lsr  #30
78         }
79         return (L_add);
80     }
81 
82 
83 
84 #define Qfmt_31(a)   (Int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F))
85 
86 
87 
fxp_mul32_Q32(Int32 L_var1,const Int32 L_var2)88     __inline  Int32 fxp_mul32_Q32(Int32 L_var1, const Int32 L_var2)
89     {
90         Int32 result64_hi;
91         __asm
92         {
93             smull L_var1, result64_hi, L_var2, L_var1
94         }
95         return (result64_hi);
96     }
97 
fxp_mul32_Q28(const Int32 L_var1,const Int32 L_var2)98     __inline  Int32 fxp_mul32_Q28(const Int32 L_var1, const Int32 L_var2)
99     {
100 
101         Int32 result64_hi;
102         Int32 result64_lo;
103         __asm
104         {
105             smull result64_lo, result64_hi, L_var2, L_var1
106             mov   result64_lo, result64_lo, lsr #28
107             add   result64_hi, result64_lo, result64_hi, asl  #4
108         }
109         return (result64_hi);
110     }
111 
112 
fxp_mul32_Q27(const Int32 L_var1,const Int32 L_var2)113     __inline  Int32 fxp_mul32_Q27(const Int32 L_var1, const Int32 L_var2)
114     {
115 
116         Int32 result64_hi;
117         Int32 result64_lo;
118         __asm
119         {
120             smull result64_lo, result64_hi, L_var2, L_var1
121             mov   result64_lo, result64_lo, lsr #27
122             add   result64_hi, result64_lo, result64_hi, asl  #5
123         }
124         return (result64_hi);
125     }
126 
127 
fxp_mul32_Q26(Int32 L_var1,Int32 L_var2)128     __inline  Int32 fxp_mul32_Q26(Int32 L_var1,  Int32 L_var2)
129     {
130 
131         Int32 result64_hi;
132         Int32 result64_lo;
133         __asm
134         {
135             smull result64_lo, result64_hi, L_var2, L_var1
136             mov   result64_lo, result64_lo, lsr #26
137             add   result64_hi, result64_lo, result64_hi, asl  #6
138         }
139         return (result64_hi);
140     }
141 
142 
143 
fxp_mac32_Q32(Int32 L_add,Int32 L_var1,const Int32 L_var2)144     __inline  Int32 fxp_mac32_Q32(Int32 L_add,  Int32 L_var1, const Int32 L_var2)
145     {
146         __asm
147         {
148             smlal L_var1, L_add, L_var2, L_var1
149         }
150         return L_add;
151     }
152 
153 
fxp_msb32_Q32(Int32 L_sub,Int32 L_var1,Int32 L_var2)154     __inline  Int32 fxp_msb32_Q32(Int32 L_sub,  Int32 L_var1, Int32 L_var2)
155     {
156 
157         __asm
158         {
159             smull  L_var2, L_var1, L_var2, L_var1
160             sub  L_sub, L_sub, L_var1
161         }
162         return L_sub;
163     }
164 
165 
fxp_mul32_Q29(const Int32 L_var1,const Int32 L_var2)166     __inline  Int32 fxp_mul32_Q29(const Int32 L_var1,  const Int32 L_var2)
167     {
168         Int32 result64_hi;
169         Int32 result64_lo;
170         __asm
171         {
172             smull result64_lo, result64_hi, L_var2, L_var1
173             mov   result64_lo, result64_lo, lsr #29
174             add   result64_hi, result64_lo, result64_hi, asl  #3
175         }
176         return (result64_hi);
177     }
178 
179 
pv_abs(int32 a)180     __inline int32 pv_abs(int32 a)
181     {
182         Int32 b;
183         /*
184             b = a - (a<0);
185             a = b ^ sign(b)
186          */
187         __asm
188         {
189             sub  b, a, a, lsr #31
190             eor  a, b, b, asr #31
191         }
192         return (a);
193     }
194 
195 #endif
196 
197 #ifdef __cplusplus
198 }
199 #endif
200 
201 
202 #endif   /*  PV_MP3DEC_FXD_OP_ARM  */
203 
204