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 - Wideband (AMR-WB) speech codec
23 Available from http://www.3gpp.org
25 (C) 2007, 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 ------------------------------------------------------------------------------
36 ------------------------------------------------------------------------------
37 INPUT AND OUTPUT DEFINITIONS
39 int16 isf[], (i) Q15 : isf[m] normalized (range: 0.0<=val<=0.5)
40 int16 isp[], (o) Q15 : isp[m] (range: -1<=val<1)
41 int16 m (i) : LPC order
44 ------------------------------------------------------------------------------
47 Isf_isp Transformation isf to isp
49 The transformation from isf[i] to isp[i] is
50 approximated by a look-up table and interpolation.
54 ------------------------------------------------------------------------------
58 ------------------------------------------------------------------------------
61 ------------------------------------------------------------------------------
64 ------------------------------------------------------------------------------
68 /*----------------------------------------------------------------------------
70 ----------------------------------------------------------------------------*/
73 #include "pv_amr_wb_type_defs.h"
74 #include "pvamrwbdecoder_basic_op.h"
75 #include "pvamrwbdecoder_acelp.h"
77 /*----------------------------------------------------------------------------
79 ; Define module specific macros here
80 ----------------------------------------------------------------------------*/
83 /*----------------------------------------------------------------------------
85 ; Include all pre-processor statements here. Include conditional
86 ; compile variables also.
87 ----------------------------------------------------------------------------*/
89 /*----------------------------------------------------------------------------
90 ; LOCAL FUNCTION DEFINITIONS
91 ; Function Prototype declaration
92 ----------------------------------------------------------------------------*/
94 /*----------------------------------------------------------------------------
95 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
96 ; Variable declaration - defined here and used outside this module
97 ----------------------------------------------------------------------------*/
99 /* Look-up table for transformations */
101 /* table of cos(x) in Q15 */
103 static const int16 table[129] =
106 32758, 32729, 32679, 32610, 32522, 32413, 32286, 32138,
107 31972, 31786, 31581, 31357, 31114, 30853, 30572, 30274,
108 29957, 29622, 29269, 28899, 28511, 28106, 27684, 27246,
109 26791, 26320, 25833, 25330, 24812, 24279, 23732, 23170,
110 22595, 22006, 21403, 20788, 20160, 19520, 18868, 18205,
111 17531, 16846, 16151, 15447, 14733, 14010, 13279, 12540,
112 11793, 11039, 10279, 9512, 8740, 7962, 7180, 6393,
113 5602, 4808, 4011, 3212, 2411, 1608, 804, 0,
114 -804, -1608, -2411, -3212, -4011, -4808, -5602, -6393,
115 -7180, -7962, -8740, -9512, -10279, -11039, -11793, -12540,
116 -13279, -14010, -14733, -15447, -16151, -16846, -17531, -18205,
117 -18868, -19520, -20160, -20788, -21403, -22006, -22595, -23170,
118 -23732, -24279, -24812, -25330, -25833, -26320, -26791, -27246,
119 -27684, -28106, -28511, -28899, -29269, -29622, -29957, -30274,
120 -30572, -30853, -31114, -31357, -31581, -31786, -31972, -32138,
121 -32286, -32413, -32522, -32610, -32679, -32729, -32758, -32768
125 /*----------------------------------------------------------------------------
126 ; EXTERNAL FUNCTION REFERENCES
127 ; Declare functions defined elsewhere and referenced in this module
128 ----------------------------------------------------------------------------*/
130 /*----------------------------------------------------------------------------
131 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
132 ; Declare variables used in this module but defined elsewhere
133 ----------------------------------------------------------------------------*/
135 /*----------------------------------------------------------------------------
137 ----------------------------------------------------------------------------*/
141 int16 isf[], /* (i) Q15 : isf[m] normalized (range: 0.0<=val<=0.5) */
142 int16 isp[], /* (o) Q15 : isp[m] (range: -1<=val<1) */
143 int16 m /* (i) : LPC order */
146 int16 i, ind, offset;
149 for (i = 0; i < m - 1; i++)
153 isp[m - 1] = shl_int16(isf[m - 1], 1);
155 for (i = 0; i < m; i++)
157 ind = isp[i] >> 7; /* ind = b7-b15 of isf[i] */
158 offset = (isp[i] & 0x007f); /* offset = b0-b6 of isf[i] */
160 /* isp[i] = table[ind]+ ((table[ind+1]-table[ind])*offset) / 128 */
162 L_tmp = mul_16by16_to_int32(table[ind + 1] - table[ind], offset);
163 isp[i] = add_int16(table[ind], (int16)(L_tmp >> 8));