Subversion Repositories shark

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
/*
2
 * decoders.c
3
 *
4
 * This file contains all the routines for Huffman decoding required in
5
 * MPEG
6
 *
7
 */
8
 
9
/*
10
 * Copyright (c) 1995 The Regents of the University of California.
11
 * All rights reserved.
12
 *
13
 * Permission to use, copy, modify, and distribute this software and its
14
 * documentation for any purpose, without fee, and without written agreement is
15
 * hereby granted, provided that the above copyright notice and the following
16
 * two paragraphs appear in all copies of this software.
17
 *
18
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
19
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
20
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
21
 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
 *
23
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
24
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
26
 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
27
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
28
 */
29
 
30
/*
31
 * Portions of this software Copyright (c) 1995 Brown University.
32
 * All rights reserved.
33
 *
34
 * Permission to use, copy, modify, and distribute this software and its
35
 * documentation for any purpose, without fee, and without written agreement
36
 * is hereby granted, provided that the above copyright notice and the
37
 * following two paragraphs appear in all copies of this software.
38
 *
39
 * IN NO EVENT SHALL BROWN UNIVERSITY BE LIABLE TO ANY PARTY FOR
40
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
41
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF BROWN
42
 * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43
 *
44
 * BROWN UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
45
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
46
 * PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
47
 * BASIS, AND BROWN UNIVERSITY HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
48
 * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
49
 */
50
 
51
#include <stdio.h>
52
#include <assert.h>
53
#include "decoders.h"
54
#include "util.h" 
55
#include "video.h"
56
#include "proto.h"
57
 
58
/*
59
   Changes to make the code reentrant:
60
     curVidStream now not global - DecodeDCT* functioned #ifdef'd out
61
       (are they needed?)
62
   Additional changes:
63
     none
64
   -lsh@cs.brown.edu (Loring Holden)
65
 */
66
 
67
/* Decoding table for macroblock_address_increment */
68
mb_addr_inc_entry     mb_addr_inc[2048];
69
 
70
/* Decoding table for macroblock_type in predictive-coded pictures */
71
mb_type_entry         mb_type_P[64];
72
 
73
/* Decoding table for macroblock_type in bidirectionally-coded pictures */
74
mb_type_entry         mb_type_B[64];
75
 
76
/* Decoding table for motion vectors */
77
motion_vectors_entry  motion_vectors[2048];
78
 
79
/* Decoding table for coded_block_pattern */
80
 
81
coded_block_pattern_entry coded_block_pattern[512] =
82
{ {(unsigned int)ERROR, 0}, {(unsigned int)ERROR, 0}, {39, 9}, {27, 9}, {59, 9}, {55, 9}, {47, 9}, {31, 9},
83
    {58, 8}, {58, 8}, {54, 8}, {54, 8}, {46, 8}, {46, 8}, {30, 8}, {30, 8},
84
    {57, 8}, {57, 8}, {53, 8}, {53, 8}, {45, 8}, {45, 8}, {29, 8}, {29, 8},
85
    {38, 8}, {38, 8}, {26, 8}, {26, 8}, {37, 8}, {37, 8}, {25, 8}, {25, 8},
86
    {43, 8}, {43, 8}, {23, 8}, {23, 8}, {51, 8}, {51, 8}, {15, 8}, {15, 8},
87
    {42, 8}, {42, 8}, {22, 8}, {22, 8}, {50, 8}, {50, 8}, {14, 8}, {14, 8},
88
    {41, 8}, {41, 8}, {21, 8}, {21, 8}, {49, 8}, {49, 8}, {13, 8}, {13, 8},
89
    {35, 8}, {35, 8}, {19, 8}, {19, 8}, {11, 8}, {11, 8}, {7, 8}, {7, 8},
90
    {34, 7}, {34, 7}, {34, 7}, {34, 7}, {18, 7}, {18, 7}, {18, 7}, {18, 7},
91
    {10, 7}, {10, 7}, {10, 7}, {10, 7}, {6, 7}, {6, 7}, {6, 7}, {6, 7},
92
    {33, 7}, {33, 7}, {33, 7}, {33, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
93
    {9, 7}, {9, 7}, {9, 7}, {9, 7}, {5, 7}, {5, 7}, {5, 7}, {5, 7},
94
    {63, 6}, {63, 6}, {63, 6}, {63, 6}, {63, 6}, {63, 6}, {63, 6}, {63, 6},
95
    {3, 6}, {3, 6}, {3, 6}, {3, 6}, {3, 6}, {3, 6}, {3, 6}, {3, 6},
96
    {36, 6}, {36, 6}, {36, 6}, {36, 6}, {36, 6}, {36, 6}, {36, 6}, {36, 6},
97
    {24, 6}, {24, 6}, {24, 6}, {24, 6}, {24, 6}, {24, 6}, {24, 6}, {24, 6},
98
    {62, 5}, {62, 5}, {62, 5}, {62, 5}, {62, 5}, {62, 5}, {62, 5}, {62, 5},
99
    {62, 5}, {62, 5}, {62, 5}, {62, 5}, {62, 5}, {62, 5}, {62, 5}, {62, 5},
100
    {2, 5}, {2, 5}, {2, 5}, {2, 5}, {2, 5}, {2, 5}, {2, 5}, {2, 5},
101
    {2, 5}, {2, 5}, {2, 5}, {2, 5}, {2, 5}, {2, 5}, {2, 5}, {2, 5},
102
    {61, 5}, {61, 5}, {61, 5}, {61, 5}, {61, 5}, {61, 5}, {61, 5}, {61, 5},
103
    {61, 5}, {61, 5}, {61, 5}, {61, 5}, {61, 5}, {61, 5}, {61, 5}, {61, 5},
104
    {1, 5}, {1, 5}, {1, 5}, {1, 5}, {1, 5}, {1, 5}, {1, 5}, {1, 5},
105
    {1, 5}, {1, 5}, {1, 5}, {1, 5}, {1, 5}, {1, 5}, {1, 5}, {1, 5},
106
    {56, 5}, {56, 5}, {56, 5}, {56, 5}, {56, 5}, {56, 5}, {56, 5}, {56, 5},
107
    {56, 5}, {56, 5}, {56, 5}, {56, 5}, {56, 5}, {56, 5}, {56, 5}, {56, 5},
108
    {52, 5}, {52, 5}, {52, 5}, {52, 5}, {52, 5}, {52, 5}, {52, 5}, {52, 5},
109
    {52, 5}, {52, 5}, {52, 5}, {52, 5}, {52, 5}, {52, 5}, {52, 5}, {52, 5},
110
    {44, 5}, {44, 5}, {44, 5}, {44, 5}, {44, 5}, {44, 5}, {44, 5}, {44, 5},
111
    {44, 5}, {44, 5}, {44, 5}, {44, 5}, {44, 5}, {44, 5}, {44, 5}, {44, 5},
112
    {28, 5}, {28, 5}, {28, 5}, {28, 5}, {28, 5}, {28, 5}, {28, 5}, {28, 5},
113
    {28, 5}, {28, 5}, {28, 5}, {28, 5}, {28, 5}, {28, 5}, {28, 5}, {28, 5},
114
    {40, 5}, {40, 5}, {40, 5}, {40, 5}, {40, 5}, {40, 5}, {40, 5}, {40, 5},
115
    {40, 5}, {40, 5}, {40, 5}, {40, 5}, {40, 5}, {40, 5}, {40, 5}, {40, 5},
116
    {20, 5}, {20, 5}, {20, 5}, {20, 5}, {20, 5}, {20, 5}, {20, 5}, {20, 5},
117
    {20, 5}, {20, 5}, {20, 5}, {20, 5}, {20, 5}, {20, 5}, {20, 5}, {20, 5},
118
    {48, 5}, {48, 5}, {48, 5}, {48, 5}, {48, 5}, {48, 5}, {48, 5}, {48, 5},
119
    {48, 5}, {48, 5}, {48, 5}, {48, 5}, {48, 5}, {48, 5}, {48, 5}, {48, 5},
120
    {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5},
121
    {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5},
122
    {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4},
123
    {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4},
124
    {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4},
125
    {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4},
126
    {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4},
127
    {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4},
128
    {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4},
129
    {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4},
130
    {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4},
131
    {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4},
132
    {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4},
133
    {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4},
134
    {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4},
135
    {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4},
136
    {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4},
137
    {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4},
138
    {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3},
139
    {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3},
140
    {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3},
141
    {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3},
142
    {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3},
143
    {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3},
144
    {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3},
145
    {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}
146
};
147
 
148
/* Decoding tables for dct_dc_size_luminance */
149
dct_dc_size_entry dct_dc_size_luminance[32] =
150
{   {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
151
    {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
152
    {0, 3}, {0, 3}, {0, 3}, {0, 3}, {3, 3}, {3, 3}, {3, 3}, {3, 3},
153
    {4, 3}, {4, 3}, {4, 3}, {4, 3}, {5, 4}, {5, 4}, {6, 5}, {(unsigned int)ERROR, 0}
154
};
155
 
156
dct_dc_size_entry dct_dc_size_luminance1[16] =
157
{   {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6},
158
    {8, 7}, {8, 7}, {8, 7}, {8, 7}, {9, 8}, {9, 8}, {10, 9}, {11, 9}
159
};
160
 
161
/* Decoding table for dct_dc_size_chrominance */
162
dct_dc_size_entry dct_dc_size_chrominance[32] =
163
{   {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2},
164
    {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
165
    {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
166
    {3, 3}, {3, 3}, {3, 3}, {3, 3}, {4, 4}, {4, 4}, {5, 5}, {(unsigned int)ERROR, 0}
167
};
168
 
169
dct_dc_size_entry dct_dc_size_chrominance1[32] =
170
{   {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6},
171
    {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6},
172
    {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7},
173
    {8, 8}, {8, 8}, {8, 8}, {8, 8}, {9, 9}, {9, 9}, {10, 10}, {11, 10}
174
};
175
 
176
/* DCT coeff tables. */
177
 
178
unsigned short int dct_coeff_tbl_0[256] =
179
{
180
0xffff, 0xffff, 0xffff, 0xffff,
181
0xffff, 0xffff, 0xffff, 0xffff,
182
0xffff, 0xffff, 0xffff, 0xffff,
183
0xffff, 0xffff, 0xffff, 0xffff,
184
0x052f, 0x051f, 0x050f, 0x04ff,
185
0x183f, 0x402f, 0x3c2f, 0x382f,
186
0x342f, 0x302f, 0x2c2f, 0x7c1f,
187
0x781f, 0x741f, 0x701f, 0x6c1f,
188
0x028e, 0x028e, 0x027e, 0x027e,
189
0x026e, 0x026e, 0x025e, 0x025e,
190
0x024e, 0x024e, 0x023e, 0x023e,
191
0x022e, 0x022e, 0x021e, 0x021e,
192
0x020e, 0x020e, 0x04ee, 0x04ee,
193
0x04de, 0x04de, 0x04ce, 0x04ce,
194
0x04be, 0x04be, 0x04ae, 0x04ae,
195
0x049e, 0x049e, 0x048e, 0x048e,
196
0x01fd, 0x01fd, 0x01fd, 0x01fd,
197
0x01ed, 0x01ed, 0x01ed, 0x01ed,
198
0x01dd, 0x01dd, 0x01dd, 0x01dd,
199
0x01cd, 0x01cd, 0x01cd, 0x01cd,
200
0x01bd, 0x01bd, 0x01bd, 0x01bd,
201
0x01ad, 0x01ad, 0x01ad, 0x01ad,
202
0x019d, 0x019d, 0x019d, 0x019d,
203
0x018d, 0x018d, 0x018d, 0x018d,
204
0x017d, 0x017d, 0x017d, 0x017d,
205
0x016d, 0x016d, 0x016d, 0x016d,
206
0x015d, 0x015d, 0x015d, 0x015d,
207
0x014d, 0x014d, 0x014d, 0x014d,
208
0x013d, 0x013d, 0x013d, 0x013d,
209
0x012d, 0x012d, 0x012d, 0x012d,
210
0x011d, 0x011d, 0x011d, 0x011d,
211
0x010d, 0x010d, 0x010d, 0x010d,
212
0x282c, 0x282c, 0x282c, 0x282c,
213
0x282c, 0x282c, 0x282c, 0x282c,
214
0x242c, 0x242c, 0x242c, 0x242c,
215
0x242c, 0x242c, 0x242c, 0x242c,
216
0x143c, 0x143c, 0x143c, 0x143c,
217
0x143c, 0x143c, 0x143c, 0x143c,
218
0x0c4c, 0x0c4c, 0x0c4c, 0x0c4c,
219
0x0c4c, 0x0c4c, 0x0c4c, 0x0c4c,
220
0x085c, 0x085c, 0x085c, 0x085c,
221
0x085c, 0x085c, 0x085c, 0x085c,
222
0x047c, 0x047c, 0x047c, 0x047c,
223
0x047c, 0x047c, 0x047c, 0x047c,
224
0x046c, 0x046c, 0x046c, 0x046c,
225
0x046c, 0x046c, 0x046c, 0x046c,
226
0x00fc, 0x00fc, 0x00fc, 0x00fc,
227
0x00fc, 0x00fc, 0x00fc, 0x00fc,
228
0x00ec, 0x00ec, 0x00ec, 0x00ec,
229
0x00ec, 0x00ec, 0x00ec, 0x00ec,
230
0x00dc, 0x00dc, 0x00dc, 0x00dc,
231
0x00dc, 0x00dc, 0x00dc, 0x00dc,
232
0x00cc, 0x00cc, 0x00cc, 0x00cc,
233
0x00cc, 0x00cc, 0x00cc, 0x00cc,
234
0x681c, 0x681c, 0x681c, 0x681c,
235
0x681c, 0x681c, 0x681c, 0x681c,
236
0x641c, 0x641c, 0x641c, 0x641c,
237
0x641c, 0x641c, 0x641c, 0x641c,
238
0x601c, 0x601c, 0x601c, 0x601c,
239
0x601c, 0x601c, 0x601c, 0x601c,
240
0x5c1c, 0x5c1c, 0x5c1c, 0x5c1c,
241
0x5c1c, 0x5c1c, 0x5c1c, 0x5c1c,
242
0x581c, 0x581c, 0x581c, 0x581c,
243
0x581c, 0x581c, 0x581c, 0x581c,
244
};
245
 
246
unsigned short int dct_coeff_tbl_1[16] =
247
{
248
0x00bb, 0x202b, 0x103b, 0x00ab,
249
0x084b, 0x1c2b, 0x541b, 0x501b,
250
0x009b, 0x4c1b, 0x481b, 0x045b,
251
0x0c3b, 0x008b, 0x182b, 0x441b,
252
};
253
 
254
unsigned short int dct_coeff_tbl_2[4] =
255
{
256
0x4019, 0x1429, 0x0079, 0x0839,
257
};
258
 
259
unsigned short int dct_coeff_tbl_3[4] =
260
{
261
0x0449, 0x3c19, 0x3819, 0x1029,
262
};
263
 
264
unsigned short int dct_coeff_next[256] =
265
{
266
0xffff, 0xffff, 0xffff, 0xffff,
267
0xf7d5, 0xf7d5, 0xf7d5, 0xf7d5,
268
0x0826, 0x0826, 0x2416, 0x2416,
269
0x0046, 0x0046, 0x2016, 0x2016,
270
0x1c15, 0x1c15, 0x1c15, 0x1c15,
271
0x1815, 0x1815, 0x1815, 0x1815,
272
0x0425, 0x0425, 0x0425, 0x0425,
273
0x1415, 0x1415, 0x1415, 0x1415,
274
0x3417, 0x0067, 0x3017, 0x2c17,
275
0x0c27, 0x0437, 0x0057, 0x2817,
276
0x0034, 0x0034, 0x0034, 0x0034,
277
0x0034, 0x0034, 0x0034, 0x0034,
278
0x1014, 0x1014, 0x1014, 0x1014,
279
0x1014, 0x1014, 0x1014, 0x1014,
280
0x0c14, 0x0c14, 0x0c14, 0x0c14,
281
0x0c14, 0x0c14, 0x0c14, 0x0c14,
282
0x0023, 0x0023, 0x0023, 0x0023,
283
0x0023, 0x0023, 0x0023, 0x0023,
284
0x0023, 0x0023, 0x0023, 0x0023,
285
0x0023, 0x0023, 0x0023, 0x0023,
286
0x0813, 0x0813, 0x0813, 0x0813,
287
0x0813, 0x0813, 0x0813, 0x0813,
288
0x0813, 0x0813, 0x0813, 0x0813,
289
0x0813, 0x0813, 0x0813, 0x0813,
290
0x0412, 0x0412, 0x0412, 0x0412,
291
0x0412, 0x0412, 0x0412, 0x0412,
292
0x0412, 0x0412, 0x0412, 0x0412,
293
0x0412, 0x0412, 0x0412, 0x0412,
294
0x0412, 0x0412, 0x0412, 0x0412,
295
0x0412, 0x0412, 0x0412, 0x0412,
296
0x0412, 0x0412, 0x0412, 0x0412,
297
0x0412, 0x0412, 0x0412, 0x0412,
298
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1,
299
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1,
300
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1,
301
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1,
302
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1,
303
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1,
304
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1,
305
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1,
306
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1,
307
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1,
308
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1,
309
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1,
310
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1,
311
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1,
312
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1,
313
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1,
314
0x0011, 0x0011, 0x0011, 0x0011,
315
0x0011, 0x0011, 0x0011, 0x0011,
316
0x0011, 0x0011, 0x0011, 0x0011,
317
0x0011, 0x0011, 0x0011, 0x0011,
318
0x0011, 0x0011, 0x0011, 0x0011,
319
0x0011, 0x0011, 0x0011, 0x0011,
320
0x0011, 0x0011, 0x0011, 0x0011,
321
0x0011, 0x0011, 0x0011, 0x0011,
322
0x0011, 0x0011, 0x0011, 0x0011,
323
0x0011, 0x0011, 0x0011, 0x0011,
324
0x0011, 0x0011, 0x0011, 0x0011,
325
0x0011, 0x0011, 0x0011, 0x0011,
326
0x0011, 0x0011, 0x0011, 0x0011,
327
0x0011, 0x0011, 0x0011, 0x0011,
328
0x0011, 0x0011, 0x0011, 0x0011,
329
0x0011, 0x0011, 0x0011, 0x0011,
330
};
331
 
332
unsigned short int dct_coeff_first[256] =
333
{
334
0xffff, 0xffff, 0xffff, 0xffff,
335
0xf7d5, 0xf7d5, 0xf7d5, 0xf7d5,
336
0x0826, 0x0826, 0x2416, 0x2416,
337
0x0046, 0x0046, 0x2016, 0x2016,
338
0x1c15, 0x1c15, 0x1c15, 0x1c15,
339
0x1815, 0x1815, 0x1815, 0x1815,
340
0x0425, 0x0425, 0x0425, 0x0425,
341
0x1415, 0x1415, 0x1415, 0x1415,
342
0x3417, 0x0067, 0x3017, 0x2c17,
343
0x0c27, 0x0437, 0x0057, 0x2817,
344
0x0034, 0x0034, 0x0034, 0x0034,
345
0x0034, 0x0034, 0x0034, 0x0034,
346
0x1014, 0x1014, 0x1014, 0x1014,
347
0x1014, 0x1014, 0x1014, 0x1014,
348
0x0c14, 0x0c14, 0x0c14, 0x0c14,
349
0x0c14, 0x0c14, 0x0c14, 0x0c14,
350
0x0023, 0x0023, 0x0023, 0x0023,
351
0x0023, 0x0023, 0x0023, 0x0023,
352
0x0023, 0x0023, 0x0023, 0x0023,
353
0x0023, 0x0023, 0x0023, 0x0023,
354
0x0813, 0x0813, 0x0813, 0x0813,
355
0x0813, 0x0813, 0x0813, 0x0813,
356
0x0813, 0x0813, 0x0813, 0x0813,
357
0x0813, 0x0813, 0x0813, 0x0813,
358
0x0412, 0x0412, 0x0412, 0x0412,
359
0x0412, 0x0412, 0x0412, 0x0412,
360
0x0412, 0x0412, 0x0412, 0x0412,
361
0x0412, 0x0412, 0x0412, 0x0412,
362
0x0412, 0x0412, 0x0412, 0x0412,
363
0x0412, 0x0412, 0x0412, 0x0412,
364
0x0412, 0x0412, 0x0412, 0x0412,
365
0x0412, 0x0412, 0x0412, 0x0412,
366
0x0010, 0x0010, 0x0010, 0x0010,
367
0x0010, 0x0010, 0x0010, 0x0010,
368
0x0010, 0x0010, 0x0010, 0x0010,
369
0x0010, 0x0010, 0x0010, 0x0010,
370
0x0010, 0x0010, 0x0010, 0x0010,
371
0x0010, 0x0010, 0x0010, 0x0010,
372
0x0010, 0x0010, 0x0010, 0x0010,
373
0x0010, 0x0010, 0x0010, 0x0010,
374
0x0010, 0x0010, 0x0010, 0x0010,
375
0x0010, 0x0010, 0x0010, 0x0010,
376
0x0010, 0x0010, 0x0010, 0x0010,
377
0x0010, 0x0010, 0x0010, 0x0010,
378
0x0010, 0x0010, 0x0010, 0x0010,
379
0x0010, 0x0010, 0x0010, 0x0010,
380
0x0010, 0x0010, 0x0010, 0x0010,
381
0x0010, 0x0010, 0x0010, 0x0010,
382
0x0010, 0x0010, 0x0010, 0x0010,
383
0x0010, 0x0010, 0x0010, 0x0010,
384
0x0010, 0x0010, 0x0010, 0x0010,
385
0x0010, 0x0010, 0x0010, 0x0010,
386
0x0010, 0x0010, 0x0010, 0x0010,
387
0x0010, 0x0010, 0x0010, 0x0010,
388
0x0010, 0x0010, 0x0010, 0x0010,
389
0x0010, 0x0010, 0x0010, 0x0010,
390
0x0010, 0x0010, 0x0010, 0x0010,
391
0x0010, 0x0010, 0x0010, 0x0010,
392
0x0010, 0x0010, 0x0010, 0x0010,
393
0x0010, 0x0010, 0x0010, 0x0010,
394
0x0010, 0x0010, 0x0010, 0x0010,
395
0x0010, 0x0010, 0x0010, 0x0010,
396
0x0010, 0x0010, 0x0010, 0x0010,
397
0x0010, 0x0010, 0x0010, 0x0010,
398
};
399
 
400
/* Macro for filling up the decoding table for mb_addr_inc */
401
#define ASSIGN1(start, end, step, val, num) \
402
  for (i = start; i < end; i+= step) { \
403
    for (j = 0; j < step; j++) { \
404
      mb_addr_inc[i+j].value = val; \
405
      mb_addr_inc[i+j].num_bits = num; \
406
    } \
407
    val--; \
408
    }
409
 
410
 
411
 
412
/*
413
 *--------------------------------------------------------------
414
 *
415
 * init_mb_addr_inc --
416
 *
417
 *      Initialize the VLC decoding table for macro_block_address_increment
418
 *
419
 * Results:
420
 *      The decoding table for macro_block_address_increment will
421
 *      be filled; illegal values will be filled as ERROR.
422
 *
423
 * Side effects:
424
 *      The global array mb_addr_inc will be filled.
425
 *
426
 *--------------------------------------------------------------
427
 */
428
static void
429
init_mb_addr_inc()
430
{
431
  int i, j, val;
432
 
433
  for (i = 0; i < 8; i++) {
434
    mb_addr_inc[i].value = ERROR;
435
    mb_addr_inc[i].num_bits = 0;
436
  }
437
 
438
  mb_addr_inc[8].value = MACRO_BLOCK_ESCAPE;
439
  mb_addr_inc[8].num_bits = 11;
440
 
441
  for (i = 9; i < 15; i++) {
442
    mb_addr_inc[i].value = ERROR;
443
    mb_addr_inc[i].num_bits = 0;
444
  }
445
 
446
  mb_addr_inc[15].value = MACRO_BLOCK_STUFFING;
447
  mb_addr_inc[15].num_bits = 11;
448
 
449
  for (i = 16; i < 24; i++) {
450
    mb_addr_inc[i].value = ERROR;
451
    mb_addr_inc[i].num_bits = 0;
452
  }
453
 
454
  val = 33;
455
 
456
  ASSIGN1(24, 36, 1, val, 11);
457
  ASSIGN1(36, 48, 2, val, 10);
458
  ASSIGN1(48, 96, 8, val, 8);
459
  ASSIGN1(96, 128, 16, val, 7);
460
  ASSIGN1(128, 256, 64, val, 5);
461
  ASSIGN1(256, 512, 128, val, 4);
462
  ASSIGN1(512, 1024, 256, val, 3);
463
  ASSIGN1(1024, 2048, 1024, val, 1);
464
}
465
 
466
 
467
/* Macro for filling up the decoding table for mb_type */
468
#define ASSIGN2(start, end, quant, motion_forward, motion_backward, pattern, intra, num, mb_type) \
469
  for (i = start; i < end; i ++) { \
470
    mb_type[i].mb_quant = quant; \
471
    mb_type[i].mb_motion_forward = motion_forward; \
472
    mb_type[i].mb_motion_backward = motion_backward; \
473
    mb_type[i].mb_pattern = pattern; \
474
    mb_type[i].mb_intra = intra; \
475
    mb_type[i].num_bits = num; \
476
  }
477
 
478
 
479
 
480
/*
481
 *--------------------------------------------------------------
482
 *
483
 * init_mb_type_P --
484
 *
485
 *      Initialize the VLC decoding table for macro_block_type in
486
 *      predictive-coded pictures.
487
 *
488
 * Results:
489
 *      The decoding table for macro_block_type in predictive-coded
490
 *      pictures will be filled; illegal values will be filled as ERROR.
491
 *
492
 * Side effects:
493
 *      The global array mb_type_P will be filled.
494
 *
495
 *--------------------------------------------------------------
496
 */
497
static void
498
init_mb_type_P()
499
{
500
  int i;
501
 
502
  mb_type_P[0].mb_quant = mb_type_P[0].mb_motion_forward
503
    = mb_type_P[0].mb_motion_backward = mb_type_P[0].mb_pattern
504
      = mb_type_P[0].mb_intra = ERROR;
505
  mb_type_P[0].num_bits = 0;
506
 
507
  ASSIGN2(1, 2, 1, 0, 0, 0, 1, 6, mb_type_P)
508
  ASSIGN2(2, 4, 1, 0, 0, 1, 0, 5, mb_type_P)
509
  ASSIGN2(4, 6, 1, 1, 0, 1, 0, 5, mb_type_P);
510
  ASSIGN2(6, 8, 0, 0, 0, 0, 1, 5, mb_type_P);
511
  ASSIGN2(8, 16, 0, 1, 0, 0, 0, 3, mb_type_P);
512
  ASSIGN2(16, 32, 0, 0, 0, 1, 0, 2, mb_type_P);
513
  ASSIGN2(32, 64, 0, 1, 0, 1, 0, 1, mb_type_P);
514
}
515
 
516
 
517
 
518
 
519
/*
520
 *--------------------------------------------------------------
521
 *
522
 * init_mb_type_B --
523
 *
524
 *      Initialize the VLC decoding table for macro_block_type in
525
 *      bidirectionally-coded pictures.
526
 *
527
 * Results:
528
 *      The decoding table for macro_block_type in bidirectionally-coded
529
 *      pictures will be filled; illegal values will be filled as ERROR.
530
 *
531
 * Side effects:
532
 *      The global array mb_type_B will be filled.
533
 *
534
 *--------------------------------------------------------------
535
 */
536
static void
537
init_mb_type_B()
538
{
539
  int i;
540
 
541
  mb_type_B[0].mb_quant = mb_type_B[0].mb_motion_forward
542
    = mb_type_B[0].mb_motion_backward = mb_type_B[0].mb_pattern
543
      = mb_type_B[0].mb_intra = ERROR;
544
  mb_type_B[0].num_bits = 0;
545
 
546
  ASSIGN2(1, 2, 1, 0, 0, 0, 1, 6, mb_type_B);
547
  ASSIGN2(2, 3, 1, 0, 1, 1, 0, 6, mb_type_B);
548
  ASSIGN2(3, 4, 1, 1, 0, 1, 0, 6, mb_type_B);
549
  ASSIGN2(4, 6, 1, 1, 1, 1, 0, 5, mb_type_B);
550
  ASSIGN2(6, 8, 0, 0, 0, 0, 1, 5, mb_type_B);
551
  ASSIGN2(8, 12, 0, 1, 0, 0, 0, 4, mb_type_B);
552
  ASSIGN2(12, 16, 0, 1, 0, 1, 0, 4, mb_type_B);
553
  ASSIGN2(16, 24, 0, 0, 1, 0, 0, 3, mb_type_B);
554
  ASSIGN2(24, 32, 0, 0, 1, 1, 0, 3, mb_type_B);
555
  ASSIGN2(32, 48, 0, 1, 1, 0, 0, 2, mb_type_B);
556
  ASSIGN2(48, 64, 0, 1, 1, 1, 0, 2, mb_type_B);
557
}
558
 
559
 
560
/* Macro for filling up the decoding tables for motion_vectors */
561
#define ASSIGN3(start, end, step, val, num) \
562
  for (i = start; i < end; i+= step) { \
563
    for (j = 0; j < step / 2; j++) { \
564
      motion_vectors[i+j].code = val; \
565
      motion_vectors[i+j].num_bits = num; \
566
    } \
567
    for (j = step / 2; j < step; j++) { \
568
      motion_vectors[i+j].code = -val; \
569
      motion_vectors[i+j].num_bits = num; \
570
    } \
571
    val--; \
572
  }
573
 
574
 
575
 
576
/*
577
 *--------------------------------------------------------------
578
 *
579
 * init_motion_vectors --
580
 *
581
 *      Initialize the VLC decoding table for the various motion
582
 *      vectors, including motion_horizontal_forward_code,
583
 *      motion_vertical_forward_code, motion_horizontal_backward_code,
584
 *      and motion_vertical_backward_code.
585
 *
586
 * Results:
587
 *      The decoding table for the motion vectors will be filled;
588
 *      illegal values will be filled as ERROR.
589
 *
590
 * Side effects:
591
 *      The global array motion_vector will be filled.
592
 *
593
 *--------------------------------------------------------------
594
 */
595
static void
596
init_motion_vectors()
597
{
598
  int i, j, val = 16;
599
 
600
  for (i = 0; i < 24; i++) {
601
    motion_vectors[i].code = ERROR;
602
    motion_vectors[i].num_bits = 0;
603
  }
604
 
605
  ASSIGN3(24, 36, 2, val, 11);
606
  ASSIGN3(36, 48, 4, val, 10);
607
  ASSIGN3(48, 96, 16, val, 8);
608
  ASSIGN3(96, 128, 32, val, 7);
609
  ASSIGN3(128, 256, 128, val, 5);
610
  ASSIGN3(256, 512, 256, val, 4);
611
  ASSIGN3(512, 1024, 512, val, 3);
612
  ASSIGN3(1024, 2048, 1024, val, 1);
613
}
614
 
615
 
616
 
617
extern void init_pre_idct();
618
 
619
 
620
/*
621
 *--------------------------------------------------------------
622
 *
623
 * init_tables --
624
 *
625
 *      Initialize all the tables for VLC decoding; this must be
626
 *      called when the system is set up before any decoding can
627
 *      take place.
628
 *
629
 * Results:
630
 *      All the decoding tables will be filled accordingly.
631
 *
632
 * Side effects:
633
 *      The corresponding global array for each decoding table
634
 *      will be filled.
635
 *
636
 *--------------------------------------------------------------
637
 */    
638
void
639
init_tables()
640
{
641
 
642
  init_mb_addr_inc();
643
  init_mb_type_P();
644
  init_mb_type_B();
645
  init_motion_vectors();
646
 
647
#ifdef FLOATDCT
648
  if (qualityFlag)
649
    init_float_idct();
650
  else
651
#endif
652
    init_pre_idct();
653
 
654
#ifdef ANALYSIS
655
  {
656
    init_stats();
657
  }
658
#endif
659
}
660
 
661
#if OLDCODE
662
 
663
/*
664
 *--------------------------------------------------------------
665
 *
666
 * DecodeDCTDCSizeLum --
667
 *
668
 *      Huffman Decoder for dct_dc_size_luminance; location where
669
 *      the result of decoding will be placed is passed as argument.
670
 *      The decoded values are obtained by doing a table lookup on
671
 *      dct_dc_size_luminance.
672
 *
673
 * Results:
674
 *      The decoded value for dct_dc_size_luminance or ERROR for
675
 *      unbound values will be placed in the location specified.
676
 *
677
 * Side effects:
678
 *      Bit stream is irreversibly parsed.
679
 *
680
 *--------------------------------------------------------------
681
 */        
682
void
683
decodeDCTDCSizeLum(value)
684
unsigned int *value;
685
{
686
  unsigned int index;
687
 
688
  show_bits5(index);
689
 
690
  if (index < 31) {
691
        *value = dct_dc_size_luminance[index].value;
692
        flush_bits(dct_dc_size_luminance[index].num_bits);
693
  }
694
  else {
695
        show_bits9(index);
696
        index -= 0x1f0;
697
        *value = dct_dc_size_luminance1[index].value;
698
        flush_bits(dct_dc_size_luminance1[index].num_bits);
699
  }
700
}
701
 
702
 
703
 
704
 
705
/*
706
 *--------------------------------------------------------------
707
 *
708
 * DecodeDCTDCSizeChrom --
709
 *
710
 *      Huffman Decoder for dct_dc_size_chrominance; location where
711
 *      the result of decoding will be placed is passed as argument.
712
 *      The decoded values are obtained by doing a table lookup on
713
 *      dct_dc_size_chrominance.
714
 *
715
 * Results:
716
 *      The decoded value for dct_dc_size_chrominance or ERROR for
717
 *      unbound values will be placed in the location specified.
718
 *
719
 * Side effects:
720
 *      Bit stream is irreversibly parsed.
721
 *
722
 *--------------------------------------------------------------
723
 */    
724
void    
725
decodeDCTDCSizeChrom(value)
726
unsigned int *value;
727
{
728
  unsigned int index;
729
 
730
  show_bits5(index);
731
 
732
  if (index < 31) {
733
        *value = dct_dc_size_chrominance[index].value;
734
        flush_bits(dct_dc_size_chrominance[index].num_bits);
735
  }
736
  else {
737
        show_bits10(index);
738
        index -= 0x3e0;
739
        *value = dct_dc_size_chrominance1[index].value;
740
        flush_bits(dct_dc_size_chrominance1[index].num_bits);
741
  }
742
}
743
 
744
 
745
 
746
/*
747
 *--------------------------------------------------------------
748
 *
749
 * decodeDCTCoeff --
750
 *
751
 *      Huffman Decoder for dct_coeff_first and dct_coeff_next;
752
 *      locations where the results of decoding: run and level, are to
753
 *      be placed and also the type of DCT coefficients, either
754
 *      dct_coeff_first or dct_coeff_next, are being passed as argument.
755
 *      
756
 *      The decoder first examines the next 8 bits in the input stream,
757
 *      and perform according to the following cases:
758
 *      
759
 *      '0000 0000' - examine 8 more bits (i.e. 16 bits total) and
760
 *                    perform a table lookup on dct_coeff_tbl_0.
761
 *                    One more bit is then examined to determine the sign
762
 *                    of level.
763
 *
764
 *      '0000 0001' - examine 4 more bits (i.e. 12 bits total) and
765
 *                    perform a table lookup on dct_coeff_tbl_1.
766
 *                    One more bit is then examined to determine the sign
767
 *                    of level.
768
 *      
769
 *      '0000 0010' - examine 2 more bits (i.e. 10 bits total) and
770
 *                    perform a table lookup on dct_coeff_tbl_2.
771
 *                    One more bit is then examined to determine the sign
772
 *                    of level.
773
 *
774
 *      '0000 0011' - examine 2 more bits (i.e. 10 bits total) and
775
 *                    perform a table lookup on dct_coeff_tbl_3.
776
 *                    One more bit is then examined to determine the sign
777
 *                    of level.
778
 *
779
 *      otherwise   - perform a table lookup on dct_coeff_tbl. If the
780
 *                    value of run is not ESCAPE, extract one more bit
781
 *                    to determine the sign of level; otherwise 6 more
782
 *                    bits will be extracted to obtain the actual value
783
 *                    of run , and then 8 or 16 bits to get the value of level.
784
 *                    
785
 *      
786
 *
787
 * Results:
788
 *      The decoded values of run and level or ERROR for unbound values
789
 *      are placed in the locations specified.
790
 *
791
 * Side effects:
792
 *      Bit stream is irreversibly parsed.
793
 *
794
 *--------------------------------------------------------------
795
 */
796
static void
797
decodeDCTCoeff(dct_coeff_tbl, run, level)
798
unsigned short int *dct_coeff_tbl;                                      
799
unsigned int *run;
800
int *level;
801
{
802
  unsigned int temp, index /*, num_bits */;
803
  unsigned int value, next32bits, flushed;
804
 
805
  /*
806
   * Grab the next 32 bits and use it to improve performance of
807
   * getting the bits to parse. Thus, calls are translated as:
808
   *
809
   *    show_bitsX  <-->   next32bits >> (32-X)
810
   *    get_bitsX   <-->   val = next32bits >> (32-flushed-X);
811
   *                       flushed += X;
812
   *                       next32bits &= bitMask[flushed];
813
   *    flush_bitsX <-->   flushed += X;
814
   *                       next32bits &= bitMask[flushed];
815
   *
816
   */
817
  show_bits32(next32bits);
818
  flushed = 0;
819
 
820
  /* show_bits8(index); */
821
  index = next32bits >> 24;
822
 
823
  if (index > 3) {
824
    value = dct_coeff_tbl[index];
825
    *run = (value & RUN_MASK) >> RUN_SHIFT;
826
    if (*run == END_OF_BLOCK) {
827
      *level = END_OF_BLOCK;
828
    }
829
    else {
830
      /* num_bits = (value & NUM_MASK) + 1; */
831
      /* flush_bits(num_bits); */
832
      flushed = (value & NUM_MASK) + 1;
833
      next32bits &= bitMask[flushed];
834
      if (*run != ESCAPE) {
835
         *level = (value & LEVEL_MASK) >> LEVEL_SHIFT;
836
         /* get_bits1(value); */
837
         /* if (value) *level = -*level; */
838
         if (next32bits >> (31-flushed)) *level = -*level;
839
         flushed++;
840
         /* next32bits &= bitMask[flushed];  last op before update */
841
       }
842
       else {    /* *run == ESCAPE */
843
         /* get_bits14(temp); */
844
         temp = next32bits >> (18-flushed);
845
         flushed += 14;
846
         next32bits &= bitMask[flushed];
847
         *run = temp >> 8;
848
         temp &= 0xff;
849
         if (temp == 0) {
850
            /* get_bits8(*level); */
851
            *level = next32bits >> (24-flushed);
852
            flushed += 8;
853
            /* next32bits &= bitMask[flushed];  last op before update */
854
            assert(*level >= 128);
855
         } else if (temp != 128) {
856
            /* Grab sign bit */
857
            *level = ((int) (temp << 24)) >> 24;
858
         } else {
859
            /* get_bits8(*level); */
860
            *level = next32bits >> (24-flushed);
861
            flushed += 8;
862
            /* next32bits &= bitMask[flushed];  last op before update */
863
            *level = *level - 256;
864
            assert(*level <= -128 && *level >= -255);
865
         }
866
       }
867
       /* Update bitstream... */
868
       flush_bits(flushed);
869
    }
870
  }
871
  else {
872
    if (index == 2) {
873
      /* show_bits10(index); */
874
      index = next32bits >> 22;
875
      value = dct_coeff_tbl_2[index & 3];
876
    }
877
    else if (index == 3) {
878
      /* show_bits10(index); */
879
      index = next32bits >> 22;
880
      value = dct_coeff_tbl_3[index & 3];
881
    }
882
    else if (index) {   /* index == 1 */
883
      /* show_bits12(index); */
884
      index = next32bits >> 20;
885
      value = dct_coeff_tbl_1[index & 15];
886
    }
887
    else {   /* index == 0 */
888
      /* show_bits16(index); */
889
      index = next32bits >> 16;
890
      value = dct_coeff_tbl_0[index & 255];
891
    }
892
    *run = (value & RUN_MASK) >> RUN_SHIFT;
893
    *level = (value & LEVEL_MASK) >> LEVEL_SHIFT;
894
 
895
    /*
896
     * Fold these operations together to make it fast...
897
     */
898
    /* num_bits = (value & NUM_MASK) + 1; */
899
    /* flush_bits(num_bits); */
900
    /* get_bits1(value); */
901
    /* if (value) *level = -*level; */
902
 
903
    flushed = (value & NUM_MASK) + 2;
904
    if ((next32bits >> (32-flushed)) & 0x1) *level = -*level;
905
 
906
    /* Update bitstream ... */
907
    flush_bits(flushed);
908
  }
909
}
910
 
911
 
912
/*
913
 *--------------------------------------------------------------
914
 *
915
 * decodeDCTCoeffFirst --
916
 *
917
 *      Huffman Decoder for dct_coeff_first. Locations for the
918
 *      decoded results: run and level, are being passed as
919
 *      arguments. Actual work is being done by calling DecodeDCTCoeff,
920
 *      with the table dct_coeff_first.
921
 *
922
 * Results:
923
 *      The decoded values of run and level for dct_coeff_first or
924
 *      ERROR for unbound values are placed in the locations given.
925
 *
926
 * Side effects:
927
 *      Bit stream is irreversibly parsed.
928
 *
929
 *--------------------------------------------------------------
930
 */        
931
void
932
decodeDCTCoeffFirst(run, level)
933
unsigned int *run;
934
int *level;
935
{
936
  decodeDCTCoeff(dct_coeff_first, run, level);
937
}
938
 
939
 
940
 
941
 
942
/*
943
 *--------------------------------------------------------------
944
 *
945
 * decodeDCTCoeffNext --
946
 *
947
 *      Huffman Decoder for dct_coeff_first. Locations for the
948
 *      decoded results: run and level, are being passed as
949
 *      arguments. Actual work is being done by calling DecodeDCTCoeff,
950
 *      with the table dct_coeff_next.
951
 *
952
 * Results:
953
 *      The decoded values of run and level for dct_coeff_next or
954
 *      ERROR for unbound values are placed in the locations given.
955
 *
956
 * Side effects:
957
 *      Bit stream is irreversibly parsed.
958
 *
959
 *--------------------------------------------------------------
960
 */
961
void      
962
decodeDCTCoeffNext(run, level)
963
unsigned int *run;
964
int *level;
965
{
966
  decodeDCTCoeff(dct_coeff_next, run, level);
967
}
968
#endif