]> git.sesse.net Git - vlc/blob - plugins/mpeg_vdec/vpar_blocks.h
35f17474a6204f95aa8ac817a6254a28ff3dee8a
[vlc] / plugins / mpeg_vdec / vpar_blocks.h
1 /*****************************************************************************
2  * video_parser.h : Variable Length Codes
3  *****************************************************************************
4  * Copyright (C) 1999, 2000 VideoLAN
5  * $Id: vpar_blocks.h,v 1.1 2001/11/13 12:09:18 henri Exp $
6  *
7  * Authors: Christophe Massiot <massiot@via.ecp.fr>
8  *          Jean-Marc Dressler <polux@via.ecp.fr>
9  *          Stéphane Borel <stef@via.ecp.fr>
10  *          Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
11  *          Michel Lespinasse <walken@zoy.org>
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  * 
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
26  *****************************************************************************/
27
28 /*****************************************************************************
29  * lookup_t : entry type for lookup tables                                   *
30  *****************************************************************************/
31 typedef struct lookup_s
32 {
33     u8     i_value;
34     u8     i_length;
35 } lookup_t;
36
37 typedef struct dmv_lookup_s
38 {
39     s8     i_value;
40     u8     i_length;
41 } dmv_lookup_t;
42
43 /*****************************************************************************
44  * dct_lookup_t : special entry type for lookup tables about ac coefficients
45  *****************************************************************************/
46 typedef struct dct_lookup_s
47 {
48     u8     i_run;
49     u8     i_level;
50     u8     i_length;
51 } dct_lookup_t;
52
53 /*****************************************************************************
54  * Standard codes
55  *****************************************************************************/
56
57 /* Motion types */
58 #define MOTION_TYPE_MASK (3*64)
59 #define MOTION_TYPE_BASE 64
60 #define MC_FIELD (1*64)
61 #define MC_FRAME (2*64)
62 #define MC_16X8 (2*64)
63 #define MC_DMV (3*64)
64
65 /* Macroblock Address Increment types */
66 #define MB_ADDRINC_ESCAPE               8
67 #define MB_ADDRINC_STUFFING             15
68
69 /* Error constant for lookup tables */
70 #define MB_ERROR                        (-1)
71
72 /* Scan */
73 #define SCAN_ZIGZAG                     0
74 #define SCAN_ALT                        1
75
76 /* Constant for block decoding */
77 #define DCT_EOB                         64
78 #define DCT_ESCAPE                      65
79
80
81 /*****************************************************************************
82  * Lookup tables for macroblock modes
83  *****************************************************************************/
84
85 #define INTRA MB_INTRA
86 #define QUANT MB_QUANT
87
88 static lookup_t MB_I [] = {
89     {INTRA|QUANT, 2}, {INTRA, 1}
90 };
91
92 #define MC MB_MOTION_FORWARD
93 #define CODED MB_PATTERN
94
95 static lookup_t MB_P [] = {
96     {INTRA|QUANT, 6}, {CODED|QUANT, 5}, {MC|CODED|QUANT, 5}, {INTRA,    5},
97     {MC,          3}, {MC,          3}, {MC,             3}, {MC,       3},
98     {CODED,       2}, {CODED,       2}, {CODED,          2}, {CODED,    2},
99     {CODED,       2}, {CODED,       2}, {CODED,          2}, {CODED,    2},
100     {MC|CODED,    1}, {MC|CODED,    1}, {MC|CODED,       1}, {MC|CODED, 1},
101     {MC|CODED,    1}, {MC|CODED,    1}, {MC|CODED,       1}, {MC|CODED, 1},
102     {MC|CODED,    1}, {MC|CODED,    1}, {MC|CODED,       1}, {MC|CODED, 1},
103     {MC|CODED,    1}, {MC|CODED,    1}, {MC|CODED,       1}, {MC|CODED, 1}
104 };
105
106 #define FWD MB_MOTION_FORWARD
107 #define BWD MB_MOTION_BACKWARD
108 #define INTER MB_MOTION_FORWARD|MB_MOTION_BACKWARD
109
110 static lookup_t MB_B [] = {
111     {0,                 0}, {INTRA|QUANT,       6},
112     {BWD|CODED|QUANT,   6}, {FWD|CODED|QUANT,   6},
113     {INTER|CODED|QUANT, 5}, {INTER|CODED|QUANT, 5},
114                                         {INTRA,       5}, {INTRA,       5},
115     {FWD,         4}, {FWD,         4}, {FWD,         4}, {FWD,         4},
116     {FWD|CODED,   4}, {FWD|CODED,   4}, {FWD|CODED,   4}, {FWD|CODED,   4},
117     {BWD,         3}, {BWD,         3}, {BWD,         3}, {BWD,         3},
118     {BWD,         3}, {BWD,         3}, {BWD,         3}, {BWD,         3},
119     {BWD|CODED,   3}, {BWD|CODED,   3}, {BWD|CODED,   3}, {BWD|CODED,   3},
120     {BWD|CODED,   3}, {BWD|CODED,   3}, {BWD|CODED,   3}, {BWD|CODED,   3},
121     {INTER,       2}, {INTER,       2}, {INTER,       2}, {INTER,       2},
122     {INTER,       2}, {INTER,       2}, {INTER,       2}, {INTER,       2},
123     {INTER,       2}, {INTER,       2}, {INTER,       2}, {INTER,       2},
124     {INTER,       2}, {INTER,       2}, {INTER,       2}, {INTER,       2},
125     {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2},
126     {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2},
127     {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2},
128     {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}
129 };
130
131 #undef INTRA
132 #undef QUANT
133 #undef MC
134 #undef CODED
135 #undef FWD
136 #undef BWD
137 #undef INTER
138
139
140 /*****************************************************************************
141  * Lookup tables for motion vectors
142  *****************************************************************************/
143
144 static lookup_t MV_4 [] = {
145     { 3, 6}, { 2, 4}, { 1, 3}, { 1, 3}, { 0, 2}, { 0, 2}, { 0, 2}, { 0, 2}
146 };
147
148 static lookup_t MV_10 [] = {
149     { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10},
150     { 0,10}, { 0,10}, { 0,10}, { 0,10}, {15,10}, {14,10}, {13,10}, {12,10},
151     {11,10}, {10,10}, { 9, 9}, { 9, 9}, { 8, 9}, { 8, 9}, { 7, 9}, { 7, 9},
152     { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7},
153     { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7},
154     { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}
155 };
156
157
158 static dmv_lookup_t DMV_2 [] = {
159     { 0, 1}, { 0, 1}, { 1, 2}, {-1, 2}
160 };
161
162
163 /*****************************************************************************
164  * Lookup tables for Coded Block Patterns
165  *****************************************************************************/
166
167 static lookup_t CBP_7 [] = {
168     {0x22, 7}, {0x12, 7}, {0x0a, 7}, {0x06, 7},
169     {0x21, 7}, {0x11, 7}, {0x09, 7}, {0x05, 7},
170     {0x3f, 6}, {0x3f, 6}, {0x03, 6}, {0x03, 6},
171     {0x24, 6}, {0x24, 6}, {0x18, 6}, {0x18, 6},
172     {0x3e, 5}, {0x3e, 5}, {0x3e, 5}, {0x3e, 5},
173     {0x02, 5}, {0x02, 5}, {0x02, 5}, {0x02, 5},
174     {0x3d, 5}, {0x3d, 5}, {0x3d, 5}, {0x3d, 5},
175     {0x01, 5}, {0x01, 5}, {0x01, 5}, {0x01, 5},
176     {0x38, 5}, {0x38, 5}, {0x38, 5}, {0x38, 5},
177     {0x34, 5}, {0x34, 5}, {0x34, 5}, {0x34, 5},
178     {0x2c, 5}, {0x2c, 5}, {0x2c, 5}, {0x2c, 5},
179     {0x1c, 5}, {0x1c, 5}, {0x1c, 5}, {0x1c, 5},
180     {0x28, 5}, {0x28, 5}, {0x28, 5}, {0x28, 5},
181     {0x14, 5}, {0x14, 5}, {0x14, 5}, {0x14, 5},
182     {0x30, 5}, {0x30, 5}, {0x30, 5}, {0x30, 5},
183     {0x0c, 5}, {0x0c, 5}, {0x0c, 5}, {0x0c, 5},
184     {0x20, 4}, {0x20, 4}, {0x20, 4}, {0x20, 4},
185     {0x20, 4}, {0x20, 4}, {0x20, 4}, {0x20, 4},
186     {0x10, 4}, {0x10, 4}, {0x10, 4}, {0x10, 4},
187     {0x10, 4}, {0x10, 4}, {0x10, 4}, {0x10, 4},
188     {0x08, 4}, {0x08, 4}, {0x08, 4}, {0x08, 4},
189     {0x08, 4}, {0x08, 4}, {0x08, 4}, {0x08, 4},
190     {0x04, 4}, {0x04, 4}, {0x04, 4}, {0x04, 4},
191     {0x04, 4}, {0x04, 4}, {0x04, 4}, {0x04, 4},
192     {0x3c, 3}, {0x3c, 3}, {0x3c, 3}, {0x3c, 3},
193     {0x3c, 3}, {0x3c, 3}, {0x3c, 3}, {0x3c, 3},
194     {0x3c, 3}, {0x3c, 3}, {0x3c, 3}, {0x3c, 3},
195     {0x3c, 3}, {0x3c, 3}, {0x3c, 3}, {0x3c, 3}
196 };
197
198 static lookup_t CBP_9 [] = {
199     {0,    0}, {0x00, 9}, {0x27, 9}, {0x1b, 9},
200     {0x3b, 9}, {0x37, 9}, {0x2f, 9}, {0x1f, 9},
201     {0x3a, 8}, {0x3a, 8}, {0x36, 8}, {0x36, 8},
202     {0x2e, 8}, {0x2e, 8}, {0x1e, 8}, {0x1e, 8},
203     {0x39, 8}, {0x39, 8}, {0x35, 8}, {0x35, 8},
204     {0x2d, 8}, {0x2d, 8}, {0x1d, 8}, {0x1d, 8},
205     {0x26, 8}, {0x26, 8}, {0x1a, 8}, {0x1a, 8},
206     {0x25, 8}, {0x25, 8}, {0x19, 8}, {0x19, 8},
207     {0x2b, 8}, {0x2b, 8}, {0x17, 8}, {0x17, 8},
208     {0x33, 8}, {0x33, 8}, {0x0f, 8}, {0x0f, 8},
209     {0x2a, 8}, {0x2a, 8}, {0x16, 8}, {0x16, 8},
210     {0x32, 8}, {0x32, 8}, {0x0e, 8}, {0x0e, 8},
211     {0x29, 8}, {0x29, 8}, {0x15, 8}, {0x15, 8},
212     {0x31, 8}, {0x31, 8}, {0x0d, 8}, {0x0d, 8},
213     {0x23, 8}, {0x23, 8}, {0x13, 8}, {0x13, 8},
214     {0x0b, 8}, {0x0b, 8}, {0x07, 8}, {0x07, 8}
215 };
216
217
218 /*****************************************************************************
219  * Lookup tables for coefficients
220  *****************************************************************************/
221
222 static lookup_t DC_lum_5 [] = {
223     {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
224     {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
225     {0, 3}, {0, 3}, {0, 3}, {0, 3}, {3, 3}, {3, 3}, {3, 3}, {3, 3},
226     {4, 3}, {4, 3}, {4, 3}, {4, 3}, {5, 4}, {5, 4}, {6, 5}
227 };
228
229 static lookup_t DC_chrom_5 [] = {
230     {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2},
231     {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
232     {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
233     {3, 3}, {3, 3}, {3, 3}, {3, 3}, {4, 4}, {4, 4}, {5, 5}
234 };
235
236 static lookup_t DC_long [] = {
237     {6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, { 6, 5}, { 6, 5},
238     {6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, { 6, 5}, { 6, 5},
239     {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, { 7, 6}, { 7, 6},
240     {8, 7}, {8, 7}, {8, 7}, {8, 7}, {9, 8}, {9, 8}, {10, 9}, {11, 9}
241 };
242
243
244 static dct_lookup_t DCT_16 [] = {
245     {129, 0, 16}, {129, 0, 16}, {129, 0, 16}, {129, 0, 16},
246     {129, 0, 16}, {129, 0, 16}, {129, 0, 16}, {129, 0, 16},
247     {129, 0, 16}, {129, 0, 16}, {129, 0, 16}, {129, 0, 16},
248     {129, 0, 16}, {129, 0, 16}, {129, 0, 16}, {129, 0, 16},
249     {  2,18, 16}, {  2,17, 16}, {  2,16, 16}, {  2,15, 16},
250     {  7, 3, 16}, { 17, 2, 16}, { 16, 2, 16}, { 15, 2, 16},
251     { 14, 2, 16}, { 13, 2, 16}, { 12, 2, 16}, { 32, 1, 16},
252     { 31, 1, 16}, { 30, 1, 16}, { 29, 1, 16}, { 28, 1, 16}
253 };
254
255 static dct_lookup_t DCT_15 [] = {
256     {  1,40,15}, {  1,39,15}, {  1,38,15}, {  1,37,15},
257     {  1,36,15}, {  1,35,15}, {  1,34,15}, {  1,33,15},
258     {  1,32,15}, {  2,14,15}, {  2,13,15}, {  2,12,15},
259     {  2,11,15}, {  2,10,15}, {  2, 9,15}, {  2, 8,15},
260     {  1,31,14}, {  1,31,14}, {  1,30,14}, {  1,30,14},
261     {  1,29,14}, {  1,29,14}, {  1,28,14}, {  1,28,14},
262     {  1,27,14}, {  1,27,14}, {  1,26,14}, {  1,26,14},
263     {  1,25,14}, {  1,25,14}, {  1,24,14}, {  1,24,14},
264     {  1,23,14}, {  1,23,14}, {  1,22,14}, {  1,22,14},
265     {  1,21,14}, {  1,21,14}, {  1,20,14}, {  1,20,14},
266     {  1,19,14}, {  1,19,14}, {  1,18,14}, {  1,18,14},
267     {  1,17,14}, {  1,17,14}, {  1,16,14}, {  1,16,14}
268 };
269
270 static dct_lookup_t DCT_13 [] = {
271     { 11, 2,13}, { 10, 2,13}, {  6, 3,13}, {  4, 4,13},
272     {  3, 5,13}, {  2, 7,13}, {  2, 6,13}, {  1,15,13},
273     {  1,14,13}, {  1,13,13}, {  1,12,13}, { 27, 1,13},
274     { 26, 1,13}, { 25, 1,13}, { 24, 1,13}, { 23, 1,13},
275     {  1,11,12}, {  1,11,12}, {  9, 2,12}, {  9, 2,12},
276     {  5, 3,12}, {  5, 3,12}, {  1,10,12}, {  1,10,12},
277     {  3, 4,12}, {  3, 4,12}, {  8, 2,12}, {  8, 2,12},
278     { 22, 1,12}, { 22, 1,12}, { 21, 1,12}, { 21, 1,12},
279     {  1, 9,12}, {  1, 9,12}, { 20, 1,12}, { 20, 1,12},
280     { 19, 1,12}, { 19, 1,12}, {  2, 5,12}, {  2, 5,12},
281     {  4, 3,12}, {  4, 3,12}, {  1, 8,12}, {  1, 8,12},
282     {  7, 2,12}, {  7, 2,12}, { 18, 1,12}, { 18, 1,12}
283 };
284
285 static dct_lookup_t DCT_B14_10 [] = {
286     { 17, 1,10}, {  6, 2,10}, {  1, 7,10}, {  3, 3,10},
287     {  2, 4,10}, { 16, 1,10}, { 15, 1,10}, {  5, 2,10}
288 };
289
290 static dct_lookup_t DCT_B14_8 [] = {
291     { 65, 0, 6}, { 65, 0, 6}, { 65, 0, 6}, { 65, 0, 6},
292     {  3, 2, 7}, {  3, 2, 7}, { 10, 1, 7}, { 10, 1, 7},
293     {  1, 4, 7}, {  1, 4, 7}, {  9, 1, 7}, {  9, 1, 7},
294     {  8, 1, 6}, {  8, 1, 6}, {  8, 1, 6}, {  8, 1, 6},
295     {  7, 1, 6}, {  7, 1, 6}, {  7, 1, 6}, {  7, 1, 6},
296     {  2, 2, 6}, {  2, 2, 6}, {  2, 2, 6}, {  2, 2, 6},
297     {  6, 1, 6}, {  6, 1, 6}, {  6, 1, 6}, {  6, 1, 6},
298     { 14, 1, 8}, {  1, 6, 8}, { 13, 1, 8}, { 12, 1, 8},
299     {  4, 2, 8}, {  2, 3, 8}, {  1, 5, 8}, { 11, 1, 8}
300 };
301
302 static dct_lookup_t DCT_B14AC_5 [] = {
303                  {  1, 3, 5}, {  5, 1, 5}, {  4, 1, 5},
304     {  1, 2, 4}, {  1, 2, 4}, {  3, 1, 4}, {  3, 1, 4},
305     {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
306     {129, 0, 2}, {129, 0, 2}, {129, 0, 2}, {129, 0, 2},
307     {129, 0, 2}, {129, 0, 2}, {129, 0, 2}, {129, 0, 2},
308     {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
309     {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}
310 };
311
312 static dct_lookup_t DCT_B14DC_5 [] = {
313                  {  1, 3, 5}, {  5, 1, 5}, {  4, 1, 5},
314     {  1, 2, 4}, {  1, 2, 4}, {  3, 1, 4}, {  3, 1, 4},
315     {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
316     {  1, 1, 1}, {  1, 1, 1}, {  1, 1, 1}, {  1, 1, 1},
317     {  1, 1, 1}, {  1, 1, 1}, {  1, 1, 1}, {  1, 1, 1},
318     {  1, 1, 1}, {  1, 1, 1}, {  1, 1, 1}, {  1, 1, 1},
319     {  1, 1, 1}, {  1, 1, 1}, {  1, 1, 1}, {  1, 1, 1}
320 };
321
322 static dct_lookup_t DCT_B15_10 [] = {
323     {  6, 2, 9}, {  6, 2, 9}, { 15, 1, 9}, { 15, 1, 9},
324     {  3, 4,10}, { 17, 1,10}, { 16, 1, 9}, { 16, 1, 9}
325 };
326
327 static dct_lookup_t DCT_B15_8 [] = {
328     { 65, 0, 6}, { 65, 0, 6}, { 65, 0, 6}, { 65, 0, 6},
329     {  8, 1, 7}, {  8, 1, 7}, {  9, 1, 7}, {  9, 1, 7},
330     {  7, 1, 7}, {  7, 1, 7}, {  3, 2, 7}, {  3, 2, 7},
331     {  1, 7, 6}, {  1, 7, 6}, {  1, 7, 6}, {  1, 7, 6},
332     {  1, 6, 6}, {  1, 6, 6}, {  1, 6, 6}, {  1, 6, 6},
333     {  5, 1, 6}, {  5, 1, 6}, {  5, 1, 6}, {  5, 1, 6},
334     {  6, 1, 6}, {  6, 1, 6}, {  6, 1, 6}, {  6, 1, 6},
335     {  2, 5, 8}, { 12, 1, 8}, {  1,11, 8}, {  1,10, 8},
336     { 14, 1, 8}, { 13, 1, 8}, {  4, 2, 8}, {  2, 4, 8},
337     {  3, 1, 5}, {  3, 1, 5}, {  3, 1, 5}, {  3, 1, 5},
338     {  3, 1, 5}, {  3, 1, 5}, {  3, 1, 5}, {  3, 1, 5},
339     {  2, 2, 5}, {  2, 2, 5}, {  2, 2, 5}, {  2, 2, 5},
340     {  2, 2, 5}, {  2, 2, 5}, {  2, 2, 5}, {  2, 2, 5},
341     {  4, 1, 5}, {  4, 1, 5}, {  4, 1, 5}, {  4, 1, 5},
342     {  4, 1, 5}, {  4, 1, 5}, {  4, 1, 5}, {  4, 1, 5},
343     {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
344     {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
345     {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
346     {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3}, {  2, 1, 3},
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     {129, 0, 4}, {129, 0, 4}, {129, 0, 4}, {129, 0, 4},
352     {129, 0, 4}, {129, 0, 4}, {129, 0, 4}, {129, 0, 4},
353     {129, 0, 4}, {129, 0, 4}, {129, 0, 4}, {129, 0, 4},
354     {129, 0, 4}, {129, 0, 4}, {129, 0, 4}, {129, 0, 4},
355     {  1, 3, 4}, {  1, 3, 4}, {  1, 3, 4}, {  1, 3, 4},
356     {  1, 3, 4}, {  1, 3, 4}, {  1, 3, 4}, {  1, 3, 4},
357     {  1, 3, 4}, {  1, 3, 4}, {  1, 3, 4}, {  1, 3, 4},
358     {  1, 3, 4}, {  1, 3, 4}, {  1, 3, 4}, {  1, 3, 4},
359     {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
360     {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
361     {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
362     {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2}, {  1, 1, 2},
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, 2, 3}, {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3},
376     {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3},
377     {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3},
378     {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3}, {  1, 2, 3},
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, 4, 5}, {  1, 4, 5}, {  1, 4, 5}, {  1, 4, 5},
384     {  1, 4, 5}, {  1, 4, 5}, {  1, 4, 5}, {  1, 4, 5},
385     {  1, 5, 5}, {  1, 5, 5}, {  1, 5, 5}, {  1, 5, 5},
386     {  1, 5, 5}, {  1, 5, 5}, {  1, 5, 5}, {  1, 5, 5},
387     { 10, 1, 7}, { 10, 1, 7}, {  2, 3, 7}, {  2, 3, 7},
388     { 11, 1, 7}, { 11, 1, 7}, {  1, 8, 7}, {  1, 8, 7},
389     {  1, 9, 7}, {  1, 9, 7}, {  1,12, 8}, {  1,13, 8},
390     {  3, 3, 8}, {  5, 2, 8}, {  1,14, 8}, {  1,15, 8}
391 };
392
393
394 /*****************************************************************************
395  * Lookup tables for Macroblock Address Increment
396  *****************************************************************************/
397
398 static lookup_t 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 lookup_t 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 };