Nugget
Bare-metal libraries and examples for the original PlayStation
Loading...
Searching...
No Matches
bsdec-vlc.h
Go to the documentation of this file.
1// GENERATED by bsdec/gentable.py - do not edit.
2//
3// Sony's standard MDEC AC code book (FileFormat47 Table 1-7), rearranged for a
4// count-leading-zeros dispatch. Every code in the book is N zeros, a marker 1, then a
5// suffix whose width depends only on N, so one clz plus one indexed load replaces the
6// bit-at-a-time walk down a trie.
7//
8// n codes code lengths suffix width
9// 0 3 [2, 3] 2
10// 1 6 [4, 5] 3
11// 2 22 [6, 9] 6
12// 3 8 [7] 3
13// 4 8 [8] 3
14// 5 1 [6] 0
15// 6 16 [11] 4
16// 7 32 [13] 5
17// 8 32 [14] 5
18// 9 32 [15] 5
19// 10 32 [16] 5
20// 11 32 [17] 5
21//
22// 224 symbols, 269 table slots, 0 unreachable (invalid prefixes).
23//
24// Entry layout, chosen so the common path is one load and one mask:
25// bits 0..15 the MDEC run-level halfword, ready to store (0xfe00 for EOB)
26// bits 16..20 suffix bits to consume after the marker 1
27// bits 21..22 kind: 0 normal, 1 end of block, 2 escape
28// bit 23 set on a valid entry; a zero word is an invalid prefix
29
30#pragma once
31
32#include <stdint.h>
33
34#define BSDEC_VLC_MAXNZ 11
35
36#define BSDEC_VLC_HALFWORD(e) ((uint16_t)((e) & 0xffff))
37#define BSDEC_VLC_SUFFIXBITS(e) (((e) >> 16) & 0x1f)
38#define BSDEC_VLC_KIND(e) (((e) >> 21) & 3)
39#define BSDEC_VLC_VALID(e) ((e) & (1 << 23))
40
41#define BSDEC_VLC_NORMAL 0
42#define BSDEC_VLC_EOB 1
43#define BSDEC_VLC_ESCAPE 2
44
45/* Rows past 11 are the garbage-prefix sentinel: width 0, pointing at
46 the appended EOB slot, so an impossible prefix needs no bounds test. */
47static const uint8_t c_bsdecVlcSuffixBits[32] = {2, 3, 6, 3, 3, 0, 4, 5, 5, 5, 5, 5, 0, 0, 0, 0,
48 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
49
50static const uint16_t c_bsdecVlcOffset[32] = {0, 4, 12, 76, 84, 92, 93, 109, 141, 173, 205,
51 237, 269, 269, 269, 269, 269, 269, 269, 269, 269, 269,
52 269, 269, 269, 269, 269, 269, 269, 269, 269, 269};
53
54static const uint32_t c_bsdecVlc[270] = {
55 // n = 0, suffix 2 bits
56 0x00a1fe00,
57 0x00a1fe00,
58 0x00820001,
59 0x008203ff,
60 // n = 1, suffix 3 bits
61 0x00830002,
62 0x008303fe,
63 0x00830801,
64 0x00830bff,
65 0x00820401,
66 0x00820401,
67 0x008207ff,
68 0x008207ff,
69 // n = 2, suffix 6 bits
70 0x00863401,
71 0x008637ff,
72 0x00860006,
73 0x008603fa,
74 0x00863001,
75 0x008633ff,
76 0x00862c01,
77 0x00862fff,
78 0x00860c02,
79 0x00860ffe,
80 0x00860403,
81 0x008607fd,
82 0x00860005,
83 0x008603fb,
84 0x00862801,
85 0x00862bff,
86 0x00830003,
87 0x00830003,
88 0x00830003,
89 0x00830003,
90 0x00830003,
91 0x00830003,
92 0x00830003,
93 0x00830003,
94 0x008303fd,
95 0x008303fd,
96 0x008303fd,
97 0x008303fd,
98 0x008303fd,
99 0x008303fd,
100 0x008303fd,
101 0x008303fd,
102 0x00831001,
103 0x00831001,
104 0x00831001,
105 0x00831001,
106 0x00831001,
107 0x00831001,
108 0x00831001,
109 0x00831001,
110 0x008313ff,
111 0x008313ff,
112 0x008313ff,
113 0x008313ff,
114 0x008313ff,
115 0x008313ff,
116 0x008313ff,
117 0x008313ff,
118 0x00830c01,
119 0x00830c01,
120 0x00830c01,
121 0x00830c01,
122 0x00830c01,
123 0x00830c01,
124 0x00830c01,
125 0x00830c01,
126 0x00830fff,
127 0x00830fff,
128 0x00830fff,
129 0x00830fff,
130 0x00830fff,
131 0x00830fff,
132 0x00830fff,
133 0x00830fff,
134 // n = 3, suffix 3 bits
135 0x00831c01,
136 0x00831fff,
137 0x00831801,
138 0x00831bff,
139 0x00830402,
140 0x008307fe,
141 0x00831401,
142 0x008317ff,
143 // n = 4, suffix 3 bits
144 0x00830802,
145 0x00830bfe,
146 0x00832401,
147 0x008327ff,
148 0x00830004,
149 0x008303fc,
150 0x00832001,
151 0x008323ff,
152 // n = 5, suffix 0 bits
153 0x00c00000,
154 // n = 6, suffix 4 bits
155 0x00844001,
156 0x008443ff,
157 0x00841402,
158 0x008417fe,
159 0x00840007,
160 0x008403f9,
161 0x00840803,
162 0x00840bfd,
163 0x00840404,
164 0x008407fc,
165 0x00843c01,
166 0x00843fff,
167 0x00843801,
168 0x00843bff,
169 0x00841002,
170 0x008413fe,
171 // n = 7, suffix 5 bits
172 0x0085000b,
173 0x008503f5,
174 0x00852002,
175 0x008523fe,
176 0x00851003,
177 0x008513fd,
178 0x0085000a,
179 0x008503f6,
180 0x00850804,
181 0x00850bfc,
182 0x00851c02,
183 0x00851ffe,
184 0x00855401,
185 0x008557ff,
186 0x00855001,
187 0x008553ff,
188 0x00850009,
189 0x008503f7,
190 0x00854c01,
191 0x00854fff,
192 0x00854801,
193 0x00854bff,
194 0x00850405,
195 0x008507fb,
196 0x00850c03,
197 0x00850ffd,
198 0x00850008,
199 0x008503f8,
200 0x00851802,
201 0x00851bfe,
202 0x00854401,
203 0x008547ff,
204 // n = 8, suffix 5 bits
205 0x00852802,
206 0x00852bfe,
207 0x00852402,
208 0x008527fe,
209 0x00851403,
210 0x008517fd,
211 0x00850c04,
212 0x00850ffc,
213 0x00850805,
214 0x00850bfb,
215 0x00850407,
216 0x008507f9,
217 0x00850406,
218 0x008507fa,
219 0x0085000f,
220 0x008503f1,
221 0x0085000e,
222 0x008503f2,
223 0x0085000d,
224 0x008503f3,
225 0x0085000c,
226 0x008503f4,
227 0x00856801,
228 0x00856bff,
229 0x00856401,
230 0x008567ff,
231 0x00856001,
232 0x008563ff,
233 0x00855c01,
234 0x00855fff,
235 0x00855801,
236 0x00855bff,
237 // n = 9, suffix 5 bits
238 0x0085001f,
239 0x008503e1,
240 0x0085001e,
241 0x008503e2,
242 0x0085001d,
243 0x008503e3,
244 0x0085001c,
245 0x008503e4,
246 0x0085001b,
247 0x008503e5,
248 0x0085001a,
249 0x008503e6,
250 0x00850019,
251 0x008503e7,
252 0x00850018,
253 0x008503e8,
254 0x00850017,
255 0x008503e9,
256 0x00850016,
257 0x008503ea,
258 0x00850015,
259 0x008503eb,
260 0x00850014,
261 0x008503ec,
262 0x00850013,
263 0x008503ed,
264 0x00850012,
265 0x008503ee,
266 0x00850011,
267 0x008503ef,
268 0x00850010,
269 0x008503f0,
270 // n = 10, suffix 5 bits
271 0x00850028,
272 0x008503d8,
273 0x00850027,
274 0x008503d9,
275 0x00850026,
276 0x008503da,
277 0x00850025,
278 0x008503db,
279 0x00850024,
280 0x008503dc,
281 0x00850023,
282 0x008503dd,
283 0x00850022,
284 0x008503de,
285 0x00850021,
286 0x008503df,
287 0x00850020,
288 0x008503e0,
289 0x0085040e,
290 0x008507f2,
291 0x0085040d,
292 0x008507f3,
293 0x0085040c,
294 0x008507f4,
295 0x0085040b,
296 0x008507f5,
297 0x0085040a,
298 0x008507f6,
299 0x00850409,
300 0x008507f7,
301 0x00850408,
302 0x008507f8,
303 // n = 11, suffix 5 bits
304 0x00850412,
305 0x008507ee,
306 0x00850411,
307 0x008507ef,
308 0x00850410,
309 0x008507f0,
310 0x0085040f,
311 0x008507f1,
312 0x00851803,
313 0x00851bfd,
314 0x00854002,
315 0x008543fe,
316 0x00853c02,
317 0x00853ffe,
318 0x00853802,
319 0x00853bfe,
320 0x00853402,
321 0x008537fe,
322 0x00853002,
323 0x008533fe,
324 0x00852c02,
325 0x00852ffe,
326 0x00857c01,
327 0x00857fff,
328 0x00857801,
329 0x00857bff,
330 0x00857401,
331 0x008577ff,
332 0x00857001,
333 0x008573ff,
334 0x00856c01,
335 0x00856fff,
336 // sentinel: every prefix longer than the book ends the block here
337 0x00a0fe00,
338};
339
340// Direct-lookup tables: nine bits of the window give the finished entry, with bits
341// 16..20 holding the whole code length. c_bsdecPrim9 is indexed by the top nine bits
342// and misses only when the window has six or more leading zeros; c_bsdecSec9 is
343// indexed by bits 6..14 on that miss and misses only on ten or more, which is what
344// is left for the count-and-dispatch tables above.
345#define BSDEC_VLC_LENGTH(e) (((e) >> 16) & 0x1f)
346static const uint32_t c_bsdecPrim9[512] = {
347 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00c60000,
348 0x00c60000, 0x00c60000, 0x00c60000, 0x00c60000, 0x00c60000, 0x00c60000, 0x00c60000, 0x00880802, 0x00880802,
349 0x00880bfe, 0x00880bfe, 0x00882401, 0x00882401, 0x008827ff, 0x008827ff, 0x00880004, 0x00880004, 0x008803fc,
350 0x008803fc, 0x00882001, 0x00882001, 0x008823ff, 0x008823ff, 0x00871c01, 0x00871c01, 0x00871c01, 0x00871c01,
351 0x00871fff, 0x00871fff, 0x00871fff, 0x00871fff, 0x00871801, 0x00871801, 0x00871801, 0x00871801, 0x00871bff,
352 0x00871bff, 0x00871bff, 0x00871bff, 0x00870402, 0x00870402, 0x00870402, 0x00870402, 0x008707fe, 0x008707fe,
353 0x008707fe, 0x008707fe, 0x00871401, 0x00871401, 0x00871401, 0x00871401, 0x008717ff, 0x008717ff, 0x008717ff,
354 0x008717ff, 0x00893401, 0x008937ff, 0x00890006, 0x008903fa, 0x00893001, 0x008933ff, 0x00892c01, 0x00892fff,
355 0x00890c02, 0x00890ffe, 0x00890403, 0x008907fd, 0x00890005, 0x008903fb, 0x00892801, 0x00892bff, 0x00860003,
356 0x00860003, 0x00860003, 0x00860003, 0x00860003, 0x00860003, 0x00860003, 0x00860003, 0x008603fd, 0x008603fd,
357 0x008603fd, 0x008603fd, 0x008603fd, 0x008603fd, 0x008603fd, 0x008603fd, 0x00861001, 0x00861001, 0x00861001,
358 0x00861001, 0x00861001, 0x00861001, 0x00861001, 0x00861001, 0x008613ff, 0x008613ff, 0x008613ff, 0x008613ff,
359 0x008613ff, 0x008613ff, 0x008613ff, 0x008613ff, 0x00860c01, 0x00860c01, 0x00860c01, 0x00860c01, 0x00860c01,
360 0x00860c01, 0x00860c01, 0x00860c01, 0x00860fff, 0x00860fff, 0x00860fff, 0x00860fff, 0x00860fff, 0x00860fff,
361 0x00860fff, 0x00860fff, 0x00850002, 0x00850002, 0x00850002, 0x00850002, 0x00850002, 0x00850002, 0x00850002,
362 0x00850002, 0x00850002, 0x00850002, 0x00850002, 0x00850002, 0x00850002, 0x00850002, 0x00850002, 0x00850002,
363 0x008503fe, 0x008503fe, 0x008503fe, 0x008503fe, 0x008503fe, 0x008503fe, 0x008503fe, 0x008503fe, 0x008503fe,
364 0x008503fe, 0x008503fe, 0x008503fe, 0x008503fe, 0x008503fe, 0x008503fe, 0x008503fe, 0x00850801, 0x00850801,
365 0x00850801, 0x00850801, 0x00850801, 0x00850801, 0x00850801, 0x00850801, 0x00850801, 0x00850801, 0x00850801,
366 0x00850801, 0x00850801, 0x00850801, 0x00850801, 0x00850801, 0x00850bff, 0x00850bff, 0x00850bff, 0x00850bff,
367 0x00850bff, 0x00850bff, 0x00850bff, 0x00850bff, 0x00850bff, 0x00850bff, 0x00850bff, 0x00850bff, 0x00850bff,
368 0x00850bff, 0x00850bff, 0x00850bff, 0x00840401, 0x00840401, 0x00840401, 0x00840401, 0x00840401, 0x00840401,
369 0x00840401, 0x00840401, 0x00840401, 0x00840401, 0x00840401, 0x00840401, 0x00840401, 0x00840401, 0x00840401,
370 0x00840401, 0x00840401, 0x00840401, 0x00840401, 0x00840401, 0x00840401, 0x00840401, 0x00840401, 0x00840401,
371 0x00840401, 0x00840401, 0x00840401, 0x00840401, 0x00840401, 0x00840401, 0x00840401, 0x00840401, 0x008407ff,
372 0x008407ff, 0x008407ff, 0x008407ff, 0x008407ff, 0x008407ff, 0x008407ff, 0x008407ff, 0x008407ff, 0x008407ff,
373 0x008407ff, 0x008407ff, 0x008407ff, 0x008407ff, 0x008407ff, 0x008407ff, 0x008407ff, 0x008407ff, 0x008407ff,
374 0x008407ff, 0x008407ff, 0x008407ff, 0x008407ff, 0x008407ff, 0x008407ff, 0x008407ff, 0x008407ff, 0x008407ff,
375 0x008407ff, 0x008407ff, 0x008407ff, 0x008407ff, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00,
376 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00,
377 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00,
378 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00,
379 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00,
380 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00,
381 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00,
382 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00,
383 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00,
384 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00,
385 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00,
386 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00,
387 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00,
388 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00,
389 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00a2fe00, 0x00830001, 0x00830001, 0x00830001,
390 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001,
391 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001,
392 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001,
393 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001,
394 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001,
395 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001,
396 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x00830001, 0x008303ff, 0x008303ff,
397 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff,
398 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff,
399 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff,
400 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff,
401 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff,
402 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff,
403 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff, 0x008303ff,
404};
405
406static const uint32_t c_bsdecSec9[512] = {
407 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
408 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
409 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
410 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x008f001f, 0x008f03e1, 0x008f001e, 0x008f03e2,
411 0x008f001d, 0x008f03e3, 0x008f001c, 0x008f03e4, 0x008f001b, 0x008f03e5, 0x008f001a, 0x008f03e6, 0x008f0019,
412 0x008f03e7, 0x008f0018, 0x008f03e8, 0x008f0017, 0x008f03e9, 0x008f0016, 0x008f03ea, 0x008f0015, 0x008f03eb,
413 0x008f0014, 0x008f03ec, 0x008f0013, 0x008f03ed, 0x008f0012, 0x008f03ee, 0x008f0011, 0x008f03ef, 0x008f0010,
414 0x008f03f0, 0x008e2802, 0x008e2802, 0x008e2bfe, 0x008e2bfe, 0x008e2402, 0x008e2402, 0x008e27fe, 0x008e27fe,
415 0x008e1403, 0x008e1403, 0x008e17fd, 0x008e17fd, 0x008e0c04, 0x008e0c04, 0x008e0ffc, 0x008e0ffc, 0x008e0805,
416 0x008e0805, 0x008e0bfb, 0x008e0bfb, 0x008e0407, 0x008e0407, 0x008e07f9, 0x008e07f9, 0x008e0406, 0x008e0406,
417 0x008e07fa, 0x008e07fa, 0x008e000f, 0x008e000f, 0x008e03f1, 0x008e03f1, 0x008e000e, 0x008e000e, 0x008e03f2,
418 0x008e03f2, 0x008e000d, 0x008e000d, 0x008e03f3, 0x008e03f3, 0x008e000c, 0x008e000c, 0x008e03f4, 0x008e03f4,
419 0x008e6801, 0x008e6801, 0x008e6bff, 0x008e6bff, 0x008e6401, 0x008e6401, 0x008e67ff, 0x008e67ff, 0x008e6001,
420 0x008e6001, 0x008e63ff, 0x008e63ff, 0x008e5c01, 0x008e5c01, 0x008e5fff, 0x008e5fff, 0x008e5801, 0x008e5801,
421 0x008e5bff, 0x008e5bff, 0x008d000b, 0x008d000b, 0x008d000b, 0x008d000b, 0x008d03f5, 0x008d03f5, 0x008d03f5,
422 0x008d03f5, 0x008d2002, 0x008d2002, 0x008d2002, 0x008d2002, 0x008d23fe, 0x008d23fe, 0x008d23fe, 0x008d23fe,
423 0x008d1003, 0x008d1003, 0x008d1003, 0x008d1003, 0x008d13fd, 0x008d13fd, 0x008d13fd, 0x008d13fd, 0x008d000a,
424 0x008d000a, 0x008d000a, 0x008d000a, 0x008d03f6, 0x008d03f6, 0x008d03f6, 0x008d03f6, 0x008d0804, 0x008d0804,
425 0x008d0804, 0x008d0804, 0x008d0bfc, 0x008d0bfc, 0x008d0bfc, 0x008d0bfc, 0x008d1c02, 0x008d1c02, 0x008d1c02,
426 0x008d1c02, 0x008d1ffe, 0x008d1ffe, 0x008d1ffe, 0x008d1ffe, 0x008d5401, 0x008d5401, 0x008d5401, 0x008d5401,
427 0x008d57ff, 0x008d57ff, 0x008d57ff, 0x008d57ff, 0x008d5001, 0x008d5001, 0x008d5001, 0x008d5001, 0x008d53ff,
428 0x008d53ff, 0x008d53ff, 0x008d53ff, 0x008d0009, 0x008d0009, 0x008d0009, 0x008d0009, 0x008d03f7, 0x008d03f7,
429 0x008d03f7, 0x008d03f7, 0x008d4c01, 0x008d4c01, 0x008d4c01, 0x008d4c01, 0x008d4fff, 0x008d4fff, 0x008d4fff,
430 0x008d4fff, 0x008d4801, 0x008d4801, 0x008d4801, 0x008d4801, 0x008d4bff, 0x008d4bff, 0x008d4bff, 0x008d4bff,
431 0x008d0405, 0x008d0405, 0x008d0405, 0x008d0405, 0x008d07fb, 0x008d07fb, 0x008d07fb, 0x008d07fb, 0x008d0c03,
432 0x008d0c03, 0x008d0c03, 0x008d0c03, 0x008d0ffd, 0x008d0ffd, 0x008d0ffd, 0x008d0ffd, 0x008d0008, 0x008d0008,
433 0x008d0008, 0x008d0008, 0x008d03f8, 0x008d03f8, 0x008d03f8, 0x008d03f8, 0x008d1802, 0x008d1802, 0x008d1802,
434 0x008d1802, 0x008d1bfe, 0x008d1bfe, 0x008d1bfe, 0x008d1bfe, 0x008d4401, 0x008d4401, 0x008d4401, 0x008d4401,
435 0x008d47ff, 0x008d47ff, 0x008d47ff, 0x008d47ff, 0x008b4001, 0x008b4001, 0x008b4001, 0x008b4001, 0x008b4001,
436 0x008b4001, 0x008b4001, 0x008b4001, 0x008b4001, 0x008b4001, 0x008b4001, 0x008b4001, 0x008b4001, 0x008b4001,
437 0x008b4001, 0x008b4001, 0x008b43ff, 0x008b43ff, 0x008b43ff, 0x008b43ff, 0x008b43ff, 0x008b43ff, 0x008b43ff,
438 0x008b43ff, 0x008b43ff, 0x008b43ff, 0x008b43ff, 0x008b43ff, 0x008b43ff, 0x008b43ff, 0x008b43ff, 0x008b43ff,
439 0x008b1402, 0x008b1402, 0x008b1402, 0x008b1402, 0x008b1402, 0x008b1402, 0x008b1402, 0x008b1402, 0x008b1402,
440 0x008b1402, 0x008b1402, 0x008b1402, 0x008b1402, 0x008b1402, 0x008b1402, 0x008b1402, 0x008b17fe, 0x008b17fe,
441 0x008b17fe, 0x008b17fe, 0x008b17fe, 0x008b17fe, 0x008b17fe, 0x008b17fe, 0x008b17fe, 0x008b17fe, 0x008b17fe,
442 0x008b17fe, 0x008b17fe, 0x008b17fe, 0x008b17fe, 0x008b17fe, 0x008b0007, 0x008b0007, 0x008b0007, 0x008b0007,
443 0x008b0007, 0x008b0007, 0x008b0007, 0x008b0007, 0x008b0007, 0x008b0007, 0x008b0007, 0x008b0007, 0x008b0007,
444 0x008b0007, 0x008b0007, 0x008b0007, 0x008b03f9, 0x008b03f9, 0x008b03f9, 0x008b03f9, 0x008b03f9, 0x008b03f9,
445 0x008b03f9, 0x008b03f9, 0x008b03f9, 0x008b03f9, 0x008b03f9, 0x008b03f9, 0x008b03f9, 0x008b03f9, 0x008b03f9,
446 0x008b03f9, 0x008b0803, 0x008b0803, 0x008b0803, 0x008b0803, 0x008b0803, 0x008b0803, 0x008b0803, 0x008b0803,
447 0x008b0803, 0x008b0803, 0x008b0803, 0x008b0803, 0x008b0803, 0x008b0803, 0x008b0803, 0x008b0803, 0x008b0bfd,
448 0x008b0bfd, 0x008b0bfd, 0x008b0bfd, 0x008b0bfd, 0x008b0bfd, 0x008b0bfd, 0x008b0bfd, 0x008b0bfd, 0x008b0bfd,
449 0x008b0bfd, 0x008b0bfd, 0x008b0bfd, 0x008b0bfd, 0x008b0bfd, 0x008b0bfd, 0x008b0404, 0x008b0404, 0x008b0404,
450 0x008b0404, 0x008b0404, 0x008b0404, 0x008b0404, 0x008b0404, 0x008b0404, 0x008b0404, 0x008b0404, 0x008b0404,
451 0x008b0404, 0x008b0404, 0x008b0404, 0x008b0404, 0x008b07fc, 0x008b07fc, 0x008b07fc, 0x008b07fc, 0x008b07fc,
452 0x008b07fc, 0x008b07fc, 0x008b07fc, 0x008b07fc, 0x008b07fc, 0x008b07fc, 0x008b07fc, 0x008b07fc, 0x008b07fc,
453 0x008b07fc, 0x008b07fc, 0x008b3c01, 0x008b3c01, 0x008b3c01, 0x008b3c01, 0x008b3c01, 0x008b3c01, 0x008b3c01,
454 0x008b3c01, 0x008b3c01, 0x008b3c01, 0x008b3c01, 0x008b3c01, 0x008b3c01, 0x008b3c01, 0x008b3c01, 0x008b3c01,
455 0x008b3fff, 0x008b3fff, 0x008b3fff, 0x008b3fff, 0x008b3fff, 0x008b3fff, 0x008b3fff, 0x008b3fff, 0x008b3fff,
456 0x008b3fff, 0x008b3fff, 0x008b3fff, 0x008b3fff, 0x008b3fff, 0x008b3fff, 0x008b3fff, 0x008b3801, 0x008b3801,
457 0x008b3801, 0x008b3801, 0x008b3801, 0x008b3801, 0x008b3801, 0x008b3801, 0x008b3801, 0x008b3801, 0x008b3801,
458 0x008b3801, 0x008b3801, 0x008b3801, 0x008b3801, 0x008b3801, 0x008b3bff, 0x008b3bff, 0x008b3bff, 0x008b3bff,
459 0x008b3bff, 0x008b3bff, 0x008b3bff, 0x008b3bff, 0x008b3bff, 0x008b3bff, 0x008b3bff, 0x008b3bff, 0x008b3bff,
460 0x008b3bff, 0x008b3bff, 0x008b3bff, 0x008b1002, 0x008b1002, 0x008b1002, 0x008b1002, 0x008b1002, 0x008b1002,
461 0x008b1002, 0x008b1002, 0x008b1002, 0x008b1002, 0x008b1002, 0x008b1002, 0x008b1002, 0x008b1002, 0x008b1002,
462 0x008b1002, 0x008b13fe, 0x008b13fe, 0x008b13fe, 0x008b13fe, 0x008b13fe, 0x008b13fe, 0x008b13fe, 0x008b13fe,
463 0x008b13fe, 0x008b13fe, 0x008b13fe, 0x008b13fe, 0x008b13fe, 0x008b13fe, 0x008b13fe, 0x008b13fe,
464};
465
466// Version-3 delta-DC size books, indexed by size 0..8: MPEG-1's DC size codes
467// (ISO/IEC 11172-2 tables B-12 and B-13). Blocks 0 and 1 of a macroblock are Cr and
468// Cb and take the chroma book; blocks 2..5 are luma and share the other one. Both
469// are prefix-free, checked at generation time, so a linear walk resolves them
470// without caring about the order.
471static const uint8_t c_bsdecDcLumaCode[9] = {0x04, 0x00, 0x01, 0x05, 0x06, 0x0e, 0x1e, 0x3e, 0x7e};
472static const uint8_t c_bsdecDcLumaBits[9] = {3, 2, 2, 3, 3, 4, 5, 6, 7};
473static const uint8_t c_bsdecDcChromaCode[9] = {0x00, 0x01, 0x02, 0x06, 0x0e, 0x1e, 0x3e, 0x7e, 0xfe};
474static const uint8_t c_bsdecDcChromaBits[9] = {2, 2, 2, 3, 4, 5, 6, 7, 8};