aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/indeo4data.h
blob: 35ff404e183bbe249a8a41082bfbad9bbf2b259b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
/*
 * Indeo Video Interactive 4 compatible decoder
 * Copyright (c) 2009-2010 Maxim Poliakovski
 *
 * This file is part of Libav.
 *
 * Libav is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * Libav is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with Libav; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

/**
 * @file
 * This file contains data needed for the Indeo 4 decoder.
 */

#ifndef AVCODEC_INDEO4DATA_H
#define AVCODEC_INDEO4DATA_H

#include <stdint.h>

#include "ivi.h"

/**
 *  standard picture dimensions
 */
static const uint16_t ivi4_common_pic_sizes[14] = {
    640, 480, 320, 240, 160, 120, 704, 480, 352, 240, 352, 288, 176, 144
};

/**
 *  Indeo 4 8x8 scan (zigzag) patterns
 */
static const uint8_t ivi4_alternate_scan_8x8[64] = {
     0,  8,  1,  9, 16, 24,  2,  3, 17, 25, 10, 11, 32, 40, 48, 56,
     4,  5,  6,  7, 33, 41, 49, 57, 18, 19, 26, 27, 12, 13, 14, 15,
    34, 35, 43, 42, 50, 51, 59, 58, 20, 21, 22, 23, 31, 30, 29, 28,
    36, 37, 38, 39, 47, 46, 45, 44, 52, 53, 54, 55, 63, 62, 61, 60
};

static const uint8_t ivi4_alternate_scan_4x4[16] = {
    0, 1, 4, 5, 8, 12, 2, 3, 9, 13, 6, 7, 10, 11, 14, 15
};

static const uint8_t ivi4_vertical_scan_4x4[16] = {
    0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15
};

static const uint8_t ivi4_horizontal_scan_4x4[16] = {
    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
};

static const uint8_t * const scan_index_to_tab[15] = {
    // for 8x8 transforms
    ff_zigzag_direct,
    ivi4_alternate_scan_8x8,
    ff_ivi_horizontal_scan_8x8,
    ff_ivi_vertical_scan_8x8,
    ff_zigzag_direct,

    // for 4x4 transforms
    ff_ivi_direct_scan_4x4,
    ivi4_alternate_scan_4x4,
    ivi4_vertical_scan_4x4,
    ivi4_horizontal_scan_4x4,
    ff_ivi_direct_scan_4x4,

    // TODO: check if those are needed
    ff_ivi_horizontal_scan_8x8,
    ff_ivi_horizontal_scan_8x8,
    ff_ivi_horizontal_scan_8x8,
    ff_ivi_horizontal_scan_8x8,
    ff_ivi_horizontal_scan_8x8
};

/**
 *  Indeo 4 dequant tables
 */
static const uint16_t ivi4_quant_8x8_intra[9][64] = {
  {
      43,  342,  385,  470,  555,  555,  598,  726,
     342,  342,  470,  513,  555,  598,  726,  769,
     385,  470,  555,  555,  598,  726,  726,  811,
     470,  470,  555,  555,  598,  726,  769,  854,
     470,  555,  555,  598,  683,  726,  854, 1025,
     555,  555,  598,  683,  726,  854, 1025, 1153,
     555,  555,  598,  726,  811,  982, 1195, 1451,
     555,  598,  726,  811,  982, 1195, 1451, 1793
  },
  {
      86, 1195, 2390, 2390, 4865, 4865, 4865, 4865,
    1195, 1195, 2390, 2390, 4865, 4865, 4865, 4865,
    2390, 2390, 4865, 4865, 6827, 6827, 6827, 6827,
    2390, 2390, 4865, 4865, 6827, 6827, 6827, 6827,
    4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
    4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
    4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
    4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827
  },
  {
     235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
     235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
     235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
     235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
     235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
     235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
     235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
     235, 1067, 1195, 1323, 1451, 1579, 1707, 1835
  },
  {
    1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
    1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
    1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
    1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
    1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
    1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
    1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
    1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414
  },
  {
     897,  897,  897,  897,  897,  897,  897,  897,
    1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067,
    1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238,
    1409, 1409, 1409, 1409, 1409, 1409, 1409, 1409,
    1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579,
    1750, 1750, 1750, 1750, 1750, 1750, 1750, 1750,
    1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921,
    2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091
  },
  {
    1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
    1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
    3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
    3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
    3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
    3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
    3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
    3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414
  },
  {
    2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
    2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
    2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
    2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
    2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
    2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
    2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
    2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390
  },
  {
      22,  171,  214,  257,  257,  299,  299,  342,
     171,  171,  257,  257,  299,  299,  342,  385,
     214,  257,  257,  299,  299,  342,  342,  385,
     257,  257,  257,  299,  299,  342,  385,  427,
     257,  257,  299,  299,  342,  385,  427,  513,
     257,  299,  299,  342,  385,  427,  513,  598,
     299,  299,  299,  385,  385,  470,  598,  726,
     299,  299,  385,  385,  470,  598,  726,  897
  },
  {
      86,  598, 1195, 1195, 2390, 2390, 2390, 2390,
     598,  598, 1195, 1195, 2390, 2390, 2390, 2390,
    1195, 1195, 2390, 2390, 3414, 3414, 3414, 3414,
    1195, 1195, 2390, 2390, 3414, 3414, 3414, 3414,
    2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
    2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
    2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
    2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414
  }
};

static const uint16_t ivi4_quant_8x8_inter[9][64] = {
  {
     427,  427,  470,  427,  427,  427,  470,  470,
     427,  427,  470,  427,  427,  427,  470,  470,
     470,  470,  470,  470,  470,  470,  470,  470,
     427,  427,  470,  470,  427,  427,  470,  470,
     427,  427,  470,  427,  427,  427,  470,  470,
     427,  427,  470,  427,  427,  427,  470,  470,
     470,  470,  470,  470,  470,  470,  470,  470,
     470,  470,  470,  470,  470,  470,  470,  470
  },
  {
    1707, 1707, 2433, 2433, 3414, 3414, 3414, 3414,
    1707, 1707, 2433, 2433, 3414, 3414, 3414, 3414,
    2433, 2433, 3414, 3414, 4822, 4822, 4822, 4822,
    2433, 2433, 3414, 3414, 4822, 4822, 4822, 4822,
    3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
    3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
    3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
    3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414
  },
  {
    1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
    1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
    1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
    1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
    1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
    1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
    1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
    1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281
  },
  {
    2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
    2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
    2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
    2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
    2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
    2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
    2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
    2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433
  },
  {
    1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
    1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
    1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281,
    1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238,
    1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
    1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
    1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281,
    1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281
  },
  {
    2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
    2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
    3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
    3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
    2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
    2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
    2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
    2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433
  },
  {
    1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
    1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
    1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
    1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
    1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
    1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
    1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
    1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707
  },
  {
      86,  171,  171,  214,  214,  214,  214,  257,
     171,  171,  214,  214,  214,  214,  257,  257,
     171,  214,  214,  214,  214,  257,  257,  257,
     214,  214,  214,  214,  257,  257,  257,  299,
     214,  214,  214,  257,  257,  257,  299,  299,
     214,  214,  257,  257,  257,  299,  299,  299,
     214,  257,  257,  257,  299,  299,  299,  342,
     257,  257,  257,  299,  299,  299,  342,  342
  },
  {
     854,  854, 1195, 1195, 1707, 1707, 1707, 1707,
     854,  854, 1195, 1195, 1707, 1707, 1707, 1707,
    1195, 1195, 1707, 1707, 2390, 2390, 2390, 2390,
    1195, 1195, 1707, 1707, 2390, 2390, 2390, 2390,
    1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
    1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
    1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
    1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707
  }
};

static const uint16_t ivi4_quant_4x4_intra[5][16] = {
  {
      22,  214,  257,  299,
     214,  257,  299,  342,
     257,  299,  342,  427,
     299,  342,  427,  513
  },
  {
     129, 1025, 1451, 1451,
    1025, 1025, 1451, 1451,
    1451, 1451, 2049, 2049,
    1451, 1451, 2049, 2049
  },
  {
      43,  171,  171,  171,
      43,  171,  171,  171,
      43,  171,  171,  171,
      43,  171,  171,  171
  },
  {
      43,   43,   43,   43,
     171,  171,  171,  171,
     171,  171,  171,  171,
     171,  171,  171,  171
  },
  {
      43,   43,   43,   43,
      43,   43,   43,   43,
      43,   43,   43,   43,
      43,   43,   43,   43
  }
};

static const uint16_t ivi4_quant_4x4_inter[5][16] = {
  {
     107,  214,  257,  299,
     214,  257,  299,  299,
     257,  299,  299,  342,
     299,  299,  342,  342
  },
  {
     513, 1025, 1238, 1238,
    1025, 1025, 1238, 1238,
    1238, 1238, 1451, 1451,
    1238, 1238, 1451, 1451
  },
  {
      43,  171,  171,  171,
      43,  171,  171,  171,
      43,  171,  171,  171,
      43,  171,  171,  171
  },
  {
      43,   43,   43,   43,
     171,  171,  171,  171,
     171,  171,  171,  171,
     171,  171,  171,  171
  },
  {
      43,   43,   43,   43,
      43,   43,   43,   43,
      43,   43,   43,   43,
      43,   43,   43,   43
  }
};

/**
 *  Table for mapping quant matrix index from the bitstream
 *  into internal quant table number.
 */
static const uint8_t quant_index_to_tab[22] = {
    0, 1, 0, 2, 1, 3, 0, 4, 1, 5, 0, 1, 6, 7, 8, // for 8x8 quant matrixes
    0, 1, 2, 2, 3, 3, 4                          // for 4x4 quant matrixes
};

#endif /* AVCODEC_INDEO4DATA_H */