Git init
[external/opencore-amr.git] / opencore / codecs_v2 / audio / gsm_amr / amr_nb / enc / src / l_extract.cpp
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
32
33
34  Filename: l_extract.cpp
35
36 ------------------------------------------------------------------------------
37 */
38
39 /*----------------------------------------------------------------------------
40 ; INCLUDES
41 ----------------------------------------------------------------------------*/
42 #include    "basic_op.h"
43
44 /*----------------------------------------------------------------------------
45 ; MACROS
46 ; [Define module specific macros here]
47 ----------------------------------------------------------------------------*/
48
49 /*----------------------------------------------------------------------------
50 ; DEFINES
51 ; [Include all pre-processor statements here. Include conditional
52 ; compile variables also.]
53 ----------------------------------------------------------------------------*/
54
55 /*----------------------------------------------------------------------------
56 ; LOCAL FUNCTION DEFINITIONS
57 ; [List function prototypes here]
58 ----------------------------------------------------------------------------*/
59
60 /*----------------------------------------------------------------------------
61 ; LOCAL VARIABLE DEFINITIONS
62 ; [Variable declaration - defined here and used outside this module]
63 ----------------------------------------------------------------------------*/
64
65
66 /*
67 ------------------------------------------------------------------------------
68  FUNCTION NAME: L_extract
69 ------------------------------------------------------------------------------
70  INPUT AND OUTPUT DEFINITIONS
71
72  Inputs:
73     L_var = 32 bit signed integer (Word32) whose value falls
74            in the range : 0x8000 0000 <= L_32 <= 0x7fff ffff.
75
76     pL_var_hi =  pointer to the most significant word of L_var (Word16).
77
78     pL_var_lo =  pointer to the least significant word of L_var shifted
79               to the left by 1 (Word16).
80
81     pOverflow = pointer to overflow (Flag)
82
83  Outputs:
84     pOverflow -> 1 if the 32 bit add operation resulted in overflow
85     pL_var_hi -> MS word of L_32.
86     pL_var_lo -> LS word of L_32 shifted left by 1.
87
88  Returns:
89     None
90
91  Global Variables Used:
92     None
93
94  Local Variables Needed:
95     None
96
97 ------------------------------------------------------------------------------
98  FUNCTION DESCRIPTION
99
100  This function extracts two 16-bit double precision format (DPF) numbers
101  from a 32-bit integer. The MS word of L_var will be stored in the location
102  pointed to by pL_var_hi and the shifted LS word of L_var will be stored in
103  the location pointed to by pL_var_lo.
104
105 ------------------------------------------------------------------------------
106  REQUIREMENTS
107
108  None
109
110 ------------------------------------------------------------------------------
111  REFERENCES
112
113  [1] L_extract() function in oper_32b.c,  UMTS GSM AMR speech codec, R99 -
114  Version 3.2.0, March 2, 2001
115
116 ------------------------------------------------------------------------------
117  PSEUDO-CODE
118
119
120 ------------------------------------------------------------------------------
121  CAUTION [optional]
122  [State any special notes, constraints or cautions for users of this function]
123
124 ------------------------------------------------------------------------------
125 */
126
127 /*----------------------------------------------------------------------------
128 ; FUNCTION CODE
129 ----------------------------------------------------------------------------*/
130 void L_Extract(Word32 L_var,
131                Word16 *pL_var_hi,
132                Word16 *pL_var_lo,
133                Flag   *pOverflow)
134 {
135
136     Word32  temp;
137
138     OSCL_UNUSED_ARG(pOverflow);
139
140     temp = (L_var >> 16);
141
142     *(pL_var_hi) = (Word16) temp;
143     *(pL_var_lo) = (Word16)((L_var >> 1) - (temp << 15));
144
145     return;
146 }