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  Filename: /audio/gsm_amr/c/src/gains_tbl.c
32 
33 ------------------------------------------------------------------------------
34  REVISION HISTORY
35 
36  Description: Created this file from the reference, gains.tab
37 
38  Description: Added include of "typedef.h" to includes section.
39 
40  Description: Added #ifdef __cplusplus and removed "extern" from table
41               definition.
42 
43  Description: Put "extern" back.
44 
45  Who:                               Date:
46  Description:
47 
48 ------------------------------------------------------------------------------
49  MODULE DESCRIPTION
50 
51 ------------------------------------------------------------------------------
52 */
53 
54 /*----------------------------------------------------------------------------
55 ; INCLUDES
56 ----------------------------------------------------------------------------*/
57 #include "typedef.h"
58 
59 /*--------------------------------------------------------------------------*/
60 #ifdef __cplusplus
61 extern "C"
62 {
63 #endif
64 
65     /*----------------------------------------------------------------------------
66     ; MACROS
67     ; [Define module specific macros here]
68     ----------------------------------------------------------------------------*/
69 
70     /*----------------------------------------------------------------------------
71     ; DEFINES
72     ; [Include all pre-processor statements here. Include conditional
73     ; compile variables also.]
74     ----------------------------------------------------------------------------*/
75 #define NB_QUA_PITCH 16
76 #define NB_QUA_CODE 32
77 
78     /*----------------------------------------------------------------------------
79     ; LOCAL FUNCTION DEFINITIONS
80     ; [List function prototypes here]
81     ----------------------------------------------------------------------------*/
82 
83     /*----------------------------------------------------------------------------
84     ; LOCAL VARIABLE DEFINITIONS
85     ; [Variable declaration - defined here and used outside this module]
86     ----------------------------------------------------------------------------*/
87 
88 
89     extern const Word16 qua_gain_pitch[];
90     const Word16 qua_gain_pitch[NB_QUA_PITCH] =
91     {
92         0, 3277, 6556, 8192, 9830, 11469, 12288, 13107,
93         13926, 14746, 15565, 16384, 17203, 18022, 18842, 19661
94     };
95 
96 
97     extern const Word16 qua_gain_code[];
98     const Word16 qua_gain_code[(NB_QUA_CODE+1)*3] =
99     {
100         /* gain factor (g_fac) and quantized energy error (qua_ener_MR122, qua_ener)
101          * are stored:
102          *
103          * qua_ener_MR122 = log2(g_fac)      (not the rounded floating point value, but
104          *                                    the value the original EFR algorithm
105          *                                    calculates from g_fac [using Log2])
106          * qua_ener       = 20*log10(g_fac); (rounded floating point value)
107          *
108          *
109          * g_fac (Q11), qua_ener_MR122 (Q10), qua_ener (Q10)
110          */
111         159,                -3776,          -22731,
112         206,                -3394,          -20428,
113         268,                -3005,          -18088,
114         349,                -2615,          -15739,
115         419,                -2345,          -14113,
116         482,                -2138,          -12867,
117         554,                -1932,          -11629,
118         637,                -1726,          -10387,
119         733,                -1518,           -9139,
120         842,                -1314,           -7906,
121         969,                -1106,           -6656,
122         1114,                 -900,           -5416,
123         1281,                 -694,           -4173,
124         1473,                 -487,           -2931,
125         1694,                 -281,           -1688,
126         1948,                  -75,            -445,
127         2241,                  133,             801,
128         2577,                  339,            2044,
129         2963,                  545,            3285,
130         3408,                  752,            4530,
131         3919,                  958,            5772,
132         4507,                 1165,            7016,
133         5183,                 1371,            8259,
134         5960,                 1577,            9501,
135         6855,                 1784,           10745,
136         7883,                 1991,           11988,
137         9065,                 2197,           13231,
138         10425,                 2404,           14474,
139         12510,                 2673,           16096,
140         16263,                 3060,           18429,
141         21142,                 3448,           20763,
142         27485,                 3836,           23097,
143         27485,                 3836,           23097
144     };
145 
146     /*--------------------------------------------------------------------------*/
147 #ifdef __cplusplus
148 }
149 #endif
150 
151 /*
152 ------------------------------------------------------------------------------
153  FUNCTION NAME:
154 ------------------------------------------------------------------------------
155  INPUT AND OUTPUT DEFINITIONS
156 
157  Inputs:
158     None
159 
160  Outputs:
161     None
162 
163  Returns:
164     None
165 
166  Global Variables Used:
167     None
168 
169  Local Variables Needed:
170     None
171 
172 ------------------------------------------------------------------------------
173  FUNCTION DESCRIPTION
174 
175  None
176 
177 ------------------------------------------------------------------------------
178  REQUIREMENTS
179 
180  None
181 
182 ------------------------------------------------------------------------------
183  REFERENCES
184 
185  [1] gains.tab,  UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001
186 
187 ------------------------------------------------------------------------------
188  PSEUDO-CODE
189 
190 
191 ------------------------------------------------------------------------------
192  RESOURCES USED [optional]
193 
194  When the code is written for a specific target processor the
195  the resources used should be documented below.
196 
197  HEAP MEMORY USED: x bytes
198 
199  STACK MEMORY USED: x bytes
200 
201  CLOCK CYCLES: (cycle count equation for this function) + (variable
202                 used to represent cycle count for each subroutine
203                 called)
204      where: (cycle count variable) = cycle count for [subroutine
205                                      name]
206 
207 ------------------------------------------------------------------------------
208  CAUTION [optional]
209  [State any special notes, constraints or cautions for users of this function]
210 
211 ------------------------------------------------------------------------------
212 */
213 
214 /*----------------------------------------------------------------------------
215 ; FUNCTION CODE
216 ----------------------------------------------------------------------------*/
217 
218 
219 
220