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 ****************************************************************************************/
32 ------------------------------------------------------------------------------
35 /*----------------------------------------------------------------------------
37 ----------------------------------------------------------------------------*/
40 #include "log2_norm.h"
42 /*----------------------------------------------------------------------------
44 ; [Define module specific macros here]
45 ----------------------------------------------------------------------------*/
47 /*----------------------------------------------------------------------------
49 ; [Include all pre-processor statements here. Include conditional
50 ; compile variables also.]
51 ----------------------------------------------------------------------------*/
53 /*----------------------------------------------------------------------------
54 ; LOCAL FUNCTION DEFINITIONS
55 ; [List function prototypes here]
56 ----------------------------------------------------------------------------*/
58 /*----------------------------------------------------------------------------
59 ; LOCAL VARIABLE DEFINITIONS
60 ; [Variable declaration - defined here and used outside this module]
61 ----------------------------------------------------------------------------*/
65 ------------------------------------------------------------------------------
67 ------------------------------------------------------------------------------
68 INPUT AND OUTPUT DEFINITIONS
71 L_x = input value of type Word32
72 pExponent = pointer to the integer part of Log2 of type Word16 whose
73 valid range is: 0 <= value <= 30
74 pFraction = pointer to the fractional part of Log2 of type Word16
75 whose valid range is: 0 <= value < 1
76 pOverflow = pointer to overflow flag
80 pExponent -> integer part of the newly calculated Log2
81 pFraction -> fractional part of the newly calculated Log2
82 pOverflow -> 1 if the log2() operation resulted in saturation
87 Global Variables Used:
90 Local Variables Needed:
93 ------------------------------------------------------------------------------
96 This function computes logarithm (base2) of the input L_x, where L_x is
97 positive. If L_x is negative or zero, the result is 0.
99 This function first normalizes the input L_x and calls the function Log2_norm
100 to calculate the logarithm.
102 ------------------------------------------------------------------------------
107 ------------------------------------------------------------------------------
110 [1] log2.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
112 ------------------------------------------------------------------------------
116 ------------------------------------------------------------------------------
118 [State any special notes, constraints or cautions for users of this function]
120 ------------------------------------------------------------------------------
123 /*----------------------------------------------------------------------------
125 ----------------------------------------------------------------------------*/
126 OSCL_EXPORT_REF void Log2(
127 Word32 L_x, /* (i) : input value */
128 Word16 *pExponent, /* (o) : Integer part of Log2. (range: 0<=val<=30)*/
129 Word16 *pFraction, /* (o) : Fractional part of Log2. (range: 0<=val<1) */
130 Flag *pOverflow /* (i/o) : overflow flag */
135 OSCL_UNUSED_ARG(pOverflow);
139 Log2_norm(result, exp, pExponent, pFraction);