Statistics
| Branch: | Revision:

ffmpeg / libavcodec / mpeg12data.h @ d771bcae

History | View | Annotate | Download (9.41 KB)

1 de6d9b64 Fabrice Bellard
/*
2
 * MPEG1/2 tables
3
 */
4
5
const UINT8 default_intra_matrix[64] = {
6
        8, 16, 19, 22, 26, 27, 29, 34,
7
        16, 16, 22, 24, 27, 29, 34, 37,
8
        19, 22, 26, 27, 29, 34, 34, 38,
9
        22, 22, 26, 27, 29, 34, 37, 40,
10
        22, 26, 27, 29, 32, 35, 40, 48,
11
        26, 27, 29, 32, 35, 40, 48, 58,
12
        26, 27, 29, 34, 38, 46, 56, 69,
13
        27, 29, 35, 38, 46, 56, 69, 83
14
};
15
16
const UINT8 default_non_intra_matrix[64] = {
17
    16, 16, 16, 16, 16, 16, 16, 16,
18
    16, 16, 16, 16, 16, 16, 16, 16,
19
    16, 16, 16, 16, 16, 16, 16, 16,
20
    16, 16, 16, 16, 16, 16, 16, 16,
21
    16, 16, 16, 16, 16, 16, 16, 16,
22
    16, 16, 16, 16, 16, 16, 16, 16,
23
    16, 16, 16, 16, 16, 16, 16, 16,
24
    16, 16, 16, 16, 16, 16, 16, 16,
25
};
26
27
const unsigned char vlc_dc_table[256] = {
28
    0, 1, 2, 2,
29
    3, 3, 3, 3,
30
    4, 4, 4, 4, 4, 4, 4, 4,
31
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
32
    6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
33
    6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
34
35
    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
36
    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
37
    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
38
    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
39
40
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
41
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
42
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
43
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
44
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
45
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
46
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
47
    8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
48
};
49
50
const UINT16 vlc_dc_lum_code[12] = {
51
    0x4, 0x0, 0x1, 0x5, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe, 0x1ff,
52
};
53
const unsigned char vlc_dc_lum_bits[12] = {
54
    3, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 9,
55
};
56
57
const UINT16 vlc_dc_chroma_code[12] = {
58
    0x0, 0x1, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe, 0x3fe, 0x3ff,
59
};
60
const unsigned char vlc_dc_chroma_bits[12] = {
61
    2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10,
62
};
63
64
static const UINT16 mpeg1_vlc[113][2] = {
65
 { 0x3, 2 }, { 0x4, 4 }, { 0x5, 5 }, { 0x6, 7 },
66
 { 0x26, 8 }, { 0x21, 8 }, { 0xa, 10 }, { 0x1d, 12 },
67
 { 0x18, 12 }, { 0x13, 12 }, { 0x10, 12 }, { 0x1a, 13 },
68
 { 0x19, 13 }, { 0x18, 13 }, { 0x17, 13 }, { 0x1f, 14 },
69
 { 0x1e, 14 }, { 0x1d, 14 }, { 0x1c, 14 }, { 0x1b, 14 },
70
 { 0x1a, 14 }, { 0x19, 14 }, { 0x18, 14 }, { 0x17, 14 },
71
 { 0x16, 14 }, { 0x15, 14 }, { 0x14, 14 }, { 0x13, 14 },
72
 { 0x12, 14 }, { 0x11, 14 }, { 0x10, 14 }, { 0x18, 15 },
73
 { 0x17, 15 }, { 0x16, 15 }, { 0x15, 15 }, { 0x14, 15 },
74
 { 0x13, 15 }, { 0x12, 15 }, { 0x11, 15 }, { 0x10, 15 },
75
 { 0x3, 3 }, { 0x6, 6 }, { 0x25, 8 }, { 0xc, 10 },
76
 { 0x1b, 12 }, { 0x16, 13 }, { 0x15, 13 }, { 0x1f, 15 },
77
 { 0x1e, 15 }, { 0x1d, 15 }, { 0x1c, 15 }, { 0x1b, 15 },
78
 { 0x1a, 15 }, { 0x19, 15 }, { 0x13, 16 }, { 0x12, 16 },
79
 { 0x11, 16 }, { 0x10, 16 }, { 0x5, 4 }, { 0x4, 7 },
80
 { 0xb, 10 }, { 0x14, 12 }, { 0x14, 13 }, { 0x7, 5 },
81
 { 0x24, 8 }, { 0x1c, 12 }, { 0x13, 13 }, { 0x6, 5 },
82
 { 0xf, 10 }, { 0x12, 12 }, { 0x7, 6 }, { 0x9, 10 },
83
 { 0x12, 13 }, { 0x5, 6 }, { 0x1e, 12 }, { 0x14, 16 },
84
 { 0x4, 6 }, { 0x15, 12 }, { 0x7, 7 }, { 0x11, 12 },
85
 { 0x5, 7 }, { 0x11, 13 }, { 0x27, 8 }, { 0x10, 13 },
86
 { 0x23, 8 }, { 0x1a, 16 }, { 0x22, 8 }, { 0x19, 16 },
87
 { 0x20, 8 }, { 0x18, 16 }, { 0xe, 10 }, { 0x17, 16 },
88
 { 0xd, 10 }, { 0x16, 16 }, { 0x8, 10 }, { 0x15, 16 },
89
 { 0x1f, 12 }, { 0x1a, 12 }, { 0x19, 12 }, { 0x17, 12 },
90
 { 0x16, 12 }, { 0x1f, 13 }, { 0x1e, 13 }, { 0x1d, 13 },
91
 { 0x1c, 13 }, { 0x1b, 13 }, { 0x1f, 16 }, { 0x1e, 16 },
92
 { 0x1d, 16 }, { 0x1c, 16 }, { 0x1b, 16 },
93
 { 0x1, 6 }, /* escape */
94
 { 0x2, 2 }, /* EOB */
95
};
96
97
static const UINT16 mpeg2_vlc[113][2] = {
98
  {0x02, 2}, {0x06, 3}, {0x07, 4}, {0x1c, 5},
99
  {0x1d, 5}, {0x05, 6}, {0x04, 6}, {0x7b, 7},
100
  {0x7c, 7}, {0x23, 8}, {0x22, 8}, {0xfa, 8},
101
  {0xfb, 8}, {0xfe, 8}, {0xff, 8}, {0x1f,14},
102
  {0x1e,14}, {0x1d,14}, {0x1c,14}, {0x1b,14},
103
  {0x1a,14}, {0x19,14}, {0x18,14}, {0x17,14},
104
  {0x16,14}, {0x15,14}, {0x14,14}, {0x13,14},
105
  {0x12,14}, {0x11,14}, {0x10,14}, {0x18,15},
106
  {0x17,15}, {0x16,15}, {0x15,15}, {0x14,15},
107
  {0x13,15}, {0x12,15}, {0x11,15}, {0x10,15},
108
  {0x02, 3}, {0x06, 5}, {0x79, 7}, {0x27, 8},
109
  {0x20, 8}, {0x16,13}, {0x15,13}, {0x1f,15},
110
  {0x1e,15}, {0x1d,15}, {0x1c,15}, {0x1b,15},
111
  {0x1a,15}, {0x19,15}, {0x13,16}, {0x12,16},
112
  {0x11,16}, {0x10,16}, {0x05, 5}, {0x07, 7}, 
113
  {0xfc, 8}, {0x0c,10}, {0x14,13}, {0x07, 5}, 
114
  {0x26, 8}, {0x1c,12}, {0x13,13}, {0x06, 6}, 
115
  {0xfd, 8}, {0x12,12}, {0x07, 6}, {0x04, 9}, 
116
  {0x12,13}, {0x06, 7}, {0x1e,12}, {0x14,16}, 
117
  {0x04, 7}, {0x15,12}, {0x05, 7}, {0x11,12}, 
118
  {0x78, 7}, {0x11,13}, {0x7a, 7}, {0x10,13}, 
119
  {0x21, 8}, {0x1a,16}, {0x25, 8}, {0x19,16}, 
120
  {0x24, 8}, {0x18,16}, {0x05, 9}, {0x17,16}, 
121
  {0x07, 9}, {0x16,16}, {0x0d,10}, {0x15,16}, 
122
  {0x1f,12}, {0x1a,12}, {0x19,12}, {0x17,12}, 
123
  {0x16,12}, {0x1f,13}, {0x1e,13}, {0x1d,13}, 
124
  {0x1c,13}, {0x1b,13}, {0x1f,16}, {0x1e,16}, 
125
  {0x1d,16}, {0x1c,16}, {0x1b,16}, 
126
  {0x01,6}, /* escape */
127
  {0x06,4}, /* EOB */
128
};
129
130
static const UINT8 mpeg1_level[111] = {
131
  1,  2,  3,  4,  5,  6,  7,  8,
132
  9, 10, 11, 12, 13, 14, 15, 16,
133
 17, 18, 19, 20, 21, 22, 23, 24,
134
 25, 26, 27, 28, 29, 30, 31, 32,
135
 33, 34, 35, 36, 37, 38, 39, 40,
136
  1,  2,  3,  4,  5,  6,  7,  8,
137
  9, 10, 11, 12, 13, 14, 15, 16,
138
 17, 18,  1,  2,  3,  4,  5,  1,
139
  2,  3,  4,  1,  2,  3,  1,  2,
140
  3,  1,  2,  3,  1,  2,  1,  2,
141
  1,  2,  1,  2,  1,  2,  1,  2,
142
  1,  2,  1,  2,  1,  2,  1,  2,
143
  1,  1,  1,  1,  1,  1,  1,  1,
144
  1,  1,  1,  1,  1,  1,  1,
145
};
146
147
static const UINT8 mpeg1_run[111] = {
148
  0,  0,  0,  0,  0,  0,  0,  0,
149
  0,  0,  0,  0,  0,  0,  0,  0,
150
  0,  0,  0,  0,  0,  0,  0,  0,
151
  0,  0,  0,  0,  0,  0,  0,  0,
152
  0,  0,  0,  0,  0,  0,  0,  0,
153
  1,  1,  1,  1,  1,  1,  1,  1,
154
  1,  1,  1,  1,  1,  1,  1,  1,
155
  1,  1,  2,  2,  2,  2,  2,  3,
156
  3,  3,  3,  4,  4,  4,  5,  5,
157
  5,  6,  6,  6,  7,  7,  8,  8,
158
  9,  9, 10, 10, 11, 11, 12, 12,
159
 13, 13, 14, 14, 15, 15, 16, 16,
160
 17, 18, 19, 20, 21, 22, 23, 24,
161
 25, 26, 27, 28, 29, 30, 31,
162
};
163
164
static RLTable rl_mpeg1 = {
165
    111,
166
    111,
167
    mpeg1_vlc,
168
    mpeg1_run,
169
    mpeg1_level,
170
};
171
172
static RLTable rl_mpeg2 = {
173
    111,
174
    111,
175
    mpeg2_vlc,
176
    mpeg1_run,
177
    mpeg1_level,
178
};
179
180
static const UINT8 mbAddrIncrTable[35][2] = {
181
    {0x1, 1},
182
    {0x3, 3},
183
    {0x2, 3},
184
    {0x3, 4},
185
    {0x2, 4},
186
    {0x3, 5},
187
    {0x2, 5},
188
    {0x7, 7},
189
    {0x6, 7},
190
    {0xb, 8},
191
    {0xa, 8},
192
    {0x9, 8},
193
    {0x8, 8},
194
    {0x7, 8},
195
    {0x6, 8},
196
    {0x17, 10},
197
    {0x16, 10},
198
    {0x15, 10},
199
    {0x14, 10},
200
    {0x13, 10},
201
    {0x12, 10},
202
    {0x23, 11},
203
    {0x22, 11},
204
    {0x21, 11},
205
    {0x20, 11},
206
    {0x1f, 11},
207
    {0x1e, 11},
208
    {0x1d, 11},
209
    {0x1c, 11},
210
    {0x1b, 11},
211
    {0x1a, 11},
212
    {0x19, 11},
213
    {0x18, 11},
214
    {0x8, 11}, /* escape */
215
    {0xf, 11}, /* stuffing */
216
};
217
218
static const UINT8 mbPatTable[63][2] = {
219
    {0xb, 5},
220
    {0x9, 5},
221
    {0xd, 6},
222
    {0xd, 4},
223
    {0x17, 7},
224
    {0x13, 7},
225
    {0x1f, 8},
226
    {0xc, 4},
227
    {0x16, 7},
228
    {0x12, 7},
229
    {0x1e, 8},
230
    {0x13, 5},
231
    {0x1b, 8},
232
    {0x17, 8},
233
    {0x13, 8},
234
    {0xb, 4},
235
    {0x15, 7},
236
    {0x11, 7},
237
    {0x1d, 8},
238
    {0x11, 5},
239
    {0x19, 8},
240
    {0x15, 8},
241
    {0x11, 8},
242
    {0xf, 6},
243
    {0xf, 8},
244
    {0xd, 8},
245
    {0x3, 9},
246
    {0xf, 5},
247
    {0xb, 8},
248
    {0x7, 8},
249
    {0x7, 9},
250
    {0xa, 4},
251
    {0x14, 7},
252
    {0x10, 7},
253
    {0x1c, 8},
254
    {0xe, 6},
255
    {0xe, 8},
256
    {0xc, 8},
257
    {0x2, 9},
258
    {0x10, 5},
259
    {0x18, 8},
260
    {0x14, 8},
261
    {0x10, 8},
262
    {0xe, 5},
263
    {0xa, 8},
264
    {0x6, 8},
265
    {0x6, 9},
266
    {0x12, 5},
267
    {0x1a, 8},
268
    {0x16, 8},
269
    {0x12, 8},
270
    {0xd, 5},
271
    {0x9, 8},
272
    {0x5, 8},
273
    {0x5, 9},
274
    {0xc, 5},
275
    {0x8, 8},
276
    {0x4, 8},
277
    {0x4, 9},
278
    {0x7, 3},
279
    {0xa, 5},
280
    {0x8, 5},
281
    {0xc, 6}
282
};
283
284
#define MB_INTRA 0x01
285
#define MB_PAT   0x02
286
#define MB_BACK  0x04
287
#define MB_FOR   0x08
288
#define MB_QUANT 0x10  
289
290
static const UINT8 table_mb_ptype[32][2] = {
291
    [ MB_FOR|MB_PAT ] { 1, 1 },
292
    [ MB_PAT ] { 1, 2 },
293
    [ MB_FOR ] { 1, 3 },
294
    [ MB_INTRA ] { 3, 5 },
295
    [ MB_QUANT|MB_FOR|MB_PAT ] { 2, 5 },
296
    [ MB_QUANT|MB_PAT ] { 1, 5 },
297
    [ MB_QUANT|MB_INTRA ] { 1, 6 },
298
};
299
300
static const UINT8 table_mb_btype[32][2] = {
301
    [ MB_FOR|MB_BACK ] { 2, 2 },
302
    [ MB_FOR|MB_BACK|MB_PAT ] { 3, 2 },
303
    [ MB_BACK ] { 2, 3 },
304
    [ MB_BACK|MB_PAT ] { 3, 3 },
305
    [ MB_FOR ] { 2, 4 },
306
    [ MB_FOR|MB_PAT ] { 3, 4 },
307
    [ MB_INTRA ] { 3, 5 },
308
    [ MB_QUANT|MB_FOR|MB_BACK|MB_PAT ] { 2, 5 },
309
    [ MB_QUANT|MB_FOR|MB_PAT ] { 3, 6 },
310
    [ MB_QUANT|MB_BACK|MB_PAT ] { 2, 6 },
311
    [ MB_QUANT|MB_INTRA ] { 1, 6 },
312
};
313
314
static const UINT8 mbMotionVectorTable[17][2] = {
315
{ 0x1, 1 },
316
{ 0x1, 2 },
317
{ 0x1, 3 },
318
{ 0x1, 4 },
319
{ 0x3, 6 },
320
{ 0x5, 7 },
321
{ 0x4, 7 },
322
{ 0x3, 7 },
323
{ 0xb, 9 },
324
{ 0xa, 9 },
325
{ 0x9, 9 },
326
{ 0x11, 10 },
327
{ 0x10, 10 },
328
{ 0xf, 10 },
329
{ 0xe, 10 },
330
{ 0xd, 10 },
331
{ 0xc, 10 },
332
};
333
334
const UINT8 zigzag_direct[64] = {
335
    0, 1, 8, 16, 9, 2, 3, 10,
336
    17, 24, 32, 25, 18, 11, 4, 5,
337
    12, 19, 26, 33, 40, 48, 41, 34,
338
    27, 20, 13, 6, 7, 14, 21, 28,
339
    35, 42, 49, 56, 57, 50, 43, 36,
340
    29, 22, 15, 23, 30, 37, 44, 51,
341
    58, 59, 52, 45, 38, 31, 39, 46,
342
    53, 60, 61, 54, 47, 55, 62, 63
343
};
344
345
static const int frame_rate_tab[9] = {
346
    0, 
347
    (int)(23.976 * FRAME_RATE_BASE), 
348
    (int)(24 * FRAME_RATE_BASE), 
349
    (int)(25 * FRAME_RATE_BASE), 
350
    (int)(29.97 * FRAME_RATE_BASE), 
351
    (int)(30 * FRAME_RATE_BASE), 
352
    (int)(50 * FRAME_RATE_BASE), 
353
    (int)(59.94 * FRAME_RATE_BASE), 
354
    (int)(60 * FRAME_RATE_BASE), 
355
};
356
357
static const UINT8 non_linear_qscale[32] = {
358
    0, 1, 2, 3, 4, 5, 6, 7,
359
    8,10,12,14,16,18,20,22,
360
    24,28,32,36,40,44,48,52,
361
    56,64,72,80,88,96,104,112,
362
};