3 /* type definitions for variable length code table entries */
7 unsigned char code; /* right justified */
11 /* for codes longer than 8 bits (excluding leading zeroes) */
14 unsigned short code; /* right justified */
19 /* Table B-2, B-3, B-4 variable length codes for macroblock_type
21 * indexed by [macroblock_type]
24 const static VLCtable mbtypetab[3][32]=
28 {0,0}, {1,1}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
29 {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
30 {0,0}, {1,2}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
31 {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}
35 {0,0}, {3,5}, {1,2}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
36 {1,3}, {0,0}, {1,1}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
37 {0,0}, {1,6}, {1,5}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0},
38 {0,0}, {0,0}, {2,5}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}
42 {0,0}, {3,5}, {0,0}, {0,0}, {2,3}, {0,0}, {3,3}, {0,0},
43 {2,4}, {0,0}, {3,4}, {0,0}, {2,2}, {0,0}, {3,2}, {0,0},
44 {0,0}, {1,6}, {0,0}, {0,0}, {0,0}, {0,0}, {2,6}, {0,0},
45 {0,0}, {0,0}, {3,6}, {0,0}, {0,0}, {0,0}, {2,5}, {0,0}
50 /* Table B-5 ... B-8 variable length codes for macroblock_type in
56 /* Table B-9, variable length codes for coded_block_pattern
58 * indexed by [coded_block_pattern]
61 const static VLCtable cbptable[64]=
63 {0x01,9}, {0x0b,5}, {0x09,5}, {0x0d,6},
64 {0x0d,4}, {0x17,7}, {0x13,7}, {0x1f,8},
65 {0x0c,4}, {0x16,7}, {0x12,7}, {0x1e,8},
66 {0x13,5}, {0x1b,8}, {0x17,8}, {0x13,8},
67 {0x0b,4}, {0x15,7}, {0x11,7}, {0x1d,8},
68 {0x11,5}, {0x19,8}, {0x15,8}, {0x11,8},
69 {0x0f,6}, {0x0f,8}, {0x0d,8}, {0x03,9},
70 {0x0f,5}, {0x0b,8}, {0x07,8}, {0x07,9},
71 {0x0a,4}, {0x14,7}, {0x10,7}, {0x1c,8},
72 {0x0e,6}, {0x0e,8}, {0x0c,8}, {0x02,9},
73 {0x10,5}, {0x18,8}, {0x14,8}, {0x10,8},
74 {0x0e,5}, {0x0a,8}, {0x06,8}, {0x06,9},
75 {0x12,5}, {0x1a,8}, {0x16,8}, {0x12,8},
76 {0x0d,5}, {0x09,8}, {0x05,8}, {0x05,9},
77 {0x0c,5}, {0x08,8}, {0x04,8}, {0x04,9},
78 {0x07,3}, {0x0a,5}, {0x08,5}, {0x0c,6}
83 /* Table B-14, DCT coefficients table zero
85 * indexed by [run][level-1]
86 * split into two tables (dct_code_tab1, dct_code_tab2) to reduce size
87 * 'first DCT coefficient' condition and 'End of Block' are treated elsewhere
88 * codes do not include s (sign bit)
91 const static VLCtable dct_code_tab1[2][40]=
93 /* run = 0, level = 1...40 */
95 {0x03, 2}, {0x04, 4}, {0x05, 5}, {0x06, 7},
96 {0x26, 8}, {0x21, 8}, {0x0a,10}, {0x1d,12},
97 {0x18,12}, {0x13,12}, {0x10,12}, {0x1a,13},
98 {0x19,13}, {0x18,13}, {0x17,13}, {0x1f,14},
99 {0x1e,14}, {0x1d,14}, {0x1c,14}, {0x1b,14},
100 {0x1a,14}, {0x19,14}, {0x18,14}, {0x17,14},
101 {0x16,14}, {0x15,14}, {0x14,14}, {0x13,14},
102 {0x12,14}, {0x11,14}, {0x10,14}, {0x18,15},
103 {0x17,15}, {0x16,15}, {0x15,15}, {0x14,15},
104 {0x13,15}, {0x12,15}, {0x11,15}, {0x10,15}
106 /* run = 1, level = 1...18 */
108 {0x03, 3}, {0x06, 6}, {0x25, 8}, {0x0c,10},
109 {0x1b,12}, {0x16,13}, {0x15,13}, {0x1f,15},
110 {0x1e,15}, {0x1d,15}, {0x1c,15}, {0x1b,15},
111 {0x1a,15}, {0x19,15}, {0x13,16}, {0x12,16},
112 {0x11,16}, {0x10,16}, {0x00, 0}, {0x00, 0},
113 {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0},
114 {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0},
115 {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0},
116 {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0},
117 {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}
121 const static VLCtable dct_code_tab2[30][5]=
123 /* run = 2...31, level = 1...5 */
124 {{0x05, 4}, {0x04, 7}, {0x0b,10}, {0x14,12}, {0x14,13}},
125 {{0x07, 5}, {0x24, 8}, {0x1c,12}, {0x13,13}, {0x00, 0}},
126 {{0x06, 5}, {0x0f,10}, {0x12,12}, {0x00, 0}, {0x00, 0}},
127 {{0x07, 6}, {0x09,10}, {0x12,13}, {0x00, 0}, {0x00, 0}},
128 {{0x05, 6}, {0x1e,12}, {0x14,16}, {0x00, 0}, {0x00, 0}},
129 {{0x04, 6}, {0x15,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
130 {{0x07, 7}, {0x11,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
131 {{0x05, 7}, {0x11,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
132 {{0x27, 8}, {0x10,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
133 {{0x23, 8}, {0x1a,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
134 {{0x22, 8}, {0x19,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
135 {{0x20, 8}, {0x18,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
136 {{0x0e,10}, {0x17,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
137 {{0x0d,10}, {0x16,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
138 {{0x08,10}, {0x15,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
139 {{0x1f,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
140 {{0x1a,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
141 {{0x19,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
142 {{0x17,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
143 {{0x16,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
144 {{0x1f,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
145 {{0x1e,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
146 {{0x1d,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
147 {{0x1c,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
148 {{0x1b,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
149 {{0x1f,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
150 {{0x1e,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
151 {{0x1d,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
152 {{0x1c,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
153 {{0x1b,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}}
157 /* Table B-15, DCT coefficients table one
159 * indexed by [run][level-1]
160 * split into two tables (dct_code_tab1a, dct_code_tab2a) to reduce size
161 * 'End of Block' is treated elsewhere
162 * codes do not include s (sign bit)
165 const static VLCtable dct_code_tab1a[2][40]=
167 /* run = 0, level = 1...40 */
169 {0x02, 2}, {0x06, 3}, {0x07, 4}, {0x1c, 5},
170 {0x1d, 5}, {0x05, 6}, {0x04, 6}, {0x7b, 7},
171 {0x7c, 7}, {0x23, 8}, {0x22, 8}, {0xfa, 8},
172 {0xfb, 8}, {0xfe, 8}, {0xff, 8}, {0x1f,14},
173 {0x1e,14}, {0x1d,14}, {0x1c,14}, {0x1b,14},
174 {0x1a,14}, {0x19,14}, {0x18,14}, {0x17,14},
175 {0x16,14}, {0x15,14}, {0x14,14}, {0x13,14},
176 {0x12,14}, {0x11,14}, {0x10,14}, {0x18,15},
177 {0x17,15}, {0x16,15}, {0x15,15}, {0x14,15},
178 {0x13,15}, {0x12,15}, {0x11,15}, {0x10,15}
180 /* run = 1, level = 1...18 */
182 {0x02, 3}, {0x06, 5}, {0x79, 7}, {0x27, 8},
183 {0x20, 8}, {0x16,13}, {0x15,13}, {0x1f,15},
184 {0x1e,15}, {0x1d,15}, {0x1c,15}, {0x1b,15},
185 {0x1a,15}, {0x19,15}, {0x13,16}, {0x12,16},
186 {0x11,16}, {0x10,16}, {0x00, 0}, {0x00, 0},
187 {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0},
188 {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0},
189 {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0},
190 {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0},
191 {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}
195 const static VLCtable dct_code_tab2a[30][5]=
197 /* run = 2...31, level = 1...5 */
198 {{0x05, 5}, {0x07, 7}, {0xfc, 8}, {0x0c,10}, {0x14,13}},
199 {{0x07, 5}, {0x26, 8}, {0x1c,12}, {0x13,13}, {0x00, 0}},
200 {{0x06, 6}, {0xfd, 8}, {0x12,12}, {0x00, 0}, {0x00, 0}},
201 {{0x07, 6}, {0x04, 9}, {0x12,13}, {0x00, 0}, {0x00, 0}},
202 {{0x06, 7}, {0x1e,12}, {0x14,16}, {0x00, 0}, {0x00, 0}},
203 {{0x04, 7}, {0x15,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
204 {{0x05, 7}, {0x11,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
205 {{0x78, 7}, {0x11,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
206 {{0x7a, 7}, {0x10,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
207 {{0x21, 8}, {0x1a,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
208 {{0x25, 8}, {0x19,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
209 {{0x24, 8}, {0x18,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
210 {{0x05, 9}, {0x17,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
211 {{0x07, 9}, {0x16,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
212 {{0x0d,10}, {0x15,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
213 {{0x1f,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
214 {{0x1a,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
215 {{0x19,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
216 {{0x17,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
217 {{0x16,12}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
218 {{0x1f,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
219 {{0x1e,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
220 {{0x1d,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
221 {{0x1c,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
222 {{0x1b,13}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
223 {{0x1f,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
224 {{0x1e,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
225 {{0x1d,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
226 {{0x1c,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}},
227 {{0x1b,16}, {0x00, 0}, {0x00, 0}, {0x00, 0}, {0x00, 0}}