• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2003 - 2016 Sony Corporation
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 express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "ldac.h"
18 
19 /***************************************************************************************************
20     Tables related to Sampling Rate Indices
21 ***************************************************************************************************/
22 DECLFUNC const unsigned int ga_smplrate_ldac[LDAC_NSUPSMPLRATEID] = {
23     44100, 48000, 88200, 96000,
24 };
25 
26 DECLFUNC const unsigned short ga_framesmpls_ldac[LDAC_NSUPSMPLRATEID] = {
27     LDAC_1FSLSU, LDAC_1FSLSU, LDAC_2FSLSU, LDAC_2FSLSU,
28 };
29 
30 DECLFUNC const unsigned char ga_ln_framesmpls_ldac[LDAC_NSUPSMPLRATEID] = {
31     LDAC_1FSLNN, LDAC_1FSLNN, LDAC_2FSLNN, LDAC_2FSLNN,
32 };
33 
34 DECLFUNC const unsigned char ga_max_nbands_ldac[LDAC_NSUPSMPLRATEID] = {
35     LDAC_1FSNBANDS, LDAC_1FSNBANDS, LDAC_2FSNBANDS, LDAC_2FSNBANDS,
36 };
37 
38 DECLFUNC const char gaa_nlnn_shift_ldac[LDAC_NSUPSMPLRATEID][LDAC_NSFTSTEP] = {
39     {-1, -1,  0,  0, -1},
40     {-1, -1,  0,  0, -1},
41     {-1,  0,  0, -1, -1},
42     {-1,  0,  0, -1, -1},
43 };
44 
45 /***************************************************************************************************
46     Tables related to Channel Config Indices
47 ***************************************************************************************************/
48 DECLFUNC const unsigned char ga_ch_ldac[LDAC_NCHCONFIGID] = {
49     LDAC_CHANNEL_1CH, LDAC_CHANNEL_2CH, LDAC_CHANNEL_2CH, 0, 0, 0, 0, 0
50 };
51 
52 DECLFUNC const unsigned char ga_chconfig_id_ldac[LDAC_MAXNCH+1] = {
53     0, LDAC_CHCONFIGID_MN, LDAC_CHCONFIGID_ST
54 };
55 
56 DECLFUNC const char gaa_block_setting_ldac[LDAC_NCHCONFIGID][LDAC_MAXNCH+2]=
57 {
58     {LDAC_CHANNEL_1CH, 1, LDAC_BLKID_MONO},
59     {LDAC_CHANNEL_2CH, 2, LDAC_BLKID_MONO, LDAC_BLKID_MONO},
60     {LDAC_CHANNEL_2CH, 1, LDAC_BLKID_STEREO},
61     {0, 0, 0},
62 };
63 
get_block_nchs_ldac(int blk_type)64 DECLFUNC int get_block_nchs_ldac(
65 int blk_type)
66 {
67     int blk_nchs;
68 
69     if (blk_type == LDAC_BLKID_MONO) {
70         blk_nchs = 1;
71     }
72     else if (blk_type == LDAC_BLKID_STEREO) {
73         blk_nchs = 2;
74     }
75     else {
76         blk_nchs = -1;
77     }
78 
79     return blk_nchs;
80 }
81 
82 /***************************************************************************************************
83     Tables related to Quantization Units
84 ***************************************************************************************************/
85 DECLFUNC const unsigned char ga_idsp_ldac[LDAC_MAXNQUS] = {
86       0,  0,  0,  0,  0,  0,  0,  0,
87       1,  1,  1,  1,
88       1,  1,  1,  1,
89       1,  1,  1,  1,
90       2,  2,
91       2,  2,
92       3,  3,
93       3,  3,
94       3,  3,
95       3,  3,
96       3,  3,
97 };
98 
99 DECLFUNC const unsigned char ga_nsps_ldac[LDAC_MAXNQUS] = {
100       2,  2,  2,  2,  2,  2,  2,  2,
101       4,  4,  4,  4,
102       4,  4,  4,  4,
103       4,  4,  4,  4,
104       8,  8,
105       8,  8,
106      16, 16,
107      16, 16,
108      16, 16,
109      16, 16,
110      16, 16,
111 };
112 
113 DECLFUNC const unsigned short ga_isp_ldac[LDAC_MAXNQUS+1] = {
114       0,  2,  4,  6,  8, 10, 12, 14,
115      16, 20, 24, 28,
116      32, 36, 40, 44,
117      48, 52, 56, 60,
118      64, 72,
119      80, 88,
120      96,112,
121     128,144,
122     160,176,
123     192,208,
124     224,240,
125     256,
126 };
127 
128 DECLFUNC const unsigned char ga_nqus_ldac[LDAC_MAXNBANDS+1] = {
129     0,  4,  8, 10, 12, 14, 16, 18, 20, 22, 24, 25, 26, 28, 30, 32, 34,
130 };
131 
132 /***************************************************************************************************
133     Encoding/Decoding Tables for Spectrum Data
134 ***************************************************************************************************/
135 DECLFUNC const unsigned char ga_wl_ldac[LDAC_NIDWL] = {
136     0,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
137 };
138 
139 DECLFUNC const short gaa_ndim_wls_ldac[4][LDAC_NIDWL] = {
140     {0,  3,  6,  8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32},
141     {0,  7, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64},
142     {0, 14, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96,104,112,120,128},
143     {0, 28, 48, 64, 80, 96,112,128,144,160,176,192,208,224,240,256},
144 };
145 
146 DECLFUNC const int ga_2dimenc_spec_ldac[LDAC_N2DIMSPECENCTBL] = {
147     0,  1,  2,  0,  3,  0,  4,  0,  5,  6,  7,  0,  0,  0,  0,  0,
148 };
149 
150 DECLFUNC const int ga_4dimenc_spec_ldac[LDAC_N4DIMSPECENCTBL] = {
151      0,  1,  2,  0,  3,  4,  5,  0,  6,  7,  8,  0,  0,  0,  0,  0,
152      9, 10, 11,  0, 12, 13, 14,  0, 15, 16, 17,  0,  0,  0,  0,  0,
153     18, 19, 20,  0, 21, 22, 23,  0, 24, 25, 26,  0,  0,  0,  0,  0,
154      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
155     27, 28, 29,  0, 30, 31, 32,  0, 33, 34, 35,  0,  0,  0,  0,  0,
156     36, 37, 38,  0, 39, 40, 41,  0, 42, 43, 44,  0,  0,  0,  0,  0,
157     45, 46, 47,  0, 48, 49, 50,  0, 51, 52, 53,  0,  0,  0,  0,  0,
158      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
159     54, 55, 56,  0, 57, 58, 59,  0, 60, 61, 62,  0,  0,  0,  0,  0,
160     63, 64, 65,  0, 66, 67, 68,  0, 69, 70, 71,  0,  0,  0,  0,  0,
161     72, 73, 74,  0, 75, 76, 77,  0, 78, 79, 80,  0,  0,  0,  0,  0,
162      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
163      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
164      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
165      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
166      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
167 };
168 
169 
170 /***************************************************************************************************
171     Resampled Gradient Table
172 ***************************************************************************************************/
173 DECLFUNC const unsigned char gaa_resamp_grad_ldac[LDAC_MAXGRADQU][LDAC_MAXGRADQU] = {
174 {
175 128,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
176 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
177 },
178 {
179  31,225,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
180 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
181 },
182 {
183  17,128,239,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
184 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
185 },
186 {
187  12, 69,187,244,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
188 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
189 },
190 {
191  10, 43,128,213,246,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
192 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
193 },
194 {
195   9, 31, 87,169,225,247,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
196 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
197 },
198 {
199   8, 24, 62,128,194,232,248,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
200 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
201 },
202 {
203   8, 19, 47, 97,159,209,237,248,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
204 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
205 },
206 {
207   7, 17, 37, 75,128,181,219,239,249,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
208 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
209 },
210 {
211   7, 15, 31, 59,103,153,197,225,241,249,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
212 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
213 },
214 {
215   7, 13, 26, 48, 83,128,173,208,230,243,249,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
216 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
217 },
218 {
219   6, 12, 23, 41, 69,107,149,187,215,233,244,250,255,255,255,255,255,255,255,255,255,255,255,255,255,
220 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
221 },
222 {
223   6, 11, 20, 35, 58, 90,128,166,198,221,236,245,250,255,255,255,255,255,255,255,255,255,255,255,255,
224 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
225 },
226 {
227   6, 11, 18, 31, 49, 76,110,146,180,207,225,238,245,250,255,255,255,255,255,255,255,255,255,255,255,
228 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
229 },
230 {
231   6, 10, 17, 27, 43, 66, 95,128,161,190,213,229,239,246,250,255,255,255,255,255,255,255,255,255,255,
232 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
233 },
234 {
235   6, 10, 15, 24, 38, 57, 82,112,144,174,199,218,232,241,246,250,255,255,255,255,255,255,255,255,255,
236 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
237 },
238 {
239   6,  9, 14, 22, 34, 50, 72, 98,128,158,184,206,222,234,242,247,250,255,255,255,255,255,255,255,255,
240 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
241 },
242 {
243   6,  9, 13, 20, 31, 45, 63, 87,114,142,169,193,211,225,236,243,247,250,255,255,255,255,255,255,255,
244 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
245 },
246 {
247   6,  9, 13, 19, 28, 40, 56, 77,101,128,155,179,200,216,228,237,243,247,250,255,255,255,255,255,255,
248 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
249 },
250 {
251   6,  8, 12, 18, 26, 36, 51, 69, 91,115,141,165,187,205,220,230,238,244,248,250,255,255,255,255,255,
252 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
253 },
254 {
255   6,  8, 12, 17, 24, 33, 46, 62, 81,104,128,152,175,194,210,223,232,239,244,248,250,255,255,255,255,
256 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
257 },
258 {
259   6,  8, 11, 16, 22, 31, 42, 56, 74, 94,116,140,162,182,200,214,225,234,240,245,248,250,255,255,255,
260 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
261 },
262 {
263   5,  8, 11, 15, 21, 28, 38, 51, 67, 85,106,128,150,171,189,205,218,228,235,241,245,248,251,255,255,
264 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
265 },
266 {
267   5,  8, 10, 14, 19, 26, 35, 47, 61, 78, 97,117,139,159,178,195,209,221,230,237,242,246,248,251,255,
268 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
269 },
270 {
271   5,  7, 10, 14, 18, 25, 33, 43, 56, 71, 88,108,128,148,168,185,200,213,223,231,238,242,246,249,251,
272 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
273 },
274 {
275   5,  7, 10, 13, 17, 23, 31, 40, 51, 65, 81, 99,118,138,157,175,191,205,216,225,233,239,243,246,249,
276 251,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
277 },
278 {
279   5,  7,  9, 13, 17, 22, 29, 37, 47, 60, 75, 91,109,128,147,165,181,196,209,219,227,234,239,243,247,
280 249,251,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
281 },
282 {
283   5,  7,  9, 12, 16, 21, 27, 35, 44, 55, 69, 84,101,119,137,155,172,187,201,212,221,229,235,240,244,
284 247,249,251,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
285 },
286 {
287   5,  7,  9, 12, 15, 20, 25, 32, 41, 51, 64, 78, 94,110,128,146,162,178,192,205,215,224,231,236,241,
288 244,247,249,251,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
289 },
290 {
291   5,  7,  9, 11, 15, 19, 24, 31, 38, 48, 59, 72, 87,103,119,137,153,169,184,197,208,218,225,232,237,
292 241,245,247,249,251,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
293 },
294 {
295   5,  7,  9, 11, 14, 18, 23, 29, 36, 45, 55, 67, 81, 96,112,128,144,160,175,189,201,211,220,227,233,
296 238,242,245,247,249,251,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
297 },
298 {
299   5,  7,  8, 11, 14, 17, 22, 27, 34, 42, 52, 63, 75, 89,104,120,136,152,167,181,193,204,214,222,229,
300 234,239,242,245,248,249,251,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
301 },
302 {
303   5,  7,  8, 11, 13, 17, 21, 26, 32, 40, 48, 59, 70, 83, 98,113,128,143,158,173,186,197,208,216,224,
304 230,235,239,243,245,248,249,251,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
305 },
306 {
307   5,  7,  8, 10, 13, 16, 20, 25, 31, 37, 46, 55, 66, 78, 91,106,120,136,150,165,178,190,201,210,219,
308 225,231,236,240,243,246,248,249,251,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
309 },
310 {
311   5,  6,  8, 10, 12, 15, 19, 24, 29, 35, 43, 52, 62, 73, 86, 99,113,128,143,157,170,183,194,204,213,
312 221,227,232,237,241,244,246,248,250,251,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
313 },
314 {
315   5,  6,  8, 10, 12, 15, 18, 23, 28, 34, 41, 49, 58, 69, 81, 93,107,121,135,149,163,175,187,198,207,
316 215,222,228,233,238,241,244,246,248,250,251,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
317 },
318 {
319   5,  6,  8, 10, 12, 15, 18, 22, 26, 32, 39, 46, 55, 65, 76, 88,101,114,128,142,155,168,180,191,201,
320 210,217,224,230,234,238,241,244,246,248,250,251,255,255,255,255,255,255,255,255,255,255,255,255,255,
321 },
322 {
323   5,  6,  8,  9, 12, 14, 17, 21, 25, 31, 37, 44, 52, 61, 72, 83, 95,108,121,135,148,161,173,184,195,
324 204,212,219,225,231,235,239,242,244,247,248,250,251,255,255,255,255,255,255,255,255,255,255,255,255,
325 },
326 {
327   5,  6,  8,  9, 11, 14, 17, 20, 24, 29, 35, 42, 49, 58, 68, 78, 90,102,115,128,141,154,166,178,188,
328 198,207,214,221,227,232,236,239,242,245,247,248,250,251,255,255,255,255,255,255,255,255,255,255,255,
329 },
330 {
331   5,  6,  8,  9, 11, 13, 16, 19, 23, 28, 33, 40, 47, 55, 64, 74, 85, 97,109,122,134,147,159,171,182,
332 192,201,209,216,223,228,233,237,240,243,245,247,248,250,251,255,255,255,255,255,255,255,255,255,255,
333 },
334 {
335   5,  6,  7,  9, 11, 13, 16, 19, 22, 27, 32, 38, 44, 52, 61, 70, 80, 92,103,116,128,140,153,164,176,
336 186,195,204,212,218,224,229,234,237,240,243,245,247,249,250,251,255,255,255,255,255,255,255,255,255,
337 },
338 {
339   5,  6,  7,  9, 11, 13, 15, 18, 22, 26, 31, 36, 42, 49, 58, 66, 76, 87, 98,110,122,134,146,158,169,
340 180,190,198,207,214,220,225,230,234,238,241,243,245,247,249,250,251,255,255,255,255,255,255,255,255,
341 },
342 {
343   5,  6,  7,  9, 10, 12, 15, 18, 21, 25, 29, 34, 40, 47, 55, 63, 72, 82, 93,104,116,128,140,152,163,
344 174,184,193,201,209,216,222,227,231,235,238,241,244,246,247,249,250,251,255,255,255,255,255,255,255,
345 },
346 {
347   5,  6,  7,  9, 10, 12, 14, 17, 20, 24, 28, 33, 39, 45, 52, 60, 69, 78, 89, 99,111,122,134,145,157,
348 167,178,187,196,204,211,217,223,228,232,236,239,242,244,246,247,249,250,251,255,255,255,255,255,255,
349 },
350 {
351   5,  6,  7,  8, 10, 12, 14, 17, 20, 23, 27, 32, 37, 43, 50, 57, 66, 75, 84, 95,105,117,128,139,151,
352 161,172,181,190,199,206,213,219,224,229,233,236,239,242,244,246,248,249,250,251,255,255,255,255,255,
353 },
354 {
355   5,  6,  7,  8, 10, 12, 14, 16, 19, 22, 26, 31, 36, 41, 48, 55, 62, 71, 80, 90,101,111,122,134,145,
356 155,166,176,185,194,201,208,215,220,225,230,234,237,240,242,244,246,248,249,250,251,255,255,255,255,
357 },
358 {
359   5,  6,  7,  8, 10, 11, 13, 16, 18, 22, 25, 29, 34, 39, 45, 52, 60, 68, 77, 86, 96,106,117,128,139,
360 150,160,170,179,188,196,204,211,217,222,227,231,234,238,240,243,245,246,248,249,250,251,255,255,255,
361 },
362 {
363   5,  6,  7,  8, 10, 11, 13, 15, 18, 21, 24, 28, 33, 38, 44, 50, 57, 65, 73, 82, 92,102,112,123,133,
364 144,154,164,174,183,191,199,206,212,218,223,228,232,235,238,241,243,245,246,248,249,250,251,255,255,
365 },
366 {
367   5,  6,  7,  8,  9, 11, 13, 15, 17, 20, 24, 27, 32, 36, 42, 48, 55, 62, 70, 78, 88, 97,107,118,128,
368 138,149,159,168,178,186,194,201,208,214,220,224,229,232,236,239,241,243,245,247,248,249,250,251,255,
369 },
370 {
371   5,  6,  7,  8,  9, 11, 13, 15, 17, 20, 23, 26, 31, 35, 40, 46, 52, 59, 67, 75, 84, 93,103,113,123,
372 133,143,153,163,172,181,189,197,204,210,216,221,225,230,233,236,239,241,243,245,247,248,249,250,251,
373 },
374 };
375 
376 /***************************************************************************************************
377     Weighting Tables for Scale Factor Data
378 ***************************************************************************************************/
379 DECLFUNC const unsigned char gaa_sfcwgt_ldac[LDAC_NSFCWTBL][LDAC_MAXNQUS] = {
380 {
381      1,  0,  0,  1,  1,  1,  2,  2,  2,  2,  2,  2,  3,  3,  3,  3,
382      3,  3,  3,  3,  3,  3,  3,  4,  4,  5,  5,  6,  6,  7,  7,  8,  8,  8,
383 },
384 {
385      0,  1,  1,  2,  3,  4,  4,  4,  4,  5,  6,  6,  6,  6,  6,  7,
386      7,  7,  7,  7,  7,  7,  8,  8,  8,  9, 10, 10, 11, 11, 12, 12, 12, 12,
387 },
388 {
389      0,  1,  1,  2,  3,  3,  3,  3,  3,  4,  4,  5,  5,  5,  5,  5,
390      5,  5,  5,  5,  5,  5,  6,  6,  6,  7,  8,  9,  9, 10, 10, 11, 11, 11,
391 },
392 {
393      0,  1,  3,  4,  5,  5,  6,  6,  6,  6,  7,  7,  7,  7,  7,  7,
394      7,  7,  7,  7,  7,  7,  7,  8,  8,  8,  8,  9,  9,  9, 10, 10, 10, 10,
395 },
396 {
397      0,  1,  3,  4,  5,  5,  6,  7,  7,  8,  8,  9,  9, 10, 10, 10,
398     10, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13,
399 },
400 {
401      1,  0,  1,  2,  2,  3,  3,  4,  4,  5,  6,  7,  7,  8,  8,  8,
402      9,  9,  9,  9,  9, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11,
403 },
404 {
405      0,  0,  1,  1,  2,  2,  2,  2,  2,  3,  3,  3,  3,  4,  4,  4,
406      4,  4,  4,  4,  4,  4,  4,  5,  5,  6,  7,  7,  7,  8,  9,  9,  9,  9,
407 },
408 {
409      0,  0,  1,  2,  3,  4,  4,  5,  5,  6,  7,  7,  8,  8,  8,  8,
410      9,  9,  9,  9,  9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 12,
411 },
412 };
413 
414 /***************************************************************************************************
415     Huffman Codewords for Scale Factor Data
416 ***************************************************************************************************/
417 static const HC sa_hc_sf0_blen3_ldac[8] = {
418     {  0, 2}, {  1, 2}, { 14, 4}, { 62, 6},
419     { 63, 6}, { 30, 5}, {  6, 3}, {  2, 2},
420 };
421 
422 static const HC sa_hc_sf0_blen4_ldac[16] = {
423     {  1, 2}, {  2, 2}, {  0, 4}, {  6, 5},
424     { 15, 6}, { 19, 7}, { 35, 8}, { 36, 8},
425     { 37, 8}, { 34, 8}, { 33, 8}, { 32, 8},
426     { 14, 6}, {  5, 5}, {  1, 4}, {  3, 2},
427 };
428 
429 static const HC sa_hc_sf0_blen5_ldac[32] = {
430     {  2, 2}, {  1, 3}, {  7, 3}, { 13, 4},
431     { 12, 5}, { 24, 5}, { 27, 6}, { 33, 7},
432     { 63, 7}, {106, 8}, {107, 8}, {104, 8},
433     {115, 8}, {121, 8}, {124, 8}, {125, 8},
434     {122, 8}, {123, 8}, {120, 8}, {114, 8},
435     { 68, 8}, { 69, 8}, { 71, 8}, { 70, 8},
436     {105, 8}, { 56, 7}, { 32, 7}, { 29, 6},
437     { 25, 5}, {  9, 5}, {  5, 4}, {  0, 3},
438 };
439 
440 static const HC sa_hc_sf0_blen6_ldac[64] = {
441     {  0, 3}, {  1, 3}, {  4, 4}, {  5, 4},
442     { 18, 5}, { 19, 5}, { 46, 6}, { 47, 6},
443     { 48, 6}, {102, 7}, {103, 7}, {214, 8},
444     {215, 8}, {216, 8}, {217, 8}, {218, 8},
445     {219, 8}, {220, 8}, {221, 8}, {222, 8},
446     {223, 8}, {224, 8}, {225, 8}, {226, 8},
447     {227, 8}, {228, 8}, {229, 8}, {230, 8},
448     {231, 8}, {232, 8}, {233, 8}, {234, 8},
449     {235, 8}, {236, 8}, {237, 8}, {238, 8},
450     {239, 8}, {240, 8}, {241, 8}, {242, 8},
451     {243, 8}, {244, 8}, {245, 8}, {246, 8},
452     {247, 8}, {248, 8}, {249, 8}, {250, 8},
453     {251, 8}, {252, 8}, {253, 8}, {254, 8},
454     {255, 8}, {104, 7}, {105, 7}, {106, 7},
455     { 49, 6}, { 50, 6}, { 20, 5}, { 21, 5},
456     { 22, 5}, {  6, 4}, {  7, 4}, {  8, 4},
457 };
458 
459 static const HC sa_hc_sf1_blen2_ldac[4] = {
460     {  0, 1}, {  3, 2}, {  0, 0}, { 2,  2},
461 };
462 
463 static const HC sa_hc_sf1_blen3_ldac[8] = {
464     {  1, 1}, {  0, 3}, {  4, 5}, { 11, 6},
465     {  0, 0}, { 10, 6}, {  3, 4}, {  1, 2},
466 };
467 
468 static const HC sa_hc_sf1_blen4_ldac[16] = {
469     {  1, 1}, {  1, 3}, {  4, 4}, { 14, 5},
470     { 15, 5}, { 44, 7}, { 90, 8}, { 93, 8},
471     {  0, 0}, { 92, 8}, { 91, 8}, { 47, 7},
472     { 21, 6}, { 20, 6}, {  6, 4}, {  0, 3},
473 };
474 
475 static const HC sa_hc_sf1_blen5_ldac[32] = {
476     {  0, 3}, {  5, 3}, {  7, 4}, { 12, 4},
477     {  4, 4}, {  2, 4}, {  3, 4}, {  5, 4},
478     {  9, 4}, { 16, 5}, { 35, 6}, { 51, 7},
479     { 54, 7}, {110, 7}, { 96, 8}, {101, 8},
480     { 98, 8}, { 97, 8}, { 99, 8}, {100, 8},
481     {111, 7}, {109, 7}, {108, 7}, {107, 7},
482     {106, 7}, {104, 7}, {105, 7}, { 69, 7},
483     { 68, 7}, { 55, 7}, { 26, 6}, {  7, 3},
484 };
485 
486 
487 /***************************************************************************************************
488     Huffman Encoding/Decoding Structures for Scale Factor Data
489 ***************************************************************************************************/
490 DECLFUNC HCENC ga_hcenc_sf0_ldac[LDAC_MAXSFCBLEN_0-LDAC_MINSFCBLEN_0+1] = {
491     {sa_hc_sf0_blen3_ldac,  8,  3,  7},
492     {sa_hc_sf0_blen4_ldac, 16,  4, 15},
493     {sa_hc_sf0_blen5_ldac, 32,  5, 31},
494     {sa_hc_sf0_blen6_ldac, 64,  6, 63},
495 };
496 
497 DECLFUNC HCENC ga_hcenc_sf1_ldac[LDAC_MAXSFCBLEN_2-LDAC_MINSFCBLEN_2+1] = {
498     {sa_hc_sf1_blen2_ldac,  4,  2,  3},
499     {sa_hc_sf1_blen3_ldac,  8,  3,  7},
500     {sa_hc_sf1_blen4_ldac, 16,  4, 15},
501     {sa_hc_sf1_blen5_ldac, 32,  5, 31},
502 };
503 
504 
505 
506