Revision 986a865f

View differences:

libavcodec/Makefile
157 157
OBJS-$(CONFIG_TSCC_DECODER)            += tscc.o
158 158
OBJS-$(CONFIG_TTA_DECODER)             += tta.o
159 159
OBJS-$(CONFIG_ULTI_DECODER)            += ulti.o
160
OBJS-$(CONFIG_VC1_DECODER)             += vc1.o vc1dsp.o
160
OBJS-$(CONFIG_VC1_DECODER)             += vc1.o vc1data.o vc1dsp.o
161 161
OBJS-$(CONFIG_VCR1_DECODER)            += vcr1.o
162 162
OBJS-$(CONFIG_VCR1_ENCODER)            += vcr1.o
163 163
OBJS-$(CONFIG_VMDAUDIO_DECODER)        += vmdav.o
......
174 174
OBJS-$(CONFIG_WMAV2_DECODER)           += wmadec.o wma.o
175 175
OBJS-$(CONFIG_WMAV1_ENCODER)           += wmaenc.o wma.o
176 176
OBJS-$(CONFIG_WMAV2_ENCODER)           += wmaenc.o wma.o
177
OBJS-$(CONFIG_WMV3_DECODER)            += vc1.o vc1dsp.o
177
OBJS-$(CONFIG_WMV3_DECODER)            += vc1.o vc1data.o vc1dsp.o
178 178
OBJS-$(CONFIG_WNV1_DECODER)            += wnv1.o
179 179
OBJS-$(CONFIG_WS_SND1_DECODER)         += ws-snd1.o
180 180
OBJS-$(CONFIG_XAN_DPCM_DECODER)        += dpcm.o
libavcodec/vc1data.c
1
/*
2
 * VC-1 and WMV3 decoder
3
 * copyright (c) 2006 Konstantin Shishkov
4
 * (c) 2005 anonymous, Alex Beregszaszi, Michael Niedermayer
5
 *
6
 * This file is part of FFmpeg.
7
 *
8
 * FFmpeg is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU Lesser General Public
10
 * License as published by the Free Software Foundation; either
11
 * version 2.1 of the License, or (at your option) any later version.
12
 *
13
 * FFmpeg is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 * Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public
19
 * License along with FFmpeg; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
 */
22

  
23
/**
24
 * @file vc1data.c
25
 * VC-1 tables.
26
 */
27

  
28
#include "avcodec.h"
29
#include "vc1.h"
30
#include "vc1data.h"
31

  
32
/** Table for conversion between TTBLK and TTMB */
33
const int ttblk_to_tt[3][8] = {
34
  { TT_8X4, TT_4X8, TT_8X8, TT_4X4, TT_8X4_TOP, TT_8X4_BOTTOM, TT_4X8_RIGHT, TT_4X8_LEFT },
35
  { TT_8X8, TT_4X8_RIGHT, TT_4X8_LEFT, TT_4X4, TT_8X4, TT_4X8, TT_8X4_BOTTOM, TT_8X4_TOP },
36
  { TT_8X8, TT_4X8, TT_4X4, TT_8X4_BOTTOM, TT_4X8_RIGHT, TT_4X8_LEFT, TT_8X4, TT_8X4_TOP }
37
};
38

  
39
const int ttfrm_to_tt[4] = { TT_8X8, TT_8X4, TT_4X8, TT_4X4 };
40

  
41
/** MV P mode - the 5th element is only used for mode 1 */
42
const uint8_t mv_pmode_table[2][5] = {
43
  { MV_PMODE_1MV_HPEL_BILIN, MV_PMODE_1MV, MV_PMODE_1MV_HPEL, MV_PMODE_INTENSITY_COMP, MV_PMODE_MIXED_MV },
44
  { MV_PMODE_1MV, MV_PMODE_MIXED_MV, MV_PMODE_1MV_HPEL, MV_PMODE_INTENSITY_COMP, MV_PMODE_1MV_HPEL_BILIN }
45
};
46
const uint8_t mv_pmode_table2[2][4] = {
47
  { MV_PMODE_1MV_HPEL_BILIN, MV_PMODE_1MV, MV_PMODE_1MV_HPEL, MV_PMODE_MIXED_MV },
48
  { MV_PMODE_1MV, MV_PMODE_MIXED_MV, MV_PMODE_1MV_HPEL, MV_PMODE_1MV_HPEL_BILIN }
49
};
50

  
51
const int fps_nr[5] = { 24, 25, 30, 50, 60 },
52
  fps_dr[2] = { 1000, 1001 };
53
const uint8_t pquant_table[3][32] = {
54
  {  /* Implicit quantizer */
55
     0,  1,  2,  3,  4,  5,  6,  7,  8,  6,  7,  8,  9, 10, 11, 12,
56
    13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 29, 31
57
  },
58
  {  /* Explicit quantizer, pquantizer uniform */
59
     0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
60
    16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
61
  },
62
  {  /* Explicit quantizer, pquantizer non-uniform */
63
     0,  1,  1,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13,
64
    14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 29, 31
65
  }
66
};
67

  
68
/** @name VC-1 VLC tables and defines
69
 *  @todo TODO move this into the context
70
 */
71
//@{
72
#define VC1_BFRACTION_VLC_BITS 7
73
VLC vc1_bfraction_vlc;
74
#define VC1_IMODE_VLC_BITS 4
75
VLC vc1_imode_vlc;
76
#define VC1_NORM2_VLC_BITS 3
77
VLC vc1_norm2_vlc;
78
#define VC1_NORM6_VLC_BITS 9
79
VLC vc1_norm6_vlc;
80
/* Could be optimized, one table only needs 8 bits */
81
#define VC1_TTMB_VLC_BITS 9 //12
82
VLC vc1_ttmb_vlc[3];
83
#define VC1_MV_DIFF_VLC_BITS 9 //15
84
VLC vc1_mv_diff_vlc[4];
85
#define VC1_CBPCY_P_VLC_BITS 9 //14
86
VLC vc1_cbpcy_p_vlc[4];
87
#define VC1_4MV_BLOCK_PATTERN_VLC_BITS 6
88
VLC vc1_4mv_block_pattern_vlc[4];
89
#define VC1_TTBLK_VLC_BITS 5
90
VLC vc1_ttblk_vlc[3];
91
#define VC1_SUBBLKPAT_VLC_BITS 6
92
VLC vc1_subblkpat_vlc[3];
93

  
94
VLC vc1_ac_coeff_table[8];
95
//@}
96

  
97

  
98
#if B_FRACTION_DEN==840 //original bfraction from vc9data.h, not conforming to standard
99
/* bfraction is fractional, we scale to the GCD 3*5*7*8 = 840 */
100
const int16_t vc1_bfraction_lut[23] = {
101
  420 /*1/2*/, 280 /*1/3*/, 560 /*2/3*/, 210 /*1/4*/,
102
  630 /*3/4*/, 168 /*1/5*/, 336 /*2/5*/,
103
  504 /*3/5*/, 672 /*4/5*/, 140 /*1/6*/, 700 /*5/6*/,
104
  120 /*1/7*/, 240 /*2/7*/, 360 /*3/7*/, 480 /*4/7*/,
105
  600 /*5/7*/, 720 /*6/7*/, 105 /*1/8*/, 315 /*3/8*/,
106
  525 /*5/8*/, 735 /*7/8*/,
107
  -1 /*inv.*/, 0 /*BI fm*/
108
};
109
#else
110
/* pre-computed scales for all bfractions and base=256 */
111
const int16_t vc1_bfraction_lut[23] = {
112
  128 /*1/2*/,  85 /*1/3*/, 170 /*2/3*/,  64 /*1/4*/,
113
  192 /*3/4*/,  51 /*1/5*/, 102 /*2/5*/,
114
  153 /*3/5*/, 204 /*4/5*/,  43 /*1/6*/, 215 /*5/6*/,
115
   37 /*1/7*/,  74 /*2/7*/, 111 /*3/7*/, 148 /*4/7*/,
116
  185 /*5/7*/, 222 /*6/7*/,  32 /*1/8*/,  96 /*3/8*/,
117
  160 /*5/8*/, 224 /*7/8*/,
118
  -1 /*inv.*/, 0 /*BI fm*/
119
};
120
#endif
121

  
122
const uint8_t vc1_bfraction_bits[23] = {
123
    3, 3, 3, 3,
124
    3, 3, 3,
125
    7, 7, 7, 7,
126
    7, 7, 7, 7,
127
    7, 7, 7, 7,
128
    7, 7,
129
    7, 7
130
};
131
const uint8_t vc1_bfraction_codes[23] = {
132
     0,   1,   2,   3,
133
     4,   5,   6,
134
   112, 113, 114, 115,
135
   116, 117, 118, 119,
136
   120, 121, 122, 123,
137
   124, 125,
138
   126, 127
139
};
140

  
141
//Same as H.264
142
const AVRational vc1_pixel_aspect[16]={
143
 {0, 1},
144
 {1, 1},
145
 {12, 11},
146
 {10, 11},
147
 {16, 11},
148
 {40, 33},
149
 {24, 11},
150
 {20, 11},
151
 {32, 11},
152
 {80, 33},
153
 {18, 11},
154
 {15, 11},
155
 {64, 33},
156
 {160, 99},
157
 {0, 1},
158
 {0, 1}
159
};
160

  
161
/* BitPlane IMODE - such a small table... */
162
const uint8_t vc1_imode_codes[7] = {
163
  0, 2, 1, 3, 1, 2, 3
164
};
165
const uint8_t vc1_imode_bits[7] = {
166
  4, 2, 3, 2, 4, 3, 3
167
};
168

  
169
/* Normal-2 imode */
170
const uint8_t vc1_norm2_codes[4] = {
171
  0, 4, 5, 3
172
};
173
const uint8_t vc1_norm2_bits[4] = {
174
  1, 3, 3, 2
175
};
176

  
177
const uint16_t vc1_norm6_codes[64] = {
178
0x001, 0x002, 0x003, 0x000, 0x004, 0x001, 0x002, 0x047, 0x005, 0x003, 0x004, 0x04B, 0x005, 0x04D, 0x04E, 0x30E,
179
0x006, 0x006, 0x007, 0x053, 0x008, 0x055, 0x056, 0x30D, 0x009, 0x059, 0x05A, 0x30C, 0x05C, 0x30B, 0x30A, 0x037,
180
0x007, 0x00A, 0x00B, 0x043, 0x00C, 0x045, 0x046, 0x309, 0x00D, 0x049, 0x04A, 0x308, 0x04C, 0x307, 0x306, 0x036,
181
0x00E, 0x051, 0x052, 0x305, 0x054, 0x304, 0x303, 0x035, 0x058, 0x302, 0x301, 0x034, 0x300, 0x033, 0x032, 0x007,
182
};
183

  
184
const uint8_t vc1_norm6_bits[64] = {
185
 1,  4,  4,  8,  4,  8,  8, 10,  4,  8,  8, 10,  8, 10, 10, 13,
186
 4,  8,  8, 10,  8, 10, 10, 13,  8, 10, 10, 13, 10, 13, 13,  9,
187
 4,  8,  8, 10,  8, 10, 10, 13,  8, 10, 10, 13, 10, 13, 13,  9,
188
 8, 10, 10, 13, 10, 13, 13,  9, 10, 13, 13,  9, 13,  9,  9,  6,
189
};
190
/* Normal-6 imode */
191
const uint8_t vc1_norm6_spec[64][5] = {
192
{ 0,  1, 1        },
193
{ 1,  2, 4        },
194
{ 2,  3, 4        },
195
{ 3,  0, 8        },
196
{ 4,  4, 4        },
197
{ 5,  1, 8        },
198
{ 6,  2, 8        },
199
{ 7,  2, 5,  7, 5 },
200
{ 8,  5, 4        },
201
{ 9,  3, 8        },
202
{10,  4, 8        },
203
{11,  2, 5, 11, 5 },
204
{12,  5, 8        },
205
{13,  2, 5, 13, 5 },
206
{14,  2, 5, 14, 5 },
207
{15,  3, 5, 14, 8 },
208
{16,  6, 4        },
209
{17,  6, 8        },
210
{18,  7, 8        },
211
{19,  2, 5, 19, 5 },
212
{20,  8, 8        },
213
{21,  2, 5, 21, 5 },
214
{22,  2, 5, 22, 5 },
215
{23,  3, 5, 13, 8 },
216
{24,  9, 8        },
217
{25,  2, 5, 25, 5 },
218
{26,  2, 5, 26, 5 },
219
{27,  3, 5, 12, 8 },
220
{28,  2, 5, 28, 5 },
221
{29,  3, 5, 11, 8 },
222
{30,  3, 5, 10, 8 },
223
{31,  3, 5,  7, 4 },
224
{32,  7, 4        },
225
{33, 10, 8        },
226
{34, 11, 8        },
227
{35,  2, 5,  3, 5 },
228
{36, 12, 8        },
229
{37,  2, 5,  5, 5 },
230
{38,  2, 5,  6, 5 },
231
{39,  3, 5,  9, 8 },
232
{40, 13, 8        },
233
{41,  2, 5,  9, 5 },
234
{42,  2, 5, 10, 5 },
235
{43,  3, 5,  8, 8 },
236
{44,  2, 5, 12, 5 },
237
{45,  3, 5,  7, 8 },
238
{46,  3, 5,  6, 8 },
239
{47,  3, 5,  6, 4 },
240
{48, 14, 8        },
241
{49,  2, 5, 17, 5 },
242
{50,  2, 5, 18, 5 },
243
{51,  3, 5,  5, 8 },
244
{52,  2, 5, 20, 5 },
245
{53,  3, 5,  4, 8 },
246
{54,  3, 5,  3, 8 },
247
{55,  3, 5,  5, 4 },
248
{56,  2, 5, 24, 5 },
249
{57,  3, 5,  2, 8 },
250
{58,  3, 5,  1, 8 },
251
{59,  3, 5,  4, 4 },
252
{60,  3, 5,  0, 8 },
253
{61,  3, 5,  3, 4 },
254
{62,  3, 5,  2, 4 },
255
{63,  3, 5,  1, 1 },
256
};
257

  
258
/* 4MV Block pattern VLC tables */
259
const uint8_t vc1_4mv_block_pattern_codes[4][16] = {
260
  { 14, 58, 59, 25, 12, 26, 15, 15, 13, 24, 27,  0, 28,  1,  2,  2},
261
  {  8, 18, 19,  4, 20,  5, 30, 11, 21, 31,  6, 12,  7, 13, 14,  0},
262
  { 15,  6,  7,  2,  8,  3, 28,  9, 10, 29,  4, 11,  5, 12, 13,  0},
263
  {  0, 11, 12,  4, 13,  5, 30, 16, 14, 31,  6, 17,  7, 18, 19, 10}
264
};
265
const uint8_t vc1_4mv_block_pattern_bits[4][16] = {
266
  { 5, 6, 6, 5, 5, 5, 5, 4, 5, 5, 5, 3, 5, 3, 3, 2},
267
  { 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4, 4, 4, 4, 4, 2},
268
  { 4, 4, 4, 4, 4, 4, 5, 4, 4, 5, 4, 4, 4, 4, 4, 3},
269
  { 2, 4, 4, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4}
270
};
271

  
272
const uint8_t wmv3_dc_scale_table[32]={
273
    0, 2, 4, 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
274
};
275

  
276
/* P-Picture CBPCY VLC tables */
277
#if 1 // Looks like original tables are not conforming to standard at all. Are they used for old WMV?
278
const uint16_t vc1_cbpcy_p_codes[4][64] = {
279
  {
280
      0,   6,  15,  13,  13,  11,   3,  13,   5,   8,  49,  10,  12, 114, 102, 119,
281
      1,  54,  96,   8,  10, 111,   5,  15,  12,  10,   2,  12,  13, 115,  53,  63,
282
      1,   7,   1,   7,  14,  12,   4,  14,   1,   9,  97,  11,   7,  58,  52,  62,
283
      4, 103,   1,   9,  11,  56, 101, 118,   4, 110, 100,  30,   2,   5,   4,   3
284
  },
285
  {
286
      0,   9,   1,  18,   5,  14, 237,  26,   3, 121,   3,  22,  13,  16,   6,  30,
287
      2,  10,   1,  20,  12, 241,   5,  28,  16,  12,   3,  24,  28, 124, 239, 247,
288
      1, 240,   1,  19,  18,  15,   4,  27,   1, 122,   2,  23,   1,  17,   7,  31,
289
      1,  11,   2,  21,  19, 246, 238,  29,  17,  13, 236,  25,  58,  63,   8, 125
290
  },
291
  {
292
      0, 201,  25, 231,   5, 221,   1,   3,   2, 414,   2, 241,  16, 225, 195, 492,
293
      2, 412,   1, 240,   7, 224,  98, 245,   1, 220,  96,   5,   9, 230, 101, 247,
294
      1, 102,   1, 415,  24,   3,   2, 244,   3,  54,   3, 484,  17, 114, 200, 493,
295
      3, 413,   1,   4,  13, 113,  99, 485,   4, 111, 194, 243,   5,  29,  26,  31
296
  },
297
  {
298
      0,  28,  12,  44,   3,  36,  20,  52,   2,  32,  16,  48,   8,  40,  24,  28,
299
      1,  30,  14,  46,   6,  38,  22,  54,   3,  34,  18,  50,  10,  42,  26,  30,
300
      1,  29,  13,  45,   5,  37,  21,  53,   2,  33,  17,  49,   9,  41,  25,  29,
301
      1,  31,  15,  47,   7,  39,  23,  55,   4,  35,  19,  51,  11,  43,  27,  31
302
   }
303
};
304

  
305
const uint8_t vc1_cbpcy_p_bits[4][64] = {
306
  {
307
    13,  13,   7,  13,   7,  13,  13,  12,   6,  13,   7,  12,   6,   8,   8,   8,
308
     5,   7,   8,  12,   6,   8,  13,  12,   7,  13,  13,  12,   6,   8,   7,   7,
309
     6,  13,   8,  12,   7,  13,  13,  12,   7,  13,   8,  12,   5,   7,   7,   7,
310
     6,   8,  13,  12,   6,   7,   8,   8,   5,   8,   8,   6,   3,   3,   3,   2
311
  },
312
  {
313
    14,  13,   8,  13,   3,  13,   8,  13,   3,   7,   8,  13,   4,  13,  13,  13,
314
     3,  13,  13,  13,   4,   8,  13,  13,   5,  13,  13,  13,   5,   7,   8,   8,
315
     3,   8,  14,  13,   5,  13,  13,  13,   4,   7,  13,  13,   6,  13,  13,  13,
316
     5,  13,   8,  13,   5,   8,   8,  13,   5,  13,   8,  13,   6,   6,  13,   7
317
  },
318
  {
319
    13,   8,   6,   8,   4,   8,  13,  12,   4,   9,   8,   8,   5,   8,   8,   9,
320
     5,   9,  10,   8,   4,   8,   7,   8,   6,   8,   7,  13,   4,   8,   7,   8,
321
     5,   7,   8,   9,   6,  13,  13,   8,   4,   6,   8,   9,   5,   7,   8,   9,
322
     5,   9,   9,  13,   5,   7,   7,   9,   4,   7,   8,   8,   3,   5,   5,   5
323
  },
324
  {
325
     9,   9,   9,   9,   2,   9,   9,   9,   2,   9,   9,   9,   9,   9,   9,   8,
326
     3,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   8,
327
     2,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   8,
328
     9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   8
329
  }
330
};
331
#else
332
const uint16_t vc1_cbpcy_p_codes[4][64] = {
333
  {
334
      0,   1,   1,   4,   5,   1,  12,   4,  13,  14,  10,  11,  12,   7,  13,   2,
335
     15,   1,  96,   1,  49,  97,   2, 100,   3,   4,   5, 101, 102,  52,  53,   4,
336
      6,   7,  54, 103,   8,   9,  10, 110,  11,  12, 111,  56, 114,  58, 115,   5,
337
     13,   7,   8,   9,  10,  11,  12,  30,  13,  14,  15, 118, 119,  62,  63,   3
338
  },
339
  {
340
      0,   1,   2,   1,   3,   1,  16,  17,   5,  18,  12,  19,  13,   1,  28,  58,
341
      1,   1,   1,   2,   3,   2,   3, 236, 237,   4,   5, 238,   6,   7, 239,   8,
342
      9, 240,  10,  11, 121, 122,  12,  13,  14,  15, 241, 246,  16,  17, 124,  63,
343
     18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31, 247, 125
344
  },
345
  {
346
      0,   1,   2,   3,   2,   3,   1,   4,   5,  24,   7,  13,  16,  17,   9,   5,
347
     25,   1,   1,   1,   2,   3,  96, 194,   1,   2,  98,  99, 195, 200, 101,  26,
348
    201, 102, 412, 413, 414,  54, 220, 111, 221,   3, 224, 113, 225, 114, 230,  29,
349
    231, 415, 240,   4, 241, 484,   5, 243,   3, 244, 245, 485, 492, 493, 247,  31
350
  },
351
  {
352
      0,   1,   1,   1,   2,   2,   3,   4,   3,   5,   6,   7,   8,   9,  10,  11,
353
     12,  13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,
354
     28,  29,  30,  31,  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,
355
     44,  45,  46,  47,  48,  49,  50,  51,  52,  53,  54,  55,  28,  29,  30,  31
356
   }
357
};
358
const uint8_t vc1_cbpcy_p_bits[4][64] = {
359
  {
360
    13,  6,  5,  6,  6,  7,  7,  5,  7,  7,  6,  6,  6,  5,  6,  3,
361
     7,  8,  8, 13,  7,  8, 13,  8, 13, 13, 13,  8,  8,  7,  7,  3,
362
    13, 13,  7,  8, 13, 13, 13,  8, 13, 13,  8,  7,  8,  7,  8,  3,
363
    13, 12, 12, 12, 12, 12, 12,  6, 12, 12, 12,  8,  8,  7,  7,  2
364
  },
365
  {
366
    14,  3,  3,  5,  3,  4,  5,  5,  3,  5,  4,  5,  4,  6,  5,  6,
367
     8, 14, 13,  8,  8, 13, 13,  8,  8, 13, 13,  8, 13, 13,  8, 13,
368
    13,  8, 13, 13,  7,  7, 13, 13, 13, 13,  8,  8, 13, 13,  7,  6,
369
    13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,  8,  7
370
  },
371
  {
372
    13,  5,  5,  5,  4,  4,  6,  4,  4,  6,  4,  5,  5,  5,  4,  3,
373
     6,  8, 10,  9,  8,  8,  7,  8, 13, 13,  7,  7,  8,  8,  7,  5,
374
     8,  7,  9,  9,  9,  6,  8,  7,  8, 13,  8,  7,  8,  7,  8,  5,
375
     8,  9,  8, 13,  8,  9, 13,  8, 12,  8,  8,  9,  9,  9,  8,  5
376
  },
377
  {
378
     9,  2,  3,  9,  2,  9,  9,  9,  2,  9,  9,  9,  9,  9,  9,  9,
379
     9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,
380
     9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,
381
     9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  8,  8,  8,  8
382
  }
383
};
384
#endif
385

  
386
/* MacroBlock Transform Type: 7.1.3.11, p89
387
 * 8x8:B
388
 * 8x4:B:btm  8x4:B:top  8x4:B:both,
389
 * 4x8:B:right  4x8:B:left  4x8:B:both
390
 * 4x4:B  8x8:MB
391
 * 8x4:MB:btm  8x4:MB:top  8x4,MB,both
392
 * 4x8,MB,right  4x8,MB,left
393
 * 4x4,MB                               */
394
const uint16_t vc1_ttmb_codes[3][16] = {
395
  {
396
    0x0003,
397
    0x002E, 0x005F, 0x0000,
398
    0x0016, 0x0015, 0x0001,
399
    0x0004, 0x0014,
400
    0x02F1, 0x0179, 0x017B,
401
    0x0BC0, 0x0BC1, 0x05E1,
402
    0x017A
403
  },
404
  {
405
    0x0006,
406
    0x0006, 0x0003, 0x0007,
407
    0x000F, 0x000E, 0x0000,
408
    0x0002, 0x0002,
409
    0x0014, 0x0011, 0x000B,
410
    0x0009, 0x0021, 0x0015,
411
    0x0020
412
  },
413
  {
414
    0x0006,
415
    0x0000, 0x000E, 0x0005,
416
    0x0002, 0x0003, 0x0003,
417
    0x000F, 0x0002,
418
    0x0081, 0x0021, 0x0009,
419
    0x0101, 0x0041, 0x0011,
420
    0x0100
421
  }
422
};
423

  
424
const uint8_t vc1_ttmb_bits[3][16] = {
425
  {
426
     2,
427
     6,  7,  2,
428
     5,  5,  2,
429
     3,  5,
430
    10,  9,  9,
431
    12, 12, 11,
432
     9
433
  },
434
  {
435
    3,
436
    4, 4, 4,
437
    4, 4, 3,
438
    3, 2,
439
    7, 7, 6,
440
    6, 8, 7,
441
    8
442
  },
443
  {
444
     3,
445
     3, 4, 5,
446
     3, 3, 4,
447
     4, 2,
448
    10, 8, 6,
449
    11, 9, 7,
450
    11
451
  }
452
};
453

  
454
/* TTBLK (Transform Type per Block) tables */
455
const uint8_t vc1_ttblk_codes[3][8] = {
456
  {  0,  1,  3,  5, 16, 17, 18, 19},
457
  {  3,  0,  1,  2,  3,  5,  8,  9},
458
  {  1,  0,  1,  4,  6,  7, 10, 11}
459
};
460
const uint8_t vc1_ttblk_bits[3][8] = {
461
  {  2,  2,  2,  3,  5,  5,  5,  5},
462
  {  2,  3,  3,  3,  3,  3,  4,  4},
463
  {  2,  3,  3,  3,  3,  3,  4,  4}
464
};
465

  
466
/* SUBBLKPAT tables, p93-94, reordered */
467
const uint8_t vc1_subblkpat_codes[3][15] = {
468
  { 14, 12,  7, 11,  9, 26,  2, 10, 27,  8,  0,  6,  1, 15,  1},
469
  { 14,  0,  8, 15, 10,  4, 23, 13,  5,  9, 25,  3, 24, 22,  1},
470
  {  5,  6,  2,  2,  8,  0, 28,  3,  1,  3, 29,  1, 19, 18, 15}
471
};
472
const uint8_t vc1_subblkpat_bits[3][15] = {
473
  {  5,  5,  5,  5,  5,  6,  4,  5,  6,  5,  4,  5,  4,  5,  1},
474
  {  4,  3,  4,  4,  4,  5,  5,  4,  5,  4,  5,  4,  5,  5,  2},
475
  {  3,  3,  4,  3,  4,  5,  5,  3,  5,  4,  5,  4,  5,  5,  4}
476
};
477

  
478
/* MV differential tables, p265 */
479
const uint16_t vc1_mv_diff_codes[4][73] = {
480
  {
481
       0,    2,    3,    8,  576,    3,    2,    6,
482
       5,  577,  578,    7,    8,    9,   40,   19,
483
      37,   82,   21,   22,   23,  579,  580,  166,
484
      96,  167,   49,  194,  195,  581,  582,  583,
485
     292,  293,  294,   13,    2,    7,   24,   50,
486
     102,  295,   13,    7,    8,   18,   50,  103,
487
      38,   20,   21,   22,   39,  204,  103,   23,
488
      24,   25,  104,  410,  105,  106,  107,  108,
489
     109,  220,  411,  442,  222,  443,  446,  447,
490
       7 /* 73 elements */
491
  },
492
  {
493
       0,    4,    5,    3,    4,    3,    4,    5,
494
      20,    6,   21,   44,   45,   46, 3008,   95,
495
     112,  113,   57, 3009, 3010,  116,  117, 3011,
496
     118, 3012, 3013, 3014, 3015, 3016, 3017, 3018,
497
    3019, 3020, 3021, 3022,    1,    4,   15,  160,
498
     161,   41,    6,   11,   42,  162,   43,  119,
499
      56,   57,   58,  163,  236,  237, 3023,  119,
500
     120,  242,  122,  486, 1512,  487,  246,  494,
501
    1513,  495, 1514, 1515, 1516, 1517, 1518, 1519,
502
      31 /* 73 elements */
503
  },
504
  {
505
       0,  512,  513,  514,  515,    2,    3,  258,
506
     259,  260,  261,  262,  263,  264,  265,  266,
507
     267,  268,  269,  270,  271,  272,  273,  274,
508
     275,  276,  277,  278,  279,  280,  281,  282,
509
     283,  284,  285,  286,    1,    5,  287,  288,
510
     289,  290,    6,    7,  291,  292,  293,  294,
511
     295,  296,  297,  298,  299,  300,  301,  302,
512
     303,  304,  305,  306,  307,  308,  309,  310,
513
     311,  312,  313,  314,  315,  316,  317,  318,
514
     319 /* 73 elements */
515
  },
516
  {
517
       0,    1,    1,    2,    3,    4,    1,    5,
518
       4,    3,    5,    8,    6,    9,   10,   11,
519
      12,    7,  104,   14,  105,    4,   10,   15,
520
      11,    6,   14,    8,  106,  107,  108,   15,
521
     109,    9,   55,   10,    1,    2,    1,    2,
522
       3,   12,    6,    2,    6,    7,   28,    7,
523
      15,    8,    5,   18,   29,  152,   77,   24,
524
      25,   26,   39,  108,   13,  109,   55,   56,
525
      57,  116,   11,  153,  234,  235,  118,  119,
526
      15 /* 73 elements */
527
  }
528
};
529
const uint8_t vc1_mv_diff_bits[4][73] = {
530
  {
531
     6,  7,  7,  8, 14,  6,  5,  6,  7, 14, 14,  6,  6,  6,  8,  9,
532
    10,  9,  7,  7,  7, 14, 14, 10,  9, 10,  8, 10, 10, 14, 14, 14,
533
    13, 13, 13,  6,  3,  5,  6,  8,  9, 13,  5,  4,  4,  5,  7,  9,
534
     6,  5,  5,  5,  6,  9,  8,  5,  5,  5,  7, 10,  7,  7,  7,  7,
535
     7,  8, 10,  9,  8,  9,  9,  9,  3 /* 73 elements */
536
  },
537
  {
538
     5,  7,  7,  6,  6,  5,  5,  6,  7,  5,  7,  8,  8,  8, 14,  9,
539
     9,  9,  8, 14, 14,  9,  9, 14,  9, 14, 14, 14, 14, 14, 14, 14,
540
    14, 14, 14, 14,  2,  3,  6,  8,  8,  6,  3,  4,  6,  8,  6,  9,
541
     6,  6,  6,  8,  8,  8, 14,  7,  7,  8,  7,  9, 13,  9,  8,  9,
542
    13,  9, 13, 13, 13, 13, 13, 13,  5 /* 73 elements */
543

  
544
  },
545
  {
546
     3, 12, 12, 12, 12,  3,  4, 11, 11, 11, 11, 11, 11, 11, 11, 11,
547
    11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
548
    11, 11, 11, 11,  1,  5, 11, 11, 11, 11,  4,  4, 11, 11, 11, 11,
549
    11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
550
    11, 11, 11, 11, 11, 11, 11, 11, 11 /* 73 elements */
551
  },
552
  {
553
    15, 11, 15, 15, 15, 15, 12, 15, 12, 11, 12, 12, 15, 12, 12, 12,
554
    12, 15, 15, 12, 15, 10, 11, 12, 11, 10, 11, 10, 15, 15, 15, 11,
555
    15, 10, 14, 10,  4,  4,  5,  7,  8,  9,  5,  3,  4,  5,  6,  8,
556
     5,  4,  3,  5,  6,  8,  7,  5,  5,  5,  6,  7,  9,  7,  6,  6,
557
     6,  7, 10,  8,  8,  8,  7,  7,  4 /* 73 elements */
558
  }
559
};
560

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

  
563
/* Scantables/ZZ scan are at 11.9 (p262) and 8.1.1.12 (p10) */
564
const int8_t vc1_normal_zz[64] = {
565
       0,     8,     1,     2,     9,    16,    24,    17,
566
      10,     3,     4,    11,    18,    25,    32,    40,
567
      33,    48,    26,    19,    12,     5,     6,    13,
568
      20,    27,    34,    41,    56,    49,    57,    42,
569
      35,    28,    21,    14,     7,    15,    22,    29,
570
      36,    43,    50,    58,    51,    59,    44,    37,
571
      30,    23,    31,    38,    45,    52,    60,    53,
572
      61,    46,    39,    47,    54,    62,    55,    63
573
};
574

  
575
const int8_t vc1_horizontal_zz [64] = /* Table 227 */
576
{
577
       0,     1,     8,     2,     3,     9,    16,    24,
578
      17,    10,     4,     5,    11,    18,    25,    32,
579
      40,    48,    33,    26,    19,    12,     6,     7,
580
      13,    20,    27,    34,    41,    56,    49,    57,
581
      42,    35,    28,    21,    14,    15,    22,    29,
582
      36,    43,    50,    58,    51,    44,    37,    30,
583
      23,    31,    38,    45,    52,    59,    60,    53,
584
      46,    39,    47,    54,    61,    62,    55,    63
585
};
586

  
587
const int8_t vc1_vertical_zz [64] = /* Table 228 */
588
{
589
       0,     8,    16,     1,    24,    32,    40,     9,
590
       2,     3,    10,    17,    25,    48,    56,    41,
591
      33,    26,    18,    11,     4,     5,    12,    19,
592
      27,    34,    49,    57,    50,    42,    35,    28,
593
      20,    13,     6,     7,    14,    21,    29,    36,
594
      43,    51,    58,    59,    52,    44,    37,    30,
595
      22,    15,    23,    31,    38,    45,    60,    53,
596
      46,    39,    47,    54,    61,    62,    55,    63
597
};
598

  
599
const int8_t vc1_simple_progressive_8x8_zz [64] =
600
/* Table 229 */
601
{
602
       0,     8,     1,     2,     9,    16,    24,    17,
603
      10,     3,     4,    11,    18,    25,    32,    40,
604
      48,    56,    41,    33,    26,    19,    12,     5,
605
       6,    13,    20,    27,    34,    49,    57,    58,
606
      50,    42,    35,    28,    21,    14,     7,    15,
607
      22,    29,    36,    43,    51,    59,    60,    52,
608
      44,    37,    30,    23,    31,    38,    45,    53,
609
      61,    62,    54,    46,    39,    47,    55,    63
610
};
611

  
612
const int8_t vc1_simple_progressive_8x4_zz [32] = /* Table 230 */
613
{
614
       0,     1,     2,     8,     3,     9,    10,    16,
615
       4,    11,    17,    24,    18,    12,     5,    19,
616
      25,    13,    20,    26,    27,     6,    21,    28,
617
      14,    22,    29,     7,    30,    15,    23,    31
618
};
619

  
620
const int8_t vc1_simple_progressive_4x8_zz [32] = /* Table 231 */
621
{
622
       0,     8,     1,    16,
623
       9,    24,    17,     2,
624
      32,    10,    25,    40,
625
      18,    48,    33,    26,
626
      56,    41,    34,     3,
627
      49,    57,    11,    42,
628
      19,    50,    27,    58,
629
      35,    43,    51,    59
630
};
631

  
632
/* Table 232 */
633
const int8_t vc1_simple_progressive_4x4_zz [16] =
634
{
635
       0,     8,    16,     1,
636
       9,    24,    17,     2,
637
      10,    18,    25,     3,
638
      11,    26,    19,    27
639
};
640

  
641
const int8_t vc1_adv_progressive_8x4_zz [32] = /* Table 233 */
642
{
643
       0,     8,     1,    16,     2,     9,    10,     3,
644
      24,    17,     4,    11,    18,    12,     5,    19,
645
      25,    13,    20,    26,    27,     6,    21,    28,
646
      14,    22,    29,     7,    30,    15,    23,    31
647
};
648

  
649
const int8_t vc1_adv_progressive_4x8_zz [32] = /* Table 234 */
650
{
651
       0,     1,     8,     2,
652
       9,    16,    17,    24,
653
      10,    32,    25,    18,
654
      40,     3,    33,    26,
655
      48,    11,    56,    41,
656
      34,    49,    57,    42,
657
      19,    50,    27,    58,
658
      35,    43,    51,    59
659
};
660

  
661
const int8_t vc1_adv_interlaced_8x8_zz [64] = /* Table 235 */
662
{
663
       0,     8,     1,    16,    24,     9,     2,    32,
664
      40,    48,    56,    17,    10,     3,    25,    18,
665
      11,     4,    33,    41,    49,    57,    26,    34,
666
      42,    50,    58,    19,    12,     5,    27,    20,
667
      13,     6,    35,    28,    21,    14,     7,    15,
668
      22,    29,    36,    43,    51,    59,    60,    52,
669
      44,    37,    30,    23,    31,    38,    45,    53,
670
      61,    62,    54,    46,    39,    47,    55,    63
671
};
672

  
673
const int8_t vc1_adv_interlaced_8x4_zz [32] = /* Table 236 */
674
{
675
       0,     8,    16,    24,     1,     9,     2,    17,
676
      25,    10,     3,    18,    26,     4,    11,    19,
677
      12,     5,    13,    20,    27,     6,    21,    28,
678
      14,    22,    29,     7,    30,    15,    23,    31
679
};
680

  
681
const int8_t vc1_adv_interlaced_4x8_zz [32] = /* Table 237 */
682
{
683
       0,     1,     2,     8,
684
      16,     9,    24,    17,
685
      10,     3,    32,    40,
686
      48,    56,    25,    18,
687
      33,    26,    41,    34,
688
      49,    57,    11,    42,
689
      19,    50,    27,    58,
690
      35,    43,    51,    59
691
};
692

  
693
const int8_t vc1_adv_interlaced_4x4_zz [16] = /* Table 238 */
694
{
695
       0,     8,    16,    24,
696
       1,     9,    17,     2,
697
      25,    10,    18,     3,
698
      26,    11,    19,    27
699
};
700

  
701

  
702
/* DQScale as specified in 8.1.3.9 - almost identical to 0x40000/i */
703
const int32_t vc1_dqscale[63] = {
704
0x40000, 0x20000, 0x15555, 0x10000, 0xCCCD, 0xAAAB, 0x9249, 0x8000,
705
    0x71C7, 0x6666, 0x5D17, 0x5555, 0x4EC5, 0x4925, 0x4444, 0x4000,
706
    0x3C3C, 0x38E4, 0x35E5, 0x3333, 0x30C3, 0x2E8C, 0x2C86, 0x2AAB,
707
    0x28F6, 0x2762, 0x25ED, 0x2492, 0x234F, 0x2222, 0x2108, 0x2000,
708
    0x1F08, 0x1E1E, 0x1D42, 0x1C72, 0x1BAD, 0x1AF3, 0x1A42, 0x199A,
709
    0x18FA, 0x1862, 0x17D0, 0x1746, 0x16C1, 0x1643, 0x15CA, 0x1555,
710
    0x14E6, 0x147B, 0x1414, 0x13B1, 0x1352, 0x12F7, 0x129E, 0x1249,
711
    0x11F7, 0x11A8, 0x115B, 0x1111, 0x10C9, 0x1084, 0x1000
712
};
libavcodec/vc1data.h
29 29
#define VC1DATA_H
30 30

  
31 31
/** Table for conversion between TTBLK and TTMB */
32
static const int ttblk_to_tt[3][8] = {
33
  { TT_8X4, TT_4X8, TT_8X8, TT_4X4, TT_8X4_TOP, TT_8X4_BOTTOM, TT_4X8_RIGHT, TT_4X8_LEFT },
34
  { TT_8X8, TT_4X8_RIGHT, TT_4X8_LEFT, TT_4X4, TT_8X4, TT_4X8, TT_8X4_BOTTOM, TT_8X4_TOP },
35
  { TT_8X8, TT_4X8, TT_4X4, TT_8X4_BOTTOM, TT_4X8_RIGHT, TT_4X8_LEFT, TT_8X4, TT_8X4_TOP }
36
};
32
extern const int ttblk_to_tt[3][8];
37 33

  
38
static const int ttfrm_to_tt[4] = { TT_8X8, TT_8X4, TT_4X8, TT_4X4 };
34
extern const int ttfrm_to_tt[4];
39 35

  
40 36
/** MV P mode - the 5th element is only used for mode 1 */
41
static const uint8_t mv_pmode_table[2][5] = {
42
  { MV_PMODE_1MV_HPEL_BILIN, MV_PMODE_1MV, MV_PMODE_1MV_HPEL, MV_PMODE_INTENSITY_COMP, MV_PMODE_MIXED_MV },
43
  { MV_PMODE_1MV, MV_PMODE_MIXED_MV, MV_PMODE_1MV_HPEL, MV_PMODE_INTENSITY_COMP, MV_PMODE_1MV_HPEL_BILIN }
44
};
45
static const uint8_t mv_pmode_table2[2][4] = {
46
  { MV_PMODE_1MV_HPEL_BILIN, MV_PMODE_1MV, MV_PMODE_1MV_HPEL, MV_PMODE_MIXED_MV },
47
  { MV_PMODE_1MV, MV_PMODE_MIXED_MV, MV_PMODE_1MV_HPEL, MV_PMODE_1MV_HPEL_BILIN }
48
};
37
extern const uint8_t mv_pmode_table[2][5];
38
extern const uint8_t mv_pmode_table2[2][4];
49 39

  
50
static const int fps_nr[5] = { 24, 25, 30, 50, 60 },
51
  fps_dr[2] = { 1000, 1001 };
52
static const uint8_t pquant_table[3][32] = {
53
  {  /* Implicit quantizer */
54
     0,  1,  2,  3,  4,  5,  6,  7,  8,  6,  7,  8,  9, 10, 11, 12,
55
    13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 29, 31
56
  },
57
  {  /* Explicit quantizer, pquantizer uniform */
58
     0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
59
    16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
60
  },
61
  {  /* Explicit quantizer, pquantizer non-uniform */
62
     0,  1,  1,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13,
63
    14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 29, 31
64
  }
65
};
40
extern const int fps_nr[5], fps_dr[2];
41
extern const uint8_t pquant_table[3][32];
66 42

  
67 43
/** @name VC-1 VLC tables and defines
68 44
 *  @todo TODO move this into the context
69 45
 */
70 46
//@{
71 47
#define VC1_BFRACTION_VLC_BITS 7
72
static VLC vc1_bfraction_vlc;
48
extern VLC vc1_bfraction_vlc;
73 49
#define VC1_IMODE_VLC_BITS 4
74
static VLC vc1_imode_vlc;
50
extern VLC vc1_imode_vlc;
75 51
#define VC1_NORM2_VLC_BITS 3
76
static VLC vc1_norm2_vlc;
52
extern VLC vc1_norm2_vlc;
77 53
#define VC1_NORM6_VLC_BITS 9
78
static VLC vc1_norm6_vlc;
54
extern VLC vc1_norm6_vlc;
79 55
/* Could be optimized, one table only needs 8 bits */
80 56
#define VC1_TTMB_VLC_BITS 9 //12
81
static VLC vc1_ttmb_vlc[3];
57
extern VLC vc1_ttmb_vlc[3];
82 58
#define VC1_MV_DIFF_VLC_BITS 9 //15
83
static VLC vc1_mv_diff_vlc[4];
59
extern VLC vc1_mv_diff_vlc[4];
84 60
#define VC1_CBPCY_P_VLC_BITS 9 //14
85
static VLC vc1_cbpcy_p_vlc[4];
61
extern VLC vc1_cbpcy_p_vlc[4];
86 62
#define VC1_4MV_BLOCK_PATTERN_VLC_BITS 6
87
static VLC vc1_4mv_block_pattern_vlc[4];
63
extern VLC vc1_4mv_block_pattern_vlc[4];
88 64
#define VC1_TTBLK_VLC_BITS 5
89
static VLC vc1_ttblk_vlc[3];
65
extern VLC vc1_ttblk_vlc[3];
90 66
#define VC1_SUBBLKPAT_VLC_BITS 6
91
static VLC vc1_subblkpat_vlc[3];
67
extern VLC vc1_subblkpat_vlc[3];
92 68

  
93
static VLC vc1_ac_coeff_table[8];
69
extern VLC vc1_ac_coeff_table[8];
94 70
//@}
95 71

  
96 72

  
......
99 75
#define B_FRACTION_DEN  840
100 76

  
101 77
/* bfraction is fractional, we scale to the GCD 3*5*7*8 = 840 */
102
const int16_t vc1_bfraction_lut[23] = {
103
  420 /*1/2*/, 280 /*1/3*/, 560 /*2/3*/, 210 /*1/4*/,
104
  630 /*3/4*/, 168 /*1/5*/, 336 /*2/5*/,
105
  504 /*3/5*/, 672 /*4/5*/, 140 /*1/6*/, 700 /*5/6*/,
106
  120 /*1/7*/, 240 /*2/7*/, 360 /*3/7*/, 480 /*4/7*/,
107
  600 /*5/7*/, 720 /*6/7*/, 105 /*1/8*/, 315 /*3/8*/,
108
  525 /*5/8*/, 735 /*7/8*/,
109
  -1 /*inv.*/, 0 /*BI fm*/
110
};
78
extern const int16_t vc1_bfraction_lut[23];
111 79
#else
112 80
/* Denominator used for vc1_bfraction_lut */
113 81
#define B_FRACTION_DEN  256
114 82

  
115 83
/* pre-computed scales for all bfractions and base=256 */
116
static const int16_t vc1_bfraction_lut[23] = {
117
  128 /*1/2*/,  85 /*1/3*/, 170 /*2/3*/,  64 /*1/4*/,
118
  192 /*3/4*/,  51 /*1/5*/, 102 /*2/5*/,
119
  153 /*3/5*/, 204 /*4/5*/,  43 /*1/6*/, 215 /*5/6*/,
120
   37 /*1/7*/,  74 /*2/7*/, 111 /*3/7*/, 148 /*4/7*/,
121
  185 /*5/7*/, 222 /*6/7*/,  32 /*1/8*/,  96 /*3/8*/,
122
  160 /*5/8*/, 224 /*7/8*/,
123
  -1 /*inv.*/, 0 /*BI fm*/
124
};
84
extern const int16_t vc1_bfraction_lut[23];
125 85
#endif
126 86

  
127
static const uint8_t vc1_bfraction_bits[23] = {
128
    3, 3, 3, 3,
129
    3, 3, 3,
130
    7, 7, 7, 7,
131
    7, 7, 7, 7,
132
    7, 7, 7, 7,
133
    7, 7,
134
    7, 7
135
};
136
static const uint8_t vc1_bfraction_codes[23] = {
137
     0,   1,   2,   3,
138
     4,   5,   6,
139
   112, 113, 114, 115,
140
   116, 117, 118, 119,
141
   120, 121, 122, 123,
142
   124, 125,
143
   126, 127
144
};
87
extern const uint8_t vc1_bfraction_bits[23];
88
extern const uint8_t vc1_bfraction_codes[23];
145 89

  
146 90
//Same as H.264
147
static const AVRational vc1_pixel_aspect[16]={
148
 {0, 1},
149
 {1, 1},
150
 {12, 11},
151
 {10, 11},
152
 {16, 11},
153
 {40, 33},
154
 {24, 11},
155
 {20, 11},
156
 {32, 11},
157
 {80, 33},
158
 {18, 11},
159
 {15, 11},
160
 {64, 33},
161
 {160, 99},
162
 {0, 1},
163
 {0, 1}
164
};
91
extern const AVRational vc1_pixel_aspect[16];
165 92

  
166 93
/* BitPlane IMODE - such a small table... */
167
static const uint8_t vc1_imode_codes[7] = {
168
  0, 2, 1, 3, 1, 2, 3
169
};
170
static const uint8_t vc1_imode_bits[7] = {
171
  4, 2, 3, 2, 4, 3, 3
172
};
94
extern const uint8_t vc1_imode_codes[7];
95
extern const uint8_t vc1_imode_bits[7];
173 96

  
174 97
/* Normal-2 imode */
175
static const uint8_t vc1_norm2_codes[4] = {
176
  0, 4, 5, 3
177
};
178
static const uint8_t vc1_norm2_bits[4] = {
179
  1, 3, 3, 2
180
};
181

  
182
static const uint16_t vc1_norm6_codes[64] = {
183
0x001, 0x002, 0x003, 0x000, 0x004, 0x001, 0x002, 0x047, 0x005, 0x003, 0x004, 0x04B, 0x005, 0x04D, 0x04E, 0x30E,
184
0x006, 0x006, 0x007, 0x053, 0x008, 0x055, 0x056, 0x30D, 0x009, 0x059, 0x05A, 0x30C, 0x05C, 0x30B, 0x30A, 0x037,
185
0x007, 0x00A, 0x00B, 0x043, 0x00C, 0x045, 0x046, 0x309, 0x00D, 0x049, 0x04A, 0x308, 0x04C, 0x307, 0x306, 0x036,
186
0x00E, 0x051, 0x052, 0x305, 0x054, 0x304, 0x303, 0x035, 0x058, 0x302, 0x301, 0x034, 0x300, 0x033, 0x032, 0x007,
187
};
188

  
189
static const uint8_t vc1_norm6_bits[64] = {
190
 1,  4,  4,  8,  4,  8,  8, 10,  4,  8,  8, 10,  8, 10, 10, 13,
191
 4,  8,  8, 10,  8, 10, 10, 13,  8, 10, 10, 13, 10, 13, 13,  9,
192
 4,  8,  8, 10,  8, 10, 10, 13,  8, 10, 10, 13, 10, 13, 13,  9,
193
 8, 10, 10, 13, 10, 13, 13,  9, 10, 13, 13,  9, 13,  9,  9,  6,
194
};
98
extern const uint8_t vc1_norm2_codes[4];
99
extern const uint8_t vc1_norm2_bits[4];
100
extern const uint16_t vc1_norm6_codes[64];
101
extern const uint8_t vc1_norm6_bits[64];
195 102
/* Normal-6 imode */
196
static const uint8_t vc1_norm6_spec[64][5] = {
197
{ 0,  1, 1        },
198
{ 1,  2, 4        },
199
{ 2,  3, 4        },
200
{ 3,  0, 8        },
201
{ 4,  4, 4        },
202
{ 5,  1, 8        },
203
{ 6,  2, 8        },
204
{ 7,  2, 5,  7, 5 },
205
{ 8,  5, 4        },
206
{ 9,  3, 8        },
207
{10,  4, 8        },
208
{11,  2, 5, 11, 5 },
209
{12,  5, 8        },
210
{13,  2, 5, 13, 5 },
211
{14,  2, 5, 14, 5 },
212
{15,  3, 5, 14, 8 },
213
{16,  6, 4        },
214
{17,  6, 8        },
215
{18,  7, 8        },
216
{19,  2, 5, 19, 5 },
217
{20,  8, 8        },
218
{21,  2, 5, 21, 5 },
219
{22,  2, 5, 22, 5 },
220
{23,  3, 5, 13, 8 },
221
{24,  9, 8        },
222
{25,  2, 5, 25, 5 },
223
{26,  2, 5, 26, 5 },
224
{27,  3, 5, 12, 8 },
225
{28,  2, 5, 28, 5 },
226
{29,  3, 5, 11, 8 },
227
{30,  3, 5, 10, 8 },
228
{31,  3, 5,  7, 4 },
229
{32,  7, 4        },
230
{33, 10, 8        },
231
{34, 11, 8        },
232
{35,  2, 5,  3, 5 },
233
{36, 12, 8        },
234
{37,  2, 5,  5, 5 },
235
{38,  2, 5,  6, 5 },
236
{39,  3, 5,  9, 8 },
237
{40, 13, 8        },
238
{41,  2, 5,  9, 5 },
239
{42,  2, 5, 10, 5 },
240
{43,  3, 5,  8, 8 },
241
{44,  2, 5, 12, 5 },
242
{45,  3, 5,  7, 8 },
243
{46,  3, 5,  6, 8 },
244
{47,  3, 5,  6, 4 },
245
{48, 14, 8        },
246
{49,  2, 5, 17, 5 },
247
{50,  2, 5, 18, 5 },
248
{51,  3, 5,  5, 8 },
249
{52,  2, 5, 20, 5 },
250
{53,  3, 5,  4, 8 },
251
{54,  3, 5,  3, 8 },
252
{55,  3, 5,  5, 4 },
253
{56,  2, 5, 24, 5 },
254
{57,  3, 5,  2, 8 },
255
{58,  3, 5,  1, 8 },
256
{59,  3, 5,  4, 4 },
257
{60,  3, 5,  0, 8 },
258
{61,  3, 5,  3, 4 },
259
{62,  3, 5,  2, 4 },
260
{63,  3, 5,  1, 1 },
261
};
103
extern const uint8_t vc1_norm6_spec[64][5];
262 104

  
263 105
/* 4MV Block pattern VLC tables */
264
static const uint8_t vc1_4mv_block_pattern_codes[4][16] = {
265
  { 14, 58, 59, 25, 12, 26, 15, 15, 13, 24, 27,  0, 28,  1,  2,  2},
266
  {  8, 18, 19,  4, 20,  5, 30, 11, 21, 31,  6, 12,  7, 13, 14,  0},
267
  { 15,  6,  7,  2,  8,  3, 28,  9, 10, 29,  4, 11,  5, 12, 13,  0},
268
  {  0, 11, 12,  4, 13,  5, 30, 16, 14, 31,  6, 17,  7, 18, 19, 10}
269
};
270
static const uint8_t vc1_4mv_block_pattern_bits[4][16] = {
271
  { 5, 6, 6, 5, 5, 5, 5, 4, 5, 5, 5, 3, 5, 3, 3, 2},
272
  { 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4, 4, 4, 4, 4, 2},
273
  { 4, 4, 4, 4, 4, 4, 5, 4, 4, 5, 4, 4, 4, 4, 4, 3},
274
  { 2, 4, 4, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4}
275
};
106
extern const uint8_t vc1_4mv_block_pattern_codes[4][16];
107
extern const uint8_t vc1_4mv_block_pattern_bits[4][16];
276 108

  
277
const uint8_t wmv3_dc_scale_table[32]={
278
    0, 2, 4, 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
279
};
109
extern const uint8_t wmv3_dc_scale_table[32];
280 110

  
281 111
/* P-Picture CBPCY VLC tables */
282
#if 1 // Looks like original tables are not conforming to standard at all. Are they used for old WMV?
283
static const uint16_t vc1_cbpcy_p_codes[4][64] = {
284
  {
285
      0,   6,  15,  13,  13,  11,   3,  13,   5,   8,  49,  10,  12, 114, 102, 119,
286
      1,  54,  96,   8,  10, 111,   5,  15,  12,  10,   2,  12,  13, 115,  53,  63,
287
      1,   7,   1,   7,  14,  12,   4,  14,   1,   9,  97,  11,   7,  58,  52,  62,
288
      4, 103,   1,   9,  11,  56, 101, 118,   4, 110, 100,  30,   2,   5,   4,   3
289
  },
290
  {
291
      0,   9,   1,  18,   5,  14, 237,  26,   3, 121,   3,  22,  13,  16,   6,  30,
292
      2,  10,   1,  20,  12, 241,   5,  28,  16,  12,   3,  24,  28, 124, 239, 247,
293
      1, 240,   1,  19,  18,  15,   4,  27,   1, 122,   2,  23,   1,  17,   7,  31,
294
      1,  11,   2,  21,  19, 246, 238,  29,  17,  13, 236,  25,  58,  63,   8, 125
295
  },
296
  {
297
      0, 201,  25, 231,   5, 221,   1,   3,   2, 414,   2, 241,  16, 225, 195, 492,
298
      2, 412,   1, 240,   7, 224,  98, 245,   1, 220,  96,   5,   9, 230, 101, 247,
299
      1, 102,   1, 415,  24,   3,   2, 244,   3,  54,   3, 484,  17, 114, 200, 493,
300
      3, 413,   1,   4,  13, 113,  99, 485,   4, 111, 194, 243,   5,  29,  26,  31
301
  },
302
  {
303
      0,  28,  12,  44,   3,  36,  20,  52,   2,  32,  16,  48,   8,  40,  24,  28,
304
      1,  30,  14,  46,   6,  38,  22,  54,   3,  34,  18,  50,  10,  42,  26,  30,
305
      1,  29,  13,  45,   5,  37,  21,  53,   2,  33,  17,  49,   9,  41,  25,  29,
306
      1,  31,  15,  47,   7,  39,  23,  55,   4,  35,  19,  51,  11,  43,  27,  31
307
   }
308
};
309

  
310
static const uint8_t vc1_cbpcy_p_bits[4][64] = {
311
  {
312
    13,  13,   7,  13,   7,  13,  13,  12,   6,  13,   7,  12,   6,   8,   8,   8,
313
     5,   7,   8,  12,   6,   8,  13,  12,   7,  13,  13,  12,   6,   8,   7,   7,
314
     6,  13,   8,  12,   7,  13,  13,  12,   7,  13,   8,  12,   5,   7,   7,   7,
315
     6,   8,  13,  12,   6,   7,   8,   8,   5,   8,   8,   6,   3,   3,   3,   2
316
  },
317
  {
318
    14,  13,   8,  13,   3,  13,   8,  13,   3,   7,   8,  13,   4,  13,  13,  13,
319
     3,  13,  13,  13,   4,   8,  13,  13,   5,  13,  13,  13,   5,   7,   8,   8,
320
     3,   8,  14,  13,   5,  13,  13,  13,   4,   7,  13,  13,   6,  13,  13,  13,
321
     5,  13,   8,  13,   5,   8,   8,  13,   5,  13,   8,  13,   6,   6,  13,   7
322
  },
323
  {
324
    13,   8,   6,   8,   4,   8,  13,  12,   4,   9,   8,   8,   5,   8,   8,   9,
325
     5,   9,  10,   8,   4,   8,   7,   8,   6,   8,   7,  13,   4,   8,   7,   8,
326
     5,   7,   8,   9,   6,  13,  13,   8,   4,   6,   8,   9,   5,   7,   8,   9,
327
     5,   9,   9,  13,   5,   7,   7,   9,   4,   7,   8,   8,   3,   5,   5,   5
328
  },
329
  {
330
     9,   9,   9,   9,   2,   9,   9,   9,   2,   9,   9,   9,   9,   9,   9,   8,
331
     3,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   8,
332
     2,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   8,
333
     9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   9,   8
334
  }
335
};
336
#else
337
static const uint16_t vc1_cbpcy_p_codes[4][64] = {
338
  {
339
      0,   1,   1,   4,   5,   1,  12,   4,  13,  14,  10,  11,  12,   7,  13,   2,
340
     15,   1,  96,   1,  49,  97,   2, 100,   3,   4,   5, 101, 102,  52,  53,   4,
341
      6,   7,  54, 103,   8,   9,  10, 110,  11,  12, 111,  56, 114,  58, 115,   5,
342
     13,   7,   8,   9,  10,  11,  12,  30,  13,  14,  15, 118, 119,  62,  63,   3
343
  },
344
  {
345
      0,   1,   2,   1,   3,   1,  16,  17,   5,  18,  12,  19,  13,   1,  28,  58,
346
      1,   1,   1,   2,   3,   2,   3, 236, 237,   4,   5, 238,   6,   7, 239,   8,
347
      9, 240,  10,  11, 121, 122,  12,  13,  14,  15, 241, 246,  16,  17, 124,  63,
348
     18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31, 247, 125
349
  },
350
  {
351
      0,   1,   2,   3,   2,   3,   1,   4,   5,  24,   7,  13,  16,  17,   9,   5,
352
     25,   1,   1,   1,   2,   3,  96, 194,   1,   2,  98,  99, 195, 200, 101,  26,
353
    201, 102, 412, 413, 414,  54, 220, 111, 221,   3, 224, 113, 225, 114, 230,  29,
354
    231, 415, 240,   4, 241, 484,   5, 243,   3, 244, 245, 485, 492, 493, 247,  31
355
  },
356
  {
357
      0,   1,   1,   1,   2,   2,   3,   4,   3,   5,   6,   7,   8,   9,  10,  11,
358
     12,  13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,
359
     28,  29,  30,  31,  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,
360
     44,  45,  46,  47,  48,  49,  50,  51,  52,  53,  54,  55,  28,  29,  30,  31
361
   }
362
};
363
static const uint8_t vc1_cbpcy_p_bits[4][64] = {
364
  {
365
    13,  6,  5,  6,  6,  7,  7,  5,  7,  7,  6,  6,  6,  5,  6,  3,
366
     7,  8,  8, 13,  7,  8, 13,  8, 13, 13, 13,  8,  8,  7,  7,  3,
367
    13, 13,  7,  8, 13, 13, 13,  8, 13, 13,  8,  7,  8,  7,  8,  3,
368
    13, 12, 12, 12, 12, 12, 12,  6, 12, 12, 12,  8,  8,  7,  7,  2
369
  },
370
  {
371
    14,  3,  3,  5,  3,  4,  5,  5,  3,  5,  4,  5,  4,  6,  5,  6,
372
     8, 14, 13,  8,  8, 13, 13,  8,  8, 13, 13,  8, 13, 13,  8, 13,
373
    13,  8, 13, 13,  7,  7, 13, 13, 13, 13,  8,  8, 13, 13,  7,  6,
374
    13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,  8,  7
375
  },
376
  {
377
    13,  5,  5,  5,  4,  4,  6,  4,  4,  6,  4,  5,  5,  5,  4,  3,
378
     6,  8, 10,  9,  8,  8,  7,  8, 13, 13,  7,  7,  8,  8,  7,  5,
379
     8,  7,  9,  9,  9,  6,  8,  7,  8, 13,  8,  7,  8,  7,  8,  5,
380
     8,  9,  8, 13,  8,  9, 13,  8, 12,  8,  8,  9,  9,  9,  8,  5
381
  },
382
  {
383
     9,  2,  3,  9,  2,  9,  9,  9,  2,  9,  9,  9,  9,  9,  9,  9,
384
     9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,
385
     9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,
386
     9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  8,  8,  8,  8
387
  }
388
};
389
#endif
112
extern const uint16_t vc1_cbpcy_p_codes[4][64];
113
extern const uint8_t vc1_cbpcy_p_bits[4][64];
390 114

  
391 115
/* MacroBlock Transform Type: 7.1.3.11, p89
392 116
 * 8x8:B
......
396 120
 * 8x4:MB:btm  8x4:MB:top  8x4,MB,both
397 121
 * 4x8,MB,right  4x8,MB,left
398 122
 * 4x4,MB                               */
399
static const uint16_t vc1_ttmb_codes[3][16] = {
400
  {
401
    0x0003,
402
    0x002E, 0x005F, 0x0000,
403
    0x0016, 0x0015, 0x0001,
404
    0x0004, 0x0014,
405
    0x02F1, 0x0179, 0x017B,
406
    0x0BC0, 0x0BC1, 0x05E1,
407
    0x017A
408
  },
409
  {
410
    0x0006,
411
    0x0006, 0x0003, 0x0007,
412
    0x000F, 0x000E, 0x0000,
413
    0x0002, 0x0002,
414
    0x0014, 0x0011, 0x000B,
415
    0x0009, 0x0021, 0x0015,
416
    0x0020
417
  },
418
  {
419
    0x0006,
420
    0x0000, 0x000E, 0x0005,
421
    0x0002, 0x0003, 0x0003,
422
    0x000F, 0x0002,
423
    0x0081, 0x0021, 0x0009,
424
    0x0101, 0x0041, 0x0011,
425
    0x0100
426
  }
427
};
123
extern const uint16_t vc1_ttmb_codes[3][16];
428 124

  
429
static const uint8_t vc1_ttmb_bits[3][16] = {
430
  {
431
     2,
432
     6,  7,  2,
433
     5,  5,  2,
434
     3,  5,
435
    10,  9,  9,
436
    12, 12, 11,
437
     9
438
  },
439
  {
440
    3,
441
    4, 4, 4,
442
    4, 4, 3,
443
    3, 2,
444
    7, 7, 6,
445
    6, 8, 7,
446
    8
447
  },
448
  {
449
     3,
450
     3, 4, 5,
451
     3, 3, 4,
452
     4, 2,
453
    10, 8, 6,
454
    11, 9, 7,
455
    11
456
  }
457
};
125
extern const uint8_t vc1_ttmb_bits[3][16];
458 126

  
459 127
/* TTBLK (Transform Type per Block) tables */
460
static const uint8_t vc1_ttblk_codes[3][8] = {
461
  {  0,  1,  3,  5, 16, 17, 18, 19},
462
  {  3,  0,  1,  2,  3,  5,  8,  9},
463
  {  1,  0,  1,  4,  6,  7, 10, 11}
464
};
465
static const uint8_t vc1_ttblk_bits[3][8] = {
466
  {  2,  2,  2,  3,  5,  5,  5,  5},
467
  {  2,  3,  3,  3,  3,  3,  4,  4},
468
  {  2,  3,  3,  3,  3,  3,  4,  4}
469
};
128
extern const uint8_t vc1_ttblk_codes[3][8];
129
extern const uint8_t vc1_ttblk_bits[3][8];
470 130

  
471 131
/* SUBBLKPAT tables, p93-94, reordered */
472
static const uint8_t vc1_subblkpat_codes[3][15] = {
473
  { 14, 12,  7, 11,  9, 26,  2, 10, 27,  8,  0,  6,  1, 15,  1},
474
  { 14,  0,  8, 15, 10,  4, 23, 13,  5,  9, 25,  3, 24, 22,  1},
475
  {  5,  6,  2,  2,  8,  0, 28,  3,  1,  3, 29,  1, 19, 18, 15}
476
};
477
static const uint8_t vc1_subblkpat_bits[3][15] = {
478
  {  5,  5,  5,  5,  5,  6,  4,  5,  6,  5,  4,  5,  4,  5,  1},
479
  {  4,  3,  4,  4,  4,  5,  5,  4,  5,  4,  5,  4,  5,  5,  2},
480
  {  3,  3,  4,  3,  4,  5,  5,  3,  5,  4,  5,  4,  5,  5,  4}
481
};
132
extern const uint8_t vc1_subblkpat_codes[3][15];
133
extern const uint8_t vc1_subblkpat_bits[3][15];
482 134

  
483 135
/* MV differential tables, p265 */
484
static const uint16_t vc1_mv_diff_codes[4][73] = {
485
  {
486
       0,    2,    3,    8,  576,    3,    2,    6,
487
       5,  577,  578,    7,    8,    9,   40,   19,
488
      37,   82,   21,   22,   23,  579,  580,  166,
489
      96,  167,   49,  194,  195,  581,  582,  583,
490
     292,  293,  294,   13,    2,    7,   24,   50,
491
     102,  295,   13,    7,    8,   18,   50,  103,
492
      38,   20,   21,   22,   39,  204,  103,   23,
493
      24,   25,  104,  410,  105,  106,  107,  108,
494
     109,  220,  411,  442,  222,  443,  446,  447,
495
       7 /* 73 elements */
496
  },
497
  {
498
       0,    4,    5,    3,    4,    3,    4,    5,
499
      20,    6,   21,   44,   45,   46, 3008,   95,
500
     112,  113,   57, 3009, 3010,  116,  117, 3011,
501
     118, 3012, 3013, 3014, 3015, 3016, 3017, 3018,
502
    3019, 3020, 3021, 3022,    1,    4,   15,  160,
503
     161,   41,    6,   11,   42,  162,   43,  119,
504
      56,   57,   58,  163,  236,  237, 3023,  119,
505
     120,  242,  122,  486, 1512,  487,  246,  494,
506
    1513,  495, 1514, 1515, 1516, 1517, 1518, 1519,
507
      31 /* 73 elements */
508
  },
509
  {
510
       0,  512,  513,  514,  515,    2,    3,  258,
511
     259,  260,  261,  262,  263,  264,  265,  266,
512
     267,  268,  269,  270,  271,  272,  273,  274,
513
     275,  276,  277,  278,  279,  280,  281,  282,
514
     283,  284,  285,  286,    1,    5,  287,  288,
515
     289,  290,    6,    7,  291,  292,  293,  294,
516
     295,  296,  297,  298,  299,  300,  301,  302,
517
     303,  304,  305,  306,  307,  308,  309,  310,
518
     311,  312,  313,  314,  315,  316,  317,  318,
519
     319 /* 73 elements */
520
  },
521
  {
522
       0,    1,    1,    2,    3,    4,    1,    5,
523
       4,    3,    5,    8,    6,    9,   10,   11,
524
      12,    7,  104,   14,  105,    4,   10,   15,
525
      11,    6,   14,    8,  106,  107,  108,   15,
526
     109,    9,   55,   10,    1,    2,    1,    2,
527
       3,   12,    6,    2,    6,    7,   28,    7,
528
      15,    8,    5,   18,   29,  152,   77,   24,
529
      25,   26,   39,  108,   13,  109,   55,   56,
530
      57,  116,   11,  153,  234,  235,  118,  119,
531
      15 /* 73 elements */
532
  }
533
};
534
static const uint8_t vc1_mv_diff_bits[4][73] = {
535
  {
536
     6,  7,  7,  8, 14,  6,  5,  6,  7, 14, 14,  6,  6,  6,  8,  9,
537
    10,  9,  7,  7,  7, 14, 14, 10,  9, 10,  8, 10, 10, 14, 14, 14,
538
    13, 13, 13,  6,  3,  5,  6,  8,  9, 13,  5,  4,  4,  5,  7,  9,
539
     6,  5,  5,  5,  6,  9,  8,  5,  5,  5,  7, 10,  7,  7,  7,  7,
540
     7,  8, 10,  9,  8,  9,  9,  9,  3 /* 73 elements */
541
  },
542
  {
543
     5,  7,  7,  6,  6,  5,  5,  6,  7,  5,  7,  8,  8,  8, 14,  9,
544
     9,  9,  8, 14, 14,  9,  9, 14,  9, 14, 14, 14, 14, 14, 14, 14,
545
    14, 14, 14, 14,  2,  3,  6,  8,  8,  6,  3,  4,  6,  8,  6,  9,
546
     6,  6,  6,  8,  8,  8, 14,  7,  7,  8,  7,  9, 13,  9,  8,  9,
547
    13,  9, 13, 13, 13, 13, 13, 13,  5 /* 73 elements */
548

  
549
  },
550
  {
551
     3, 12, 12, 12, 12,  3,  4, 11, 11, 11, 11, 11, 11, 11, 11, 11,
552
    11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
553
    11, 11, 11, 11,  1,  5, 11, 11, 11, 11,  4,  4, 11, 11, 11, 11,
554
    11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
555
    11, 11, 11, 11, 11, 11, 11, 11, 11 /* 73 elements */
556
  },
557
  {
558
    15, 11, 15, 15, 15, 15, 12, 15, 12, 11, 12, 12, 15, 12, 12, 12,
559
    12, 15, 15, 12, 15, 10, 11, 12, 11, 10, 11, 10, 15, 15, 15, 11,
560
    15, 10, 14, 10,  4,  4,  5,  7,  8,  9,  5,  3,  4,  5,  6,  8,
561
     5,  4,  3,  5,  6,  8,  7,  5,  5,  5,  6,  7,  9,  7,  6,  6,
562
     6,  7, 10,  8,  8,  8,  7,  7,  4 /* 73 elements */
563
  }
564
};
136
extern const uint16_t vc1_mv_diff_codes[4][73];
137
extern const uint8_t vc1_mv_diff_bits[4][73];
565 138

  
566 139
/* DC differentials low+hi-mo, p217 are the same as in msmpeg4data .h */
567 140

  
568 141
/* Scantables/ZZ scan are at 11.9 (p262) and 8.1.1.12 (p10) */
569
static const int8_t vc1_normal_zz[64] = {
570
       0,     8,     1,     2,     9,    16,    24,    17,
571
      10,     3,     4,    11,    18,    25,    32,    40,
572
      33,    48,    26,    19,    12,     5,     6,    13,
573
      20,    27,    34,    41,    56,    49,    57,    42,
574
      35,    28,    21,    14,     7,    15,    22,    29,
575
      36,    43,    50,    58,    51,    59,    44,    37,
576
      30,    23,    31,    38,    45,    52,    60,    53,
577
      61,    46,    39,    47,    54,    62,    55,    63
578
};
579

  
580
static const int8_t vc1_horizontal_zz [64] = /* Table 227 */
581
{
582
       0,     1,     8,     2,     3,     9,    16,    24,
583
      17,    10,     4,     5,    11,    18,    25,    32,
584
      40,    48,    33,    26,    19,    12,     6,     7,
585
      13,    20,    27,    34,    41,    56,    49,    57,
586
      42,    35,    28,    21,    14,    15,    22,    29,
587
      36,    43,    50,    58,    51,    44,    37,    30,
588
      23,    31,    38,    45,    52,    59,    60,    53,
589
      46,    39,    47,    54,    61,    62,    55,    63
590
};
591

  
592
static const int8_t vc1_vertical_zz [64] = /* Table 228 */
593
{
594
       0,     8,    16,     1,    24,    32,    40,     9,
595
       2,     3,    10,    17,    25,    48,    56,    41,
596
      33,    26,    18,    11,     4,     5,    12,    19,
597
      27,    34,    49,    57,    50,    42,    35,    28,
598
      20,    13,     6,     7,    14,    21,    29,    36,
599
      43,    51,    58,    59,    52,    44,    37,    30,
600
      22,    15,    23,    31,    38,    45,    60,    53,
601
      46,    39,    47,    54,    61,    62,    55,    63
602
};
603

  
604
static const int8_t vc1_simple_progressive_8x8_zz [64] =
605
/* Table 229 */
606
{
607
       0,     8,     1,     2,     9,    16,    24,    17,
608
      10,     3,     4,    11,    18,    25,    32,    40,
609
      48,    56,    41,    33,    26,    19,    12,     5,
610
       6,    13,    20,    27,    34,    49,    57,    58,
611
      50,    42,    35,    28,    21,    14,     7,    15,
612
      22,    29,    36,    43,    51,    59,    60,    52,
613
      44,    37,    30,    23,    31,    38,    45,    53,
614
      61,    62,    54,    46,    39,    47,    55,    63
615
};
616

  
617
static const int8_t vc1_simple_progressive_8x4_zz [32] = /* Table 230 */
618
{
619
       0,     1,     2,     8,     3,     9,    10,    16,
620
       4,    11,    17,    24,    18,    12,     5,    19,
621
      25,    13,    20,    26,    27,     6,    21,    28,
622
      14,    22,    29,     7,    30,    15,    23,    31
623
};
624

  
625
static const int8_t vc1_simple_progressive_4x8_zz [32] = /* Table 231 */
626
{
627
       0,     8,     1,    16,
628
       9,    24,    17,     2,
629
      32,    10,    25,    40,
630
      18,    48,    33,    26,
631
      56,    41,    34,     3,
632
      49,    57,    11,    42,
633
      19,    50,    27,    58,
634
      35,    43,    51,    59
635
};
636

  
637
/* Table 232 */
638
static const int8_t vc1_simple_progressive_4x4_zz [16] =
639
{
640
       0,     8,    16,     1,
641
       9,    24,    17,     2,
642
      10,    18,    25,     3,
643
      11,    26,    19,    27
644
};
645

  
646
static const int8_t vc1_adv_progressive_8x4_zz [32] = /* Table 233 */
647
{
648
       0,     8,     1,    16,     2,     9,    10,     3,
649
      24,    17,     4,    11,    18,    12,     5,    19,
650
      25,    13,    20,    26,    27,     6,    21,    28,
651
      14,    22,    29,     7,    30,    15,    23,    31
652
};
653

  
654
static const int8_t vc1_adv_progressive_4x8_zz [32] = /* Table 234 */
655
{
656
       0,     1,     8,     2,
657
       9,    16,    17,    24,
658
      10,    32,    25,    18,
659
      40,     3,    33,    26,
660
      48,    11,    56,    41,
661
      34,    49,    57,    42,
662
      19,    50,    27,    58,
663
      35,    43,    51,    59
664
};
665

  
666
static const int8_t vc1_adv_interlaced_8x8_zz [64] = /* Table 235 */
667
{
668
       0,     8,     1,    16,    24,     9,     2,    32,
669
      40,    48,    56,    17,    10,     3,    25,    18,
670
      11,     4,    33,    41,    49,    57,    26,    34,
671
      42,    50,    58,    19,    12,     5,    27,    20,
672
      13,     6,    35,    28,    21,    14,     7,    15,
673
      22,    29,    36,    43,    51,    59,    60,    52,
674
      44,    37,    30,    23,    31,    38,    45,    53,
675
      61,    62,    54,    46,    39,    47,    55,    63
676
};
677

  
678
static const int8_t vc1_adv_interlaced_8x4_zz [32] = /* Table 236 */
679
{
680
       0,     8,    16,    24,     1,     9,     2,    17,
681
      25,    10,     3,    18,    26,     4,    11,    19,
682
      12,     5,    13,    20,    27,     6,    21,    28,
683
      14,    22,    29,     7,    30,    15,    23,    31
684
};
685

  
686
static const int8_t vc1_adv_interlaced_4x8_zz [32] = /* Table 237 */
687
{
688
       0,     1,     2,     8,
689
      16,     9,    24,    17,
690
      10,     3,    32,    40,
691
      48,    56,    25,    18,
692
      33,    26,    41,    34,
693
      49,    57,    11,    42,
694
      19,    50,    27,    58,
695
      35,    43,    51,    59
696
};
697

  
698
static const int8_t vc1_adv_interlaced_4x4_zz [16] = /* Table 238 */
699
{
700
       0,     8,    16,    24,
701
       1,     9,    17,     2,
702
      25,    10,    18,     3,
703
      26,    11,    19,    27
704
};
705

  
142
extern const int8_t vc1_normal_zz[64];
143
extern const int8_t vc1_horizontal_zz [64];
144
extern const int8_t vc1_vertical_zz [64];
145
extern const int8_t vc1_simple_progressive_8x8_zz [64];
146
extern const int8_t vc1_simple_progressive_8x4_zz [32];
147
extern const int8_t vc1_simple_progressive_4x8_zz [32];
148
extern const int8_t vc1_simple_progressive_4x4_zz [16];
149
extern const int8_t vc1_adv_progressive_8x4_zz [32];
150
extern const int8_t vc1_adv_progressive_4x8_zz [32];
151
extern const int8_t vc1_adv_interlaced_8x8_zz [64];
152
extern const int8_t vc1_adv_interlaced_8x4_zz [32];
153
extern const int8_t vc1_adv_interlaced_4x8_zz [32];
154
extern const int8_t vc1_adv_interlaced_4x4_zz [16];
706 155

  
707 156
/* DQScale as specified in 8.1.3.9 - almost identical to 0x40000/i */
708
static const int32_t vc1_dqscale[63] = {
709
0x40000, 0x20000, 0x15555, 0x10000, 0xCCCD, 0xAAAB, 0x9249, 0x8000,
710
    0x71C7, 0x6666, 0x5D17, 0x5555, 0x4EC5, 0x4925, 0x4444, 0x4000,
711
    0x3C3C, 0x38E4, 0x35E5, 0x3333, 0x30C3, 0x2E8C, 0x2C86, 0x2AAB,
712
    0x28F6, 0x2762, 0x25ED, 0x2492, 0x234F, 0x2222, 0x2108, 0x2000,
713
    0x1F08, 0x1E1E, 0x1D42, 0x1C72, 0x1BAD, 0x1AF3, 0x1A42, 0x199A,
714
    0x18FA, 0x1862, 0x17D0, 0x1746, 0x16C1, 0x1643, 0x15CA, 0x1555,
715
    0x14E6, 0x147B, 0x1414, 0x13B1, 0x1352, 0x12F7, 0x129E, 0x1249,
716
    0x11F7, 0x11A8, 0x115B, 0x1111, 0x10C9, 0x1084, 0x1000
717
};
157
extern const int32_t vc1_dqscale[63];
158

  
718 159
#endif /* VC1DATA_H */

Also available in: Unified diff