1 /*
2  * vlc.h
3  * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
4  * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
5  *
6  * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
7  * See http://libmpeg2.sourceforge.net/ for updates.
8  *
9  * mpeg2dec is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * mpeg2dec 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
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  */
23 
24 #ifndef LIBMPEG2_VLC_H
25 #define LIBMPEG2_VLC_H
26 
27 #define GETWORD(bit_buf,shift,bit_ptr)				\
28 do {								\
29     bit_buf |= ((bit_ptr[0] << 8) | bit_ptr[1]) << (shift);	\
30     bit_ptr += 2;						\
31 } while (0)
32 
bitstream_init(mpeg2_decoder_t * decoder,const uint8_t * start)33 static inline void bitstream_init (mpeg2_decoder_t * decoder,
34 				   const uint8_t * start)
35 {
36     decoder->bitstream_buf =
37 	(start[0] << 24) | (start[1] << 16) | (start[2] << 8) | start[3];
38     decoder->bitstream_ptr = start + 4;
39     decoder->bitstream_bits = -16;
40 }
41 
42 /* make sure that there are at least 16 valid bits in bit_buf */
43 #define NEEDBITS(bit_buf,bits,bit_ptr)		\
44 do {						\
45     if (unlikely (bits > 0)) {			\
46 	GETWORD (bit_buf, bits, bit_ptr);	\
47 	bits -= 16;				\
48     }						\
49 } while (0)
50 
51 /* remove num valid bits from bit_buf */
52 #define DUMPBITS(bit_buf,bits,num)	\
53 do {					\
54     bit_buf <<= (num);			\
55     bits += (num);			\
56 } while (0)
57 
58 /* take num bits from the high part of bit_buf and zero extend them */
59 #define UBITS(bit_buf,num) (((uint32_t)(bit_buf)) >> (32 - (num)))
60 
61 /* take num bits from the high part of bit_buf and sign extend them */
62 #define SBITS(bit_buf,num) (((int32_t)(bit_buf)) >> (32 - (num)))
63 
64 typedef struct {
65     uint8_t modes;
66     uint8_t len;
67 } MBtab;
68 
69 typedef struct {
70     uint8_t delta;
71     uint8_t len;
72 } MVtab;
73 
74 typedef struct {
75     int8_t dmv;
76     uint8_t len;
77 } DMVtab;
78 
79 typedef struct {
80     uint8_t cbp;
81     uint8_t len;
82 } CBPtab;
83 
84 typedef struct {
85     uint8_t size;
86     uint8_t len;
87 } DCtab;
88 
89 typedef struct {
90     uint8_t run;
91     uint8_t level;
92     uint8_t len;
93 } DCTtab;
94 
95 typedef struct {
96     uint8_t mba;
97     uint8_t len;
98 } MBAtab;
99 
100 
101 #define INTRA MACROBLOCK_INTRA
102 #define QUANT MACROBLOCK_QUANT
103 
104 static const MBtab MB_I [] = {
105     {INTRA|QUANT, 2}, {INTRA, 1}
106 };
107 
108 #define MC MACROBLOCK_MOTION_FORWARD
109 #define CODED MACROBLOCK_PATTERN
110 
111 static const MBtab MB_P [] = {
112     {INTRA|QUANT, 6}, {CODED|QUANT, 5}, {MC|CODED|QUANT, 5}, {INTRA,    5},
113     {MC,          3}, {MC,          3}, {MC,             3}, {MC,       3},
114     {CODED,       2}, {CODED,       2}, {CODED,          2}, {CODED,    2},
115     {CODED,       2}, {CODED,       2}, {CODED,          2}, {CODED,    2},
116     {MC|CODED,    1}, {MC|CODED,    1}, {MC|CODED,       1}, {MC|CODED, 1},
117     {MC|CODED,    1}, {MC|CODED,    1}, {MC|CODED,       1}, {MC|CODED, 1},
118     {MC|CODED,    1}, {MC|CODED,    1}, {MC|CODED,       1}, {MC|CODED, 1},
119     {MC|CODED,    1}, {MC|CODED,    1}, {MC|CODED,       1}, {MC|CODED, 1}
120 };
121 
122 #define FWD MACROBLOCK_MOTION_FORWARD
123 #define BWD MACROBLOCK_MOTION_BACKWARD
124 #define INTER MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD
125 
126 static const MBtab MB_B [] = {
127     {0,                 6}, {INTRA|QUANT,       6},
128     {BWD|CODED|QUANT,   6}, {FWD|CODED|QUANT,   6},
129     {INTER|CODED|QUANT, 5}, {INTER|CODED|QUANT, 5},
130 					{INTRA,       5}, {INTRA,       5},
131     {FWD,         4}, {FWD,         4}, {FWD,         4}, {FWD,         4},
132     {FWD|CODED,   4}, {FWD|CODED,   4}, {FWD|CODED,   4}, {FWD|CODED,   4},
133     {BWD,         3}, {BWD,         3}, {BWD,         3}, {BWD,         3},
134     {BWD,         3}, {BWD,         3}, {BWD,         3}, {BWD,         3},
135     {BWD|CODED,   3}, {BWD|CODED,   3}, {BWD|CODED,   3}, {BWD|CODED,   3},
136     {BWD|CODED,   3}, {BWD|CODED,   3}, {BWD|CODED,   3}, {BWD|CODED,   3},
137     {INTER,       2}, {INTER,       2}, {INTER,       2}, {INTER,       2},
138     {INTER,       2}, {INTER,       2}, {INTER,       2}, {INTER,       2},
139     {INTER,       2}, {INTER,       2}, {INTER,       2}, {INTER,       2},
140     {INTER,       2}, {INTER,       2}, {INTER,       2}, {INTER,       2},
141     {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2},
142     {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2},
143     {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2},
144     {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}
145 };
146 
147 #undef INTRA
148 #undef QUANT
149 #undef MC
150 #undef CODED
151 #undef FWD
152 #undef BWD
153 #undef INTER
154 
155 
156 static const MVtab MV_4 [] = {
157     { 3, 6}, { 2, 4}, { 1, 3}, { 1, 3}, { 0, 2}, { 0, 2}, { 0, 2}, { 0, 2}
158 };
159 
160 static const MVtab MV_10 [] = {
161     { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10},
162     { 0,10}, { 0,10}, { 0,10}, { 0,10}, {15,10}, {14,10}, {13,10}, {12,10},
163     {11,10}, {10,10}, { 9, 9}, { 9, 9}, { 8, 9}, { 8, 9}, { 7, 9}, { 7, 9},
164     { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7},
165     { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7},
166     { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}
167 };
168 
169 
170 static const DMVtab DMV_2 [] = {
171     { 0, 1}, { 0, 1}, { 1, 2}, {-1, 2}
172 };
173 
174 
175 static const CBPtab CBP_7 [] = {
176     {0x11, 7}, {0x12, 7}, {0x14, 7}, {0x18, 7},
177     {0x21, 7}, {0x22, 7}, {0x24, 7}, {0x28, 7},
178     {0x3f, 6}, {0x3f, 6}, {0x30, 6}, {0x30, 6},
179     {0x09, 6}, {0x09, 6}, {0x06, 6}, {0x06, 6},
180     {0x1f, 5}, {0x1f, 5}, {0x1f, 5}, {0x1f, 5},
181     {0x10, 5}, {0x10, 5}, {0x10, 5}, {0x10, 5},
182     {0x2f, 5}, {0x2f, 5}, {0x2f, 5}, {0x2f, 5},
183     {0x20, 5}, {0x20, 5}, {0x20, 5}, {0x20, 5},
184     {0x07, 5}, {0x07, 5}, {0x07, 5}, {0x07, 5},
185     {0x0b, 5}, {0x0b, 5}, {0x0b, 5}, {0x0b, 5},
186     {0x0d, 5}, {0x0d, 5}, {0x0d, 5}, {0x0d, 5},
187     {0x0e, 5}, {0x0e, 5}, {0x0e, 5}, {0x0e, 5},
188     {0x05, 5}, {0x05, 5}, {0x05, 5}, {0x05, 5},
189     {0x0a, 5}, {0x0a, 5}, {0x0a, 5}, {0x0a, 5},
190     {0x03, 5}, {0x03, 5}, {0x03, 5}, {0x03, 5},
191     {0x0c, 5}, {0x0c, 5}, {0x0c, 5}, {0x0c, 5},
192     {0x01, 4}, {0x01, 4}, {0x01, 4}, {0x01, 4},
193     {0x01, 4}, {0x01, 4}, {0x01, 4}, {0x01, 4},
194     {0x02, 4}, {0x02, 4}, {0x02, 4}, {0x02, 4},
195     {0x02, 4}, {0x02, 4}, {0x02, 4}, {0x02, 4},
196     {0x04, 4}, {0x04, 4}, {0x04, 4}, {0x04, 4},
197     {0x04, 4}, {0x04, 4}, {0x04, 4}, {0x04, 4},
198     {0x08, 4}, {0x08, 4}, {0x08, 4}, {0x08, 4},
199     {0x08, 4}, {0x08, 4}, {0x08, 4}, {0x08, 4},
200     {0x0f, 3}, {0x0f, 3}, {0x0f, 3}, {0x0f, 3},
201     {0x0f, 3}, {0x0f, 3}, {0x0f, 3}, {0x0f, 3},
202     {0x0f, 3}, {0x0f, 3}, {0x0f, 3}, {0x0f, 3},
203     {0x0f, 3}, {0x0f, 3}, {0x0f, 3}, {0x0f, 3}
204 };
205 
206 static const CBPtab CBP_9 [] = {
207     {0,    9}, {0x00, 9}, {0x39, 9}, {0x36, 9},
208     {0x37, 9}, {0x3b, 9}, {0x3d, 9}, {0x3e, 9},
209     {0x17, 8}, {0x17, 8}, {0x1b, 8}, {0x1b, 8},
210     {0x1d, 8}, {0x1d, 8}, {0x1e, 8}, {0x1e, 8},
211     {0x27, 8}, {0x27, 8}, {0x2b, 8}, {0x2b, 8},
212     {0x2d, 8}, {0x2d, 8}, {0x2e, 8}, {0x2e, 8},
213     {0x19, 8}, {0x19, 8}, {0x16, 8}, {0x16, 8},
214     {0x29, 8}, {0x29, 8}, {0x26, 8}, {0x26, 8},
215     {0x35, 8}, {0x35, 8}, {0x3a, 8}, {0x3a, 8},
216     {0x33, 8}, {0x33, 8}, {0x3c, 8}, {0x3c, 8},
217     {0x15, 8}, {0x15, 8}, {0x1a, 8}, {0x1a, 8},
218     {0x13, 8}, {0x13, 8}, {0x1c, 8}, {0x1c, 8},
219     {0x25, 8}, {0x25, 8}, {0x2a, 8}, {0x2a, 8},
220     {0x23, 8}, {0x23, 8}, {0x2c, 8}, {0x2c, 8},
221     {0x31, 8}, {0x31, 8}, {0x32, 8}, {0x32, 8},
222     {0x34, 8}, {0x34, 8}, {0x38, 8}, {0x38, 8}
223 };
224 
225 
226 static const DCtab DC_lum_5 [] = {
227     {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
228     {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
229     {0, 3}, {0, 3}, {0, 3}, {0, 3}, {3, 3}, {3, 3}, {3, 3}, {3, 3},
230     {4, 3}, {4, 3}, {4, 3}, {4, 3}, {5, 4}, {5, 4}, {6, 5}
231 };
232 
233 static const DCtab DC_chrom_5 [] = {
234     {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2},
235     {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
236     {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
237     {3, 3}, {3, 3}, {3, 3}, {3, 3}, {4, 4}, {4, 4}, {5, 5}
238 };
239 
240 static const DCtab DC_long [] = {
241     {6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, { 6, 5}, { 6, 5},
242     {6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, { 6, 5}, { 6, 5},
243     {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, { 7, 6}, { 7, 6},
244     {8, 7}, {8, 7}, {8, 7}, {8, 7}, {9, 8}, {9, 8}, {10, 9}, {11, 9}
245 };
246 
247 
248 static const DCTtab DCT_16 [] = {
249     {129, 0, 0}, {129, 0, 0}, {129, 0, 0}, {129, 0, 0},
250     {129, 0, 0}, {129, 0, 0}, {129, 0, 0}, {129, 0, 0},
251     {129, 0, 0}, {129, 0, 0}, {129, 0, 0}, {129, 0, 0},
252     {129, 0, 0}, {129, 0, 0}, {129, 0, 0}, {129, 0, 0},
253     {  2,18, 0}, {  2,17, 0}, {  2,16, 0}, {  2,15, 0},
254     {  7, 3, 0}, { 17, 2, 0}, { 16, 2, 0}, { 15, 2, 0},
255     { 14, 2, 0}, { 13, 2, 0}, { 12, 2, 0}, { 32, 1, 0},
256     { 31, 1, 0}, { 30, 1, 0}, { 29, 1, 0}, { 28, 1, 0}
257 };
258 
259 static const DCTtab DCT_15 [] = {
260     {  1,40,15}, {  1,39,15}, {  1,38,15}, {  1,37,15},
261     {  1,36,15}, {  1,35,15}, {  1,34,15}, {  1,33,15},
262     {  1,32,15}, {  2,14,15}, {  2,13,15}, {  2,12,15},
263     {  2,11,15}, {  2,10,15}, {  2, 9,15}, {  2, 8,15},
264     {  1,31,14}, {  1,31,14}, {  1,30,14}, {  1,30,14},
265     {  1,29,14}, {  1,29,14}, {  1,28,14}, {  1,28,14},
266     {  1,27,14}, {  1,27,14}, {  1,26,14}, {  1,26,14},
267     {  1,25,14}, {  1,25,14}, {  1,24,14}, {  1,24,14},
268     {  1,23,14}, {  1,23,14}, {  1,22,14}, {  1,22,14},
269     {  1,21,14}, {  1,21,14}, {  1,20,14}, {  1,20,14},
270     {  1,19,14}, {  1,19,14}, {  1,18,14}, {  1,18,14},
271     {  1,17,14}, {  1,17,14}, {  1,16,14}, {  1,16,14}
272 };
273 
274 static const DCTtab DCT_13 [] = {
275     { 11, 2,13}, { 10, 2,13}, {  6, 3,13}, {  4, 4,13},
276     {  3, 5,13}, {  2, 7,13}, {  2, 6,13}, {  1,15,13},
277     {  1,14,13}, {  1,13,13}, {  1,12,13}, { 27, 1,13},
278     { 26, 1,13}, { 25, 1,13}, { 24, 1,13}, { 23, 1,13},
279     {  1,11,12}, {  1,11,12}, {  9, 2,12}, {  9, 2,12},
280     {  5, 3,12}, {  5, 3,12}, {  1,10,12}, {  1,10,12},
281     {  3, 4,12}, {  3, 4,12}, {  8, 2,12}, {  8, 2,12},
282     { 22, 1,12}, { 22, 1,12}, { 21, 1,12}, { 21, 1,12},
283     {  1, 9,12}, {  1, 9,12}, { 20, 1,12}, { 20, 1,12},
284     { 19, 1,12}, { 19, 1,12}, {  2, 5,12}, {  2, 5,12},
285     {  4, 3,12}, {  4, 3,12}, {  1, 8,12}, {  1, 8,12},
286     {  7, 2,12}, {  7, 2,12}, { 18, 1,12}, { 18, 1,12}
287 };
288 
289 static const DCTtab DCT_B14_10 [] = {
290     { 17, 1,10}, {  6, 2,10}, {  1, 7,10}, {  3, 3,10},
291     {  2, 4,10}, { 16, 1,10}, { 15, 1,10}, {  5, 2,10}
292 };
293 
294 static const DCTtab DCT_B14_8 [] = {
295     { 65, 0,12}, { 65, 0,12}, { 65, 0,12}, { 65, 0,12},
296     {  3, 2, 7}, {  3, 2, 7}, { 10, 1, 7}, { 10, 1, 7},
297     {  1, 4, 7}, {  1, 4, 7}, {  9, 1, 7}, {  9, 1, 7},
298     {  8, 1, 6}, {  8, 1, 6}, {  8, 1, 6}, {  8, 1, 6},
299     {  7, 1, 6}, {  7, 1, 6}, {  7, 1, 6}, {  7, 1, 6},
300     {  2, 2, 6}, {  2, 2, 6}, {  2, 2, 6}, {  2, 2, 6},
301     {  6, 1, 6}, {  6, 1, 6}, {  6, 1, 6}, {  6, 1, 6},
302     { 14, 1, 8}, {  1, 6, 8}, { 13, 1, 8}, { 12, 1, 8},
303     {  4, 2, 8}, {  2, 3, 8}, {  1, 5, 8}, { 11, 1, 8}
304 };
305 
306 static const DCTtab DCT_B14AC_5 [] = {
307 		 {  1, 3, 5}, {  5, 1, 5}, {  4, 1, 5},
308     {  1, 2, 4}, {  1, 2, 4}, {  3, 1, 4}, {  3, 1, 4},
309     {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
310     {129, 0, 2}, {129, 0, 2}, {129, 0, 2}, {129, 0, 2},
311     {129, 0, 2}, {129, 0, 2}, {129, 0, 2}, {129, 0, 2},
312     {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
313     {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}
314 };
315 
316 static const DCTtab DCT_B14DC_5 [] = {
317 		 {  1, 3, 5}, {  5, 1, 5}, {  4, 1, 5},
318     {  1, 2, 4}, {  1, 2, 4}, {  3, 1, 4}, {  3, 1, 4},
319     {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
320     {  1, 1, 1}, {  1, 1, 1}, {  1, 1, 1}, {  1, 1, 1},
321     {  1, 1, 1}, {  1, 1, 1}, {  1, 1, 1}, {  1, 1, 1},
322     {  1, 1, 1}, {  1, 1, 1}, {  1, 1, 1}, {  1, 1, 1},
323     {  1, 1, 1}, {  1, 1, 1}, {  1, 1, 1}, {  1, 1, 1}
324 };
325 
326 static const DCTtab DCT_B15_10 [] = {
327     {  6, 2, 9}, {  6, 2, 9}, { 15, 1, 9}, { 15, 1, 9},
328     {  3, 4,10}, { 17, 1,10}, { 16, 1, 9}, { 16, 1, 9}
329 };
330 
331 static const DCTtab DCT_B15_8 [] = {
332     { 65, 0,12}, { 65, 0,12}, { 65, 0,12}, { 65, 0,12},
333     {  8, 1, 7}, {  8, 1, 7}, {  9, 1, 7}, {  9, 1, 7},
334     {  7, 1, 7}, {  7, 1, 7}, {  3, 2, 7}, {  3, 2, 7},
335     {  1, 7, 6}, {  1, 7, 6}, {  1, 7, 6}, {  1, 7, 6},
336     {  1, 6, 6}, {  1, 6, 6}, {  1, 6, 6}, {  1, 6, 6},
337     {  5, 1, 6}, {  5, 1, 6}, {  5, 1, 6}, {  5, 1, 6},
338     {  6, 1, 6}, {  6, 1, 6}, {  6, 1, 6}, {  6, 1, 6},
339     {  2, 5, 8}, { 12, 1, 8}, {  1,11, 8}, {  1,10, 8},
340     { 14, 1, 8}, { 13, 1, 8}, {  4, 2, 8}, {  2, 4, 8},
341     {  3, 1, 5}, {  3, 1, 5}, {  3, 1, 5}, {  3, 1, 5},
342     {  3, 1, 5}, {  3, 1, 5}, {  3, 1, 5}, {  3, 1, 5},
343     {  2, 2, 5}, {  2, 2, 5}, {  2, 2, 5}, {  2, 2, 5},
344     {  2, 2, 5}, {  2, 2, 5}, {  2, 2, 5}, {  2, 2, 5},
345     {  4, 1, 5}, {  4, 1, 5}, {  4, 1, 5}, {  4, 1, 5},
346     {  4, 1, 5}, {  4, 1, 5}, {  4, 1, 5}, {  4, 1, 5},
347     {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
348     {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
349     {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
350     {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
351     {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
352     {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
353     {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
354     {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
355     {129, 0, 4}, {129, 0, 4}, {129, 0, 4}, {129, 0, 4},
356     {129, 0, 4}, {129, 0, 4}, {129, 0, 4}, {129, 0, 4},
357     {129, 0, 4}, {129, 0, 4}, {129, 0, 4}, {129, 0, 4},
358     {129, 0, 4}, {129, 0, 4}, {129, 0, 4}, {129, 0, 4},
359     {  1, 3, 4}, {  1, 3, 4}, {  1, 3, 4}, {  1, 3, 4},
360     {  1, 3, 4}, {  1, 3, 4}, {  1, 3, 4}, {  1, 3, 4},
361     {  1, 3, 4}, {  1, 3, 4}, {  1, 3, 4}, {  1, 3, 4},
362     {  1, 3, 4}, {  1, 3, 4}, {  1, 3, 4}, {  1, 3, 4},
363     {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
364     {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
365     {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
366     {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
367     {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
368     {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
369     {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
370     {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
371     {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
372     {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
373     {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
374     {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
375     {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
376     {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
377     {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
378     {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
379     {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3},
380     {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3},
381     {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3},
382     {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3},
383     {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3},
384     {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3},
385     {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3},
386     {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3},
387     {  1, 4, 5}, {  1, 4, 5}, {  1, 4, 5}, {  1, 4, 5},
388     {  1, 4, 5}, {  1, 4, 5}, {  1, 4, 5}, {  1, 4, 5},
389     {  1, 5, 5}, {  1, 5, 5}, {  1, 5, 5}, {  1, 5, 5},
390     {  1, 5, 5}, {  1, 5, 5}, {  1, 5, 5}, {  1, 5, 5},
391     { 10, 1, 7}, { 10, 1, 7}, {  2, 3, 7}, {  2, 3, 7},
392     { 11, 1, 7}, { 11, 1, 7}, {  1, 8, 7}, {  1, 8, 7},
393     {  1, 9, 7}, {  1, 9, 7}, {  1,12, 8}, {  1,13, 8},
394     {  3, 3, 8}, {  5, 2, 8}, {  1,14, 8}, {  1,15, 8}
395 };
396 
397 
398 static const MBAtab MBA_5 [] = {
399 		    {6, 5}, {5, 5}, {4, 4}, {4, 4}, {3, 4}, {3, 4},
400     {2, 3}, {2, 3}, {2, 3}, {2, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3},
401     {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1},
402     {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}
403 };
404 
405 static const MBAtab MBA_11 [] = {
406     {32, 11}, {31, 11}, {30, 11}, {29, 11},
407     {28, 11}, {27, 11}, {26, 11}, {25, 11},
408     {24, 11}, {23, 11}, {22, 11}, {21, 11},
409     {20, 10}, {20, 10}, {19, 10}, {19, 10},
410     {18, 10}, {18, 10}, {17, 10}, {17, 10},
411     {16, 10}, {16, 10}, {15, 10}, {15, 10},
412     {14,  8}, {14,  8}, {14,  8}, {14,  8},
413     {14,  8}, {14,  8}, {14,  8}, {14,  8},
414     {13,  8}, {13,  8}, {13,  8}, {13,  8},
415     {13,  8}, {13,  8}, {13,  8}, {13,  8},
416     {12,  8}, {12,  8}, {12,  8}, {12,  8},
417     {12,  8}, {12,  8}, {12,  8}, {12,  8},
418     {11,  8}, {11,  8}, {11,  8}, {11,  8},
419     {11,  8}, {11,  8}, {11,  8}, {11,  8},
420     {10,  8}, {10,  8}, {10,  8}, {10,  8},
421     {10,  8}, {10,  8}, {10,  8}, {10,  8},
422     { 9,  8}, { 9,  8}, { 9,  8}, { 9,  8},
423     { 9,  8}, { 9,  8}, { 9,  8}, { 9,  8},
424     { 8,  7}, { 8,  7}, { 8,  7}, { 8,  7},
425     { 8,  7}, { 8,  7}, { 8,  7}, { 8,  7},
426     { 8,  7}, { 8,  7}, { 8,  7}, { 8,  7},
427     { 8,  7}, { 8,  7}, { 8,  7}, { 8,  7},
428     { 7,  7}, { 7,  7}, { 7,  7}, { 7,  7},
429     { 7,  7}, { 7,  7}, { 7,  7}, { 7,  7},
430     { 7,  7}, { 7,  7}, { 7,  7}, { 7,  7},
431     { 7,  7}, { 7,  7}, { 7,  7}, { 7,  7}
432 };
433 
434 #endif /* LIBMPEG2_VLC_H */
435