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 lsf -- Pointer to Word16 -- LSF vector
40 wf -- Pointer to Word16 -- square of weighting factors
41 pOverflow -- Pointer to type Flag -- Flag set when overflow occurs
46 Global Variables Used:
49 Local Variables Needed:
52 ------------------------------------------------------------------------------
55 Compute LSF weighting factors
57 d[i] = lsf[i+1] - lsf[i-1]
59 The weighting factors are approximated by two line segment
61 First segment passes by the following 2 points:
63 d[i] = 0Hz wf[i] = 3.347
64 d[i] = 450Hz wf[i] = 1.8
66 Second segment passes by the following 2 points:
68 d[i] = 450Hz wf[i] = 1.8
69 d[i] = 1500Hz wf[i] = 1.0
72 wf[i] = 3.347 - ( (3.347-1.8) / (450-0)) * d[i]
74 wf[i] = 1.8 - ( (1.8-1.0) / (1500-450)) * (d[i] - 450)
78 wf[i] = 3427 - (28160*d[i])>>15
80 wf[i] = 1843 - (6242*(d[i]-1843))>>15
82 ------------------------------------------------------------------------------
87 ------------------------------------------------------------------------------
90 lsfwt.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
92 ------------------------------------------------------------------------------
97 ------------------------------------------------------------------------------
101 /*----------------------------------------------------------------------------
103 ----------------------------------------------------------------------------*/
107 /*----------------------------------------------------------------------------
109 ; Define module specific macros here
110 ----------------------------------------------------------------------------*/
113 /*----------------------------------------------------------------------------
115 ; Include all pre-processor statements here. Include conditional
116 ; compile variables also.
117 ----------------------------------------------------------------------------*/
120 /*----------------------------------------------------------------------------
121 ; LOCAL FUNCTION DEFINITIONS
122 ; Function Prototype declaration
123 ----------------------------------------------------------------------------*/
126 /*----------------------------------------------------------------------------
127 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
128 ; Variable declaration - defined here and used outside this module
129 ----------------------------------------------------------------------------*/
131 /*----------------------------------------------------------------------------
132 ; EXTERNAL FUNCTION REFERENCES
133 ; Declare functions defined elsewhere and referenced in this module
134 ----------------------------------------------------------------------------*/
136 /*----------------------------------------------------------------------------
137 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
138 ; Declare variables used in this module but defined elsewhere
139 ----------------------------------------------------------------------------*/
142 /*----------------------------------------------------------------------------
144 ----------------------------------------------------------------------------*/
147 Word16 *lsf, /* input : LSF vector */
148 Word16 *wf, /* output: square of weighting factors */
156 Word16 *p_lsf = &lsf[0];
157 Word16 *p_lsf_2 = &lsf[1];
159 OSCL_UNUSED_ARG(pOverflow);
161 /* wf[0] = lsf[1] - 0 */
162 *(p_wf++) = *(p_lsf_2++);
164 for (i = 4; i != 0 ; i--)
166 *(p_wf++) = *(p_lsf_2++) - *(p_lsf++);
167 *(p_wf++) = *(p_lsf_2++) - *(p_lsf++);
170 * wf[9] = 4000 - lsf[8]
172 *(p_wf) = 16384 - *(p_lsf);
176 for (i = 10; i != 0; i--)
180 * 1843 == 450 Hz (Q15 considering 7FFF = 8000 Hz)
183 temp = wgt_fct - 1843;
187 temp = (Word16)(((Word32)temp * 6242) >> 15);
188 wgt_fct = 1843 - temp;
192 temp = (Word16)(((Word32)wgt_fct * 28160) >> 15);
193 wgt_fct = 3427 - temp;
196 *(p_wf++) = wgt_fct << 3;
198 } /* for (i = 10; i != 0; i--) */