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