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 ****************************************************************************************/
30 ------------------------------------------------------------------------------
31 INPUT AND OUTPUT DEFINITIONS
34 hi = 16 bit signed integer (Word16) whose value falls in
35 the range : 0x8000 <= hi <= 0x7fff.
36 lo = 16 bit signed integer (Word16) whose value falls in
37 the range : 0x8000 <= lo <= 0x7fff.
40 pOverflow = 1 if overflow happens in a math function called by this function.
41 L_out = 32-bit result of (hi<<16 + lo<<1).
46 Local Stores Modified:
49 Global Stores Modified:
52 ------------------------------------------------------------------------------
55 This function composes a 32 bit integer from two 16 bit double precision
56 format (DPF) numbers hi and lo by the following operation:
57 1. Deposit hi into the 16 MS bits of the 32 bit output L_out.
58 2. Shift lo left by 1.
59 3. Add results from 1 and 2 with saturation to return the 32 bit result
62 ------------------------------------------------------------------------------
67 ------------------------------------------------------------------------------
70 [1] oper_32b.c, ETS Version 2.0.0, February 8, 1999
72 ------------------------------------------------------------------------------
75 ------------------------------------------------------------------------------
79 /*----------------------------------------------------------------------------
81 ----------------------------------------------------------------------------*/
85 /*----------------------------------------------------------------------------
87 ; Define module specific macros here
88 ----------------------------------------------------------------------------*/
90 /*----------------------------------------------------------------------------
92 ; Include all pre-processor statements here. Include conditional
93 ; compile variables also.
94 ----------------------------------------------------------------------------*/
96 /*----------------------------------------------------------------------------
97 ; LOCAL FUNCTION DEFINITIONS
98 ; Function Prototype declaration
99 ----------------------------------------------------------------------------*/
101 /*----------------------------------------------------------------------------
102 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
103 ; Variable declaration - defined here and used outside this module
104 ----------------------------------------------------------------------------*/
106 /*----------------------------------------------------------------------------
107 ; EXTERNAL FUNCTION REFERENCES
108 ; Declare functions defined elsewhere and referenced in this module
109 ----------------------------------------------------------------------------*/
111 /*----------------------------------------------------------------------------
112 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
113 ; Declare variables used in this module but defined elsewhere
114 ----------------------------------------------------------------------------*/
116 /*----------------------------------------------------------------------------
118 ----------------------------------------------------------------------------*/
120 Word32 L_Comp(Word16 hi, Word16 lo, Flag *pOverflow)
123 /*----------------------------------------------------------------------------
124 ; Define all local variables
125 ----------------------------------------------------------------------------*/
128 /*----------------------------------------------------------------------------
130 ----------------------------------------------------------------------------*/
132 L_32 = ((Word32)hi << 16);
134 temp32 = L_mac(L_32, lo, 1, pOverflow);
135 /*----------------------------------------------------------------------------
136 ; Return nothing or data or data pointer
137 ----------------------------------------------------------------------------*/
139 return (temp32); /* = hi<<16 + lo<<1 */