~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to mpeglib/lib/mpegplay/decoderTables.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * decoders.c
 
3
 *
 
4
 * This file contains all the routines for Huffman decoding required in 
 
5
 * MPEG
 
6
 *
 
7
 */
 
8
 
 
9
 
 
10
#include "decoderTables.h"
 
11
 
 
12
 
 
13
/* Decoding table for macroblock_address_increment */
 
14
mb_addr_inc_entry     mb_addr_inc[2048];
 
15
 
 
16
/* Decoding table for macroblock_type in predictive-coded pictures */
 
17
mb_type_entry         mb_type_P[64];
 
18
 
 
19
/* Decoding table for macroblock_type in bidirectionally-coded pictures */
 
20
mb_type_entry         mb_type_B[64];
 
21
 
 
22
/* Decoding table for motion vectors */
 
23
motion_vectors_entry  motion_vectors[2048];
 
24
 
 
25
/* Decoding table for coded_block_pattern */
 
26
 
 
27
coded_block_pattern_entry coded_block_pattern[512] = 
 
28
{ {(unsigned int)MPGDECODE_ERROR, 0}, {(unsigned int)MPGDECODE_ERROR, 0}, {39, 9}, {27, 9}, {59, 9}, {55, 9}, {47, 9}, {31, 9},
 
29
    {58, 8}, {58, 8}, {54, 8}, {54, 8}, {46, 8}, {46, 8}, {30, 8}, {30, 8},
 
30
    {57, 8}, {57, 8}, {53, 8}, {53, 8}, {45, 8}, {45, 8}, {29, 8}, {29, 8},
 
31
    {38, 8}, {38, 8}, {26, 8}, {26, 8}, {37, 8}, {37, 8}, {25, 8}, {25, 8},
 
32
    {43, 8}, {43, 8}, {23, 8}, {23, 8}, {51, 8}, {51, 8}, {15, 8}, {15, 8},
 
33
    {42, 8}, {42, 8}, {22, 8}, {22, 8}, {50, 8}, {50, 8}, {14, 8}, {14, 8},
 
34
    {41, 8}, {41, 8}, {21, 8}, {21, 8}, {49, 8}, {49, 8}, {13, 8}, {13, 8},
 
35
    {35, 8}, {35, 8}, {19, 8}, {19, 8}, {11, 8}, {11, 8}, {7, 8}, {7, 8},
 
36
    {34, 7}, {34, 7}, {34, 7}, {34, 7}, {18, 7}, {18, 7}, {18, 7}, {18, 7},
 
37
    {10, 7}, {10, 7}, {10, 7}, {10, 7}, {6, 7}, {6, 7}, {6, 7}, {6, 7}, 
 
38
    {33, 7}, {33, 7}, {33, 7}, {33, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, 
 
39
    {9, 7}, {9, 7}, {9, 7}, {9, 7}, {5, 7}, {5, 7}, {5, 7}, {5, 7}, 
 
40
    {63, 6}, {63, 6}, {63, 6}, {63, 6}, {63, 6}, {63, 6}, {63, 6}, {63, 6}, 
 
41
    {3, 6}, {3, 6}, {3, 6}, {3, 6}, {3, 6}, {3, 6}, {3, 6}, {3, 6}, 
 
42
    {36, 6}, {36, 6}, {36, 6}, {36, 6}, {36, 6}, {36, 6}, {36, 6}, {36, 6}, 
 
43
    {24, 6}, {24, 6}, {24, 6}, {24, 6}, {24, 6}, {24, 6}, {24, 6}, {24, 6}, 
 
44
    {62, 5}, {62, 5}, {62, 5}, {62, 5}, {62, 5}, {62, 5}, {62, 5}, {62, 5},
 
45
    {62, 5}, {62, 5}, {62, 5}, {62, 5}, {62, 5}, {62, 5}, {62, 5}, {62, 5},
 
46
    {2, 5}, {2, 5}, {2, 5}, {2, 5}, {2, 5}, {2, 5}, {2, 5}, {2, 5}, 
 
47
    {2, 5}, {2, 5}, {2, 5}, {2, 5}, {2, 5}, {2, 5}, {2, 5}, {2, 5}, 
 
48
    {61, 5}, {61, 5}, {61, 5}, {61, 5}, {61, 5}, {61, 5}, {61, 5}, {61, 5}, 
 
49
    {61, 5}, {61, 5}, {61, 5}, {61, 5}, {61, 5}, {61, 5}, {61, 5}, {61, 5}, 
 
50
    {1, 5}, {1, 5}, {1, 5}, {1, 5}, {1, 5}, {1, 5}, {1, 5}, {1, 5}, 
 
51
    {1, 5}, {1, 5}, {1, 5}, {1, 5}, {1, 5}, {1, 5}, {1, 5}, {1, 5}, 
 
52
    {56, 5}, {56, 5}, {56, 5}, {56, 5}, {56, 5}, {56, 5}, {56, 5}, {56, 5}, 
 
53
    {56, 5}, {56, 5}, {56, 5}, {56, 5}, {56, 5}, {56, 5}, {56, 5}, {56, 5}, 
 
54
    {52, 5}, {52, 5}, {52, 5}, {52, 5}, {52, 5}, {52, 5}, {52, 5}, {52, 5}, 
 
55
    {52, 5}, {52, 5}, {52, 5}, {52, 5}, {52, 5}, {52, 5}, {52, 5}, {52, 5}, 
 
56
    {44, 5}, {44, 5}, {44, 5}, {44, 5}, {44, 5}, {44, 5}, {44, 5}, {44, 5}, 
 
57
    {44, 5}, {44, 5}, {44, 5}, {44, 5}, {44, 5}, {44, 5}, {44, 5}, {44, 5}, 
 
58
    {28, 5}, {28, 5}, {28, 5}, {28, 5}, {28, 5}, {28, 5}, {28, 5}, {28, 5}, 
 
59
    {28, 5}, {28, 5}, {28, 5}, {28, 5}, {28, 5}, {28, 5}, {28, 5}, {28, 5}, 
 
60
    {40, 5}, {40, 5}, {40, 5}, {40, 5}, {40, 5}, {40, 5}, {40, 5}, {40, 5}, 
 
61
    {40, 5}, {40, 5}, {40, 5}, {40, 5}, {40, 5}, {40, 5}, {40, 5}, {40, 5}, 
 
62
    {20, 5}, {20, 5}, {20, 5}, {20, 5}, {20, 5}, {20, 5}, {20, 5}, {20, 5}, 
 
63
    {20, 5}, {20, 5}, {20, 5}, {20, 5}, {20, 5}, {20, 5}, {20, 5}, {20, 5}, 
 
64
    {48, 5}, {48, 5}, {48, 5}, {48, 5}, {48, 5}, {48, 5}, {48, 5}, {48, 5}, 
 
65
    {48, 5}, {48, 5}, {48, 5}, {48, 5}, {48, 5}, {48, 5}, {48, 5}, {48, 5}, 
 
66
    {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, 
 
67
    {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, 
 
68
    {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, 
 
69
    {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, 
 
70
    {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, 
 
71
    {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, 
 
72
    {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, 
 
73
    {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, 
 
74
    {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, 
 
75
    {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, 
 
76
    {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, 
 
77
    {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, 
 
78
    {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, 
 
79
    {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4}, {8, 4},
 
80
    {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4},
 
81
    {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, 
 
82
    {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, 
 
83
    {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4}, {4, 4},
 
84
    {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, 
 
85
    {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, 
 
86
    {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, 
 
87
    {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, 
 
88
    {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, 
 
89
    {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, 
 
90
    {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, 
 
91
    {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}, {60, 3}
 
92
};
 
93
 
 
94
/* Decoding tables for dct_dc_size_luminance */
 
95
dct_dc_size_entry dct_dc_size_luminance[32] =
 
96
{   {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, 
 
97
    {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, 
 
98
    {0, 3}, {0, 3}, {0, 3}, {0, 3}, {3, 3}, {3, 3}, {3, 3}, {3, 3}, 
 
99
    {4, 3}, {4, 3}, {4, 3}, {4, 3}, {5, 4}, {5, 4}, {6, 5}, {(unsigned int)MPGDECODE_ERROR, 0}
 
100
};
 
101
 
 
102
dct_dc_size_entry dct_dc_size_luminance1[16] =
 
103
{   {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6},
 
104
    {8, 7}, {8, 7}, {8, 7}, {8, 7}, {9, 8}, {9, 8}, {10, 9}, {11, 9}
 
105
};
 
106
 
 
107
/* Decoding table for dct_dc_size_chrominance */
 
108
dct_dc_size_entry dct_dc_size_chrominance[32] =
 
109
{   {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, 
 
110
    {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, 
 
111
    {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, 
 
112
    {3, 3}, {3, 3}, {3, 3}, {3, 3}, {4, 4}, {4, 4}, {5, 5}, {(unsigned int)MPGDECODE_ERROR, 0}
 
113
};
 
114
 
 
115
dct_dc_size_entry dct_dc_size_chrominance1[32] =
 
116
{   {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, 
 
117
    {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, 
 
118
    {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, 
 
119
    {8, 8}, {8, 8}, {8, 8}, {8, 8}, {9, 9}, {9, 9}, {10, 10}, {11, 10}
 
120
};
 
121
 
 
122
/* DCT coeff tables. */
 
123
 
 
124
unsigned short int dct_coeff_tbl_0[256] =
 
125
{
 
126
0xffff, 0xffff, 0xffff, 0xffff, 
 
127
0xffff, 0xffff, 0xffff, 0xffff, 
 
128
0xffff, 0xffff, 0xffff, 0xffff, 
 
129
0xffff, 0xffff, 0xffff, 0xffff, 
 
130
0x052f, 0x051f, 0x050f, 0x04ff, 
 
131
0x183f, 0x402f, 0x3c2f, 0x382f, 
 
132
0x342f, 0x302f, 0x2c2f, 0x7c1f, 
 
133
0x781f, 0x741f, 0x701f, 0x6c1f, 
 
134
0x028e, 0x028e, 0x027e, 0x027e, 
 
135
0x026e, 0x026e, 0x025e, 0x025e, 
 
136
0x024e, 0x024e, 0x023e, 0x023e, 
 
137
0x022e, 0x022e, 0x021e, 0x021e, 
 
138
0x020e, 0x020e, 0x04ee, 0x04ee, 
 
139
0x04de, 0x04de, 0x04ce, 0x04ce, 
 
140
0x04be, 0x04be, 0x04ae, 0x04ae, 
 
141
0x049e, 0x049e, 0x048e, 0x048e, 
 
142
0x01fd, 0x01fd, 0x01fd, 0x01fd, 
 
143
0x01ed, 0x01ed, 0x01ed, 0x01ed, 
 
144
0x01dd, 0x01dd, 0x01dd, 0x01dd, 
 
145
0x01cd, 0x01cd, 0x01cd, 0x01cd, 
 
146
0x01bd, 0x01bd, 0x01bd, 0x01bd, 
 
147
0x01ad, 0x01ad, 0x01ad, 0x01ad, 
 
148
0x019d, 0x019d, 0x019d, 0x019d, 
 
149
0x018d, 0x018d, 0x018d, 0x018d, 
 
150
0x017d, 0x017d, 0x017d, 0x017d, 
 
151
0x016d, 0x016d, 0x016d, 0x016d, 
 
152
0x015d, 0x015d, 0x015d, 0x015d, 
 
153
0x014d, 0x014d, 0x014d, 0x014d, 
 
154
0x013d, 0x013d, 0x013d, 0x013d, 
 
155
0x012d, 0x012d, 0x012d, 0x012d, 
 
156
0x011d, 0x011d, 0x011d, 0x011d, 
 
157
0x010d, 0x010d, 0x010d, 0x010d, 
 
158
0x282c, 0x282c, 0x282c, 0x282c, 
 
159
0x282c, 0x282c, 0x282c, 0x282c, 
 
160
0x242c, 0x242c, 0x242c, 0x242c, 
 
161
0x242c, 0x242c, 0x242c, 0x242c, 
 
162
0x143c, 0x143c, 0x143c, 0x143c, 
 
163
0x143c, 0x143c, 0x143c, 0x143c, 
 
164
0x0c4c, 0x0c4c, 0x0c4c, 0x0c4c, 
 
165
0x0c4c, 0x0c4c, 0x0c4c, 0x0c4c, 
 
166
0x085c, 0x085c, 0x085c, 0x085c, 
 
167
0x085c, 0x085c, 0x085c, 0x085c, 
 
168
0x047c, 0x047c, 0x047c, 0x047c, 
 
169
0x047c, 0x047c, 0x047c, 0x047c, 
 
170
0x046c, 0x046c, 0x046c, 0x046c, 
 
171
0x046c, 0x046c, 0x046c, 0x046c, 
 
172
0x00fc, 0x00fc, 0x00fc, 0x00fc, 
 
173
0x00fc, 0x00fc, 0x00fc, 0x00fc, 
 
174
0x00ec, 0x00ec, 0x00ec, 0x00ec, 
 
175
0x00ec, 0x00ec, 0x00ec, 0x00ec, 
 
176
0x00dc, 0x00dc, 0x00dc, 0x00dc, 
 
177
0x00dc, 0x00dc, 0x00dc, 0x00dc, 
 
178
0x00cc, 0x00cc, 0x00cc, 0x00cc, 
 
179
0x00cc, 0x00cc, 0x00cc, 0x00cc, 
 
180
0x681c, 0x681c, 0x681c, 0x681c, 
 
181
0x681c, 0x681c, 0x681c, 0x681c, 
 
182
0x641c, 0x641c, 0x641c, 0x641c, 
 
183
0x641c, 0x641c, 0x641c, 0x641c, 
 
184
0x601c, 0x601c, 0x601c, 0x601c, 
 
185
0x601c, 0x601c, 0x601c, 0x601c, 
 
186
0x5c1c, 0x5c1c, 0x5c1c, 0x5c1c, 
 
187
0x5c1c, 0x5c1c, 0x5c1c, 0x5c1c, 
 
188
0x581c, 0x581c, 0x581c, 0x581c, 
 
189
0x581c, 0x581c, 0x581c, 0x581c, 
 
190
};
 
191
 
 
192
unsigned short int dct_coeff_tbl_1[16] = 
 
193
{
 
194
0x00bb, 0x202b, 0x103b, 0x00ab, 
 
195
0x084b, 0x1c2b, 0x541b, 0x501b, 
 
196
0x009b, 0x4c1b, 0x481b, 0x045b, 
 
197
0x0c3b, 0x008b, 0x182b, 0x441b, 
 
198
};
 
199
 
 
200
unsigned short int dct_coeff_tbl_2[4] =
 
201
{
 
202
0x4019, 0x1429, 0x0079, 0x0839, 
 
203
};
 
204
 
 
205
unsigned short int dct_coeff_tbl_3[4] = 
 
206
{
 
207
0x0449, 0x3c19, 0x3819, 0x1029, 
 
208
};
 
209
 
 
210
unsigned short int dct_coeff_next[256] = 
 
211
{
 
212
0xffff, 0xffff, 0xffff, 0xffff, 
 
213
0xf7d5, 0xf7d5, 0xf7d5, 0xf7d5, 
 
214
0x0826, 0x0826, 0x2416, 0x2416, 
 
215
0x0046, 0x0046, 0x2016, 0x2016, 
 
216
0x1c15, 0x1c15, 0x1c15, 0x1c15, 
 
217
0x1815, 0x1815, 0x1815, 0x1815, 
 
218
0x0425, 0x0425, 0x0425, 0x0425, 
 
219
0x1415, 0x1415, 0x1415, 0x1415, 
 
220
0x3417, 0x0067, 0x3017, 0x2c17, 
 
221
0x0c27, 0x0437, 0x0057, 0x2817, 
 
222
0x0034, 0x0034, 0x0034, 0x0034, 
 
223
0x0034, 0x0034, 0x0034, 0x0034, 
 
224
0x1014, 0x1014, 0x1014, 0x1014, 
 
225
0x1014, 0x1014, 0x1014, 0x1014, 
 
226
0x0c14, 0x0c14, 0x0c14, 0x0c14, 
 
227
0x0c14, 0x0c14, 0x0c14, 0x0c14, 
 
228
0x0023, 0x0023, 0x0023, 0x0023, 
 
229
0x0023, 0x0023, 0x0023, 0x0023, 
 
230
0x0023, 0x0023, 0x0023, 0x0023, 
 
231
0x0023, 0x0023, 0x0023, 0x0023, 
 
232
0x0813, 0x0813, 0x0813, 0x0813, 
 
233
0x0813, 0x0813, 0x0813, 0x0813, 
 
234
0x0813, 0x0813, 0x0813, 0x0813, 
 
235
0x0813, 0x0813, 0x0813, 0x0813, 
 
236
0x0412, 0x0412, 0x0412, 0x0412, 
 
237
0x0412, 0x0412, 0x0412, 0x0412, 
 
238
0x0412, 0x0412, 0x0412, 0x0412, 
 
239
0x0412, 0x0412, 0x0412, 0x0412, 
 
240
0x0412, 0x0412, 0x0412, 0x0412, 
 
241
0x0412, 0x0412, 0x0412, 0x0412, 
 
242
0x0412, 0x0412, 0x0412, 0x0412, 
 
243
0x0412, 0x0412, 0x0412, 0x0412, 
 
244
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1, 
 
245
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1, 
 
246
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1, 
 
247
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1, 
 
248
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1, 
 
249
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1, 
 
250
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1, 
 
251
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1, 
 
252
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1, 
 
253
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1, 
 
254
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1, 
 
255
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1, 
 
256
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1, 
 
257
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1, 
 
258
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1, 
 
259
0xfbe1, 0xfbe1, 0xfbe1, 0xfbe1, 
 
260
0x0011, 0x0011, 0x0011, 0x0011, 
 
261
0x0011, 0x0011, 0x0011, 0x0011, 
 
262
0x0011, 0x0011, 0x0011, 0x0011, 
 
263
0x0011, 0x0011, 0x0011, 0x0011, 
 
264
0x0011, 0x0011, 0x0011, 0x0011, 
 
265
0x0011, 0x0011, 0x0011, 0x0011, 
 
266
0x0011, 0x0011, 0x0011, 0x0011, 
 
267
0x0011, 0x0011, 0x0011, 0x0011, 
 
268
0x0011, 0x0011, 0x0011, 0x0011, 
 
269
0x0011, 0x0011, 0x0011, 0x0011, 
 
270
0x0011, 0x0011, 0x0011, 0x0011, 
 
271
0x0011, 0x0011, 0x0011, 0x0011, 
 
272
0x0011, 0x0011, 0x0011, 0x0011, 
 
273
0x0011, 0x0011, 0x0011, 0x0011, 
 
274
0x0011, 0x0011, 0x0011, 0x0011, 
 
275
0x0011, 0x0011, 0x0011, 0x0011, 
 
276
};
 
277
 
 
278
unsigned short int dct_coeff_first[256] = 
 
279
{
 
280
0xffff, 0xffff, 0xffff, 0xffff, 
 
281
0xf7d5, 0xf7d5, 0xf7d5, 0xf7d5, 
 
282
0x0826, 0x0826, 0x2416, 0x2416, 
 
283
0x0046, 0x0046, 0x2016, 0x2016, 
 
284
0x1c15, 0x1c15, 0x1c15, 0x1c15, 
 
285
0x1815, 0x1815, 0x1815, 0x1815, 
 
286
0x0425, 0x0425, 0x0425, 0x0425, 
 
287
0x1415, 0x1415, 0x1415, 0x1415, 
 
288
0x3417, 0x0067, 0x3017, 0x2c17, 
 
289
0x0c27, 0x0437, 0x0057, 0x2817, 
 
290
0x0034, 0x0034, 0x0034, 0x0034, 
 
291
0x0034, 0x0034, 0x0034, 0x0034, 
 
292
0x1014, 0x1014, 0x1014, 0x1014, 
 
293
0x1014, 0x1014, 0x1014, 0x1014, 
 
294
0x0c14, 0x0c14, 0x0c14, 0x0c14, 
 
295
0x0c14, 0x0c14, 0x0c14, 0x0c14, 
 
296
0x0023, 0x0023, 0x0023, 0x0023, 
 
297
0x0023, 0x0023, 0x0023, 0x0023, 
 
298
0x0023, 0x0023, 0x0023, 0x0023, 
 
299
0x0023, 0x0023, 0x0023, 0x0023, 
 
300
0x0813, 0x0813, 0x0813, 0x0813, 
 
301
0x0813, 0x0813, 0x0813, 0x0813, 
 
302
0x0813, 0x0813, 0x0813, 0x0813, 
 
303
0x0813, 0x0813, 0x0813, 0x0813, 
 
304
0x0412, 0x0412, 0x0412, 0x0412, 
 
305
0x0412, 0x0412, 0x0412, 0x0412, 
 
306
0x0412, 0x0412, 0x0412, 0x0412, 
 
307
0x0412, 0x0412, 0x0412, 0x0412, 
 
308
0x0412, 0x0412, 0x0412, 0x0412, 
 
309
0x0412, 0x0412, 0x0412, 0x0412, 
 
310
0x0412, 0x0412, 0x0412, 0x0412, 
 
311
0x0412, 0x0412, 0x0412, 0x0412, 
 
312
0x0010, 0x0010, 0x0010, 0x0010, 
 
313
0x0010, 0x0010, 0x0010, 0x0010, 
 
314
0x0010, 0x0010, 0x0010, 0x0010, 
 
315
0x0010, 0x0010, 0x0010, 0x0010, 
 
316
0x0010, 0x0010, 0x0010, 0x0010, 
 
317
0x0010, 0x0010, 0x0010, 0x0010, 
 
318
0x0010, 0x0010, 0x0010, 0x0010, 
 
319
0x0010, 0x0010, 0x0010, 0x0010, 
 
320
0x0010, 0x0010, 0x0010, 0x0010, 
 
321
0x0010, 0x0010, 0x0010, 0x0010, 
 
322
0x0010, 0x0010, 0x0010, 0x0010, 
 
323
0x0010, 0x0010, 0x0010, 0x0010, 
 
324
0x0010, 0x0010, 0x0010, 0x0010, 
 
325
0x0010, 0x0010, 0x0010, 0x0010, 
 
326
0x0010, 0x0010, 0x0010, 0x0010, 
 
327
0x0010, 0x0010, 0x0010, 0x0010, 
 
328
0x0010, 0x0010, 0x0010, 0x0010, 
 
329
0x0010, 0x0010, 0x0010, 0x0010, 
 
330
0x0010, 0x0010, 0x0010, 0x0010, 
 
331
0x0010, 0x0010, 0x0010, 0x0010, 
 
332
0x0010, 0x0010, 0x0010, 0x0010, 
 
333
0x0010, 0x0010, 0x0010, 0x0010, 
 
334
0x0010, 0x0010, 0x0010, 0x0010, 
 
335
0x0010, 0x0010, 0x0010, 0x0010, 
 
336
0x0010, 0x0010, 0x0010, 0x0010, 
 
337
0x0010, 0x0010, 0x0010, 0x0010, 
 
338
0x0010, 0x0010, 0x0010, 0x0010, 
 
339
0x0010, 0x0010, 0x0010, 0x0010, 
 
340
0x0010, 0x0010, 0x0010, 0x0010, 
 
341
0x0010, 0x0010, 0x0010, 0x0010, 
 
342
0x0010, 0x0010, 0x0010, 0x0010, 
 
343
0x0010, 0x0010, 0x0010, 0x0010, 
 
344
};
 
345
 
 
346
/* Macro for filling up the decoding table for mb_addr_inc */
 
347
#define ASSIGN1(start, end, step, val, num) \
 
348
  for (i = start; i < end; i+= step) { \
 
349
    for (j = 0; j < step; j++) { \
 
350
      mb_addr_inc[i+j].value = val; \
 
351
      mb_addr_inc[i+j].num_bits = num; \
 
352
    } \
 
353
    val--; \
 
354
    }
 
355
 
 
356
 
 
357
 
 
358
/*
 
359
 *--------------------------------------------------------------
 
360
 *
 
361
 * init_mb_addr_inc --
 
362
 *
 
363
 *      Initialize the VLC decoding table for macro_block_address_increment
 
364
 *
 
365
 * Results:
 
366
 *      The decoding table for macro_block_address_increment will
 
367
 *      be filled; illegal values will be filled as MPGDECODE_ERROR.
 
368
 *
 
369
 * Side effects:
 
370
 *      The global array mb_addr_inc will be filled.
 
371
 *
 
372
 *--------------------------------------------------------------
 
373
 */
 
374
static void init_mb_addr_inc()
 
375
{
 
376
  int i, j, val;
 
377
 
 
378
  for (i = 0; i < 8; i++) {
 
379
    mb_addr_inc[i].value = MPGDECODE_ERROR;
 
380
    mb_addr_inc[i].num_bits = 0;
 
381
  }
 
382
 
 
383
  mb_addr_inc[8].value = MACRO_BLOCK_ESCAPE;
 
384
  mb_addr_inc[8].num_bits = 11;
 
385
 
 
386
  for (i = 9; i < 15; i++) {
 
387
    mb_addr_inc[i].value = MPGDECODE_ERROR;
 
388
    mb_addr_inc[i].num_bits = 0;
 
389
  }
 
390
 
 
391
  mb_addr_inc[15].value = MACRO_BLOCK_STUFFING;
 
392
  mb_addr_inc[15].num_bits = 11;
 
393
 
 
394
  for (i = 16; i < 24; i++) {
 
395
    mb_addr_inc[i].value = MPGDECODE_ERROR;
 
396
    mb_addr_inc[i].num_bits = 0;
 
397
  }
 
398
 
 
399
  val = 33;
 
400
 
 
401
  ASSIGN1(24, 36, 1, val, 11);
 
402
  ASSIGN1(36, 48, 2, val, 10);
 
403
  ASSIGN1(48, 96, 8, val, 8);
 
404
  ASSIGN1(96, 128, 16, val, 7);
 
405
  ASSIGN1(128, 256, 64, val, 5);
 
406
  ASSIGN1(256, 512, 128, val, 4);
 
407
  ASSIGN1(512, 1024, 256, val, 3);
 
408
  ASSIGN1(1024, 2048, 1024, val, 1);
 
409
}
 
410
 
 
411
 
 
412
/* Macro for filling up the decoding table for mb_type */
 
413
#define ASSIGN2(start, end, quant, motion_forward, motion_backward, pattern, intra, num, mb_type) \
 
414
  for (i = start; i < end; i ++) { \
 
415
    mb_type[i].mb_quant = quant; \
 
416
    mb_type[i].mb_motion_forward = motion_forward; \
 
417
    mb_type[i].mb_motion_backward = motion_backward; \
 
418
    mb_type[i].mb_pattern = pattern; \
 
419
    mb_type[i].mb_intra = intra; \
 
420
    mb_type[i].num_bits = num; \
 
421
  }
 
422
         
 
423
 
 
424
 
 
425
/*
 
426
 *--------------------------------------------------------------
 
427
 *
 
428
 * init_mb_type_P --
 
429
 *
 
430
 *      Initialize the VLC decoding table for macro_block_type in
 
431
 *      predictive-coded pictures.
 
432
 *
 
433
 * Results:
 
434
 *      The decoding table for macro_block_type in predictive-coded
 
435
 *      pictures will be filled; illegal values will be filled as MPGDECODE_ERROR.
 
436
 *
 
437
 * Side effects:
 
438
 *      The global array mb_type_P will be filled.
 
439
 *
 
440
 *--------------------------------------------------------------
 
441
 */
 
442
static void init_mb_type_P() {
 
443
  int i;
 
444
 
 
445
  mb_type_P[0].mb_quant = mb_type_P[0].mb_motion_forward 
 
446
    = mb_type_P[0].mb_motion_backward = mb_type_P[0].mb_pattern 
 
447
      = mb_type_P[0].mb_intra = (unsigned int)MPGDECODE_ERROR;
 
448
  mb_type_P[0].num_bits = 0;
 
449
 
 
450
  ASSIGN2(1, 2, 1, 0, 0, 0, 1, 6, mb_type_P)
 
451
  ASSIGN2(2, 4, 1, 0, 0, 1, 0, 5, mb_type_P)
 
452
  ASSIGN2(4, 6, 1, 1, 0, 1, 0, 5, mb_type_P);
 
453
  ASSIGN2(6, 8, 0, 0, 0, 0, 1, 5, mb_type_P);
 
454
  ASSIGN2(8, 16, 0, 1, 0, 0, 0, 3, mb_type_P);
 
455
  ASSIGN2(16, 32, 0, 0, 0, 1, 0, 2, mb_type_P);
 
456
  ASSIGN2(32, 64, 0, 1, 0, 1, 0, 1, mb_type_P);
 
457
}
 
458
 
 
459
 
 
460
 
 
461
 
 
462
/*
 
463
 *--------------------------------------------------------------
 
464
 *
 
465
 * init_mb_type_B --
 
466
 *
 
467
 *      Initialize the VLC decoding table for macro_block_type in
 
468
 *      bidirectionally-coded pictures.
 
469
 *
 
470
 * Results:
 
471
 *      The decoding table for macro_block_type in bidirectionally-coded
 
472
 *      pictures will be filled; illegal values will be filled as MPGDECODE_ERROR.
 
473
 *
 
474
 * Side effects:
 
475
 *      The global array mb_type_B will be filled.
 
476
 *
 
477
 *--------------------------------------------------------------
 
478
 */
 
479
static void init_mb_type_B() {
 
480
  int i;
 
481
 
 
482
  mb_type_B[0].mb_quant = mb_type_B[0].mb_motion_forward 
 
483
    = mb_type_B[0].mb_motion_backward = mb_type_B[0].mb_pattern 
 
484
      = mb_type_B[0].mb_intra = (unsigned int) MPGDECODE_ERROR;
 
485
  mb_type_B[0].num_bits = 0;
 
486
 
 
487
  ASSIGN2(1, 2, 1, 0, 0, 0, 1, 6, mb_type_B);
 
488
  ASSIGN2(2, 3, 1, 0, 1, 1, 0, 6, mb_type_B);
 
489
  ASSIGN2(3, 4, 1, 1, 0, 1, 0, 6, mb_type_B);
 
490
  ASSIGN2(4, 6, 1, 1, 1, 1, 0, 5, mb_type_B);
 
491
  ASSIGN2(6, 8, 0, 0, 0, 0, 1, 5, mb_type_B);
 
492
  ASSIGN2(8, 12, 0, 1, 0, 0, 0, 4, mb_type_B);
 
493
  ASSIGN2(12, 16, 0, 1, 0, 1, 0, 4, mb_type_B);
 
494
  ASSIGN2(16, 24, 0, 0, 1, 0, 0, 3, mb_type_B);
 
495
  ASSIGN2(24, 32, 0, 0, 1, 1, 0, 3, mb_type_B);
 
496
  ASSIGN2(32, 48, 0, 1, 1, 0, 0, 2, mb_type_B);
 
497
  ASSIGN2(48, 64, 0, 1, 1, 1, 0, 2, mb_type_B);
 
498
}
 
499
 
 
500
 
 
501
/* Macro for filling up the decoding tables for motion_vectors */
 
502
#define ASSIGN3(start, end, step, val, num) \
 
503
  for (i = start; i < end; i+= step) { \
 
504
    for (j = 0; j < step / 2; j++) { \
 
505
      motion_vectors[i+j].code = val; \
 
506
      motion_vectors[i+j].num_bits = num; \
 
507
    } \
 
508
    for (j = step / 2; j < step; j++) { \
 
509
      motion_vectors[i+j].code = -val; \
 
510
      motion_vectors[i+j].num_bits = num; \
 
511
    } \
 
512
    val--; \
 
513
  }
 
514
 
 
515
 
 
516
 
 
517
/*
 
518
 *--------------------------------------------------------------
 
519
 *
 
520
 * init_motion_vectors --
 
521
 *
 
522
 *      Initialize the VLC decoding table for the various motion
 
523
 *      vectors, including motion_horizontal_forward_code, 
 
524
 *      motion_vertical_forward_code, motion_horizontal_backward_code,
 
525
 *      and motion_vertical_backward_code.
 
526
 *
 
527
 * Results:
 
528
 *      The decoding table for the motion vectors will be filled;
 
529
 *      illegal values will be filled as MPGDECODE_ERROR.
 
530
 *
 
531
 * Side effects:
 
532
 *      The global array motion_vector will be filled.
 
533
 *
 
534
 *--------------------------------------------------------------
 
535
 */
 
536
static void init_motion_vectors()
 
537
{
 
538
  int i, j, val = 16;
 
539
 
 
540
  for (i = 0; i < 24; i++) {
 
541
    motion_vectors[i].code = MPGDECODE_ERROR;
 
542
    motion_vectors[i].num_bits = 0; 
 
543
  }
 
544
 
 
545
  ASSIGN3(24, 36, 2, val, 11);
 
546
  ASSIGN3(36, 48, 4, val, 10);
 
547
  ASSIGN3(48, 96, 16, val, 8);
 
548
  ASSIGN3(96, 128, 32, val, 7);
 
549
  ASSIGN3(128, 256, 128, val, 5);
 
550
  ASSIGN3(256, 512, 256, val, 4);
 
551
  ASSIGN3(512, 1024, 512, val, 3);
 
552
  ASSIGN3(1024, 2048, 1024, val, 1);
 
553
}
 
554
 
 
555
 
 
556
 
 
557
extern void init_pre_idct();
 
558
 
 
559
 
 
560
/*
 
561
 *--------------------------------------------------------------
 
562
 *
 
563
 * init_tables --
 
564
 *
 
565
 *      Initialize all the tables for VLC decoding; this must be
 
566
 *      called when the system is set up before any decoding can
 
567
 *      take place.
 
568
 *
 
569
 * Results:
 
570
 *      All the decoding tables will be filled accordingly.
 
571
 *
 
572
 * Side effects:
 
573
 *      The corresponding global array for each decoding table 
 
574
 *      will be filled.
 
575
 *
 
576
 *--------------------------------------------------------------
 
577
 */    
 
578
void init_tables() {
 
579
  
 
580
  init_mb_addr_inc();
 
581
  init_mb_type_P();
 
582
  init_mb_type_B();
 
583
  init_motion_vectors();
 
584
  
 
585
  if (qualityFlag) {
 
586
    cout << "qualityFlag in init_tables float idct removed"<<endl;
 
587
  }
 
588
  init_pre_idct();
 
589
 
 
590
}
 
591
 
 
592