Statistics
| Branch: | Revision:

ffmpeg / libavcodec / vc9data.h @ 5e424311

History | View | Annotate | Download (13.3 KB)

1
/**
2
 * @file vc9data.h
3
 * VC9 tables.
4
 */
5

    
6
#ifndef VC9DATA_H
7
#define VC9DATA_H
8

    
9
/* Set a method for reading VLC in NORM6 bitplane decoding */
10
#define VLC_NORM6_METH0D    2
11

    
12
/* bfraction is fractional, we scale to the GCD 3*5*7*8 = 840 */
13
const int16_t vc9_bfraction_lut[23] = {
14
  420 /*1/2*/, 280 /*1/3*/, 560 /*2/3*/, 210 /*1/4*/,
15
  630 /*3/4*/, 168 /*1/5*/, 336 /*2/5*/,
16
  504 /*3/5*/, 672 /*4/5*/, 140 /*1/6*/, 700 /*5/6*/,
17
  120 /*1/7*/, 240 /*2/7*/, 360 /*3/7*/, 480 /*4/7*/,
18
  600 /*5/7*/, 720 /*6/7*/, 105 /*1/8*/, 315 /*3/8*/,
19
  525 /*5/8*/, 735 /*7/8*/,
20
  -1 /*inv.*/, 0 /*BI fm*/
21
};
22
const uint8_t vc9_bfraction_bits[23] = {
23
    3, 3, 3, 3,
24
    3, 3, 3,
25
    7, 7, 7, 7,
26
    7, 7, 7, 7,
27
    7, 7, 7, 7,
28
    7, 7,
29
    7, 7
30
};
31
const uint8_t vc9_bfraction_codes[23] = {
32
     0,   1,   2,   3,
33
     4,   5,   6,
34
   112, 113, 114, 115,
35
   116, 117, 118, 119,
36
   120, 121, 122, 123,
37
   124, 125,
38
   126, 127
39
};
40

    
41
//Same as H.264
42
static const AVRational vc9_pixel_aspect[16]={
43
 {0, 1},
44
 {1, 1},
45
 {12, 11},
46
 {10, 11},
47
 {16, 11},
48
 {40, 33},
49
 {24, 11},
50
 {20, 11},
51
 {32, 11},
52
 {80, 33},
53
 {18, 11},
54
 {15, 11},
55
 {64, 33},
56
 {160, 99},
57
 {0, 1},
58
 {0, 1}
59
};
60

    
61
/* BitPlane IMODE - such a small table... */
62
static const uint8_t vc9_imode_codes[7] = {
63
  0, 2, 1, 3, 1, 2, 3
64
};
65
static const uint8_t vc9_imode_bits[7] = {
66
  4, 2, 3, 2, 4, 3, 3
67
};
68

    
69
/* Normal-2 imode */
70
static const uint8_t vc9_norm2_codes[4] = {
71
  0, 4, 5, 3
72
};
73
static const uint8_t vc9_norm2_bits[4] = {
74
  1, 3, 3, 2
75
};
76

    
77
#if VLC_NORM6_METH0D == 1
78
static const uint16_t vc9_norm6_codes[64] = {
79
0x001, 0x002, 0x003, 0x000, 0x004, 0x001, 0x002, 0x047, 0x005, 0x003, 0x004, 0x04B, 0x005, 0x04D, 0x04E, 0x30E, 
80
0x006, 0x006, 0x007, 0x053, 0x008, 0x055, 0x056, 0x30D, 0x009, 0x059, 0x05A, 0x30C, 0x05C, 0x30B, 0x30A, 0x037, 
81
0x007, 0x00A, 0x00B, 0x043, 0x00C, 0x045, 0x046, 0x309, 0x00D, 0x049, 0x04A, 0x308, 0x04C, 0x307, 0x306, 0x036, 
82
0x00E, 0x051, 0x052, 0x305, 0x054, 0x304, 0x303, 0x035, 0x058, 0x302, 0x301, 0x034, 0x300, 0x033, 0x032, 0x007, 
83
};
84

    
85
static const uint8_t vc9_norm6_bits[64] = {
86
 1,  4,  4,  8,  4,  8,  8, 10,  4,  8,  8, 10,  8, 10, 10, 13, 
87
 4,  8,  8, 10,  8, 10, 10, 13,  8, 10, 10, 13, 10, 13, 13,  9, 
88
 4,  8,  8, 10,  8, 10, 10, 13,  8, 10, 10, 13, 10, 13, 13,  9, 
89
 8, 10, 10, 13, 10, 13, 13,  9, 10, 13, 13,  9, 13,  9,  9,  6,
90
};
91
/* Normal-6 imode */
92
static const uint8_t vc9_norm6_spec[64][5] = {
93
{ 0,  1, 1        },
94
{ 1,  2, 4        },
95
{ 2,  3, 4        },
96
{ 3,  0, 8        },
97
{ 4,  4, 4        },
98
{ 5,  1, 8        },
99
{ 6,  2, 8        },
100
{ 7,  2, 5,  7, 5 },
101
{ 8,  5, 4        },
102
{ 9,  3, 8        },
103
{10,  4, 8        },
104
{11,  2, 5, 11, 5 },
105
{12,  5, 8        },
106
{13,  2, 5, 13, 5 },
107
{14,  2, 5, 14, 5 },
108
{15,  3, 5, 14, 8 },
109
{16,  6, 4        },
110
{17,  6, 8        },
111
{18,  7, 8        },
112
{19,  2, 5, 19, 5 },
113
{20,  8, 8        },
114
{21,  2, 5, 21, 5 },
115
{22,  2, 5, 22, 5 },
116
{23,  3, 5, 13, 8 },
117
{24,  9, 8        },
118
{25,  2, 5, 25, 5 },
119
{26,  2, 5, 26, 5 },
120
{27,  3, 5, 12, 8 },
121
{28,  2, 5, 28, 5 },
122
{29,  3, 5, 11, 8 },
123
{30,  3, 5, 10, 8 },
124
{31,  3, 5,  7, 4 },
125
{32,  7, 4        },
126
{33, 10, 8        },
127
{34, 11, 8        },
128
{35,  2, 5,  3, 5 },
129
{36, 12, 8        },
130
{37,  2, 5,  5, 5 },
131
{38,  2, 5,  6, 5 },
132
{39,  3, 5,  9, 8 },
133
{40, 13, 8        },
134
{41,  2, 5,  9, 5 },
135
{42,  2, 5, 10, 5 },
136
{43,  3, 5,  8, 8 },
137
{44,  2, 5, 12, 5 },
138
{45,  3, 5,  7, 8 },
139
{46,  3, 5,  6, 8 },
140
{47,  3, 5,  6, 4 },
141
{48, 14, 8        },
142
{49,  2, 5, 17, 5 },
143
{50,  2, 5, 18, 5 },
144
{51,  3, 5,  5, 8 },
145
{52,  2, 5, 20, 5 },
146
{53,  3, 5,  4, 8 },
147
{54,  3, 5,  3, 8 },
148
{55,  3, 5,  5, 4 },
149
{56,  2, 5, 24, 5 },
150
{57,  3, 5,  2, 8 },
151
{58,  3, 5,  1, 8 },
152
{59,  3, 5,  4, 4 },
153
{60,  3, 5,  0, 8 },
154
{61,  3, 5,  3, 4 },
155
{62,  3, 5,  2, 4 },
156
{63,  3, 5,  1, 1 },
157
};
158
#endif
159

    
160
#if TILE_VLC_METHOD == 2 //Hyper-stupid way to handle sparse tables
161
static const uint8_t vc9_norm6_first[2][64] = {
162
    {  1, 1}, {  2, 4}, {  3, 4}, {  0, 8},
163
    {  4, 4}, {  5, 1}, {  2, 8}, {  2, 5},
164
    {  5, 4}, {  3, 8}, {  4, 8}, {  2, 5},
165
    {  5, 8}, {  2, 5}, {  2, 5}, {  3, 5},
166
    {  6, 4}, {  6, 8}, {  7, 8}, {  2, 5},
167
    {  8, 8}, {  2, 5}, {  2, 5}, {  3, 5},
168
    {  9, 8}, {  2, 5}, {  2, 5}, {  3, 5},
169
    {  2, 5}, {  3, 5}, {  3, 5}, {  3, 5},
170
    {  7, 4}, { 10, 8}, { 11, 8}, {  2, 5},
171
    { 12, 8}, {  2, 5}, {  2, 5}, {  3, 5},
172
    { 13, 8}, {  2, 5}, {  2, 5}, {  3, 5},
173
    {  2, 5}, {  3, 5}, {  3, 5}, {  3, 5},
174
    { 14, 8}, {  2, 5}, {  2, 5}, {  3, 5},
175
    {  2, 5}, {  3, 5}, {  3, 5}, {  3, 5},
176
    {  2, 5}, {  3, 5}, {  3, 5}, {  3, 5},
177
    {  3, 5}, {  3, 5}, {  3, 5}, {  3, 5}
178
};
179

    
180
/* 0=>simple VLC, 1=>VLCFLC, 2=>double VLC */
181
static const int vc9_norm6_mode[64] = {
182
    0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 2,
183
    0, 0, 0, 1, 0, 1, 1, 2, 0, 1, 1, 2, 1, 2, 2, 2,
184
    0, 0, 0, 1, 0, 1, 1, 2, 0, 1, 1, 2, 1, 2, 2, 2,
185
    0, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2
186
};
187
static const uint8_t vc9_norm6_second[22] = {
188
    { 14, 8}, { 13, 8}, { 12, 8}, { 11, 8},
189
    { 10, 8}, {  7, 4}, {  9, 8}, {  8, 8},
190
    {  7, 8}, {  6, 8}, {  6, 4}, {  5, 8},
191
    {  4, 8}, {  3, 8}, {  5, 4}, {  2, 8},
192
    {  1, 8}, {  4, 4}, {  0, 8}, {  3, 4},
193
    {  2, 4}, {  1, 1}
194
};
195
static const uint8_t vc9_norm6_flc_val[20] = {
196
    7, 11, 13, 14, 19, 21, 22, 25,
197
   26, 28, 35, 37, 38, 41, 42, 44,
198
   49, 50, 52, 56
199
};
200
static const uint8_t vc9_norm6_second_val[22] = {
201
   15, 23, 27, 29, 30, 31, 39, 43,
202
   45, 46, 47, 51, 53, 54, 55, 57,
203
   58, 59, 60, 61, 62, 63
204
};
205
#endif
206

    
207
/* 4MV Block pattern VLC tables */
208
static const uint8_t vc9_4mv_block_pattern_codes[4][16] = {
209
  { 14, 58, 59, 25, 12, 26, 15, 15, 13, 24, 27,  0, 28,  1,  2,  2},
210
  {  8, 18, 19,  4, 20,  5, 30, 11, 21, 31,  6, 12,  7, 13, 14,  0},
211
  { 15,  6,  7,  2,  8,  3, 28,  9, 10, 29,  4, 11,  5, 12, 13,  0},
212
  {  0, 11, 12,  4, 13,  5, 30, 16, 14, 31,  6, 17,  7, 18, 19, 19}
213
};
214
static const uint8_t vc9_4mv_block_pattern_bits[4][16] = {
215
  { 5, 6, 6, 5, 5, 5, 5, 4, 5, 5, 5, 3, 5, 3, 3, 2},
216
  { 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4, 4, 4, 4, 4, 2},
217
  { 4, 4, 4, 4, 4, 4, 5, 4, 4, 5, 4, 4, 4, 4, 4, 3},
218
  { 2, 4, 4, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4}
219
};
220

    
221
const uint8_t wmv3_dc_scale_table[32]={
222
    0, 4, 6, 8, 8, 8, 9, 9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21
223
};
224

    
225
/* P-Picture CBPCY VLC tables */
226
static const uint16_t vc9_cbpcy_p_codes[4][64] = {
227
  {
228
      0,   1,   1,   4,   5,   1,  12,   4,  13,  14,  10,  11,  12,   7,  13,   2,
229
     15,   1,  96,   1,  49,  97,   2, 100,   3,   4,   5, 101, 102,  52,  53,   4,
230
      6,   7,  54, 103,   8,   9,  10, 110,  11,  12, 111,  56, 114,  58, 115,   5,
231
     13,   7,   8,   9,  10,  11,  12,  30,  13,  14,  15, 118, 119,  62,  63,   3
232
  },
233
  {
234
      0,   1,   2,   1,   3,   1,  16,  17,   5,  18,  12,  19,  13,   1,  28,  58,
235
      1,   1,   1,   2,   3,   2,   3, 236, 237,   4,   5, 238,   6,   7, 239,   8,
236
      9, 240,  10,  11, 121, 122,  12,  13,  14,  15, 241, 246,  16,  17, 124,  63,
237
     18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31, 247, 125
238
  },
239
  {
240
      0,   1,   2,   3,   2,   3,   1,   4,   5,  24,   7,  13,  16,  17,   9,   5,
241
     25,   1,   1,   1,   2,   3,  96, 194,   1,   2,  98,  99, 195, 200, 101,  26,
242
    201, 102, 412, 413, 414,  54, 220, 111, 221,   3, 224, 113, 225, 114, 230,  29,
243
    231, 415, 240,   4, 241, 484,   5, 243,   3, 244, 245, 485, 492, 493, 247,  31
244
  },
245
  {
246
      0,   1,   1,   1,   2,   2,   3,   4,   3,   5,   6,   7,   8,   9,  10,  11,
247
     12,  13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,
248
     28,  29,  30,  31,  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,
249
     44,  45,  46,  47,  48,  49,  50,  51,  52,  53,  54,  55,  28,  29,  30,  31
250
   }
251
};
252
static const uint8_t vc9_cbpcy_p_bits[4][64] = {
253
  {
254
    13,  6,  5,  6,  6,  7,  7,  5,  7,  7,  6,  6,  6,  5,  6,  3,
255
     7,  8,  8, 13,  7,  8, 13,  8, 13, 13, 13,  8,  8,  7,  7,  3,
256
    13, 13,  7,  8, 13, 13, 13,  8, 13, 13,  8,  7,  8,  7,  8,  3,
257
    13, 12, 12, 12, 12, 12, 12,  6, 12, 12, 12,  8,  8,  7,  7,  2
258
  },
259
  {
260
    14,  3,  3,  5,  3,  4,  5,  5,  3,  5,  4,  5,  4,  6,  5,  6,
261
     8, 14, 13,  8,  8, 13, 13,  8,  8, 13, 13,  8, 13, 13,  8, 13,
262
    13,  8, 13, 13,  7,  7, 13, 13, 13, 13,  8,  8, 13, 13,  7,  6,
263
    13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,  8,  7
264
  },
265
  {
266
    13,  5,  5,  5,  4,  4,  6,  4,  4,  6,  4,  5,  5,  5,  4,  3,
267
     6,  8, 10,  9,  8,  8,  7,  8, 13, 13,  7,  7,  8,  8,  7,  5,
268
     8,  7,  9,  9,  9,  6,  8,  7,  8, 13,  8,  7,  8,  7,  8,  5,
269
     8,  9,  8, 13,  8,  9, 13,  8, 12,  8,  8,  9,  9,  9,  8,  5
270
  },
271
  {
272
     9,  2,  3,  9,  2,  9,  9,  9,  2,  9,  9,  9,  9,  9,  9,  9,
273
     9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,
274
     9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,
275
     9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  8,  8,  8,  8
276
  }
277
};
278

    
279
/* MacroBlock Transform Type: 7.1.3.11, p89
280
 * 8x8:B
281
 * 8x4:B:btm  8x4:B:top  8x4:B:both,
282
 * 4x8:B:right  4x8:B:left  4x8:B:both
283
 * 4x4:B  8x8:MB
284
 * 8x4:MB:btm  8x4:MB:top  8x4,MB,both
285
 * 4x8,MB,right  4x8,MB,left
286
 * 4x4,MB                               */
287
static const uint16_t vc9_ttmb_codes[3][16] = {
288
  {
289
    0x0003,
290
    0x002E, 0x005F, 0x0000,
291
    0x0016, 0x0015, 0x0001,
292
    0x0004, 0x0014,
293
    0x02F1, 0x0179, 0x017B,
294
    0x0BC0, 0x0BC1, 0x05E1,
295
    0x017A
296
  },
297
  {
298
    0x0006,
299
    0x0006, 0x0003, 0x0007,
300
    0x000F, 0x000E, 0x0000,
301
    0x0002, 0x0002,
302
    0x0014, 0x0011, 0x000B,
303
    0x0009, 0x0021, 0x0015,
304
    0x0020
305
  },
306
  {
307
    0x0006,
308
    0x0000, 0x000E, 0x0005,
309
    0x0002, 0x0003, 0x0003,
310
    0x000F, 0x0002,
311
    0x0081, 0x0021, 0x0009,
312
    0x0101, 0x0041, 0x0011,
313
    0x0100
314
  }
315
};
316

    
317
static const uint8_t vc9_ttmb_bits[3][16] = {
318
  {
319
     2,
320
     6,  7,  2,
321
     5,  5,  2,
322
     3,  5,
323
    10,  9,  9,
324
    12, 12, 11,
325
     9
326
  },
327
  {
328
    3,
329
    4, 4, 4,
330
    4, 4, 3,
331
    3, 2,
332
    7, 7, 6,
333
    6, 8, 7,
334
    8
335
  },
336
  {
337
     3,
338
     3, 4, 5,
339
     3, 3, 4,
340
     4, 2,
341
    10, 8, 6,
342
    11, 9, 7,
343
    11
344
  }
345
};  
346

    
347

    
348
/* MV differential tables, p265 */
349
static const uint16_t vc9_mv_diff_codes[4][73] = {
350
  {
351
       0,    2,    3,    8,  576,    3,    2,    6,
352
       5,  577,  578,    7,    8,    9,   40,   19,
353
      37,   82,   21,   22,   23,  579,  580,  166,
354
      96,  167,   49,  194,  195,  581,  582,  583,
355
     292,  293,  294,   13,    2,    7,   24,   50,
356
     102,  295,   13,    7,    8,   18,   50,  103,
357
      38,   20,   21,   22,   39,  204,  103,   23,
358
      24,   25,  104,  410,  105,  106,  107,  108,
359
     109,  220,  411,  442,  222,  443,  446,  447,
360
       7 /* 73 elements */
361
  },
362
  {
363
       0,    4,    5,    3,    4,    3,    4,    5,
364
      20,    6,   21,   44,   45,   46, 3008,   95,
365
     112,  113,   57, 3009, 3010,  116,  117, 3011,
366
     118, 3012, 3013, 3014, 3015, 3016, 3017, 3018,
367
    3019, 3020, 3021, 3022,    1,    4,   15,  160,
368
     161,   41,    6,   11,   42,  162,   43,  119,
369
      56,   57,   58,  163,  236,  237, 3023,  119,
370
     120,  242,  122,  486, 1512,  487,  246,  494,
371
    1513,  495, 1514, 1515, 1516, 1517, 1518, 1519,
372
      31 /* 73 elements */
373
  },
374
  {
375
       0,  512,  513,  514,  515,    2,    3,  258,
376
     259,  260,  261,  262,  263,  264,  265,  266,
377
     267,  268,  269,  270,  271,  272,  273,  274,
378
     275,  276,  277,  278,  279,  280,  281,  282,
379
     283,  284,  285,  286,    1,    5,  287,  288,
380
     289,  290,    6,    7,  291,  292,  293,  294,
381
     295,  296,  297,  298,  299,  300,  301,  302,
382
     303,  304,  305,  306,  307,  308,  309,  310,
383
     311,  312,  313,  314,  315,  316,  317,  318,
384
     319 /* 73 elements */
385
  },
386
  {
387
       0,    1,    1,    2,    3,    4,    1,    5,
388
       4,    3,    5,    8,    6,    9,   10,   11,
389
      12,    7,  104,   14,  105,    4,   10,   15,
390
      11,    6,   14,    8,  106,  107,  108,   15,
391
     109,    9,   55,   10,    1,    2,    1,    2,
392
       3,   12,    6,    2,    6,    7,   28,    7,
393
      15,    8,    5,   18,   29,  152,   77,   24,
394
      25,   26,   39,  108,   13,  109,   55,   56,
395
      57,  116,   11,  153,  234,  235,  118,  119,
396
      15 /* 73 elements */
397
  }
398
};
399
static const uint8_t vc9_mv_diff_bits[4][73] = {
400
  {
401
     6,  7,  7,  8, 14,  6,  5,  6,  7, 14, 14,  6,  6,  6,  8,  9,
402
    10,  9,  7,  7,  7, 14, 14, 10,  9, 10,  8, 10, 10, 14, 14, 14,
403
    13, 13, 13,  6,  3,  5,  6,  8,  9, 13,  5,  4,  4,  5,  7,  9,
404
     6,  5,  5,  5,  6,  9,  8,  5,  5,  5,  7, 10,  7,  7,  7,  7,
405
     7,  8, 10,  9,  8,  9,  9,  9,  3 /* 73 elements */
406
  },
407
  {
408
     5,  7,  7,  6,  6,  5,  5,  6,  7,  5,  7,  8,  8,  8, 14,  9,
409
     9,  9,  8, 14, 14,  9,  9, 14,  9, 14, 14, 14, 14, 14, 14, 14,
410
    14, 14, 14, 14,  2,  3,  6,  8,  8,  6,  3,  4,  6,  8,  6,  9,
411
     6,  6,  6,  8,  8,  8, 14,  7,  7,  8,  7,  9, 13,  9,  8,  9,
412
    13,  9, 13, 13, 13, 13, 13, 13,  5 /* 73 elements */
413
     
414
  },
415
  {
416
     3, 12, 12, 12, 12,  3,  4, 11, 11, 11, 11, 11, 11, 11, 11, 11,
417
    11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
418
    11, 11, 11, 11,  1,  5, 11, 11, 11, 11,  4,  4, 11, 11, 11, 11,
419
    11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
420
    11, 11, 11, 11, 11, 11, 11, 11, 11 /* 73 elements */
421
  },
422
  {
423
    15, 11, 15, 15, 15, 15, 12, 15, 12, 11, 12, 12, 15, 12, 12, 12,
424
    12, 15, 15, 12, 15, 10, 11, 12, 11, 10, 11, 10, 15, 15, 15, 11,
425
    15, 10, 14, 10,  4,  4,  5,  7,  8,  9,  5,  3,  4,  5,  6,  8,
426
     5,  4,  3,  5,  6,  8,  7,  5,  5,  5,  6,  7,  9,  7,  6,  6,
427
     6,  7, 10,  8,  8,  8,  7,  7,  4 /* 73 elements */
428
  }
429
};
430

    
431
/* DC differentials low+hi-mo, p217 are the same as in msmpeg4data .h */
432

    
433
/* Scantables/ZZ scan are at 11.9 (p262) and 8.1.1.12 (p10) */
434

    
435
#endif /* VC9DATA_H */