FFmpeg
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vp6data.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /**
22  * @file
23  * VP6 compatible video decoder
24  */
25 
26 #ifndef AVCODEC_VP6DATA_H
27 #define AVCODEC_VP6DATA_H
28 
29 #include "vp56data.h"
30 
31 static const uint8_t vp6_def_fdv_vector_model[2][8] = {
32  { 247, 210, 135, 68, 138, 220, 239, 246 },
33  { 244, 184, 201, 44, 173, 221, 239, 253 },
34 };
35 
36 static const uint8_t vp6_def_pdv_vector_model[2][7] = {
37  { 225, 146, 172, 147, 214, 39, 156 },
38  { 204, 170, 119, 235, 140, 230, 228 },
39 };
40 
41 static const uint8_t vp6_def_coeff_reorder[] = {
42  0, 0, 1, 1, 1, 2, 2, 2,
43  2, 2, 2, 3, 3, 4, 4, 4,
44  5, 5, 5, 5, 6, 6, 7, 7,
45  7, 7, 7, 8, 8, 9, 9, 9,
46  9, 9, 9, 10, 10, 11, 11, 11,
47  11, 11, 11, 12, 12, 12, 12, 12,
48  12, 13, 13, 13, 13, 13, 14, 14,
49  14, 14, 15, 15, 15, 15, 15, 15,
50 };
51 
52 static const uint8_t vp6_def_runv_coeff_model[2][14] = {
53  { 198, 197, 196, 146, 198, 204, 169, 142, 130, 136, 149, 149, 191, 249 },
54  { 135, 201, 181, 154, 98, 117, 132, 126, 146, 169, 184, 240, 246, 254 },
55 };
56 
57 static const uint8_t vp6_sig_dct_pct[2][2] = {
58  { 237, 246 },
59  { 231, 243 },
60 };
61 
62 static const uint8_t vp6_pdv_pct[2][7] = {
63  { 253, 253, 254, 254, 254, 254, 254 },
64  { 245, 253, 254, 254, 254, 254, 254 },
65 };
66 
67 static const uint8_t vp6_fdv_pct[2][8] = {
68  { 254, 254, 254, 254, 254, 250, 250, 252 },
69  { 254, 254, 254, 254, 254, 251, 251, 254 },
70 };
71 
72 static const uint8_t vp6_dccv_pct[2][11] = {
73  { 146, 255, 181, 207, 232, 243, 238, 251, 244, 250, 249 },
74  { 179, 255, 214, 240, 250, 255, 244, 255, 255, 255, 255 },
75 };
76 
77 static const uint8_t vp6_coeff_reorder_pct[] = {
78  255, 132, 132, 159, 153, 151, 161, 170,
79  164, 162, 136, 110, 103, 114, 129, 118,
80  124, 125, 132, 136, 114, 110, 142, 135,
81  134, 123, 143, 126, 153, 183, 166, 161,
82  171, 180, 179, 164, 203, 218, 225, 217,
83  215, 206, 203, 217, 229, 241, 248, 243,
84  253, 255, 253, 255, 255, 255, 255, 255,
85  255, 255, 255, 255, 255, 255, 255, 255,
86 };
87 
88 static const uint8_t vp6_runv_pct[2][14] = {
89  { 219, 246, 238, 249, 232, 239, 249, 255, 248, 253, 239, 244, 241, 248 },
90  { 198, 232, 251, 253, 219, 241, 253, 255, 248, 249, 244, 238, 251, 255 },
91 };
92 
93 static const uint8_t vp6_ract_pct[3][2][6][11] = {
94  { { { 227, 246, 230, 247, 244, 255, 255, 255, 255, 255, 255 },
95  { 255, 255, 209, 231, 231, 249, 249, 253, 255, 255, 255 },
96  { 255, 255, 225, 242, 241, 251, 253, 255, 255, 255, 255 },
97  { 255, 255, 241, 253, 252, 255, 255, 255, 255, 255, 255 },
98  { 255, 255, 248, 255, 255, 255, 255, 255, 255, 255, 255 },
99  { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 } },
100  { { 240, 255, 248, 255, 255, 255, 255, 255, 255, 255, 255 },
101  { 255, 255, 240, 253, 255, 255, 255, 255, 255, 255, 255 },
102  { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
103  { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
104  { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
105  { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 } } },
106  { { { 206, 203, 227, 239, 247, 255, 253, 255, 255, 255, 255 },
107  { 207, 199, 220, 236, 243, 252, 252, 255, 255, 255, 255 },
108  { 212, 219, 230, 243, 244, 253, 252, 255, 255, 255, 255 },
109  { 236, 237, 247, 252, 253, 255, 255, 255, 255, 255, 255 },
110  { 240, 240, 248, 255, 255, 255, 255, 255, 255, 255, 255 },
111  { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 } },
112  { { 230, 233, 249, 255, 255, 255, 255, 255, 255, 255, 255 },
113  { 238, 238, 250, 255, 255, 255, 255, 255, 255, 255, 255 },
114  { 248, 251, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
115  { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
116  { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
117  { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 } } },
118  { { { 225, 239, 227, 231, 244, 253, 243, 255, 255, 253, 255 },
119  { 232, 234, 224, 228, 242, 249, 242, 252, 251, 251, 255 },
120  { 235, 249, 238, 240, 251, 255, 249, 255, 253, 253, 255 },
121  { 249, 253, 251, 250, 255, 255, 255, 255, 255, 255, 255 },
122  { 251, 250, 249, 255, 255, 255, 255, 255, 255, 255, 255 },
123  { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 } },
124  { { 243, 244, 250, 250, 255, 255, 255, 255, 255, 255, 255 },
125  { 249, 248, 250, 253, 255, 255, 255, 255, 255, 255, 255 },
126  { 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
127  { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
128  { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
129  { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 } } }
130 };
131 
132 static const int vp6_dccv_lc[3][5][2] = {
133  { { 122, 133 }, { 0, 1 }, { 78, 171 }, { 139, 117 }, { 168, 79 } },
134  { { 133, 51 }, { 0, 1 }, { 169, 71 }, { 214, 44 }, { 210, 38 } },
135  { { 142, -16 }, { 0, 1 }, { 221, -30 }, { 246, -3 }, { 203, 17 } },
136 };
137 
138 static const uint8_t vp6_coeff_groups[] = {
139  0, 0, 1, 1, 1, 2, 2, 2,
140  2, 2, 2, 3, 3, 3, 3, 3,
141  3, 3, 3, 3, 3, 3, 4, 4,
142  4, 4, 4, 4, 4, 4, 4, 4,
143  4, 4, 4, 4, 4, 5, 5, 5,
144  5, 5, 5, 5, 5, 5, 5, 5,
145  5, 5, 5, 5, 5, 5, 5, 5,
146  5, 5, 5, 5, 5, 5, 5, 5,
147 };
148 
149 static const int16_t vp6_block_copy_filter[17][8][4] = {
150  { { 0, 128, 0, 0 }, /* 0 */
151  { -3, 122, 9, 0 },
152  { -4, 109, 24, -1 },
153  { -5, 91, 45, -3 },
154  { -4, 68, 68, -4 },
155  { -3, 45, 91, -5 },
156  { -1, 24, 109, -4 },
157  { 0, 9, 122, -3 } },
158  { { 0, 128, 0, 0 }, /* 1 */
159  { -4, 124, 9, -1 },
160  { -5, 110, 25, -2 },
161  { -6, 91, 46, -3 },
162  { -5, 69, 69, -5 },
163  { -3, 46, 91, -6 },
164  { -2, 25, 110, -5 },
165  { -1, 9, 124, -4 } },
166  { { 0, 128, 0, 0 }, /* 2 */
167  { -4, 123, 10, -1 },
168  { -6, 110, 26, -2 },
169  { -7, 92, 47, -4 },
170  { -6, 70, 70, -6 },
171  { -4, 47, 92, -7 },
172  { -2, 26, 110, -6 },
173  { -1, 10, 123, -4 } },
174  { { 0, 128, 0, 0 }, /* 3 */
175  { -5, 124, 10, -1 },
176  { -7, 110, 27, -2 },
177  { -7, 91, 48, -4 },
178  { -6, 70, 70, -6 },
179  { -4, 48, 92, -8 },
180  { -2, 27, 110, -7 },
181  { -1, 10, 124, -5 } },
182  { { 0, 128, 0, 0 }, /* 4 */
183  { -6, 124, 11, -1 },
184  { -8, 111, 28, -3 },
185  { -8, 92, 49, -5 },
186  { -7, 71, 71, -7 },
187  { -5, 49, 92, -8 },
188  { -3, 28, 111, -8 },
189  { -1, 11, 124, -6 } },
190  { { 0, 128, 0, 0 }, /* 5 */
191  { -6, 123, 12, -1 },
192  { -9, 111, 29, -3 },
193  { -9, 93, 50, -6 },
194  { -8, 72, 72, -8 },
195  { -6, 50, 93, -9 },
196  { -3, 29, 111, -9 },
197  { -1, 12, 123, -6 } },
198  { { 0, 128, 0, 0 }, /* 6 */
199  { -7, 124, 12, -1 },
200  { -10, 111, 30, -3 },
201  { -10, 93, 51, -6 },
202  { -9, 73, 73, -9 },
203  { -6, 51, 93, -10 },
204  { -3, 30, 111, -10 },
205  { -1, 12, 124, -7 } },
206  { { 0, 128, 0, 0 }, /* 7 */
207  { -7, 123, 13, -1 },
208  { -11, 112, 31, -4 },
209  { -11, 94, 52, -7 },
210  { -10, 74, 74, -10 },
211  { -7, 52, 94, -11 },
212  { -4, 31, 112, -11 },
213  { -1, 13, 123, -7 } },
214  { { 0, 128, 0, 0 }, /* 8 */
215  { -8, 124, 13, -1 },
216  { -12, 112, 32, -4 },
217  { -12, 94, 53, -7 },
218  { -10, 74, 74, -10 },
219  { -7, 53, 94, -12 },
220  { -4, 32, 112, -12 },
221  { -1, 13, 124, -8 } },
222  { { 0, 128, 0, 0 }, /* 9 */
223  { -9, 124, 14, -1 },
224  { -13, 112, 33, -4 },
225  { -13, 95, 54, -8 },
226  { -11, 75, 75, -11 },
227  { -8, 54, 95, -13 },
228  { -4, 33, 112, -13 },
229  { -1, 14, 124, -9 } },
230  { { 0, 128, 0, 0 }, /* 10 */
231  { -9, 123, 15, -1 },
232  { -14, 113, 34, -5 },
233  { -14, 95, 55, -8 },
234  { -12, 76, 76, -12 },
235  { -8, 55, 95, -14 },
236  { -5, 34, 112, -13 },
237  { -1, 15, 123, -9 } },
238  { { 0, 128, 0, 0 }, /* 11 */
239  { -10, 124, 15, -1 },
240  { -14, 113, 34, -5 },
241  { -15, 96, 56, -9 },
242  { -13, 77, 77, -13 },
243  { -9, 56, 96, -15 },
244  { -5, 34, 113, -14 },
245  { -1, 15, 124, -10 } },
246  { { 0, 128, 0, 0 }, /* 12 */
247  { -10, 123, 16, -1 },
248  { -15, 113, 35, -5 },
249  { -16, 98, 56, -10 },
250  { -14, 78, 78, -14 },
251  { -10, 56, 98, -16 },
252  { -5, 35, 113, -15 },
253  { -1, 16, 123, -10 } },
254  { { 0, 128, 0, 0 }, /* 13 */
255  { -11, 124, 17, -2 },
256  { -16, 113, 36, -5 },
257  { -17, 98, 57, -10 },
258  { -14, 78, 78, -14 },
259  { -10, 57, 98, -17 },
260  { -5, 36, 113, -16 },
261  { -2, 17, 124, -11 } },
262  { { 0, 128, 0, 0 }, /* 14 */
263  { -12, 125, 17, -2 },
264  { -17, 114, 37, -6 },
265  { -18, 99, 58, -11 },
266  { -15, 79, 79, -15 },
267  { -11, 58, 99, -18 },
268  { -6, 37, 114, -17 },
269  { -2, 17, 125, -12 } },
270  { { 0, 128, 0, 0 }, /* 15 */
271  { -12, 124, 18, -2 },
272  { -18, 114, 38, -6 },
273  { -19, 99, 59, -11 },
274  { -16, 80, 80, -16 },
275  { -11, 59, 99, -19 },
276  { -6, 38, 114, -18 },
277  { -2, 18, 124, -12 } },
278  { { 0, 128, 0, 0 }, /* 16 */
279  { -4, 118, 16, -2 },
280  { -7, 106, 34, -5 },
281  { -8, 90, 53, -7 },
282  { -8, 72, 72, -8 },
283  { -7, 53, 90, -8 },
284  { -5, 34, 106, -7 },
285  { -2, 16, 118, -4 } },
286 };
287 
288 static const VP56Tree vp6_pcr_tree[] = {
289  { 8, 0},
290  { 4, 1},
291  { 2, 2}, {-1}, {-2},
292  { 2, 3}, {-3}, {-4},
293  { 8, 4},
294  { 4, 5},
295  { 2, 6}, {-5}, {-6},
296  { 2, 7}, {-7}, {-8},
297  {-0},
298 };
299 
300 static const uint8_t vp6_coord_div[] = { 4, 4, 4, 4, 8, 8 };
301 
302 static const uint8_t vp6_huff_coeff_map[] = {
303  13, 14, 11, 0, 1, 15, 16, 18, 2, 17, 3, 4, 19, 20, 5, 6, 21, 22, 7, 8, 9, 10
304 };
305 
306 static const uint8_t vp6_huff_run_map[] = {
307  10, 13, 11, 12, 0, 1, 2, 3, 14, 8, 15, 16, 4, 5, 6, 7
308 };
309 
310 #endif /* AVCODEC_VP6DATA_H */