FFmpeg
dnxhddata.c
Go to the documentation of this file.
1 /*
2  * VC3/DNxHD data.
3  * Copyright (c) 2007 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "avcodec.h"
23 #include "dnxhddata.h"
24 #include "libavutil/common.h"
25 
26 /* The quantization tables below are in zigzag order! */
27 
28 /* Used in CID 1235, 1256, 1270 */
29 static const uint8_t dnxhd_1235_luma_weight[] = {
30  0, 32, 32, 32, 33, 32, 32, 32,
31  32, 31, 32, 33, 33, 33, 33, 35,
32  36, 36, 34, 34, 36, 37, 37, 36,
33  36, 35, 36, 38, 39, 39, 37, 36,
34  37, 37, 39, 41, 42, 41, 39, 39,
35  40, 41, 42, 43, 42, 42, 41, 41,
36  41, 44, 47, 46, 46, 48, 51, 51,
37  50, 50, 53, 55, 55, 56, 60, 60,
38 };
39 
40 /* Used in CID 1235, 1256 */
41 static const uint8_t dnxhd_1235_chroma_weight[] = {
42  0, 32, 33, 34, 34, 33, 34, 35,
43  37, 40, 43, 42, 39, 38, 39, 41,
44  43, 44, 47, 50, 55, 61, 63, 56,
45  48, 46, 49, 54, 59, 58, 55, 58,
46  63, 65, 67, 74, 84, 82, 75, 72,
47  70, 74, 84, 87, 87, 94, 93, 81,
48  75, 78, 83, 89, 91, 86, 82, 85,
49  90, 90, 85, 79, 73, 73, 73, 73,
50 };
51 
52 /* Used in CID 1237, 1253, 1259, 1273, 1274 */
53 static const uint8_t dnxhd_1237_luma_weight[] = {
54  0, 32, 33, 34, 34, 36, 37, 36,
55  36, 37, 38, 38, 38, 39, 41, 44,
56  43, 41, 40, 41, 46, 49, 47, 46,
57  47, 49, 51, 54, 60, 62, 59, 55,
58  54, 56, 58, 61, 65, 66, 64, 63,
59  66, 73, 78, 79, 80, 79, 78, 78,
60  82, 87, 89, 90, 93, 95, 96, 97,
61  97, 100, 104, 102, 98, 98, 99, 99,
62 };
63 
64 /* Used in CID 1237, 1253, 1259, 1273, 1274 */
65 static const uint8_t dnxhd_1237_chroma_weight[] = {
66  0, 32, 36, 39, 39, 38, 39, 41,
67  45, 51, 57, 58, 53, 48, 47, 51,
68  55, 58, 66, 75, 81, 83, 82, 78,
69  73, 72, 74, 77, 83, 85, 83, 82,
70  89, 99, 96, 90, 94, 97, 99, 105,
71  109, 105, 95, 89, 92, 95, 94, 93,
72  92, 88, 89, 90, 93, 95, 96, 97,
73  97, 100, 104, 102, 98, 98, 99, 99,
74 };
75 
76 /* Used in CID 1238, 1272 */
77 static const uint8_t dnxhd_1238_luma_weight[] = {
78  0, 32, 32, 33, 34, 33, 33, 33,
79  33, 33, 33, 33, 33, 35, 37, 37,
80  36, 36, 35, 36, 38, 38, 36, 35,
81  36, 37, 38, 41, 42, 41, 39, 38,
82  38, 38, 39, 41, 42, 41, 39, 39,
83  40, 41, 43, 44, 44, 44, 44, 44,
84  45, 47, 47, 47, 49, 50, 51, 51,
85  51, 53, 55, 57, 58, 59, 57, 57,
86 };
87 
88 /* Used in CID 1238, 1272 */
89 static const uint8_t dnxhd_1238_chroma_weight[] = {
90  0, 32, 35, 35, 35, 34, 34, 35,
91  39, 43, 45, 45, 41, 39, 40, 41,
92  42, 44, 48, 55, 59, 63, 65, 59,
93  53, 52, 52, 55, 61, 62, 58, 58,
94  63, 66, 66, 65, 70, 74, 70, 66,
95  65, 68, 75, 77, 74, 74, 77, 76,
96  73, 73, 73, 73, 76, 80, 89, 90,
97  82, 77, 80, 86, 84, 82, 82, 82,
98 };
99 
100 /* Used in CID 1241, 1271 */
101 static const uint8_t dnxhd_1241_luma_weight[] = {
102  0, 32, 33, 34, 34, 35, 36, 37,
103  36, 37, 38, 38, 38, 39, 39, 40,
104  40, 38, 38, 39, 38, 37, 39, 41,
105  41, 42, 43, 45, 45, 46, 47, 46,
106  45, 43, 39, 37, 37, 40, 44, 45,
107  45, 46, 46, 46, 47, 47, 46, 44,
108  42, 43, 45, 47, 48, 49, 50, 49,
109  48, 46, 47, 48, 48, 49, 49, 49,
110 };
111 
112 /* Used in CID 1241, 1271 */
113 static const uint8_t dnxhd_1241_chroma_weight[] = {
114  0, 32, 36, 38, 37, 37, 40, 41,
115  40, 40, 42, 42, 41, 41, 41, 41,
116  42, 43, 44, 44, 45, 46, 46, 45,
117  44, 45, 45, 45, 45, 46, 47, 46,
118  45, 44, 42, 41, 43, 45, 45, 47,
119  48, 48, 48, 46, 47, 47, 46, 47,
120  46, 45, 45, 47, 48, 49, 50, 49,
121  48, 46, 48, 49, 48, 49, 49, 49,
122 };
123 
124 static const uint8_t dnxhd_1242_luma_weight[] = {
125  0, 32, 33, 33, 34, 35, 36, 35,
126  33, 33, 35, 36, 37, 37, 38, 37,
127  37, 37, 36, 37, 37, 37, 38, 39,
128  37, 36, 37, 40, 42, 45, 46, 44,
129  41, 42, 44, 45, 47, 49, 50, 48,
130  46, 48, 49, 50, 52, 52, 50, 49,
131  47, 48, 50, 50, 51, 51, 50, 49,
132  49, 51, 52, 51, 49, 47, 47, 47,
133 };
134 
135 static const uint8_t dnxhd_1242_chroma_weight[] = {
136  0, 32, 37, 42, 45, 45, 45, 44,
137  38, 37, 40, 42, 44, 49, 51, 47,
138  41, 40, 43, 44, 46, 48, 51, 54,
139  51, 47, 47, 45, 47, 50, 51, 49,
140  46, 47, 49, 47, 50, 55, 55, 51,
141  48, 49, 51, 51, 52, 52, 54, 54,
142  49, 49, 52, 53, 54, 54, 53, 53,
143  55, 59, 63, 62, 60, 60, 60, 60,
144 };
145 
146 static const uint8_t dnxhd_1243_luma_weight[] = {
147  0, 32, 32, 33, 33, 35, 35, 35,
148  35, 35, 35, 35, 34, 35, 38, 40,
149  39, 37, 37, 37, 36, 35, 36, 38,
150  40, 41, 42, 44, 45, 44, 42, 41,
151  40, 38, 36, 36, 37, 38, 40, 43,
152  44, 45, 45, 45, 45, 45, 45, 41,
153  39, 41, 45, 47, 47, 48, 48, 48,
154  46, 44, 45, 47, 47, 48, 47, 47,
155 };
156 
157 static const uint8_t dnxhd_1243_chroma_weight[] = {
158  0, 32, 36, 37, 36, 37, 39, 39,
159  41, 43, 43, 42, 41, 41, 41, 42,
160  43, 43, 43, 44, 44, 44, 46, 47,
161  46, 45, 45, 45, 45, 46, 44, 44,
162  45, 44, 42, 41, 43, 46, 45, 44,
163  45, 45, 45, 46, 46, 46, 45, 44,
164  45, 44, 45, 47, 47, 48, 49, 48,
165  46, 45, 46, 47, 47, 48, 47, 47,
166 };
167 
168 static const uint8_t dnxhd_1250_luma_weight[] = {
169  0, 32, 32, 33, 34, 35, 35, 35,
170  34, 34, 35, 36, 36, 36, 36, 36,
171  37, 38, 38, 38, 38, 38, 39, 39,
172  38, 38, 39, 41, 43, 43, 42, 41,
173  40, 40, 39, 40, 41, 41, 39, 39,
174  40, 42, 47, 50, 47, 45, 46, 46,
175  44, 45, 46, 47, 49, 54, 58, 54,
176  48, 49, 54, 57, 60, 62, 63, 63,
177 };
178 
179 static const uint8_t dnxhd_1250_chroma_weight[] = {
180  0, 32, 35, 36, 36, 35, 36, 39,
181  41, 43, 45, 44, 41, 39, 40, 42,
182  43, 43, 45, 48, 49, 51, 52, 50,
183  50, 51, 51, 51, 51, 52, 53, 54,
184  51, 49, 51, 52, 52, 56, 57, 55,
185  54, 54, 55, 56, 55, 58, 58, 58,
186  60, 61, 62, 62, 59, 57, 58, 58,
187  61, 59, 59, 59, 60, 62, 63, 63,
188 };
189 
190 static const uint8_t dnxhd_1251_luma_weight[] = {
191  0, 32, 32, 34, 34, 34, 34, 35,
192  35, 35, 36, 37, 36, 36, 35, 36,
193  38, 38, 38, 38, 38, 38, 38, 38,
194  38, 38, 39, 41, 44, 43, 41, 40,
195  40, 40, 40, 39, 40, 41, 40, 39,
196  40, 43, 46, 46, 44, 44, 44, 42,
197  41, 43, 46, 48, 50, 55, 58, 53,
198  48, 50, 55, 58, 61, 62, 62, 62,
199 };
200 
201 static const uint8_t dnxhd_1251_chroma_weight[] = {
202  0, 32, 35, 36, 36, 35, 36, 39,
203  41, 43, 45, 44, 41, 39, 40, 42,
204  43, 43, 45, 48, 48, 48, 50, 50,
205  50, 51, 51, 51, 51, 52, 53, 54,
206  51, 49, 51, 52, 52, 56, 57, 55,
207  54, 54, 55, 56, 55, 58, 58, 58,
208  60, 61, 62, 62, 59, 57, 58, 58,
209  61, 59, 59, 59, 61, 62, 62, 62,
210 };
211 
212 /* Used in CID 1252, 1258 */
213 static const uint8_t dnxhd_1252_luma_weight[] = {
214  0, 32, 34, 35, 36, 36, 36, 37,
215  36, 37, 39, 40, 41, 40, 40, 40,
216  41, 41, 42, 41, 41, 43, 44, 44,
217  45, 46, 48, 55, 60, 57, 52, 50,
218  49, 49, 52, 52, 53, 55, 58, 62,
219  65, 73, 82, 82, 80, 78, 73, 68,
220  71, 82, 90, 90, 88, 87, 90, 95,
221  100, 107, 103, 97, 95, 93, 99, 99,
222 };
223 
224 /* Used in CID 1252, 1258 */
225 static const uint8_t dnxhd_1252_chroma_weight[] = {
226  0, 32, 35, 36, 37, 37, 38, 40,
227  42, 46, 49, 50, 50, 49, 49, 53,
228  56, 56, 57, 58, 60, 62, 64, 65,
229  63, 64, 64, 65, 66, 65, 67, 71,
230  72, 74, 74, 74, 74, 77, 81, 78,
231  72, 73, 82, 85, 89, 88, 84, 80,
232  90, 100, 90, 90, 88, 87, 90, 95,
233  114, 128, 125, 129, 134, 125, 116, 116,
234 };
235 
236 /* Used in CID 1244, 1260 */
237 static const uint8_t dnxhd_1260_luma_weight[] = {
238  0, 32, 33, 34, 36, 37, 37, 36,
239  34, 33, 34, 35, 37, 38, 40, 41,
240  40, 39, 38, 37, 34, 33, 34, 37,
241  40, 44, 48, 52, 53, 49, 47, 45,
242  42, 38, 36, 36, 38, 41, 43, 44,
243  46, 49, 52, 54, 54, 49, 44, 44,
244  44, 47, 51, 51, 52, 51, 48, 50,
245  52, 53, 53, 50, 50, 54, 54, 54,
246 };
247 
248 /* Used in CID 1244, 1260 */
249 static const uint8_t dnxhd_1260_chroma_weight[] = {
250  0, 32, 34, 38, 42, 40, 38, 36,
251  35, 35, 38, 42, 43, 43, 42, 40,
252  38, 39, 43, 43, 42, 41, 43, 43,
253  42, 44, 46, 45, 45, 46, 47, 46,
254  44, 44, 45, 46, 46, 46, 50, 50,
255  47, 47, 49, 49, 49, 49, 51, 53,
256  51, 49, 53, 57, 56, 52, 50, 52,
257  56, 56, 53, 53, 53, 54, 58, 58,
258 };
259 
260 /* Used in CID 1235, 1236, 1241, 1250, 1256, 1257, 1270, 1271 */
261 static const uint8_t dnxhd_1235_dc_codes[14] = {
262  10, 62, 11, 12, 13, 0, 1, 2, 3, 4, 14, 30, 126, 127,
263 };
264 
265 /* Used in CID 1235, 1236, 1241, 1250, 1256, 1257, 1270, 1271 */
266 static const uint8_t dnxhd_1235_dc_bits[14] = {
267  4, 6, 4, 4, 4, 3, 3, 3, 3, 3, 4, 5, 7, 7,
268 };
269 
270 /* Used in CID 1237, 1238, 1242, 1243, 1251, 1252, 1253, 1258, 1259, 1260, 1272, 1273, 1274 */
271 static const uint8_t dnxhd_1237_dc_codes[12] = {
272  0, 12, 13, 1, 2, 3, 4, 5, 14, 30, 62, 63,
273 };
274 
275 /* Used in CID 1237, 1238, 1242, 1243, 1251, 1252, 1253, 1258, 1259, 1260, 1272, 1273, 1274 */
276 static const uint8_t dnxhd_1237_dc_bits[12] = {
277  3, 4, 4, 3, 3, 3, 3, 3, 4, 5, 6, 6,
278 };
279 
280 /* Used in CID 1237, 1242, 1253, 1259, 1260, 1273, 1274 */
281 static const uint16_t dnxhd_1237_ac_codes[257] = {
282  0, 1, 4, 5, 12, 26, 27, 56,
283  57, 58, 59, 120, 121, 244, 245, 246,
284  247, 248, 498, 499, 500, 501, 502, 1006,
285  1007, 1008, 1009, 1010, 1011, 2024, 2025, 2026,
286  2027, 2028, 2029, 2030, 2031, 4064, 4065, 4066,
287  4067, 4068, 4069, 4070, 4071, 4072, 4073, 8148,
288  8149, 8150, 8151, 8152, 8153, 8154, 8155, 8156,
289  8157, 8158, 16318, 16319, 16320, 16321, 16322, 16323,
290  16324, 16325, 16326, 16327, 16328, 16329, 16330, 16331,
291  16332, 16333, 32668, 32669, 32670, 32671, 32672, 32673,
292  32674, 32675, 32676, 32677, 32678, 32679, 32680, 32681,
293  32682, 32683, 32684, 65370, 65371, 65372, 65373, 65374,
294  65375, 65376, 65377, 65378, 65379, 65380, 65381, 65382,
295  65383, 65384, 65385, 65386, 65387, 65388, 65389, 65390,
296  65391, 65392, 65393, 65394, 65395, 65396, 65397, 65398,
297  65399, 65400, 65401, 65402, 65403, 65404, 65405, 65406,
298  65407, 65408, 65409, 65410, 65411, 65412, 65413, 65414,
299  65415, 65416, 65417, 65418, 65419, 65420, 65421, 65422,
300  65423, 65424, 65425, 65426, 65427, 65428, 65429, 65430,
301  65431, 65432, 65433, 65434, 65435, 65436, 65437, 65438,
302  65439, 65440, 65441, 65442, 65443, 65444, 65445, 65446,
303  65447, 65448, 65449, 65450, 65451, 65452, 65453, 65454,
304  65455, 65456, 65457, 65458, 65459, 65460, 65461, 65462,
305  65463, 65464, 65465, 65466, 65467, 65468, 65469, 65470,
306  65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478,
307  65479, 65480, 65481, 65482, 65483, 65484, 65485, 65486,
308  65487, 65488, 65489, 65490, 65491, 65492, 65493, 65494,
309  65495, 65496, 65497, 65498, 65499, 65500, 65501, 65502,
310  65503, 65504, 65505, 65506, 65507, 65508, 65509, 65510,
311  65511, 65512, 65513, 65514, 65515, 65516, 65517, 65518,
312  65519, 65520, 65521, 65522, 65523, 65524, 65525, 65526,
313  65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534,
314  65535,
315 };
316 
317 /* Used in CID 1237, 1242, 1253, 1259, 1260, 1273, 1274 */
318 static const uint8_t dnxhd_1237_ac_bits[257] = {
319  2, 2, 3, 3, 4, 5, 5, 6, 6, 6, 6, 7, 7, 8, 8, 8,
320  8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 11, 11, 11,
321  11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13,
322  13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14,
323  14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15,
324  15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16,
325  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
326  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
327  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
328  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
329  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
330  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
331  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
332  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
333  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
334  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
335  16,
336 };
337 
338 /* Used in CID 1237, 1242, 1253, 1259, 1260, 1273, 1274 */
339 static const uint8_t dnxhd_1237_ac_info[2*257] = {
340  3, 0, 3, 2, 5, 0, 0, 0, 7, 0, 9, 0, 5, 2, 11, 0,
341  13, 0, 15, 0, 7, 2, 17, 0, 19, 0, 21, 0, 23, 0, 25, 0,
342  9, 2, 11, 2, 27, 0, 29, 0, 31, 0, 33, 0, 13, 2, 35, 0,
343  37, 0, 39, 0, 41, 0, 43, 0, 15, 2, 45, 0, 47, 0, 49, 0,
344  51, 0, 53, 0, 55, 0, 17, 2, 19, 2, 57, 0, 59, 0, 61, 0,
345  63, 0, 65, 0, 67, 0, 69, 0, 21, 2, 23, 2, 25, 2, 71, 0,
346  73, 0, 75, 0, 77, 0, 79, 0, 81, 0, 83, 0, 27, 2, 29, 2,
347  31, 2, 33, 2, 85, 0, 87, 0, 89, 0, 91, 0, 93, 0, 95, 0,
348  97, 0, 99, 0, 101, 0, 103, 0, 105, 0, 35, 2, 37, 2, 39, 2,
349  41, 2, 43, 2, 107, 0, 109, 0, 111, 0, 113, 0, 115, 0, 117, 0,
350  119, 0, 121, 0, 123, 0, 129, 0, 3, 1, 45, 2, 47, 2, 49, 2,
351  51, 2, 53, 2, 55, 2, 125, 0, 127, 0, 5, 1, 7, 1, 9, 1,
352  11, 1, 13, 1, 15, 1, 17, 1, 19, 1, 21, 1, 23, 1, 25, 1,
353  27, 1, 29, 1, 31, 1, 33, 1, 35, 1, 37, 1, 39, 1, 41, 1,
354  43, 1, 45, 1, 47, 1, 49, 1, 51, 1, 53, 1, 55, 1, 57, 1,
355  59, 1, 61, 1, 63, 1, 65, 1, 67, 1, 69, 1, 71, 1, 73, 1,
356  75, 1, 77, 1, 79, 1, 81, 1, 83, 1, 85, 1, 87, 1, 89, 1,
357  91, 1, 93, 1, 95, 1, 97, 1, 99, 1, 101, 1, 103, 1, 105, 1,
358  107, 1, 109, 1, 111, 1, 113, 1, 115, 1, 117, 1, 119, 1, 121, 1,
359  123, 1, 125, 1, 127, 1, 129, 1, 57, 2, 59, 2, 61, 2, 63, 2,
360  65, 2, 67, 2, 69, 2, 71, 2, 73, 2, 75, 2, 77, 2, 79, 2,
361  81, 2, 83, 2, 85, 2, 87, 2, 89, 2, 91, 2, 93, 2, 95, 2,
362  97, 2, 99, 2, 101, 2, 103, 2, 105, 2, 107, 2, 109, 2, 111, 2,
363  113, 2, 115, 2, 117, 2, 119, 2, 121, 2, 123, 2, 125, 2, 127, 2,
364  129, 2, 3, 3, 5, 3, 7, 3, 9, 3, 11, 3, 13, 3, 15, 3,
365  17, 3, 19, 3, 21, 3, 23, 3, 25, 3, 27, 3, 29, 3, 31, 3,
366  33, 3, 35, 3, 37, 3, 39, 3, 41, 3, 43, 3, 45, 3, 47, 3,
367  49, 3, 51, 3, 53, 3, 55, 3, 57, 3, 59, 3, 61, 3, 63, 3,
368  65, 3, 67, 3, 69, 3, 71, 3, 73, 3, 75, 3, 77, 3, 79, 3,
369  81, 3, 83, 3, 85, 3, 87, 3, 89, 3, 91, 3, 93, 3, 95, 3,
370  97, 3, 99, 3, 101, 3, 103, 3, 105, 3, 107, 3, 109, 3, 111, 3,
371  113, 3, 115, 3, 117, 3, 119, 3, 121, 3, 123, 3, 125, 3, 127, 3,
372  129, 3,
373 };
374 
375 /* Used in CID 1238, 1240, 1243, 1272 */
376 static const uint16_t dnxhd_1238_ac_codes[257] = {
377  0, 1, 4, 10, 11, 24, 25, 26,
378  54, 55, 56, 57, 116, 117, 118, 119,
379  240, 241, 242, 243, 244, 245, 492, 493,
380  494, 495, 496, 497, 498, 499, 1000, 1001,
381  1002, 1003, 1004, 1005, 1006, 1007, 1008, 2018,
382  2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026,
383  2027, 4056, 4057, 4058, 4059, 4060, 4061, 4062,
384  4063, 4064, 4065, 4066, 4067, 4068, 4069, 8140,
385  8141, 8142, 8143, 8144, 8145, 8146, 8147, 8148,
386  8149, 8150, 8151, 8152, 8153, 8154, 8155, 8156,
387  16314, 16315, 16316, 16317, 16318, 16319, 16320, 16321,
388  16322, 16323, 16324, 16325, 16326, 16327, 16328, 16329,
389  16330, 16331, 16332, 16333, 16334, 16335, 16336, 16337,
390  16338, 32678, 32679, 32680, 32681, 32682, 32683, 32684,
391  32685, 32686, 32687, 32688, 32689, 32690, 32691, 32692,
392  32693, 32694, 32695, 32696, 32697, 32698, 32699, 32700,
393  32701, 32702, 32703, 32704, 32705, 65412, 65413, 65414,
394  65415, 65416, 65417, 65418, 65419, 65420, 65421, 65422,
395  65423, 65424, 65425, 65426, 65427, 65428, 65429, 65430,
396  65431, 65432, 65433, 65434, 65435, 65436, 65437, 65438,
397  65439, 65440, 65441, 65442, 65443, 65444, 65445, 65446,
398  65447, 65448, 65449, 65450, 65451, 65452, 65453, 65454,
399  65455, 65456, 65457, 65458, 65459, 65460, 65461, 65462,
400  65463, 65464, 65465, 65466, 65467, 65468, 65469, 65470,
401  65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478,
402  65479, 65480, 65481, 65482, 65483, 65484, 65485, 65486,
403  65487, 65488, 65489, 65490, 65491, 65492, 65493, 65494,
404  65495, 65496, 65497, 65498, 65499, 65500, 65501, 65502,
405  65503, 65504, 65505, 65506, 65507, 65508, 65509, 65510,
406  65511, 65512, 65513, 65514, 65515, 65516, 65517, 65518,
407  65519, 65520, 65521, 65522, 65523, 65524, 65525, 65526,
408  65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534,
409  65535,
410 };
411 
412 /* Used in CID 1238, 1240, 1243, 1272 */
413 static const uint8_t dnxhd_1238_ac_bits[257] = {
414  2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7,
415  8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10,
416  10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11,
417  11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13,
418  13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
419  14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
420  14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15,
421  15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
422  15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
423  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
424  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
425  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
426  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
427  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
428  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
429  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
430  16,
431 };
432 
433 /* Used in CID 1238, 1240, 1243, 1272 */
434 static const uint8_t dnxhd_1238_ac_info[2*257] = {
435  3, 0, 3, 2, 5, 0, 7, 0, 0, 0, 9, 0, 11, 0, 5, 2,
436  13, 0, 15, 0, 17, 0, 7, 2, 19, 0, 21, 0, 23, 0, 9, 2,
437  25, 0, 27, 0, 29, 0, 31, 0, 33, 0, 11, 2, 35, 0, 37, 0,
438  39, 0, 41, 0, 43, 0, 45, 0, 13, 2, 15, 2, 47, 0, 49, 0,
439  51, 0, 53, 0, 55, 0, 57, 0, 59, 0, 17, 2, 19, 2, 61, 0,
440  63, 0, 65, 0, 67, 0, 69, 0, 71, 0, 73, 0, 75, 0, 21, 2,
441  23, 2, 77, 0, 79, 0, 81, 0, 83, 0, 85, 0, 87, 0, 89, 0,
442  91, 0, 93, 0, 95, 0, 97, 0, 25, 2, 27, 2, 29, 2, 99, 0,
443  101, 0, 103, 0, 105, 0, 107, 0, 109, 0, 111, 0, 113, 0, 115, 0,
444  117, 0, 119, 0, 121, 0, 123, 0, 31, 2, 33, 2, 35, 2, 37, 2,
445  125, 0, 127, 0, 129, 0, 3, 1, 5, 1, 7, 1, 9, 1, 11, 1,
446  13, 1, 15, 1, 17, 1, 19, 1, 21, 1, 23, 1, 25, 1, 27, 1,
447  29, 1, 31, 1, 33, 1, 39, 2, 41, 2, 43, 2, 45, 2, 47, 2,
448  49, 2, 35, 1, 37, 1, 39, 1, 41, 1, 43, 1, 45, 1, 47, 1,
449  49, 1, 51, 1, 53, 1, 55, 1, 57, 1, 59, 1, 61, 1, 63, 1,
450  65, 1, 67, 1, 69, 1, 71, 1, 73, 1, 75, 1, 81, 1, 51, 2,
451  53, 2, 55, 2, 57, 2, 59, 2, 61, 2, 77, 1, 79, 1, 83, 1,
452  85, 1, 87, 1, 89, 1, 91, 1, 93, 1, 95, 1, 97, 1, 99, 1,
453  101, 1, 103, 1, 105, 1, 107, 1, 109, 1, 111, 1, 113, 1, 115, 1,
454  117, 1, 119, 1, 121, 1, 123, 1, 125, 1, 127, 1, 129, 1, 63, 2,
455  65, 2, 67, 2, 69, 2, 71, 2, 73, 2, 75, 2, 77, 2, 79, 2,
456  81, 2, 83, 2, 85, 2, 87, 2, 89, 2, 91, 2, 93, 2, 95, 2,
457  97, 2, 99, 2, 101, 2, 103, 2, 105, 2, 107, 2, 109, 2, 111, 2,
458  113, 2, 115, 2, 117, 2, 119, 2, 121, 2, 123, 2, 125, 2, 127, 2,
459  129, 2, 3, 3, 5, 3, 7, 3, 9, 3, 11, 3, 13, 3, 15, 3,
460  17, 3, 19, 3, 21, 3, 23, 3, 25, 3, 27, 3, 29, 3, 31, 3,
461  33, 3, 35, 3, 37, 3, 39, 3, 41, 3, 43, 3, 45, 3, 47, 3,
462  49, 3, 51, 3, 53, 3, 55, 3, 57, 3, 59, 3, 61, 3, 63, 3,
463  65, 3, 67, 3, 69, 3, 71, 3, 73, 3, 75, 3, 77, 3, 79, 3,
464  81, 3, 83, 3, 85, 3, 87, 3, 89, 3, 91, 3, 93, 3, 95, 3,
465  97, 3, 99, 3, 101, 3, 103, 3, 105, 3, 107, 3, 109, 3, 111, 3,
466  113, 3, 115, 3, 117, 3, 119, 3, 121, 3, 123, 3, 125, 3, 127, 3,
467  129, 3,
468 }; /* 0 is EOB */
469 
470 /* Used in CID 1235, 1236, 1241, 1256, 1257, 1270, 1271 */
471 static const uint16_t dnxhd_1235_ac_codes[257] = {
472  0, 1, 4, 10, 11, 24, 25, 26,
473  54, 55, 56, 57, 116, 117, 118, 119,
474  240, 241, 242, 243, 244, 245, 492, 493,
475  494, 495, 496, 497, 498, 998, 999, 1000,
476  1001, 1002, 1003, 1004, 1005, 1006, 1007, 2016,
477  2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024,
478  2025, 2026, 4054, 4055, 4056, 4057, 4058, 4059,
479  4060, 4061, 4062, 4063, 4064, 4065, 4066, 4067,
480  4068, 4069, 8140, 8141, 8142, 8143, 8144, 8145,
481  8146, 8147, 8148, 8149, 8150, 8151, 8152, 8153,
482  8154, 8155, 8156, 8157, 16316, 16317, 16318, 16319,
483  16320, 16321, 16322, 16323, 16324, 16325, 16326, 16327,
484  16328, 16329, 16330, 16331, 16332, 16333, 16334, 16335,
485  16336, 16337, 32676, 32677, 32678, 32679, 32680, 32681,
486  32682, 32683, 32684, 32685, 32686, 32687, 32688, 32689,
487  32690, 32691, 32692, 32693, 32694, 32695, 32696, 32697,
488  32698, 32699, 32700, 32701, 32702, 32703, 32704, 32705,
489  32706, 32707, 32708, 65418, 65419, 65420, 65421, 65422,
490  65423, 65424, 65425, 65426, 65427, 65428, 65429, 65430,
491  65431, 65432, 65433, 65434, 65435, 65436, 65437, 65438,
492  65439, 65440, 65441, 65442, 65443, 65444, 65445, 65446,
493  65447, 65448, 65449, 65450, 65451, 65452, 65453, 65454,
494  65455, 65456, 65457, 65458, 65459, 65460, 65461, 65462,
495  65463, 65464, 65465, 65466, 65467, 65468, 65469, 65470,
496  65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478,
497  65479, 65480, 65481, 65482, 65483, 65484, 65485, 65486,
498  65487, 65488, 65489, 65490, 65491, 65492, 65493, 65494,
499  65495, 65496, 65497, 65498, 65499, 65500, 65501, 65502,
500  65503, 65504, 65505, 65506, 65507, 65508, 65509, 65510,
501  65511, 65512, 65513, 65514, 65515, 65516, 65517, 65518,
502  65519, 65520, 65521, 65522, 65523, 65524, 65525, 65526,
503  65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534,
504  65535,
505 };
506 
507 /* Used in CID 1235, 1236, 1241, 1256, 1257, 1270, 1271 */
508 static const uint8_t dnxhd_1235_ac_bits[257] = {
509  2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7,
510  8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10,
511  10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11,
512  11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
513  12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
514  13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
515  14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15,
516  15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
517  15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16,
518  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
519  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
520  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
521  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
522  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
523  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
524  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
525  16,
526 };
527 
528 /* Used in CID 1235, 1241, 1256, 1270, 1271 */
529 static const uint8_t dnxhd_1235_ac_info[2*257] = {
530  3, 0, 3, 2, 5, 0, 7, 0, 0, 0, 9, 0, 11, 0, 5, 2,
531  13, 0, 15, 0, 17, 0, 7, 2, 19, 0, 21, 0, 23, 0, 9, 2,
532  25, 0, 27, 0, 29, 0, 31, 0, 33, 0, 11, 2, 35, 0, 37, 0,
533  39, 0, 41, 0, 43, 0, 13, 2, 15, 2, 45, 0, 47, 0, 49, 0,
534  51, 0, 53, 0, 55, 0, 57, 0, 59, 0, 17, 2, 19, 2, 61, 0,
535  63, 0, 65, 0, 67, 0, 69, 0, 71, 0, 73, 0, 75, 0, 77, 0,
536  21, 2, 23, 2, 79, 0, 81, 0, 83, 0, 85, 0, 87, 0, 89, 0,
537  91, 0, 93, 0, 95, 0, 97, 0, 99, 0, 101, 0, 25, 2, 27, 2,
538  29, 2, 31, 2, 103, 0, 105, 0, 107, 0, 109, 0, 111, 0, 113, 0,
539  115, 0, 117, 0, 119, 0, 121, 0, 123, 0, 125, 0, 127, 0, 3, 1,
540  33, 2, 35, 2, 37, 2, 39, 2, 129, 0, 5, 1, 7, 1, 9, 1,
541  11, 1, 13, 1, 15, 1, 17, 1, 19, 1, 21, 1, 23, 1, 25, 1,
542  27, 1, 29, 1, 31, 1, 33, 1, 35, 1, 41, 2, 43, 2, 45, 2,
543  47, 2, 49, 2, 37, 1, 39, 1, 41, 1, 43, 1, 45, 1, 47, 1,
544  49, 1, 51, 1, 53, 1, 55, 1, 57, 1, 59, 1, 61, 1, 63, 1,
545  65, 1, 67, 1, 69, 1, 71, 1, 73, 1, 75, 1, 77, 1, 79, 1,
546  81, 1, 83, 1, 85, 1, 51, 2, 53, 2, 55, 2, 57, 2, 59, 2,
547  61, 2, 63, 2, 65, 2, 87, 1, 89, 1, 91, 1, 93, 1, 95, 1,
548  97, 1, 99, 1, 101, 1, 103, 1, 105, 1, 107, 1, 109, 1, 111, 1,
549  113, 1, 115, 1, 117, 1, 119, 1, 121, 1, 123, 1, 125, 1, 127, 1,
550  129, 1, 67, 2, 69, 2, 71, 2, 73, 2, 75, 2, 77, 2, 79, 2,
551  81, 2, 83, 2, 85, 2, 87, 2, 89, 2, 91, 2, 93, 2, 95, 2,
552  97, 2, 99, 2, 101, 2, 103, 2, 105, 2, 107, 2, 109, 2, 111, 2,
553  113, 2, 115, 2, 117, 2, 119, 2, 121, 2, 123, 2, 125, 2, 127, 2,
554  129, 2, 3, 3, 5, 3, 7, 3, 9, 3, 11, 3, 13, 3, 15, 3,
555  17, 3, 19, 3, 21, 3, 23, 3, 25, 3, 27, 3, 29, 3, 31, 3,
556  33, 3, 35, 3, 37, 3, 39, 3, 41, 3, 43, 3, 45, 3, 47, 3,
557  49, 3, 51, 3, 53, 3, 55, 3, 57, 3, 59, 3, 61, 3, 63, 3,
558  65, 3, 67, 3, 69, 3, 71, 3, 73, 3, 75, 3, 77, 3, 79, 3,
559  81, 3, 83, 3, 85, 3, 87, 3, 89, 3, 91, 3, 93, 3, 95, 3,
560  97, 3, 99, 3, 101, 3, 103, 3, 105, 3, 107, 3, 109, 3, 111, 3,
561  113, 3, 115, 3, 117, 3, 119, 3, 121, 3, 123, 3, 125, 3, 127, 3,
562  129, 3,
563 };
564 
565 static const uint16_t dnxhd_1250_ac_codes[257] = {
566  0, 1, 4, 10, 11, 24, 25, 26,
567  54, 55, 56, 57, 116, 117, 118, 119,
568  240, 241, 242, 243, 244, 245, 492, 493,
569  494, 495, 496, 497, 498, 998, 999, 1000,
570  1001, 1002, 1003, 1004, 1005, 1006, 2014, 2015,
571  2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023,
572  2024, 2025, 4052, 4053, 4054, 4055, 4056, 4057,
573  4058, 4059, 4060, 4061, 4062, 4063, 4064, 4065,
574  4066, 4067, 8136, 8137, 8138, 8139, 8140, 8141,
575  8142, 8143, 8144, 8145, 8146, 8147, 8148, 8149,
576  8150, 8151, 8152, 8153, 8154, 8155, 8156, 16314,
577  16315, 16316, 16317, 16318, 16319, 16320, 16321, 16322,
578  16323, 16324, 16325, 16326, 16327, 16328, 16329, 16330,
579  16331, 16332, 16333, 16334, 16335, 16336, 16337, 16338,
580  32678, 32679, 32680, 32681, 32682, 32683, 32684, 32685,
581  32686, 32687, 32688, 32689, 32690, 32691, 32692, 32693,
582  32694, 32695, 32696, 32697, 32698, 32699, 32700, 32701,
583  32702, 32703, 32704, 32705, 32706, 32707, 32708, 32709,
584  32710, 32711, 32712, 65426, 65427, 65428, 65429, 65430,
585  65431, 65432, 65433, 65434, 65435, 65436, 65437, 65438,
586  65439, 65440, 65441, 65442, 65443, 65444, 65445, 65446,
587  65447, 65448, 65449, 65450, 65451, 65452, 65453, 65454,
588  65455, 65456, 65457, 65458, 65459, 65460, 65461, 65462,
589  65463, 65464, 65465, 65466, 65467, 65468, 65469, 65470,
590  65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478,
591  65479, 65480, 65481, 65482, 65483, 65484, 65485, 65486,
592  65487, 65488, 65489, 65490, 65491, 65492, 65493, 65494,
593  65495, 65496, 65497, 65498, 65499, 65500, 65501, 65502,
594  65503, 65504, 65505, 65506, 65507, 65508, 65509, 65510,
595  65511, 65512, 65513, 65514, 65515, 65516, 65517, 65518,
596  65519, 65520, 65521, 65522, 65523, 65524, 65525, 65526,
597  65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534,
598  65535
599 };
600 static const uint8_t dnxhd_1250_ac_bits[257] = {
601  2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7,
602  8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10,
603  10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
604  11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
605  12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
606  13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14,
607  14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
608  15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
609  15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
610  15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
611  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
612  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
613  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
614  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
615  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
616  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
617  16
618 };
619 
620 static const uint8_t dnxhd_1250_ac_info[2*257] = {
621  3, 0, 3, 2, 5, 0, 7, 0, 0, 0, 9, 0, 11, 0, 5, 2,
622  13, 0, 15, 0, 17, 0, 7, 2, 19, 0, 21, 0, 23, 0, 9, 2,
623  25, 0, 27, 0, 29, 0, 31, 0, 33, 0, 11, 2, 35, 0, 37, 0,
624  39, 0, 41, 0, 43, 0, 45, 0, 13, 2, 47, 0, 49, 0, 51, 0,
625  53, 0, 55, 0, 57, 0, 59, 0, 15, 2, 17, 2, 61, 0, 63, 0,
626  65, 0, 67, 0, 69, 0, 71, 0, 73, 0, 75, 0, 77, 0, 79, 0,
627  19, 2, 21, 2, 81, 0, 83, 0, 85, 0, 87, 0, 89, 0, 91, 0,
628  93, 0, 95, 0, 97, 0, 99, 0, 101, 0, 103, 0, 105, 0, 23, 2,
629  25, 2, 27, 2, 107, 0, 109, 0, 111, 0, 113, 0, 115, 0, 117, 0,
630  119, 0, 121, 0, 123, 0, 125, 0, 127, 0, 129, 0, 3, 1, 5, 1,
631  7, 1, 9, 1, 11, 1, 29, 2, 31, 2, 33, 2, 35, 2, 13, 1,
632  15, 1, 17, 1, 19, 1, 21, 1, 23, 1, 25, 1, 27, 1, 29, 1,
633  31, 1, 33, 1, 35, 1, 37, 1, 39, 1, 41, 1, 43, 1, 45, 1,
634  47, 1, 49, 1, 51, 1, 53, 1, 37, 2, 39, 2, 41, 2, 43, 2,
635  55, 1, 57, 1, 59, 1, 61, 1, 63, 1, 65, 1, 67, 1, 69, 1,
636  71, 1, 73, 1, 75, 1, 77, 1, 79, 1, 81, 1, 83, 1, 85, 1,
637  87, 1, 89, 1, 91, 1, 93, 1, 95, 1, 97, 1, 99, 1, 101, 1,
638  103, 1, 105, 1, 107, 1, 111, 1, 113, 1, 45, 2, 47, 2, 49, 2,
639  51, 2, 53, 2, 55, 2, 109, 1, 115, 1, 117, 1, 119, 1, 121, 1,
640  123, 1, 125, 1, 127, 1, 129, 1, 57, 2, 59, 2, 61, 2, 63, 2,
641  65, 2, 67, 2, 69, 2, 71, 2, 73, 2, 75, 2, 77, 2, 79, 2,
642  81, 2, 83, 2, 85, 2, 87, 2, 89, 2, 91, 2, 93, 2, 95, 2,
643  97, 2, 99, 2, 101, 2, 103, 2, 105, 2, 107, 2, 109, 2, 111, 2,
644  113, 2, 115, 2, 117, 2, 119, 2, 121, 2, 123, 2, 125, 2, 127, 2,
645  129, 2, 3, 3, 5, 3, 7, 3, 9, 3, 11, 3, 13, 3, 15, 3,
646  17, 3, 19, 3, 21, 3, 23, 3, 25, 3, 27, 3, 29, 3, 31, 3,
647  33, 3, 35, 3, 37, 3, 39, 3, 41, 3, 43, 3, 45, 3, 47, 3,
648  49, 3, 51, 3, 53, 3, 55, 3, 57, 3, 59, 3, 61, 3, 63, 3,
649  65, 3, 67, 3, 69, 3, 71, 3, 73, 3, 75, 3, 77, 3, 79, 3,
650  81, 3, 83, 3, 85, 3, 87, 3, 89, 3, 91, 3, 93, 3, 95, 3,
651  97, 3, 99, 3, 101, 3, 103, 3, 105, 3, 107, 3, 109, 3, 111, 3,
652  113, 3, 115, 3, 117, 3, 119, 3, 121, 3, 123, 3, 125, 3, 127, 3,
653  129, 3,
654 };
655 
656 static const uint16_t dnxhd_1251_ac_codes[257] = {
657  0, 1, 4, 10, 11, 24, 25, 26,
658  54, 55, 56, 57, 116, 117, 118, 119,
659  240, 241, 242, 243, 244, 245, 492, 493,
660  494, 495, 496, 497, 996, 997, 998, 999,
661  1000, 1001, 1002, 1003, 1004, 1005, 2012, 2013,
662  2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021,
663  2022, 2023, 2024, 2025, 4052, 4053, 4054, 4055,
664  4056, 4057, 4058, 4059, 4060, 4061, 4062, 4063,
665  4064, 4065, 4066, 8134, 8135, 8136, 8137, 8138,
666  8139, 8140, 8141, 8142, 8143, 8144, 8145, 8146,
667  8147, 8148, 8149, 8150, 8151, 8152, 8153, 8154,
668  8155, 8156, 16314, 16315, 16316, 16317, 16318, 16319,
669  16320, 16321, 16322, 16323, 16324, 16325, 16326, 16327,
670  16328, 16329, 16330, 16331, 16332, 16333, 16334, 16335,
671  16336, 16337, 16338, 16339, 32680, 32681, 32682, 32683,
672  32684, 32685, 32686, 32687, 32688, 32689, 32690, 32691,
673  32692, 32693, 32694, 32695, 32696, 32697, 32698, 32699,
674  32700, 32701, 32702, 32703, 32704, 32705, 32706, 32707,
675  32708, 32709, 32710, 32711, 32712, 32713, 32714, 65430,
676  65431, 65432, 65433, 65434, 65435, 65436, 65437, 65438,
677  65439, 65440, 65441, 65442, 65443, 65444, 65445, 65446,
678  65447, 65448, 65449, 65450, 65451, 65452, 65453, 65454,
679  65455, 65456, 65457, 65458, 65459, 65460, 65461, 65462,
680  65463, 65464, 65465, 65466, 65467, 65468, 65469, 65470,
681  65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478,
682  65479, 65480, 65481, 65482, 65483, 65484, 65485, 65486,
683  65487, 65488, 65489, 65490, 65491, 65492, 65493, 65494,
684  65495, 65496, 65497, 65498, 65499, 65500, 65501, 65502,
685  65503, 65504, 65505, 65506, 65507, 65508, 65509, 65510,
686  65511, 65512, 65513, 65514, 65515, 65516, 65517, 65518,
687  65519, 65520, 65521, 65522, 65523, 65524, 65525, 65526,
688  65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534,
689  65535,
690 };
691 
692 static const uint8_t dnxhd_1251_ac_bits[257] = {
693  2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7,
694  8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10,
695  10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
696  11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
697  12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
698  13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14,
699  14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
700  14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
701  15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
702  15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16,
703  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
704  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
705  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
706  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
707  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
708  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
709  16,
710 };
711 
712 static const uint8_t dnxhd_1251_ac_info[2*257] = {
713  3, 0, 3, 2, 5, 0, 7, 0, 0, 0, 9, 0, 11, 0, 5, 2,
714  13, 0, 15, 0, 17, 0, 7, 2, 19, 0, 21, 0, 23, 0, 9, 2,
715  25, 0, 27, 0, 29, 0, 31, 0, 33, 0, 11, 2, 35, 0, 37, 0,
716  39, 0, 41, 0, 43, 0, 13, 2, 45, 0, 47, 0, 49, 0, 51, 0,
717  53, 0, 55, 0, 57, 0, 59, 0, 15, 2, 17, 2, 61, 0, 63, 0,
718  65, 0, 67, 0, 69, 0, 71, 0, 73, 0, 75, 0, 77, 0, 79, 0,
719  81, 0, 19, 2, 21, 2, 23, 2, 83, 0, 85, 0, 87, 0, 89, 0,
720  91, 0, 93, 0, 95, 0, 97, 0, 99, 0, 101, 0, 103, 0, 105, 0,
721  25, 2, 27, 2, 29, 2, 107, 0, 109, 0, 111, 0, 113, 0, 115, 0,
722  117, 0, 119, 0, 121, 0, 123, 0, 125, 0, 127, 0, 129, 0, 3, 1,
723  5, 1, 7, 1, 9, 1, 11, 1, 13, 1, 15, 1, 17, 1, 31, 2,
724  33, 2, 35, 2, 19, 1, 21, 1, 23, 1, 25, 1, 27, 1, 29, 1,
725  31, 1, 33, 1, 35, 1, 37, 1, 39, 1, 41, 1, 43, 1, 45, 1,
726  47, 1, 49, 1, 51, 1, 53, 1, 55, 1, 57, 1, 59, 1, 37, 2,
727  39, 2, 41, 2, 43, 2, 45, 2, 61, 1, 63, 1, 65, 1, 67, 1,
728  69, 1, 71, 1, 73, 1, 75, 1, 77, 1, 79, 1, 81, 1, 83, 1,
729  85, 1, 87, 1, 89, 1, 91, 1, 93, 1, 95, 1, 97, 1, 99, 1,
730  101, 1, 103, 1, 105, 1, 107, 1, 109, 1, 111, 1, 113, 1, 115, 1,
731  117, 1, 47, 2, 49, 2, 51, 2, 53, 2, 55, 2, 57, 2, 119, 1,
732  121, 1, 123, 1, 125, 1, 127, 1, 129, 1, 59, 2, 61, 2, 63, 2,
733  65, 2, 67, 2, 69, 2, 71, 2, 73, 2, 75, 2, 77, 2, 79, 2,
734  81, 2, 83, 2, 85, 2, 87, 2, 89, 2, 91, 2, 93, 2, 95, 2,
735  97, 2, 99, 2, 101, 2, 103, 2, 105, 2, 107, 2, 109, 2, 111, 2,
736  113, 2, 115, 2, 117, 2, 119, 2, 121, 2, 123, 2, 125, 2, 127, 2,
737  129, 2, 3, 3, 5, 3, 7, 3, 9, 3, 11, 3, 13, 3, 15, 3,
738  17, 3, 19, 3, 21, 3, 23, 3, 25, 3, 27, 3, 29, 3, 31, 3,
739  33, 3, 35, 3, 37, 3, 39, 3, 41, 3, 43, 3, 45, 3, 47, 3,
740  49, 3, 51, 3, 53, 3, 55, 3, 57, 3, 59, 3, 61, 3, 63, 3,
741  65, 3, 67, 3, 69, 3, 71, 3, 73, 3, 75, 3, 77, 3, 79, 3,
742  81, 3, 83, 3, 85, 3, 87, 3, 89, 3, 91, 3, 93, 3, 95, 3,
743  97, 3, 99, 3, 101, 3, 103, 3, 105, 3, 107, 3, 109, 3, 111, 3,
744  113, 3, 115, 3, 117, 3, 119, 3, 121, 3, 123, 3, 125, 3, 127, 3,
745  129, 3,
746 };
747 
748 /* Used in CID 1252, 1258 */
749 static const uint16_t dnxhd_1252_ac_codes[257] = {
750  0, 1, 4, 10, 11, 12, 26, 27,
751  56, 57, 58, 118, 119, 120, 242, 243,
752  244, 245, 246, 247, 496, 497, 498, 499,
753  500, 1002, 1003, 1004, 1005, 1006, 1007, 1008,
754  1009, 2020, 2021, 2022, 2023, 2024, 2025, 2026,
755  2027, 2028, 2029, 4060, 4061, 4062, 4063, 4064,
756  4065, 4066, 4067, 4068, 4069, 4070, 4071, 8144,
757  8145, 8146, 8147, 8148, 8149, 8150, 8151, 8152,
758  8153, 8154, 8155, 8156, 8157, 8158, 16318, 16319,
759  16320, 16321, 16322, 16323, 16324, 16325, 16326, 16327,
760  16328, 16329, 16330, 16331, 16332, 16333, 16334, 16335,
761  32672, 32673, 32674, 32675, 32676, 32677, 32678, 32679,
762  32680, 32681, 32682, 32683, 32684, 32685, 32686, 32687,
763  32688, 32689, 32690, 32691, 32692, 32693, 32694, 65390,
764  65391, 65392, 65393, 65394, 65395, 65396, 65397, 65398,
765  65399, 65400, 65401, 65402, 65403, 65404, 65405, 65406,
766  65407, 65408, 65409, 65410, 65411, 65412, 65413, 65414,
767  65415, 65416, 65417, 65418, 65419, 65420, 65421, 65422,
768  65423, 65424, 65425, 65426, 65427, 65428, 65429, 65430,
769  65431, 65432, 65433, 65434, 65435, 65436, 65437, 65438,
770  65439, 65440, 65441, 65442, 65443, 65444, 65445, 65446,
771  65447, 65448, 65449, 65450, 65451, 65452, 65453, 65454,
772  65455, 65456, 65457, 65458, 65459, 65460, 65461, 65462,
773  65463, 65464, 65465, 65466, 65467, 65468, 65469, 65470,
774  65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478,
775  65479, 65480, 65481, 65482, 65483, 65484, 65485, 65486,
776  65487, 65488, 65489, 65490, 65491, 65492, 65493, 65494,
777  65495, 65496, 65497, 65498, 65499, 65500, 65501, 65502,
778  65503, 65504, 65505, 65506, 65507, 65508, 65509, 65510,
779  65511, 65512, 65513, 65514, 65515, 65516, 65517, 65518,
780  65519, 65520, 65521, 65522, 65523, 65524, 65525, 65526,
781  65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534,
782  65535,
783 };
784 
785 /* Used in CID 1252, 1258 */
786 static const uint8_t dnxhd_1252_ac_bits[257] = {
787  2, 2, 3, 4, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8,
788  8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10,
789  10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12,
790  12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13,
791  13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
792  14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
793  15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16,
794  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
795  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
796  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
797  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
798  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
799  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
800  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
801  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
802  16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
803  16,
804 };
805 
806 /* Used in CID 1252, 1258 */
807 static const uint8_t dnxhd_1252_ac_info[2*257] = {
808  3, 0, 3, 2, 5, 0, 7, 0, 5, 2, 0, 0, 9, 0, 11, 0,
809  13, 0, 15, 0, 7, 2, 17, 0, 19, 0, 21, 0, 23, 0, 25, 0,
810  27, 0, 29, 0, 9, 2, 11, 2, 31, 0, 33, 0, 35, 0, 37, 0,
811  13, 2, 39, 0, 41, 0, 43, 0, 45, 0, 47, 0, 49, 0, 15, 2,
812  17, 2, 51, 0, 53, 0, 55, 0, 57, 0, 59, 0, 61, 0, 63, 0,
813  65, 0, 19, 2, 21, 2, 67, 0, 69, 0, 71, 0, 73, 0, 75, 0,
814  77, 0, 79, 0, 81, 0, 83, 0, 23, 2, 25, 2, 27, 2, 85, 0,
815  87, 0, 89, 0, 91, 0, 93, 0, 95, 0, 97, 0, 99, 0, 101, 0,
816  103, 0, 105, 0, 107, 0, 29, 2, 31, 2, 33, 2, 109, 0, 111, 0,
817  113, 0, 115, 0, 117, 0, 119, 0, 121, 0, 123, 0, 125, 0, 127, 0,
818  129, 0, 3, 1, 5, 1, 7, 1, 35, 2, 37, 2, 39, 2, 41, 2,
819  9, 1, 11, 1, 13, 1, 15, 1, 17, 1, 19, 1, 21, 1, 23, 1,
820  25, 1, 27, 1, 29, 1, 31, 1, 33, 1, 35, 1, 37, 1, 39, 1,
821  41, 1, 43, 1, 43, 2, 45, 2, 47, 2, 49, 2, 51, 2, 45, 1,
822  47, 1, 49, 1, 51, 1, 53, 1, 55, 1, 57, 1, 59, 1, 61, 1,
823  63, 1, 65, 1, 67, 1, 69, 1, 71, 1, 73, 1, 75, 1, 77, 1,
824  79, 1, 81, 1, 83, 1, 85, 1, 87, 1, 89, 1, 91, 1, 93, 1,
825  95, 1, 97, 1, 99, 1, 101, 1, 103, 1, 105, 1, 107, 1, 109, 1,
826  111, 1, 113, 1, 115, 1, 117, 1, 119, 1, 121, 1, 123, 1, 125, 1,
827  127, 1, 129, 1, 53, 2, 55, 2, 57, 2, 59, 2, 61, 2, 63, 2,
828  65, 2, 67, 2, 69, 2, 71, 2, 73, 2, 75, 2, 77, 2, 79, 2,
829  81, 2, 83, 2, 85, 2, 87, 2, 89, 2, 91, 2, 93, 2, 95, 2,
830  97, 2, 99, 2, 101, 2, 103, 2, 105, 2, 107, 2, 109, 2, 111, 2,
831  113, 2, 115, 2, 117, 2, 119, 2, 121, 2, 123, 2, 125, 2, 127, 2,
832  129, 2, 3, 3, 5, 3, 7, 3, 9, 3, 11, 3, 13, 3, 15, 3,
833  17, 3, 19, 3, 21, 3, 23, 3, 25, 3, 27, 3, 29, 3, 31, 3,
834  33, 3, 35, 3, 37, 3, 39, 3, 41, 3, 43, 3, 45, 3, 47, 3,
835  49, 3, 51, 3, 53, 3, 55, 3, 57, 3, 59, 3, 61, 3, 63, 3,
836  65, 3, 67, 3, 69, 3, 71, 3, 73, 3, 75, 3, 77, 3, 79, 3,
837  81, 3, 83, 3, 85, 3, 87, 3, 89, 3, 91, 3, 93, 3, 95, 3,
838  97, 3, 99, 3, 101, 3, 103, 3, 105, 3, 107, 3, 109, 3, 111, 3,
839  113, 3, 115, 3, 117, 3, 119, 3, 121, 3, 123, 3, 125, 3, 127, 3,
840  129, 3,
841 };
842 
843 /* Used in CID 1235, 1238, 1241, 1243, 1256, 1270, 1271, 1272 */
844 static const uint16_t dnxhd_1235_run_codes[62] = {
845  0, 4, 10, 11, 24, 25, 26, 27,
846  56, 57, 58, 59, 120, 242, 486, 487,
847  488, 489, 980, 981, 982, 983, 984, 985,
848  986, 987, 988, 989, 990, 991, 992, 993,
849  994, 995, 996, 997, 998, 999, 1000, 1001,
850  1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009,
851  1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017,
852  1018, 1019, 1020, 1021, 1022, 1023,
853 };
854 
855 /* Used in CID 1235, 1238, 1241, 1243, 1256, 1270, 1271, 1272 */
856 static const uint8_t dnxhd_1235_run_bits[62] = {
857  1, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 8, 9, 9,
858  9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
859  10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
860  10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
861 };
862 
863 /* Used in CID 1235, 1241, 1256, 1270, 1271 */
864 static const uint8_t dnxhd_1235_run[62] = {
865  1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
866  18, 20, 17, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
867  33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
868  49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
869 };
870 
871 /* Used in CID 1237, 1242, 1253, 1259, 1260, 1273, 1274 */
872 static const uint16_t dnxhd_1237_run_codes[62] = {
873  0, 4, 10, 11, 24, 25, 26, 54,
874  55, 56, 57, 58, 118, 119, 240, 482,
875  483, 484, 485, 486, 487, 488, 489, 490,
876  491, 492, 493, 494, 990, 991, 992, 993,
877  994, 995, 996, 997, 998, 999, 1000, 1001,
878  1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009,
879  1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017,
880  1018, 1019, 1020, 1021, 1022, 1023,
881 };
882 
883 /* Used in CID 1237, 1242, 1253, 1259, 1260, 1273, 1274 */
884 static const uint8_t dnxhd_1237_run_bits[62] = {
885  1, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 8, 9,
886  9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10,
887  10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
888  10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
889 };
890 
891 /* Used in CID 1237, 1242, 1253, 1259, 1260, 1273, 1274 */
892 static const uint8_t dnxhd_1237_run[62] = {
893  1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
894  17, 18, 19, 20, 21, 53, 57, 58, 59, 60, 61, 62, 22, 23, 24, 25,
895  26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
896  42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 54, 55, 56,
897 };
898 
899 /* Used in CID 1238, 1243, 1272 */
900 static const uint8_t dnxhd_1238_run[62] = {
901  1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
902  20, 21, 17, 18, 19, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
903  33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
904  49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
905 };
906 
907 /* Used in CID 1250, 1251, 1252, 1258 */
908 static const uint16_t dnxhd_1250_run_codes[62] = {
909  0, 4, 5, 12, 26, 27, 28, 58,
910  118, 119, 120, 242, 486, 487, 976, 977,
911  978, 979, 980, 981, 982, 983, 984, 985,
912  986, 987, 988, 989, 990, 991, 992, 993,
913  994, 995, 996, 997, 998, 999, 1000, 1001,
914  1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009,
915  1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017,
916  1018, 1019, 1020, 1021, 1022, 1023,
917 };
918 
919 /* Used in CID 1250, 1251, 1252, 1258 */
920 static const uint8_t dnxhd_1250_run_bits[62] = {
921  1, 3, 3, 4, 5, 5, 5, 6, 7, 7, 7, 8, 9, 9, 10, 10,
922  10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
923  10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
924  10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
925 };
926 
927 /* Used in CID 1250, 1251, 1252, 1258 */
928 static const uint8_t dnxhd_1250_run[62] = {
929  1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
930  17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
931  33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
932  49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
933 };
934 
935 static const CIDEntry dnxhd_cid_table[] = {
936  { 1235, 1920, 1080, 917504, 917504,
937  0, 6, 10, 4,
942  { 175, 185, 365, 440 } },
943  { 1237, 1920, 1080, 606208, 606208,
944  0, 4, 8, 3,
949  { 115, 120, 145, 240, 290 } },
950  { 1238, 1920, 1080, 917504, 917504,
951  0, 4, 8, 4,
956  { 175, 185, 220, 365, 440 } },
957  { 1241, 1920, 1080, 917504, 458752,
958  DNXHD_INTERLACED, 6, 10, 4,
963  { 185, 220 } },
964  { 1242, 1920, 1080, 606208, 303104,
965  DNXHD_INTERLACED, 4, 8, 3,
970  { 120, 145 } },
971  { 1243, 1920, 1080, 917504, 458752,
972  DNXHD_INTERLACED, 4, 8, 4,
977  { 185, 220 } },
978  { 1244, 1440, 1080, 606208, 303104,
979  DNXHD_INTERLACED, 4, 8, 3,
984  { 120, 145 } },
985  { 1250, 1280, 720, 458752, 458752,
986  0, 6, 10, 4,
991  { 90, 180, 220 } },
992  { 1251, 1280, 720, 458752, 458752,
993  0, 4, 8, 4,
998  { 90, 110, 180, 220 } },
999  { 1252, 1280, 720, 303104, 303104,
1000  0, 4, 8, 5,
1005  { 60, 75, 120, 145 } },
1006  { 1253, 1920, 1080, 188416, 188416,
1007  0, 4, 8, 3,
1012  { 36, 45, 75, 90 } },
1013  { 1256, 1920, 1080, 1835008, 1835008,
1014  DNXHD_444, 6, 10, 4,
1019  { 350, 390, 440, 730, 880 } },
1020  { 1258, 960, 720, 212992, 212992,
1021  0, 4, 8, 5,
1026  { 42, 60, 75, 115 } },
1027  { 1259, 1440, 1080, 417792, 417792,
1028  0, 4, 8, 3,
1033  { 63, 84, 100, 110 } },
1034  { 1260, 1440, 1080, 835584, 417792,
1035  DNXHD_INTERLACED | DNXHD_MBAFF, 4, 8, 3,
1040  { 80, 90, 100, 110 } },
1042  DNXHD_444, 6, DNXHD_VARIABLE, 4,
1047  { 0 }, { 57344, 255} },
1049  0, 6, DNXHD_VARIABLE, 4,
1054  { 0 }, { 28672, 255} },
1056  0, 4, 8, 4,
1061  { 0 }, { 28672, 255} },
1063  0, 4, 8, 3,
1068  { 0 }, { 18944, 255} },
1070  0, 4, 8, 3,
1075  { 0 }, { 5888, 255} },
1076 };
1077 
1079 {
1080  for (int i = 0; i < FF_ARRAY_ELEMS(dnxhd_cid_table); i++)
1081  if (dnxhd_cid_table[i].cid == cid)
1082  return &dnxhd_cid_table[i];
1083  return NULL;
1084 }
1085 
1087 {
1088  const CIDEntry *entry = ff_dnxhd_get_cid_table(cid);
1089  if (!entry)
1090  return -1;
1091  return entry->frame_size;
1092 }
1093 
1094 int ff_dnxhd_get_hr_frame_size(int cid, int w, int h)
1095 {
1096  const CIDEntry *entry = ff_dnxhd_get_cid_table(cid);
1097  int result;
1098 
1099  if (!entry)
1100  return -1;
1101 
1102  result = ((h + 15) / 16) * ((w + 15) / 16) * (int64_t)entry->packet_scale.num / entry->packet_scale.den;
1103  result = (result + 2048) / 4096 * 4096;
1104 
1105  return FFMAX(result, 8192);
1106 }
1107 
1109 {
1110  switch (avctx->profile) {
1111  case FF_PROFILE_DNXHR_444:
1112  return 1270;
1113  case FF_PROFILE_DNXHR_HQX:
1114  return 1271;
1115  case FF_PROFILE_DNXHR_HQ:
1116  return 1272;
1117  case FF_PROFILE_DNXHR_SQ:
1118  return 1273;
1119  case FF_PROFILE_DNXHR_LB:
1120  return 1274;
1121  }
1122  return 0;
1123 }
1124 
1126 {
1127  int i, j;
1128  int mbs = avctx->bit_rate / 1000000;
1129 
1130  if (avctx->profile != FF_PROFILE_DNXHD)
1131  return dnxhd_find_hr_cid(avctx);
1132 
1133  if (!mbs)
1134  return 0;
1135  for (i = 0; i < FF_ARRAY_ELEMS(dnxhd_cid_table); i++) {
1136  const CIDEntry *cid = &dnxhd_cid_table[i];
1137  int interlaced = cid->flags & DNXHD_INTERLACED ? 1 : 0;
1138  if (cid->width == avctx->width && cid->height == avctx->height &&
1139  interlaced == !!(avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) &&
1140  !(cid->flags & DNXHD_444) && cid->bit_depth == bit_depth) {
1142  cid->flags & DNXHD_MBAFF) {
1143  av_log(avctx, AV_LOG_WARNING, "Profile selected is experimental\n");
1144  continue;
1145  }
1146  for (j = 0; j < FF_ARRAY_ELEMS(cid->bit_rates); j++) {
1147  if (cid->bit_rates[j] == mbs)
1148  return cid->cid;
1149  }
1150  }
1151  }
1152  return 0;
1153 }
1154 
1155 void ff_dnxhd_print_profiles(AVCodecContext *avctx, int loglevel)
1156 {
1157  int i, j;
1158  for (i = 0; i < FF_ARRAY_ELEMS(dnxhd_cid_table); i++) {
1159  const CIDEntry *cid = &dnxhd_cid_table[i];
1160  for (j = 0; j < FF_ARRAY_ELEMS(cid->bit_rates); j++) {
1161  if (!cid->bit_rates[j])
1162  break;
1163 
1164  av_log(avctx, loglevel, "Frame size: %dx%d%c; bitrate: %dMbps; pixel format: %s\n",
1165  cid->width, cid->height, cid->flags & DNXHD_INTERLACED ? 'i' : 'p', cid->bit_rates[j],
1166  cid->flags & DNXHD_444 ? "yuv444p10, gbrp10" : cid->bit_depth == 10 ? "yuv422p10" : "yuv422p");
1167  }
1168  }
1169 }
bit_depth
static void bit_depth(AudioStatsContext *s, uint64_t mask, uint64_t imask, AVRational *depth)
Definition: af_astats.c:226
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
dnxhd_1237_ac_codes
static const uint16_t dnxhd_1237_ac_codes[257]
Definition: dnxhddata.c:281
DNXHD_INTERLACED
#define DNXHD_INTERLACED
Additional profile info flags.
Definition: dnxhddata.h:31
FF_COMPLIANCE_EXPERIMENTAL
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
Definition: avcodec.h:1285
dnxhd_1235_ac_codes
static const uint16_t dnxhd_1235_ac_codes[257]
Definition: dnxhddata.c:471
dnxhd_1250_ac_info
static const uint8_t dnxhd_1250_ac_info[2 *257]
Definition: dnxhddata.c:620
dnxhd_1260_chroma_weight
static const uint8_t dnxhd_1260_chroma_weight[]
Definition: dnxhddata.c:249
w
uint8_t w
Definition: llviddspenc.c:38
dnxhd_1237_dc_codes
static const uint8_t dnxhd_1237_dc_codes[12]
Definition: dnxhddata.c:271
FF_PROFILE_DNXHD
#define FF_PROFILE_DNXHD
Definition: avcodec.h:1540
dnxhd_1238_chroma_weight
static const uint8_t dnxhd_1238_chroma_weight[]
Definition: dnxhddata.c:89
dnxhd_1252_ac_bits
static const uint8_t dnxhd_1252_ac_bits[257]
Definition: dnxhddata.c:786
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
dnxhd_1252_ac_codes
static const uint16_t dnxhd_1252_ac_codes[257]
Definition: dnxhddata.c:749
DNXHD_444
#define DNXHD_444
Definition: dnxhddata.h:33
dnxhd_1237_ac_info
static const uint8_t dnxhd_1237_ac_info[2 *257]
Definition: dnxhddata.c:339
ff_dnxhd_print_profiles
void ff_dnxhd_print_profiles(AVCodecContext *avctx, int loglevel)
Definition: dnxhddata.c:1155
AVCodecContext::flags
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:463
CIDEntry::packet_scale
AVRational packet_scale
Definition: dnxhddata.h:58
dnxhd_1238_run
static const uint8_t dnxhd_1238_run[62]
Definition: dnxhddata.c:900
dnxhd_1252_chroma_weight
static const uint8_t dnxhd_1252_chroma_weight[]
Definition: dnxhddata.c:225
AVRational::num
int num
Numerator.
Definition: rational.h:59
FF_PROFILE_DNXHR_LB
#define FF_PROFILE_DNXHR_LB
Definition: avcodec.h:1541
CIDEntry
Definition: dnxhddata.h:42
AV_CODEC_FLAG_INTERLACED_DCT
#define AV_CODEC_FLAG_INTERLACED_DCT
Use interlaced DCT.
Definition: avcodec.h:260
dnxhd_1241_chroma_weight
static const uint8_t dnxhd_1241_chroma_weight[]
Definition: dnxhddata.c:113
dnxhddata.h
dnxhd_1235_ac_bits
static const uint8_t dnxhd_1235_ac_bits[257]
Definition: dnxhddata.c:508
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
dnxhd_1238_ac_info
static const uint8_t dnxhd_1238_ac_info[2 *257]
Definition: dnxhddata.c:434
ff_dnxhd_get_hr_frame_size
int ff_dnxhd_get_hr_frame_size(int cid, int w, int h)
Definition: dnxhddata.c:1094
dnxhd_1237_dc_bits
static const uint8_t dnxhd_1237_dc_bits[12]
Definition: dnxhddata.c:276
DNXHD_MBAFF
#define DNXHD_MBAFF
Definition: dnxhddata.h:32
dnxhd_1242_luma_weight
static const uint8_t dnxhd_1242_luma_weight[]
Definition: dnxhddata.c:124
dnxhd_1250_ac_bits
static const uint8_t dnxhd_1250_ac_bits[257]
Definition: dnxhddata.c:600
dnxhd_1238_luma_weight
static const uint8_t dnxhd_1238_luma_weight[]
Definition: dnxhddata.c:77
dnxhd_1250_run_bits
static const uint8_t dnxhd_1250_run_bits[62]
Definition: dnxhddata.c:920
FF_PROFILE_DNXHR_HQ
#define FF_PROFILE_DNXHR_HQ
Definition: avcodec.h:1543
dnxhd_1237_chroma_weight
static const uint8_t dnxhd_1237_chroma_weight[]
Definition: dnxhddata.c:65
dnxhd_1251_chroma_weight
static const uint8_t dnxhd_1251_chroma_weight[]
Definition: dnxhddata.c:201
result
and forward the result(frame or status change) to the corresponding input. If nothing is possible
NULL
#define NULL
Definition: coverity.c:32
dnxhd_1251_ac_bits
static const uint8_t dnxhd_1251_ac_bits[257]
Definition: dnxhddata.c:692
AVCodecContext::bit_rate
int64_t bit_rate
the average bitrate
Definition: avcodec.h:433
dnxhd_1235_dc_codes
static const uint8_t dnxhd_1235_dc_codes[14]
Definition: dnxhddata.c:261
DNXHD_VARIABLE
#define DNXHD_VARIABLE
Indicate that a CIDEntry value must be read in the bitstream.
Definition: dnxhddata.h:40
ff_dnxhd_get_frame_size
int ff_dnxhd_get_frame_size(int cid)
Definition: dnxhddata.c:1086
cid
uint16_t cid
Definition: mxfenc.c:2039
dnxhd_1237_ac_bits
static const uint8_t dnxhd_1237_ac_bits[257]
Definition: dnxhddata.c:318
dnxhd_find_hr_cid
static int dnxhd_find_hr_cid(AVCodecContext *avctx)
Definition: dnxhddata.c:1108
dnxhd_1251_luma_weight
static const uint8_t dnxhd_1251_luma_weight[]
Definition: dnxhddata.c:190
dnxhd_cid_table
static const CIDEntry dnxhd_cid_table[]
Definition: dnxhddata.c:935
dnxhd_1235_run_bits
static const uint8_t dnxhd_1235_run_bits[62]
Definition: dnxhddata.c:856
dnxhd_1235_run_codes
static const uint16_t dnxhd_1235_run_codes[62]
Definition: dnxhddata.c:844
ff_dnxhd_get_cid_table
const CIDEntry * ff_dnxhd_get_cid_table(int cid)
Definition: dnxhddata.c:1078
dnxhd_1235_luma_weight
static const uint8_t dnxhd_1235_luma_weight[]
Definition: dnxhddata.c:29
interlaced
uint8_t interlaced
Definition: mxfenc.c:2040
FF_PROFILE_DNXHR_SQ
#define FF_PROFILE_DNXHR_SQ
Definition: avcodec.h:1542
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
common.h
AVCodecContext::height
int height
Definition: avcodec.h:556
dnxhd_1250_run
static const uint8_t dnxhd_1250_run[62]
Definition: dnxhddata.c:928
avcodec.h
AVCodecContext::strict_std_compliance
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
Definition: avcodec.h:1280
dnxhd_1250_ac_codes
static const uint16_t dnxhd_1250_ac_codes[257]
Definition: dnxhddata.c:565
dnxhd_1250_luma_weight
static const uint8_t dnxhd_1250_luma_weight[]
Definition: dnxhddata.c:168
dnxhd_1237_luma_weight
static const uint8_t dnxhd_1237_luma_weight[]
Definition: dnxhddata.c:53
dnxhd_1241_luma_weight
static const uint8_t dnxhd_1241_luma_weight[]
Definition: dnxhddata.c:101
AVCodecContext
main external API structure.
Definition: avcodec.h:383
dnxhd_1251_ac_codes
static const uint16_t dnxhd_1251_ac_codes[257]
Definition: dnxhddata.c:656
dnxhd_1235_chroma_weight
static const uint8_t dnxhd_1235_chroma_weight[]
Definition: dnxhddata.c:41
AVRational::den
int den
Denominator.
Definition: rational.h:60
dnxhd_1238_ac_codes
static const uint16_t dnxhd_1238_ac_codes[257]
Definition: dnxhddata.c:376
AVCodecContext::profile
int profile
profile
Definition: avcodec.h:1525
dnxhd_1237_run
static const uint8_t dnxhd_1237_run[62]
Definition: dnxhddata.c:892
dnxhd_1250_run_codes
static const uint16_t dnxhd_1250_run_codes[62]
Definition: dnxhddata.c:908
ff_dnxhd_find_cid
int ff_dnxhd_find_cid(AVCodecContext *avctx, int bit_depth)
Definition: dnxhddata.c:1125
dnxhd_1242_chroma_weight
static const uint8_t dnxhd_1242_chroma_weight[]
Definition: dnxhddata.c:135
dnxhd_1252_luma_weight
static const uint8_t dnxhd_1252_luma_weight[]
Definition: dnxhddata.c:213
dnxhd_1243_chroma_weight
static const uint8_t dnxhd_1243_chroma_weight[]
Definition: dnxhddata.c:157
dnxhd_1235_ac_info
static const uint8_t dnxhd_1235_ac_info[2 *257]
Definition: dnxhddata.c:529
FF_PROFILE_DNXHR_HQX
#define FF_PROFILE_DNXHR_HQX
Definition: avcodec.h:1544
dnxhd_1238_ac_bits
static const uint8_t dnxhd_1238_ac_bits[257]
Definition: dnxhddata.c:413
dnxhd_1243_luma_weight
static const uint8_t dnxhd_1243_luma_weight[]
Definition: dnxhddata.c:146
dnxhd_1237_run_bits
static const uint8_t dnxhd_1237_run_bits[62]
Definition: dnxhddata.c:884
dnxhd_1251_ac_info
static const uint8_t dnxhd_1251_ac_info[2 *257]
Definition: dnxhddata.c:712
CIDEntry::frame_size
unsigned int frame_size
Definition: dnxhddata.h:45
dnxhd_1250_chroma_weight
static const uint8_t dnxhd_1250_chroma_weight[]
Definition: dnxhddata.c:179
dnxhd_1237_run_codes
static const uint16_t dnxhd_1237_run_codes[62]
Definition: dnxhddata.c:872
FF_PROFILE_DNXHR_444
#define FF_PROFILE_DNXHR_444
Definition: avcodec.h:1545
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:556
dnxhd_1252_ac_info
static const uint8_t dnxhd_1252_ac_info[2 *257]
Definition: dnxhddata.c:807
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
dnxhd_1260_luma_weight
static const uint8_t dnxhd_1260_luma_weight[]
Definition: dnxhddata.c:237
h
h
Definition: vp9dsp_template.c:2038
dnxhd_1235_dc_bits
static const uint8_t dnxhd_1235_dc_bits[14]
Definition: dnxhddata.c:266
dnxhd_1235_run
static const uint8_t dnxhd_1235_run[62]
Definition: dnxhddata.c:864