1 /* ///////////////////////////////////////////////////////////////////////
2 //
3 //               INTEL CORPORATION PROPRIETARY INFORMATION
4 //  This software is supplied under the terms of a license agreement or
5 //  nondisclosure agreement with Intel Corporation and may not be copied
6 //  or disclosed except in accordance with the terms of that agreement.
7 //        Copyright (c) 2008 Intel Corporation. All Rights Reserved.
8 //
9 //  Description: Contains tables for VLC decoding of syntax elements in simple
10 //  or main profile of VC-1 bitstream.
11 //
12 */
13 
14 #include "vc1parse.h"
15 
16 const uint8_t VC1_MVMODE_LOW_TBL[] =
17 {
18     VC1_MVMODE_HPELBI_1MV,
19     VC1_MVMODE_1MV,
20     VC1_MVMODE_HPEL_1MV,
21     VC1_MVMODE_MIXED_MV,
22     VC1_MVMODE_INTENSCOMP
23 };
24 
25 const uint8_t VC1_MVMODE_HIGH_TBL[] =
26 {
27     VC1_MVMODE_1MV,
28     VC1_MVMODE_MIXED_MV,
29     VC1_MVMODE_HPEL_1MV,
30     VC1_MVMODE_HPELBI_1MV,
31     VC1_MVMODE_INTENSCOMP
32 };
33 
34 const int32_t VC1_BITPLANE_IMODE_TBL[] =
35 {
36  4, /* max bits */
37  1, /* total subtables */
38  4, /* subtable sizes */
39 
40  0, /* 1-bit codes */
41  2, /* 2-bit codes */
42     2, VC1_BITPLANE_NORM2_MODE,
43     3, VC1_BITPLANE_NORM6_MODE,
44  3, /* 3-bit codes */
45     1, VC1_BITPLANE_DIFF2_MODE,
46     2, VC1_BITPLANE_ROWSKIP_MODE,
47     3, VC1_BITPLANE_COLSKIP_MODE,
48  2, /* 4-bit codes */
49     0, VC1_BITPLANE_RAW_MODE,
50     1, VC1_BITPLANE_DIFF6_MODE,
51 -1
52 };
53 
54 /* This VLC table is used for decoding of k in bitplane. */
55 const int32_t VC1_BITPLANE_K_TBL[] =
56 {
57  13, /* max bits */
58  2,  /* total subtables */
59  6,7,/* subtable sizes */
60 
61  1, /* 1-bit codes */
62     1,       0 ,
63  0, /* 2-bit codes */
64  0, /* 3-bit codes */
65  6, /* 4-bit codes */
66     2, 1,    3, 2,     4, 4,    5, 8,
67     6, 16,   7, 32,
68  0, /* 5-bit codes */
69  1, /* 6-bit codes */
70     (3 << 1)| 1,     63,
71  0, /* 7-bit codes */
72  15, /* 8-bit codes */
73     0, 3,    1, 5,    2, 6,    3, 9,
74     4, 10,   5, 12,   6, 17,   7, 18,
75     8, 20,   9, 24,   10, 33,  11, 34,
76     12, 36,  13, 40,  14, 48,
77  6, /* 9-bit codes */
78     (3 << 4)| 7,    31,
79     (3 << 4)| 6,    47,
80     (3 << 4)| 5,    55,
81     (3 << 4)| 4,    59,
82 
83     (3 << 4)| 3,    61,
84     (3 << 4)| 2,    62,
85  20, /* 10-bit codes */
86     (1 << 6)| 11,  11,
87     (1 << 6)|  7,  7 ,
88     (1 << 6)| 13,  13,
89     (1 << 6)| 14,  14,
90 
91     (1 << 6)| 19,  19,
92     (1 << 6)| 21,  21,
93     (1 << 6)| 22,  22,
94     (1 << 6)| 25,  25,
95 
96     (1 << 6)| 26,  26,
97     (1 << 6)| 28,  28,
98     (1 << 6)|  3,  35,
99     (1 << 6)|  5,  37,
100 
101     (1 << 6)|  6,  38,
102     (1 << 6)|  9,  41,
103     (1 << 6)| 10,  42,
104     (1 << 6)| 12,  44,
105 
106     (1 << 6)| 17,  49,
107     (1 << 6)| 18,  50,
108     (1 << 6)| 20,  52,
109     (1 << 6)| 24,  56,
110  0,  /* 11-bit codes */
111  0,  /* 12-bit codes */
112  15, /* 13-bit codes */
113     (3 << 8)| 14,  15,
114     (3 << 8)| 13,  23,
115     (3 << 8)| 12,  27,
116     (3 << 8)| 11,  29,
117 
118     (3 << 8)| 10,  30,
119     (3 << 8)|  9,  39,
120     (3 << 8)|  8,  43,
121     (3 << 8)|  7,  45,
122 
123     (3 << 8)|  6,  46,
124     (3 << 8)|  5,  51,
125     (3 << 8)|  4,  53,
126     (3 << 8)|  3,  54,
127 
128     (3 << 8)|  2,  57,
129     (3 << 8)|  1,  58,
130     (3 << 8)|  0,  60,
131     -1
132 };
133 
134 /* This VLC table is used for decoding of BFRACTION. */
135 const int32_t VC1_BFRACTION_TBL[] =
136 {
137  7,        /* max bits */
138  2,        /* total subtables */
139  3,4,    /* subtable sizes */
140  0,        /* 1-bit codes */
141  0,        /* 2-bit codes */
142  7,        /* 3-bit codes */
143     0x00,1,2,    0x01,1,3,    0x02,2,3,    0x03,1,4,
144     0x04,3,4,    0x05,1,5,    0x06,2,5,
145  0,        /* 4-bit codes */
146  0,        /* 5-bit codes */
147  0,        /* 6-bit codes */
148  16,    /* 7-bit codes */
149     0x70, 3,5,    0x71, 4,5,    0x72, 1,6,    0x73, 5,6,
150     0x74, 1,7,    0x75, 2,7,    0x76, 3,7,    0x77, 4,7,
151     0x78, 5,7,    0x79, 6,7,    0x7A, 1,8,    0x7B, 3,8,
152     0x7C, 5,8,    0x7D, 7,8,
153     0x7E, VC1_BFRACTION_INVALID,VC1_BFRACTION_INVALID,
154     0x7F, VC1_BFRACTION_BI, VC1_BFRACTION_BI,
155 
156     -1
157 };
158 
159 /* This table is used for VLC decoding of REFDIST. */
160 const int32_t VC1_REFDIST_TBL[] =
161 {
162     16, /* Max bits. */
163      3, /* Total sub-tables. */
164          5, 6, 5, /* Sub-table sizes. */
165 
166      0, /* 1-bit codes. */
167      3, /* 2-bit codes. */
168             0,  0,       1,  1,       2,  2,
169      1, /* 3-bit codes. */
170             6,  3,
171      1, /* 4-bit codes. */
172            14,  4,
173      1, /* 5-bit codes. */
174            30,  5,
175      1, /* 6-bit codes. */
176            62,  6,
177      1, /* 7-bit codes. */
178           126,  7,
179      1, /* 8-bit codes. */
180           254,  8,
181      1, /* 9-bit codes. */
182           510,  9,
183      1, /* 10-bit codes. */
184          1022, 10,
185      1, /* 11-bit codes. */
186          2046, 11,
187      1, /* 12-bit codes. */
188          4094, 12,
189      1, /* 13-bit codes. */
190          8190, 13,
191      1, /* 14-bit codes. */
192         16382, 14,
193      1, /* 15-bit codes. */
194         32766, 15,
195      1, /* 16-bit codes. */
196         65534, 16,
197     -1  /* end of table. */
198 };
199