/[pcsx2_0.9.7]/trunk/pcsx2/IPU/mpeg2lib/Vlc.h
ViewVC logotype

Contents of /trunk/pcsx2/IPU/mpeg2lib/Vlc.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62 - (show annotations) (download)
Tue Sep 7 11:08:22 2010 UTC (10 years ago) by william
File MIME type: text/plain
File size: 26819 byte(s)
Auto Commited Import of: pcsx2-0.9.7-r3738-debug in ./trunk
1 /*
2 * vlc.h
3 * Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org>
4 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
5 * Modified by Florin for PCSX2 emu
6 *
7 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
8 * See http://libmpeg2.sourceforge.net/ for updates.
9 *
10 * mpeg2dec is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * mpeg2dec is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25 // WARNING! This file should only be included into Mpeg.cpp AND NOWHERE ELSE.
26 // All contents of this file are used only by Mpeg.cpp, and including it elsewhere will
27 // just result in the linker having to remove a whole lot of redundant/unused decoder
28 // tables and static functions. -- air
29
30 #ifndef __VLC_H__
31 #define __VLC_H__
32
33 //static u8 word[4];
34 //static u8 dword[8];
35 //static u8 qword[16];
36
37 static __fi int GETWORD()
38 {
39 static u8 data[2];
40
41 if (decoder.bitstream_bits > 0)
42 {
43 if(!getBits16(data,1))
44 {
45 return 0;
46 }
47
48 /*u32 data;
49 BigEndian(data, *(u32*)word);
50 decoder.bitstream_buf |= (u64)data << decoder.bitstream_bits;
51 decoder.bitstream_bits -= 32;*/
52 decoder.bitstream_buf |= (((u32)data[0] << 8) | data[1]) << decoder.bitstream_bits;
53 decoder.bitstream_bits -= 16;
54 }
55
56 return 1;
57 }
58
59 static __fi int bitstream_init ()
60 {
61 if (!getBits32((u8*)&decoder.bitstream_buf, 1))
62 {
63 return 0;
64 }
65
66 decoder.bitstream_bits = -16;
67 BigEndian(decoder.bitstream_buf, decoder.bitstream_buf);
68 /*decoder.bitstream_buf = *(u64*)dword;
69 BigEndian64(decoder.bitstream_buf, decoder.bitstream_buf);*/
70
71 return 1;
72 }
73
74 /* remove num valid bits from bit_buf */
75 static __fi void DUMPBITS(int num)
76 {
77 decoder.bitstream_buf <<= num;
78 decoder.bitstream_bits += num;
79 }
80
81 /* take num bits from the high part of bit_buf and zero extend them */
82 #define UBITS(num) (((u32)decoder.bitstream_buf) >> (32 - (num)))
83
84 /* take num bits from the high part of bit_buf and sign extend them */
85 #define SBITS(num) (((s32)decoder.bitstream_buf) >> (32 - (num)))
86
87 /* Get bits from bitstream */
88 static __fi u32 GETBITS(int num)
89 {
90 u16 retVal = UBITS(num);
91 DUMPBITS(num);
92
93 return retVal;
94 }
95
96 struct MBtab {
97 u8 modes;
98 u8 len;
99 };
100
101 struct MVtab {
102 u8 delta;
103 u8 len;
104 };
105
106 struct DMVtab {
107 s8 dmv;
108 u8 len;
109 };
110
111 struct CBPtab {
112 u8 cbp;
113 u8 len;
114 };
115
116 struct DCtab {
117 u8 size;
118 u8 len;
119 };
120
121 struct DCTtab {
122 u8 run;
123 u8 level;
124 u8 len;
125 };
126
127 struct MBAtab {
128 u8 mba;
129 u8 len;
130 };
131
132
133 #define INTRA MACROBLOCK_INTRA
134 #define QUANT MACROBLOCK_QUANT
135
136 static const MBtab MB_I [] = {
137 {INTRA|QUANT, 2}, {INTRA, 1}
138 };
139
140 #define MC MACROBLOCK_MOTION_FORWARD
141 #define CODED MACROBLOCK_PATTERN
142
143 static const __aligned16 MBtab MB_P [] = {
144 {INTRA|QUANT, 6}, {CODED|QUANT, 5}, {MC|CODED|QUANT, 5}, {INTRA, 5},
145 {MC, 3}, {MC, 3}, {MC, 3}, {MC, 3},
146 {CODED, 2}, {CODED, 2}, {CODED, 2}, {CODED, 2},
147 {CODED, 2}, {CODED, 2}, {CODED, 2}, {CODED, 2},
148 {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1},
149 {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1},
150 {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1},
151 {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1}
152 };
153
154 #define FWD MACROBLOCK_MOTION_FORWARD
155 #define BWD MACROBLOCK_MOTION_BACKWARD
156 #define INTER MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD
157
158 static const __aligned16 MBtab MB_B [] = {
159 {0, 0}, {INTRA|QUANT, 6},
160 {BWD|CODED|QUANT, 6}, {FWD|CODED|QUANT, 6},
161 {INTER|CODED|QUANT, 5}, {INTER|CODED|QUANT, 5},
162 {INTRA, 5}, {INTRA, 5},
163 {FWD, 4}, {FWD, 4}, {FWD, 4}, {FWD, 4},
164 {FWD|CODED, 4}, {FWD|CODED, 4}, {FWD|CODED, 4}, {FWD|CODED, 4},
165 {BWD, 3}, {BWD, 3}, {BWD, 3}, {BWD, 3},
166 {BWD, 3}, {BWD, 3}, {BWD, 3}, {BWD, 3},
167 {BWD|CODED, 3}, {BWD|CODED, 3}, {BWD|CODED, 3}, {BWD|CODED, 3},
168 {BWD|CODED, 3}, {BWD|CODED, 3}, {BWD|CODED, 3}, {BWD|CODED, 3},
169 {INTER, 2}, {INTER, 2}, {INTER, 2}, {INTER, 2},
170 {INTER, 2}, {INTER, 2}, {INTER, 2}, {INTER, 2},
171 {INTER, 2}, {INTER, 2}, {INTER, 2}, {INTER, 2},
172 {INTER, 2}, {INTER, 2}, {INTER, 2}, {INTER, 2},
173 {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2},
174 {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2},
175 {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2},
176 {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}
177 };
178
179 #undef INTRA
180 #undef QUANT
181 #undef MC
182 #undef CODED
183 #undef FWD
184 #undef BWD
185 #undef INTER
186
187
188 static const MVtab MV_4 [] = {
189 { 3, 6}, { 2, 4}, { 1, 3}, { 1, 3}, { 0, 2}, { 0, 2}, { 0, 2}, { 0, 2}
190 };
191
192 static const __aligned16 MVtab MV_10 [] = {
193 { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10},
194 { 0,10}, { 0,10}, { 0,10}, { 0,10}, {15,10}, {14,10}, {13,10}, {12,10},
195 {11,10}, {10,10}, { 9, 9}, { 9, 9}, { 8, 9}, { 8, 9}, { 7, 9}, { 7, 9},
196 { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7},
197 { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7},
198 { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}
199 };
200
201
202 static const DMVtab DMV_2 [] = {
203 { 0, 1}, { 0, 1}, { 1, 2}, {-1, 2}
204 };
205
206
207 static const __aligned16 CBPtab CBP_7 [] = {
208 {0x22, 7}, {0x12, 7}, {0x0a, 7}, {0x06, 7},
209 {0x21, 7}, {0x11, 7}, {0x09, 7}, {0x05, 7},
210 {0x3f, 6}, {0x3f, 6}, {0x03, 6}, {0x03, 6},
211 {0x24, 6}, {0x24, 6}, {0x18, 6}, {0x18, 6},
212 {0x3e, 5}, {0x3e, 5}, {0x3e, 5}, {0x3e, 5},
213 {0x02, 5}, {0x02, 5}, {0x02, 5}, {0x02, 5},
214 {0x3d, 5}, {0x3d, 5}, {0x3d, 5}, {0x3d, 5},
215 {0x01, 5}, {0x01, 5}, {0x01, 5}, {0x01, 5},
216 {0x38, 5}, {0x38, 5}, {0x38, 5}, {0x38, 5},
217 {0x34, 5}, {0x34, 5}, {0x34, 5}, {0x34, 5},
218 {0x2c, 5}, {0x2c, 5}, {0x2c, 5}, {0x2c, 5},
219 {0x1c, 5}, {0x1c, 5}, {0x1c, 5}, {0x1c, 5},
220 {0x28, 5}, {0x28, 5}, {0x28, 5}, {0x28, 5},
221 {0x14, 5}, {0x14, 5}, {0x14, 5}, {0x14, 5},
222 {0x30, 5}, {0x30, 5}, {0x30, 5}, {0x30, 5},
223 {0x0c, 5}, {0x0c, 5}, {0x0c, 5}, {0x0c, 5},
224 {0x20, 4}, {0x20, 4}, {0x20, 4}, {0x20, 4},
225 {0x20, 4}, {0x20, 4}, {0x20, 4}, {0x20, 4},
226 {0x10, 4}, {0x10, 4}, {0x10, 4}, {0x10, 4},
227 {0x10, 4}, {0x10, 4}, {0x10, 4}, {0x10, 4},
228 {0x08, 4}, {0x08, 4}, {0x08, 4}, {0x08, 4},
229 {0x08, 4}, {0x08, 4}, {0x08, 4}, {0x08, 4},
230 {0x04, 4}, {0x04, 4}, {0x04, 4}, {0x04, 4},
231 {0x04, 4}, {0x04, 4}, {0x04, 4}, {0x04, 4},
232 {0x3c, 3}, {0x3c, 3}, {0x3c, 3}, {0x3c, 3},
233 {0x3c, 3}, {0x3c, 3}, {0x3c, 3}, {0x3c, 3},
234 {0x3c, 3}, {0x3c, 3}, {0x3c, 3}, {0x3c, 3},
235 {0x3c, 3}, {0x3c, 3}, {0x3c, 3}, {0x3c, 3}
236 };
237
238 static const __aligned16 CBPtab CBP_9 [] = {
239 {0, 0}, {0x00, 9}, {0x27, 9}, {0x1b, 9},
240 {0x3b, 9}, {0x37, 9}, {0x2f, 9}, {0x1f, 9},
241 {0x3a, 8}, {0x3a, 8}, {0x36, 8}, {0x36, 8},
242 {0x2e, 8}, {0x2e, 8}, {0x1e, 8}, {0x1e, 8},
243 {0x39, 8}, {0x39, 8}, {0x35, 8}, {0x35, 8},
244 {0x2d, 8}, {0x2d, 8}, {0x1d, 8}, {0x1d, 8},
245 {0x26, 8}, {0x26, 8}, {0x1a, 8}, {0x1a, 8},
246 {0x25, 8}, {0x25, 8}, {0x19, 8}, {0x19, 8},
247 {0x2b, 8}, {0x2b, 8}, {0x17, 8}, {0x17, 8},
248 {0x33, 8}, {0x33, 8}, {0x0f, 8}, {0x0f, 8},
249 {0x2a, 8}, {0x2a, 8}, {0x16, 8}, {0x16, 8},
250 {0x32, 8}, {0x32, 8}, {0x0e, 8}, {0x0e, 8},
251 {0x29, 8}, {0x29, 8}, {0x15, 8}, {0x15, 8},
252 {0x31, 8}, {0x31, 8}, {0x0d, 8}, {0x0d, 8},
253 {0x23, 8}, {0x23, 8}, {0x13, 8}, {0x13, 8},
254 {0x0b, 8}, {0x0b, 8}, {0x07, 8}, {0x07, 8}
255 };
256
257 #if 0 // following tables are unused by PCSX2
258
259 static const DCtab DC_lum_5 [] = {
260 {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
261 {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
262 {0, 3}, {0, 3}, {0, 3}, {0, 3}, {3, 3}, {3, 3}, {3, 3}, {3, 3},
263 {4, 3}, {4, 3}, {4, 3}, {4, 3}, {5, 4}, {5, 4}, {6, 5}
264 };
265
266 static const DCtab DC_chrom_5 [] = {
267 {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2},
268 {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
269 {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
270 {3, 3}, {3, 3}, {3, 3}, {3, 3}, {4, 4}, {4, 4}, {5, 5}
271 };
272
273 static const DCtab DC_long [] = {
274 {6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, { 6, 5}, { 6, 5},
275 {6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, { 6, 5}, { 6, 5},
276 {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, { 7, 6}, { 7, 6},
277 {8, 7}, {8, 7}, {8, 7}, {8, 7}, {9, 8}, {9, 8}, {10, 9}, {11, 9}
278 };
279
280 static const DCTtab DCT_16 [] = {
281 {129, 0, 0}, {129, 0, 0}, {129, 0, 0}, {129, 0, 0},
282 {129, 0, 0}, {129, 0, 0}, {129, 0, 0}, {129, 0, 0},
283 {129, 0, 0}, {129, 0, 0}, {129, 0, 0}, {129, 0, 0},
284 {129, 0, 0}, {129, 0, 0}, {129, 0, 0}, {129, 0, 0},
285 { 2,18, 0}, { 2,17, 0}, { 2,16, 0}, { 2,15, 0},
286 { 7, 3, 0}, { 17, 2, 0}, { 16, 2, 0}, { 15, 2, 0},
287 { 14, 2, 0}, { 13, 2, 0}, { 12, 2, 0}, { 32, 1, 0},
288 { 31, 1, 0}, { 30, 1, 0}, { 29, 1, 0}, { 28, 1, 0}
289 };
290
291 static const DCTtab DCT_15 [] = {
292 { 1,40,15}, { 1,39,15}, { 1,38,15}, { 1,37,15},
293 { 1,36,15}, { 1,35,15}, { 1,34,15}, { 1,33,15},
294 { 1,32,15}, { 2,14,15}, { 2,13,15}, { 2,12,15},
295 { 2,11,15}, { 2,10,15}, { 2, 9,15}, { 2, 8,15},
296 { 1,31,14}, { 1,31,14}, { 1,30,14}, { 1,30,14},
297 { 1,29,14}, { 1,29,14}, { 1,28,14}, { 1,28,14},
298 { 1,27,14}, { 1,27,14}, { 1,26,14}, { 1,26,14},
299 { 1,25,14}, { 1,25,14}, { 1,24,14}, { 1,24,14},
300 { 1,23,14}, { 1,23,14}, { 1,22,14}, { 1,22,14},
301 { 1,21,14}, { 1,21,14}, { 1,20,14}, { 1,20,14},
302 { 1,19,14}, { 1,19,14}, { 1,18,14}, { 1,18,14},
303 { 1,17,14}, { 1,17,14}, { 1,16,14}, { 1,16,14}
304 };
305
306 static const DCTtab DCT_13 [] = {
307 { 11, 2,13}, { 10, 2,13}, { 6, 3,13}, { 4, 4,13},
308 { 3, 5,13}, { 2, 7,13}, { 2, 6,13}, { 1,15,13},
309 { 1,14,13}, { 1,13,13}, { 1,12,13}, { 27, 1,13},
310 { 26, 1,13}, { 25, 1,13}, { 24, 1,13}, { 23, 1,13},
311 { 1,11,12}, { 1,11,12}, { 9, 2,12}, { 9, 2,12},
312 { 5, 3,12}, { 5, 3,12}, { 1,10,12}, { 1,10,12},
313 { 3, 4,12}, { 3, 4,12}, { 8, 2,12}, { 8, 2,12},
314 { 22, 1,12}, { 22, 1,12}, { 21, 1,12}, { 21, 1,12},
315 { 1, 9,12}, { 1, 9,12}, { 20, 1,12}, { 20, 1,12},
316 { 19, 1,12}, { 19, 1,12}, { 2, 5,12}, { 2, 5,12},
317 { 4, 3,12}, { 4, 3,12}, { 1, 8,12}, { 1, 8,12},
318 { 7, 2,12}, { 7, 2,12}, { 18, 1,12}, { 18, 1,12}
319 };
320
321 static const DCTtab DCT_B14_10 [] = {
322 { 17, 1,10}, { 6, 2,10}, { 1, 7,10}, { 3, 3,10},
323 { 2, 4,10}, { 16, 1,10}, { 15, 1,10}, { 5, 2,10}
324 };
325
326 static const DCTtab DCT_B14_8 [] = {
327 { 65, 0, 6}, { 65, 0, 6}, { 65, 0, 6}, { 65, 0, 6},
328 { 3, 2, 7}, { 3, 2, 7}, { 10, 1, 7}, { 10, 1, 7},
329 { 1, 4, 7}, { 1, 4, 7}, { 9, 1, 7}, { 9, 1, 7},
330 { 8, 1, 6}, { 8, 1, 6}, { 8, 1, 6}, { 8, 1, 6},
331 { 7, 1, 6}, { 7, 1, 6}, { 7, 1, 6}, { 7, 1, 6},
332 { 2, 2, 6}, { 2, 2, 6}, { 2, 2, 6}, { 2, 2, 6},
333 { 6, 1, 6}, { 6, 1, 6}, { 6, 1, 6}, { 6, 1, 6},
334 { 14, 1, 8}, { 1, 6, 8}, { 13, 1, 8}, { 12, 1, 8},
335 { 4, 2, 8}, { 2, 3, 8}, { 1, 5, 8}, { 11, 1, 8}
336 };
337
338 static const DCTtab DCT_B14AC_5 [] = {
339 { 1, 3, 5}, { 5, 1, 5}, { 4, 1, 5},
340 { 1, 2, 4}, { 1, 2, 4}, { 3, 1, 4}, { 3, 1, 4},
341 { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
342 {129, 0, 2}, {129, 0, 2}, {129, 0, 2}, {129, 0, 2},
343 {129, 0, 2}, {129, 0, 2}, {129, 0, 2}, {129, 0, 2},
344 { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
345 { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}
346 };
347
348 static const DCTtab DCT_B14DC_5 [] = {
349 { 1, 3, 5}, { 5, 1, 5}, { 4, 1, 5},
350 { 1, 2, 4}, { 1, 2, 4}, { 3, 1, 4}, { 3, 1, 4},
351 { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
352 { 1, 1, 1}, { 1, 1, 1}, { 1, 1, 1}, { 1, 1, 1},
353 { 1, 1, 1}, { 1, 1, 1}, { 1, 1, 1}, { 1, 1, 1},
354 { 1, 1, 1}, { 1, 1, 1}, { 1, 1, 1}, { 1, 1, 1},
355 { 1, 1, 1}, { 1, 1, 1}, { 1, 1, 1}, { 1, 1, 1}
356 };
357
358 static const DCTtab DCT_B15_10 [] = {
359 { 6, 2, 9}, { 6, 2, 9}, { 15, 1, 9}, { 15, 1, 9},
360 { 3, 4,10}, { 17, 1,10}, { 16, 1, 9}, { 16, 1, 9}
361 };
362
363 static const DCTtab DCT_B15_8 [] = {
364 { 65, 0, 6}, { 65, 0, 6}, { 65, 0, 6}, { 65, 0, 6},
365 { 8, 1, 7}, { 8, 1, 7}, { 9, 1, 7}, { 9, 1, 7},
366 { 7, 1, 7}, { 7, 1, 7}, { 3, 2, 7}, { 3, 2, 7},
367 { 1, 7, 6}, { 1, 7, 6}, { 1, 7, 6}, { 1, 7, 6},
368 { 1, 6, 6}, { 1, 6, 6}, { 1, 6, 6}, { 1, 6, 6},
369 { 5, 1, 6}, { 5, 1, 6}, { 5, 1, 6}, { 5, 1, 6},
370 { 6, 1, 6}, { 6, 1, 6}, { 6, 1, 6}, { 6, 1, 6},
371 { 2, 5, 8}, { 12, 1, 8}, { 1,11, 8}, { 1,10, 8},
372 { 14, 1, 8}, { 13, 1, 8}, { 4, 2, 8}, { 2, 4, 8},
373 { 3, 1, 5}, { 3, 1, 5}, { 3, 1, 5}, { 3, 1, 5},
374 { 3, 1, 5}, { 3, 1, 5}, { 3, 1, 5}, { 3, 1, 5},
375 { 2, 2, 5}, { 2, 2, 5}, { 2, 2, 5}, { 2, 2, 5},
376 { 2, 2, 5}, { 2, 2, 5}, { 2, 2, 5}, { 2, 2, 5},
377 { 4, 1, 5}, { 4, 1, 5}, { 4, 1, 5}, { 4, 1, 5},
378 { 4, 1, 5}, { 4, 1, 5}, { 4, 1, 5}, { 4, 1, 5},
379 { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
380 { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
381 { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
382 { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
383 { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
384 { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
385 { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
386 { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
387 {129, 0, 4}, {129, 0, 4}, {129, 0, 4}, {129, 0, 4},
388 {129, 0, 4}, {129, 0, 4}, {129, 0, 4}, {129, 0, 4},
389 {129, 0, 4}, {129, 0, 4}, {129, 0, 4}, {129, 0, 4},
390 {129, 0, 4}, {129, 0, 4}, {129, 0, 4}, {129, 0, 4},
391 { 1, 3, 4}, { 1, 3, 4}, { 1, 3, 4}, { 1, 3, 4},
392 { 1, 3, 4}, { 1, 3, 4}, { 1, 3, 4}, { 1, 3, 4},
393 { 1, 3, 4}, { 1, 3, 4}, { 1, 3, 4}, { 1, 3, 4},
394 { 1, 3, 4}, { 1, 3, 4}, { 1, 3, 4}, { 1, 3, 4},
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, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
399 { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
400 { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
401 { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
402 { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
403 { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
404 { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
405 { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
406 { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
407 { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
408 { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
409 { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
410 { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
411 { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3},
412 { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3},
413 { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3},
414 { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3},
415 { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3},
416 { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3},
417 { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3},
418 { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3},
419 { 1, 4, 5}, { 1, 4, 5}, { 1, 4, 5}, { 1, 4, 5},
420 { 1, 4, 5}, { 1, 4, 5}, { 1, 4, 5}, { 1, 4, 5},
421 { 1, 5, 5}, { 1, 5, 5}, { 1, 5, 5}, { 1, 5, 5},
422 { 1, 5, 5}, { 1, 5, 5}, { 1, 5, 5}, { 1, 5, 5},
423 { 10, 1, 7}, { 10, 1, 7}, { 2, 3, 7}, { 2, 3, 7},
424 { 11, 1, 7}, { 11, 1, 7}, { 1, 8, 7}, { 1, 8, 7},
425 { 1, 9, 7}, { 1, 9, 7}, { 1,12, 8}, { 1,13, 8},
426 { 3, 3, 8}, { 5, 2, 8}, { 1,14, 8}, { 1,15, 8}
427 };
428 #endif
429
430 struct MBAtabSet
431 {
432 MBAtab mba5[30];
433 MBAtab mba11[26*4];
434 };
435 static const __aligned16 MBAtabSet MBA = {
436 { // mba5
437 {6, 5}, {5, 5}, {4, 4}, {4, 4}, {3, 4}, {3, 4},
438 {2, 3}, {2, 3}, {2, 3}, {2, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3},
439 {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1},
440 {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}
441 },
442
443 { // mba11
444 {32, 11}, {31, 11}, {30, 11}, {29, 11},
445 {28, 11}, {27, 11}, {26, 11}, {25, 11},
446 {24, 11}, {23, 11}, {22, 11}, {21, 11},
447 {20, 10}, {20, 10}, {19, 10}, {19, 10},
448 {18, 10}, {18, 10}, {17, 10}, {17, 10},
449 {16, 10}, {16, 10}, {15, 10}, {15, 10},
450 {14, 8}, {14, 8}, {14, 8}, {14, 8},
451 {14, 8}, {14, 8}, {14, 8}, {14, 8},
452 {13, 8}, {13, 8}, {13, 8}, {13, 8},
453 {13, 8}, {13, 8}, {13, 8}, {13, 8},
454 {12, 8}, {12, 8}, {12, 8}, {12, 8},
455 {12, 8}, {12, 8}, {12, 8}, {12, 8},
456 {11, 8}, {11, 8}, {11, 8}, {11, 8},
457 {11, 8}, {11, 8}, {11, 8}, {11, 8},
458 {10, 8}, {10, 8}, {10, 8}, {10, 8},
459 {10, 8}, {10, 8}, {10, 8}, {10, 8},
460 { 9, 8}, { 9, 8}, { 9, 8}, { 9, 8},
461 { 9, 8}, { 9, 8}, { 9, 8}, { 9, 8},
462 { 8, 7}, { 8, 7}, { 8, 7}, { 8, 7},
463 { 8, 7}, { 8, 7}, { 8, 7}, { 8, 7},
464 { 8, 7}, { 8, 7}, { 8, 7}, { 8, 7},
465 { 8, 7}, { 8, 7}, { 8, 7}, { 8, 7},
466 { 7, 7}, { 7, 7}, { 7, 7}, { 7, 7},
467 { 7, 7}, { 7, 7}, { 7, 7}, { 7, 7},
468 { 7, 7}, { 7, 7}, { 7, 7}, { 7, 7},
469 { 7, 7}, { 7, 7}, { 7, 7}, { 7, 7}
470 }
471 };
472
473 // New
474
475 #if 0 // Not used by PCSX2
476 /* Table B-1, macroblock_address_increment, codes 00010 ... 011xx */
477 static MBAtab MBAtab1[16] =
478 { {0,0}, {0,0}, {7,5}, {6,5}, {5,4}, {5,4}, {4,4}, {4,4},
479 {3,3}, {3,3}, {3,3}, {3,3}, {2,3}, {2,3}, {2,3}, {2,3}
480 };
481
482 /* Table B-1, macroblock_address_increment, codes 00000011000 ... 0000111xxxx */
483 static MBAtab MBAtab2[104] =
484 {
485 {33,11}, {32,11}, {31,11}, {30,11}, {29,11}, {28,11}, {27,11}, {26,11},
486 {25,11}, {24,11}, {23,11}, {22,11}, {21,10}, {21,10}, {20,10}, {20,10},
487 {19,10}, {19,10}, {18,10}, {18,10}, {17,10}, {17,10}, {16,10}, {16,10},
488 {15,8}, {15,8}, {15,8}, {15,8}, {15,8}, {15,8}, {15,8}, {15,8},
489 {14,8}, {14,8}, {14,8}, {14,8}, {14,8}, {14,8}, {14,8}, {14,8},
490 {13,8}, {13,8}, {13,8}, {13,8}, {13,8}, {13,8}, {13,8}, {13,8},
491 {12,8}, {12,8}, {12,8}, {12,8}, {12,8}, {12,8}, {12,8}, {12,8},
492 {11,8}, {11,8}, {11,8}, {11,8}, {11,8}, {11,8}, {11,8}, {11,8},
493 {10,8}, {10,8}, {10,8}, {10,8}, {10,8}, {10,8}, {10,8}, {10,8},
494 {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, {9,7},
495 {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, {9,7},
496 {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7},
497 {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7}
498 };
499 #endif
500
501 struct DCtabSet
502 {
503 DCtab lum0[32]; // Table B-12, dct_dc_size_luminance, codes 00xxx ... 11110
504 DCtab lum1[16]; // Table B-12, dct_dc_size_luminance, codes 111110xxx ... 111111111
505 DCtab chrom0[32]; // Table B-13, dct_dc_size_chrominance, codes 00xxx ... 11110
506 DCtab chrom1[32]; // Table B-13, dct_dc_size_chrominance, codes 111110xxxx ... 1111111111
507 };
508
509 static const __aligned16 DCtabSet DCtable =
510 {
511 // lum0: Table B-12, dct_dc_size_luminance, codes 00xxx ... 11110 */
512 { {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
513 {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
514 {0, 3}, {0, 3}, {0, 3}, {0, 3}, {3, 3}, {3, 3}, {3, 3}, {3, 3},
515 {4, 3}, {4, 3}, {4, 3}, {4, 3}, {5, 4}, {5, 4}, {6, 5}, {0, 0} },
516
517 /* lum1: Table B-12, dct_dc_size_luminance, codes 111110xxx ... 111111111 */
518 { {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6},
519 {8, 7}, {8, 7}, {8, 7}, {8, 7}, {9, 8}, {9, 8}, {10,9}, {11,9} },
520
521 /* chrom0: Table B-13, dct_dc_size_chrominance, codes 00xxx ... 11110 */
522 { {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2},
523 {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
524 {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
525 {3, 3}, {3, 3}, {3, 3}, {3, 3}, {4, 4}, {4, 4}, {5, 5}, {0, 0} },
526
527 /* chrom1: Table B-13, dct_dc_size_chrominance, codes 111110xxxx ... 1111111111 */
528 { {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6},
529 {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6},
530 {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7},
531 {8, 8}, {8, 8}, {8, 8}, {8, 8}, {9, 9}, {9, 9}, {10,10}, {11,10} },
532 };
533
534 struct DCTtabSet
535 {
536 DCTtab first[12];
537 DCTtab next[12];
538
539 DCTtab tab0[60];
540 DCTtab tab0a[252];
541 DCTtab tab1[8];
542 DCTtab tab1a[8];
543
544 DCTtab tab2[16];
545 DCTtab tab3[16];
546 DCTtab tab4[16];
547 DCTtab tab5[16];
548 DCTtab tab6[16];
549 };
550
551 static const __aligned16 DCTtabSet DCT =
552 {
553 /* first[12]: Table B-14, DCT coefficients table zero,
554 * codes 0100 ... 1xxx (used for first (DC) coefficient)
555 */
556 { {0,2,4}, {2,1,4}, {1,1,3}, {1,1,3},
557 {0,1,1}, {0,1,1}, {0,1,1}, {0,1,1},
558 {0,1,1}, {0,1,1}, {0,1,1}, {0,1,1} },
559
560 /* next[12]: Table B-14, DCT coefficients table zero,
561 * codes 0100 ... 1xxx (used for all other coefficients)
562 */
563 { {0,2,4}, {2,1,4}, {1,1,3}, {1,1,3},
564 {64,0,2}, {64,0,2}, {64,0,2}, {64,0,2}, /* EOB */
565 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2} },
566
567 /* tab0[60]: Table B-14, DCT coefficients table zero,
568 * codes 000001xx ... 00111xxx
569 */
570 { {65,0,6}, {65,0,6}, {65,0,6}, {65,0,6}, /* Escape */
571 {2,2,7}, {2,2,7}, {9,1,7}, {9,1,7},
572 {0,4,7}, {0,4,7}, {8,1,7}, {8,1,7},
573 {7,1,6}, {7,1,6}, {7,1,6}, {7,1,6},
574 {6,1,6}, {6,1,6}, {6,1,6}, {6,1,6},
575 {1,2,6}, {1,2,6}, {1,2,6}, {1,2,6},
576 {5,1,6}, {5,1,6}, {5,1,6}, {5,1,6},
577 {13,1,8}, {0,6,8}, {12,1,8}, {11,1,8},
578 {3,2,8}, {1,3,8}, {0,5,8}, {10,1,8},
579 {0,3,5}, {0,3,5}, {0,3,5}, {0,3,5},
580 {0,3,5}, {0,3,5}, {0,3,5}, {0,3,5},
581 {4,1,5}, {4,1,5}, {4,1,5}, {4,1,5},
582 {4,1,5}, {4,1,5}, {4,1,5}, {4,1,5},
583 {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5},
584 {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5} },
585
586 /* tab0a[252]: Table B-15, DCT coefficients table one,
587 * codes 000001xx ... 11111111
588 */
589 { {65,0,6}, {65,0,6}, {65,0,6}, {65,0,6}, /* Escape */
590 {7,1,7}, {7,1,7}, {8,1,7}, {8,1,7},
591 {6,1,7}, {6,1,7}, {2,2,7}, {2,2,7},
592 {0,7,6}, {0,7,6}, {0,7,6}, {0,7,6},
593 {0,6,6}, {0,6,6}, {0,6,6}, {0,6,6},
594 {4,1,6}, {4,1,6}, {4,1,6}, {4,1,6},
595 {5,1,6}, {5,1,6}, {5,1,6}, {5,1,6},
596 {1,5,8}, {11,1,8}, {0,11,8}, {0,10,8},
597 {13,1,8}, {12,1,8}, {3,2,8}, {1,4,8},
598 {2,1,5}, {2,1,5}, {2,1,5}, {2,1,5},
599 {2,1,5}, {2,1,5}, {2,1,5}, {2,1,5},
600 {1,2,5}, {1,2,5}, {1,2,5}, {1,2,5},
601 {1,2,5}, {1,2,5}, {1,2,5}, {1,2,5},
602 {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5},
603 {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5},
604 {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
605 {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
606 {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
607 {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
608 {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
609 {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
610 {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
611 {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
612 {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4}, /* EOB */
613 {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4},
614 {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4},
615 {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4},
616 {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4},
617 {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4},
618 {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4},
619 {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4},
620 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
621 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
622 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
623 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
624 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
625 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
626 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
627 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
628 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
629 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
630 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
631 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
632 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
633 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
634 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
635 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
636 {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
637 {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
638 {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
639 {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
640 {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
641 {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
642 {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
643 {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
644 {0,4,5}, {0,4,5}, {0,4,5}, {0,4,5},
645 {0,4,5}, {0,4,5}, {0,4,5}, {0,4,5},
646 {0,5,5}, {0,5,5}, {0,5,5}, {0,5,5},
647 {0,5,5}, {0,5,5}, {0,5,5}, {0,5,5},
648 {9,1,7}, {9,1,7}, {1,3,7}, {1,3,7},
649 {10,1,7}, {10,1,7}, {0,8,7}, {0,8,7},
650 {0,9,7}, {0,9,7}, {0,12,8}, {0,13,8},
651 {2,3,8}, {4,2,8}, {0,14,8}, {0,15,8} },
652
653 /* Table B-14, DCT coefficients table zero,
654 * codes 0000001000 ... 0000001111
655 */
656 { {16,1,10}, {5,2,10}, {0,7,10}, {2,3,10},
657 {1,4,10}, {15,1,10}, {14,1,10}, {4,2,10} },
658
659 /* Table B-15, DCT coefficients table one,
660 * codes 000000100x ... 000000111x
661 */
662 { {5,2,9}, {5,2,9}, {14,1,9}, {14,1,9},
663 {2,4,10}, {16,1,10}, {15,1,9}, {15,1,9} },
664
665 /* Table B-14/15, DCT coefficients table zero / one,
666 * codes 000000010000 ... 000000011111
667 */
668 { {0,11,12}, {8,2,12}, {4,3,12}, {0,10,12},
669 {2,4,12}, {7,2,12}, {21,1,12}, {20,1,12},
670 {0,9,12}, {19,1,12}, {18,1,12}, {1,5,12},
671 {3,3,12}, {0,8,12}, {6,2,12}, {17,1,12} },
672
673 /* Table B-14/15, DCT coefficients table zero / one,
674 * codes 0000000010000 ... 0000000011111
675 */
676 { {10,2,13}, {9,2,13}, {5,3,13}, {3,4,13},
677 {2,5,13}, {1,7,13}, {1,6,13}, {0,15,13},
678 {0,14,13}, {0,13,13}, {0,12,13}, {26,1,13},
679 {25,1,13}, {24,1,13}, {23,1,13}, {22,1,13} },
680
681 /* Table B-14/15, DCT coefficients table zero / one,
682 * codes 00000000010000 ... 00000000011111
683 */
684 { {0,31,14}, {0,30,14}, {0,29,14}, {0,28,14},
685 {0,27,14}, {0,26,14}, {0,25,14}, {0,24,14},
686 {0,23,14}, {0,22,14}, {0,21,14}, {0,20,14},
687 {0,19,14}, {0,18,14}, {0,17,14}, {0,16,14} },
688
689 /* Table B-14/15, DCT coefficients table zero / one,
690 * codes 000000000010000 ... 000000000011111
691 */
692 { {0,40,15}, {0,39,15}, {0,38,15}, {0,37,15},
693 {0,36,15}, {0,35,15}, {0,34,15}, {0,33,15},
694 {0,32,15}, {1,14,15}, {1,13,15}, {1,12,15},
695 {1,11,15}, {1,10,15}, {1,9,15}, {1,8,15} },
696
697 /* Table B-14/15, DCT coefficients table zero / one,
698 * codes 0000000000010000 ... 0000000000011111
699 */
700 { {1,18,16}, {1,17,16}, {1,16,16}, {1,15,16},
701 {6,3,16}, {16,2,16}, {15,2,16}, {14,2,16},
702 {13,2,16}, {12,2,16}, {11,2,16}, {31,1,16},
703 {30,1,16}, {29,1,16}, {28,1,16}, {27,1,16} }
704
705 };
706
707 #endif//__VLC_H__

  ViewVC Help
Powered by ViewVC 1.1.22