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 Portions of this file are derived from the following 3GPP standard:
20
21 3GPP TS 26.073
22 ANSI-C code for the Adaptive Multi-Rate (AMR) speech codec
23 Available from http://www.3gpp.org
24
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 ****************************************************************************************/
29 /*
30 ------------------------------------------------------------------------------
31 INPUT AND OUTPUT DEFINITIONS
32
33 Inputs:
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.
38
39 Outputs:
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).
42
43 Returns:
44 None
45
46 Local Stores Modified:
47 None
48
49 Global Stores Modified:
50 None
51
52 ------------------------------------------------------------------------------
53 FUNCTION DESCRIPTION
54
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
60 L_out.
61
62 ------------------------------------------------------------------------------
63 REQUIREMENTS
64
65 None
66
67 ------------------------------------------------------------------------------
68 REFERENCES
69
70 [1] oper_32b.c, ETS Version 2.0.0, February 8, 1999
71
72 ------------------------------------------------------------------------------
73 PSEUDO-CODE
74
75 ------------------------------------------------------------------------------
76 RESOURCES USED
77 When the code is written for a specific target processor the
78 the resources used should be documented below.
79
80 STACK USAGE: [stack count for this module] + [variable to represent
81 stack usage for each subroutine called]
82
83 where: [stack usage variable] = stack usage for [subroutine
84 name] (see [filename].ext)
85
86 DATA MEMORY USED: x words
87
88 PROGRAM MEMORY USED: x words
89
90 CLOCK CYCLES: [cycle count equation for this module] + [variable
91 used to represent cycle count for each subroutine
92 called]
93
94 where: [cycle count variable] = cycle count for [subroutine
95 name] (see [filename].ext)
96
97 ------------------------------------------------------------------------------
98 */
99
100
101 /*----------------------------------------------------------------------------
102 ; INCLUDES
103 ----------------------------------------------------------------------------*/
104 #include "typedef.h"
105 #include "l_comp.h"
106 #include "basic_op.h"
107 /*----------------------------------------------------------------------------
108 ; MACROS
109 ; Define module specific macros here
110 ----------------------------------------------------------------------------*/
111
112 /*----------------------------------------------------------------------------
113 ; DEFINES
114 ; Include all pre-processor statements here. Include conditional
115 ; compile variables also.
116 ----------------------------------------------------------------------------*/
117
118 /*----------------------------------------------------------------------------
119 ; LOCAL FUNCTION DEFINITIONS
120 ; Function Prototype declaration
121 ----------------------------------------------------------------------------*/
122
123 /*----------------------------------------------------------------------------
124 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
125 ; Variable declaration - defined here and used outside this module
126 ----------------------------------------------------------------------------*/
127
128 /*----------------------------------------------------------------------------
129 ; EXTERNAL FUNCTION REFERENCES
130 ; Declare functions defined elsewhere and referenced in this module
131 ----------------------------------------------------------------------------*/
132
133 /*----------------------------------------------------------------------------
134 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
135 ; Declare variables used in this module but defined elsewhere
136 ----------------------------------------------------------------------------*/
137
138 /*----------------------------------------------------------------------------
139 ; FUNCTION CODE
140 ----------------------------------------------------------------------------*/
141
L_Comp(Word16 hi,Word16 lo,Flag * pOverflow)142 Word32 L_Comp(Word16 hi, Word16 lo, Flag *pOverflow)
143 {
144
145 /*----------------------------------------------------------------------------
146 ; Define all local variables
147 ----------------------------------------------------------------------------*/
148 Word32 L_32;
149 Word32 temp32;
150 /*----------------------------------------------------------------------------
151 ; Function body here
152 ----------------------------------------------------------------------------*/
153
154 L_32 = L_deposit_h(hi);
155
156 temp32 = L_mac(L_32, lo, 1, pOverflow);
157 /*----------------------------------------------------------------------------
158 ; Return nothing or data or data pointer
159 ----------------------------------------------------------------------------*/
160
161 return (temp32); /* = hi<<16 + lo<<1 */
162 }
163