1 /*
2  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 /*
12  * SWB_KLT_Tables.c
13  *
14  * This file defines tables used for entropy coding of LPC shape of
15  * upper-band signal if the bandwidth is 12 kHz.
16  *
17  */
18 
19 #include "lpc_shape_swb12_tables.h"
20 #include "settings.h"
21 #include "webrtc/typedefs.h"
22 
23 /*
24 * Mean value of LAR
25 */
26 const double WebRtcIsac_kMeanLarUb12[UB_LPC_ORDER] =
27 {
28   0.03748928306641, 0.09453441192543, -0.01112522344398, 0.03800237516842
29 };
30 
31 /*
32 * A rotation matrix to decorrelate intra-vector correlation,
33 * i.e. correlation among components of LAR vector.
34 */
35 const double WebRtcIsac_kIntraVecDecorrMatUb12[UB_LPC_ORDER][UB_LPC_ORDER] =
36 {
37     {-0.00075365493856,  -0.05809964887743,  -0.23397966154116,   0.97050367376411},
38     { 0.00625021257734,  -0.17299965610679,   0.95977735920651,   0.22104179375008},
39     { 0.20543384258374,  -0.96202143495696,  -0.15301870801552,  -0.09432375099565},
40     {-0.97865075648479,  -0.20300322280841,  -0.02581111653779,  -0.01913568980258}
41 };
42 
43 /*
44 * A rotation matrix to remove correlation among LAR coefficients
45 * of different LAR vectors. One might guess that decorrelation matrix
46 * for the first component should differ from the second component
47 * but we haven't observed a significant benefit of having different
48 * decorrelation matrices for different components.
49 */
50 const double WebRtcIsac_kInterVecDecorrMatUb12
51 [UB_LPC_VEC_PER_FRAME][UB_LPC_VEC_PER_FRAME] =
52 {
53     { 0.70650597970460,  -0.70770707262373},
54     {-0.70770707262373,  -0.70650597970460}
55 };
56 
57 /*
58 * LAR quantization step-size.
59 */
60 const double WebRtcIsac_kLpcShapeQStepSizeUb12 = 0.150000;
61 
62 /*
63 * The smallest reconstruction points for quantiztion of LAR coefficients.
64 */
65 const double WebRtcIsac_kLpcShapeLeftRecPointUb12
66 [UB_LPC_ORDER*UB_LPC_VEC_PER_FRAME] =
67 {
68     -0.900000, -1.050000, -1.350000, -1.800000, -1.350000, -1.650000,
69     -2.250000, -3.450000
70 };
71 
72 /*
73 * Number of reconstruction points of quantizers for LAR coefficients.
74 */
75 const int16_t WebRtcIsac_kLpcShapeNumRecPointUb12
76 [UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME] =
77 {
78     13, 15, 19, 27, 19, 24, 32, 48
79 };
80 
81 /*
82 * Starting index for entropy decoder to search for the right interval,
83 * one entry per LAR coefficient
84 */
85 const uint16_t WebRtcIsac_kLpcShapeEntropySearchUb12
86 [UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME] =
87 {
88      6,  7,  9, 13,  9, 12, 16, 24
89 };
90 
91 /*
92 * The following 8 vectors define CDF of 8 decorrelated LAR
93 * coefficients.
94 */
95 const uint16_t WebRtcIsac_kLpcShapeCdfVec0Ub12[14] =
96 {
97      0,    13,    95,   418,  1687,  6498, 21317, 44200, 59029, 63849, 65147,
98  65449, 65525, 65535
99 };
100 
101 const uint16_t WebRtcIsac_kLpcShapeCdfVec1Ub12[16] =
102 {
103      0,    10,    59,   255,   858,  2667,  8200, 22609, 42988, 57202, 62947,
104  64743, 65308, 65476, 65522, 65535
105 };
106 
107 const uint16_t WebRtcIsac_kLpcShapeCdfVec2Ub12[20] =
108 {
109      0,    18,    40,   118,   332,   857,  2017,  4822, 11321, 24330, 41279,
110  54342, 60637, 63394, 64659, 65184, 65398, 65482, 65518, 65535
111 };
112 
113 const uint16_t WebRtcIsac_kLpcShapeCdfVec3Ub12[28] =
114 {
115      0,    21,    38,    90,   196,   398,   770,  1400,  2589,  4650,  8211,
116  14933, 26044, 39592, 50814, 57452, 60971, 62884, 63995, 64621, 65019, 65273,
117  65410, 65480, 65514, 65522, 65531, 65535
118 };
119 
120 const uint16_t WebRtcIsac_kLpcShapeCdfVec4Ub12[20] =
121 {
122      0,     7,    46,   141,   403,   969,  2132,  4649, 10633, 24902, 43254,
123  54665, 59928, 62674, 64173, 64938, 65293, 65464, 65523, 65535
124 };
125 
126 const uint16_t WebRtcIsac_kLpcShapeCdfVec5Ub12[25] =
127 {
128      0,     7,    22,    72,   174,   411,   854,  1737,  3545,  6774, 13165,
129  25221, 40980, 52821, 58714, 61706, 63472, 64437, 64989, 65287, 65430, 65503,
130  65525, 65529, 65535
131 };
132 
133 const uint16_t WebRtcIsac_kLpcShapeCdfVec6Ub12[33] =
134 {
135      0,    11,    21,    36,    65,   128,   228,   401,   707,  1241,  2126,
136   3589,  6060, 10517, 18853, 31114, 42477, 49770, 54271, 57467, 59838, 61569,
137  62831, 63772, 64433, 64833, 65123, 65306, 65419, 65466, 65499, 65519, 65535
138 };
139 
140 const uint16_t WebRtcIsac_kLpcShapeCdfVec7Ub12[49] =
141 {
142      0,    14,    34,    67,   107,   167,   245,   326,   449,   645,   861,
143   1155,  1508,  2003,  2669,  3544,  4592,  5961,  7583,  9887, 13256, 18765,
144  26519, 34077, 40034, 44349, 47795, 50663, 53262, 55473, 57458, 59122, 60592,
145  61742, 62690, 63391, 63997, 64463, 64794, 65045, 65207, 65309, 65394, 65443,
146  65478, 65504, 65514, 65523, 65535
147 };
148 
149 /*
150 * An array of pointers to CDFs of decorrelated LARs
151 */
152 const uint16_t* WebRtcIsac_kLpcShapeCdfMatUb12
153 [UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME] =
154 {
155     WebRtcIsac_kLpcShapeCdfVec0Ub12, WebRtcIsac_kLpcShapeCdfVec1Ub12,
156     WebRtcIsac_kLpcShapeCdfVec2Ub12, WebRtcIsac_kLpcShapeCdfVec3Ub12,
157     WebRtcIsac_kLpcShapeCdfVec4Ub12, WebRtcIsac_kLpcShapeCdfVec5Ub12,
158     WebRtcIsac_kLpcShapeCdfVec6Ub12, WebRtcIsac_kLpcShapeCdfVec7Ub12
159 };
160