vc1data.c
Go to the documentation of this file.
1 /*
2  * VC-1 and WMV3 decoder
3  * copyright (c) 2011 Mashiat Sarker Shakkhar
4  * copyright (c) 2006 Konstantin Shishkov
5  * (c) 2005 anonymous, Alex Beregszaszi, Michael Niedermayer
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 /**
25  * @file
26  * VC-1 tables.
27  */
28 
29 #include "avcodec.h"
30 #include "vc1.h"
31 #include "vc1data.h"
32 
33 /** Table for conversion between TTBLK and TTMB */
34 const int ff_vc1_ttblk_to_tt[3][8] = {
38 };
39 
41 
42 /** MV P mode - the 5th element is only used for mode 1 */
46 };
50 };
51 
52 /* MBMODE table for interlaced frame P-picture */
53 const uint8_t ff_vc1_mbmode_intfrp[2][15][4] = {
54  { /* 1: 4-MV, 0: non-4-MV */
55  /* Type, FIELDTX, 1-MV Differential present, Residuals (CBP) present */
56  /* Table 164 - Table 167 */
57  { MV_PMODE_INTFR_1MV , 0, 1, 1 },
58  { MV_PMODE_INTFR_1MV , 1, 1, 1 },
59  { MV_PMODE_INTFR_1MV , 0, 1, 0 },
60  { MV_PMODE_INTFR_1MV , 0, 0, 1 },
61  { MV_PMODE_INTFR_1MV , 1, 0, 1 },
62  { MV_PMODE_INTFR_2MV_FIELD, 0, 0, 1 },
63  { MV_PMODE_INTFR_2MV_FIELD, 1, 0, 1 },
64  { MV_PMODE_INTFR_2MV_FIELD, 0, 0, 0 },
65  { MV_PMODE_INTFR_INTRA , 0, 0, 0 }
66  },
67  {
68  /* Table 160 - Table 163 */
69  { MV_PMODE_INTFR_1MV , 0, 1, 1 },
70  { MV_PMODE_INTFR_1MV , 1, 1, 1 },
71  { MV_PMODE_INTFR_1MV , 0, 1, 0 },
72  { MV_PMODE_INTFR_1MV , 0, 0, 1 },
73  { MV_PMODE_INTFR_1MV , 1, 0, 1 },
74  { MV_PMODE_INTFR_2MV_FIELD, 0, 0, 1 },
75  { MV_PMODE_INTFR_2MV_FIELD, 1, 0, 1 },
76  { MV_PMODE_INTFR_2MV_FIELD, 0, 0, 0 },
77  { MV_PMODE_INTFR_4MV , 0, 0, 1 },
78  { MV_PMODE_INTFR_4MV , 1, 0, 1 },
79  { MV_PMODE_INTFR_4MV , 0, 0, 0 },
80  { MV_PMODE_INTFR_4MV_FIELD, 0, 0, 1 },
81  { MV_PMODE_INTFR_4MV_FIELD, 1, 0, 1 },
82  { MV_PMODE_INTFR_4MV_FIELD, 0, 0, 0 },
83  { MV_PMODE_INTFR_INTRA , 0, 0, 0 }
84  }
85 };
86 
87 const int ff_vc1_fps_nr[7] = { 24, 25, 30, 50, 60, 48, 72 },
88  ff_vc1_fps_dr[2] = { 1000, 1001 };
89 const uint8_t ff_vc1_pquant_table[3][32] = {
90  /* Implicit quantizer */
91  { 0, 1, 2, 3, 4, 5, 6, 7, 8, 6, 7, 8, 9, 10, 11, 12,
92  13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 29, 31 },
93  /* Explicit quantizer, pquantizer uniform */
94  { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
95  16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 },
96  /* Explicit quantizer, pquantizer non-uniform */
97  { 0, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
98  14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 29, 31 }
99 };
100 
101 /** @name VC-1 VLC tables and defines
102  * @todo TODO move this into the context
103  */
104 //@{
105 #define VC1_BFRACTION_VLC_BITS 7
107 #define VC1_IMODE_VLC_BITS 4
109 #define VC1_NORM2_VLC_BITS 3
111 #define VC1_NORM6_VLC_BITS 9
113 /* Could be optimized, one table only needs 8 bits */
114 #define VC1_TTMB_VLC_BITS 9 //12
116 #define VC1_MV_DIFF_VLC_BITS 9 //15
118 #define VC1_CBPCY_P_VLC_BITS 9 //14
120 #define VC1_ICBPCY_VLC_BITS 9
122 #define VC1_4MV_BLOCK_PATTERN_VLC_BITS 6
124 #define VC1_2MV_BLOCK_PATTERN_VLC_BITS 3
126 #define VC1_TTBLK_VLC_BITS 5
128 #define VC1_SUBBLKPAT_VLC_BITS 6
130 #define VC1_INTFR_4MV_MBMODE_VLC_BITS 9
132 #define VC1_INTFR_NON4MV_MBMODE_VLC_BITS 6
134 #define VC1_IF_MMV_MBMODE_VLC_BITS 5
136 #define VC1_IF_1MV_MBMODE_VLC_BITS 5
138 #define VC1_1REF_MVDATA_VLC_BITS 9
140 #define VC1_2REF_MVDATA_VLC_BITS 9
142 
144 
145 #define VC1_IF_MBMODE_VLC_BITS 5 // as a placeholder for VC1_IF_MMV_MBMODE_VLC_BITS
146  // or VC1_IF_1MV_MBMODE_VLC_BITS since they are the same
147 //@}
148 
149 
150 #if B_FRACTION_DEN == 840 // original bfraction from vc9data.h, not conforming to standard
151 /* bfraction is fractional, we scale to the GCD 3*5*7*8 = 840 */
152 const int16_t ff_vc1_bfraction_lut[23] = {
153  420 /*1/2*/, 280 /*1/3*/, 560 /*2/3*/, 210 /*1/4*/,
154  630 /*3/4*/, 168 /*1/5*/, 336 /*2/5*/,
155  504 /*3/5*/, 672 /*4/5*/, 140 /*1/6*/, 700 /*5/6*/,
156  120 /*1/7*/, 240 /*2/7*/, 360 /*3/7*/, 480 /*4/7*/,
157  600 /*5/7*/, 720 /*6/7*/, 105 /*1/8*/, 315 /*3/8*/,
158  525 /*5/8*/, 735 /*7/8*/,
159  -1 /*inv.*/, 0 /*BI fm*/
160 };
161 #else
162 /* pre-computed scales for all bfractions and base=256 */
163 const int16_t ff_vc1_bfraction_lut[23] = {
164  128 /*1/2*/, 85 /*1/3*/, 170 /*2/3*/, 64 /*1/4*/,
165  192 /*3/4*/, 51 /*1/5*/, 102 /*2/5*/,
166  153 /*3/5*/, 204 /*4/5*/, 43 /*1/6*/, 215 /*5/6*/,
167  37 /*1/7*/, 74 /*2/7*/, 111 /*3/7*/, 148 /*4/7*/,
168  185 /*5/7*/, 222 /*6/7*/, 32 /*1/8*/, 96 /*3/8*/,
169  160 /*5/8*/, 224 /*7/8*/,
170  -1 /*inv.*/, 0 /*BI fm*/
171 };
172 #endif
173 
175  3, 3, 3, 3,
176  3, 3, 3,
177  7, 7, 7, 7,
178  7, 7, 7, 7,
179  7, 7, 7, 7,
180  7, 7,
181  7, 7
182 };
184  0, 1, 2, 3,
185  4, 5, 6,
186  112, 113, 114, 115,
187  116, 117, 118, 119,
188  120, 121, 122, 123,
189  124, 125,
190  126, 127
191 };
192 
193 //Same as H.264
195  { 0, 1 },
196  { 1, 1 },
197  { 12, 11 },
198  { 10, 11 },
199  { 16, 11 },
200  { 40, 33 },
201  { 24, 11 },
202  { 20, 11 },
203  { 32, 11 },
204  { 80, 33 },
205  { 18, 11 },
206  { 15, 11 },
207  { 64, 33 },
208  { 160, 99 },
209  { 0, 1 },
210  { 0, 1 }
211 };
212 
213 /* BitPlane IMODE - such a small table... */
215  0, 2, 1, 3, 1, 2, 3
216 };
218  4, 2, 3, 2, 4, 3, 3
219 };
220 
221 /* Normal-2 imode */
223  0, 4, 5, 3
224 };
226  1, 3, 3, 2
227 };
228 
229 const uint16_t ff_vc1_norm6_codes[64] = {
230  0x001, 0x002, 0x003, 0x000, 0x004, 0x001, 0x002, 0x047, 0x005, 0x003, 0x004, 0x04B, 0x005, 0x04D, 0x04E, 0x30E,
231  0x006, 0x006, 0x007, 0x053, 0x008, 0x055, 0x056, 0x30D, 0x009, 0x059, 0x05A, 0x30C, 0x05C, 0x30B, 0x30A, 0x037,
232  0x007, 0x00A, 0x00B, 0x043, 0x00C, 0x045, 0x046, 0x309, 0x00D, 0x049, 0x04A, 0x308, 0x04C, 0x307, 0x306, 0x036,
233  0x00E, 0x051, 0x052, 0x305, 0x054, 0x304, 0x303, 0x035, 0x058, 0x302, 0x301, 0x034, 0x300, 0x033, 0x032, 0x007,
234 };
235 
237  1, 4, 4, 8, 4, 8, 8, 10, 4, 8, 8, 10, 8, 10, 10, 13,
238  4, 8, 8, 10, 8, 10, 10, 13, 8, 10, 10, 13, 10, 13, 13, 9,
239  4, 8, 8, 10, 8, 10, 10, 13, 8, 10, 10, 13, 10, 13, 13, 9,
240  8, 10, 10, 13, 10, 13, 13, 9, 10, 13, 13, 9, 13, 9, 9, 6,
241 };
242 
243 /* 4MV Block pattern VLC tables */
245  { 14, 58, 59, 25, 12, 26, 15, 15, 13, 24, 27, 0, 28, 1, 2, 2 },
246  { 8, 18, 19, 4, 20, 5, 30, 11, 21, 31, 6, 12, 7, 13, 14, 0 },
247  { 15, 6, 7, 2, 8, 3, 28, 9, 10, 29, 4, 11, 5, 12, 13, 0 },
248  { 0, 11, 12, 4, 13, 5, 30, 16, 14, 31, 6, 17, 7, 18, 19, 10 }
249 };
251  { 5, 6, 6, 5, 5, 5, 5, 4, 5, 5, 5, 3, 5, 3, 3, 2 },
252  { 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4, 4, 4, 4, 4, 2 },
253  { 4, 4, 4, 4, 4, 4, 5, 4, 4, 5, 4, 4, 4, 4, 4, 3 },
254  { 2, 4, 4, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4 }
255 };
256 
257 /* 2MV Block pattern VLC tables */
259  { 2, 1, 0, 3 }, { 1, 0, 2, 3 }, { 2, 0, 3, 1 }, { 1, 3, 2, 0 }
260 };
261 
263  { 2, 2, 2, 2 }, { 1, 2, 3, 3 }, { 3, 2, 3, 1 }, { 1, 3, 3, 2 }
264 };
265 
266 /* Interlaced frame picture 4MV MBMODE VLC tables (p. 246, p. 360) */
267 const uint16_t ff_vc1_intfr_4mv_mbmode_codes[4][15] = {
268  { 22, 17, 0, 47, 32, 10, 1, 3, 67, 133, 132, 92, 19, 93, 18 },
269  { 3, 45, 0, 7, 23, 6, 1, 2, 10, 39, 44, 8, 18, 77, 76 },
270  { 15, 6, 28, 9, 41, 6, 2, 15, 14, 8, 40, 29, 0, 21, 11 },
271  { 7, 198, 1, 2, 193, 13, 25, 0, 97, 1599, 98, 398, 798, 192, 1598 }
272 };
273 
275  { 5, 5, 2, 6, 6, 4, 2, 2, 7, 8, 8, 7, 5, 7, 5 },
276  { 3, 6, 3, 3, 5, 3, 3, 3, 4, 6, 6, 4, 5, 7, 7 },
277  { 4, 3, 5, 5, 7, 4, 2, 5, 5, 5, 7, 5, 2, 6, 5 },
278  { 4, 9, 1, 3, 9, 5, 6, 2, 8, 12, 8, 10, 11, 9, 12 }
279 };
280 
281 /* Interlaced frame picture NON-4MV MBMODE VLC tables (p. 363) */
283  { 9, 22, 0, 17, 16, 10, 1, 3, 23 },
284  { 7, 0, 5, 2, 1, 1, 6, 3, 4 },
285  { 1, 0, 10, 23, 44, 8, 3, 9, 45 },
286  { 7, 97, 1, 2, 49, 13, 25, 0, 96 }
287 };
288 
290  { 4, 5, 2, 5, 5, 4, 2, 2, 5 },
291  { 3, 4, 6, 2, 3, 2, 3, 5, 6 },
292  { 2, 2, 4, 5, 6, 4, 2, 4, 6 },
293  { 4, 8, 1, 3, 7, 5, 6, 2, 8 }
294 };
295 
296 /* Interlaced field picture MBMODE VLC tables (p. 356 - 11.4.1, 11.4.2) */
297 /* mixed-MV */
299  { 16, 17, 3, 3, 0, 5, 9, 2 },
300  { 8, 9, 3, 6, 7, 0, 5, 2 },
301  { 16, 17, 5, 3, 0, 3, 9, 2 },
302  { 56, 57, 15, 4, 5, 6, 29, 0 },
303  { 52, 53, 27, 14, 15, 2, 12, 0 },
304  { 56, 57, 29, 5, 6, 0, 15, 4 },
305  { 16, 17, 6, 7, 0, 1, 9, 5 },
306  { 56, 57, 0, 5, 6, 29, 4, 15 }
307 };
309  { 6, 6, 2, 3, 2, 4, 5, 2 },
310  { 5, 5, 3, 3, 3, 2, 4, 2 },
311  { 6, 6, 4, 3, 2, 2, 5, 2 },
312  { 6, 6, 4, 3, 3, 3, 5, 1 },
313  { 6, 6, 5, 4, 4, 2, 4, 1 },
314  { 6, 6, 5, 3, 3, 1, 4, 3 },
315  { 5, 5, 3, 3, 2, 2, 4, 3 },
316  { 6, 6, 1, 3, 3, 5, 3, 4 }
317 };
318 /* 1MV */
320  { 0, 1, 1, 1, 1, 1 },
321  { 0, 1, 1, 1, 1, 1 },
322  { 16, 17, 3, 0, 9, 5 },
323  { 20, 21, 3, 11, 0, 4 },
324  { 4, 5, 2, 3, 3, 0 },
325  { 4, 5, 3, 2, 0, 3 },
326  { 0, 1, 1, 1, 1, 1 },
327  { 16, 17, 9, 5, 3, 0 }
328 };
330  { 5, 5, 1, 3, 2, 4 },
331  { 5, 5, 1, 2, 3, 4 },
332  { 5, 5, 2, 1, 4, 3 },
333  { 5, 5, 2, 4, 1, 3 },
334  { 4, 4, 2, 3, 2, 2 },
335  { 4, 4, 3, 2, 2, 2 },
336  { 5, 5, 3, 4, 1, 2 },
337  { 5, 5, 4, 3, 2, 1 }
338 };
339 
340 /* Interlaced frame/field picture MVDATA VLC tables */
341 
342 /* 1-reference tables */
343 const uint32_t ff_vc1_1ref_mvdata_codes[4][72] = { /* uint32_t may be too big */
344  {
345  0x00005, 0x0000C, 0x0001E, 0x00012, 0x0000C, 0x00034, 0x00075, 0x00070,
346  0x00000, 0x00008, 0x0001B, 0x00008, 0x0001D, 0x0007C, 0x000D6, 0x001DE,
347  0x001AF, 0x00005, 0x0001B, 0x00026, 0x0001E, 0x00012, 0x00076, 0x0004D,
348  0x001F6, 0x001F4, 0x00039, 0x0007F, 0x00027, 0x0006A, 0x00071, 0x00035,
349  0x00071, 0x00068, 0x001DC, 0x00027, 0x00073, 0x000FF, 0x000E8, 0x000E9,
350  0x0007E, 0x001F9, 0x001F5, 0x001FD, 0x0003E, 0x001CA, 0x003F9, 0x0004C,
351  0x00069, 0x001FA, 0x001DF, 0x001F7, 0x00070, 0x001DD, 0x00E4D, 0x00727,
352  0x00392, 0x001C8, 0x001CB, 0x003F8, 0x001AE, 0x001F8, 0x001FB, 0x0E4CE,
353  0x0E4CF, 0x07260, 0x07261, 0x07262, 0x07263, 0x07264, 0x07265, 0x07266
354  },
355  {
356  0x00007, 0x00001, 0x00007, 0x00016, 0x00001, 0x00045, 0x00018, 0x002B6,
357  0x00006, 0x00004, 0x00017, 0x00010, 0x00029, 0x0002C, 0x0015A, 0x00066,
358  0x0019E, 0x00009, 0x00028, 0x00017, 0x00000, 0x0002A, 0x00004, 0x0005B,
359  0x000B5, 0x000CE, 0x00006, 0x00044, 0x0000F, 0x00046, 0x0000E, 0x000AC,
360  0x00032, 0x00037, 0x011EB, 0x0000A, 0x0001A, 0x0011F, 0x00016, 0x00014,
361  0x0002B, 0x00168, 0x00055, 0x023D5, 0x00057, 0x0002F, 0x00036, 0x0002E,
362  0x00169, 0x00054, 0x0047B, 0x0019F, 0x02B7D, 0x0008E, 0x00ADE, 0x00479,
363  0x0056E, 0x008F4, 0x015BF, 0x00478, 0x023D4, 0x0ADF1, 0x056F9, 0xADF0E,
364  0xADF0F, 0x56F80, 0x56F81, 0x56F82, 0x56F83, 0x56F84, 0x56F85, 0x56F86
365  },
366  {
367  0x00002, 0x00006, 0x00007, 0x0000D, 0x00007, 0x00030, 0x000FF, 0x001F0,
368  0x00002, 0x00000, 0x00005, 0x00019, 0x0001E, 0x00007, 0x00063, 0x000FD,
369  0x00023, 0x0000E, 0x0001B, 0x0001A, 0x00006, 0x00009, 0x00018, 0x000C5,
370  0x00033, 0x001F1, 0x00002, 0x003FB, 0x001F3, 0x00022, 0x001FC, 0x00042,
371  0x00623, 0x00083, 0x00620, 0x0007D, 0x00040, 0x00043, 0x003E4, 0x003E5,
372  0x00191, 0x00FE9, 0x00105, 0x00208, 0x000FC, 0x00624, 0x00622, 0x00190,
373  0x00626, 0x007F5, 0x00C4B, 0x01FD0, 0x0104D, 0x00065, 0x00C42, 0x000C9,
374  0x00627, 0x00C43, 0x00C4A, 0x0104E, 0x01FD1, 0x0104F, 0x00412, 0x104CE,
375  0x104CF, 0x08260, 0x08261, 0x08262, 0x08263, 0x08264, 0x08265, 0x08266
376  },
377  {
378  0x0000D, 0x00001, 0x00004, 0x00000, 0x00017, 0x00005, 0x0007F, 0x0004D,
379  0x00003, 0x00011, 0x0003E, 0x0003B, 0x00017, 0x00067, 0x0004A, 0x000C3,
380  0x000F2, 0x0000A, 0x0002C, 0x00032, 0x0003D, 0x00015, 0x00028, 0x00093,
381  0x000CC, 0x00096, 0x00003, 0x00075, 0x00020, 0x0002D, 0x00021, 0x00029,
382  0x00090, 0x001D0, 0x001FB, 0x0001C, 0x0004C, 0x00060, 0x00009, 0x00008,
383  0x0002D, 0x0009F, 0x001FA, 0x0013D, 0x00031, 0x000FC, 0x00058, 0x00092,
384  0x000F0, 0x000F1, 0x000CD, 0x00185, 0x00165, 0x0004E, 0x00091, 0x000E9,
385  0x00184, 0x001D1, 0x001E6, 0x00097, 0x001E7, 0x000B3, 0x0013C, 0x0164E,
386  0x0164F, 0x00B20, 0x00B21, 0x00B22, 0x00B23, 0x00B24, 0x00B25, 0x00B26
387  }
388 };
389 
391  {
392  3, 4, 5, 5, 5, 6, 7, 7, 2, 4, 5, 5, 6, 7, 8, 9, 9, 4,
393  6, 6, 6, 6, 7, 8, 9, 9, 6, 8, 7, 7, 7, 7, 8, 8, 9, 6,
394  8, 8, 8, 8, 8, 9, 9, 9, 7, 10, 10, 8, 8, 9, 9, 9, 8, 9,
395  13, 12, 11, 10, 10, 10, 9, 9, 9, 17, 17, 16, 16, 16, 16, 16, 16, 16
396  },
397  {
398  3, 3, 4, 5, 5, 7, 8, 10, 3, 4, 5, 5, 6, 7, 9, 10, 12, 4,
399  6, 6, 5, 6, 6, 8, 9, 11, 4, 7, 7, 7, 7, 8, 9, 9, 13, 5,
400  8, 9, 8, 8, 9, 10, 10, 14, 7, 9, 9, 9, 10, 10, 11, 12, 14, 8,
401  12, 11, 11, 12, 13, 11, 14, 16, 15, 20, 20, 19, 19, 19, 19, 19, 19, 19
402  },
403  {
404  3, 4, 4, 4, 5, 6, 8, 9, 2, 4, 5, 5, 5, 6, 7, 8, 8, 4,
405  7, 7, 6, 6, 7, 8, 8, 9, 5, 10, 9, 8, 9, 9, 11, 10, 11, 7,
406  9, 9, 10, 10, 11, 12, 11, 12, 8, 11, 11, 11, 11, 11, 12, 13, 15, 9,
407  12, 10, 11, 12, 12, 15, 13, 15, 13, 19, 19, 18, 18, 18, 18, 18, 18, 18
408  },
409  {
410  4, 4, 4, 4, 5, 5, 7, 7, 3, 5, 6, 6, 6, 7, 7, 8, 8, 4,
411  6, 6, 6, 6, 7, 8, 8, 8, 4, 7, 6, 6, 6, 7, 8, 9, 9, 5,
412  7, 7, 6, 6, 7, 8, 9, 9, 6, 8, 8, 8, 8, 8, 8, 9, 10, 7,
413  8, 8, 9, 9, 9, 8, 9, 9, 9, 14, 14, 13, 13, 13, 13, 13, 13, 13
414  }
415 };
416 
417 /* 2-reference tables */
418 const uint32_t ff_vc1_2ref_mvdata_codes[8][126] = { /* table 132 - table 139 */
419  {
420  0x0000C, 0x0001C, 0x0000B, 0x00000, 0x0000E, 0x0002A, 0x00050, 0x00368,
421  0x00002, 0x0001A, 0x00004, 0x0003A, 0x0001D, 0x0006C, 0x000EF, 0x001BC,
422  0x0015F, 0x0000F, 0x00003, 0x0001C, 0x0000D, 0x0000B, 0x0003E, 0x000A7,
423  0x00146, 0x00199, 0x00006, 0x0001F, 0x00004, 0x0003C, 0x00007, 0x001BE,
424  0x0008B, 0x0002C, 0x007B3, 0x00005, 0x000DB, 0x00056, 0x000EC, 0x00052,
425  0x001BD, 0x00078, 0x000CF, 0x00573, 0x00009, 0x00023, 0x000ED, 0x00018,
426  0x00006, 0x00044, 0x000F5, 0x00079, 0x006D2, 0x0006E, 0x0002B, 0x0015D,
427  0x00017, 0x0037F, 0x00144, 0x000CE, 0x00028, 0x000AB, 0x00010, 0x001B5,
428  0x000F7, 0x000A6, 0x0007B, 0x00028, 0x001ED, 0x001E9, 0x006FD, 0x00004,
429  0x000F5, 0x00029, 0x0028A, 0x0028B, 0x0028F, 0x00DF9, 0x00335, 0x01E85,
430  0x000EE, 0x002BD, 0x0002B, 0x003D8, 0x003D1, 0x00198, 0x001E9, 0x0051D,
431  0x000B4, 0x0003F, 0x00455, 0x0022B, 0x00229, 0x00451, 0x00578, 0x007B2,
432  0x00570, 0x00155, 0x00032, 0x003D0, 0x00054, 0x006D3, 0x00571, 0x00454,
433  0x00334, 0x01BF1, 0x000B7, 0x00029, 0x01E84, 0x0016C, 0x0019B, 0x01BF0,
434  0x00579, 0x00F43, 0x000B5, 0x008A1, 0x0002A, 0x0016D, 0x008A0, 0x007A0,
435  0x003D1, 0x00AE5, 0x00154, 0x00AE4, 0x00A39, 0x00A38
436  },
437  {
438  0x00003, 0x00009, 0x00016, 0x00010, 0x000D7, 0x00335, 0x00574, 0x00555,
439  0x00000, 0x0001D, 0x00009, 0x00017, 0x0002C, 0x000AD, 0x00374, 0x006B3,
440  0x00577, 0x0000F, 0x00018, 0x0000A, 0x0002E, 0x00022, 0x0017C, 0x00E7B,
441  0x01B89, 0x015D8, 0x00008, 0x00034, 0x0006D, 0x00023, 0x001C2, 0x00376,
442  0x002D3, 0x01C4A, 0x0330A, 0x00014, 0x0006A, 0x00072, 0x0006C, 0x000E3,
443  0x0019B, 0x0073F, 0x01CF0, 0x00B41, 0x00032, 0x000E6, 0x000E0, 0x000CF,
444  0x000AB, 0x0019C, 0x002AB, 0x00E2B, 0x015D9, 0x0006F, 0x001C3, 0x000AF,
445  0x000BF, 0x000AC, 0x0017D, 0x006E3, 0x00E29, 0x01984, 0x00054, 0x000B5,
446  0x0017A, 0x001AD, 0x00199, 0x00178, 0x00358, 0x002D2, 0x01C4B, 0x0005B,
447  0x002A8, 0x00331, 0x00388, 0x0038B, 0x00370, 0x00713, 0x00CC3, 0x01CF1,
448  0x001B9, 0x005EF, 0x00738, 0x002F2, 0x0033B, 0x002B9, 0x006EB, 0x00570,
449  0x00E24, 0x0039D, 0x005A2, 0x005A3, 0x00E7D, 0x005EE, 0x00739, 0x00554,
450  0x00AA5, 0x00AA4, 0x00377, 0x01CF5, 0x00BCE, 0x00E79, 0x00660, 0x00674,
451  0x006EA, 0x00E7C, 0x00D65, 0x002F6, 0x015DA, 0x01B88, 0x005A1, 0x01CF4,
452  0x005E6, 0x00E28, 0x00575, 0x00D64, 0x00334, 0x0330B, 0x015DB, 0x00B40,
453  0x00BCF, 0x00DC5, 0x00E2A, 0x00675, 0x00571, 0x00553
454  },
455  {
456  0x00004, 0x00002, 0x00010, 0x00003, 0x00017, 0x00045, 0x0003E, 0x0007E,
457  0x00003, 0x00002, 0x00028, 0x0001E, 0x00015, 0x00047, 0x00002, 0x0014D,
458  0x00060, 0x0000B, 0x00026, 0x00024, 0x00014, 0x00032, 0x0006F, 0x000C3,
459  0x00531, 0x006E5, 0x00015, 0x0003F, 0x0002D, 0x00001, 0x0013E, 0x000DD,
460  0x000F6, 0x00305, 0x00331, 0x0000E, 0x00003, 0x00034, 0x00033, 0x0001A,
461  0x0014A, 0x000C5, 0x000F4, 0x006E4, 0x00001, 0x0003C, 0x0007D, 0x0008D,
462  0x0009D, 0x00031, 0x0006E, 0x00296, 0x000CD, 0x00025, 0x00149, 0x00032,
463  0x00089, 0x00036, 0x00088, 0x0006F, 0x00003, 0x0031D, 0x0000E, 0x001AA,
464  0x0027E, 0x00061, 0x0014E, 0x0014F, 0x00067, 0x000FF, 0x00183, 0x00036,
465  0x00357, 0x000F5, 0x000C6, 0x000C2, 0x00299, 0x00119, 0x00231, 0x00350,
466  0x0002C, 0x0018F, 0x00530, 0x00297, 0x00004, 0x001B8, 0x000C0, 0x0027A,
467  0x00311, 0x0009C, 0x00621, 0x00199, 0x0031C, 0x000F7, 0x003E3, 0x00356,
468  0x00189, 0x00005, 0x0006B, 0x008C2, 0x00330, 0x004FF, 0x004F0, 0x00351,
469  0x004F2, 0x001F2, 0x00373, 0x00000, 0x00C41, 0x008C3, 0x009EC, 0x003E2,
470  0x00304, 0x004F7, 0x004F1, 0x001F0, 0x00148, 0x00C40, 0x009ED, 0x008C0,
471  0x008C1, 0x004F3, 0x004FE, 0x000FE, 0x001F3, 0x001A9
472  },
473  {
474  0x00000, 0x00004, 0x0002F, 0x00052, 0x00010, 0x000AD, 0x0050B, 0x00190,
475  0x00003, 0x00016, 0x00007, 0x0000D, 0x000BB, 0x00173, 0x000C9, 0x0050F,
476  0x0172C, 0x00003, 0x00011, 0x00005, 0x00043, 0x00023, 0x0004B, 0x0032E,
477  0x02E5B, 0x00482, 0x00009, 0x0002A, 0x00014, 0x0002A, 0x00108, 0x005CA,
478  0x0065A, 0x02136, 0x02132, 0x0000B, 0x00013, 0x00041, 0x000B8, 0x00174,
479  0x00100, 0x014DA, 0x0404E, 0x01437, 0x0002B, 0x00085, 0x000A7, 0x000A0,
480  0x0014C, 0x0029A, 0x0032C, 0x02133, 0x0142A, 0x00051, 0x00284, 0x000AC,
481  0x00102, 0x00045, 0x00044, 0x0081B, 0x0065E, 0x00CB7, 0x00018, 0x0050C,
482  0x00212, 0x002E4, 0x00203, 0x00094, 0x00122, 0x0081A, 0x00655, 0x00033,
483  0x002BA, 0x00246, 0x00242, 0x00A6E, 0x0040C, 0x00808, 0x02134, 0x0404F,
484  0x00175, 0x00405, 0x00247, 0x0012A, 0x00A14, 0x002BB, 0x00191, 0x0084F,
485  0x01438, 0x000AF, 0x00B97, 0x00483, 0x0143B, 0x0032B, 0x00243, 0x0142B,
486  0x00958, 0x029BF, 0x00049, 0x00A6C, 0x014DB, 0x004AD, 0x014DE, 0x0084E,
487  0x01434, 0x00257, 0x02E5A, 0x00207, 0x01435, 0x01439, 0x00CB6, 0x0143A,
488  0x00194, 0x00654, 0x02135, 0x0537C, 0x0015C, 0x00240, 0x01012, 0x0537D,
489  0x00959, 0x01098, 0x01436, 0x0065F, 0x02026, 0x02137
490  },
491  {
492  0x00005, 0x00019, 0x00016, 0x00011, 0x0003E, 0x0005E, 0x000EF, 0x000E2,
493  0x00000, 0x00039, 0x0002B, 0x00026, 0x00028, 0x00012, 0x000C2, 0x000ED,
494  0x0011D, 0x0000D, 0x00031, 0x0002A, 0x00025, 0x00020, 0x0005C, 0x001ED,
495  0x0024D, 0x00770, 0x00006, 0x0007A, 0x00060, 0x0004F, 0x00048, 0x00039,
496  0x00186, 0x00213, 0x00EC6, 0x0000F, 0x00026, 0x0005F, 0x00075, 0x00070,
497  0x00027, 0x001DB, 0x003C6, 0x0078F, 0x0003F, 0x000A6, 0x000F0, 0x0003A,
498  0x00052, 0x0004E, 0x000E3, 0x001D9, 0x0030F, 0x00010, 0x001DD, 0x000A7,
499  0x000F7, 0x00022, 0x00092, 0x003C4, 0x002EF, 0x00762, 0x00079, 0x0008F,
500  0x001DA, 0x00087, 0x000E8, 0x000BA, 0x00176, 0x000EE, 0x003B0, 0x00085,
501  0x00119, 0x0030E, 0x00108, 0x001D2, 0x0010C, 0x00773, 0x00424, 0x00434,
502  0x00071, 0x005DD, 0x001C1, 0x003A7, 0x00127, 0x0008D, 0x0021B, 0x007B2,
503  0x001DF, 0x003D8, 0x00764, 0x00EE4, 0x003B3, 0x0074D, 0x001D8, 0x005DC,
504  0x0084A, 0x00499, 0x003C5, 0x01D8E, 0x00765, 0x00435, 0x00771, 0x001C2,
505  0x00118, 0x003BC, 0x00381, 0x00387, 0x07B33, 0x01097, 0x01096, 0x01ECD,
506  0x00E99, 0x00F1C, 0x00F1D, 0x00EE5, 0x0011C, 0x07B32, 0x03D98, 0x01D8F,
507  0x00E98, 0x00F67, 0x003BD, 0x00380, 0x00498, 0x00386
508  },
509  {
510  0x0000D, 0x00010, 0x0002E, 0x00039, 0x0000D, 0x00074, 0x000ED, 0x000B6,
511  0x00001, 0x00002, 0x00000, 0x00030, 0x00029, 0x00070, 0x000F3, 0x0008C,
512  0x00166, 0x00009, 0x00033, 0x00078, 0x00006, 0x000C4, 0x0000B, 0x00163,
513  0x000CC, 0x005BE, 0x0001F, 0x0002F, 0x00064, 0x00018, 0x000C6, 0x0000A,
514  0x00162, 0x002C0, 0x00EF3, 0x00007, 0x0000F, 0x000E3, 0x000CA, 0x000B2,
515  0x0018F, 0x003AE, 0x0075F, 0x00C51, 0x00015, 0x00047, 0x000EE, 0x000E2,
516  0x000EA, 0x00009, 0x0016A, 0x002C3, 0x0059D, 0x0003D, 0x00008, 0x001D9,
517  0x00032, 0x0000E, 0x0016E, 0x0032C, 0x0065B, 0x0196B, 0x00002, 0x0000F,
518  0x001D8, 0x0008D, 0x000B4, 0x001E4, 0x00067, 0x00317, 0x00794, 0x00022,
519  0x003BE, 0x00315, 0x00034, 0x00037, 0x002DE, 0x0006C, 0x00EFE, 0x0066C,
520  0x00028, 0x003CB, 0x003AC, 0x00035, 0x0016B, 0x003BD, 0x002C1, 0x0062C,
521  0x01DFE, 0x0000E, 0x0059E, 0x005BF, 0x000DA, 0x00629, 0x00584, 0x00EB7,
522  0x00B0A, 0x0066D, 0x0000C, 0x0077E, 0x0059C, 0x00778, 0x0075E, 0x0075A,
523  0x0062D, 0x00337, 0x00334, 0x00197, 0x01E57, 0x01DE4, 0x0196A, 0x01E56,
524  0x00C50, 0x00B3F, 0x01E54, 0x00B0B, 0x0018E, 0x001B6, 0x01E55, 0x00CB4,
525  0x00B3E, 0x00EB6, 0x01DE5, 0x01DFF, 0x00335, 0x001B7
526  },
527  {
528  0x00001, 0x0000B, 0x00019, 0x0006F, 0x0002A, 0x00075, 0x007EB, 0x00163,
529  0x00001, 0x0000E, 0x0001A, 0x0003E, 0x0001C, 0x0002D, 0x00164, 0x007EC,
530  0x00165, 0x00004, 0x00006, 0x00036, 0x0007F, 0x000AE, 0x00158, 0x0015C,
531  0x0056D, 0xFD510, 0x00000, 0x00004, 0x0007B, 0x000F3, 0x0003B, 0x007ED,
532  0x002B3, 0x002CC, 0x0056E, 0x00018, 0x0003E, 0x00017, 0x0001E, 0x000AF,
533  0x003F7, 0x0056F, 0x002CD, 0xFD511, 0x00014, 0x000AD, 0x000AA, 0x00014,
534  0x000A8, 0x00153, 0x000E8, 0x001FE, 0x00DCF, 0x00078, 0x001B8, 0x00152,
535  0x000FE, 0x002B1, 0x0015D, 0x00160, 0xFD512, 0xFD513, 0x0007A, 0x002B0,
536  0x001E5, 0x000E9, 0x000FC, 0x006E6, 0x00DC8, 0x00584, 0xFD514, 0x000AB,
537  0x00DDE, 0x00159, 0x003F4, 0x00DC9, 0x00DCA, 0x001FA, 0xFD515, 0xFD516,
538  0x000FC, 0x001FF, 0x001E4, 0x000AF, 0x0015A, 0x00167, 0x00DCB, 0x00585,
539  0xFD517, 0x003F7, 0x03F55, 0xFD518, 0x00DDC, 0x00586, 0x03F56, 0xFD519,
540  0x03F57, 0xFD51A, 0x001BA, 0x00587, 0x00588, 0x00DDF, 0x002B2, 0xFD51B,
541  0x00DCE, 0x003F6, 0xFD51C, 0x00FD4, 0xFD51D, 0xFD51E, 0xFD51F, 0x7EA80,
542  0x7EA81, 0x0056C, 0x7EA82, 0x7EA83, 0x00376, 0x00589, 0x0058A, 0x7EA84,
543  0x7EA85, 0x00DDD, 0x7EA86, 0x7EA87, 0x0058B, 0x07EA9
544  },
545  {
546  0x00003, 0x0000E, 0x0000F, 0x0007E, 0x00062, 0x000C6, 0x00CD9, 0x0063E,
547  0x00002, 0x00002, 0x00000, 0x00018, 0x0000C, 0x00069, 0x00039, 0x00707,
548  0x00C7E, 0x00002, 0x0000D, 0x0001B, 0x0000F, 0x0019A, 0x00647, 0x01A37,
549  0x346C4, 0x0346D, 0x00001, 0x0001E, 0x0007F, 0x0000A, 0x000E1, 0x00661,
550  0x00CE4, 0x346C5, 0x346C6, 0x0001D, 0x00030, 0x0000D, 0x000CB, 0x00199,
551  0x00320, 0x0008E, 0x0652E, 0x346C7, 0x0003E, 0x00039, 0x00035, 0x00033,
552  0x0019F, 0x001C0, 0x00CDA, 0x346C8, 0x346C9, 0x0000B, 0x000D0, 0x0019E,
553  0x00022, 0x00038, 0x0018E, 0x0031E, 0x03294, 0x0023C, 0x00032, 0x00012,
554  0x00013, 0x00071, 0x0019D, 0x00020, 0x00C87, 0x00CC0, 0x346CA, 0x00338,
555  0x00653, 0x001A2, 0x0032A, 0x00322, 0x00CE7, 0x00084, 0x0011F, 0x346CB,
556  0x00325, 0x00649, 0x0032B, 0x00077, 0x00648, 0x00642, 0x00C86, 0x00C8C,
557  0x346CC, 0x0003A, 0x019B7, 0x00043, 0x00327, 0x0008C, 0x0008D, 0x00C8D,
558  0x346CD, 0x346CE, 0x00337, 0x00CE5, 0x00085, 0x00326, 0x00347, 0x00CA4,
559  0x00C7F, 0x00D1A, 0x346CF, 0x00328, 0x1A360, 0x1A361, 0x00CD8, 0x0068C,
560  0x03295, 0x03296, 0x0652F, 0x066D8, 0x00331, 0x00706, 0x0023D, 0x00076,
561  0x00CC1, 0x00382, 0x00CE6, 0x066D9, 0x066DA, 0x066DB
562  }
563 };
564 
566  {
567  4, 5, 5, 5, 6, 7, 8, 10, 2, 5, 5, 6, 6, 7, 8, 9,
568  10, 4, 5, 6, 6, 7, 8, 9, 10, 11, 4, 6, 6, 7, 7, 9,
569  9, 10, 12, 5, 8, 8, 8, 8, 9, 9, 10, 12, 5, 7, 8, 7,
570  7, 8, 9, 9, 11, 7, 9, 10, 9, 10, 10, 10, 10, 12, 6, 9,
571  9, 9, 9, 9, 10, 10, 11, 7, 10, 10, 11, 11, 11, 12, 12, 14,
572  8, 11, 10, 11, 11, 11, 11, 12, 12, 8, 12, 11, 11, 12, 12, 12,
573  12, 13, 8, 12, 11, 11, 12, 12, 12, 13, 12, 9, 14, 13, 11, 13,
574  12, 13, 12, 13, 9, 13, 13, 12, 12, 13, 13, 13, 13, 13
575  },
576  {
577  3, 4, 5, 6, 8, 10, 11, 11, 2, 5, 5, 6, 7, 8, 10, 11,
578  11, 4, 5, 5, 6, 7, 9, 12, 13, 13, 4, 6, 7, 7, 9, 10,
579  11, 13, 14, 5, 7, 7, 7, 8, 9, 11, 13, 13, 6, 8, 8, 8,
580  8, 9, 10, 12, 13, 7, 9, 8, 8, 8, 9, 11, 12, 13, 7, 9,
581  9, 9, 9, 9, 10, 11, 13, 8, 10, 10, 10, 10, 10, 11, 12, 13,
582  9, 11, 11, 10, 10, 10, 11, 11, 12, 10, 12, 12, 12, 11, 11, 11,
583  12, 12, 10, 13, 12, 12, 11, 11, 11, 12, 12, 10, 13, 13, 12, 13,
584  11, 12, 11, 12, 10, 14, 13, 13, 12, 12, 12, 11, 11, 11
585  },
586  {
587  4, 4, 5, 5, 6, 7, 8, 9, 2, 5, 6, 6, 6, 7, 7, 9,
588  9, 4, 6, 6, 6, 7, 8, 9, 11, 12, 5, 7, 7, 7, 9, 9,
589  10, 11, 12, 5, 7, 7, 7, 7, 9, 9, 10, 12, 5, 8, 8, 8,
590  8, 8, 9, 10, 10, 6, 9, 8, 8, 8, 8, 9, 9, 11, 6, 10,
591  10, 9, 9, 9, 9, 10, 10, 7, 11, 10, 9, 9, 10, 9, 10, 11,
592  7, 10, 11, 10, 10, 10, 9, 10, 11, 8, 12, 11, 11, 10, 11, 11,
593  10, 10, 8, 12, 12, 11, 11, 11, 11, 10, 11, 8, 13, 12, 12, 11,
594  11, 11, 11, 10, 9, 13, 12, 12, 12, 11, 11, 10, 10, 10
595  },
596  {
597  3, 4, 6, 7, 7, 9, 11, 11, 2, 5, 5, 6, 8, 9, 10, 11,
598  13, 3, 5, 5, 7, 8, 9, 12, 14, 13, 4, 6, 6, 7, 9, 11,
599  13, 14, 14, 5, 7, 7, 8, 9, 9, 13, 15, 13, 6, 8, 8, 8,
600  9, 10, 12, 14, 13, 7, 10, 9, 9, 9, 9, 12, 13, 14, 7, 11,
601  10, 10, 10, 10, 11, 12, 13, 8, 11, 12, 12, 12, 11, 12, 14, 15,
602  9, 11, 12, 11, 12, 11, 11, 12, 13, 9, 12, 13, 13, 12, 12, 13,
603  14, 14, 9, 12, 13, 13, 13, 12, 13, 12, 14, 10, 13, 13, 14, 13,
604  11, 13, 14, 15, 10, 12, 13, 15, 14, 13, 13, 13, 14, 14
605  },
606  {
607  4, 5, 5, 5, 6, 7, 8, 8, 2, 6, 6, 6, 6, 6, 8, 9,
608  10, 4, 6, 6, 6, 6, 7, 9, 10, 11, 4, 7, 7, 7, 7, 7,
609  9, 10, 12, 5, 7, 7, 7, 7, 7, 9, 10, 11, 6, 8, 8, 7,
610  7, 7, 8, 9, 10, 6, 9, 8, 8, 7, 8, 10, 10, 11, 7, 9,
611  9, 8, 8, 8, 9, 9, 10, 8, 10, 10, 9, 9, 9, 11, 11, 11,
612  8, 11, 10, 10, 9, 9, 10, 11, 10, 10, 12, 12, 11, 11, 10, 11,
613  12, 11, 10, 13, 12, 11, 11, 10, 10, 11, 11, 11, 15, 13, 13, 13,
614  12, 12, 12, 12, 10, 15, 14, 13, 12, 12, 11, 11, 11, 11
615  },
616  {
617  4, 5, 6, 6, 6, 7, 8, 8, 2, 4, 5, 6, 6, 7, 8, 8,
618  9, 4, 6, 7, 7, 8, 8, 9, 10, 11, 5, 6, 7, 7, 8, 8,
619  9, 10, 12, 5, 7, 8, 8, 8, 9, 10, 11, 12, 5, 7, 8, 8,
620  8, 8, 9, 10, 11, 6, 8, 9, 8, 8, 9, 10, 11, 13, 5, 8,
621  9, 8, 8, 9, 9, 10, 11, 6, 10, 10, 9, 9, 10, 10, 12, 13,
622  6, 10, 10, 9, 9, 10, 10, 11, 13, 7, 11, 11, 11, 11, 11, 12,
623  12, 13, 7, 11, 11, 11, 11, 11, 11, 12, 12, 9, 13, 13, 13, 13,
624  12, 12, 13, 12, 9, 12, 13, 12, 12, 12, 13, 13, 12, 12
625  },
626  {
627  3, 5, 6, 8, 9, 10, 12, 12, 1, 5, 6, 7, 8, 9, 12, 12,
628  12, 4, 6, 7, 8, 9, 12, 12, 14, 21, 4, 6, 8, 9, 9, 12,
629  13, 13, 14, 6, 9, 8, 8, 9, 13, 14, 13, 21, 6, 9, 9, 8,
630  9, 10, 11, 12, 13, 8, 10, 10, 11, 11, 12, 12, 21, 21, 8, 11,
631  10, 11, 11, 12, 13, 14, 21, 9, 13, 10, 11, 13, 13, 12, 21, 21,
632  9, 12, 10, 11, 12, 12, 13, 14, 21, 11, 15, 21, 13, 14, 15, 21,
633  15, 21, 10, 14, 14, 13, 13, 21, 13, 13, 21, 13, 21, 21, 21, 20,
634  20, 14, 20, 20, 11, 14, 14, 20, 20, 13, 20, 20, 14, 16
635  },
636  {
637  2, 5, 6, 8, 9, 10, 13, 13, 2, 4, 5, 6, 8, 9, 10, 13,
638  14, 3, 5, 7, 8, 10, 12, 15, 20, 16, 4, 6, 8, 8, 10, 12,
639  13, 20, 20, 7, 8, 8, 9, 10, 11, 12, 16, 20, 7, 8, 8, 8,
640  10, 11, 13, 20, 20, 8, 10, 10, 10, 10, 11, 12, 15, 14, 8, 9,
641  9, 9, 10, 10, 13, 13, 20, 11, 12, 11, 11, 11, 13, 12, 13, 20,
642  11, 12, 11, 11, 12, 12, 13, 13, 20, 10, 14, 11, 11, 12, 12, 13,
643  20, 20, 11, 13, 12, 11, 12, 13, 14, 14, 20, 11, 19, 19, 13, 13,
644  15, 15, 16, 16, 11, 13, 14, 11, 13, 12, 13, 16, 16, 16
645  }
646 };
647 
649  0, 2, 4, 8, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13,
650  14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21
651 };
652 
653 /* P-Picture CBPCY VLC tables */
654 // Looks like original tables are not conforming to standard at all. Are they used for old WMV?
655 const uint16_t ff_vc1_cbpcy_p_codes[4][64] = {
656  {
657  0, 6, 15, 13, 13, 11, 3, 13, 5, 8, 49, 10, 12, 114, 102, 119,
658  1, 54, 96, 8, 10, 111, 5, 15, 12, 10, 2, 12, 13, 115, 53, 63,
659  1, 7, 1, 7, 14, 12, 4, 14, 1, 9, 97, 11, 7, 58, 52, 62,
660  4, 103, 1, 9, 11, 56, 101, 118, 4, 110, 100, 30, 2, 5, 4, 3
661  },
662  {
663  0, 9, 1, 18, 5, 14, 237, 26, 3, 121, 3, 22, 13, 16, 6, 30,
664  2, 10, 1, 20, 12, 241, 5, 28, 16, 12, 3, 24, 28, 124, 239, 247,
665  1, 240, 1, 19, 18, 15, 4, 27, 1, 122, 2, 23, 1, 17, 7, 31,
666  1, 11, 2, 21, 19, 246, 238, 29, 17, 13, 236, 25, 58, 63, 8, 125
667  },
668  {
669  0, 201, 25, 231, 5, 221, 1, 3, 2, 414, 2, 241, 16, 225, 195, 492,
670  2, 412, 1, 240, 7, 224, 98, 245, 1, 220, 96, 5, 9, 230, 101, 247,
671  1, 102, 1, 415, 24, 3, 2, 244, 3, 54, 3, 484, 17, 114, 200, 493,
672  3, 413, 1, 4, 13, 113, 99, 485, 4, 111, 194, 243, 5, 29, 26, 31
673  },
674  {
675  0, 28, 12, 44, 3, 36, 20, 52, 2, 32, 16, 48, 8, 40, 24, 28,
676  1, 30, 14, 46, 6, 38, 22, 54, 3, 34, 18, 50, 10, 42, 26, 30,
677  1, 29, 13, 45, 5, 37, 21, 53, 2, 33, 17, 49, 9, 41, 25, 29,
678  1, 31, 15, 47, 7, 39, 23, 55, 4, 35, 19, 51, 11, 43, 27, 31
679  }
680 };
681 
682 const uint8_t ff_vc1_cbpcy_p_bits[4][64] = {
683  {
684  13, 13, 7, 13, 7, 13, 13, 12, 6, 13, 7, 12, 6, 8, 8, 8,
685  5, 7, 8, 12, 6, 8, 13, 12, 7, 13, 13, 12, 6, 8, 7, 7,
686  6, 13, 8, 12, 7, 13, 13, 12, 7, 13, 8, 12, 5, 7, 7, 7,
687  6, 8, 13, 12, 6, 7, 8, 8, 5, 8, 8, 6, 3, 3, 3, 2
688  },
689  {
690  14, 13, 8, 13, 3, 13, 8, 13, 3, 7, 8, 13, 4, 13, 13, 13,
691  3, 13, 13, 13, 4, 8, 13, 13, 5, 13, 13, 13, 5, 7, 8, 8,
692  3, 8, 14, 13, 5, 13, 13, 13, 4, 7, 13, 13, 6, 13, 13, 13,
693  5, 13, 8, 13, 5, 8, 8, 13, 5, 13, 8, 13, 6, 6, 13, 7
694  },
695  {
696  13, 8, 6, 8, 4, 8, 13, 12, 4, 9, 8, 8, 5, 8, 8, 9,
697  5, 9, 10, 8, 4, 8, 7, 8, 6, 8, 7, 13, 4, 8, 7, 8,
698  5, 7, 8, 9, 6, 13, 13, 8, 4, 6, 8, 9, 5, 7, 8, 9,
699  5, 9, 9, 13, 5, 7, 7, 9, 4, 7, 8, 8, 3, 5, 5, 5
700  },
701  {
702  9, 9, 9, 9, 2, 9, 9, 9, 2, 9, 9, 9, 9, 9, 9, 8,
703  3, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8,
704  2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8,
705  9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8
706  }
707 };
708 
709 /* Interlaced CBPCY VLC tables (Table 124 - Table 131) */
710 const uint16_t ff_vc1_icbpcy_p_codes[8][63] = {
711  {
712  0x2F1A, 0x2F1B, 0x178C, 0x0090, 0x02A8, 0x02A9, 0x0BC7, 0x0091,
713  0x02AA, 0x02AB, 0x05E0, 0x004A, 0x0096, 0x0097, 0x00BD, 0x0092,
714  0x02AC, 0x02AD, 0x05E1, 0x0098, 0x0132, 0x0133, 0x0179, 0x0134,
715  0x026A, 0x026B, 0x02FC, 0x004E, 0x0040, 0x0041, 0x002B, 0x0093,
716  0x02AE, 0x02AF, 0x05E2, 0x0136, 0x026E, 0x026F, 0x02FD, 0x009E,
717  0x013E, 0x013F, 0x017F, 0x0050, 0x0042, 0x0043, 0x002C, 0x0051,
718  0x00A4, 0x00A5, 0x00BE, 0x0053, 0x0044, 0x0045, 0x002D, 0x0054,
719  0x0046, 0x0047, 0x002E, 0x0003, 0x0000, 0x0001, 0x0001
720  },
721  {
722  0x0041, 0x0042, 0x0100, 0x0043, 0x0088, 0x0089, 0x0101, 0x0045,
723  0x008C, 0x008D, 0x0102, 0x0010, 0x0022, 0x0023, 0x0024, 0x0047,
724  0x0010, 0x0011, 0x0103, 0x0025, 0x0058, 0x0059, 0x005A, 0x005B,
725  0x005A, 0x005B, 0x005C, 0x000C, 0x0030, 0x0031, 0x0019, 0x0009,
726  0x0014, 0x0015, 0x002C, 0x005C, 0x005D, 0x005E, 0x005F, 0x0026,
727  0x005D, 0x005E, 0x005F, 0x000D, 0x0034, 0x0035, 0x001B, 0x0014,
728  0x0027, 0x002A, 0x002B, 0x000E, 0x0038, 0x0039, 0x001D, 0x000F,
729  0x003C, 0x003D, 0x001F, 0x0005, 0x0009, 0x0000, 0x0003
730  },
731  {
732  0x0032, 0x0033, 0x001A, 0x0026, 0x00E4, 0x00E5, 0x01E6, 0x0027,
733  0x00E6, 0x00E7, 0x01E7, 0x000E, 0x0063, 0x006C, 0x0077, 0x0028,
734  0x00E8, 0x00E9, 0x01E8, 0x007B, 0x00DA, 0x00DB, 0x00EC, 0x00F5,
735  0x01B8, 0x01B9, 0x01DA, 0x0021, 0x004B, 0x0054, 0x002B, 0x0029,
736  0x00EA, 0x00EB, 0x01E9, 0x004A, 0x01BA, 0x01BB, 0x01DB, 0x0020,
737  0x00DE, 0x00DF, 0x00F2, 0x0022, 0x0055, 0x0058, 0x002D, 0x000F,
738  0x0070, 0x0071, 0x0078, 0x0023, 0x0059, 0x005C, 0x002F, 0x0024,
739  0x005D, 0x0062, 0x0030, 0x0002, 0x001F, 0x0006, 0x0000
740  },
741  {
742  0x0028, 0x0029, 0x009D, 0x0000, 0x01EA, 0x01EB, 0x01EC, 0x0001,
743  0x01ED, 0x01EE, 0x01EF, 0x0005, 0x00F0, 0x00F1, 0x003B, 0x0002,
744  0x01F0, 0x01F1, 0x01F2, 0x003F, 0x015C, 0x015D, 0x0099, 0x0010,
745  0x03D0, 0x03D1, 0x0130, 0x000F, 0x009E, 0x009F, 0x00FB, 0x0003,
746  0x01F3, 0x01F4, 0x01F5, 0x0011, 0x03D2, 0x03D3, 0x0131, 0x0009,
747  0x015E, 0x015F, 0x009C, 0x0010, 0x00A8, 0x00A9, 0x0038, 0x0006,
748  0x00F2, 0x00F3, 0x004D, 0x0011, 0x00AA, 0x00AB, 0x0039, 0x0012,
749  0x00AC, 0x00AD, 0x003A, 0x0006, 0x0016, 0x0017, 0x000E
750  },
751  {
752  0x003C, 0x003D, 0x001F, 0x000A, 0x0061, 0x0062, 0x0002, 0x000B,
753  0x0063, 0x0064, 0x0003, 0x0007, 0x0003, 0x0004, 0x000B, 0x000C,
754  0x0065, 0x0066, 0x0004, 0x0012, 0x000A, 0x000B, 0x0014, 0x001B,
755  0x0018, 0x0019, 0x0034, 0x002C, 0x0067, 0x0068, 0x0035, 0x000D,
756  0x0069, 0x006C, 0x0005, 0x0060, 0x001A, 0x001B, 0x0035, 0x0013,
757  0x000E, 0x000F, 0x0015, 0x002D, 0x006D, 0x006E, 0x0038, 0x0008,
758  0x0008, 0x0009, 0x000C, 0x002E, 0x006F, 0x0072, 0x003A, 0x002F,
759  0x0073, 0x0000, 0x003B, 0x0007, 0x0014, 0x0015, 0x0004
760  },
761  {
762  0x0038, 0x0039, 0x009D, 0x000A, 0x0091, 0x0092, 0x0093, 0x000B,
763  0x0094, 0x0095, 0x0096, 0x0003, 0x00EE, 0x00EF, 0x0036, 0x000C,
764  0x0097, 0x0098, 0x0099, 0x0008, 0x01E4, 0x01E5, 0x006A, 0x0018,
765  0x03CC, 0x03CD, 0x00D6, 0x000E, 0x009E, 0x009F, 0x00F5, 0x000D,
766  0x009A, 0x009B, 0x009C, 0x0019, 0x03CE, 0x03CF, 0x00D7, 0x0009,
767  0x01E8, 0x01E9, 0x0090, 0x000F, 0x00E8, 0x00E9, 0x00F6, 0x0005,
768  0x00F0, 0x00F1, 0x0037, 0x0010, 0x00EA, 0x00EB, 0x00F7, 0x0011,
769  0x00EC, 0x00ED, 0x0034, 0x0000, 0x003E, 0x003F, 0x0002
770  },
771  {
772  0x003C, 0x003D, 0x01CF, 0x0000, 0x00BF, 0x00E0, 0x01FC, 0x0001,
773  0x00E1, 0x00E2, 0x01FD, 0x0009, 0x01F1, 0x01F2, 0x01F3, 0x0002,
774  0x00E3, 0x00E4, 0x01FE, 0x0011, 0x03EE, 0x03EF, 0x03F0, 0x0021,
775  0x07E2, 0x07E3, 0x07E4, 0x0018, 0x03F7, 0x03FE, 0x03FF, 0x0003,
776  0x00E5, 0x00E6, 0x0080, 0x002E, 0x07E5, 0x07E6, 0x07E7, 0x0016,
777  0x03F4, 0x03F5, 0x03F6, 0x0019, 0x0102, 0x0103, 0x0104, 0x000A,
778  0x01F4, 0x01F5, 0x01F6, 0x001A, 0x0105, 0x0106, 0x0107, 0x001B,
779  0x0178, 0x0179, 0x01CE, 0x001D, 0x00BD, 0x00BE, 0x01F0
780  },
781  {
782  0x0003, 0x0004, 0x01B6, 0x0004, 0x002E, 0x002F, 0x000E, 0x0005,
783  0x0030, 0x0031, 0x000F, 0x0003, 0x000A, 0x000B, 0x0014, 0x0006,
784  0x0032, 0x0033, 0x0010, 0x0005, 0x0030, 0x0031, 0x0032, 0x0009,
785  0x0066, 0x0067, 0x0068, 0x001D, 0x01B7, 0x01B8, 0x01B9, 0x0007,
786  0x0034, 0x0035, 0x0011, 0x0016, 0x0069, 0x006A, 0x006B, 0x000A,
787  0x0036, 0x0037, 0x00D8, 0x001E, 0x01BA, 0x01BB, 0x01BC, 0x0004,
788  0x0015, 0x0016, 0x0017, 0x001F, 0x01BD, 0x01BE, 0x01BF, 0x0000,
789  0x0010, 0x0011, 0x0012, 0x001C, 0x00D9, 0x00DA, 0x0013
790  }
791 };
792 
794  {
795  15, 15, 14, 9, 11, 11, 13, 9, 11, 11, 12, 8, 9, 9, 9, 9,
796  11, 11, 12, 9, 10, 10, 10, 10, 11, 11, 11, 8, 8, 8, 7, 9,
797  11, 11, 12, 10, 11, 11, 11, 9, 10, 10, 10, 8, 8, 8, 7, 8,
798  9, 9, 9, 8, 8, 8, 7, 8, 8, 8, 7, 3, 3, 3, 1
799  },
800  {
801  7, 7, 9, 7, 8, 8, 9, 7, 8, 8, 9, 6, 7, 7, 7, 7,
802  7, 7, 9, 7, 8, 8, 8, 8, 9, 9, 9, 6, 7, 7, 6, 6,
803  7, 7, 8, 8, 9, 9, 9, 7, 8, 8, 8, 6, 7, 7, 6, 6,
804  7, 7, 7, 6, 7, 7, 6, 6, 7, 7, 6, 3, 4, 3, 2
805  },
806  {
807  6, 6, 5, 6, 8, 8, 9, 6, 8, 8, 9, 5, 7, 7, 7, 6,
808  8, 8, 9, 7, 8, 8, 8, 8, 9, 9, 9, 6, 7, 7, 6, 6,
809  8, 8, 9, 7, 9, 9, 9, 6, 8, 8, 8, 6, 7, 7, 6, 5,
810  7, 7, 7, 6, 7, 7, 6, 6, 7, 7, 6, 3, 5, 4, 2
811  },
812  {
813  6, 6, 8, 4, 9, 9, 9, 4, 9, 9, 9, 4, 8, 8, 7, 4,
814  9, 9, 9, 6, 9, 9, 8, 6, 10, 10, 9, 5, 8, 8, 8, 4,
815  9, 9, 9, 6, 10, 10, 9, 5, 9, 9, 8, 5, 8, 8, 7, 4,
816  8, 8, 7, 5, 8, 8, 7, 5, 8, 8, 7, 3, 5, 5, 4
817  },
818  {
819  6, 6, 5, 5, 7, 7, 7, 5, 7, 7, 7, 5, 6, 6, 6, 5,
820  7, 7, 7, 6, 7, 7, 7, 7, 8, 8, 8, 6, 7, 7, 6, 5,
821  7, 7, 7, 7, 8, 8, 8, 6, 7, 7, 7, 6, 7, 7, 6, 5,
822  6, 6, 6, 6, 7, 7, 6, 6, 7, 6, 6, 4, 5, 5, 3
823  },
824  {
825  6, 6, 8, 4, 8, 8, 8, 4, 8, 8, 8, 4, 8, 8, 7, 4,
826  8, 8, 8, 5, 9, 9, 8, 6, 10, 10, 9, 5, 8, 8, 8, 4,
827  8, 8, 8, 6, 10, 10, 9, 5, 9, 9, 8, 5, 8, 8, 8, 4,
828  8, 8, 7, 5, 8, 8, 8, 5, 8, 8, 7, 3, 6, 6, 4
829  },
830  {
831  6, 6, 9, 3, 8, 8, 9, 3, 8, 8, 9, 4, 9, 9, 9, 3,
832  8, 8, 9, 5, 10, 10, 10, 6, 11, 11, 11, 5, 10, 10, 10, 3,
833  8, 8, 8, 6, 11, 11, 11, 5, 10, 10, 10, 5, 9, 9, 9, 4,
834  9, 9, 9, 5, 9, 9, 9, 5, 9, 9, 9, 5, 8, 8, 9
835  },
836  {
837  6, 6, 10, 3, 7, 7, 7, 3, 7, 7, 7, 4, 8, 8, 8, 3,
838  7, 7, 7, 5, 9, 9, 9, 6, 10, 10, 10, 6, 10, 10, 10, 3,
839  7, 7, 7, 6, 10, 10, 10, 5, 9, 9, 9, 6, 10, 10, 10, 4,
840  8, 8, 8, 6, 10, 10, 10, 5, 9, 9, 9, 6, 9, 9, 9
841  }
842 };
843 
844 /* MacroBlock Transform Type: 7.1.3.11, p89
845  * 8x8:B
846  * 8x4:B:btm 8x4:B:top 8x4:B:both,
847  * 4x8:B:right 4x8:B:left 4x8:B:both
848  * 4x4:B 8x8:MB
849  * 8x4:MB:btm 8x4:MB:top 8x4,MB,both
850  * 4x8,MB,right 4x8,MB,left
851  * 4x4,MB */
852 const uint16_t ff_vc1_ttmb_codes[3][16] = {
853  {
854  0x0003,
855  0x002E, 0x005F, 0x0000,
856  0x0016, 0x0015, 0x0001,
857  0x0004, 0x0014,
858  0x02F1, 0x0179, 0x017B,
859  0x0BC0, 0x0BC1, 0x05E1,
860  0x017A
861  },
862  {
863  0x0006,
864  0x0006, 0x0003, 0x0007,
865  0x000F, 0x000E, 0x0000,
866  0x0002, 0x0002,
867  0x0014, 0x0011, 0x000B,
868  0x0009, 0x0021, 0x0015,
869  0x0020
870  },
871  {
872  0x0006,
873  0x0000, 0x000E, 0x0005,
874  0x0002, 0x0003, 0x0003,
875  0x000F, 0x0002,
876  0x0081, 0x0021, 0x0009,
877  0x0101, 0x0041, 0x0011,
878  0x0100
879  }
880 };
881 
882 const uint8_t ff_vc1_ttmb_bits[3][16] = {
883  {
884  2,
885  6, 7, 2,
886  5, 5, 2,
887  3, 5,
888  10, 9, 9,
889  12, 12, 11,
890  9
891  },
892  {
893  3,
894  4, 4, 4,
895  4, 4, 3,
896  3, 2,
897  7, 7, 6,
898  6, 8, 7,
899  8
900  },
901  {
902  3,
903  3, 4, 5,
904  3, 3, 4,
905  4, 2,
906  10, 8, 6,
907  11, 9, 7,
908  11
909  }
910 };
911 
912 /* TTBLK (Transform Type per Block) tables */
914  { 0, 1, 3, 5, 16, 17, 18, 19 },
915  { 3, 0, 1, 2, 3, 5, 8, 9 },
916  { 1, 0, 1, 4, 6, 7, 10, 11 }
917 };
918 const uint8_t ff_vc1_ttblk_bits[3][8] = {
919  { 2, 2, 2, 3, 5, 5, 5, 5 },
920  { 2, 3, 3, 3, 3, 3, 4, 4 },
921  { 2, 3, 3, 3, 3, 3, 4, 4 }
922 };
923 
924 /* SUBBLKPAT tables, p93-94, reordered */
926  { 14, 12, 7, 11, 9, 26, 2, 10, 27, 8, 0, 6, 1, 15, 1 },
927  { 14, 0, 8, 15, 10, 4, 23, 13, 5, 9, 25, 3, 24, 22, 1 },
928  { 5, 6, 2, 2, 8, 0, 28, 3, 1, 3, 29, 1, 19, 18, 15 }
929 };
931  { 5, 5, 5, 5, 5, 6, 4, 5, 6, 5, 4, 5, 4, 5, 1},
932  { 4, 3, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 2},
933  { 3, 3, 4, 3, 4, 5, 5, 3, 5, 4, 5, 4, 5, 5, 4}
934 };
935 
936 /* MV differential tables, p265 */
937 const uint16_t ff_vc1_mv_diff_codes[4][73] = {
938  {
939  0, 2, 3, 8, 576, 3, 2, 6,
940  5, 577, 578, 7, 8, 9, 40, 19,
941  37, 82, 21, 22, 23, 579, 580, 166,
942  96, 167, 49, 194, 195, 581, 582, 583,
943  292, 293, 294, 13, 2, 7, 24, 50,
944  102, 295, 13, 7, 8, 18, 50, 103,
945  38, 20, 21, 22, 39, 204, 103, 23,
946  24, 25, 104, 410, 105, 106, 107, 108,
947  109, 220, 411, 442, 222, 443, 446, 447,
948  7 /* 73 elements */
949  },
950  {
951  0, 4, 5, 3, 4, 3, 4, 5,
952  20, 6, 21, 44, 45, 46, 3008, 95,
953  112, 113, 57, 3009, 3010, 116, 117, 3011,
954  118, 3012, 3013, 3014, 3015, 3016, 3017, 3018,
955  3019, 3020, 3021, 3022, 1, 4, 15, 160,
956  161, 41, 6, 11, 42, 162, 43, 119,
957  56, 57, 58, 163, 236, 237, 3023, 119,
958  120, 242, 122, 486, 1512, 487, 246, 494,
959  1513, 495, 1514, 1515, 1516, 1517, 1518, 1519,
960  31 /* 73 elements */
961  },
962  {
963  0, 512, 513, 514, 515, 2, 3, 258,
964  259, 260, 261, 262, 263, 264, 265, 266,
965  267, 268, 269, 270, 271, 272, 273, 274,
966  275, 276, 277, 278, 279, 280, 281, 282,
967  283, 284, 285, 286, 1, 5, 287, 288,
968  289, 290, 6, 7, 291, 292, 293, 294,
969  295, 296, 297, 298, 299, 300, 301, 302,
970  303, 304, 305, 306, 307, 308, 309, 310,
971  311, 312, 313, 314, 315, 316, 317, 318,
972  319 /* 73 elements */
973  },
974  {
975  0, 1, 1, 2, 3, 4, 1, 5,
976  4, 3, 5, 8, 6, 9, 10, 11,
977  12, 7, 104, 14, 105, 4, 10, 15,
978  11, 6, 14, 8, 106, 107, 108, 15,
979  109, 9, 55, 10, 1, 2, 1, 2,
980  3, 12, 6, 2, 6, 7, 28, 7,
981  15, 8, 5, 18, 29, 152, 77, 24,
982  25, 26, 39, 108, 13, 109, 55, 56,
983  57, 116, 11, 153, 234, 235, 118, 119,
984  15 /* 73 elements */
985  }
986 };
987 const uint8_t ff_vc1_mv_diff_bits[4][73] = {
988  {
989  6, 7, 7, 8, 14, 6, 5, 6, 7, 14, 14, 6, 6, 6, 8, 9,
990  10, 9, 7, 7, 7, 14, 14, 10, 9, 10, 8, 10, 10, 14, 14, 14,
991  13, 13, 13, 6, 3, 5, 6, 8, 9, 13, 5, 4, 4, 5, 7, 9,
992  6, 5, 5, 5, 6, 9, 8, 5, 5, 5, 7, 10, 7, 7, 7, 7,
993  7, 8, 10, 9, 8, 9, 9, 9, 3 /* 73 elements */
994  },
995  {
996  5, 7, 7, 6, 6, 5, 5, 6, 7, 5, 7, 8, 8, 8, 14, 9,
997  9, 9, 8, 14, 14, 9, 9, 14, 9, 14, 14, 14, 14, 14, 14, 14,
998  14, 14, 14, 14, 2, 3, 6, 8, 8, 6, 3, 4, 6, 8, 6, 9,
999  6, 6, 6, 8, 8, 8, 14, 7, 7, 8, 7, 9, 13, 9, 8, 9,
1000  13, 9, 13, 13, 13, 13, 13, 13, 5 /* 73 elements */
1001 
1002  },
1003  {
1004  3, 12, 12, 12, 12, 3, 4, 11, 11, 11, 11, 11, 11, 11, 11, 11,
1005  11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
1006  11, 11, 11, 11, 1, 5, 11, 11, 11, 11, 4, 4, 11, 11, 11, 11,
1007  11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
1008  11, 11, 11, 11, 11, 11, 11, 11, 11 /* 73 elements */
1009  },
1010  {
1011  15, 11, 15, 15, 15, 15, 12, 15, 12, 11, 12, 12, 15, 12, 12, 12,
1012  12, 15, 15, 12, 15, 10, 11, 12, 11, 10, 11, 10, 15, 15, 15, 11,
1013  15, 10, 14, 10, 4, 4, 5, 7, 8, 9, 5, 3, 4, 5, 6, 8,
1014  5, 4, 3, 5, 6, 8, 7, 5, 5, 5, 6, 7, 9, 7, 6, 6,
1015  6, 7, 10, 8, 8, 8, 7, 7, 4 /* 73 elements */
1016  }
1017 };
1018 
1019 /* DC differentials low+hi-mo, p217 are the same as in msmpeg4data .h */
1020 
1021 /* Table 232 */
1023  0, 8, 16, 1,
1024  9, 24, 17, 2,
1025  10, 18, 25, 3,
1026  11, 26, 19, 27
1027 };
1028 
1029 const uint8_t ff_vc1_adv_progressive_8x4_zz [32] = { /* Table 233 */
1030  0, 8, 1, 16, 2, 9, 10, 3,
1031  24, 17, 4, 11, 18, 12, 5, 19,
1032  25, 13, 20, 26, 27, 6, 21, 28,
1033  14, 22, 29, 7, 30, 15, 23, 31
1034 };
1035 
1036 const uint8_t ff_vc1_adv_progressive_4x8_zz [32] = { /* Table 234 */
1037  0, 1, 8, 2,
1038  9, 16, 17, 24,
1039  10, 32, 25, 18,
1040  40, 3, 33, 26,
1041  48, 11, 56, 41,
1042  34, 49, 57, 42,
1043  19, 50, 27, 58,
1044  35, 43, 51, 59
1045 };
1046 
1047 const uint8_t ff_vc1_adv_interlaced_8x8_zz [64] = { /* Table 235 */
1048  0, 8, 1, 16, 24, 9, 2, 32,
1049  40, 48, 56, 17, 10, 3, 25, 18,
1050  11, 4, 33, 41, 49, 57, 26, 34,
1051  42, 50, 58, 19, 12, 5, 27, 20,
1052  13, 6, 35, 28, 21, 14, 7, 15,
1053  22, 29, 36, 43, 51, 59, 60, 52,
1054  44, 37, 30, 23, 31, 38, 45, 53,
1055  61, 62, 54, 46, 39, 47, 55, 63
1056 };
1057 
1058 const uint8_t ff_vc1_adv_interlaced_8x4_zz [32] = { /* Table 236 */
1059  0, 8, 16, 24, 1, 9, 2, 17,
1060  25, 10, 3, 18, 26, 4, 11, 19,
1061  12, 5, 13, 20, 27, 6, 21, 28,
1062  14, 22, 29, 7, 30, 15, 23, 31
1063 };
1064 
1065 const uint8_t ff_vc1_adv_interlaced_4x8_zz [32] = { /* Table 237 */
1066  0, 1, 2, 8,
1067  16, 9, 24, 17,
1068  10, 3, 32, 40,
1069  48, 56, 25, 18,
1070  33, 26, 41, 34,
1071  49, 57, 11, 42,
1072  19, 50, 27, 58,
1073  35, 43, 51, 59
1074 };
1075 
1076 const uint8_t ff_vc1_adv_interlaced_4x4_zz [16] = { /* Table 238 */
1077  0, 8, 16, 24,
1078  1, 9, 17, 2,
1079  25, 10, 18, 3,
1080  26, 11, 19, 27
1081 };
1082 
1083 
1084 /* DQScale as specified in 8.1.3.9 - almost identical to 0x40000/i */
1086  0x40000, 0x20000, 0x15555, 0x10000, 0xCCCD, 0xAAAB, 0x9249, 0x8000,
1087  0x71C7, 0x6666, 0x5D17, 0x5555, 0x4EC5, 0x4925, 0x4444, 0x4000,
1088  0x3C3C, 0x38E4, 0x35E5, 0x3333, 0x30C3, 0x2E8C, 0x2C86, 0x2AAB,
1089  0x28F6, 0x2762, 0x25ED, 0x2492, 0x234F, 0x2222, 0x2108, 0x2000,
1090  0x1F08, 0x1E1E, 0x1D42, 0x1C72, 0x1BAD, 0x1AF3, 0x1A42, 0x199A,
1091  0x18FA, 0x1862, 0x17D0, 0x1746, 0x16C1, 0x1643, 0x15CA, 0x1555,
1092  0x14E6, 0x147B, 0x1414, 0x13B1, 0x1352, 0x12F7, 0x129E, 0x1249,
1093  0x11F7, 0x11A8, 0x115B, 0x1111, 0x10C9, 0x1084, 0x1000
1094 };
1095 
1096 /* P Interlaced field picture MV predictor scaling values (Table 114) */
1097 const uint16_t ff_vc1_field_mvpred_scales[2][7][4] = {
1098 // Refdist:
1099 // 0 1 2 3 or greater
1100  { // current field is first
1101  { 128, 192, 213, 224 }, // SCALEOPP
1102  { 512, 341, 307, 293 }, // SCALESAME1
1103  { 219, 236, 242, 245 }, // SCALESAME2
1104  { 32, 48, 53, 56 }, // SCALEZONE1_X
1105  { 8, 12, 13, 14 }, // SCALEZONE1_Y
1106  { 37, 20, 14, 11 }, // ZONE1OFFSET_X
1107  { 10, 5, 4, 3 } // ZONE1OFFSET_Y
1108  },
1109  { // current field is second
1110  { 128, 64, 43, 32 }, // SCALEOPP
1111  { 512, 1024, 1536, 2048 }, // SCALESAME1
1112  { 219, 204, 200, 198 }, // SCALESAME2
1113  { 32, 16, 11, 8 }, // SCALEZONE1_X
1114  { 8, 4, 3, 2 }, // SCALEZONE1_Y
1115  { 37, 52, 56, 58 }, // ZONE1OFFSET_X
1116  { 10, 13, 14, 15 } // ZONE1OFFSET_Y
1117  }
1118 };
1119 
1120 /* B Interlaced field picture backward MV predictor scaling values for first field (Table 115) */
1121 const uint16_t ff_vc1_b_field_mvpred_scales[7][4] = {
1122  // BRFD:
1123  // 0 1 2 3 or greater
1124  { 171, 205, 219, 228 }, // SCALESAME
1125  { 384, 320, 299, 288 }, // SCALEOPP1
1126  { 230, 239, 244, 246 }, // SCALEOPP2
1127  { 43, 51, 55, 57 }, // SCALEZONE1_X
1128  { 11, 13, 14, 14 }, // SCALEZONE1_Y
1129  { 26, 17, 12, 10 }, // ZONE1OFFSET_X
1130  { 7, 4, 3, 3 } // ZONE1OFFSET_Y
1131 };
1132 
1134  186, 169, 133, 149, 103, 103, 163, 175
1135 };
const int ff_vc1_ttblk_to_tt[3][8]
Table for conversion between TTBLK and TTMB.
Definition: vc1data.c:34
const uint8_t ff_vc1_imode_codes[7]
Definition: vc1data.c:214
const uint8_t ff_vc1_icbpcy_p_bits[8][63]
Definition: vc1data.c:793
const uint8_t ff_vc1_mv_pmode_table[2][5]
MV P mode - the 5th element is only used for mode 1.
Definition: vc1data.c:43
const uint8_t ff_vc1_mv_diff_bits[4][73]
Definition: vc1data.c:987
VLC ff_vc1_ttblk_vlc[3]
Definition: vc1data.c:127
const uint8_t ff_vc1_pquant_table[3][32]
Definition: vc1data.c:89
const uint8_t ff_vc1_norm2_codes[4]
Definition: vc1data.c:222
const uint8_t ff_vc1_2ref_mvdata_bits[8][126]
Definition: vc1data.c:565
const uint8_t ff_vc1_if_1mv_mbmode_codes[8][6]
Definition: vc1data.c:319
const uint8_t ff_vc1_4mv_block_pattern_bits[4][16]
Definition: vc1data.c:250
const uint8_t ff_vc1_cbpcy_p_bits[4][64]
Definition: vc1data.c:682
const int ff_vc1_fps_nr[7]
Definition: vc1data.c:87
VLC ff_vc1_2ref_mvdata_vlc[8]
Definition: vc1data.c:141
const uint8_t ff_vc1_adv_progressive_4x8_zz[32]
Definition: vc1data.c:1036
const uint8_t ff_vc1_adv_interlaced_4x8_zz[32]
Definition: vc1data.c:1065
const uint8_t ff_vc1_1ref_mvdata_bits[4][72]
Definition: vc1data.c:390
const uint8_t ff_vc1_ttmb_bits[3][16]
Definition: vc1data.c:882
const uint16_t ff_vc1_b_field_mvpred_scales[7][4]
Definition: vc1data.c:1121
VC-1 tables.
const uint8_t ff_vc1_2mv_block_pattern_codes[4][4]
Definition: vc1data.c:258
uint8_t
const uint8_t ff_vc1_2mv_block_pattern_bits[4][4]
Definition: vc1data.c:262
const AVRational ff_vc1_pixel_aspect[16]
Definition: vc1data.c:194
VLC ff_vc1_cbpcy_p_vlc[4]
Definition: vc1data.c:119
const uint16_t ff_vc1_icbpcy_p_codes[8][63]
Definition: vc1data.c:710
const uint8_t ff_wmv3_dc_scale_table[32]
Definition: vc1data.c:648
const int ff_vc1_ac_sizes[AC_MODES]
Definition: vc1data.c:1133
const uint8_t ff_vc1_if_mmv_mbmode_bits[8][8]
Definition: vc1data.c:308
VLC ff_vc1_norm2_vlc
Definition: vc1data.c:110
const uint8_t ff_vc1_imode_bits[7]
Definition: vc1data.c:217
const uint8_t ff_vc1_subblkpat_bits[3][15]
Definition: vc1data.c:930
VLC ff_vc1_4mv_block_pattern_vlc[4]
Definition: vc1data.c:123
Definition: vc1.h:143
const uint8_t ff_vc1_simple_progressive_4x4_zz[16]
Definition: vc1data.c:1022
VLC ff_vc1_imode_vlc
Definition: vc1data.c:108
const int ff_vc1_ttfrm_to_tt[4]
Definition: vc1data.c:40
VLC ff_vc1_norm6_vlc
Definition: vc1data.c:112
external API header
Definition: get_bits.h:63
const uint8_t ff_vc1_adv_interlaced_8x4_zz[32]
Definition: vc1data.c:1058
const uint8_t ff_vc1_adv_interlaced_8x8_zz[64]
Definition: vc1data.c:1047
VLC ff_vc1_ttmb_vlc[3]
Definition: vc1data.c:115
const uint16_t ff_vc1_norm6_codes[64]
Definition: vc1data.c:229
const uint16_t ff_vc1_cbpcy_p_codes[4][64]
Definition: vc1data.c:655
VLC ff_vc1_icbpcy_vlc[8]
Definition: vc1data.c:121
const int ff_vc1_fps_dr[2]
Definition: vc1data.c:88
int32_t
const uint32_t ff_vc1_1ref_mvdata_codes[4][72]
Definition: vc1data.c:343
const uint16_t ff_vc1_field_mvpred_scales[2][7][4]
Definition: vc1data.c:1097
const uint8_t ff_vc1_norm6_bits[64]
Definition: vc1data.c:236
VLC ff_vc1_bfraction_vlc
Definition: vc1data.c:106
#define AC_MODES
Definition: vc1data.h:204
const uint8_t ff_vc1_ttblk_codes[3][8]
Definition: vc1data.c:913
const uint8_t ff_vc1_4mv_block_pattern_codes[4][16]
Definition: vc1data.c:244
const uint8_t ff_vc1_intfr_non4mv_mbmode_codes[4][9]
Definition: vc1data.c:282
const uint8_t ff_vc1_mbmode_intfrp[2][15][4]
Definition: vc1data.c:53
const uint16_t ff_vc1_ttmb_codes[3][16]
Definition: vc1data.c:852
Definition: vc1.h:139
rational number numerator/denominator
Definition: rational.h:43
const uint16_t ff_vc1_intfr_4mv_mbmode_codes[4][15]
Definition: vc1data.c:267
VLC ff_vc1_if_mmv_mbmode_vlc[8]
Definition: vc1data.c:135
VLC ff_vc1_if_1mv_mbmode_vlc[8]
Definition: vc1data.c:137
const int32_t ff_vc1_dqscale[63]
Definition: vc1data.c:1085
VLC ff_vc1_mv_diff_vlc[4]
Definition: vc1data.c:117
const uint8_t ff_vc1_intfr_4mv_mbmode_bits[4][15]
Definition: vc1data.c:274
const uint8_t ff_vc1_intfr_non4mv_mbmode_bits[4][9]
Definition: vc1data.c:289
const uint8_t ff_vc1_bfraction_bits[23]
Definition: vc1data.c:174
const uint8_t ff_vc1_bfraction_codes[23]
Definition: vc1data.c:183
VLC ff_vc1_2mv_block_pattern_vlc[4]
Definition: vc1data.c:125
const uint8_t ff_vc1_adv_interlaced_4x4_zz[16]
Definition: vc1data.c:1076
VLC ff_vc1_ac_coeff_table[8]
Definition: vc1data.c:143
const uint8_t ff_vc1_adv_progressive_8x4_zz[32]
Definition: vc1data.c:1029
Definition: vc1.h:142
const uint8_t ff_vc1_ttblk_bits[3][8]
Definition: vc1data.c:918
VLC ff_vc1_1ref_mvdata_vlc[4]
Definition: vc1data.c:139
Definition: vc1.h:136
const uint8_t ff_vc1_subblkpat_codes[3][15]
Definition: vc1data.c:925
const uint8_t ff_vc1_if_1mv_mbmode_bits[8][6]
Definition: vc1data.c:329
const uint8_t ff_vc1_norm2_bits[4]
Definition: vc1data.c:225
const uint8_t ff_vc1_if_mmv_mbmode_codes[8][8]
Definition: vc1data.c:298
const uint8_t ff_vc1_mv_pmode_table2[2][4]
Definition: vc1data.c:47
VLC ff_vc1_intfr_non4mv_mbmode_vlc[4]
Definition: vc1data.c:133
VLC ff_vc1_intfr_4mv_mbmode_vlc[4]
Definition: vc1data.c:131
VLC ff_vc1_subblkpat_vlc[3]
Definition: vc1data.c:129
const uint32_t ff_vc1_2ref_mvdata_codes[8][126]
Definition: vc1data.c:418
const uint16_t ff_vc1_mv_diff_codes[4][73]
Definition: vc1data.c:937
const int16_t ff_vc1_bfraction_lut[23]
Definition: vc1data.c:163