]> git.nihav.org Git - nihav.git/blob - nihav-duck/src/codecs/vp6data.rs
add YUV4MPEG muxer
[nihav.git] / nihav-duck / src / codecs / vp6data.rs
1 pub const VERSION_VP60: u8 = 6;
2 //pub const VERSION_VP61: u8 = 7;
3 pub const VERSION_VP62: u8 = 8;
4
5 pub const VP6_SIMPLE_PROFILE: u8 = 0;
6 pub const VP6_ADVANCED_PROFILE: u8 = 3;
7
8 pub const LONG_VECTOR_ORDER: [usize; 7] = [ 0, 1, 2, 7, 6, 5, 4 ];
9
10 pub const NZ_PROBS: [u8; 2] = [ 162, 164 ];
11 pub const RAW_PROBS: [[u8; 8]; 2] = [
12 [ 247, 210, 135, 68, 138, 220, 239, 246 ],
13 [ 244, 184, 201, 44, 173, 221, 239, 253 ]
14 ];
15 pub const TREE_PROBS: [[u8; 7]; 2] = [
16 [ 225, 146, 172, 147, 214, 39, 156 ],
17 [ 204, 170, 119, 235, 140, 230, 228 ]
18 ];
19 pub const ZERO_RUN_PROBS: [[u8; 14]; 2] = [
20 [ 198, 197, 196, 146, 198, 204, 169, 142, 130, 136, 149, 149, 191, 249 ],
21 [ 135, 201, 181, 154, 98, 117, 132, 126, 146, 169, 184, 240, 246, 254 ]
22 ];
23
24 pub const HAS_NZ_PROB: [u8; 2] = [ 237, 231 ];
25 pub const HAS_SIGN_PROB: [u8; 2] = [ 246, 243 ];
26 pub const HAS_TREE_PROB: [[u8; 7]; 2] = [
27 [ 253, 253, 254, 254, 254, 254, 254 ],
28 [ 245, 253, 254, 254, 254, 254, 254 ]
29 ];
30 pub const HAS_RAW_PROB: [[u8; 8]; 2] = [
31 [ 254, 254, 254, 254, 254, 250, 250, 252 ],
32 [ 254, 254, 254, 254, 254, 251, 251, 254 ]
33 ];
34
35 pub const HAS_COEF_PROBS: [[u8; 11]; 2] = [
36 [ 146, 255, 181, 207, 232, 243, 238, 251, 244, 250, 249 ],
37 [ 179, 255, 214, 240, 250, 255, 244, 255, 255, 255, 255 ]
38 ];
39 pub const HAS_SCAN_UPD_PROBS: [u8; 64] = [
40 0, 132, 132, 159, 153, 151, 161, 170,
41 164, 162, 136, 110, 103, 114, 129, 118,
42 124, 125, 132, 136, 114, 110, 142, 135,
43 134, 123, 143, 126, 153, 183, 166, 161,
44 171, 180, 179, 164, 203, 218, 225, 217,
45 215, 206, 203, 217, 229, 241, 248, 243,
46 253, 255, 253, 255, 255, 255, 255, 255,
47 255, 255, 255, 255, 255, 255, 255, 255
48 ];
49 pub const HAS_ZERO_RUN_PROBS: [[u8; 14]; 2] = [
50 [ 219, 246, 238, 249, 232, 239, 249, 255, 248, 253, 239, 244, 241, 248 ],
51 [ 198, 232, 251, 253, 219, 241, 253, 255, 248, 249, 244, 238, 251, 255 ]
52 ];
53
54 pub const VP6_AC_PROBS: [[[[u8; 11]; 6]; 2]; 3] = [
55 [
56 [
57 [ 227, 246, 230, 247, 244, 255, 255, 255, 255, 255, 255 ],
58 [ 255, 255, 209, 231, 231, 249, 249, 253, 255, 255, 255 ],
59 [ 255, 255, 225, 242, 241, 251, 253, 255, 255, 255, 255 ],
60 [ 255, 255, 241, 253, 252, 255, 255, 255, 255, 255, 255 ],
61 [ 255, 255, 248, 255, 255, 255, 255, 255, 255, 255, 255 ],
62 [ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 ]
63 ], [
64 [ 240, 255, 248, 255, 255, 255, 255, 255, 255, 255, 255 ],
65 [ 255, 255, 240, 253, 255, 255, 255, 255, 255, 255, 255 ],
66 [ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 ],
67 [ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 ],
68 [ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 ],
69 [ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 ]
70 ]
71 ], [
72 [
73 [ 206, 203, 227, 239, 247, 255, 253, 255, 255, 255, 255 ],
74 [ 207, 199, 220, 236, 243, 252, 252, 255, 255, 255, 255 ],
75 [ 212, 219, 230, 243, 244, 253, 252, 255, 255, 255, 255 ],
76 [ 236, 237, 247, 252, 253, 255, 255, 255, 255, 255, 255 ],
77 [ 240, 240, 248, 255, 255, 255, 255, 255, 255, 255, 255 ],
78 [ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 ]
79 ], [
80 [ 230, 233, 249, 255, 255, 255, 255, 255, 255, 255, 255 ],
81 [ 238, 238, 250, 255, 255, 255, 255, 255, 255, 255, 255 ],
82 [ 248, 251, 255, 255, 255, 255, 255, 255, 255, 255, 255 ],
83 [ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 ],
84 [ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 ],
85 [ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 ]
86 ]
87 ], [
88 [
89 [ 225, 239, 227, 231, 244, 253, 243, 255, 255, 253, 255 ],
90 [ 232, 234, 224, 228, 242, 249, 242, 252, 251, 251, 255 ],
91 [ 235, 249, 238, 240, 251, 255, 249, 255, 253, 253, 255 ],
92 [ 249, 253, 251, 250, 255, 255, 255, 255, 255, 255, 255 ],
93 [ 251, 250, 249, 255, 255, 255, 255, 255, 255, 255, 255 ],
94 [ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 ]
95 ], [
96 [ 243, 244, 250, 250, 255, 255, 255, 255, 255, 255, 255 ],
97 [ 249, 248, 250, 253, 255, 255, 255, 255, 255, 255, 255 ],
98 [ 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 ],
99 [ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 ],
100 [ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 ],
101 [ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 ]
102 ]
103 ]
104 ];
105
106 pub const VP6_DC_WEIGHTS: [[[i16; 2]; 3]; 5] = [
107 [ [ 122, 133 ], [ 133, 51 ], [ 142, -16 ] ],
108 [ [ 0, 1 ], [ 0, 1 ], [ 0, 1 ] ],
109 [ [ 78, 171 ], [ 169, 71 ], [ 221, -30 ] ],
110 [ [ 139, 117 ], [ 214, 44 ], [ 246, -3 ] ],
111 [ [ 168, 79 ], [ 210, 38 ], [ 203, 17 ] ]
112 ];
113
114 pub const VP6_IDX_TO_AC_BAND: [usize; 64] = [
115 0, 0, 1, 1, 1, 2, 2, 2,
116 2, 2, 2, 3, 3, 3, 3, 3,
117 3, 3, 3, 3, 3, 3, 4, 4,
118 4, 4, 4, 4, 4, 4, 4, 4,
119 4, 4, 4, 4, 4, 5, 5, 5,
120 5, 5, 5, 5, 5, 5, 5, 5,
121 5, 5, 5, 5, 5, 5, 5, 5,
122 5, 5, 5, 5, 5, 5, 5, 5
123 ];
124
125 pub const VP6_BICUBIC_COEFFS: [[[i16; 4]; 8]; 17] = [
126 [
127 [ 0, 128, 0, 0 ],
128 [ -3, 122, 9, 0 ],
129 [ -4, 109, 24, -1 ],
130 [ -5, 91, 45, -3 ],
131 [ -4, 68, 68, -4 ],
132 [ -3, 45, 91, -5 ],
133 [ -1, 24, 109, -4 ],
134 [ 0, 9, 122, -3 ]
135 ], [
136 [ 0, 128, 0, 0 ],
137 [ -4, 124, 9, -1 ],
138 [ -5, 110, 25, -2 ],
139 [ -6, 91, 46, -3 ],
140 [ -5, 69, 69, -5 ],
141 [ -3, 46, 91, -6 ],
142 [ -2, 25, 110, -5 ],
143 [ -1, 9, 124, -4 ]
144 ], [
145 [ 0, 128, 0, 0 ],
146 [ -4, 123, 10, -1 ],
147 [ -6, 110, 26, -2 ],
148 [ -7, 92, 47, -4 ],
149 [ -6, 70, 70, -6 ],
150 [ -4, 47, 92, -7 ],
151 [ -2, 26, 110, -6 ],
152 [ -1, 10, 123, -4 ]
153 ], [
154 [ 0, 128, 0, 0 ],
155 [ -5, 124, 10, -1 ],
156 [ -7, 110, 27, -2 ],
157 [ -7, 91, 48, -4 ],
158 [ -6, 70, 70, -6 ],
159 [ -4, 48, 92, -8 ],
160 [ -2, 27, 110, -7 ],
161 [ -1, 10, 124, -5 ]
162 ], [
163 [ 0, 128, 0, 0 ],
164 [ -6, 124, 11, -1 ],
165 [ -8, 111, 28, -3 ],
166 [ -8, 92, 49, -5 ],
167 [ -7, 71, 71, -7 ],
168 [ -5, 49, 92, -8 ],
169 [ -3, 28, 111, -8 ],
170 [ -1, 11, 124, -6 ]
171 ], [
172 [ 0, 128, 0, 0 ],
173 [ -6, 123, 12, -1 ],
174 [ -9, 111, 29, -3 ],
175 [ -9, 93, 50, -6 ],
176 [ -8, 72, 72, -8 ],
177 [ -6, 50, 93, -9 ],
178 [ -3, 29, 111, -9 ],
179 [ -1, 12, 123, -6 ]
180 ], [
181 [ 0, 128, 0, 0 ],
182 [ -7, 124, 12, -1 ],
183 [ -10, 111, 30, -3 ],
184 [ -10, 93, 51, -6 ],
185 [ -9, 73, 73, -9 ],
186 [ -6, 51, 93, -10 ],
187 [ -3, 30, 111, -10 ],
188 [ -1, 12, 124, -7 ]
189 ], [
190 [ 0, 128, 0, 0 ],
191 [ -7, 123, 13, -1 ],
192 [ -11, 112, 31, -4 ],
193 [ -11, 94, 52, -7 ],
194 [ -10, 74, 74, -10 ],
195 [ -7, 52, 94, -11 ],
196 [ -4, 31, 112, -11 ],
197 [ -1, 13, 123, -7 ]
198 ], [
199 [ 0, 128, 0, 0 ],
200 [ -8, 124, 13, -1 ],
201 [ -12, 112, 32, -4 ],
202 [ -12, 94, 53, -7 ],
203 [ -10, 74, 74, -10 ],
204 [ -7, 53, 94, -12 ],
205 [ -4, 32, 112, -12 ],
206 [ -1, 13, 124, -8 ]
207 ], [
208 [ 0, 128, 0, 0 ],
209 [ -9, 124, 14, -1 ],
210 [ -13, 112, 33, -4 ],
211 [ -13, 95, 54, -8 ],
212 [ -11, 75, 75, -11 ],
213 [ -8, 54, 95, -13 ],
214 [ -4, 33, 112, -13 ],
215 [ -1, 14, 124, -9 ]
216 ], [
217 [ 0, 128, 0, 0 ],
218 [ -9, 123, 15, -1 ],
219 [ -14, 113, 34, -5 ],
220 [ -14, 95, 55, -8 ],
221 [ -12, 76, 76, -12 ],
222 [ -8, 55, 95, -14 ],
223 [ -5, 34, 112, -13 ],
224 [ -1, 15, 123, -9 ]
225 ], [
226 [ 0, 128, 0, 0 ],
227 [ -10, 124, 15, -1 ],
228 [ -14, 113, 34, -5 ],
229 [ -15, 96, 56, -9 ],
230 [ -13, 77, 77, -13 ],
231 [ -9, 56, 96, -15 ],
232 [ -5, 34, 113, -14 ],
233 [ -1, 15, 124, -10 ]
234 ], [
235 [ 0, 128, 0, 0 ],
236 [ -10, 123, 16, -1 ],
237 [ -15, 113, 35, -5 ],
238 [ -16, 98, 56, -10 ],
239 [ -14, 78, 78, -14 ],
240 [ -10, 56, 98, -16 ],
241 [ -5, 35, 113, -15 ],
242 [ -1, 16, 123, -10 ]
243 ], [
244 [ 0, 128, 0, 0 ],
245 [ -11, 124, 17, -2 ],
246 [ -16, 113, 36, -5 ],
247 [ -17, 98, 57, -10 ],
248 [ -14, 78, 78, -14 ],
249 [ -10, 57, 98, -17 ],
250 [ -5, 36, 113, -16 ],
251 [ -2, 17, 124, -11 ]
252 ], [
253 [ 0, 128, 0, 0 ],
254 [ -12, 125, 17, -2 ],
255 [ -17, 114, 37, -6 ],
256 [ -18, 99, 58, -11 ],
257 [ -15, 79, 79, -15 ],
258 [ -11, 58, 99, -18 ],
259 [ -6, 37, 114, -17 ],
260 [ -2, 17, 125, -12 ]
261 ], [
262 [ 0, 128, 0, 0 ],
263 [ -12, 124, 18, -2 ],
264 [ -18, 114, 38, -6 ],
265 [ -19, 99, 59, -11 ],
266 [ -16, 80, 80, -16 ],
267 [ -11, 59, 99, -19 ],
268 [ -6, 38, 114, -18 ],
269 [ -2, 18, 124, -12 ]
270 ], [
271 [ 0, 128, 0, 0 ],
272 [ -4, 118, 16, -2 ],
273 [ -7, 106, 34, -5 ],
274 [ -8, 90, 53, -7 ],
275 [ -8, 72, 72, -8 ],
276 [ -7, 53, 90, -8 ],
277 [ -5, 34, 106, -7 ],
278 [ -2, 16, 118, -4 ]
279 ]
280 ];
281
282 pub const VP6_DEFAULT_SCAN_ORDER: [usize; 64] = [
283 0, 0, 1, 1, 1, 2, 2, 2,
284 2, 2, 2, 3, 3, 4, 4, 4,
285 5, 5, 5, 5, 6, 6, 7, 7,
286 7, 7, 7, 8, 8, 9, 9, 9,
287 9, 9, 9, 10, 10, 11, 11, 11,
288 11, 11, 11, 12, 12, 12, 12, 12,
289 12, 13, 13, 13, 13, 13, 14, 14,
290 14, 14, 15, 15, 15, 15, 15, 15
291 ];
292 pub const VP6_INTERLACED_SCAN_ORDER: [usize; 64] = [
293 0, 1, 0, 1, 1, 2, 5, 3,
294 2, 2, 2, 2, 4, 7, 8, 10,
295 9, 7, 5, 4, 2, 3, 5, 6,
296 8, 9, 11, 12, 13, 12, 11, 10,
297 9, 7, 5, 4, 6, 7, 9, 11,
298 12, 12, 13, 13, 14, 12, 11, 9,
299 7, 9, 11, 12, 14, 14, 14, 15,
300 13, 11, 13, 15, 15, 15, 15, 15
301 ];
302
303 pub const VP6_COEF_ADD_BITS: [u8; 6] = [ 1, 2, 3, 4, 5, 11 ];