]> git.sesse.net Git - ffmpeg/blob - libavcodec/indeo4data.h
avformat/avio: Add Metacube support
[ffmpeg] / libavcodec / indeo4data.h
1 /*
2  * Indeo Video Interactive 4 compatible decoder
3  * Copyright (c) 2009-2010 Maxim Poliakovski
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21
22 /**
23  * @file
24  * This file contains data needed for the Indeo 4 decoder.
25  */
26
27 #ifndef AVCODEC_INDEO4DATA_H
28 #define AVCODEC_INDEO4DATA_H
29
30 #include <stdint.h>
31
32 #include "ivi.h"
33
34 /**
35  *  standard picture dimensions
36  */
37 static const uint16_t ivi4_common_pic_sizes[14] = {
38     640, 480, 320, 240, 160, 120, 704, 480, 352, 240, 352, 288, 176, 144
39 };
40
41 /**
42  *  Indeo 4 8x8 scan (zigzag) patterns
43  */
44 static const uint8_t ivi4_alternate_scan_8x8[64] = {
45      0,  8,  1,  9, 16, 24,  2,  3, 17, 25, 10, 11, 32, 40, 48, 56,
46      4,  5,  6,  7, 33, 41, 49, 57, 18, 19, 26, 27, 12, 13, 14, 15,
47     34, 35, 43, 42, 50, 51, 59, 58, 20, 21, 22, 23, 31, 30, 29, 28,
48     36, 37, 38, 39, 47, 46, 45, 44, 52, 53, 54, 55, 63, 62, 61, 60
49 };
50
51 static const uint8_t ivi4_alternate_scan_4x4[16] = {
52     0, 1, 4, 5, 8, 12, 2, 3, 9, 13, 6, 7, 10, 11, 14, 15
53 };
54
55 static const uint8_t ivi4_vertical_scan_4x4[16] = {
56     0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15
57 };
58
59 static const uint8_t ivi4_horizontal_scan_4x4[16] = {
60     0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
61 };
62
63 static const uint8_t * const scan_index_to_tab[15] = {
64     // for 8x8 transforms
65     ff_zigzag_direct,
66     ivi4_alternate_scan_8x8,
67     ff_ivi_horizontal_scan_8x8,
68     ff_ivi_vertical_scan_8x8,
69     ff_zigzag_direct,
70
71     // for 4x4 transforms
72     ff_ivi_direct_scan_4x4,
73     ivi4_alternate_scan_4x4,
74     ivi4_vertical_scan_4x4,
75     ivi4_horizontal_scan_4x4,
76     ff_ivi_direct_scan_4x4,
77
78     // TODO: check if those are needed
79     ff_ivi_horizontal_scan_8x8,
80     ff_ivi_horizontal_scan_8x8,
81     ff_ivi_horizontal_scan_8x8,
82     ff_ivi_horizontal_scan_8x8,
83     ff_ivi_horizontal_scan_8x8
84 };
85
86 /**
87  *  Indeo 4 dequant tables
88  */
89 static const uint16_t ivi4_quant_8x8_intra[9][64] = {
90   {
91       43,  342,  385,  470,  555,  555,  598,  726,
92      342,  342,  470,  513,  555,  598,  726,  769,
93      385,  470,  555,  555,  598,  726,  726,  811,
94      470,  470,  555,  555,  598,  726,  769,  854,
95      470,  555,  555,  598,  683,  726,  854, 1025,
96      555,  555,  598,  683,  726,  854, 1025, 1153,
97      555,  555,  598,  726,  811,  982, 1195, 1451,
98      555,  598,  726,  811,  982, 1195, 1451, 1793
99   },
100   {
101       86, 1195, 2390, 2390, 4865, 4865, 4865, 4865,
102     1195, 1195, 2390, 2390, 4865, 4865, 4865, 4865,
103     2390, 2390, 4865, 4865, 6827, 6827, 6827, 6827,
104     2390, 2390, 4865, 4865, 6827, 6827, 6827, 6827,
105     4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
106     4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
107     4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
108     4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827
109   },
110   {
111      235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
112      235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
113      235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
114      235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
115      235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
116      235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
117      235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
118      235, 1067, 1195, 1323, 1451, 1579, 1707, 1835
119   },
120   {
121     1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
122     1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
123     1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
124     1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
125     1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
126     1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
127     1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
128     1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414
129   },
130   {
131      897,  897,  897,  897,  897,  897,  897,  897,
132     1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067,
133     1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238,
134     1409, 1409, 1409, 1409, 1409, 1409, 1409, 1409,
135     1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579,
136     1750, 1750, 1750, 1750, 1750, 1750, 1750, 1750,
137     1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921,
138     2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091
139   },
140   {
141     1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
142     1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
143     3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
144     3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
145     3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
146     3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
147     3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
148     3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414
149   },
150   {
151     2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
152     2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
153     2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
154     2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
155     2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
156     2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
157     2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
158     2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390
159   },
160   {
161       22,  171,  214,  257,  257,  299,  299,  342,
162      171,  171,  257,  257,  299,  299,  342,  385,
163      214,  257,  257,  299,  299,  342,  342,  385,
164      257,  257,  257,  299,  299,  342,  385,  427,
165      257,  257,  299,  299,  342,  385,  427,  513,
166      257,  299,  299,  342,  385,  427,  513,  598,
167      299,  299,  299,  385,  385,  470,  598,  726,
168      299,  299,  385,  385,  470,  598,  726,  897
169   },
170   {
171       86,  598, 1195, 1195, 2390, 2390, 2390, 2390,
172      598,  598, 1195, 1195, 2390, 2390, 2390, 2390,
173     1195, 1195, 2390, 2390, 3414, 3414, 3414, 3414,
174     1195, 1195, 2390, 2390, 3414, 3414, 3414, 3414,
175     2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
176     2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
177     2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
178     2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414
179   }
180 };
181
182 static const uint16_t ivi4_quant_8x8_inter[9][64] = {
183   {
184      427,  427,  470,  427,  427,  427,  470,  470,
185      427,  427,  470,  427,  427,  427,  470,  470,
186      470,  470,  470,  470,  470,  470,  470,  470,
187      427,  427,  470,  470,  427,  427,  470,  470,
188      427,  427,  470,  427,  427,  427,  470,  470,
189      427,  427,  470,  427,  427,  427,  470,  470,
190      470,  470,  470,  470,  470,  470,  470,  470,
191      470,  470,  470,  470,  470,  470,  470,  470
192   },
193   {
194     1707, 1707, 2433, 2433, 3414, 3414, 3414, 3414,
195     1707, 1707, 2433, 2433, 3414, 3414, 3414, 3414,
196     2433, 2433, 3414, 3414, 4822, 4822, 4822, 4822,
197     2433, 2433, 3414, 3414, 4822, 4822, 4822, 4822,
198     3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
199     3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
200     3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
201     3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414
202   },
203   {
204     1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
205     1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
206     1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
207     1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
208     1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
209     1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
210     1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
211     1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281
212   },
213   {
214     2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
215     2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
216     2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
217     2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
218     2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
219     2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
220     2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
221     2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433
222   },
223   {
224     1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
225     1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
226     1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281,
227     1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238,
228     1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
229     1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
230     1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281,
231     1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281
232   },
233   {
234     2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
235     2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
236     3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
237     3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
238     2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
239     2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
240     2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
241     2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433
242   },
243   {
244     1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
245     1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
246     1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
247     1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
248     1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
249     1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
250     1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
251     1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707
252   },
253   {
254       86,  171,  171,  214,  214,  214,  214,  257,
255      171,  171,  214,  214,  214,  214,  257,  257,
256      171,  214,  214,  214,  214,  257,  257,  257,
257      214,  214,  214,  214,  257,  257,  257,  299,
258      214,  214,  214,  257,  257,  257,  299,  299,
259      214,  214,  257,  257,  257,  299,  299,  299,
260      214,  257,  257,  257,  299,  299,  299,  342,
261      257,  257,  257,  299,  299,  299,  342,  342
262   },
263   {
264      854,  854, 1195, 1195, 1707, 1707, 1707, 1707,
265      854,  854, 1195, 1195, 1707, 1707, 1707, 1707,
266     1195, 1195, 1707, 1707, 2390, 2390, 2390, 2390,
267     1195, 1195, 1707, 1707, 2390, 2390, 2390, 2390,
268     1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
269     1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
270     1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
271     1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707
272   }
273 };
274
275 static const uint16_t ivi4_quant_4x4_intra[5][16] = {
276   {
277       22,  214,  257,  299,
278      214,  257,  299,  342,
279      257,  299,  342,  427,
280      299,  342,  427,  513
281   },
282   {
283      129, 1025, 1451, 1451,
284     1025, 1025, 1451, 1451,
285     1451, 1451, 2049, 2049,
286     1451, 1451, 2049, 2049
287   },
288   {
289       43,  171,  171,  171,
290       43,  171,  171,  171,
291       43,  171,  171,  171,
292       43,  171,  171,  171
293   },
294   {
295       43,   43,   43,   43,
296      171,  171,  171,  171,
297      171,  171,  171,  171,
298      171,  171,  171,  171
299   },
300   {
301       43,   43,   43,   43,
302       43,   43,   43,   43,
303       43,   43,   43,   43,
304       43,   43,   43,   43
305   }
306 };
307
308 static const uint16_t ivi4_quant_4x4_inter[5][16] = {
309   {
310      107,  214,  257,  299,
311      214,  257,  299,  299,
312      257,  299,  299,  342,
313      299,  299,  342,  342
314   },
315   {
316      513, 1025, 1238, 1238,
317     1025, 1025, 1238, 1238,
318     1238, 1238, 1451, 1451,
319     1238, 1238, 1451, 1451
320   },
321   {
322       43,  171,  171,  171,
323       43,  171,  171,  171,
324       43,  171,  171,  171,
325       43,  171,  171,  171
326   },
327   {
328       43,   43,   43,   43,
329      171,  171,  171,  171,
330      171,  171,  171,  171,
331      171,  171,  171,  171
332   },
333   {
334       43,   43,   43,   43,
335       43,   43,   43,   43,
336       43,   43,   43,   43,
337       43,   43,   43,   43
338   }
339 };
340
341 /**
342  *  Table for mapping quant matrix index from the bitstream
343  *  into internal quant table number.
344  */
345 static const uint8_t quant_index_to_tab[22] = {
346     0, 1, 0, 2, 1, 3, 0, 4, 1, 5, 0, 1, 6, 7, 8, // for 8x8 quant matrixes
347     0, 1, 2, 2, 3, 3, 4                          // for 4x4 quant matrixes
348 };
349
350 #endif /* AVCODEC_INDEO4DATA_H */