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