comparison vp56data.h @ 3695:6795c9e5f983 libavcodec

VP5 and VP6 video decoder
author aurel
date Sat, 09 Sep 2006 17:19:37 +0000
parents
children c8c591fe26f8
comparison
equal deleted inserted replaced
3694:8765ee4eaa45 3695:6795c9e5f983
1 /**
2 * @file vp56data.h
3 * VP5 and VP6 compatible video decoder (common data)
4 *
5 * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
6 *
7 * This library 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 * This library 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 this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #ifndef VP56DATA_H
23 #define VP56DATA_H
24
25 #include <inttypes.h>
26
27 typedef enum {
28 VP56_FRAME_CURRENT = 0,
29 VP56_FRAME_PREVIOUS = 1,
30 VP56_FRAME_GOLDEN = 2,
31 } vp56_frame_t;
32
33 typedef enum {
34 VP56_MB_INTER_NOVEC_PF = 0, /**< Inter MB, no vector, from previous frame */
35 VP56_MB_INTRA = 1, /**< Intra MB */
36 VP56_MB_INTER_DELTA_PF = 2, /**< Inter MB, above/left vector + delta, from previous frame */
37 VP56_MB_INTER_V1_PF = 3, /**< Inter MB, first vector, from previous frame */
38 VP56_MB_INTER_V2_PF = 4, /**< Inter MB, second vector, from previous frame */
39 VP56_MB_INTER_NOVEC_GF = 5, /**< Inter MB, no vector, from golden frame */
40 VP56_MB_INTER_DELTA_GF = 6, /**< Inter MB, above/left vector + delta, from golden frame */
41 VP56_MB_INTER_4V = 7, /**< Inter MB, 4 vectors, from previous frame */
42 VP56_MB_INTER_V1_GF = 8, /**< Inter MB, first vector, from golden frame */
43 VP56_MB_INTER_V2_GF = 9, /**< Inter MB, second vector, from golden frame */
44 } vp56_mb_t;
45
46 typedef struct {
47 int8_t val;
48 int8_t prob_idx;
49 } vp56_tree_t;
50
51 extern const uint8_t vp56_b6to3[];
52 extern const uint8_t vp56_b6to4[];
53 extern const uint8_t vp56_coeff_parse_table[6][11];
54 extern const uint8_t vp56_def_mb_types_stats[3][10][2];
55 extern const vp56_tree_t vp56_pva_tree[];
56 extern const vp56_tree_t vp56_pc_tree[];
57 extern const uint8_t vp56_coeff_bias[];
58 extern const uint8_t vp56_coeff_bit_length[];
59
60 static const vp56_frame_t vp56_reference_frame[] = {
61 VP56_FRAME_PREVIOUS, /* VP56_MB_INTER_NOVEC_PF */
62 VP56_FRAME_CURRENT, /* VP56_MB_INTRA */
63 VP56_FRAME_PREVIOUS, /* VP56_MB_INTER_DELTA_PF */
64 VP56_FRAME_PREVIOUS, /* VP56_MB_INTER_V1_PF */
65 VP56_FRAME_PREVIOUS, /* VP56_MB_INTER_V2_PF */
66 VP56_FRAME_GOLDEN, /* VP56_MB_INTER_NOVEC_GF */
67 VP56_FRAME_GOLDEN, /* VP56_MB_INTER_DELTA_GF */
68 VP56_FRAME_PREVIOUS, /* VP56_MB_INTER_4V */
69 VP56_FRAME_GOLDEN, /* VP56_MB_INTER_V1_GF */
70 VP56_FRAME_GOLDEN, /* VP56_MB_INTER_V2_GF */
71 };
72
73 static const uint8_t vp56_ac_dequant[64] = {
74 94, 92, 90, 88, 86, 82, 78, 74,
75 70, 66, 62, 58, 54, 53, 52, 51,
76 50, 49, 48, 47, 46, 45, 44, 43,
77 42, 40, 39, 37, 36, 35, 34, 33,
78 32, 31, 30, 29, 28, 27, 26, 25,
79 24, 23, 22, 21, 20, 19, 18, 17,
80 16, 15, 14, 13, 12, 11, 10, 9,
81 8, 7, 6, 5, 4, 3, 2, 1,
82 };
83
84 static const uint8_t vp56_dc_dequant[64] = {
85 47, 47, 47, 47, 45, 43, 43, 43,
86 43, 43, 42, 41, 41, 40, 40, 40,
87 40, 35, 35, 35, 35, 33, 33, 33,
88 33, 32, 32, 32, 27, 27, 26, 26,
89 25, 25, 24, 24, 23, 23, 19, 19,
90 19, 19, 18, 18, 17, 16, 16, 16,
91 16, 16, 15, 11, 11, 11, 10, 10,
92 9, 8, 7, 5, 3, 3, 2, 2,
93 };
94
95 static const uint8_t vp56_pre_def_mb_type_stats[16][3][10][2] = {
96 { { { 9, 15 }, { 32, 25 }, { 7, 19 }, { 9, 21 }, { 1, 12 },
97 { 14, 12 }, { 3, 18 }, { 14, 23 }, { 3, 10 }, { 0, 4 }, },
98 { { 41, 22 }, { 1, 0 }, { 1, 31 }, { 0, 0 }, { 0, 0 },
99 { 0, 1 }, { 1, 7 }, { 0, 1 }, { 98, 25 }, { 4, 10 }, },
100 { { 2, 3 }, { 2, 3 }, { 0, 2 }, { 0, 2 }, { 0, 0 },
101 { 11, 4 }, { 1, 4 }, { 0, 2 }, { 3, 2 }, { 0, 4 }, }, },
102 { { { 48, 39 }, { 1, 2 }, { 11, 27 }, { 29, 44 }, { 7, 27 },
103 { 1, 4 }, { 0, 3 }, { 1, 6 }, { 1, 2 }, { 0, 0 }, },
104 { { 123, 37 }, { 6, 4 }, { 1, 27 }, { 0, 0 }, { 0, 0 },
105 { 5, 8 }, { 1, 7 }, { 0, 1 }, { 12, 10 }, { 0, 2 }, },
106 { { 49, 46 }, { 3, 4 }, { 7, 31 }, { 42, 41 }, { 0, 0 },
107 { 2, 6 }, { 1, 7 }, { 1, 4 }, { 2, 4 }, { 0, 1 }, }, },
108 { { { 21, 32 }, { 1, 2 }, { 4, 10 }, { 32, 43 }, { 6, 23 },
109 { 2, 3 }, { 1, 19 }, { 1, 6 }, { 12, 21 }, { 0, 7 }, },
110 { { 26, 14 }, { 14, 12 }, { 0, 24 }, { 0, 0 }, { 0, 0 },
111 { 55, 17 }, { 1, 9 }, { 0, 36 }, { 5, 7 }, { 1, 3 }, },
112 { { 26, 25 }, { 1, 1 }, { 2, 10 }, { 67, 39 }, { 0, 0 },
113 { 1, 1 }, { 0, 14 }, { 0, 2 }, { 31, 26 }, { 1, 6 }, }, },
114 { { { 69, 83 }, { 0, 0 }, { 0, 2 }, { 10, 29 }, { 3, 12 },
115 { 0, 1 }, { 0, 3 }, { 0, 3 }, { 2, 2 }, { 0, 0 }, },
116 { { 209, 5 }, { 0, 0 }, { 0, 27 }, { 0, 0 }, { 0, 0 },
117 { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 0 }, { 0, 0 }, },
118 { { 103, 46 }, { 1, 2 }, { 2, 10 }, { 33, 42 }, { 0, 0 },
119 { 1, 4 }, { 0, 3 }, { 0, 1 }, { 1, 3 }, { 0, 0 }, }, },
120 { { { 11, 20 }, { 1, 4 }, { 18, 36 }, { 43, 48 }, { 13, 35 },
121 { 0, 2 }, { 0, 5 }, { 3, 12 }, { 1, 2 }, { 0, 0 }, },
122 { { 2, 5 }, { 4, 5 }, { 0, 121 }, { 0, 0 }, { 0, 0 },
123 { 0, 3 }, { 2, 4 }, { 1, 4 }, { 2, 2 }, { 0, 1 }, },
124 { { 14, 31 }, { 9, 13 }, { 14, 54 }, { 22, 29 }, { 0, 0 },
125 { 2, 6 }, { 4, 18 }, { 6, 13 }, { 1, 5 }, { 0, 1 }, }, },
126 { { { 70, 44 }, { 0, 1 }, { 2, 10 }, { 37, 46 }, { 8, 26 },
127 { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 1 }, { 0, 0 }, },
128 { { 175, 5 }, { 0, 1 }, { 0, 48 }, { 0, 0 }, { 0, 0 },
129 { 0, 2 }, { 0, 1 }, { 0, 2 }, { 0, 1 }, { 0, 0 }, },
130 { { 85, 39 }, { 0, 0 }, { 1, 9 }, { 69, 40 }, { 0, 0 },
131 { 0, 1 }, { 0, 3 }, { 0, 1 }, { 2, 3 }, { 0, 0 }, }, },
132 { { { 8, 15 }, { 0, 1 }, { 8, 21 }, { 74, 53 }, { 22, 42 },
133 { 0, 1 }, { 0, 2 }, { 0, 3 }, { 1, 2 }, { 0, 0 }, },
134 { { 83, 5 }, { 2, 3 }, { 0, 102 }, { 0, 0 }, { 0, 0 },
135 { 1, 3 }, { 0, 2 }, { 0, 1 }, { 0, 0 }, { 0, 0 }, },
136 { { 31, 28 }, { 0, 0 }, { 3, 14 }, { 130, 34 }, { 0, 0 },
137 { 0, 1 }, { 0, 3 }, { 0, 1 }, { 3, 3 }, { 0, 1 }, }, },
138 { { { 141, 42 }, { 0, 0 }, { 1, 4 }, { 11, 24 }, { 1, 11 },
139 { 0, 1 }, { 0, 1 }, { 0, 2 }, { 0, 0 }, { 0, 0 }, },
140 { { 233, 6 }, { 0, 0 }, { 0, 8 }, { 0, 0 }, { 0, 0 },
141 { 0, 1 }, { 0, 1 }, { 0, 0 }, { 0, 1 }, { 0, 0 }, },
142 { { 171, 25 }, { 0, 0 }, { 1, 5 }, { 25, 21 }, { 0, 0 },
143 { 0, 1 }, { 0, 1 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, }, },
144 { { { 8, 19 }, { 4, 10 }, { 24, 45 }, { 21, 37 }, { 9, 29 },
145 { 0, 3 }, { 1, 7 }, { 11, 25 }, { 0, 2 }, { 0, 1 }, },
146 { { 34, 16 }, { 112, 21 }, { 1, 28 }, { 0, 0 }, { 0, 0 },
147 { 6, 8 }, { 1, 7 }, { 0, 3 }, { 2, 5 }, { 0, 2 }, },
148 { { 17, 21 }, { 68, 29 }, { 6, 15 }, { 13, 22 }, { 0, 0 },
149 { 6, 12 }, { 3, 14 }, { 4, 10 }, { 1, 7 }, { 0, 3 }, }, },
150 { { { 46, 42 }, { 0, 1 }, { 2, 10 }, { 54, 51 }, { 10, 30 },
151 { 0, 2 }, { 0, 2 }, { 0, 1 }, { 0, 1 }, { 0, 0 }, },
152 { { 159, 35 }, { 2, 2 }, { 0, 25 }, { 0, 0 }, { 0, 0 },
153 { 3, 6 }, { 0, 5 }, { 0, 1 }, { 4, 4 }, { 0, 1 }, },
154 { { 51, 39 }, { 0, 1 }, { 2, 12 }, { 91, 44 }, { 0, 0 },
155 { 0, 2 }, { 0, 3 }, { 0, 1 }, { 2, 3 }, { 0, 1 }, }, },
156 { { { 28, 32 }, { 0, 0 }, { 3, 10 }, { 75, 51 }, { 14, 33 },
157 { 0, 1 }, { 0, 2 }, { 0, 1 }, { 1, 2 }, { 0, 0 }, },
158 { { 75, 39 }, { 5, 7 }, { 2, 48 }, { 0, 0 }, { 0, 0 },
159 { 3, 11 }, { 2, 16 }, { 1, 4 }, { 7, 10 }, { 0, 2 }, },
160 { { 81, 25 }, { 0, 0 }, { 2, 9 }, { 106, 26 }, { 0, 0 },
161 { 0, 1 }, { 0, 1 }, { 0, 1 }, { 1, 1 }, { 0, 0 }, }, },
162 { { { 100, 46 }, { 0, 1 }, { 3, 9 }, { 21, 37 }, { 5, 20 },
163 { 0, 1 }, { 0, 2 }, { 1, 2 }, { 0, 1 }, { 0, 0 }, },
164 { { 212, 21 }, { 0, 1 }, { 0, 9 }, { 0, 0 }, { 0, 0 },
165 { 1, 2 }, { 0, 2 }, { 0, 0 }, { 2, 2 }, { 0, 0 }, },
166 { { 140, 37 }, { 0, 1 }, { 1, 8 }, { 24, 33 }, { 0, 0 },
167 { 1, 2 }, { 0, 2 }, { 0, 1 }, { 1, 2 }, { 0, 0 }, }, },
168 { { { 27, 29 }, { 0, 1 }, { 9, 25 }, { 53, 51 }, { 12, 34 },
169 { 0, 1 }, { 0, 3 }, { 1, 5 }, { 0, 2 }, { 0, 0 }, },
170 { { 4, 2 }, { 0, 0 }, { 0, 172 }, { 0, 0 }, { 0, 0 },
171 { 0, 1 }, { 0, 2 }, { 0, 0 }, { 2, 0 }, { 0, 0 }, },
172 { { 14, 23 }, { 1, 3 }, { 11, 53 }, { 90, 31 }, { 0, 0 },
173 { 0, 3 }, { 1, 5 }, { 2, 6 }, { 1, 2 }, { 0, 0 }, }, },
174 { { { 80, 38 }, { 0, 0 }, { 1, 4 }, { 69, 33 }, { 5, 16 },
175 { 0, 1 }, { 0, 1 }, { 0, 0 }, { 0, 1 }, { 0, 0 }, },
176 { { 187, 22 }, { 1, 1 }, { 0, 17 }, { 0, 0 }, { 0, 0 },
177 { 3, 6 }, { 0, 4 }, { 0, 1 }, { 4, 4 }, { 0, 1 }, },
178 { { 123, 29 }, { 0, 0 }, { 1, 7 }, { 57, 30 }, { 0, 0 },
179 { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 0 }, }, },
180 { { { 16, 20 }, { 0, 0 }, { 2, 8 }, { 104, 49 }, { 15, 33 },
181 { 0, 1 }, { 0, 1 }, { 0, 1 }, { 1, 1 }, { 0, 0 }, },
182 { { 133, 6 }, { 1, 2 }, { 1, 70 }, { 0, 0 }, { 0, 0 },
183 { 0, 2 }, { 0, 4 }, { 0, 3 }, { 1, 1 }, { 0, 0 }, },
184 { { 13, 14 }, { 0, 0 }, { 4, 20 }, { 175, 20 }, { 0, 0 },
185 { 0, 1 }, { 0, 1 }, { 0, 1 }, { 1, 1 }, { 0, 0 }, }, },
186 { { { 194, 16 }, { 0, 0 }, { 1, 1 }, { 1, 9 }, { 1, 3 },
187 { 0, 0 }, { 0, 1 }, { 0, 1 }, { 0, 0 }, { 0, 0 }, },
188 { { 251, 1 }, { 0, 0 }, { 0, 2 }, { 0, 0 }, { 0, 0 },
189 { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, },
190 { { 202, 23 }, { 0, 0 }, { 1, 3 }, { 2, 9 }, { 0, 0 },
191 { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 0 }, { 0, 0 }, }, },
192 };
193
194 static const uint8_t vp56_filter_threshold[] = {
195 14, 14, 13, 13, 12, 12, 10, 10,
196 10, 10, 8, 8, 8, 8, 8, 8,
197 8, 8, 8, 8, 8, 8, 8, 8,
198 8, 8, 8, 8, 8, 8, 8, 8,
199 8, 8, 8, 8, 7, 7, 7, 7,
200 7, 7, 6, 6, 6, 6, 6, 6,
201 5, 5, 5, 5, 4, 4, 4, 4,
202 4, 4, 4, 3, 3, 3, 3, 2,
203 };
204
205 static const uint8_t vp56_mb_type_model_model[] = {
206 171, 83, 199, 140, 125, 104,
207 };
208
209 static const vp56_tree_t vp56_pmbtm_tree[] = {
210 { 4, 0},
211 { 2, 1}, {-8}, {-4},
212 { 8, 2},
213 { 6, 3},
214 { 4, 4},
215 { 2, 5}, {-24}, {-20}, {-16}, {-12}, {-0},
216 };
217
218 static const vp56_tree_t vp56_pmbt_tree[] = {
219 { 8, 1},
220 { 4, 2},
221 { 2, 4}, {-VP56_MB_INTER_NOVEC_PF}, {-VP56_MB_INTER_DELTA_PF},
222 { 2, 5}, {-VP56_MB_INTER_V1_PF}, {-VP56_MB_INTER_V2_PF},
223 { 4, 3},
224 { 2, 6}, {-VP56_MB_INTRA}, {-VP56_MB_INTER_4V},
225 { 4, 7},
226 { 2, 8}, {-VP56_MB_INTER_NOVEC_GF}, {-VP56_MB_INTER_DELTA_GF},
227 { 2, 9}, {-VP56_MB_INTER_V1_GF}, {-VP56_MB_INTER_V2_GF},
228 };
229
230 /* relative pos of surrounding blocks, from closest to farthest */
231 static const int8_t vp56_candidate_predictor_pos[12][2] = {
232 { 0, -1 },
233 { -1, 0 },
234 { -1, -1 },
235 { 1, -1 },
236 { 0, -2 },
237 { -2, 0 },
238 { -2, -1 },
239 { -1, -2 },
240 { 1, -2 },
241 { 2, -1 },
242 { -2, -2 },
243 { 2, -2 },
244 };
245
246 #endif /* VP56DATA */