1 /* ------------------------------------------------------------------
2 * Copyright (C) 1998-2009 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 ****************************************************************************************/
33 ------------------------------------------------------------------------------
34 INPUT AND OUTPUT DEFINITIONS
37 var1 = 16 bit signed integer of type Word16, whose value falls
38 in the range: 0x8000 <= var1 <= 0x7fff
40 Local Stores/Buffers/Pointers Needed:
43 Global Stores/Buffers/Pointers Needed:
47 var_out = number of left shifts need to normalize var1 (Word16)
49 Pointers and Buffers Modified:
52 Local Stores Modified:
55 Global Stores Modified:
58 ------------------------------------------------------------------------------
61 This function produces the number of left shifts needed to normalize the 16
62 bit variable var1 for positive values on the interval with minimum of 0x4000
63 and maximum of 0x7fff, and for negative values on the interval with minimum
64 of 0x8000 and maximum of 0xc000. Note that when var1 is zero, the resulting
65 output var_out is set to zero.
67 ------------------------------------------------------------------------------
72 ------------------------------------------------------------------------------
75 [1] basicop2.c, ETS Version 2.0.0, February 8, 1999
77 ------------------------------------------------------------------------------
80 Word16 norm_s (Word16 var1)
90 if (var1 == (Word16) 0xffff)
100 for (var_out = 0; var1 < 0x4000; var_out++)
108 multiCounter[currCounter].norm_s++;
113 ------------------------------------------------------------------------------
117 /*----------------------------------------------------------------------------
119 ----------------------------------------------------------------------------*/
120 #include "basic_op.h"
122 /*----------------------------------------------------------------------------
124 ; Define module specific macros here
125 ----------------------------------------------------------------------------*/
127 /*----------------------------------------------------------------------------
129 ; Include all pre-processor statements here. Include conditional
130 ; compile variables also.
131 ----------------------------------------------------------------------------*/
133 /*----------------------------------------------------------------------------
134 ; LOCAL FUNCTION DEFINITIONS
135 ; Function Prototype declaration
136 ----------------------------------------------------------------------------*/
138 /*----------------------------------------------------------------------------
139 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
140 ; Variable declaration - defined here and used outside this module
141 ----------------------------------------------------------------------------*/
143 /*----------------------------------------------------------------------------
144 ; EXTERNAL FUNCTION REFERENCES
145 ; Declare functions defined elsewhere and referenced in this module
146 ----------------------------------------------------------------------------*/
148 /*----------------------------------------------------------------------------
149 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
150 ; Declare variables used in this module but defined elsewhere
151 ----------------------------------------------------------------------------*/
153 /*----------------------------------------------------------------------------
155 ----------------------------------------------------------------------------*/
156 #if !( defined(PV_ARM_V5) || defined(PV_ARM_GCC_V5) )
158 OSCL_EXPORT_REF Word16 norm_s(register Word16 var1)
160 /*----------------------------------------------------------------------------
161 ; Define all local variables
162 ----------------------------------------------------------------------------*/
164 register Word16 var_out = 0;
166 /*----------------------------------------------------------------------------
168 ----------------------------------------------------------------------------*/
172 Word16 y = var1 - (var1 < 0);
175 while (!(0x4000 & var1))
197 /*----------------------------------------------------------------------------
198 ; Return nothing or data or data pointer
199 ----------------------------------------------------------------------------*/