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