Subversion Repositories shark

Rev

Rev 1085 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1085 pj 1
/* getvlc.h, variable length code tables                                    */
2
 
3
/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */
4
 
5
/*
6
 * Disclaimer of Warranty
7
 *
8
 * These software programs are available to the user without any license fee or
9
 * royalty on an "as is" basis.  The MPEG Software Simulation Group disclaims
10
 * any and all warranties, whether express, implied, or statuary, including any
11
 * implied warranties or merchantability or of fitness for a particular
12
 * purpose.  In no event shall the copyright-holder be liable for any
13
 * incidental, punitive, or consequential damages of any kind whatsoever
14
 * arising from the use of these programs.
15
 *
16
 * This disclaimer of warranty extends to the user of these programs and user's
17
 * customers, employees, agents, transferees, successors, and assigns.
18
 *
19
 * The MPEG Software Simulation Group does not represent or warrant that the
20
 * programs furnished hereunder are free of infringement of any third-party
21
 * patents.
22
 *
23
 * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware,
24
 * are subject to royalty fees to patent holders.  Many of these patents are
25
 * general enough such that they are unavoidable regardless of implementation
26
 * design.
27
 *
28
 */
29
 
30
/* NOTE: #define constants such as MACROBLOCK_QUANT are upper case
31
   as per C programming convention. However, the MPEG document
32
   (ISO/IEC 13818-2) lists them in all lower case (e.g. Annex B) */
33
 
34
/* NOTE: the VLC tables are in a flash format---a transformation
35
   of the tables in Annex B to a form more convenient towards
36
   parallel (more than one-bit-at-a-time) decoding */
37
 
38
typedef struct {
39
  char val, len;
40
} VLCtab;
41
 
42
typedef struct {
43
  char run, level, len;
44
} DCTtab;
45
 
46
/* Table B-3, macroblock_type in P-pictures, codes 001..1xx */
47
static VLCtab PMBtab0[8] = {
48
  {ERROR,0},
49
  {MACROBLOCK_MOTION_FORWARD,3},
50
  {MACROBLOCK_PATTERN,2}, {MACROBLOCK_PATTERN,2},
51
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,1},
52
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,1},
53
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,1},
54
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,1}
55
};
56
 
57
/* Table B-3, macroblock_type in P-pictures, codes 000001..00011x */
58
static VLCtab PMBtab1[8] = {
59
  {ERROR,0},
60
  {MACROBLOCK_QUANT|MACROBLOCK_INTRA,6},
61
  {MACROBLOCK_QUANT|MACROBLOCK_PATTERN,5}, {MACROBLOCK_QUANT|MACROBLOCK_PATTERN,5},
62
  {MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,5}, {MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,5},
63
  {MACROBLOCK_INTRA,5}, {MACROBLOCK_INTRA,5}
64
};
65
 
66
/* Table B-4, macroblock_type in B-pictures, codes 0010..11xx */
67
static VLCtab BMBtab0[16] = {
68
  {ERROR,0},
69
  {ERROR,0},
70
  {MACROBLOCK_MOTION_FORWARD,4},
71
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,4},
72
  {MACROBLOCK_MOTION_BACKWARD,3},
73
  {MACROBLOCK_MOTION_BACKWARD,3},
74
  {MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,3},
75
  {MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,3},
76
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD,2},
77
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD,2},
78
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD,2},
79
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD,2},
80
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,2},
81
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,2},
82
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,2},
83
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,2}
84
};
85
 
86
/* Table B-4, macroblock_type in B-pictures, codes 000001..00011x */
87
static VLCtab BMBtab1[8] = {
88
  {ERROR,0},
89
  {MACROBLOCK_QUANT|MACROBLOCK_INTRA,6},
90
  {MACROBLOCK_QUANT|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,6},
91
  {MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,6},
92
  {MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,5},
93
  {MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,5},
94
  {MACROBLOCK_INTRA,5},
95
  {MACROBLOCK_INTRA,5}
96
};
97
 
98
/* Table B-5, macroblock_type in spat. scal. I-pictures, codes 0001..1xxx */
99
static VLCtab spIMBtab[16] = {
100
  {ERROR,0},
101
  {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS,4},
102
  {MACROBLOCK_QUANT|MACROBLOCK_INTRA,4},
103
  {MACROBLOCK_INTRA,4},
104
  {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_QUANT|MACROBLOCK_PATTERN,2}, {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_QUANT|MACROBLOCK_PATTERN,2},
105
  {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_QUANT|MACROBLOCK_PATTERN,2}, {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_QUANT|MACROBLOCK_PATTERN,2},
106
  {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_PATTERN,1}, {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_PATTERN,1},
107
  {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_PATTERN,1}, {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_PATTERN,1},
108
  {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_PATTERN,1}, {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_PATTERN,1},
109
  {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_PATTERN,1}, {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_PATTERN,1}
110
};
111
 
112
/* Table B-6, macroblock_type in spat. scal. P-pictures, codes 0010..11xx */
113
static VLCtab spPMBtab0[16] =
114
{
115
  {ERROR,0},
116
  {ERROR,0},
117
  {MACROBLOCK_MOTION_FORWARD,4},
118
  {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_MOTION_FORWARD,4},
119
  {MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,3}, {MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,3},
120
  {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,3}, {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,3},
121
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,2},
122
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,2},
123
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,2},
124
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,2},
125
  {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,2},
126
  {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,2},
127
  {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,2},
128
  {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,2}
129
};
130
 
131
/* Table B-6, macroblock_type in spat. scal. P-pictures, codes 0000010..000111x */
132
static VLCtab spPMBtab1[16] = {
133
  {ERROR,0},
134
  {ERROR,0},
135
  {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_QUANT|MACROBLOCK_PATTERN,7},
136
  {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS,7},
137
  {MACROBLOCK_PATTERN,7},
138
  {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_PATTERN,7},
139
  {MACROBLOCK_QUANT|MACROBLOCK_INTRA,7},
140
  {MACROBLOCK_INTRA,7},
141
  {MACROBLOCK_QUANT|MACROBLOCK_PATTERN,6},
142
  {MACROBLOCK_QUANT|MACROBLOCK_PATTERN,6},
143
  {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_QUANT|MACROBLOCK_PATTERN,6},
144
  {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_QUANT|MACROBLOCK_PATTERN,6},
145
  {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG,6},
146
  {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG,6},
147
  {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_PATTERN,6},
148
  {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_PATTERN,6}
149
};
150
 
151
/* Table B-7, macroblock_type in spat. scal. B-pictures, codes 0010..11xx */
152
static VLCtab spBMBtab0[14] = {
153
  {MACROBLOCK_MOTION_FORWARD,4},
154
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,4},
155
  {MACROBLOCK_MOTION_BACKWARD,3},
156
  {MACROBLOCK_MOTION_BACKWARD,3},
157
  {MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,3},
158
  {MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,3},
159
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD,2},
160
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD,2},
161
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD,2},
162
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD,2},
163
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,2},
164
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,2},
165
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,2},
166
  {MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,2}
167
};
168
 
169
/* Table B-7, macroblock_type in spat. scal. B-pictures, codes 0000100..000111x */
170
static VLCtab spBMBtab1[12] = {
171
  {MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,7},
172
  {MACROBLOCK_QUANT|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,7},
173
  {MACROBLOCK_INTRA,7},
174
  {MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,7},
175
  {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_MOTION_FORWARD,6},
176
  {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_MOTION_FORWARD,6},
177
  {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,6},
178
  {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,6},
179
  {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_MOTION_BACKWARD,6},
180
  {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_MOTION_BACKWARD,6},
181
  {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,6},
182
  {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,6}
183
};
184
 
185
/* Table B-7, macroblock_type in spat. scal. B-pictures, codes 00000100x..000001111 */
186
static VLCtab spBMBtab2[8] = {
187
  {MACROBLOCK_QUANT|MACROBLOCK_INTRA,8},
188
  {MACROBLOCK_QUANT|MACROBLOCK_INTRA,8},
189
  {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,8},
190
  {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_QUANT|MACROBLOCK_MOTION_FORWARD|MACROBLOCK_PATTERN,8},
191
  {SPATIAL_TEMPORAL_WEIGHT_CODE_FLAG|MACROBLOCK_QUANT|MACROBLOCK_MOTION_BACKWARD|MACROBLOCK_PATTERN,9},
192
  {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_QUANT|MACROBLOCK_PATTERN,9},
193
  {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS,9},
194
  {PERMITTED_SPATIAL_TEMPORAL_WEIGHT_CLASS|MACROBLOCK_PATTERN,9}
195
};
196
 
197
/* Table B-8, macroblock_type in spat. scal. B-pictures, codes 001..1xx */
198
static VLCtab SNRMBtab[8] = {
199
  {ERROR,0},
200
  {0,3},
201
  {MACROBLOCK_QUANT|MACROBLOCK_PATTERN,2},
202
  {MACROBLOCK_QUANT|MACROBLOCK_PATTERN,2},
203
  {MACROBLOCK_PATTERN,1},
204
  {MACROBLOCK_PATTERN,1},
205
  {MACROBLOCK_PATTERN,1},
206
  {MACROBLOCK_PATTERN,1}
207
};
208
 
209
/* Table B-10, motion_code, codes 0001 ... 01xx */
210
static VLCtab MVtab0[8] =
211
{ {ERROR,0}, {3,3}, {2,2}, {2,2}, {1,1}, {1,1}, {1,1}, {1,1}
212
};
213
 
214
/* Table B-10, motion_code, codes 0000011 ... 000011x */
215
static VLCtab MVtab1[8] =
216
{ {ERROR,0}, {ERROR,0}, {ERROR,0}, {7,6}, {6,6}, {5,6}, {4,5}, {4,5}
217
};
218
 
219
/* Table B-10, motion_code, codes 0000001100 ... 000001011x */
220
static VLCtab MVtab2[12] =
221
{ {16,9}, {15,9}, {14,9}, {13,9},
222
  {12,9}, {11,9}, {10,8}, {10,8},
223
  {9,8},  {9,8},  {8,8},  {8,8}
224
};
225
 
226
/* Table B-9, coded_block_pattern, codes 01000 ... 111xx */
227
static VLCtab CBPtab0[32] =
228
{ {ERROR,0}, {ERROR,0}, {ERROR,0}, {ERROR,0},
229
  {ERROR,0}, {ERROR,0}, {ERROR,0}, {ERROR,0},
230
  {62,5}, {2,5},  {61,5}, {1,5},  {56,5}, {52,5}, {44,5}, {28,5},
231
  {40,5}, {20,5}, {48,5}, {12,5}, {32,4}, {32,4}, {16,4}, {16,4},
232
  {8,4},  {8,4},  {4,4},  {4,4},  {60,3}, {60,3}, {60,3}, {60,3}
233
};
234
 
235
/* Table B-9, coded_block_pattern, codes 00000100 ... 001111xx */
236
static VLCtab CBPtab1[64] =
237
{ {ERROR,0}, {ERROR,0}, {ERROR,0}, {ERROR,0},
238
  {58,8}, {54,8}, {46,8}, {30,8},
239
  {57,8}, {53,8}, {45,8}, {29,8}, {38,8}, {26,8}, {37,8}, {25,8},
240
  {43,8}, {23,8}, {51,8}, {15,8}, {42,8}, {22,8}, {50,8}, {14,8},
241
  {41,8}, {21,8}, {49,8}, {13,8}, {35,8}, {19,8}, {11,8}, {7,8},
242
  {34,7}, {34,7}, {18,7}, {18,7}, {10,7}, {10,7}, {6,7},  {6,7},
243
  {33,7}, {33,7}, {17,7}, {17,7}, {9,7},  {9,7},  {5,7},  {5,7},
244
  {63,6}, {63,6}, {63,6}, {63,6}, {3,6},  {3,6},  {3,6},  {3,6},
245
  {36,6}, {36,6}, {36,6}, {36,6}, {24,6}, {24,6}, {24,6}, {24,6}
246
};
247
 
248
/* Table B-9, coded_block_pattern, codes 000000001 ... 000000111 */
249
static VLCtab CBPtab2[8] =
250
{ {ERROR,0}, {0,9}, {39,9}, {27,9}, {59,9}, {55,9}, {47,9}, {31,9}
251
};
252
 
253
/* Table B-1, macroblock_address_increment, codes 00010 ... 011xx */
254
static VLCtab MBAtab1[16] =
255
{ {ERROR,0}, {ERROR,0}, {7,5}, {6,5}, {5,4}, {5,4}, {4,4}, {4,4},
256
  {3,3}, {3,3}, {3,3}, {3,3}, {2,3}, {2,3}, {2,3}, {2,3}
257
};
258
 
259
/* Table B-1, macroblock_address_increment, codes 00000011000 ... 0000111xxxx */
260
static VLCtab MBAtab2[104] =
261
{
262
  {33,11}, {32,11}, {31,11}, {30,11}, {29,11}, {28,11}, {27,11}, {26,11},
263
  {25,11}, {24,11}, {23,11}, {22,11}, {21,10}, {21,10}, {20,10}, {20,10},
264
  {19,10}, {19,10}, {18,10}, {18,10}, {17,10}, {17,10}, {16,10}, {16,10},
265
  {15,8},  {15,8},  {15,8},  {15,8},  {15,8},  {15,8},  {15,8},  {15,8},
266
  {14,8},  {14,8},  {14,8},  {14,8},  {14,8},  {14,8},  {14,8},  {14,8},
267
  {13,8},  {13,8},  {13,8},  {13,8},  {13,8},  {13,8},  {13,8},  {13,8},
268
  {12,8},  {12,8},  {12,8},  {12,8},  {12,8},  {12,8},  {12,8},  {12,8},
269
  {11,8},  {11,8},  {11,8},  {11,8},  {11,8},  {11,8},  {11,8},  {11,8},
270
  {10,8},  {10,8},  {10,8},  {10,8},  {10,8},  {10,8},  {10,8},  {10,8},
271
  {9,7},   {9,7},   {9,7},   {9,7},   {9,7},   {9,7},   {9,7},   {9,7},
272
  {9,7},   {9,7},   {9,7},   {9,7},   {9,7},   {9,7},   {9,7},   {9,7},
273
  {8,7},   {8,7},   {8,7},   {8,7},   {8,7},   {8,7},   {8,7},   {8,7},
274
  {8,7},   {8,7},   {8,7},   {8,7},   {8,7},   {8,7},   {8,7},   {8,7}
275
};
276
 
277
/* Table B-12, dct_dc_size_luminance, codes 00xxx ... 11110 */
278
static VLCtab DClumtab0[32] =
279
{ {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
280
  {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
281
  {0, 3}, {0, 3}, {0, 3}, {0, 3}, {3, 3}, {3, 3}, {3, 3}, {3, 3},
282
  {4, 3}, {4, 3}, {4, 3}, {4, 3}, {5, 4}, {5, 4}, {6, 5}, {ERROR, 0}
283
};
284
 
285
/* Table B-12, dct_dc_size_luminance, codes 111110xxx ... 111111111 */
286
static VLCtab DClumtab1[16] =
287
{ {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6},
288
  {8, 7}, {8, 7}, {8, 7}, {8, 7}, {9, 8}, {9, 8}, {10,9}, {11,9}
289
};
290
 
291
/* Table B-13, dct_dc_size_chrominance, codes 00xxx ... 11110 */
292
static VLCtab DCchromtab0[32] =
293
{ {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2},
294
  {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
295
  {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
296
  {3, 3}, {3, 3}, {3, 3}, {3, 3}, {4, 4}, {4, 4}, {5, 5}, {ERROR, 0}
297
};
298
 
299
/* Table B-13, dct_dc_size_chrominance, codes 111110xxxx ... 1111111111 */
300
static VLCtab DCchromtab1[32] =
301
{ {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6},
302
  {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6},
303
  {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7},
304
  {8, 8}, {8, 8}, {8, 8}, {8, 8}, {9, 9}, {9, 9}, {10,10}, {11,10}
305
};
306
 
307
/* Table B-14, DCT coefficients table zero,
308
 * codes 0100 ... 1xxx (used for first (DC) coefficient)
309
 */
310
DCTtab DCTtabfirst[12] =
311
{
312
  {0,2,4}, {2,1,4}, {1,1,3}, {1,1,3},
313
  {0,1,1}, {0,1,1}, {0,1,1}, {0,1,1},
314
  {0,1,1}, {0,1,1}, {0,1,1}, {0,1,1}
315
};
316
 
317
/* Table B-14, DCT coefficients table zero,
318
 * codes 0100 ... 1xxx (used for all other coefficients)
319
 */
320
DCTtab DCTtabnext[12] =
321
{
322
  {0,2,4},  {2,1,4},  {1,1,3},  {1,1,3},
323
  {64,0,2}, {64,0,2}, {64,0,2}, {64,0,2}, /* EOB */
324
  {0,1,2},  {0,1,2},  {0,1,2},  {0,1,2}
325
};
326
 
327
/* Table B-14, DCT coefficients table zero,
328
 * codes 000001xx ... 00111xxx
329
 */
330
DCTtab DCTtab0[60] =
331
{
332
  {65,0,6}, {65,0,6}, {65,0,6}, {65,0,6}, /* Escape */
333
  {2,2,7}, {2,2,7}, {9,1,7}, {9,1,7},
334
  {0,4,7}, {0,4,7}, {8,1,7}, {8,1,7},
335
  {7,1,6}, {7,1,6}, {7,1,6}, {7,1,6},
336
  {6,1,6}, {6,1,6}, {6,1,6}, {6,1,6},
337
  {1,2,6}, {1,2,6}, {1,2,6}, {1,2,6},
338
  {5,1,6}, {5,1,6}, {5,1,6}, {5,1,6},
339
  {13,1,8}, {0,6,8}, {12,1,8}, {11,1,8},
340
  {3,2,8}, {1,3,8}, {0,5,8}, {10,1,8},
341
  {0,3,5}, {0,3,5}, {0,3,5}, {0,3,5},
342
  {0,3,5}, {0,3,5}, {0,3,5}, {0,3,5},
343
  {4,1,5}, {4,1,5}, {4,1,5}, {4,1,5},
344
  {4,1,5}, {4,1,5}, {4,1,5}, {4,1,5},
345
  {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5},
346
  {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5}
347
};
348
 
349
/* Table B-15, DCT coefficients table one,
350
 * codes 000001xx ... 11111111
351
*/
352
DCTtab DCTtab0a[252] =
353
{
354
  {65,0,6}, {65,0,6}, {65,0,6}, {65,0,6}, /* Escape */
355
  {7,1,7}, {7,1,7}, {8,1,7}, {8,1,7},
356
  {6,1,7}, {6,1,7}, {2,2,7}, {2,2,7},
357
  {0,7,6}, {0,7,6}, {0,7,6}, {0,7,6},
358
  {0,6,6}, {0,6,6}, {0,6,6}, {0,6,6},
359
  {4,1,6}, {4,1,6}, {4,1,6}, {4,1,6},
360
  {5,1,6}, {5,1,6}, {5,1,6}, {5,1,6},
361
  {1,5,8}, {11,1,8}, {0,11,8}, {0,10,8},
362
  {13,1,8}, {12,1,8}, {3,2,8}, {1,4,8},
363
  {2,1,5}, {2,1,5}, {2,1,5}, {2,1,5},
364
  {2,1,5}, {2,1,5}, {2,1,5}, {2,1,5},
365
  {1,2,5}, {1,2,5}, {1,2,5}, {1,2,5},
366
  {1,2,5}, {1,2,5}, {1,2,5}, {1,2,5},
367
  {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5},
368
  {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5},
369
  {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
370
  {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
371
  {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
372
  {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
373
  {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
374
  {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
375
  {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
376
  {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
377
  {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4}, /* EOB */
378
  {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4},
379
  {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4},
380
  {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4},
381
  {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4},
382
  {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4},
383
  {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4},
384
  {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4},
385
  {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
386
  {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
387
  {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
388
  {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
389
  {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
390
  {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
391
  {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
392
  {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
393
  {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
394
  {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
395
  {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
396
  {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
397
  {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
398
  {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
399
  {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
400
  {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
401
  {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
402
  {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
403
  {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
404
  {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
405
  {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
406
  {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
407
  {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
408
  {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
409
  {0,4,5}, {0,4,5}, {0,4,5}, {0,4,5},
410
  {0,4,5}, {0,4,5}, {0,4,5}, {0,4,5},
411
  {0,5,5}, {0,5,5}, {0,5,5}, {0,5,5},
412
  {0,5,5}, {0,5,5}, {0,5,5}, {0,5,5},
413
  {9,1,7}, {9,1,7}, {1,3,7}, {1,3,7},
414
  {10,1,7}, {10,1,7}, {0,8,7}, {0,8,7},
415
  {0,9,7}, {0,9,7}, {0,12,8}, {0,13,8},
416
  {2,3,8}, {4,2,8}, {0,14,8}, {0,15,8}
417
};
418
 
419
/* Table B-14, DCT coefficients table zero,
420
 * codes 0000001000 ... 0000001111
421
 */
422
DCTtab DCTtab1[8] =
423
{
424
  {16,1,10}, {5,2,10}, {0,7,10}, {2,3,10},
425
  {1,4,10}, {15,1,10}, {14,1,10}, {4,2,10}
426
};
427
 
428
/* Table B-15, DCT coefficients table one,
429
 * codes 000000100x ... 000000111x
430
 */
431
DCTtab DCTtab1a[8] =
432
{
433
  {5,2,9}, {5,2,9}, {14,1,9}, {14,1,9},
434
  {2,4,10}, {16,1,10}, {15,1,9}, {15,1,9}
435
};
436
 
437
/* Table B-14/15, DCT coefficients table zero / one,
438
 * codes 000000010000 ... 000000011111
439
 */
440
DCTtab DCTtab2[16] =
441
{
442
  {0,11,12}, {8,2,12}, {4,3,12}, {0,10,12},
443
  {2,4,12}, {7,2,12}, {21,1,12}, {20,1,12},
444
  {0,9,12}, {19,1,12}, {18,1,12}, {1,5,12},
445
  {3,3,12}, {0,8,12}, {6,2,12}, {17,1,12}
446
};
447
 
448
/* Table B-14/15, DCT coefficients table zero / one,
449
 * codes 0000000010000 ... 0000000011111
450
 */
451
DCTtab DCTtab3[16] =
452
{
453
  {10,2,13}, {9,2,13}, {5,3,13}, {3,4,13},
454
  {2,5,13}, {1,7,13}, {1,6,13}, {0,15,13},
455
  {0,14,13}, {0,13,13}, {0,12,13}, {26,1,13},
456
  {25,1,13}, {24,1,13}, {23,1,13}, {22,1,13}
457
};
458
 
459
/* Table B-14/15, DCT coefficients table zero / one,
460
 * codes 00000000010000 ... 00000000011111
461
 */
462
DCTtab DCTtab4[16] =
463
{
464
  {0,31,14}, {0,30,14}, {0,29,14}, {0,28,14},
465
  {0,27,14}, {0,26,14}, {0,25,14}, {0,24,14},
466
  {0,23,14}, {0,22,14}, {0,21,14}, {0,20,14},
467
  {0,19,14}, {0,18,14}, {0,17,14}, {0,16,14}
468
};
469
 
470
/* Table B-14/15, DCT coefficients table zero / one,
471
 * codes 000000000010000 ... 000000000011111
472
 */
473
DCTtab DCTtab5[16] =
474
{
475
  {0,40,15}, {0,39,15}, {0,38,15}, {0,37,15},
476
  {0,36,15}, {0,35,15}, {0,34,15}, {0,33,15},
477
  {0,32,15}, {1,14,15}, {1,13,15}, {1,12,15},
478
  {1,11,15}, {1,10,15}, {1,9,15}, {1,8,15}
479
};
480
 
481
/* Table B-14/15, DCT coefficients table zero / one,
482
 * codes 0000000000010000 ... 0000000000011111
483
 */
484
DCTtab DCTtab6[16] =
485
{
486
  {1,18,16}, {1,17,16}, {1,16,16}, {1,15,16},
487
  {6,3,16}, {16,2,16}, {15,2,16}, {14,2,16},
488
  {13,2,16}, {12,2,16}, {11,2,16}, {31,1,16},
489
  {30,1,16}, {29,1,16}, {28,1,16}, {27,1,16}
490
};
491