1 /* ------------------------------------------------------------------
2 * Copyright (C) 1998-2010 PacketVideo
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
14 * See the License for the specific language governing permissions
15 * and limitations under the License.
16 * -------------------------------------------------------------------
18 /****************************************************************************************
19 Portions of this file are derived from the following 3GPP standard:
22 ANSI-C code for the Adaptive Multi-Rate (AMR) speech codec
23 Available from http://www.3gpp.org
25 (C) 2004, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC)
26 Permission to distribute, modify and use this file under the standard license
27 terms listed above has been obtained from the copyright holder.
28 ****************************************************************************************/
32 ------------------------------------------------------------------------------
33 INPUT AND OUTPUT DEFINITIONS
36 L_var1 = 32 bit long signed integer (Word32) whose value falls
37 in the range : 0x8000 0000 <= var1 <= 0x7fff ffff.
39 Local Stores/Buffers/Pointers Needed:
42 Global Stores/Buffers/Pointers Needed:
46 var_out = number of left shifts need to normalize input (Word16)
48 Pointers and Buffers Modified:
51 Local Stores Modified:
54 Global Stores Modified:
57 ------------------------------------------------------------------------------
60 This function produces the number of left shifts needed to normalize the 32
61 bit variable L_var1 for positive values on the interval with minimum of
62 0x40000000 and maximum of 0x7fffffff, and for negative values on the interval
63 with minimum of 0x80000000 and maximum of 0xc0000000. Note that when L_var1
64 is equal to zero, the output var_out is set to zero.
66 ------------------------------------------------------------------------------
71 ------------------------------------------------------------------------------
74 [1] basicop2.c, ETS Version 2.0.0, February 8, 1999
76 ------------------------------------------------------------------------------
79 Word16 norm_l (Word32 L_var1)
89 if (L_var1 == (Word32) 0xffffffffL)
99 for (var_out = 0; L_var1 < (Word32) 0x40000000L; var_out++)
107 multiCounter[currCounter].norm_l++;
112 ------------------------------------------------------------------------------
116 /*----------------------------------------------------------------------------
118 ----------------------------------------------------------------------------*/
119 #include "basic_op.h"
121 /*----------------------------------------------------------------------------
123 ; Define module specific macros here
124 ----------------------------------------------------------------------------*/
126 /*----------------------------------------------------------------------------
128 ; Include all pre-processor statements here. Include conditional
129 ; compile variables also.
130 ----------------------------------------------------------------------------*/
132 /*----------------------------------------------------------------------------
133 ; LOCAL FUNCTION DEFINITIONS
134 ; Function Prototype declaration
135 ----------------------------------------------------------------------------*/
137 /*----------------------------------------------------------------------------
138 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
139 ; Variable declaration - defined here and used outside this module
140 ----------------------------------------------------------------------------*/
142 /*----------------------------------------------------------------------------
143 ; EXTERNAL FUNCTION REFERENCES
144 ; Declare functions defined elsewhere and referenced in this module
145 ----------------------------------------------------------------------------*/
147 /*----------------------------------------------------------------------------
148 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
149 ; Declare variables used in this module but defined elsewhere
150 ----------------------------------------------------------------------------*/
152 /*----------------------------------------------------------------------------
154 ----------------------------------------------------------------------------*/
155 #if !((PV_CPU_ARCH_VERSION >=5) && ((PV_COMPILER == EPV_ARM_GNUC) || (PV_COMPILER == EPV_ARM_RVCT)))
156 OSCL_EXPORT_REF Word16 norm_l(register Word32 L_var1)
158 /*----------------------------------------------------------------------------
159 ; Define all local variables
160 ----------------------------------------------------------------------------*/
161 register Word16 var_out = 0;
163 /*----------------------------------------------------------------------------
165 ----------------------------------------------------------------------------*/
170 Word32 y = L_var1 - (L_var1 < 0);
171 L_var1 = y ^(y >> 31);
174 while (!(0x40000000L & L_var1))
177 if ((0x20000000L & L_var1))
182 if ((0x10000000L & L_var1))
187 if ((0x08000000L & L_var1))
196 /*----------------------------------------------------------------------------
197 ; Return nothing or data or data pointer
198 ----------------------------------------------------------------------------*/