Commit | Line | Data |
---|---|---|
5b24175d KS |
1 | use std::mem; |
2 | use std::ptr; | |
3 | use nihav_core::codecs::*; | |
4 | use nihav_core::codecs::blockdsp::*; | |
5 | use nihav_core::io::bitreader::*; | |
6 | use nihav_core::io::codebook::*; | |
7 | use nihav_core::io::intcode::*; | |
8 | use super::vpcommon::*; | |
9 | ||
10 | #[derive(Clone,Copy,Debug,PartialEq)] | |
11 | enum SBState { | |
12 | Coded, | |
13 | Partial, | |
14 | Uncoded, | |
15 | } | |
16 | ||
6543b6f8 KS |
17 | fn map_idx(idx: usize) -> u8 { |
18 | idx as u8 | |
19 | } | |
20 | ||
3567fcdb KS |
21 | struct VP30Codes { |
22 | dc_cb: [Codebook<u8>; 5], | |
23 | ac_i_cb: [Codebook<u8>; 5], | |
24 | ac_p_cb: [Codebook<u8>; 5], | |
25 | mbtype_cb: Codebook<VPMBType>, | |
26 | } | |
27 | ||
28 | fn map_mbt(idx: usize) -> VPMBType { | |
29 | VP30_MBTYPE_SYMS[idx] | |
30 | } | |
31 | ||
32 | impl VP30Codes { | |
33 | fn new() -> Self { | |
34 | let mut dc_cb: [Codebook<u8>; 5]; | |
35 | let mut ac_i_cb: [Codebook<u8>; 5]; | |
36 | let mut ac_p_cb: [Codebook<u8>; 5]; | |
37 | let mut cr = TableCodebookDescReader::new(&VP30_MBTYPE_CODES, &VP30_MBTYPE_BITS, map_mbt); | |
38 | let mbtype_cb = Codebook::new(&mut cr, CodebookMode::MSB).unwrap(); | |
39 | unsafe { | |
40 | dc_cb = mem::uninitialized(); | |
41 | ac_i_cb = mem::uninitialized(); | |
42 | ac_p_cb = mem::uninitialized(); | |
43 | for i in 0..5 { | |
44 | let mut cr = TableCodebookDescReader::new(&VP30_DC_CODES[i], &VP30_DC_BITS[i], map_idx); | |
45 | let cb = Codebook::new(&mut cr, CodebookMode::MSB).unwrap(); | |
46 | ptr::write(&mut dc_cb[i], cb); | |
47 | let mut cr = TableCodebookDescReader::new(&VP30_AC_INTRA_CODES[i], &VP30_AC_INTRA_BITS[i], map_idx); | |
48 | let cb = Codebook::new(&mut cr, CodebookMode::MSB).unwrap(); | |
49 | ptr::write(&mut ac_i_cb[i], cb); | |
50 | let mut cr = TableCodebookDescReader::new(&VP30_AC_INTER_CODES[i], &VP30_AC_INTER_BITS[i], map_idx); | |
51 | let cb = Codebook::new(&mut cr, CodebookMode::MSB).unwrap(); | |
52 | ptr::write(&mut ac_p_cb[i], cb); | |
53 | } | |
54 | } | |
55 | Self { dc_cb, ac_i_cb, ac_p_cb, mbtype_cb } | |
56 | } | |
57 | } | |
58 | ||
6543b6f8 | 59 | struct VP31Codes { |
5b24175d KS |
60 | dc_cb: [Codebook<u8>; 16], |
61 | ac0_cb: [Codebook<u8>; 16], | |
62 | ac1_cb: [Codebook<u8>; 16], | |
63 | ac2_cb: [Codebook<u8>; 16], | |
64 | ac3_cb: [Codebook<u8>; 16], | |
65 | } | |
66 | ||
6543b6f8 | 67 | impl VP31Codes { |
5b24175d KS |
68 | fn new() -> Self { |
69 | let mut dc_cb: [Codebook<u8>; 16]; | |
70 | let mut ac0_cb: [Codebook<u8>; 16]; | |
71 | let mut ac1_cb: [Codebook<u8>; 16]; | |
72 | let mut ac2_cb: [Codebook<u8>; 16]; | |
73 | let mut ac3_cb: [Codebook<u8>; 16]; | |
74 | unsafe { | |
75 | dc_cb = mem::uninitialized(); | |
76 | ac0_cb = mem::uninitialized(); | |
77 | ac1_cb = mem::uninitialized(); | |
78 | ac2_cb = mem::uninitialized(); | |
79 | ac3_cb = mem::uninitialized(); | |
80 | for i in 0..16 { | |
6543b6f8 | 81 | let mut cr = TableCodebookDescReader::new(&VP31_DC_CODES[i], &VP31_DC_BITS[i], map_idx); |
5b24175d KS |
82 | let cb = Codebook::new(&mut cr, CodebookMode::MSB).unwrap(); |
83 | ptr::write(&mut dc_cb[i], cb); | |
84 | ||
6543b6f8 | 85 | let mut cr = TableCodebookDescReader::new(&VP31_AC_CAT0_CODES[i], &VP31_AC_CAT0_BITS[i], map_idx); |
5b24175d KS |
86 | let cb = Codebook::new(&mut cr, CodebookMode::MSB).unwrap(); |
87 | ptr::write(&mut ac0_cb[i], cb); | |
6543b6f8 | 88 | let mut cr = TableCodebookDescReader::new(&VP31_AC_CAT1_CODES[i], &VP31_AC_CAT1_BITS[i], map_idx); |
5b24175d KS |
89 | let cb = Codebook::new(&mut cr, CodebookMode::MSB).unwrap(); |
90 | ptr::write(&mut ac1_cb[i], cb); | |
6543b6f8 | 91 | let mut cr = TableCodebookDescReader::new(&VP31_AC_CAT2_CODES[i], &VP31_AC_CAT2_BITS[i], map_idx); |
5b24175d KS |
92 | let cb = Codebook::new(&mut cr, CodebookMode::MSB).unwrap(); |
93 | ptr::write(&mut ac2_cb[i], cb); | |
6543b6f8 | 94 | let mut cr = TableCodebookDescReader::new(&VP31_AC_CAT3_CODES[i], &VP31_AC_CAT3_BITS[i], map_idx); |
5b24175d KS |
95 | let cb = Codebook::new(&mut cr, CodebookMode::MSB).unwrap(); |
96 | ptr::write(&mut ac3_cb[i], cb); | |
97 | } | |
98 | } | |
99 | Self { dc_cb, ac0_cb, ac1_cb, ac2_cb, ac3_cb } | |
100 | } | |
8e4b2f44 KS |
101 | fn new_vp4() -> VP31Codes { |
102 | let mut dc_cb: [Codebook<u8>; 16]; | |
103 | let mut ac0_cb: [Codebook<u8>; 16]; | |
104 | let mut ac1_cb: [Codebook<u8>; 16]; | |
105 | let mut ac2_cb: [Codebook<u8>; 16]; | |
106 | let mut ac3_cb: [Codebook<u8>; 16]; | |
107 | unsafe { | |
108 | dc_cb = mem::uninitialized(); | |
109 | ac0_cb = mem::uninitialized(); | |
110 | ac1_cb = mem::uninitialized(); | |
111 | ac2_cb = mem::uninitialized(); | |
112 | ac3_cb = mem::uninitialized(); | |
113 | for i in 0..16 { | |
114 | let mut cr = TableCodebookDescReader::new(&VP40_DC_CODES[i], &VP40_DC_BITS[i], map_idx); | |
115 | let cb = Codebook::new(&mut cr, CodebookMode::MSB).unwrap(); | |
116 | ptr::write(&mut dc_cb[i], cb); | |
117 | ||
118 | let mut cr = TableCodebookDescReader::new(&VP40_AC_CAT0_CODES[i], &VP40_AC_CAT0_BITS[i], map_idx); | |
119 | let cb = Codebook::new(&mut cr, CodebookMode::MSB).unwrap(); | |
120 | ptr::write(&mut ac0_cb[i], cb); | |
121 | let mut cr = TableCodebookDescReader::new(&VP40_AC_CAT1_CODES[i], &VP40_AC_CAT1_BITS[i], map_idx); | |
122 | let cb = Codebook::new(&mut cr, CodebookMode::MSB).unwrap(); | |
123 | ptr::write(&mut ac1_cb[i], cb); | |
124 | let mut cr = TableCodebookDescReader::new(&VP40_AC_CAT2_CODES[i], &VP40_AC_CAT2_BITS[i], map_idx); | |
125 | let cb = Codebook::new(&mut cr, CodebookMode::MSB).unwrap(); | |
126 | ptr::write(&mut ac2_cb[i], cb); | |
127 | let mut cr = TableCodebookDescReader::new(&VP40_AC_CAT3_CODES[i], &VP40_AC_CAT3_BITS[i], map_idx); | |
128 | let cb = Codebook::new(&mut cr, CodebookMode::MSB).unwrap(); | |
129 | ptr::write(&mut ac3_cb[i], cb); | |
130 | } | |
131 | } | |
132 | VP31Codes { dc_cb, ac0_cb, ac1_cb, ac2_cb, ac3_cb } | |
133 | } | |
134 | } | |
135 | ||
136 | struct VP40AuxCodes { | |
137 | mv_x_cb: [Codebook<i8>; 7], | |
138 | mv_y_cb: [Codebook<i8>; 7], | |
139 | mbpat_cb: [Codebook<u8>; 2], | |
140 | } | |
141 | ||
142 | fn map_mv(idx: usize) -> i8 { | |
143 | (idx as i8) - 31 | |
144 | } | |
145 | ||
146 | impl VP40AuxCodes { | |
147 | fn new() -> Self { | |
148 | let mut mv_x_cb: [Codebook<i8>; 7]; | |
149 | let mut mv_y_cb: [Codebook<i8>; 7]; | |
150 | unsafe { | |
151 | mv_x_cb = mem::uninitialized(); | |
152 | mv_y_cb = mem::uninitialized(); | |
153 | for i in 0..7 { | |
154 | let mut cr = TableCodebookDescReader::new(&VP40_MV_X_CODES[i], &VP40_MV_X_BITS[i], map_mv); | |
155 | let cb = Codebook::new(&mut cr, CodebookMode::MSB).unwrap(); | |
156 | ptr::write(&mut mv_x_cb[i], cb); | |
157 | let mut cr = TableCodebookDescReader::new(&VP40_MV_Y_CODES[i], &VP40_MV_Y_BITS[i], map_mv); | |
158 | let cb = Codebook::new(&mut cr, CodebookMode::MSB).unwrap(); | |
159 | ptr::write(&mut mv_y_cb[i], cb); | |
160 | } | |
161 | } | |
162 | let mut cr0 = TableCodebookDescReader::new(&VP40_MBPAT_CODES[0], &VP40_MBPAT_BITS[0], map_idx); | |
163 | let mut cr1 = TableCodebookDescReader::new(&VP40_MBPAT_CODES[1], &VP40_MBPAT_BITS[1], map_idx); | |
164 | let mbpat_cb = [Codebook::new(&mut cr0, CodebookMode::MSB).unwrap(), | |
165 | Codebook::new(&mut cr1, CodebookMode::MSB).unwrap()]; | |
166 | Self { mv_x_cb, mv_y_cb, mbpat_cb } | |
167 | } | |
5b24175d KS |
168 | } |
169 | ||
347108c9 KS |
170 | enum Codes { |
171 | None, | |
3567fcdb | 172 | VP30(VP30Codes), |
347108c9 KS |
173 | VP31(VP31Codes), |
174 | } | |
175 | ||
5b24175d KS |
176 | #[derive(Clone)] |
177 | struct Block { | |
178 | btype: VPMBType, | |
179 | coeffs: [i16; 64], | |
180 | has_ac: bool, | |
181 | idx: usize, | |
182 | mv: MV, | |
183 | coded: bool, | |
184 | } | |
185 | ||
186 | impl Block { | |
187 | fn new() -> Self { | |
188 | Self { | |
189 | btype: VPMBType::Intra, | |
190 | coeffs: [0; 64], | |
191 | has_ac: false, | |
192 | idx: 0, | |
193 | mv: ZERO_MV, | |
194 | coded: false, | |
195 | } | |
196 | } | |
197 | } | |
198 | ||
199 | type ReadRunFunc = fn (&mut BitReader) -> DecoderResult<usize>; | |
200 | ||
6543b6f8 KS |
201 | const VP31_LONG_RUN_BASE: [usize; 7] = [ 1, 2, 4, 6, 10, 18, 34 ]; |
202 | const VP31_LONG_RUN_BITS: [u8; 7] = [ 0, 1, 1, 2, 3, 4, 12 ]; | |
5b24175d KS |
203 | fn read_long_run(br: &mut BitReader) -> DecoderResult<usize> { |
204 | let pfx = br.read_code(UintCodeType::LimitedUnary(6, 0))? as usize; | |
205 | if pfx == 0 { return Ok(1); } | |
6543b6f8 | 206 | Ok(VP31_LONG_RUN_BASE[pfx] + (br.read(VP31_LONG_RUN_BITS[pfx])? as usize)) |
5b24175d KS |
207 | } |
208 | ||
6543b6f8 KS |
209 | const VP31_SHORT_RUN_BASE: [usize; 6] = [ 1, 3, 5, 7, 11, 15 ]; |
210 | const VP31_SHORT_RUN_BITS: [u8; 6] = [ 1, 1, 1, 2, 2, 4 ]; | |
5b24175d KS |
211 | fn read_short_run(br: &mut BitReader) -> DecoderResult<usize> { |
212 | let pfx = br.read_code(UintCodeType::LimitedUnary(5, 0))? as usize; | |
6543b6f8 | 213 | Ok(VP31_SHORT_RUN_BASE[pfx] + (br.read(VP31_SHORT_RUN_BITS[pfx])? as usize)) |
5b24175d KS |
214 | } |
215 | ||
8e4b2f44 KS |
216 | fn read_mb_run(br: &mut BitReader) -> DecoderResult<usize> { |
217 | let pfx = br.read_code(UintCodeType::LimitedUnary(10, 0))? as usize; | |
218 | if pfx == 10 { unimplemented!(); } | |
219 | if pfx < 2 { | |
220 | Ok(pfx + 1) | |
221 | } else { | |
222 | let base = (1 << (pfx - 1)) + 1; | |
223 | let bits = (pfx - 1) as u8; | |
224 | let add_bits = br.read(bits)? as usize; | |
225 | Ok(base + add_bits) | |
226 | } | |
227 | } | |
228 | ||
5b24175d KS |
229 | struct BitRunDecoder { |
230 | value: bool, | |
231 | run: usize, | |
232 | read_run: ReadRunFunc, | |
233 | } | |
234 | ||
235 | impl BitRunDecoder { | |
236 | fn new(br: &mut BitReader, read_run: ReadRunFunc) -> DecoderResult<Self> { | |
237 | let value = !br.read_bool()?; // it will be flipped before run decoding | |
238 | Ok(Self { value, run: 0, read_run }) | |
239 | } | |
240 | fn get_val(&mut self, br: &mut BitReader) -> DecoderResult<bool> { | |
241 | if self.run == 0 { | |
242 | self.value = !self.value; | |
243 | self.run = (self.read_run)(br)?; | |
244 | } | |
245 | self.run -= 1; | |
246 | Ok(self.value) | |
247 | } | |
248 | } | |
249 | ||
3567fcdb KS |
250 | const VP30_NE0_BITS: [u8; 5] = [ 2, 2, 3, 4, 8 ]; |
251 | const VP30_NE0_BASE: [usize; 5] = [ 1, 5, 9, 17, 33 ]; | |
252 | fn vp30_read_ne_run0(br: &mut BitReader) -> DecoderResult<usize> { | |
253 | let len = br.read_code(UintCodeType::LimitedUnary(4, 0))? as usize; | |
254 | Ok(VP30_NE0_BASE[len] + (br.read(VP30_NE0_BITS[len])? as usize)) | |
255 | } | |
256 | fn vp30_read_ne_run1(br: &mut BitReader) -> DecoderResult<usize> { | |
257 | let len = br.read_code(UintCodeType::LimitedUnary(6, 0))? as usize; | |
258 | if len == 0 { | |
259 | Ok((br.read(1)? as usize) + 1) | |
260 | } else if len < 6 { | |
261 | Ok(len + 2) | |
262 | } else { | |
263 | Ok((br.read(8)? as usize) + 8) | |
264 | } | |
265 | } | |
266 | fn vp30_read_coded_run0(br: &mut BitReader) -> DecoderResult<usize> { | |
267 | let len = br.read_code(UintCodeType::LimitedUnary(5, 0))? as usize; | |
268 | Ok(len + 1) | |
269 | } | |
270 | /* | |
271 | 0 - 1 | |
272 | 11 - 2 | |
273 | 1000 - 3 | |
274 | 1010 - 4 | |
275 | 10011 - 5 | |
276 | 10111 - 6 | |
277 | 10010 - 7 + get_bits(3) | |
278 | 101100 - 15 + get_bits(5) | |
279 | 1011010 - 47 + get_bits(8) | |
280 | 1011011 - 303 + get_bits(16) | |
281 | */ | |
282 | const VP30_CRUN1_LUT: [u8; 32] = [ | |
283 | 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, | |
284 | 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, | |
285 | 0x34, 0x34, 0x75, 0x55, 0x44, 0x44, 0x85, 0x65, | |
286 | 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22 | |
287 | ]; | |
288 | fn vp30_read_coded_run1(br: &mut BitReader) -> DecoderResult<usize> { | |
289 | let idx = br.peek(5) as usize; | |
290 | let sym = (VP30_CRUN1_LUT[idx] >> 4) as usize; | |
291 | let bits = VP30_CRUN1_LUT[idx] & 0xF; | |
292 | br.skip(bits as u32)?; | |
293 | if sym < 7 { | |
294 | Ok(sym) | |
295 | } else if sym == 7 { | |
296 | Ok(7 + (br.read(3)? as usize)) | |
297 | } else { | |
298 | let len = br.read_code(UintCodeType::Unary012)?; | |
299 | match len { | |
300 | 0 => Ok(15 + (br.read(5)? as usize)), | |
301 | 1 => Ok(47 + (br.read(8)? as usize)), | |
302 | _ => Ok(303 + (br.read(16)? as usize)), | |
303 | } | |
304 | } | |
305 | } | |
306 | ||
5b24175d KS |
307 | struct VP34Decoder { |
308 | info: NACodecInfoRef, | |
309 | width: usize, | |
310 | height: usize, | |
311 | mb_w: usize, | |
312 | mb_h: usize, | |
313 | version: u8, | |
314 | is_intra: bool, | |
315 | quant: usize, | |
316 | shuf: VPShuffler, | |
347108c9 | 317 | codes: Codes, |
8e4b2f44 | 318 | aux_codes: Option<VP40AuxCodes>, |
5b24175d | 319 | loop_str: i16, |
8e4b2f44 | 320 | mc_buf: NAVideoBufferRef<u8>, |
5b24175d KS |
321 | |
322 | blocks: Vec<Block>, | |
3567fcdb | 323 | mb_coded: Vec<bool>, |
8e4b2f44 | 324 | mb_partial: Vec<bool>, |
5b24175d KS |
325 | y_blocks: usize, |
326 | y_sbs: usize, | |
327 | qmat_y: [i16; 64], | |
328 | qmat_c: [i16; 64], | |
8e4b2f44 KS |
329 | qmat_y_p: [i16; 64], |
330 | qmat_c_p: [i16; 64], | |
5b24175d KS |
331 | |
332 | eob_run: usize, | |
333 | last_dc: [i16; 3], | |
334 | ||
335 | blk_addr: Vec<usize>, | |
8e4b2f44 | 336 | blk_sub: Vec<u8>, |
5b24175d KS |
337 | sb_info: Vec<SBState>, |
338 | sb_blocks: Vec<u8>, | |
3567fcdb KS |
339 | sb_mbs: Vec<u8>, |
340 | mb_blocks: Vec<u8>, | |
341 | } | |
342 | ||
343 | fn vp30_read_mv_comp(br: &mut BitReader) -> DecoderResult<i16> { | |
344 | let mode = br.read(2)?; | |
345 | if mode == 0 { return Ok(0); } | |
346 | let sign = br.read_bool()?; | |
347 | let val = match mode - 1 { | |
348 | 0 => 1, | |
349 | 1 => 2 + (br.read(2)? as i16), | |
350 | _ => br.read(5)? as i16, | |
351 | }; | |
352 | if !sign { | |
353 | Ok(val) | |
354 | } else { | |
355 | Ok(-val) | |
356 | } | |
357 | } | |
358 | ||
359 | fn vp30_read_mv(br: &mut BitReader) -> DecoderResult<MV> { | |
360 | let x = vp30_read_mv_comp(br)?; | |
361 | let y = vp30_read_mv_comp(br)?; | |
362 | Ok(MV{ x, y }) | |
5b24175d KS |
363 | } |
364 | ||
365 | fn read_mv_comp_packed(br: &mut BitReader) -> DecoderResult<i16> { | |
366 | let code = br.read(3)?; | |
367 | match code { | |
368 | 0 => Ok(0), | |
369 | 1 => Ok(1), | |
370 | 2 => Ok(-1), | |
371 | 3 => if br.read_bool()? { Ok(-2) } else { Ok(2) }, | |
372 | 4 => if br.read_bool()? { Ok(-3) } else { Ok(3) }, | |
373 | 5 => { | |
374 | let val = (br.read(2)? as i16) + 4; | |
375 | if br.read_bool()? { | |
376 | Ok(-val) | |
377 | } else { | |
378 | Ok(val) | |
379 | } | |
380 | }, | |
381 | 6 => { | |
382 | let val = (br.read(3)? as i16) + 8; | |
383 | if br.read_bool()? { | |
384 | Ok(-val) | |
385 | } else { | |
386 | Ok(val) | |
387 | } | |
388 | }, | |
389 | _ => { | |
390 | let val = (br.read(4)? as i16) + 16; | |
391 | if br.read_bool()? { | |
392 | Ok(-val) | |
393 | } else { | |
394 | Ok(val) | |
395 | } | |
396 | }, | |
397 | } | |
398 | } | |
399 | ||
400 | fn read_mv_packed(br: &mut BitReader) -> DecoderResult<MV> { | |
401 | let x = read_mv_comp_packed(br)?; | |
402 | let y = read_mv_comp_packed(br)?; | |
403 | Ok(MV{ x, y }) | |
404 | } | |
405 | ||
406 | fn read_mv_comp_raw(br: &mut BitReader) -> DecoderResult<i16> { | |
407 | let val = br.read(5)? as i16; | |
408 | if br.read_bool()? { | |
409 | Ok(-val) | |
410 | } else { | |
411 | Ok(val) | |
412 | } | |
413 | } | |
414 | ||
415 | fn read_mv_raw(br: &mut BitReader) -> DecoderResult<MV> { | |
416 | let x = read_mv_comp_raw(br)?; | |
417 | let y = read_mv_comp_raw(br)?; | |
418 | Ok(MV{ x, y }) | |
419 | } | |
420 | ||
6fbd24ec | 421 | fn rescale_qmat(dst_qmat: &mut [i16; 64], base_qmat: &[i16; 64], dc_quant: i16, ac_quant: i16, minval: i16) { |
5b24175d | 422 | for (dst, src) in dst_qmat.iter_mut().zip(base_qmat.iter()) { |
6fbd24ec | 423 | *dst = (src.wrapping_mul(ac_quant) / 100).max(minval) << 2; |
5b24175d | 424 | } |
6fbd24ec | 425 | dst_qmat[0] = (base_qmat[0] * dc_quant / 100).max(minval * 2) << 2; |
5b24175d KS |
426 | } |
427 | ||
503368d1 | 428 | fn expand_token(blk: &mut Block, br: &mut BitReader, eob_run: &mut usize, token: u8) -> DecoderResult<()> { |
6543b6f8 KS |
429 | match token { |
430 | // EOBs | |
431 | 0 | 1 | 2 => { *eob_run = (token as usize) + 1; }, | |
432 | 3 | 4 | 5 => { | |
433 | let bits = token - 1; | |
434 | *eob_run = (br.read(bits)? as usize) + (1 << bits); | |
435 | }, | |
436 | 6 => { *eob_run = br.read(12)? as usize; }, | |
437 | // zero runs | |
438 | 7 | 8 => { | |
439 | let bits = if token == 7 { 3 } else { 6 }; | |
440 | let run = (br.read(bits)? as usize) + 1; | |
441 | blk.idx += run; | |
442 | validate!(blk.idx <= 64); | |
443 | }, | |
444 | // single coefficients | |
445 | 9 | 10 | 11 | 12 => { | |
446 | let val = (i16::from(token) - 7) >> 1; | |
447 | if (token & 1) == 1 { | |
448 | blk.coeffs[ZIGZAG[blk.idx]] = val; | |
449 | } else { | |
450 | blk.coeffs[ZIGZAG[blk.idx]] = -val; | |
451 | } | |
452 | blk.idx += 1; | |
453 | }, | |
454 | 13 | 14 | 15 | 16 => { | |
455 | let val = i16::from(token) - 10; | |
456 | if !br.read_bool()? { | |
457 | blk.coeffs[ZIGZAG[blk.idx]] = val; | |
458 | } else { | |
459 | blk.coeffs[ZIGZAG[blk.idx]] = -val; | |
460 | } | |
461 | blk.idx += 1; | |
462 | }, | |
463 | 17 | 18 | 19 | 20 | 21 | 22 => { | |
464 | let add_bits = if token == 22 { 9 } else { token - 16 }; | |
465 | let sign = br.read_bool()?; | |
466 | let val = (br.read(add_bits)? as i16) + VP3_LITERAL_BASE[(token - 17) as usize]; | |
467 | if !sign { | |
468 | blk.coeffs[ZIGZAG[blk.idx]] = val; | |
469 | } else { | |
470 | blk.coeffs[ZIGZAG[blk.idx]] = -val; | |
471 | } | |
472 | blk.idx += 1; | |
473 | } | |
474 | // zero run plus coefficient | |
475 | 23 | 24 | 25 | 26 | 27 => { | |
476 | blk.idx += (token - 22) as usize; | |
477 | validate!(blk.idx < 64); | |
478 | if !br.read_bool()? { | |
479 | blk.coeffs[ZIGZAG[blk.idx]] = 1; | |
480 | } else { | |
481 | blk.coeffs[ZIGZAG[blk.idx]] = -1; | |
482 | } | |
483 | blk.idx += 1; | |
484 | }, | |
485 | 28 | 29 => { | |
486 | let run_bits = token - 26; | |
487 | if token == 28 { | |
488 | blk.idx += 6; | |
489 | } else { | |
490 | blk.idx += 10; | |
491 | } | |
492 | let sign = br.read_bool()?; | |
493 | blk.idx += br.read(run_bits)? as usize; | |
494 | validate!(blk.idx < 64); | |
495 | if !sign { | |
496 | blk.coeffs[ZIGZAG[blk.idx]] = 1; | |
497 | } else { | |
498 | blk.coeffs[ZIGZAG[blk.idx]] = -1; | |
499 | } | |
500 | blk.idx += 1; | |
501 | }, | |
502 | 30 => { | |
503 | blk.idx += 1; | |
504 | validate!(blk.idx < 64); | |
505 | let sign = br.read_bool()?; | |
506 | let val = (br.read(1)? as i16) + 2; | |
507 | if !sign { | |
508 | blk.coeffs[ZIGZAG[blk.idx]] = val; | |
509 | } else { | |
510 | blk.coeffs[ZIGZAG[blk.idx]] = -val; | |
511 | } | |
512 | blk.idx += 1; | |
513 | }, | |
514 | _ => { | |
515 | let sign = br.read_bool()?; | |
516 | let val = (br.read(1)? as i16) + 2; | |
517 | blk.idx += (br.read(1)? as usize) + 2; | |
518 | validate!(blk.idx < 64); | |
519 | if !sign { | |
520 | blk.coeffs[ZIGZAG[blk.idx]] = val; | |
521 | } else { | |
522 | blk.coeffs[ZIGZAG[blk.idx]] = -val; | |
523 | } | |
524 | blk.idx += 1; | |
525 | }, | |
526 | }; | |
527 | if *eob_run > 0 { | |
528 | blk.idx = 64; | |
529 | *eob_run -= 1; | |
503368d1 | 530 | } else if (token > 8) && (blk.idx > 1) { |
6543b6f8 KS |
531 | blk.has_ac = true; |
532 | } | |
533 | Ok(()) | |
534 | } | |
3567fcdb | 535 | |
5b24175d KS |
536 | macro_rules! fill_dc_pred { |
537 | ($self: expr, $ref_id: expr, $pred: expr, $pp: expr, $bit: expr, $idx: expr) => { | |
538 | if $self.blocks[$idx].coded && $self.blocks[$idx].btype.get_ref_id() == $ref_id { | |
539 | $pred[$bit] = $self.blocks[$idx].coeffs[0] as i32; | |
540 | $pp |= 1 << $bit; | |
541 | } | |
542 | }; | |
543 | } | |
544 | ||
6543b6f8 | 545 | fn vp31_loop_filter_v(frm: &mut NASimpleVideoFrame<u8>, x: usize, y: usize, plane: usize, loop_str: i16) { |
5b24175d | 546 | let off = frm.offset[plane] + x + y * frm.stride[plane]; |
8d8ddfe1 | 547 | vp31_loop_filter(frm.data, off, 1, frm.stride[plane], 8, loop_str); |
5b24175d KS |
548 | } |
549 | ||
6543b6f8 | 550 | fn vp31_loop_filter_h(frm: &mut NASimpleVideoFrame<u8>, x: usize, y: usize, plane: usize, loop_str: i16) { |
5b24175d | 551 | let off = frm.offset[plane] + x + y * frm.stride[plane]; |
8d8ddfe1 | 552 | vp31_loop_filter(frm.data, off, frm.stride[plane], 1, 8, loop_str); |
5b24175d KS |
553 | } |
554 | ||
3cc76ad5 KS |
555 | fn vp3_mv_mode(mvx: i16, mvy: i16) -> usize { |
556 | let mode = ((mvx & 1) + (mvy & 1) * 2) as usize; | |
557 | if (mode == 3) && (mvx ^ mvy < 0) { | |
558 | 4 | |
559 | } else { | |
560 | mode | |
561 | } | |
562 | } | |
563 | ||
5b24175d KS |
564 | impl VP34Decoder { |
565 | fn new(version: u8) -> Self { | |
8e4b2f44 KS |
566 | let vt = alloc_video_buffer(NAVideoInfo::new(24, 24, false, YUV420_FORMAT), 4).unwrap(); |
567 | let mc_buf = vt.get_vbuf().unwrap(); | |
5b24175d KS |
568 | Self { |
569 | info: NACodecInfoRef::default(), | |
570 | width: 0, | |
571 | height: 0, | |
572 | mb_w: 0, | |
573 | mb_h: 0, | |
574 | version, | |
575 | is_intra: true, | |
576 | quant: 0, | |
577 | shuf: VPShuffler::new(), | |
347108c9 | 578 | codes: Codes::None, |
8e4b2f44 | 579 | aux_codes: None, |
5b24175d | 580 | loop_str: 0, |
8e4b2f44 | 581 | mc_buf, |
5b24175d KS |
582 | |
583 | blocks: Vec::new(), | |
3567fcdb | 584 | mb_coded: Vec::new(), |
8e4b2f44 | 585 | mb_partial: Vec::new(), |
5b24175d KS |
586 | y_blocks: 0, |
587 | y_sbs: 0, | |
588 | ||
589 | qmat_y: [0; 64], | |
590 | qmat_c: [0; 64], | |
8e4b2f44 KS |
591 | qmat_y_p: [0; 64], |
592 | qmat_c_p: [0; 64], | |
5b24175d KS |
593 | |
594 | eob_run: 0, | |
595 | last_dc: [0; 3], | |
596 | ||
597 | blk_addr: Vec::new(), | |
8e4b2f44 | 598 | blk_sub: Vec::new(), |
5b24175d KS |
599 | sb_info: Vec::new(), |
600 | sb_blocks: Vec::new(), | |
3567fcdb KS |
601 | sb_mbs: Vec::new(), |
602 | mb_blocks: Vec::new(), | |
5b24175d KS |
603 | } |
604 | } | |
605 | fn parse_header(&mut self, br: &mut BitReader) -> DecoderResult<()> { | |
606 | self.is_intra = !br.read_bool()?; | |
607 | br.skip(1)?; | |
608 | self.quant = br.read(6)? as usize; | |
5b24175d KS |
609 | if self.is_intra { |
610 | if br.peek(8) != 0 { | |
3567fcdb KS |
611 | validate!(self.version == 3 || self.version == 30); |
612 | let mb_w = br.read(8)? as usize; | |
613 | let mb_h = br.read(8)? as usize; | |
3567fcdb KS |
614 | validate!(mb_w == self.mb_w && mb_h == self.mb_h); |
615 | if self.version == 3 { | |
616 | self.version = 30; | |
617 | self.codes = Codes::VP30(VP30Codes::new()); | |
618 | } | |
619 | } else { | |
620 | let version = br.read(13)?; | |
3567fcdb KS |
621 | let coding_type = br.read(1)?; |
622 | validate!(coding_type == 0); | |
5b24175d | 623 | br.skip(2)?; |
3567fcdb KS |
624 | if version == 1 { |
625 | validate!(self.version == 3 || self.version == 31); | |
626 | if self.version == 3 { | |
627 | self.version = 31; | |
628 | self.codes = Codes::VP31(VP31Codes::new()); | |
629 | } | |
8e4b2f44 | 630 | } else if version == 3 { |
3567fcdb | 631 | validate!(self.version == 4); |
8e4b2f44 KS |
632 | let mb_h = br.read(8)? as usize; |
633 | let mb_w = br.read(8)? as usize; | |
8e4b2f44 KS |
634 | validate!(mb_w == self.mb_w && mb_h == self.mb_h); |
635 | let fact1 = br.read(5)?; | |
636 | let fact2 = br.read(3)?; | |
637 | validate!(fact1 == 1 && fact2 == 1); | |
638 | let fact1 = br.read(5)?; | |
639 | let fact2 = br.read(3)?; | |
640 | validate!(fact1 == 1 && fact2 == 1); | |
641 | br.skip(2)?; | |
3567fcdb KS |
642 | } else { |
643 | return Err(DecoderError::InvalidData); | |
644 | } | |
645 | } | |
646 | } | |
8e4b2f44 KS |
647 | self.loop_str = if self.version != 4 { |
648 | VP31_LOOP_STRENGTH[self.quant] | |
649 | } else { | |
650 | VP40_LOOP_STRENGTH[self.quant] | |
651 | }; | |
3567fcdb KS |
652 | Ok(()) |
653 | } | |
654 | fn vp30_unpack_sb_info(&mut self, br: &mut BitReader) -> DecoderResult<()> { | |
655 | let mut has_nonempty = false; | |
656 | { | |
657 | let mut bit = !br.read_bool()?; | |
658 | let mut run = 0; | |
659 | for sb in self.sb_info.iter_mut() { | |
660 | if run == 0 { | |
661 | bit = !bit; | |
662 | run = if bit { vp30_read_ne_run1(br)? } else { vp30_read_ne_run0(br)? }; | |
663 | } | |
664 | *sb = if bit { has_nonempty = true; SBState::Partial } else { SBState::Uncoded }; | |
665 | run -= 1; | |
666 | } | |
667 | validate!(run == 0); | |
668 | } | |
669 | if has_nonempty { | |
670 | for el in self.mb_coded.iter_mut() { *el = false; } | |
671 | let mut bit = !br.read_bool()?; | |
672 | let mut run = 0; | |
673 | let mut mbiter = self.mb_coded.iter_mut(); | |
674 | for (sb, nmb) in self.sb_info.iter_mut().zip(self.sb_mbs.iter()) { | |
675 | let nmbs = *nmb as usize; | |
676 | if *sb == SBState::Partial { | |
677 | for _ in 0..nmbs { | |
678 | if run == 0 { | |
679 | bit = !bit; | |
680 | run = if bit { vp30_read_coded_run1(br)? } else { vp30_read_coded_run0(br)? }; | |
681 | } | |
682 | run -= 1; | |
683 | *mbiter.next().unwrap() = bit; | |
684 | } | |
685 | } else { | |
686 | for _ in 0..nmbs { | |
687 | mbiter.next().unwrap(); | |
688 | } | |
689 | } | |
690 | } | |
691 | validate!(run == 0); | |
692 | let mut bit = !br.read_bool()?; | |
693 | let mut run = 0; | |
694 | let mut cur_blk = 0; | |
695 | for (coded, nblk) in self.mb_coded.iter().zip(self.mb_blocks.iter()) { | |
696 | let nblks = *nblk as usize; | |
697 | if *coded { | |
698 | let mut cb = [false; 4]; | |
699 | for j in 0..nblks { | |
700 | if run == 0 { | |
701 | bit = !bit; | |
702 | run = if bit { vp30_read_coded_run1(br)? } else { vp30_read_coded_run0(br)? }; | |
703 | } | |
704 | run -= 1; | |
705 | cb[j] = bit; | |
706 | } | |
707 | for j in 0..nblks { | |
708 | let addr = self.blk_addr[cur_blk + j] >> 2; | |
709 | self.blocks[addr].coded = cb[j]; | |
710 | } | |
711 | } | |
712 | cur_blk += nblks; | |
713 | } | |
714 | validate!(run == 0); | |
715 | } | |
716 | Ok(()) | |
717 | } | |
718 | fn vp30_unpack_mb_info(&mut self, br: &mut BitReader) -> DecoderResult<()> { | |
719 | let mut cur_blk = 0; | |
720 | if let Codes::VP30(ref codes) = self.codes { | |
721 | for (sb, nblk) in self.sb_info.iter_mut().zip(self.sb_blocks.iter()).take(self.y_sbs) { | |
722 | let nblks = *nblk as usize; | |
723 | if *sb == SBState::Uncoded { | |
724 | for _ in 0..nblks { | |
725 | self.blocks[self.blk_addr[cur_blk] >> 2].btype = VPMBType::InterNoMV; | |
726 | cur_blk += 1; | |
727 | } | |
728 | } else { | |
729 | for _ in 0..nblks/4 { | |
730 | let mut coded = *sb == SBState::Coded; | |
731 | if !coded { | |
732 | for blk in 0..4 { | |
733 | if self.blocks[self.blk_addr[cur_blk + blk] >> 2].coded { | |
734 | coded = true; | |
735 | break; | |
736 | } | |
737 | } | |
738 | } | |
739 | let mode = if !coded { | |
740 | VPMBType::InterNoMV | |
741 | } else { | |
742 | br.read_cb(&codes.mbtype_cb)? | |
743 | }; | |
744 | for _ in 0..4 { | |
745 | self.blocks[self.blk_addr[cur_blk] >> 2].btype = mode; | |
746 | cur_blk += 1; | |
747 | } | |
748 | } | |
749 | } | |
750 | } | |
751 | } else { | |
752 | return Err(DecoderError::Bug); | |
753 | } | |
754 | // replicate types for chroma | |
755 | let mut off_y = 0; | |
756 | let mut off_u = self.y_blocks; | |
757 | let mut off_v = off_u + self.mb_w * self.mb_h; | |
758 | for _blk_y in 0..self.mb_h { | |
759 | for blk_x in 0..self.mb_w { | |
760 | let btype = self.blocks[off_y + blk_x * 2].btype; | |
761 | self.blocks[off_u + blk_x].btype = btype; | |
762 | self.blocks[off_v + blk_x].btype = btype; | |
763 | } | |
764 | off_y += self.mb_w * 2 * 2; | |
765 | off_u += self.mb_w; | |
766 | off_v += self.mb_w; | |
767 | } | |
768 | Ok(()) | |
769 | } | |
770 | fn vp30_unpack_mv_info(&mut self, br: &mut BitReader) -> DecoderResult<()> { | |
771 | let mut last_mv = ZERO_MV; | |
772 | ||
773 | let mut cur_blk = 0; | |
774 | for _ in 0..self.y_blocks/4 { | |
775 | let baddr = self.blk_addr[cur_blk] >> 2; | |
776 | if self.blocks[baddr].btype == VPMBType::InterFourMV { | |
777 | let saddr = baddr.min(self.blk_addr[cur_blk + 1] >> 2).min(self.blk_addr[cur_blk + 2] >> 2).min(self.blk_addr[cur_blk + 3] >> 2); | |
778 | for i in 0..4 { | |
779 | let blk = &mut self.blocks[saddr + (i & 1) + (i & 2) * self.mb_w]; | |
780 | if blk.coded { | |
781 | blk.mv = vp30_read_mv(br)?; | |
782 | } | |
783 | cur_blk += 1; | |
347108c9 | 784 | } |
347108c9 | 785 | } else { |
3567fcdb KS |
786 | let cur_mv; |
787 | match self.blocks[baddr].btype { | |
788 | VPMBType::Intra | VPMBType::InterNoMV | VPMBType::GoldenNoMV => { | |
789 | cur_mv = ZERO_MV; | |
790 | }, | |
791 | VPMBType::InterMV => { | |
792 | cur_mv = vp30_read_mv(br)?; | |
793 | last_mv = cur_mv; | |
794 | }, | |
795 | VPMBType::InterNearest => { | |
796 | cur_mv = last_mv; | |
797 | }, | |
798 | _ => { // GoldenMV | |
799 | cur_mv = vp30_read_mv(br)?; | |
800 | }, | |
801 | }; | |
802 | for _ in 0..4 { | |
803 | self.blocks[self.blk_addr[cur_blk] >> 2].mv = cur_mv; | |
804 | cur_blk += 1; | |
805 | } | |
347108c9 | 806 | } |
5b24175d KS |
807 | } |
808 | Ok(()) | |
809 | } | |
3567fcdb KS |
810 | fn vp30_unpack_coeffs(&mut self, br: &mut BitReader, coef_no: usize, table: usize) -> DecoderResult<()> { |
811 | if let Codes::VP30(ref codes) = self.codes { | |
812 | for blkaddr in self.blk_addr.iter() { | |
813 | let blk: &mut Block = &mut self.blocks[blkaddr >> 2]; | |
814 | if !blk.coded || blk.idx != coef_no { continue; } | |
815 | if self.eob_run > 0 { | |
816 | blk.idx = 64; | |
817 | self.eob_run -= 1; | |
818 | continue; | |
819 | } | |
820 | let cb = if coef_no == 0 { | |
821 | &codes.dc_cb[table] | |
822 | } else if blk.btype.is_intra() { | |
823 | &codes.ac_i_cb[table] | |
824 | } else { | |
825 | &codes.ac_p_cb[table] | |
826 | }; | |
827 | let token = br.read_cb(cb)?; | |
503368d1 | 828 | expand_token(blk, br, &mut self.eob_run, token)?; |
3567fcdb KS |
829 | } |
830 | Ok(()) | |
831 | } else { | |
832 | Err(DecoderError::Bug) | |
833 | } | |
834 | } | |
6543b6f8 | 835 | fn vp31_unpack_sb_info(&mut self, br: &mut BitReader) -> DecoderResult<()> { |
5b24175d KS |
836 | let mut has_uncoded = false; |
837 | let mut has_partial = false; | |
838 | { | |
839 | let mut brun = BitRunDecoder::new(br, read_long_run)?; | |
840 | for sb in self.sb_info.iter_mut() { | |
841 | if brun.get_val(br)? { | |
842 | *sb = SBState::Partial; | |
843 | has_partial = true; | |
844 | } else { | |
845 | *sb = SBState::Uncoded; | |
846 | has_uncoded = true; | |
847 | } | |
848 | } | |
849 | } | |
850 | if has_uncoded { | |
851 | let mut brun = BitRunDecoder::new(br, read_long_run)?; | |
852 | let mut cur_blk = 0; | |
853 | for (sb, nblk) in self.sb_info.iter_mut().zip(self.sb_blocks.iter()) { | |
854 | let nblks = *nblk as usize; | |
855 | if *sb != SBState::Partial && brun.get_val(br)? { | |
856 | *sb = SBState::Coded; | |
857 | for _ in 0..nblks { | |
858 | let blk_idx = self.blk_addr[cur_blk] >> 2; | |
859 | self.blocks[blk_idx].coded = true; | |
860 | cur_blk += 1; | |
861 | } | |
862 | } else { | |
863 | for _ in 0..nblks { | |
864 | let blk_idx = self.blk_addr[cur_blk] >> 2; | |
865 | self.blocks[blk_idx].coded = false; | |
866 | cur_blk += 1; | |
867 | } | |
868 | } | |
869 | } | |
870 | } | |
871 | if has_partial { | |
872 | let mut brun = BitRunDecoder::new(br, read_short_run)?; | |
873 | let mut cur_blk = 0; | |
874 | for (sb, nblk) in self.sb_info.iter_mut().zip(self.sb_blocks.iter()) { | |
875 | let nblks = *nblk as usize; | |
876 | if *sb == SBState::Partial { | |
877 | for _ in 0..nblks { | |
878 | let blk_idx = self.blk_addr[cur_blk] >> 2; | |
879 | self.blocks[blk_idx].coded = brun.get_val(br)?; | |
880 | cur_blk += 1; | |
881 | } | |
882 | } else { | |
883 | cur_blk += nblks; | |
884 | } | |
885 | } | |
886 | } | |
887 | Ok(()) | |
888 | } | |
6543b6f8 | 889 | fn vp31_unpack_mb_info(&mut self, br: &mut BitReader) -> DecoderResult<()> { |
5b24175d KS |
890 | let mut modes = [VPMBType::InterNoMV; 8]; |
891 | let alphabet = br.read(3)? as usize; | |
892 | let raw_modes = alphabet >= 7; | |
893 | if alphabet == 0 { | |
6543b6f8 | 894 | for mode in VP31_DEFAULT_MB_MODES.iter() { |
5b24175d KS |
895 | modes[br.read(3)? as usize] = *mode; |
896 | } | |
897 | } else if alphabet < 7 { | |
6543b6f8 | 898 | modes.copy_from_slice(&VP31_MB_MODES[alphabet - 1]); |
5b24175d KS |
899 | } |
900 | ||
901 | let mut cur_blk = 0; | |
902 | for (sb, nblk) in self.sb_info.iter_mut().zip(self.sb_blocks.iter()).take(self.y_sbs) { | |
903 | let nblks = *nblk as usize; | |
904 | if *sb == SBState::Uncoded { | |
905 | for _ in 0..nblks { | |
906 | self.blocks[self.blk_addr[cur_blk] >> 2].btype = VPMBType::InterNoMV; | |
907 | cur_blk += 1; | |
908 | } | |
909 | } else { | |
910 | for _ in 0..nblks/4 { | |
911 | let mut coded = *sb == SBState::Coded; | |
912 | if !coded { | |
913 | for blk in 0..4 { | |
914 | if self.blocks[self.blk_addr[cur_blk + blk] >> 2].coded { | |
915 | coded = true; | |
916 | break; | |
917 | } | |
918 | } | |
919 | } | |
920 | let mode = if !coded { | |
921 | VPMBType::InterNoMV | |
922 | } else if !raw_modes { | |
923 | let code = br.read_code(UintCodeType::LimitedUnary(7, 0))?; | |
924 | modes[code as usize] | |
925 | } else { | |
6543b6f8 | 926 | VP31_DEFAULT_MB_MODES[br.read(3)? as usize] |
5b24175d KS |
927 | }; |
928 | for _ in 0..4 { | |
929 | self.blocks[self.blk_addr[cur_blk] >> 2].btype = mode; | |
930 | cur_blk += 1; | |
931 | } | |
932 | } | |
933 | } | |
934 | } | |
935 | // replicate types for chroma | |
936 | let mut off_y = 0; | |
937 | let mut off_u = self.y_blocks; | |
938 | let mut off_v = off_u + self.mb_w * self.mb_h; | |
939 | for _blk_y in 0..self.mb_h { | |
940 | for blk_x in 0..self.mb_w { | |
941 | let btype = self.blocks[off_y + blk_x * 2].btype; | |
942 | self.blocks[off_u + blk_x].btype = btype; | |
943 | self.blocks[off_v + blk_x].btype = btype; | |
944 | } | |
945 | off_y += self.mb_w * 2 * 2; | |
946 | off_u += self.mb_w; | |
947 | off_v += self.mb_w; | |
948 | } | |
949 | Ok(()) | |
950 | } | |
6543b6f8 | 951 | fn vp31_unpack_mv_info(&mut self, br: &mut BitReader) -> DecoderResult<()> { |
5b24175d KS |
952 | let mut last_mv = ZERO_MV; |
953 | let mut last2_mv = ZERO_MV; | |
954 | let read_mv = if br.read_bool()? { read_mv_raw } else { read_mv_packed }; | |
955 | ||
956 | let mut cur_blk = 0; | |
957 | for _ in 0..self.y_blocks/4 { | |
958 | if self.blocks[self.blk_addr[cur_blk] >> 2].btype == VPMBType::InterFourMV { | |
5d00209d KS |
959 | let a0 = self.blk_addr[cur_blk + 0] >> 2; |
960 | let a1 = self.blk_addr[cur_blk + 1] >> 2; | |
961 | let a2 = self.blk_addr[cur_blk + 2] >> 2; | |
962 | let a3 = self.blk_addr[cur_blk + 3] >> 2; | |
963 | let first = a0.min(a1).min(a2).min(a3); | |
964 | let last = a0.max(a1).max(a2).max(a3); | |
965 | self.blocks[first + 0].mv = (read_mv)(br)?; | |
966 | self.blocks[first + 1].mv = (read_mv)(br)?; | |
967 | self.blocks[last - 1].mv = (read_mv)(br)?; | |
968 | self.blocks[last + 0].mv = (read_mv)(br)?; | |
969 | last2_mv = last_mv; | |
970 | last_mv = self.blocks[last].mv; | |
971 | cur_blk += 4; | |
5b24175d KS |
972 | } else { |
973 | let cur_mv; | |
974 | match self.blocks[self.blk_addr[cur_blk] >> 2].btype { | |
975 | VPMBType::Intra | VPMBType::InterNoMV | VPMBType::GoldenNoMV => { | |
976 | cur_mv = ZERO_MV; | |
977 | }, | |
978 | VPMBType::InterMV => { | |
979 | cur_mv = (read_mv)(br)?; | |
980 | last2_mv = last_mv; | |
981 | last_mv = cur_mv; | |
982 | }, | |
983 | VPMBType::InterNearest => { | |
984 | cur_mv = last_mv; | |
985 | }, | |
986 | VPMBType::InterNear => { | |
987 | cur_mv = last2_mv; | |
988 | std::mem::swap(&mut last_mv, &mut last2_mv); | |
989 | }, | |
990 | _ => { // GoldenMV | |
991 | cur_mv = (read_mv)(br)?; | |
992 | }, | |
993 | }; | |
994 | for _ in 0..4 { | |
995 | self.blocks[self.blk_addr[cur_blk] >> 2].mv = cur_mv; | |
996 | cur_blk += 1; | |
997 | } | |
998 | } | |
999 | } | |
1000 | Ok(()) | |
1001 | } | |
6543b6f8 | 1002 | fn vp31_unpack_coeffs(&mut self, br: &mut BitReader, coef_no: usize, table_y: usize, table_c: usize) -> DecoderResult<()> { |
347108c9 KS |
1003 | if let Codes::VP31(ref codes) = self.codes { |
1004 | let cbs = if coef_no == 0 { | |
1005 | [&codes.dc_cb[table_y], &codes.dc_cb[table_c]] | |
1006 | } else if coef_no < 6 { | |
1007 | [&codes.ac0_cb[table_y], &codes.ac0_cb[table_c]] | |
1008 | } else if coef_no < 15 { | |
1009 | [&codes.ac1_cb[table_y], &codes.ac1_cb[table_c]] | |
1010 | } else if coef_no < 28 { | |
1011 | [&codes.ac2_cb[table_y], &codes.ac2_cb[table_c]] | |
1012 | } else { | |
1013 | [&codes.ac3_cb[table_y], &codes.ac3_cb[table_c]] | |
1014 | }; | |
1015 | for blkaddr in self.blk_addr.iter() { | |
1016 | let blk: &mut Block = &mut self.blocks[blkaddr >> 2]; | |
1017 | if !blk.coded || blk.idx != coef_no { continue; } | |
1018 | if self.eob_run > 0 { | |
1019 | blk.idx = 64; | |
1020 | self.eob_run -= 1; | |
1021 | continue; | |
1022 | } | |
1023 | let cb = if (blkaddr & 3) == 0 { cbs[0] } else { cbs[1] }; | |
1024 | let token = br.read_cb(cb)?; | |
503368d1 | 1025 | expand_token(blk, br, &mut self.eob_run, token)?; |
5b24175d | 1026 | } |
347108c9 KS |
1027 | Ok(()) |
1028 | } else { | |
1029 | Err(DecoderError::Bug) | |
5b24175d | 1030 | } |
5b24175d | 1031 | } |
8e4b2f44 KS |
1032 | fn vp40_unpack_sb_info(&mut self, br: &mut BitReader) -> DecoderResult<()> { |
1033 | let mut has_uncoded = false; | |
1034 | ||
1035 | if let Some(ref aux_codes) = self.aux_codes { | |
1036 | for el in self.sb_info.iter_mut() { | |
1037 | *el = SBState::Partial; | |
1038 | } | |
1039 | { | |
1040 | let mut mbiter = self.mb_coded.iter_mut(); | |
1041 | let mut brun = BitRunDecoder::new(br, read_mb_run)?; | |
1042 | for nmb in self.sb_mbs.iter() { | |
1043 | let nmbs = *nmb as usize; | |
1044 | for _ in 0..nmbs { | |
1045 | let coded = brun.get_val(br)?; | |
1046 | *mbiter.next().unwrap() = coded; | |
1047 | has_uncoded |= !coded; | |
1048 | } | |
1049 | } | |
1050 | } | |
1051 | if has_uncoded { | |
1052 | let mut mbiter = self.mb_coded.iter().zip(self.mb_partial.iter_mut()); | |
1053 | let mut brun = BitRunDecoder::new(br, read_mb_run)?; | |
1054 | for nmb in self.sb_mbs.iter() { | |
1055 | let nmbs = *nmb as usize; | |
1056 | for _ in 0..nmbs { | |
1057 | let (coded, partial) = mbiter.next().unwrap(); | |
1058 | if *coded { | |
1059 | *partial = false; | |
1060 | } else { | |
1061 | *partial = brun.get_val(br)?; | |
1062 | } | |
1063 | } | |
1064 | } | |
1065 | ||
1066 | let mut bpmode = 0; | |
1067 | let mut cur_blk = 0; | |
1068 | for ((coded, partial), nblk) in self.mb_coded.iter().zip(self.mb_partial.iter()).zip(self.mb_blocks.iter()) { | |
1069 | let nblks = *nblk as usize; | |
1070 | if *coded { | |
1071 | for _ in 0..nblks { | |
1072 | let addr = self.blk_addr[cur_blk] >> 2; | |
1073 | self.blocks[addr].coded = true; | |
1074 | cur_blk += 1; | |
1075 | } | |
1076 | } else if !*partial { | |
1077 | for _ in 0..nblks { | |
1078 | let addr = self.blk_addr[cur_blk] >> 2; | |
1079 | self.blocks[addr].coded = false; | |
1080 | cur_blk += 1; | |
1081 | } | |
1082 | } else { | |
1083 | let mut pat = br.read_cb(&aux_codes.mbpat_cb[bpmode])? + 1; | |
1084 | bpmode = VP40_BP_PREDICTOR[pat as usize] as usize; | |
1085 | ||
1086 | let mut addrs = [0; 4]; | |
1087 | for i in 0..nblks { | |
1088 | addrs[i] = self.blk_addr[cur_blk + i] >> 2; | |
1089 | for j in (0..i).rev() { | |
1090 | if addrs[j] > addrs[j + 1] { | |
1091 | addrs.swap(j, j + 1); | |
1092 | } | |
1093 | } | |
1094 | } | |
1095 | for i in 0..nblks { | |
1096 | self.blocks[addrs[i]].coded = (pat & 8) != 0; | |
1097 | pat <<= 1; | |
1098 | cur_blk += 1; | |
1099 | } | |
1100 | } | |
1101 | } | |
1102 | } | |
1103 | Ok(()) | |
1104 | } else { | |
1105 | Err(DecoderError::Bug) | |
1106 | } | |
1107 | } | |
1108 | fn vp40_unpack_mv_info(&mut self, br: &mut BitReader) -> DecoderResult<()> { | |
1109 | let mut last_mv = ZERO_MV; | |
1110 | let mut last2_mv = ZERO_MV; | |
1111 | let mut last_mv_g = ZERO_MV; | |
1112 | ||
1113 | let mut cur_blk = 0; | |
1114 | if let Some(ref codes) = self.aux_codes { | |
1115 | for _ in 0..self.y_blocks/4 { | |
1116 | if self.blocks[self.blk_addr[cur_blk] >> 2].btype == VPMBType::InterFourMV { | |
1117 | let x_cb = &codes.mv_x_cb[VP40_MV_LUT_INDEX[last_mv.x.abs() as usize]]; | |
1118 | let y_cb = &codes.mv_y_cb[VP40_MV_LUT_INDEX[last_mv.y.abs() as usize]]; | |
1119 | let x_sign = last_mv.x < 0; | |
1120 | let y_sign = last_mv.y < 0; | |
1121 | last2_mv = last_mv; | |
1122 | let saddr = (self.blk_addr[cur_blk] >> 2).min(self.blk_addr[cur_blk + 1] >> 2).min(self.blk_addr[cur_blk + 2] >> 2).min(self.blk_addr[cur_blk + 3] >> 2); | |
1123 | for i in 0..4 { | |
1124 | let blk = &mut self.blocks[saddr + (i & 1) + (i >> 1) * self.mb_w]; | |
1125 | blk.mv.x = br.read_cb(x_cb)? as i16; | |
1126 | if x_sign { | |
1127 | blk.mv.x = -blk.mv.x; | |
1128 | } | |
1129 | blk.mv.y = br.read_cb(y_cb)? as i16; | |
1130 | if y_sign { | |
1131 | blk.mv.y = -blk.mv.y; | |
1132 | } | |
1133 | last_mv = blk.mv; | |
1134 | cur_blk += 1; | |
1135 | } | |
1136 | } else { | |
1137 | let cur_mv; | |
1138 | match self.blocks[self.blk_addr[cur_blk] >> 2].btype { | |
1139 | VPMBType::Intra | VPMBType::InterNoMV | VPMBType::GoldenNoMV => { | |
1140 | cur_mv = ZERO_MV; | |
1141 | }, | |
1142 | VPMBType::InterMV => { | |
1143 | let x_cb = &codes.mv_x_cb[VP40_MV_LUT_INDEX[last_mv.x.abs() as usize]]; | |
1144 | let y_cb = &codes.mv_y_cb[VP40_MV_LUT_INDEX[last_mv.y.abs() as usize]]; | |
1145 | let x_sign = last_mv.x < 0; | |
1146 | let y_sign = last_mv.y < 0; | |
1147 | let x = br.read_cb(x_cb)? as i16; | |
1148 | let y = br.read_cb(y_cb)? as i16; | |
1149 | cur_mv = MV { x: if !x_sign { x } else { -x }, y: if !y_sign { y } else { -y } }; | |
1150 | last2_mv = last_mv; | |
1151 | last_mv = cur_mv; | |
1152 | }, | |
1153 | VPMBType::InterNearest => { | |
1154 | cur_mv = last_mv; | |
1155 | }, | |
1156 | VPMBType::InterNear => { | |
1157 | cur_mv = last2_mv; | |
1158 | std::mem::swap(&mut last_mv, &mut last2_mv); | |
1159 | }, | |
1160 | _ => { // GoldenMV | |
1161 | let x_cb = &codes.mv_x_cb[VP40_MV_LUT_INDEX[last_mv_g.x.abs() as usize]]; | |
1162 | let y_cb = &codes.mv_y_cb[VP40_MV_LUT_INDEX[last_mv_g.y.abs() as usize]]; | |
1163 | let x_sign = last_mv_g.x < 0; | |
1164 | let y_sign = last_mv_g.y < 0; | |
1165 | let x = br.read_cb(x_cb)? as i16; | |
1166 | let y = br.read_cb(y_cb)? as i16; | |
1167 | cur_mv = MV { x: if !x_sign { x } else { -x }, y: if !y_sign { y } else { -y } }; | |
1168 | last_mv_g = cur_mv; | |
1169 | }, | |
1170 | }; | |
1171 | for _ in 0..4 { | |
1172 | self.blocks[self.blk_addr[cur_blk] >> 2].mv = cur_mv; | |
1173 | cur_blk += 1; | |
1174 | } | |
1175 | } | |
1176 | } | |
1177 | Ok(()) | |
1178 | } else { | |
1179 | Err(DecoderError::Bug) | |
1180 | } | |
1181 | } | |
1182 | fn vp40_unpack_coeffs(&mut self, br: &mut BitReader, dc_table_y: usize, dc_table_c: usize, ac_table_y: usize, ac_table_c: usize) -> DecoderResult<()> { | |
1183 | const VP40_PRED_MASKS: [usize; 16] = [ // top, bottom, left, right | |
1184 | 0b1010, 0b1010, 0b1000, 0b1011, | |
1185 | 0b1010, 0b1010, 0b0010, 0b1111, | |
1186 | 0b0010, 0b1010, 0b0010, 0b0110, | |
1187 | 0b0100, 0b0111, 0b1110, 0b1110 | |
1188 | ]; | |
1189 | self.last_dc = [0; 3]; | |
1190 | if let Codes::VP31(ref codes) = self.codes { | |
1191 | let mut coef_eob: [usize; 64] = [0; 64]; | |
1192 | for (blkaddr, bsub) in self.blk_addr.iter().zip(self.blk_sub.iter()) { | |
1193 | let blk: &mut Block = &mut self.blocks[blkaddr >> 2]; | |
1194 | if !blk.coded { continue; } | |
1195 | let mut idx = blkaddr >> 2; | |
1196 | let (bx, by) = if (blkaddr & 3) == 0 { | |
1197 | (idx % (self.mb_w * 2), idx / (self.mb_w * 2)) | |
1198 | } else { | |
1199 | idx -= self.mb_w * self.mb_h * 4; | |
1200 | if idx >= self.mb_w * self.mb_h { | |
1201 | idx -= self.mb_w * self.mb_h; | |
1202 | } | |
1203 | (idx % self.mb_w, idx / self.mb_w) | |
1204 | }; | |
1205 | while blk.idx < 64 { | |
1206 | if coef_eob[blk.idx] > 0 { | |
1207 | coef_eob[blk.idx] -= 1; | |
1208 | blk.idx = 64; | |
1209 | continue; | |
1210 | } | |
1211 | let cbs = if blk.idx == 0 { | |
1212 | [&codes.dc_cb[dc_table_y], &codes.dc_cb[dc_table_c]] | |
1213 | } else if blk.idx < 6 { | |
1214 | [&codes.ac0_cb[ac_table_y], &codes.ac0_cb[ac_table_c]] | |
1215 | } else if blk.idx < 15 { | |
1216 | [&codes.ac1_cb[ac_table_y], &codes.ac1_cb[ac_table_c]] | |
1217 | } else if blk.idx < 28 { | |
1218 | [&codes.ac2_cb[ac_table_y], &codes.ac2_cb[ac_table_c]] | |
1219 | } else { | |
1220 | [&codes.ac3_cb[ac_table_y], &codes.ac3_cb[ac_table_c]] | |
1221 | }; | |
1222 | let cb = if (blkaddr & 3) == 0 { cbs[0] } else { cbs[1] }; | |
1223 | let token = br.read_cb(cb)?; | |
503368d1 | 1224 | expand_token(blk, br, &mut coef_eob[blk.idx], token)?; |
8e4b2f44 KS |
1225 | if blk.idx == 64 { break; } |
1226 | } | |
1227 | let idx = blkaddr >> 2; | |
1228 | let mask = VP40_PRED_MASKS[*bsub as usize]; | |
1229 | if (blkaddr & 3) == 0 { | |
1230 | let pred_dc = self.vp40_predict_dc(bx, by, self.mb_w * 2, self.mb_h * 2, idx, mask, true); | |
1231 | let blk: &mut Block = &mut self.blocks[blkaddr >> 2]; | |
1232 | blk.coeffs[0] += pred_dc; | |
1233 | self.last_dc[blk.btype.get_ref_id() as usize] = blk.coeffs[0]; | |
1234 | } else { | |
1235 | let pred_dc = self.vp40_predict_dc(bx, by, self.mb_w, self.mb_h, idx, mask, false); | |
1236 | let blk: &mut Block = &mut self.blocks[blkaddr >> 2]; | |
1237 | blk.coeffs[0] += pred_dc; | |
1238 | self.last_dc[blk.btype.get_ref_id() as usize] = blk.coeffs[0]; | |
1239 | } | |
1240 | } | |
1241 | Ok(()) | |
1242 | } else { | |
1243 | Err(DecoderError::Bug) | |
1244 | } | |
1245 | } | |
3567fcdb KS |
1246 | fn decode_vp30(&mut self, br: &mut BitReader, frm: &mut NASimpleVideoFrame<u8>) -> DecoderResult<()> { |
1247 | for blk in self.blocks.iter_mut() { | |
1248 | blk.coeffs = [0; 64]; | |
1249 | blk.idx = 0; | |
1250 | blk.coded = false; | |
1251 | blk.has_ac = false; | |
1252 | } | |
1253 | if self.is_intra { | |
1254 | for sb in self.sb_info.iter_mut() { *sb = SBState::Coded; } | |
1255 | for blk in self.blocks.iter_mut() { | |
1256 | blk.btype = VPMBType::Intra; | |
1257 | blk.coded = true; | |
1258 | } | |
1259 | } else { | |
1260 | if self.shuf.get_last().is_none() || self.shuf.get_golden().is_none() { | |
1261 | return Err(DecoderError::MissingReference); | |
1262 | } | |
1263 | self.vp30_unpack_sb_info(br)?; | |
1264 | self.vp30_unpack_mb_info(br)?; | |
1265 | self.vp30_unpack_mv_info(br)?; | |
1266 | } | |
1267 | let dc_quant = VP30_DC_SCALES[self.quant] * 10; | |
1268 | let ac_quant = VP30_AC_SCALES[self.quant]; | |
1269 | rescale_qmat(&mut self.qmat_y, VP3_QMAT_Y, dc_quant, ac_quant, 2); | |
1270 | rescale_qmat(&mut self.qmat_c, VP3_QMAT_C, dc_quant, ac_quant, 2); | |
8e4b2f44 | 1271 | rescale_qmat(&mut self.qmat_y_p, VP3_QMAT_INTER, dc_quant, ac_quant, 4); |
3567fcdb KS |
1272 | if self.quant == 10 { |
1273 | self.qmat_y[29] = 980; | |
1274 | self.qmat_y[58] = 1636; | |
1275 | self.qmat_y[59] = 1964; | |
1276 | } else if self.quant == 31 { | |
1277 | self.qmat_y[58] = 456; | |
1278 | } else if self.quant == 44 { | |
1279 | self.qmat_y[58] = 224; | |
1280 | } | |
8e4b2f44 | 1281 | self.qmat_c_p.copy_from_slice(&self.qmat_y_p); |
3567fcdb KS |
1282 | |
1283 | let table = if ac_quant <= 50 { | |
1284 | 0 | |
1285 | } else if ac_quant <= 150 { | |
1286 | 1 | |
1287 | } else if ac_quant <= 300 { | |
1288 | 2 | |
1289 | } else if ac_quant <= 600 { | |
1290 | 3 | |
1291 | } else { | |
1292 | 4 | |
1293 | }; | |
1294 | ||
1295 | self.eob_run = 0; | |
1296 | self.vp30_unpack_coeffs(br, 0, table)?; | |
1297 | let mut last_dc_i = 0; | |
1298 | let mut last_dc_p = 0; | |
1299 | for blkaddr in self.blk_addr.iter() { | |
1300 | let blk: &mut Block = &mut self.blocks[blkaddr >> 2]; | |
1301 | if !blk.coded { continue; } | |
1302 | if blk.btype.is_intra() { | |
1303 | blk.coeffs[0] += last_dc_i; | |
1304 | last_dc_i = blk.coeffs[0]; | |
1305 | } else { | |
1306 | blk.coeffs[0] += last_dc_p; | |
1307 | last_dc_p = blk.coeffs[0]; | |
1308 | } | |
1309 | } | |
1310 | ||
1311 | for coef_no in 1..64 { | |
1312 | self.vp30_unpack_coeffs(br, coef_no, table)?; | |
1313 | } | |
1314 | ||
1315 | if self.is_intra { | |
1316 | self.output_blocks_intra(frm); | |
1317 | } else { | |
1318 | self.output_blocks_inter(frm); | |
1319 | } | |
1320 | ||
1321 | Ok(()) | |
1322 | } | |
6543b6f8 | 1323 | fn decode_vp31(&mut self, br: &mut BitReader, frm: &mut NASimpleVideoFrame<u8>) -> DecoderResult<()> { |
5b24175d KS |
1324 | for blk in self.blocks.iter_mut() { |
1325 | blk.coeffs = [0; 64]; | |
1326 | blk.idx = 0; | |
1327 | blk.coded = false; | |
1328 | blk.has_ac = false; | |
1329 | } | |
1330 | if self.is_intra { | |
1331 | for sb in self.sb_info.iter_mut() { *sb = SBState::Coded; } | |
1332 | for blk in self.blocks.iter_mut() { | |
1333 | blk.btype = VPMBType::Intra; | |
1334 | blk.coded = true; | |
1335 | } | |
1336 | } else { | |
1337 | if self.shuf.get_last().is_none() || self.shuf.get_golden().is_none() { | |
1338 | return Err(DecoderError::MissingReference); | |
1339 | } | |
6543b6f8 KS |
1340 | self.vp31_unpack_sb_info(br)?; |
1341 | self.vp31_unpack_mb_info(br)?; | |
1342 | self.vp31_unpack_mv_info(br)?; | |
5b24175d | 1343 | } |
6543b6f8 KS |
1344 | let dc_quant = VP31_DC_SCALES[self.quant]; |
1345 | let ac_quant = VP31_AC_SCALES[self.quant]; | |
6fbd24ec KS |
1346 | rescale_qmat(&mut self.qmat_y, VP3_QMAT_Y, dc_quant, ac_quant, 2); |
1347 | rescale_qmat(&mut self.qmat_c, VP3_QMAT_C, dc_quant, ac_quant, 2); | |
8e4b2f44 KS |
1348 | rescale_qmat(&mut self.qmat_y_p, VP3_QMAT_INTER, dc_quant, ac_quant, 4); |
1349 | rescale_qmat(&mut self.qmat_c_p, VP3_QMAT_INTER, dc_quant, ac_quant, 4); | |
5b24175d KS |
1350 | |
1351 | self.eob_run = 0; | |
1352 | let dc_table_y = br.read(4)? as usize; | |
1353 | let dc_table_c = br.read(4)? as usize; | |
6543b6f8 | 1354 | self.vp31_unpack_coeffs(br, 0, dc_table_y, dc_table_c)?; |
5b24175d KS |
1355 | self.restore_dcs(); |
1356 | ||
1357 | let ac_table_y = br.read(4)? as usize; | |
1358 | let ac_table_c = br.read(4)? as usize; | |
1359 | for coef_no in 1..64 { | |
6543b6f8 | 1360 | self.vp31_unpack_coeffs(br, coef_no, ac_table_y, ac_table_c)?; |
5b24175d KS |
1361 | } |
1362 | ||
1363 | if self.is_intra { | |
1364 | self.output_blocks_intra(frm); | |
1365 | } else { | |
1366 | self.output_blocks_inter(frm); | |
1367 | } | |
1368 | if self.loop_str > 0 { | |
6543b6f8 | 1369 | self.vp31_loop_filter(frm); |
5b24175d KS |
1370 | } |
1371 | ||
1372 | Ok(()) | |
1373 | } | |
8e4b2f44 KS |
1374 | fn decode_vp4(&mut self, br: &mut BitReader, frm: &mut NASimpleVideoFrame<u8>) -> DecoderResult<()> { |
1375 | for blk in self.blocks.iter_mut() { | |
1376 | blk.coeffs = [0; 64]; | |
1377 | blk.idx = 0; | |
1378 | blk.coded = false; | |
1379 | blk.has_ac = false; | |
1380 | } | |
1381 | if self.is_intra { | |
1382 | for sb in self.sb_info.iter_mut() { *sb = SBState::Coded; } | |
1383 | for blk in self.blocks.iter_mut() { | |
1384 | blk.btype = VPMBType::Intra; | |
1385 | blk.coded = true; | |
1386 | } | |
1387 | } else { | |
1388 | if self.shuf.get_last().is_none() || self.shuf.get_golden().is_none() { | |
1389 | return Err(DecoderError::MissingReference); | |
1390 | } | |
1391 | self.vp40_unpack_sb_info(br)?; | |
1392 | self.vp31_unpack_mb_info(br)?; | |
1393 | self.vp40_unpack_mv_info(br)?; | |
1394 | } | |
1395 | let dc_y_quant = VP40_DC_Y_SCALES[self.quant]; | |
1396 | let dc_c_quant = VP40_DC_C_SCALES[self.quant]; | |
1397 | let ac_quant = VP40_AC_SCALES[self.quant]; | |
1398 | rescale_qmat(&mut self.qmat_y, VP40_QMAT, dc_y_quant, ac_quant, 2); | |
1399 | rescale_qmat(&mut self.qmat_c, VP40_QMAT, dc_c_quant, ac_quant, 2); | |
1400 | self.qmat_y_p.copy_from_slice(&self.qmat_y); | |
1401 | self.qmat_c_p.copy_from_slice(&self.qmat_c); | |
1402 | ||
1403 | self.eob_run = 0; | |
1404 | let dc_table_y = br.read(4)? as usize; | |
1405 | let dc_table_c = br.read(4)? as usize; | |
1406 | let ac_table_y = br.read(4)? as usize; | |
1407 | let ac_table_c = br.read(4)? as usize; | |
1408 | self.vp40_unpack_coeffs(br, dc_table_y, dc_table_c, ac_table_y, ac_table_c)?; | |
1409 | ||
1410 | if self.is_intra { | |
1411 | self.output_blocks_intra(frm); | |
1412 | } else { | |
1413 | self.output_blocks_inter(frm); | |
1414 | } | |
1415 | ||
1416 | Ok(()) | |
5b24175d | 1417 | } |
8e4b2f44 | 1418 | fn vp31_predict_dc(&self, bx: usize, by: usize, bw: usize, blk_idx: usize) -> i16 { |
5b24175d KS |
1419 | let mut preds = [0i32; 4]; |
1420 | let mut pp: usize = 0; | |
1421 | let ref_id = self.blocks[blk_idx].btype.get_ref_id(); | |
1422 | let is_right = bx == bw - 1; | |
1423 | if bx > 0 { | |
1424 | fill_dc_pred!(self, ref_id, preds, pp, 0, blk_idx - 1); | |
1425 | if by > 0 { | |
1426 | fill_dc_pred!(self, ref_id, preds, pp, 1, blk_idx - 1 - bw); | |
1427 | } | |
1428 | } | |
1429 | if by > 0 { | |
1430 | fill_dc_pred!(self, ref_id, preds, pp, 2, blk_idx - bw); | |
1431 | if !is_right { | |
1432 | fill_dc_pred!(self, ref_id, preds, pp, 3, blk_idx + 1 - bw); | |
1433 | } | |
1434 | } | |
1435 | if pp == 0 { return self.last_dc[ref_id as usize]; } | |
1436 | let mut pred = 0i32; | |
1437 | for i in 0..4 { | |
1438 | if (pp & (1 << i)) != 0 { | |
6543b6f8 | 1439 | pred += (preds[i] as i32) * (VP31_DC_WEIGHTS[pp][i] as i32); |
5b24175d KS |
1440 | } |
1441 | } | |
6543b6f8 | 1442 | pred /= VP31_DC_WEIGHTS[pp][4] as i32; |
5b24175d KS |
1443 | if (pp & 7) == 7 { |
1444 | if (pred - preds[2]).abs() > 128 { return preds[2] as i16; } | |
1445 | if (pred - preds[0]).abs() > 128 { return preds[0] as i16; } | |
1446 | if (pred - preds[1]).abs() > 128 { return preds[1] as i16; } | |
1447 | } | |
1448 | pred as i16 | |
1449 | } | |
8e4b2f44 KS |
1450 | fn vp40_predict_dc(&self, bx: usize, by: usize, bw: usize, bh: usize, blk_idx: usize, mask: usize, is_luma: bool) -> i16 { |
1451 | let mut preds = [0i32; 4]; | |
1452 | let mut pp: usize = 0; | |
1453 | let ref_id = self.blocks[blk_idx].btype.get_ref_id(); | |
1454 | if (by > 0) && (((mask >> 3) & 1) == 1) { //top | |
1455 | fill_dc_pred!(self, ref_id, preds, pp, 0, blk_idx - bw); | |
1456 | } | |
1457 | if (by < bh - 1) && (((mask >> 2) & 1) == 1) { //bottom | |
1458 | fill_dc_pred!(self, ref_id, preds, pp, 1, blk_idx + bw); | |
1459 | } | |
1460 | if (bx > 0) && (((mask >> 1) & 1) == 1) { //left | |
1461 | fill_dc_pred!(self, ref_id, preds, pp, 2, blk_idx - 1); | |
1462 | } | |
1463 | if (is_luma && bx == 0 && (by >= 4)) && (((mask >> 1) & 1) == 1) { //left wrap | |
1464 | fill_dc_pred!(self, ref_id, preds, pp, 2, blk_idx - 1 - 3 * bw); | |
1465 | } | |
1466 | if (bx < bw - 1) && (((mask >> 0) & 1) == 1) { //right | |
1467 | fill_dc_pred!(self, ref_id, preds, pp, 3, blk_idx + 1); | |
1468 | } | |
1469 | if pp == 0 { return self.last_dc[ref_id as usize]; } | |
1470 | let mut pred = 0i32; | |
1471 | let mut npred = 0; | |
1472 | for i in 0..4 { | |
1473 | if (pp & (1 << i)) != 0 { | |
1474 | pred += preds[i] as i32; | |
1475 | npred += 1; | |
1476 | if npred == 2 { | |
1477 | return (pred / 2) as i16; | |
1478 | } | |
1479 | } | |
1480 | } | |
1481 | self.last_dc[ref_id as usize] | |
1482 | } | |
5b24175d KS |
1483 | fn restore_dcs(&mut self) { |
1484 | let blk_stride = self.mb_w * 2; | |
1485 | let mut blk_idx = 0; | |
1486 | self.last_dc = [0; 3]; | |
1487 | for by in 0..self.mb_h*2 { | |
1488 | for bx in 0..self.mb_w*2 { | |
1489 | if !self.blocks[blk_idx + bx].coded { continue; } | |
8e4b2f44 | 1490 | let dc = self.vp31_predict_dc(bx, by, self.mb_w*2, blk_idx + bx); |
5b24175d KS |
1491 | self.blocks[blk_idx + bx].coeffs[0] += dc; |
1492 | self.last_dc[self.blocks[blk_idx + bx].btype.get_ref_id() as usize] = self.blocks[blk_idx + bx].coeffs[0]; | |
1493 | } | |
1494 | blk_idx += blk_stride; | |
1495 | } | |
1496 | let blk_stride = self.mb_w; | |
1497 | for _plane in 1..3 { | |
1498 | self.last_dc = [0; 3]; | |
1499 | for by in 0..self.mb_h { | |
1500 | for bx in 0..self.mb_w { | |
1501 | if !self.blocks[blk_idx + bx].coded { continue; } | |
8e4b2f44 | 1502 | let dc = self.vp31_predict_dc(bx, by, self.mb_w, blk_idx + bx); |
5b24175d KS |
1503 | self.blocks[blk_idx + bx].coeffs[0] += dc; |
1504 | self.last_dc[self.blocks[blk_idx + bx].btype.get_ref_id() as usize] = self.blocks[blk_idx + bx].coeffs[0]; | |
1505 | } | |
1506 | blk_idx += blk_stride; | |
1507 | } | |
1508 | } | |
1509 | } | |
1510 | fn output_blocks_intra(&mut self, frm: &mut NASimpleVideoFrame<u8>) { | |
1511 | let mut biter = self.blocks.iter_mut(); | |
1512 | for by in 0..self.mb_h*2 { | |
1513 | for bx in 0..self.mb_w*2 { | |
1514 | let mut blk = biter.next().unwrap(); | |
8e4b2f44 | 1515 | let qmat = &self.qmat_y; |
5b24175d KS |
1516 | blk.coeffs[0] *= qmat[0]; |
1517 | if blk.has_ac { | |
1518 | unquant(&mut blk.coeffs, qmat); | |
1519 | vp_put_block(&mut blk.coeffs, bx, by, 0, frm); | |
1520 | } else { | |
1521 | vp_put_block_dc(&mut blk.coeffs, bx, by, 0, frm); | |
1522 | } | |
1523 | } | |
1524 | } | |
1525 | for plane in 1..3 { | |
1526 | for by in 0..self.mb_h { | |
1527 | for bx in 0..self.mb_w { | |
1528 | let mut blk = biter.next().unwrap(); | |
8e4b2f44 | 1529 | let qmat = &self.qmat_c; |
5b24175d KS |
1530 | blk.coeffs[0] *= qmat[0]; |
1531 | if blk.has_ac { | |
1532 | unquant(&mut blk.coeffs, qmat); | |
1533 | vp_put_block(&mut blk.coeffs, bx, by, plane, frm); | |
1534 | } else { | |
1535 | vp_put_block_dc(&mut blk.coeffs, bx, by, plane, frm); | |
1536 | } | |
1537 | } | |
1538 | } | |
1539 | } | |
1540 | } | |
1541 | fn output_blocks_inter(&mut self, frm: &mut NASimpleVideoFrame<u8>) { | |
1542 | let mut blk_idx = 0; | |
1543 | let bstride = self.mb_w * 2; | |
1544 | for by in (0..self.mb_h*2).step_by(2) { | |
1545 | for bx in (0..self.mb_w*2).step_by(2) { | |
1546 | if self.blocks[blk_idx + bx].btype != VPMBType::InterFourMV { | |
1547 | continue; | |
1548 | } | |
72c6f263 KS |
1549 | let mvs = [ self.blocks[blk_idx + bx].mv, |
1550 | self.blocks[blk_idx + bx + 1].mv, | |
1551 | self.blocks[blk_idx + bx + bstride].mv, | |
1552 | self.blocks[blk_idx + bx + 1 + bstride].mv ]; | |
1553 | let mut mv_sum = mvs[0] + mvs[1] + mvs[2] + mvs[3]; | |
5b24175d KS |
1554 | mv_sum.x = (mv_sum.x + 2) >> 2; |
1555 | mv_sum.y = (mv_sum.y + 2) >> 2; | |
1556 | ||
1557 | let src = self.shuf.get_last().unwrap(); | |
72c6f263 KS |
1558 | for i in 0..4 { |
1559 | let xoff = (i & 1) * 8; | |
1560 | let yoff = (i >> 1) * 8; | |
0949792e | 1561 | |
3cc76ad5 | 1562 | let mode = vp3_mv_mode(mvs[i].x, mvs[i].y); |
72c6f263 KS |
1563 | if self.version != 4 { |
1564 | copy_block(frm, src.clone(), 0, bx * 8 + xoff, by * 8 + yoff, | |
1565 | mvs[i].x >> 1, mvs[i].y >> 1, 8, 8, 0, 1, mode, VP3_INTERP_FUNCS); | |
1566 | } else { | |
1567 | vp_copy_block(frm, src.clone(), 0, bx * 8 + xoff, by * 8 + yoff, | |
1568 | mvs[i].x >> 1, mvs[i].y >> 1, 0, 1, self.loop_str, | |
1569 | mode, VP3_INTERP_FUNCS, self.mc_buf.clone()); | |
1570 | } | |
8e4b2f44 | 1571 | } |
5b24175d KS |
1572 | |
1573 | let mx = (mv_sum.x >> 1) | (mv_sum.x & 1); | |
1574 | let my = (mv_sum.y >> 1) | (mv_sum.y & 1); | |
3cc76ad5 | 1575 | let mode = vp3_mv_mode(mx, my); |
5b24175d KS |
1576 | copy_block(frm, src.clone(), 1, bx * 4, by * 4, mx >> 1, my >> 1, 8, 8, 0, 1, mode, VP3_INTERP_FUNCS); |
1577 | copy_block(frm, src.clone(), 2, bx * 4, by * 4, mx >> 1, my >> 1, 8, 8, 0, 1, mode, VP3_INTERP_FUNCS); | |
1578 | } | |
96f8649d | 1579 | blk_idx += bstride * 2; |
5b24175d KS |
1580 | } |
1581 | ||
1582 | let mut biter = self.blocks.iter_mut(); | |
1583 | for by in 0..self.mb_h*2 { | |
1584 | for bx in 0..self.mb_w*2 { | |
1585 | let mut blk = biter.next().unwrap(); | |
1586 | // do MC for whole macroblock | |
1587 | if !blk.btype.is_intra() && (((bx | by) & 1) == 0) && (blk.btype != VPMBType::InterFourMV) { | |
1588 | let src = if blk.btype.get_ref_id() == 1 { | |
1589 | self.shuf.get_last().unwrap() | |
1590 | } else { | |
1591 | self.shuf.get_golden().unwrap() | |
1592 | }; | |
3cc76ad5 | 1593 | let mode = vp3_mv_mode(blk.mv.x, blk.mv.y); |
8e4b2f44 KS |
1594 | if self.version != 4 { |
1595 | copy_block(frm, src.clone(), 0, bx * 8, by * 8, | |
1596 | blk.mv.x >> 1, blk.mv.y >> 1, 16, 16, 0, 1, mode, VP3_INTERP_FUNCS); | |
1597 | } else { | |
1598 | vp_copy_block(frm, src.clone(), 0, bx * 8, by * 8, | |
1599 | blk.mv.x >> 1, blk.mv.y >> 1, 0, 1, self.loop_str, | |
1600 | mode, VP3_INTERP_FUNCS, self.mc_buf.clone()); | |
1601 | vp_copy_block(frm, src.clone(), 0, bx * 8 + 8, by * 8, | |
1602 | blk.mv.x >> 1, blk.mv.y >> 1, 0, 1, self.loop_str, | |
1603 | mode, VP3_INTERP_FUNCS, self.mc_buf.clone()); | |
1604 | vp_copy_block(frm, src.clone(), 0, bx * 8, by * 8 + 8, | |
1605 | blk.mv.x >> 1, blk.mv.y >> 1, 0, 1, self.loop_str, | |
1606 | mode, VP3_INTERP_FUNCS, self.mc_buf.clone()); | |
1607 | vp_copy_block(frm, src.clone(), 0, bx * 8 + 8, by * 8 + 8, | |
1608 | blk.mv.x >> 1, blk.mv.y >> 1, 0, 1, self.loop_str, | |
1609 | mode, VP3_INTERP_FUNCS, self.mc_buf.clone()); | |
1610 | } | |
5b24175d KS |
1611 | let mx = (blk.mv.x >> 1) | (blk.mv.x & 1); |
1612 | let my = (blk.mv.y >> 1) | (blk.mv.y & 1); | |
3cc76ad5 | 1613 | let mode = vp3_mv_mode(mx, my); |
8e4b2f44 KS |
1614 | if self.version != 4 { |
1615 | copy_block(frm, src.clone(), 1, bx * 4, by * 4, | |
1616 | mx >> 1, my >> 1, 8, 8, 0, 1, mode, VP3_INTERP_FUNCS); | |
1617 | copy_block(frm, src.clone(), 2, bx * 4, by * 4, | |
1618 | mx >> 1, my >> 1, 8, 8, 0, 1, mode, VP3_INTERP_FUNCS); | |
1619 | } else { | |
1620 | vp_copy_block(frm, src.clone(), 1, bx * 4, by * 4, | |
1621 | mx >> 1, my >> 1, 0, 1, self.loop_str, | |
1622 | mode, VP3_INTERP_FUNCS, self.mc_buf.clone()); | |
1623 | vp_copy_block(frm, src.clone(), 2, bx * 4, by * 4, | |
1624 | mx >> 1, my >> 1, 0, 1, self.loop_str, | |
1625 | mode, VP3_INTERP_FUNCS, self.mc_buf.clone()); | |
1626 | } | |
5b24175d | 1627 | } |
8e4b2f44 | 1628 | let qmat = if blk.btype.is_intra() { &self.qmat_y } else { &self.qmat_y_p }; |
5b24175d KS |
1629 | blk.coeffs[0] *= qmat[0]; |
1630 | if blk.has_ac { | |
1631 | unquant(&mut blk.coeffs, qmat); | |
1632 | } | |
0949792e KS |
1633 | if !blk.coded { |
1634 | copy_block(frm, self.shuf.get_last().unwrap(), 0, bx * 8, by * 8, 0, 0, 8, 8, 0, 1, 0, VP3_INTERP_FUNCS); | |
1635 | } else if blk.btype.is_intra() { | |
1636 | if blk.has_ac { | |
5b24175d KS |
1637 | vp_put_block(&mut blk.coeffs, bx, by, 0, frm); |
1638 | } else { | |
1639 | vp_put_block_dc(&mut blk.coeffs, bx, by, 0, frm); | |
1640 | } | |
0949792e | 1641 | } else { |
5b24175d KS |
1642 | if blk.has_ac { |
1643 | vp_add_block(&mut blk.coeffs, bx, by, 0, frm); | |
1644 | } else { | |
1645 | vp_add_block_dc(&mut blk.coeffs, bx, by, 0, frm); | |
1646 | } | |
1647 | } | |
1648 | } | |
1649 | } | |
1650 | for plane in 1..3 { | |
1651 | for by in 0..self.mb_h { | |
1652 | for bx in 0..self.mb_w { | |
1653 | let mut blk = biter.next().unwrap(); | |
8e4b2f44 | 1654 | let qmat = if blk.btype.is_intra() { &self.qmat_c } else { &self.qmat_c_p }; |
5b24175d KS |
1655 | blk.coeffs[0] *= qmat[0]; |
1656 | if blk.has_ac { | |
1657 | unquant(&mut blk.coeffs, qmat); | |
1658 | } | |
0949792e KS |
1659 | if !blk.coded { |
1660 | copy_block(frm, self.shuf.get_last().unwrap(), plane, bx * 8, by * 8, 0, 0, 8, 8, 0, 1, 0, VP3_INTERP_FUNCS); | |
1661 | } else if blk.btype.is_intra() { | |
1662 | if blk.has_ac { | |
5b24175d KS |
1663 | vp_put_block(&mut blk.coeffs, bx, by, plane, frm); |
1664 | } else { | |
1665 | vp_put_block_dc(&mut blk.coeffs, bx, by, plane, frm); | |
1666 | } | |
0949792e | 1667 | } else { |
5b24175d KS |
1668 | if blk.has_ac { |
1669 | vp_add_block(&mut blk.coeffs, bx, by, plane, frm); | |
1670 | } else { | |
1671 | vp_add_block_dc(&mut blk.coeffs, bx, by, plane, frm); | |
1672 | } | |
1673 | } | |
1674 | } | |
1675 | } | |
1676 | } | |
1677 | } | |
6543b6f8 | 1678 | fn vp31_loop_filter(&mut self, frm: &mut NASimpleVideoFrame<u8>) { |
5b24175d KS |
1679 | let mut blk_idx = 0; |
1680 | let blk_w = self.mb_w * 2; | |
1681 | for by in 0..self.mb_h*2 { | |
1682 | for bx in 0..blk_w { | |
1683 | let blk = &self.blocks[blk_idx + bx]; | |
1684 | if (bx > 0) && blk.coded { | |
6543b6f8 | 1685 | vp31_loop_filter_v(frm, bx * 8, by * 8, 0, self.loop_str); |
5b24175d KS |
1686 | } |
1687 | if (by > 0) && blk.coded { | |
6543b6f8 | 1688 | vp31_loop_filter_h(frm, bx * 8, by * 8, 0, self.loop_str); |
5b24175d KS |
1689 | } |
1690 | if (bx < blk_w - 1) && !self.blocks[blk_idx + bx + 1].coded { | |
6543b6f8 | 1691 | vp31_loop_filter_v(frm, bx * 8 + 8, by * 8, 0, self.loop_str); |
5b24175d KS |
1692 | } |
1693 | if (by < self.mb_h * 2 - 1) && !self.blocks[blk_idx + bx + blk_w].coded { | |
6543b6f8 | 1694 | vp31_loop_filter_h(frm, bx * 8, by * 8 + 8, 0, self.loop_str); |
5b24175d KS |
1695 | } |
1696 | } | |
1697 | blk_idx += blk_w; | |
1698 | } | |
ed416511 KS |
1699 | let blk_w = self.mb_w; |
1700 | for plane in 1..3 { | |
5b24175d KS |
1701 | for by in 0..self.mb_h { |
1702 | for bx in 0..self.mb_w { | |
ed416511 KS |
1703 | let blk = &self.blocks[blk_idx + bx]; |
1704 | if (bx > 0) && blk.coded { | |
1705 | vp31_loop_filter_v(frm, bx * 8, by * 8, plane, self.loop_str); | |
1706 | } | |
1707 | if (by > 0) && blk.coded { | |
1708 | vp31_loop_filter_h(frm, bx * 8, by * 8, plane, self.loop_str); | |
1709 | } | |
1710 | if (bx < blk_w - 1) && !self.blocks[blk_idx + bx + 1].coded { | |
1711 | vp31_loop_filter_v(frm, bx * 8 + 8, by * 8, plane, self.loop_str); | |
1712 | } | |
1713 | if (by < self.mb_h - 1) && !self.blocks[blk_idx + bx + blk_w].coded { | |
1714 | vp31_loop_filter_h(frm, bx * 8, by * 8 + 8, plane, self.loop_str); | |
1715 | } | |
5b24175d | 1716 | } |
ed416511 | 1717 | blk_idx += blk_w; |
5b24175d | 1718 | } |
ed416511 | 1719 | } |
5b24175d KS |
1720 | } |
1721 | fn generate_block_addr(&mut self) { | |
1722 | let sb_w_y = (self.width + 31) >> 5; | |
1723 | let sb_h_y = (self.height + 31) >> 5; | |
1724 | let sb_w_c = ((self.width >> 1) + 31) >> 5; | |
1725 | let sb_h_c = ((self.height >> 1) + 31) >> 5; | |
1726 | self.y_sbs = sb_w_y * sb_h_y; | |
1727 | let tot_sb = sb_w_y * sb_h_y + 2 * sb_w_c * sb_h_c; | |
3567fcdb | 1728 | let tot_mb = self.mb_w * self.mb_h * 2 + ((self.mb_w + 1) & !1) * ((self.mb_h + 1) & !1) * 2; |
5b24175d KS |
1729 | let bw = self.width >> 3; |
1730 | let bh = self.height >> 3; | |
1731 | let tot_blk = bw * bh * 3 / 2; | |
1732 | self.sb_info.resize(tot_sb, SBState::Uncoded); | |
1733 | self.sb_blocks = Vec::with_capacity(tot_sb); | |
3567fcdb KS |
1734 | self.mb_blocks = Vec::with_capacity(tot_mb); |
1735 | self.sb_mbs = Vec::with_capacity(tot_sb); | |
5b24175d | 1736 | self.blk_addr = Vec::with_capacity(tot_blk); |
8e4b2f44 | 1737 | self.blk_sub = Vec::with_capacity(tot_blk); |
5b24175d KS |
1738 | self.y_blocks = bw * bh; |
1739 | let mut base_idx = 0; | |
1740 | for plane in 0..3 { | |
1741 | let w = if plane > 0 { self.width >> 1 } else { self.width }; | |
1742 | let h = if plane > 0 { self.height >> 1 } else { self.height }; | |
1743 | let sb_w = (w + 31) >> 5; | |
1744 | let sb_h = (h + 31) >> 5; | |
1745 | let blk_w = w >> 3; | |
1746 | let blk_h = h >> 3; | |
1747 | for y in 0..sb_h { | |
1748 | for x in 0..sb_w { | |
3567fcdb KS |
1749 | let mut nmbs = 0; |
1750 | for mb_no in 0..4 { | |
1751 | let bx = x * 4 + HILBERT_ORDER[mb_no * 4][0]; | |
1752 | let by = y * 4 + HILBERT_ORDER[mb_no * 4][1]; | |
1753 | if (bx >= blk_w) || (by >= blk_h) { continue; } | |
1754 | let mut nblocks = 0; | |
1755 | for blk_no in 0..4 { | |
1756 | let bx = x * 4 + HILBERT_ORDER[mb_no * 4 + blk_no][0]; | |
1757 | let by = y * 4 + HILBERT_ORDER[mb_no * 4 + blk_no][1]; | |
1758 | if (bx >= blk_w) || (by >= blk_h) { continue; } | |
1759 | nblocks += 1; | |
1760 | } | |
1761 | self.mb_blocks.push(nblocks); | |
1762 | nmbs += 1; | |
1763 | } | |
1764 | self.sb_mbs.push(nmbs); | |
1765 | ||
5b24175d KS |
1766 | let mut nblocks = 0; |
1767 | for blk_no in 0..16 { | |
1768 | let bx = x * 4 + HILBERT_ORDER[blk_no][0]; | |
1769 | let by = y * 4 + HILBERT_ORDER[blk_no][1]; | |
1770 | if (bx >= blk_w) || (by >= blk_h) { continue; } | |
1771 | let idx = base_idx + bx + by * blk_w; | |
1772 | self.blk_addr.push(idx * 4 + plane); | |
8e4b2f44 | 1773 | self.blk_sub.push(blk_no as u8); |
5b24175d KS |
1774 | nblocks += 1; |
1775 | } | |
1776 | self.sb_blocks.push(nblocks); | |
1777 | } | |
1778 | } | |
1779 | base_idx += blk_w * blk_h; | |
1780 | } | |
1781 | self.blocks.resize(tot_blk, Block::new()); | |
3567fcdb | 1782 | self.mb_coded.resize(tot_mb, false); |
8e4b2f44 | 1783 | self.mb_partial.resize(tot_mb, false); |
5b24175d KS |
1784 | } |
1785 | } | |
1786 | ||
1787 | impl NADecoder for VP34Decoder { | |
1788 | fn init(&mut self, supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> { | |
1789 | if let NACodecTypeInfo::Video(vinfo) = info.get_properties() { | |
1790 | let fmt = YUV420_FORMAT; | |
1791 | self.width = vinfo.get_width(); | |
1792 | self.height = vinfo.get_height(); | |
1793 | validate!(((self.width | self.height) & 15) == 0); | |
1794 | self.mb_w = self.width >> 4; | |
1795 | self.mb_h = self.height >> 4; | |
1796 | let myinfo = NACodecTypeInfo::Video(NAVideoInfo::new(vinfo.get_width(), vinfo.get_height(), true, fmt)); | |
1797 | self.info = NACodecInfo::new_ref(info.get_name(), myinfo, info.get_extradata()).into_ref(); | |
1798 | supp.pool_u8.set_dec_bufs(3); | |
b8fb8e36 | 1799 | supp.pool_u8.prealloc_video(NAVideoInfo::new(vinfo.get_width(), vinfo.get_height(), true, fmt), 4)?; |
5b24175d | 1800 | |
8e4b2f44 KS |
1801 | self.generate_block_addr(); |
1802 | if self.version == 4 { | |
1803 | self.codes = Codes::VP31(VP31Codes::new_vp4()); | |
1804 | self.aux_codes = Some(VP40AuxCodes::new()); | |
5b24175d KS |
1805 | } |
1806 | Ok(()) | |
1807 | } else { | |
1808 | Err(DecoderError::InvalidData) | |
1809 | } | |
1810 | } | |
1811 | fn decode(&mut self, supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> { | |
1812 | let src = pkt.get_buffer(); | |
1813 | validate!(src.len() > 0); | |
1814 | let mut br = BitReader::new(&src, src.len(), BitReaderMode::BE); | |
1815 | ||
1816 | self.parse_header(&mut br)?; | |
1817 | if self.is_intra { | |
1818 | self.shuf.clear(); | |
6e24ec0b KS |
1819 | } else { |
1820 | if !self.shuf.has_refs() { | |
1821 | return Err(DecoderError::MissingReference); | |
1822 | } | |
5b24175d KS |
1823 | } |
1824 | ||
1825 | let ret = supp.pool_u8.get_free(); | |
1826 | if ret.is_none() { | |
1827 | return Err(DecoderError::AllocError); | |
1828 | } | |
1829 | let mut buf = ret.unwrap(); | |
1830 | let mut dframe = NASimpleVideoFrame::from_video_buf(&mut buf).unwrap(); | |
347108c9 | 1831 | match self.version { |
3567fcdb | 1832 | 30 => self.decode_vp30(&mut br, &mut dframe)?, |
347108c9 | 1833 | 31 => self.decode_vp31(&mut br, &mut dframe)?, |
8e4b2f44 | 1834 | 4 => self.decode_vp4(&mut br, &mut dframe)?, |
347108c9 | 1835 | _ => return Err(DecoderError::Bug), |
5b24175d KS |
1836 | } |
1837 | ||
1838 | if self.is_intra { | |
1839 | self.shuf.add_golden_frame(buf.clone()); | |
1840 | } | |
1841 | self.shuf.add_frame(buf.clone()); | |
1842 | ||
1843 | let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), NABufferType::Video(buf)); | |
1844 | frm.set_keyframe(self.is_intra); | |
1845 | frm.set_frame_type(if self.is_intra { FrameType::I } else { FrameType::P }); | |
1846 | Ok(frm.into_ref()) | |
1847 | } | |
f9be4e75 KS |
1848 | fn flush(&mut self) { |
1849 | self.shuf.clear(); | |
1850 | } | |
5b24175d KS |
1851 | } |
1852 | ||
08a1fab7 | 1853 | pub fn get_decoder_vp3() -> Box<NADecoder + Send> { |
5b24175d KS |
1854 | Box::new(VP34Decoder::new(3)) |
1855 | } | |
1856 | ||
08a1fab7 | 1857 | pub fn get_decoder_vp4() -> Box<NADecoder + Send> { |
5b24175d | 1858 | Box::new(VP34Decoder::new(4)) |
8e4b2f44 | 1859 | } |
5b24175d KS |
1860 | |
1861 | #[cfg(test)] | |
1862 | mod test { | |
1863 | use nihav_core::codecs::RegisteredDecoders; | |
1864 | use nihav_core::demuxers::RegisteredDemuxers; | |
1865 | use nihav_core::test::dec_video::*; | |
1866 | use crate::codecs::duck_register_all_codecs; | |
1867 | use nihav_commonfmt::demuxers::generic_register_all_demuxers; | |
1868 | ||
1869 | #[test] | |
3567fcdb KS |
1870 | fn test_vp30() { |
1871 | let mut dmx_reg = RegisteredDemuxers::new(); | |
1872 | generic_register_all_demuxers(&mut dmx_reg); | |
1873 | let mut dec_reg = RegisteredDecoders::new(); | |
1874 | duck_register_all_codecs(&mut dec_reg); | |
1875 | ||
1876 | let file = "assets/Duck/vp30-logo.avi"; | |
8e4b2f44 | 1877 | test_file_decoding("avi", file, Some(23), true, false, None/*Some("vp30")*/, &dmx_reg, &dec_reg); |
3567fcdb KS |
1878 | } |
1879 | ||
1880 | #[test] | |
1881 | fn test_vp31() { | |
5b24175d KS |
1882 | let mut dmx_reg = RegisteredDemuxers::new(); |
1883 | generic_register_all_demuxers(&mut dmx_reg); | |
1884 | let mut dec_reg = RegisteredDecoders::new(); | |
1885 | duck_register_all_codecs(&mut dec_reg); | |
1886 | ||
0eb72055 | 1887 | // let file = "assets/Duck/vp31.avi"; |
5b24175d KS |
1888 | // let file = "assets/Duck/vp31_crash.avi"; |
1889 | // let file = "assets/Duck/01-vp31-0500.avi"; | |
0eb72055 | 1890 | // test_file_decoding("avi", file, Some(3), true, false, None/*Some("vp31")*/, &dmx_reg, &dec_reg); |
5b24175d | 1891 | //panic!("end"); |
0eb72055 KS |
1892 | test_decoding("avi", "vp3", "assets/Duck/01-vp31-0500.avi", Some(16), &dmx_reg, &dec_reg, |
1893 | ExpectedTestResult::MD5([0x65112f7e, 0x2914f29b, 0x2908ed2f, 0xce5fc8c5])); | |
5b24175d KS |
1894 | } |
1895 | ||
1896 | #[test] | |
1897 | fn test_vp4() { | |
1898 | let mut dmx_reg = RegisteredDemuxers::new(); | |
1899 | generic_register_all_demuxers(&mut dmx_reg); | |
1900 | let mut dec_reg = RegisteredDecoders::new(); | |
1901 | duck_register_all_codecs(&mut dec_reg); | |
1902 | ||
1903 | let file = "assets/Duck/ot171_vp40.avi"; | |
8e4b2f44 KS |
1904 | test_file_decoding("avi", file, Some(16), true, false, None/*Some("vp4")*/, &dmx_reg, &dec_reg); |
1905 | //panic!("end"); | |
5b24175d KS |
1906 | } |
1907 | } | |
1908 | ||
1909 | const HILBERT_ORDER: [[usize; 2]; 16] = [ | |
1910 | [ 0, 0 ], [ 1, 0 ], [ 1, 1 ], [ 0, 1 ], | |
1911 | [ 0, 2 ], [ 0, 3 ], [ 1, 3 ], [ 1, 2 ], | |
1912 | [ 2, 2 ], [ 2, 3 ], [ 3, 3 ], [ 3, 2 ], | |
1913 | [ 3, 1 ], [ 2, 1 ], [ 2, 0 ], [ 3, 0 ] | |
1914 | ]; | |
1915 | ||
6543b6f8 | 1916 | const VP31_LOOP_STRENGTH: [i16; 64] = [ |
5b24175d KS |
1917 | 30, 25, 20, 20, 15, 15, 14, 14, |
1918 | 13, 13, 12, 12, 11, 11, 10, 10, | |
1919 | 9, 9, 8, 8, 7, 7, 7, 7, | |
1920 | 6, 6, 6, 6, 5, 5, 5, 5, | |
1921 | 4, 4, 4, 4, 3, 3, 3, 3, | |
1922 | 2, 2, 2, 2, 2, 2, 2, 2, | |
1923 | 0, 0, 0, 0, 0, 0, 0, 0, | |
1924 | 0, 0, 0, 0, 0, 0, 0, 0 | |
1925 | ]; | |
1926 | ||
6543b6f8 | 1927 | const VP31_DEFAULT_MB_MODES: [VPMBType; 8] = [ |
5b24175d KS |
1928 | VPMBType::InterNoMV, VPMBType::Intra, VPMBType::InterMV, VPMBType::InterNearest, |
1929 | VPMBType::InterNear, VPMBType::GoldenNoMV, VPMBType::GoldenMV, VPMBType::InterFourMV | |
1930 | ]; | |
1931 | ||
6543b6f8 | 1932 | const VP31_MB_MODES: [[VPMBType; 8]; 6] = [ |
5b24175d KS |
1933 | [ |
1934 | VPMBType::InterNearest, VPMBType::InterNear, VPMBType::InterMV, VPMBType::InterNoMV, | |
1935 | VPMBType::Intra, VPMBType::GoldenNoMV, VPMBType::GoldenMV, VPMBType::InterFourMV | |
1936 | ], [ | |
1937 | VPMBType::InterNearest, VPMBType::InterNear, VPMBType::InterNoMV, VPMBType::InterMV, | |
1938 | VPMBType::Intra, VPMBType::GoldenNoMV, VPMBType::GoldenMV, VPMBType::InterFourMV | |
1939 | ], [ | |
1940 | VPMBType::InterNearest, VPMBType::InterMV, VPMBType::InterNear, VPMBType::InterNoMV, | |
1941 | VPMBType::Intra, VPMBType::GoldenNoMV, VPMBType::GoldenMV, VPMBType::InterFourMV | |
1942 | ], [ | |
1943 | VPMBType::InterNearest, VPMBType::InterMV, VPMBType::InterNoMV, VPMBType::InterNear, | |
1944 | VPMBType::Intra, VPMBType::GoldenNoMV, VPMBType::GoldenMV, VPMBType::InterFourMV | |
1945 | ], [ | |
1946 | VPMBType::InterNoMV, VPMBType::InterNearest, VPMBType::InterNear, VPMBType::InterMV, | |
1947 | VPMBType::Intra, VPMBType::GoldenNoMV, VPMBType::GoldenMV, VPMBType::InterFourMV | |
1948 | ], [ | |
1949 | VPMBType::InterNoMV, VPMBType::GoldenNoMV, VPMBType::InterNearest, VPMBType::InterNear, | |
1950 | VPMBType::InterMV, VPMBType::Intra, VPMBType::GoldenMV, VPMBType::InterFourMV | |
1951 | ] | |
1952 | ]; | |
1953 | ||
1954 | const VP3_LITERAL_BASE: [i16; 6] = [ 7, 9, 13, 21, 37, 69 ]; | |
1955 | ||
6543b6f8 | 1956 | const VP31_AC_SCALES: [i16; 64] = [ |
5b24175d KS |
1957 | 500, 450, 400, 370, 340, 310, 285, 265, |
1958 | 245, 225, 210, 195, 185, 180, 170, 160, | |
1959 | 150, 145, 135, 130, 125, 115, 110, 107, | |
1960 | 100, 96, 93, 89, 85, 82, 75, 74, | |
1961 | 70, 68, 64, 60, 57, 56, 52, 50, | |
1962 | 49, 45, 44, 43, 40, 38, 37, 35, | |
1963 | 33, 32, 30, 29, 28, 25, 24, 22, | |
1964 | 21, 19, 18, 17, 15, 13, 12, 10 | |
1965 | ]; | |
1966 | ||
6543b6f8 | 1967 | const VP31_DC_SCALES: [i16; 64] = [ |
5b24175d KS |
1968 | 220, 200, 190, 180, 170, 170, 160, 160, |
1969 | 150, 150, 140, 140, 130, 130, 120, 120, | |
1970 | 110, 110, 100, 100, 90, 90, 90, 80, | |
1971 | 80, 80, 70, 70, 70, 60, 60, 60, | |
1972 | 60, 50, 50, 50, 50, 40, 40, 40, | |
1973 | 40, 40, 30, 30, 30, 30, 30, 30, | |
1974 | 30, 20, 20, 20, 20, 20, 20, 20, | |
1975 | 20, 10, 10, 10, 10, 10, 10, 10 | |
1976 | ]; | |
1977 | ||
1978 | const VP3_QMAT_Y: &[i16; 64] = &[ | |
1979 | 16, 11, 10, 16, 24, 40, 51, 61, | |
1980 | 12, 12, 14, 19, 26, 58, 60, 55, | |
1981 | 14, 13, 16, 24, 40, 57, 69, 56, | |
1982 | 14, 17, 22, 29, 51, 87, 80, 62, | |
1983 | 18, 22, 37, 58, 68, 109, 103, 77, | |
1984 | 24, 35, 55, 64, 81, 104, 113, 92, | |
1985 | 49, 64, 78, 87, 103, 121, 120, 101, | |
1986 | 72, 92, 95, 98, 112, 100, 103, 99 | |
1987 | ]; | |
1988 | ||
1989 | const VP3_QMAT_C: &[i16; 64] = &[ | |
1990 | 17, 18, 24, 47, 99, 99, 99, 99, | |
1991 | 18, 21, 26, 66, 99, 99, 99, 99, | |
1992 | 24, 26, 56, 99, 99, 99, 99, 99, | |
1993 | 47, 66, 99, 99, 99, 99, 99, 99, | |
1994 | 99, 99, 99, 99, 99, 99, 99, 99, | |
1995 | 99, 99, 99, 99, 99, 99, 99, 99, | |
1996 | 99, 99, 99, 99, 99, 99, 99, 99, | |
1997 | 99, 99, 99, 99, 99, 99, 99, 99 | |
1998 | ]; | |
1999 | ||
2000 | const VP3_QMAT_INTER: &[i16; 64] = &[ | |
2001 | 16, 16, 16, 20, 24, 28, 32, 40, | |
2002 | 16, 16, 20, 24, 28, 32, 40, 48, | |
2003 | 16, 20, 24, 28, 32, 40, 48, 64, | |
2004 | 20, 24, 28, 32, 40, 48, 64, 64, | |
2005 | 24, 28, 32, 40, 48, 64, 64, 64, | |
2006 | 28, 32, 40, 48, 64, 64, 64, 96, | |
2007 | 32, 40, 48, 64, 64, 64, 96, 128, | |
2008 | 40, 48, 64, 64, 64, 96, 128, 128 | |
2009 | ]; | |
2010 | ||
6543b6f8 | 2011 | const VP31_DC_CODES: [[u16; 32]; 16] = [ |
5b24175d KS |
2012 | [ |
2013 | 0x002D, 0x0026, 0x0166, 0x004E, 0x02CE, 0x059E, 0x027D, 0x0008, | |
2014 | 0x04F9, 0x000F, 0x000E, 0x001B, 0x0006, 0x0008, 0x0005, 0x001A, | |
2015 | 0x0015, 0x0007, 0x000C, 0x0001, 0x0000, 0x0009, 0x0017, 0x0029, | |
2016 | 0x0028, 0x00B2, 0x04F8, 0x059F, 0x009E, 0x013F, 0x0012, 0x0058, | |
2017 | ], [ | |
2018 | 0x0010, 0x0047, 0x01FF, 0x008C, 0x03FC, 0x046A, 0x0469, 0x0022, | |
2019 | 0x11A1, 0x000E, 0x000D, 0x0004, 0x0005, 0x0009, 0x0006, 0x001E, | |
2020 | 0x0016, 0x0007, 0x000C, 0x0001, 0x0000, 0x000A, 0x0017, 0x007D, | |
2021 | 0x007E, 0x011B, 0x08D1, 0x03FD, 0x046B, 0x11A0, 0x007C, 0x00FE, | |
2022 | ], [ | |
2023 | 0x0016, 0x0020, 0x0086, 0x0087, 0x0367, 0x06CC, 0x06CB, 0x006E, | |
2024 | 0x366D, 0x000F, 0x000E, 0x0004, 0x0005, 0x000A, 0x0006, 0x001A, | |
2025 | 0x0011, 0x0007, 0x000C, 0x0001, 0x0000, 0x0009, 0x0017, 0x006F, | |
2026 | 0x006D, 0x0364, 0x0D9A, 0x06CA, 0x1B37, 0x366C, 0x0042, 0x00D8, | |
2027 | ], [ | |
2028 | 0x0000, 0x002D, 0x00F7, 0x0058, 0x0167, 0x02CB, 0x02CA, 0x000E, | |
2029 | 0x1661, 0x0003, 0x0002, 0x0008, 0x0009, 0x000D, 0x0002, 0x001F, | |
2030 | 0x0017, 0x0001, 0x000C, 0x000E, 0x000A, 0x0006, 0x0078, 0x000F, | |
2031 | 0x007A, 0x0164, 0x0599, 0x02CD, 0x0B31, 0x1660, 0x0079, 0x00F6, | |
2032 | ], [ | |
2033 | 0x0003, 0x003C, 0x000F, 0x007A, 0x001D, 0x0020, 0x0072, 0x0006, | |
2034 | 0x0399, 0x0004, 0x0005, 0x0005, 0x0006, 0x000E, 0x0004, 0x0000, | |
2035 | 0x0019, 0x0002, 0x000D, 0x0007, 0x001F, 0x0030, 0x0011, 0x0031, | |
2036 | 0x0005, 0x0021, 0x00E7, 0x0038, 0x01CD, 0x0398, 0x007B, 0x0009, | |
2037 | ], [ | |
2038 | 0x0009, 0x0002, 0x0074, 0x0007, 0x00EC, 0x00D1, 0x01A6, 0x0006, | |
2039 | 0x0D21, 0x0005, 0x0006, 0x0008, 0x0007, 0x000F, 0x0004, 0x0000, | |
2040 | 0x001C, 0x0002, 0x0005, 0x0003, 0x000C, 0x0035, 0x01A7, 0x001B, | |
2041 | 0x0077, 0x01A5, 0x0349, 0x00D0, 0x0691, 0x0D20, 0x0075, 0x00ED, | |
2042 | ], [ | |
2043 | 0x000A, 0x000C, 0x0012, 0x001B, 0x00B7, 0x016C, 0x0099, 0x005A, | |
2044 | 0x16D8, 0x0007, 0x0006, 0x0009, 0x0008, 0x0000, 0x0005, 0x0017, | |
2045 | 0x000E, 0x0002, 0x0003, 0x000F, 0x001A, 0x004D, 0x2DB3, 0x002C, | |
2046 | 0x0011, 0x02DA, 0x05B7, 0x0098, 0x0B6D, 0x2DB2, 0x0010, 0x0027, | |
2047 | ], [ | |
2048 | 0x000D, 0x000F, 0x001D, 0x0008, 0x0051, 0x0056, 0x00AF, 0x002A, | |
2049 | 0x148A, 0x0007, 0x0000, 0x0008, 0x0009, 0x000C, 0x0006, 0x0017, | |
2050 | 0x000B, 0x0016, 0x0015, 0x0009, 0x0050, 0x00AE, 0x2917, 0x001C, | |
2051 | 0x0014, 0x0290, 0x0523, 0x0149, 0x0A44, 0x2916, 0x0053, 0x00A5, | |
2052 | ], [ | |
2053 | 0x0001, 0x001D, 0x00F5, 0x00F4, 0x024D, 0x0499, 0x0498, 0x0001, | |
2054 | 0x0021, 0x0006, 0x0005, 0x0006, 0x0005, 0x0002, 0x0007, 0x0025, | |
2055 | 0x007B, 0x001C, 0x0020, 0x000D, 0x0048, 0x0092, 0x0127, 0x000E, | |
2056 | 0x0004, 0x0011, 0x000C, 0x003C, 0x000F, 0x0000, 0x001F, 0x0013, | |
2057 | ], [ | |
2058 | 0x0005, 0x003C, 0x0040, 0x000D, 0x0031, 0x0061, 0x0060, 0x0002, | |
2059 | 0x00F5, 0x0006, 0x0005, 0x0007, 0x0006, 0x0002, 0x0009, 0x0025, | |
2060 | 0x0007, 0x0021, 0x0024, 0x0010, 0x0041, 0x00F4, 0x0019, 0x000E, | |
2061 | 0x0003, 0x0011, 0x0011, 0x003F, 0x003E, 0x007B, 0x0000, 0x0013, | |
2062 | ], [ | |
2063 | 0x000A, 0x0007, 0x0001, 0x0009, 0x0131, 0x0261, 0x0260, 0x0015, | |
2064 | 0x0001, 0x0007, 0x0006, 0x0008, 0x0007, 0x0006, 0x0012, 0x002F, | |
2065 | 0x0014, 0x0027, 0x002D, 0x0016, 0x004D, 0x0099, 0x0000, 0x0004, | |
2066 | 0x0001, 0x0005, 0x0017, 0x002E, 0x002C, 0x0008, 0x0006, 0x0001, | |
2067 | ], [ | |
2068 | 0x0000, 0x000E, 0x0017, 0x002A, 0x0010, 0x00F9, 0x00F8, 0x001E, | |
2069 | 0x003F, 0x0007, 0x0006, 0x0009, 0x0008, 0x0006, 0x000F, 0x0005, | |
2070 | 0x0016, 0x0029, 0x002B, 0x0015, 0x0050, 0x0011, 0x007D, 0x0004, | |
2071 | 0x0017, 0x0006, 0x0014, 0x002C, 0x002D, 0x000E, 0x0009, 0x0051, | |
2072 | ], [ | |
2073 | 0x0002, 0x0018, 0x002F, 0x000D, 0x0053, 0x0295, 0x0294, 0x00A4, | |
2074 | 0x007C, 0x0000, 0x0007, 0x0009, 0x0008, 0x001B, 0x000C, 0x0028, | |
2075 | 0x006A, 0x001E, 0x001D, 0x0069, 0x00D7, 0x007D, 0x014B, 0x0019, | |
2076 | 0x0016, 0x002E, 0x001C, 0x002B, 0x002A, 0x0068, 0x003F, 0x00D6, | |
2077 | ], [ | |
2078 | 0x0002, 0x001B, 0x000C, 0x0018, 0x0029, 0x007F, 0x02F0, 0x0198, | |
2079 | 0x0179, 0x0000, 0x0007, 0x0009, 0x0008, 0x001A, 0x000D, 0x002A, | |
2080 | 0x0064, 0x001E, 0x0067, 0x005F, 0x00CD, 0x007E, 0x02F1, 0x0016, | |
2081 | 0x000E, 0x002E, 0x0065, 0x002B, 0x0028, 0x003E, 0x00BD, 0x0199, | |
2082 | ], [ | |
2083 | 0x0002, 0x0007, 0x0016, 0x0006, 0x0036, 0x005C, 0x015D, 0x015C, | |
2084 | 0x02BF, 0x0000, 0x0007, 0x0009, 0x0008, 0x0018, 0x0034, 0x002A, | |
2085 | 0x005E, 0x006A, 0x0064, 0x005D, 0x00CB, 0x00AD, 0x02BE, 0x0014, | |
2086 | 0x0033, 0x006E, 0x005F, 0x006F, 0x006B, 0x00CA, 0x00AC, 0x015E, | |
2087 | ], [ | |
2088 | 0x000F, 0x001D, 0x0018, 0x000B, 0x0019, 0x0029, 0x00D6, 0x0551, | |
2089 | 0x0AA1, 0x0001, 0x0000, 0x0009, 0x0008, 0x001B, 0x0038, 0x0028, | |
2090 | 0x0057, 0x006A, 0x0068, 0x0056, 0x00E5, 0x0155, 0x0AA0, 0x0073, | |
2091 | 0x0069, 0x00D7, 0x00AB, 0x00E4, 0x00A9, 0x0151, 0x0150, 0x02A9, | |
2092 | ] | |
2093 | ]; | |
2094 | ||
6543b6f8 | 2095 | const VP31_DC_BITS: [[u8; 32]; 16] = [ |
5b24175d KS |
2096 | [ |
2097 | 6, 7, 9, 8, 10, 11, 11, 5, 12, 4, 4, 5, 4, 4, 4, 5, | |
2098 | 5, 4, 4, 3, 3, 4, 5, 6, 6, 8, 12, 11, 9, 10, 6, 7, | |
2099 | ], [ | |
2100 | 5, 7, 9, 8, 10, 11, 11, 6, 13, 4, 4, 4, 4, 4, 4, 5, | |
2101 | 5, 4, 4, 3, 3, 4, 5, 7, 7, 9, 12, 10, 11, 13, 7, 8, | |
2102 | ], [ | |
2103 | 5, 6, 8, 8, 10, 11, 11, 7, 14, 4, 4, 4, 4, 4, 4, 5, | |
2104 | 5, 4, 4, 3, 3, 4, 5, 7, 7, 10, 12, 11, 13, 14, 7, 8, | |
2105 | ], [ | |
2106 | 4, 6, 8, 7, 9, 10, 10, 6, 13, 3, 3, 4, 4, 4, 4, 5, | |
2107 | 5, 4, 4, 4, 4, 5, 7, 6, 7, 9, 11, 10, 12, 13, 7, 8, | |
2108 | ], [ | |
2109 | 4, 6, 7, 7, 8, 9, 10, 6, 13, 3, 3, 4, 4, 4, 4, 4, | |
2110 | 5, 4, 4, 4, 5, 6, 8, 6, 6, 9, 11, 9, 12, 13, 7, 7, | |
2111 | ], [ | |
2112 | 4, 5, 7, 6, 8, 9, 10, 6, 13, 3, 3, 4, 4, 4, 4, 4, | |
2113 | 5, 4, 4, 4, 5, 7, 10, 6, 7, 10, 11, 9, 12, 13, 7, 8, | |
2114 | ], [ | |
2115 | 4, 5, 6, 6, 8, 9, 9, 7, 13, 3, 3, 4, 4, 3, 4, 5, | |
2116 | 5, 4, 4, 5, 6, 8, 14, 6, 6, 10, 11, 9, 12, 14, 6, 7, | |
2117 | ], [ | |
2118 | 4, 5, 6, 5, 7, 8, 9, 7, 13, 3, 2, 4, 4, 4, 4, 5, | |
2119 | 5, 5, 5, 5, 7, 9, 14, 6, 6, 10, 11, 9, 12, 14, 7, 8, | |
2120 | ], [ | |
2121 | 4, 6, 8, 8, 10, 11, 11, 5, 6, 3, 3, 4, 4, 4, 5, 6, | |
2122 | 7, 6, 6, 6, 7, 8, 9, 4, 4, 5, 6, 6, 5, 5, 5, 5, | |
2123 | ], [ | |
2124 | 4, 6, 7, 7, 9, 10, 10, 5, 8, 3, 3, 4, 4, 4, 5, 6, | |
2125 | 6, 6, 6, 6, 7, 8, 8, 4, 4, 5, 6, 6, 6, 7, 4, 5, | |
2126 | ], [ | |
2127 | 4, 5, 6, 6, 9, 10, 10, 6, 7, 3, 3, 4, 4, 4, 5, 6, | |
2128 | 6, 6, 6, 6, 7, 8, 7, 4, 4, 5, 6, 6, 6, 6, 5, 5, | |
2129 | ], [ | |
2130 | 3, 5, 6, 6, 7, 10, 10, 7, 8, 3, 3, 4, 4, 4, 5, 5, | |
2131 | 6, 6, 6, 6, 7, 7, 9, 4, 5, 5, 6, 6, 6, 6, 6, 7, | |
2132 | ], [ | |
2133 | 3, 5, 6, 5, 7, 10, 10, 8, 8, 2, 3, 4, 4, 5, 5, 6, | |
2134 | 7, 6, 6, 7, 8, 8, 9, 5, 5, 6, 6, 6, 6, 7, 7, 8, | |
2135 | ], [ | |
2136 | 3, 5, 5, 5, 6, 8, 10, 9, 9, 2, 3, 4, 4, 5, 5, 6, | |
2137 | 7, 6, 7, 7, 8, 8, 10, 5, 5, 6, 7, 6, 6, 7, 8, 9, | |
2138 | ], [ | |
2139 | 3, 4, 5, 4, 6, 7, 9, 9, 10, 2, 3, 4, 4, 5, 6, 6, | |
2140 | 7, 7, 7, 7, 8, 8, 10, 5, 6, 7, 7, 7, 7, 8, 8, 9, | |
2141 | ], [ | |
2142 | 4, 5, 5, 4, 5, 6, 8, 11, 12, 2, 2, 4, 4, 5, 6, 6, | |
2143 | 7, 7, 7, 7, 8, 9, 12, 7, 7, 8, 8, 8, 8, 9, 9, 10, | |
2144 | ] | |
2145 | ]; | |
2146 | ||
6543b6f8 | 2147 | const VP31_AC_CAT0_CODES: [[u16; 32]; 16] = [ |
5b24175d KS |
2148 | [ |
2149 | 0x0008, 0x0025, 0x017A, 0x02F7, 0x0BDB, 0x17B4, 0x2F6B, 0x001D, | |
2150 | 0x2F6A, 0x0008, 0x0007, 0x0001, 0x0002, 0x000A, 0x0006, 0x0000, | |
2151 | 0x001C, 0x0009, 0x000D, 0x000F, 0x000C, 0x0003, 0x000A, 0x0016, | |
2152 | 0x0013, 0x005D, 0x0024, 0x00BC, 0x005C, 0x05EC, 0x000B, 0x005F, | |
2153 | ], [ | |
2154 | 0x000F, 0x0010, 0x004B, 0x00C6, 0x031D, 0x0C71, 0x0C70, 0x0001, | |
2155 | 0x0C73, 0x0008, 0x0009, 0x0002, 0x0003, 0x000B, 0x0006, 0x0000, | |
2156 | 0x001C, 0x0005, 0x000D, 0x000F, 0x000A, 0x0019, 0x0013, 0x001D, | |
2157 | 0x0030, 0x0062, 0x0024, 0x004A, 0x018F, 0x0C72, 0x000E, 0x0011, | |
2158 | ], [ | |
2159 | 0x001B, 0x0003, 0x008D, 0x0040, 0x0239, 0x0471, 0x08E0, 0x0003, | |
2160 | 0x11C3, 0x000A, 0x0009, 0x0004, 0x0005, 0x000E, 0x0007, 0x0001, | |
2161 | 0x001E, 0x0006, 0x000C, 0x000B, 0x0002, 0x0000, 0x0041, 0x001F, | |
2162 | 0x0022, 0x0002, 0x008F, 0x008C, 0x011D, 0x11C2, 0x001A, 0x0021, | |
2163 | ], [ | |
2164 | 0x001F, 0x0003, 0x0003, 0x0043, 0x000B, 0x0015, 0x0051, 0x0003, | |
2165 | 0x0050, 0x000D, 0x000C, 0x0004, 0x0006, 0x000E, 0x000A, 0x0001, | |
2166 | 0x001E, 0x0005, 0x0009, 0x0007, 0x0011, 0x0002, 0x0004, 0x0002, | |
2167 | 0x002D, 0x0020, 0x0042, 0x0001, 0x0000, 0x0029, 0x0017, 0x002C, | |
2168 | ], [ | |
2169 | 0x0003, 0x001F, 0x003A, 0x005D, 0x0173, 0x02E4, 0x172D, 0x0004, | |
2170 | 0x172C, 0x000F, 0x000E, 0x0009, 0x0008, 0x000C, 0x000A, 0x0001, | |
2171 | 0x0016, 0x0002, 0x0005, 0x001A, 0x002F, 0x0038, 0x05CA, 0x0006, | |
2172 | 0x0037, 0x001E, 0x003B, 0x0039, 0x00B8, 0x0B97, 0x0000, 0x0036, | |
2173 | ], [ | |
2174 | 0x0006, 0x0037, 0x005D, 0x000C, 0x00B9, 0x02E3, 0x05C4, 0x0004, | |
2175 | 0x1715, 0x0000, 0x000F, 0x0008, 0x0007, 0x000C, 0x0009, 0x001D, | |
2176 | 0x0016, 0x001C, 0x001A, 0x000B, 0x005E, 0x0170, 0x1714, 0x000A, | |
2177 | 0x000A, 0x0036, 0x005F, 0x001B, 0x001A, 0x0B8B, 0x0002, 0x0007, | |
2178 | ], [ | |
2179 | 0x000C, 0x000B, 0x0079, 0x0022, 0x00F0, 0x0119, 0x0230, 0x001D, | |
2180 | 0x08C4, 0x0001, 0x0000, 0x000A, 0x0009, 0x000B, 0x0007, 0x001C, | |
2181 | 0x003D, 0x000D, 0x0008, 0x0015, 0x008D, 0x118B, 0x118A, 0x000D, | |
2182 | 0x0010, 0x0009, 0x0014, 0x0047, 0x00F1, 0x0463, 0x001F, 0x000C, | |
2183 | ], [ | |
2184 | 0x0000, 0x001A, 0x0033, 0x000C, 0x0046, 0x01E3, 0x03C5, 0x0017, | |
2185 | 0x1E21, 0x0002, 0x0001, 0x0009, 0x000A, 0x0007, 0x001B, 0x003D, | |
2186 | 0x001B, 0x0022, 0x0079, 0x00F0, 0x1E20, 0x1E23, 0x1E22, 0x000E, | |
2187 | 0x0016, 0x0018, 0x0032, 0x001A, 0x0047, 0x0789, 0x001F, 0x0010, | |
2188 | ], [ | |
2189 | 0x001D, 0x0061, 0x004E, 0x009E, 0x027C, 0x09F5, 0x09F4, 0x0003, | |
2190 | 0x0060, 0x0000, 0x000F, 0x000B, 0x000A, 0x0009, 0x0005, 0x000D, | |
2191 | 0x0031, 0x0008, 0x0038, 0x0012, 0x0026, 0x013F, 0x04FB, 0x000D, | |
2192 | 0x0002, 0x000C, 0x0039, 0x001C, 0x000F, 0x001D, 0x0008, 0x0019, | |
2193 | ], [ | |
2194 | 0x0007, 0x0019, 0x00AB, 0x00AA, 0x0119, 0x0461, 0x0460, 0x001B, | |
2195 | 0x0047, 0x0001, 0x0000, 0x000C, 0x000B, 0x0009, 0x0005, 0x000D, | |
2196 | 0x0035, 0x003D, 0x003C, 0x0018, 0x0022, 0x008D, 0x0231, 0x000E, | |
2197 | 0x001F, 0x0009, 0x002B, 0x0010, 0x0034, 0x0054, 0x0008, 0x0014, | |
2198 | ], [ | |
2199 | 0x000C, 0x0005, 0x0008, 0x005B, 0x004D, 0x0131, 0x0261, 0x001A, | |
2200 | 0x0012, 0x0000, 0x000F, 0x000A, 0x0009, 0x0006, 0x001B, 0x0006, | |
2201 | 0x001C, 0x002C, 0x0015, 0x005A, 0x0027, 0x0099, 0x0260, 0x000E, | |
2202 | 0x0004, 0x000F, 0x0007, 0x001D, 0x000B, 0x0014, 0x0008, 0x0017, | |
2203 | ], [ | |
2204 | 0x000F, 0x0013, 0x0075, 0x0024, 0x0095, 0x0251, 0x04A0, 0x0010, | |
2205 | 0x00C8, 0x0002, 0x0001, 0x0001, 0x0000, 0x001A, 0x0011, 0x002C, | |
2206 | 0x0065, 0x0074, 0x004B, 0x00C9, 0x0129, 0x0943, 0x0942, 0x0003, | |
2207 | 0x000A, 0x001C, 0x0018, 0x0033, 0x0017, 0x002D, 0x001B, 0x003B, | |
2208 | ], [ | |
2209 | 0x0003, 0x001A, 0x002D, 0x0038, 0x0028, 0x0395, 0x0E51, 0x0037, | |
2210 | 0x00E4, 0x0001, 0x0000, 0x001F, 0x001E, 0x0017, 0x003A, 0x0073, | |
2211 | 0x002A, 0x002B, 0x0029, 0x01CB, 0x0729, 0x1CA1, 0x1CA0, 0x0004, | |
2212 | 0x000A, 0x0004, 0x0018, 0x0036, 0x000B, 0x002C, 0x0019, 0x003B, | |
2213 | ], [ | |
2214 | 0x0004, 0x0004, 0x003F, 0x0017, 0x0075, 0x01F5, 0x07D1, 0x0017, | |
2215 | 0x01F6, 0x0001, 0x0000, 0x001B, 0x001A, 0x000A, 0x0032, 0x0074, | |
2216 | 0x00F8, 0x00F9, 0x01F7, 0x03E9, 0x0FA0, 0x1F43, 0x1F42, 0x0003, | |
2217 | 0x000A, 0x001E, 0x001C, 0x003B, 0x0018, 0x0016, 0x0016, 0x0033, | |
2218 | ], [ | |
2219 | 0x0004, 0x0007, 0x0018, 0x001E, 0x0036, 0x0031, 0x0177, 0x0077, | |
2220 | 0x0176, 0x0001, 0x0000, 0x001A, 0x0019, 0x003A, 0x0019, 0x005C, | |
2221 | 0x00BA, 0x0061, 0x00C1, 0x0180, 0x0302, 0x0607, 0x0606, 0x0002, | |
2222 | 0x000A, 0x001F, 0x001C, 0x0037, 0x0016, 0x0076, 0x000D, 0x002F, | |
2223 | ], [ | |
2224 | 0x0000, 0x000A, 0x001A, 0x000C, 0x001D, 0x0039, 0x0078, 0x005E, | |
2225 | 0x0393, 0x0002, 0x0001, 0x0016, 0x000F, 0x002E, 0x005F, 0x0073, | |
2226 | 0x00E5, 0x01C8, 0x0E4A, 0x1C97, 0x1C96, 0x0E49, 0x0E48, 0x0004, | |
2227 | 0x0006, 0x001F, 0x001B, 0x001D, 0x0038, 0x0038, 0x003D, 0x0079, | |
2228 | ] | |
2229 | ]; | |
2230 | ||
6543b6f8 | 2231 | const VP31_AC_CAT0_BITS: [[u8; 32]; 16] = [ |
5b24175d KS |
2232 | [ |
2233 | 5, 7, 9, 10, 12, 13, 14, 5, 14, 4, 4, 4, 4, 4, 4, 4, | |
2234 | 5, 4, 4, 4, 4, 4, 5, 5, 6, 7, 7, 8, 7, 11, 5, 7, | |
2235 | ], [ | |
2236 | 5, 6, 8, 8, 10, 12, 12, 4, 12, 4, 4, 4, 4, 4, 4, 4, | |
2237 | 5, 4, 4, 4, 4, 5, 6, 5, 6, 7, 7, 8, 9, 12, 5, 6, | |
2238 | ], [ | |
2239 | 5, 6, 8, 7, 10, 11, 12, 4, 13, 4, 4, 4, 4, 4, 4, 4, | |
2240 | 5, 4, 4, 4, 4, 5, 7, 5, 6, 6, 8, 8, 9, 13, 5, 6, | |
2241 | ], [ | |
2242 | 5, 6, 7, 7, 9, 10, 12, 4, 12, 4, 4, 4, 4, 4, 4, 4, | |
2243 | 5, 4, 4, 4, 5, 6, 8, 4, 6, 6, 7, 7, 7, 11, 5, 6, | |
2244 | ], [ | |
2245 | 4, 6, 7, 7, 9, 10, 13, 4, 13, 4, 4, 4, 4, 4, 4, 4, | |
2246 | 5, 4, 4, 5, 6, 7, 11, 4, 6, 6, 7, 7, 8, 12, 4, 6, | |
2247 | ], [ | |
2248 | 4, 6, 7, 6, 8, 10, 11, 4, 13, 3, 4, 4, 4, 4, 4, 5, | |
2249 | 5, 5, 5, 5, 7, 9, 13, 4, 5, 6, 7, 7, 7, 12, 4, 5, | |
2250 | ], [ | |
2251 | 4, 5, 7, 6, 8, 9, 10, 5, 12, 3, 3, 4, 4, 4, 4, 5, | |
2252 | 6, 5, 5, 6, 8, 13, 13, 4, 5, 5, 6, 7, 8, 11, 5, 5, | |
2253 | ], [ | |
2254 | 3, 5, 6, 5, 7, 9, 10, 5, 13, 3, 3, 4, 4, 4, 5, 6, | |
2255 | 6, 6, 7, 8, 13, 13, 13, 4, 5, 5, 6, 6, 7, 11, 5, 5, | |
2256 | ], [ | |
2257 | 5, 7, 8, 9, 11, 13, 13, 4, 7, 3, 4, 4, 4, 4, 4, 5, | |
2258 | 6, 5, 6, 6, 7, 10, 12, 4, 4, 5, 6, 6, 5, 6, 4, 5, | |
2259 | ], [ | |
2260 | 4, 6, 8, 8, 10, 12, 12, 5, 8, 3, 3, 4, 4, 4, 4, 5, | |
2261 | 6, 6, 6, 6, 7, 9, 11, 4, 5, 5, 6, 6, 6, 7, 4, 5, | |
2262 | ], [ | |
2263 | 4, 5, 6, 7, 9, 11, 12, 5, 7, 3, 4, 4, 4, 4, 5, 5, | |
2264 | 6, 6, 6, 7, 8, 10, 12, 4, 4, 5, 5, 6, 5, 6, 4, 5, | |
2265 | ], [ | |
2266 | 4, 5, 7, 6, 8, 10, 11, 5, 8, 3, 3, 4, 4, 5, 5, 6, | |
2267 | 7, 7, 7, 8, 9, 12, 12, 3, 4, 5, 5, 6, 5, 6, 5, 6, | |
2268 | ], [ | |
2269 | 3, 5, 6, 6, 7, 10, 12, 6, 8, 3, 3, 5, 5, 5, 6, 7, | |
2270 | 7, 7, 7, 9, 11, 13, 13, 3, 4, 4, 5, 6, 5, 6, 5, 6, | |
2271 | ], [ | |
2272 | 3, 4, 6, 5, 7, 9, 11, 6, 9, 3, 3, 5, 5, 5, 6, 7, | |
2273 | 8, 8, 9, 10, 12, 13, 13, 3, 4, 5, 5, 6, 5, 6, 5, 6, | |
2274 | ], [ | |
2275 | 3, 4, 5, 5, 6, 7, 9, 7, 9, 3, 3, 5, 5, 6, 6, 7, | |
2276 | 8, 8, 9, 10, 11, 12, 12, 3, 4, 5, 5, 6, 5, 7, 5, 6, | |
2277 | ], [ | |
2278 | 3, 4, 5, 4, 5, 6, 7, 7, 11, 3, 3, 5, 5, 6, 7, 8, | |
2279 | 9, 10, 13, 14, 14, 13, 13, 3, 4, 5, 5, 6, 6, 7, 6, 7, | |
2280 | ] | |
2281 | ]; | |
2282 | ||
6543b6f8 | 2283 | const VP31_AC_CAT1_CODES: [[u16; 32]; 16] = [ |
5b24175d KS |
2284 | [ |
2285 | 0x000B, 0x002B, 0x0054, 0x01B7, 0x06D9, 0x0DB1, 0x0DB0, 0x0002, | |
2286 | 0x00AB, 0x0009, 0x000A, 0x0007, 0x0008, 0x000F, 0x000C, 0x0003, | |
2287 | 0x001D, 0x0004, 0x000B, 0x0006, 0x001A, 0x0003, 0x00AA, 0x0001, | |
2288 | 0x0000, 0x0014, 0x006C, 0x00DA, 0x0002, 0x036D, 0x001C, 0x0037, | |
2289 | ], [ | |
2290 | 0x001D, 0x0004, 0x00B6, 0x006A, 0x05B9, 0x16E1, 0x16E0, 0x0007, | |
2291 | 0x016F, 0x000C, 0x000D, 0x0009, 0x0008, 0x000F, 0x000A, 0x0003, | |
2292 | 0x0017, 0x0002, 0x0004, 0x001C, 0x002C, 0x006B, 0x0B71, 0x0005, | |
2293 | 0x0003, 0x001B, 0x005A, 0x0034, 0x0005, 0x02DD, 0x0000, 0x000C, | |
2294 | ], [ | |
2295 | 0x0003, 0x007F, 0x00A1, 0x00A0, 0x020C, 0x0834, 0x106B, 0x0007, | |
2296 | 0x0082, 0x000E, 0x000D, 0x000B, 0x000C, 0x0000, 0x0009, 0x0002, | |
2297 | 0x0011, 0x001E, 0x0015, 0x003E, 0x0040, 0x041B, 0x106A, 0x0006, | |
2298 | 0x000A, 0x0029, 0x007E, 0x0051, 0x0021, 0x0107, 0x0004, 0x000B, | |
2299 | ], [ | |
2300 | 0x0007, 0x001B, 0x00F6, 0x00E9, 0x03A1, 0x0740, 0x0E82, 0x001F, | |
2301 | 0x01EF, 0x0001, 0x0002, 0x000B, 0x000C, 0x000D, 0x0008, 0x001C, | |
2302 | 0x0003, 0x0012, 0x0002, 0x0075, 0x01D1, 0x1D07, 0x1D06, 0x000A, | |
2303 | 0x0013, 0x003B, 0x001A, 0x007A, 0x003C, 0x01EE, 0x0000, 0x000C, | |
2304 | ], [ | |
2305 | 0x000D, 0x003D, 0x0042, 0x0037, 0x00D9, 0x0362, 0x06C6, 0x001F, | |
2306 | 0x0086, 0x0001, 0x0002, 0x000C, 0x000B, 0x000A, 0x0001, 0x000F, | |
2307 | 0x0025, 0x003C, 0x001A, 0x0087, 0x01B0, 0x0D8F, 0x0D8E, 0x000E, | |
2308 | 0x0013, 0x000C, 0x0024, 0x0020, 0x0011, 0x006D, 0x0000, 0x000E, | |
2309 | ], [ | |
2310 | 0x0000, 0x0012, 0x0076, 0x0077, 0x014D, 0x0533, 0x14C9, 0x0013, | |
2311 | 0x00A5, 0x0002, 0x0003, 0x000B, 0x000C, 0x0008, 0x001A, 0x002B, | |
2312 | 0x0075, 0x0074, 0x00A7, 0x0298, 0x14C8, 0x14CB, 0x14CA, 0x000F, | |
2313 | 0x001C, 0x0007, 0x002A, 0x0028, 0x001B, 0x00A4, 0x0002, 0x0006, | |
2314 | ], [ | |
2315 | 0x0002, 0x001A, 0x002B, 0x003A, 0x00ED, 0x0283, 0x0A0A, 0x0004, | |
2316 | 0x00A1, 0x0004, 0x0003, 0x000B, 0x000C, 0x001F, 0x0006, 0x0077, | |
2317 | 0x00A3, 0x00A2, 0x0140, 0x1417, 0x1416, 0x0A09, 0x0A08, 0x0000, | |
2318 | 0x001E, 0x0007, 0x002A, 0x0029, 0x001C, 0x00EC, 0x001B, 0x0005, | |
2319 | ], [ | |
2320 | 0x0002, 0x0002, 0x0018, 0x001D, 0x0035, 0x00E4, 0x01CF, 0x001D, | |
2321 | 0x0072, 0x0004, 0x0005, 0x0006, 0x0007, 0x0006, 0x0073, 0x0038, | |
2322 | 0x01CE, 0x039B, 0x0398, 0x0733, 0x0732, 0x0735, 0x0734, 0x0000, | |
2323 | 0x001F, 0x001B, 0x0034, 0x000F, 0x001E, 0x00E5, 0x0019, 0x0038, | |
2324 | ], [ | |
2325 | 0x0016, 0x0050, 0x0172, 0x02E7, 0x1732, 0x2E67, 0x2E66, 0x0006, | |
2326 | 0x0051, 0x0001, 0x0000, 0x000D, 0x000C, 0x0009, 0x001C, 0x0009, | |
2327 | 0x001C, 0x001D, 0x005D, 0x00B8, 0x05CD, 0x1731, 0x1730, 0x000F, | |
2328 | 0x0005, 0x000F, 0x0008, 0x0029, 0x001D, 0x002F, 0x0008, 0x0015, | |
2329 | ], [ | |
2330 | 0x0009, 0x0021, 0x0040, 0x00AD, 0x02B0, 0x1589, 0x1588, 0x001C, | |
2331 | 0x005F, 0x0000, 0x000F, 0x000D, 0x000C, 0x0006, 0x0011, 0x002A, | |
2332 | 0x0057, 0x005E, 0x0041, 0x0159, 0x0563, 0x158B, 0x158A, 0x0001, | |
2333 | 0x0005, 0x0014, 0x003B, 0x002E, 0x0004, 0x003A, 0x0007, 0x0016, | |
2334 | ], [ | |
2335 | 0x000E, 0x0007, 0x0046, 0x0045, 0x0064, 0x032A, 0x0657, 0x0018, | |
2336 | 0x000D, 0x0000, 0x000F, 0x000A, 0x000B, 0x001A, 0x0036, 0x0047, | |
2337 | 0x0044, 0x0018, 0x0033, 0x00CB, 0x0656, 0x0329, 0x0328, 0x0002, | |
2338 | 0x0006, 0x0019, 0x000E, 0x0037, 0x0009, 0x000F, 0x0002, 0x0010, | |
2339 | ], [ | |
2340 | 0x0003, 0x0018, 0x0023, 0x0077, 0x0194, 0x1956, 0x32AF, 0x003A, | |
2341 | 0x0076, 0x0002, 0x0001, 0x001F, 0x001E, 0x0014, 0x0022, 0x0064, | |
2342 | 0x0197, 0x0196, 0x032B, 0x0654, 0x32AE, 0x1955, 0x1954, 0x0000, | |
2343 | 0x0009, 0x001C, 0x0015, 0x0010, 0x000D, 0x0017, 0x0016, 0x0033, | |
2344 | ], [ | |
2345 | 0x0005, 0x0006, 0x003E, 0x0010, 0x0048, 0x093F, 0x24FA, 0x0032, | |
2346 | 0x0067, 0x0002, 0x0001, 0x001B, 0x001E, 0x0034, 0x0066, 0x0092, | |
2347 | 0x0126, 0x024E, 0x049E, 0x49F7, 0x49F6, 0x24F9, 0x24F8, 0x0000, | |
2348 | 0x0007, 0x0018, 0x0011, 0x003F, 0x000E, 0x0013, 0x0035, 0x0025, | |
2349 | ], [ | |
2350 | 0x0005, 0x0008, 0x0012, 0x001C, 0x001C, 0x00EA, 0x1D75, 0x001E, | |
2351 | 0x0066, 0x0001, 0x0002, 0x001B, 0x001A, 0x001F, 0x003B, 0x0074, | |
2352 | 0x01D6, 0x03AF, 0x1D74, 0x1D77, 0x1D76, 0x0EB9, 0x0EB8, 0x000F, | |
2353 | 0x0006, 0x0013, 0x003B, 0x003A, 0x0000, 0x0018, 0x0032, 0x0067, | |
2354 | ], [ | |
2355 | 0x0004, 0x000A, 0x001B, 0x000C, 0x000D, 0x00E6, 0x0684, 0x0072, | |
2356 | 0x00E7, 0x0002, 0x0001, 0x0017, 0x0016, 0x0018, 0x00D1, 0x01A0, | |
2357 | 0x0686, 0x0D0F, 0x0D0A, 0x1A17, 0x1A16, 0x1A1D, 0x1A1C, 0x000F, | |
2358 | 0x001D, 0x000E, 0x0035, 0x0038, 0x0000, 0x000F, 0x0019, 0x0069, | |
2359 | ], [ | |
2360 | 0x0003, 0x000C, 0x001B, 0x0000, 0x0003, 0x002E, 0x0051, 0x00BC, | |
2361 | 0x0053, 0x0004, 0x0002, 0x0016, 0x0015, 0x0015, 0x0050, 0x00A4, | |
2362 | 0x0294, 0x052B, 0x052A, 0x052D, 0x052C, 0x052F, 0x052E, 0x000E, | |
2363 | 0x001A, 0x0004, 0x0028, 0x0029, 0x000F, 0x000B, 0x005F, 0x00BD, | |
2364 | ] | |
2365 | ]; | |
2366 | ||
6543b6f8 | 2367 | const VP31_AC_CAT1_BITS: [[u8; 32]; 16] = [ |
5b24175d KS |
2368 | [ |
2369 | 5, 7, 8, 9, 11, 12, 12, 4, 9, 4, 4, 4, 4, 4, 4, 4, | |
2370 | 5, 4, 4, 4, 5, 6, 9, 4, 5, 6, 7, 8, 6, 10, 5, 6, | |
2371 | ], [ | |
2372 | 5, 6, 8, 8, 11, 13, 13, 4, 9, 4, 4, 4, 4, 4, 4, 4, | |
2373 | 5, 4, 4, 5, 6, 8, 12, 4, 5, 6, 7, 7, 6, 10, 4, 5, | |
2374 | ], [ | |
2375 | 4, 7, 8, 8, 10, 12, 13, 4, 8, 4, 4, 4, 4, 3, 4, 4, | |
2376 | 5, 5, 5, 6, 7, 11, 13, 4, 5, 6, 7, 7, 6, 9, 4, 5, | |
2377 | ], [ | |
2378 | 4, 6, 8, 8, 10, 11, 12, 5, 9, 3, 3, 4, 4, 4, 4, 5, | |
2379 | 5, 5, 5, 7, 9, 13, 13, 4, 5, 6, 6, 7, 6, 9, 4, 5, | |
2380 | ], [ | |
2381 | 4, 6, 7, 7, 9, 11, 12, 5, 8, 3, 3, 4, 4, 4, 4, 5, | |
2382 | 6, 6, 6, 8, 10, 13, 13, 4, 5, 5, 6, 6, 5, 8, 4, 5, | |
2383 | ], [ | |
2384 | 3, 5, 7, 7, 9, 11, 13, 5, 8, 3, 3, 4, 4, 4, 5, 6, | |
2385 | 7, 7, 8, 10, 13, 13, 13, 4, 5, 5, 6, 6, 5, 8, 4, 5, | |
2386 | ], [ | |
2387 | 3, 5, 6, 6, 8, 10, 12, 5, 8, 3, 3, 4, 4, 5, 5, 7, | |
2388 | 8, 8, 9, 13, 13, 12, 12, 3, 5, 5, 6, 6, 5, 8, 5, 5, | |
2389 | ], [ | |
2390 | 3, 4, 5, 5, 6, 8, 11, 7, 9, 3, 3, 4, 4, 5, 7, 8, | |
2391 | 11, 12, 12, 13, 13, 13, 13, 3, 5, 5, 6, 6, 5, 8, 5, 6, | |
2392 | ], [ | |
2393 | 5, 7, 9, 10, 13, 14, 14, 4, 7, 3, 3, 4, 4, 4, 5, 5, | |
2394 | 6, 6, 7, 8, 11, 13, 13, 4, 4, 5, 5, 6, 5, 6, 4, 5, | |
2395 | ], [ | |
2396 | 4, 6, 7, 8, 10, 13, 13, 5, 7, 3, 4, 4, 4, 4, 5, 6, | |
2397 | 7, 7, 7, 9, 11, 13, 13, 3, 4, 5, 6, 6, 4, 6, 4, 5, | |
2398 | ], [ | |
2399 | 4, 5, 7, 7, 9, 12, 13, 5, 6, 3, 4, 4, 4, 5, 6, 7, | |
2400 | 7, 7, 8, 10, 13, 12, 12, 3, 4, 5, 5, 6, 4, 5, 4, 5, | |
2401 | ], [ | |
2402 | 3, 5, 6, 7, 9, 13, 14, 6, 7, 3, 3, 5, 5, 5, 6, 7, | |
2403 | 9, 9, 10, 11, 14, 13, 13, 3, 4, 5, 5, 5, 4, 5, 5, 6, | |
2404 | ], [ | |
2405 | 3, 4, 6, 5, 7, 12, 14, 6, 7, 3, 3, 5, 5, 6, 7, 8, | |
2406 | 9, 10, 11, 15, 15, 14, 14, 3, 4, 5, 5, 6, 4, 5, 6, 6, | |
2407 | ], [ | |
2408 | 3, 4, 5, 5, 6, 9, 14, 6, 7, 3, 3, 5, 5, 6, 7, 8, | |
2409 | 10, 11, 14, 14, 14, 13, 13, 4, 4, 5, 6, 6, 3, 5, 6, 7, | |
2410 | ], [ | |
2411 | 3, 4, 5, 4, 5, 8, 11, 7, 8, 3, 3, 5, 5, 6, 8, 9, | |
2412 | 11, 12, 12, 13, 13, 13, 13, 4, 5, 5, 6, 6, 3, 5, 6, 7, | |
2413 | ], [ | |
2414 | 3, 4, 5, 3, 4, 6, 9, 8, 9, 3, 3, 5, 5, 7, 9, 10, | |
2415 | 12, 13, 13, 13, 13, 13, 13, 4, 5, 5, 6, 6, 4, 6, 7, 8, | |
2416 | ] | |
2417 | ]; | |
2418 | ||
6543b6f8 | 2419 | const VP31_AC_CAT2_CODES: [[u16; 32]; 16] = [ |
5b24175d KS |
2420 | [ |
2421 | 0x0003, 0x0009, 0x00D0, 0x01A3, 0x0344, 0x0D14, 0x1A2B, 0x0004, | |
2422 | 0x0015, 0x0000, 0x000F, 0x000B, 0x000C, 0x000E, 0x0009, 0x001B, | |
2423 | 0x000A, 0x0014, 0x000D, 0x002A, 0x0014, 0x068B, 0x1A2A, 0x0008, | |
2424 | 0x000B, 0x002B, 0x000B, 0x0069, 0x0035, 0x0008, 0x0007, 0x000C, | |
2425 | ], [ | |
2426 | 0x000A, 0x003C, 0x0032, 0x0030, 0x00C5, 0x0621, 0x0620, 0x001F, | |
2427 | 0x0033, 0x0001, 0x0000, 0x000E, 0x000D, 0x000C, 0x0004, 0x000D, | |
2428 | 0x0026, 0x0027, 0x0014, 0x0063, 0x0189, 0x0623, 0x0622, 0x000B, | |
2429 | 0x0012, 0x003D, 0x0022, 0x0015, 0x000B, 0x0023, 0x0007, 0x0010, | |
2430 | ], [ | |
2431 | 0x000F, 0x000C, 0x0043, 0x0010, 0x0044, 0x0114, 0x0455, 0x0018, | |
2432 | 0x0023, 0x0001, 0x0000, 0x000E, 0x000D, 0x0009, 0x0019, 0x0009, | |
2433 | 0x0017, 0x0016, 0x0042, 0x008B, 0x0454, 0x0457, 0x0456, 0x000B, | |
2434 | 0x0015, 0x000A, 0x0029, 0x0020, 0x000D, 0x0028, 0x0007, 0x0011, | |
2435 | ], [ | |
2436 | 0x0001, 0x001A, 0x0029, 0x002A, 0x00A0, 0x0285, 0x1425, 0x0002, | |
2437 | 0x0000, 0x0002, 0x0003, 0x000C, 0x000B, 0x0008, 0x0012, 0x0001, | |
2438 | 0x0051, 0x0001, 0x0143, 0x0508, 0x1424, 0x1427, 0x1426, 0x000F, | |
2439 | 0x001C, 0x0003, 0x0037, 0x002B, 0x0013, 0x0036, 0x001D, 0x0001, | |
2440 | ], [ | |
2441 | 0x0004, 0x001F, 0x003D, 0x0006, 0x0016, 0x0053, 0x014A, 0x0034, | |
2442 | 0x002A, 0x0002, 0x0003, 0x000B, 0x000C, 0x001C, 0x0037, 0x0017, | |
2443 | 0x002B, 0x0028, 0x00A4, 0x052D, 0x052C, 0x052F, 0x052E, 0x0000, | |
2444 | 0x001D, 0x0007, 0x0004, 0x0035, 0x0014, 0x0036, 0x0015, 0x003C, | |
2445 | ], [ | |
2446 | 0x0004, 0x000A, 0x0007, 0x001D, 0x0009, 0x01F3, 0x07C7, 0x0008, | |
2447 | 0x01F0, 0x0003, 0x0002, 0x000D, 0x000C, 0x0017, 0x007D, 0x01F2, | |
2448 | 0x07C6, 0x07C5, 0x1F12, 0x3E27, 0x3E26, 0x1F11, 0x1F10, 0x0000, | |
2449 | 0x001E, 0x0006, 0x0039, 0x0038, 0x003F, 0x002C, 0x0005, 0x002D, | |
2450 | ], [ | |
2451 | 0x0002, 0x0007, 0x0018, 0x0003, 0x0005, 0x0035, 0x004F, 0x0012, | |
2452 | 0x04E5, 0x0005, 0x0004, 0x000D, 0x000E, 0x0033, 0x0026, 0x009D, | |
2453 | 0x04E4, 0x04E7, 0x04E6, 0x04E1, 0x04E0, 0x04E3, 0x04E2, 0x0000, | |
2454 | 0x001F, 0x000C, 0x003D, 0x003C, 0x0032, 0x0034, 0x001B, 0x0008, | |
2455 | ], [ | |
2456 | 0x0000, 0x0004, 0x001C, 0x000F, 0x0002, 0x0007, 0x0075, 0x00E8, | |
2457 | 0x1D2A, 0x0005, 0x0004, 0x000D, 0x000C, 0x0077, 0x0E96, 0x3A57, | |
2458 | 0x3A56, 0x3A5D, 0x3A5C, 0x3A5F, 0x3A5E, 0x1D29, 0x1D28, 0x0003, | |
2459 | 0x0006, 0x000A, 0x002C, 0x0017, 0x0076, 0x01D3, 0x03A4, 0x002D, | |
2460 | ], [ | |
2461 | 0x000A, 0x0024, 0x00BF, 0x0085, 0x0211, 0x0842, 0x1087, 0x0018, | |
2462 | 0x0020, 0x0001, 0x0002, 0x000E, 0x000D, 0x0007, 0x0013, 0x0025, | |
2463 | 0x005E, 0x0043, 0x00BE, 0x0109, 0x1086, 0x0841, 0x0840, 0x000F, | |
2464 | 0x0001, 0x0011, 0x0000, 0x002E, 0x0019, 0x0001, 0x0006, 0x0016, | |
2465 | ], [ | |
2466 | 0x0002, 0x000F, 0x006F, 0x0061, 0x0374, 0x1BA8, 0x3753, 0x0012, | |
2467 | 0x0036, 0x0000, 0x0001, 0x000A, 0x000B, 0x001A, 0x0031, 0x0060, | |
2468 | 0x00DC, 0x01BB, 0x06EB, 0x1BAB, 0x3752, 0x3755, 0x3754, 0x000E, | |
2469 | 0x0006, 0x0013, 0x000E, 0x003E, 0x0008, 0x001E, 0x0019, 0x003F, | |
2470 | ], [ | |
2471 | 0x0003, 0x001C, 0x0025, 0x0024, 0x01DA, 0x1DBD, 0x3B7C, 0x003C, | |
2472 | 0x003D, 0x0000, 0x0001, 0x000B, 0x000A, 0x000B, 0x0077, 0x00EC, | |
2473 | 0x03B6, 0x076E, 0x1DBF, 0x76FB, 0x76FA, 0x3B79, 0x3B78, 0x000D, | |
2474 | 0x001F, 0x0013, 0x000A, 0x0008, 0x000C, 0x0008, 0x0009, 0x003A, | |
2475 | ], [ | |
2476 | 0x0005, 0x0003, 0x0004, 0x0010, 0x008F, 0x0475, 0x11D1, 0x0079, | |
2477 | 0x0027, 0x0002, 0x0003, 0x0001, 0x0000, 0x0026, 0x0046, 0x011C, | |
2478 | 0x0477, 0x08ED, 0x11D0, 0x11D3, 0x11D2, 0x11D9, 0x11D8, 0x000D, | |
2479 | 0x001F, 0x0012, 0x0005, 0x003D, 0x000C, 0x000E, 0x0022, 0x0078, | |
2480 | ], [ | |
2481 | 0x0005, 0x000C, 0x001B, 0x0000, 0x0006, 0x03E2, 0x3E3D, 0x000F, | |
2482 | 0x0034, 0x0003, 0x0002, 0x001E, 0x001D, 0x007D, 0x01F0, 0x07C6, | |
2483 | 0x3E3C, 0x3E3F, 0x3E3E, 0x3E39, 0x3E38, 0x3E3B, 0x3E3A, 0x0008, | |
2484 | 0x001C, 0x0002, 0x003F, 0x0035, 0x0009, 0x0001, 0x000E, 0x00F9, | |
2485 | ], [ | |
2486 | 0x0004, 0x000B, 0x0001, 0x000A, 0x001E, 0x00E0, 0x0E1E, 0x0071, | |
2487 | 0x0039, 0x0007, 0x0006, 0x000D, 0x000C, 0x0020, 0x01C2, 0x1C3F, | |
2488 | 0x1C3E, 0x0E19, 0x0E18, 0x0E1B, 0x0E1A, 0x0E1D, 0x0E1C, 0x0000, | |
2489 | 0x0009, 0x001D, 0x001F, 0x0011, 0x0005, 0x0001, 0x0043, 0x0042, | |
2490 | ], [ | |
2491 | 0x0004, 0x000D, 0x0007, 0x0002, 0x0014, 0x016C, 0x16D1, 0x02DF, | |
2492 | 0x016E, 0x0000, 0x0007, 0x002C, 0x002B, 0x02DE, 0x16D0, 0x16D3, | |
2493 | 0x16D2, 0x2DB5, 0x2DB4, 0x2DB7, 0x2DB6, 0x16D9, 0x16D8, 0x000C, | |
2494 | 0x002A, 0x005A, 0x001B, 0x001A, 0x0017, 0x000C, 0x05B7, 0x05B5, | |
2495 | ], [ | |
2496 | 0x0002, 0x000F, 0x001C, 0x000C, 0x003B, 0x01AC, 0x1AD8, 0x35B3, | |
2497 | 0x35B2, 0x0001, 0x0000, 0x0069, 0x0068, 0x35BD, 0x35BC, 0x35BF, | |
2498 | 0x35BE, 0x35B9, 0x35B8, 0x35BB, 0x35BA, 0x35B5, 0x35B4, 0x01A9, | |
2499 | 0x01A8, 0x035A, 0x00D7, 0x00D5, 0x003A, 0x001B, 0x35B7, 0x35B6, | |
2500 | ] | |
2501 | ]; | |
2502 | ||
6543b6f8 | 2503 | const VP31_AC_CAT2_BITS: [[u8; 32]; 16] = [ |
5b24175d KS |
2504 | [ |
2505 | 4, 6, 8, 9, 10, 12, 13, 4, 7, 3, 4, 4, 4, 4, 4, 5, | |
2506 | 5, 5, 5, 6, 7, 11, 13, 4, 5, 6, 6, 7, 6, 6, 4, 5, | |
2507 | ], [ | |
2508 | 4, 6, 7, 7, 9, 12, 12, 5, 7, 3, 3, 4, 4, 4, 4, 5, | |
2509 | 6, 6, 6, 8, 10, 12, 12, 4, 5, 6, 6, 6, 5, 6, 4, 5, | |
2510 | ], [ | |
2511 | 4, 5, 7, 6, 8, 10, 12, 5, 7, 3, 3, 4, 4, 4, 5, 5, | |
2512 | 6, 6, 7, 9, 12, 12, 12, 4, 5, 5, 6, 6, 5, 6, 4, 5, | |
2513 | ], [ | |
2514 | 3, 5, 6, 6, 8, 10, 13, 5, 7, 3, 3, 4, 4, 4, 5, 6, | |
2515 | 7, 7, 9, 11, 13, 13, 13, 4, 5, 5, 6, 6, 5, 6, 5, 5, | |
2516 | ], [ | |
2517 | 3, 5, 6, 5, 7, 9, 11, 6, 8, 3, 3, 4, 4, 5, 6, 7, | |
2518 | 8, 8, 10, 13, 13, 13, 13, 3, 5, 5, 5, 6, 5, 6, 5, 6, | |
2519 | ], [ | |
2520 | 3, 4, 5, 5, 6, 9, 11, 6, 9, 3, 3, 4, 4, 5, 7, 9, | |
2521 | 11, 11, 13, 14, 14, 13, 13, 3, 5, 5, 6, 6, 6, 6, 5, 6, | |
2522 | ], [ | |
2523 | 3, 4, 5, 4, 5, 7, 9, 7, 13, 3, 3, 4, 4, 6, 8, 10, | |
2524 | 13, 13, 13, 13, 13, 13, 13, 3, 5, 5, 6, 6, 6, 7, 6, 6, | |
2525 | ], [ | |
2526 | 3, 4, 5, 4, 4, 5, 7, 8, 13, 3, 3, 4, 4, 7, 12, 14, | |
2527 | 14, 14, 14, 14, 14, 13, 13, 3, 5, 5, 7, 6, 7, 9, 10, 7, | |
2528 | ], [ | |
2529 | 4, 6, 8, 8, 10, 12, 13, 5, 6, 3, 3, 4, 4, 4, 5, 6, | |
2530 | 7, 7, 8, 9, 13, 12, 12, 4, 4, 5, 5, 6, 5, 5, 4, 5, | |
2531 | ], [ | |
2532 | 3, 5, 7, 7, 10, 13, 14, 5, 6, 3, 3, 4, 4, 5, 6, 7, | |
2533 | 8, 9, 11, 13, 14, 14, 14, 4, 4, 5, 5, 6, 4, 5, 5, 6, | |
2534 | ], [ | |
2535 | 3, 5, 6, 6, 9, 13, 14, 6, 6, 3, 3, 4, 4, 5, 7, 8, | |
2536 | 10, 11, 13, 15, 15, 14, 14, 4, 5, 5, 5, 5, 4, 4, 5, 6, | |
2537 | ], [ | |
2538 | 3, 4, 5, 5, 8, 11, 13, 7, 6, 3, 3, 4, 4, 6, 7, 9, | |
2539 | 11, 12, 13, 13, 13, 13, 13, 4, 5, 5, 5, 6, 4, 4, 6, 7, | |
2540 | ], [ | |
2541 | 3, 4, 5, 4, 6, 10, 14, 7, 6, 3, 3, 5, 5, 7, 9, 11, | |
2542 | 14, 14, 14, 14, 14, 14, 14, 4, 5, 5, 6, 6, 4, 3, 7, 8, | |
2543 | ], [ | |
2544 | 3, 4, 4, 4, 6, 9, 13, 8, 7, 3, 3, 5, 5, 7, 10, 14, | |
2545 | 14, 13, 13, 13, 13, 13, 13, 4, 5, 6, 6, 6, 4, 3, 8, 8, | |
2546 | ], [ | |
2547 | 3, 4, 4, 3, 5, 9, 13, 10, 9, 2, 3, 6, 6, 10, 13, 13, | |
2548 | 13, 14, 14, 14, 14, 13, 13, 5, 6, 7, 6, 6, 5, 4, 11, 11, | |
2549 | ], [ | |
2550 | 2, 4, 5, 4, 6, 9, 13, 14, 14, 2, 2, 7, 7, 14, 14, 14, | |
2551 | 14, 14, 14, 14, 14, 14, 14, 9, 9, 10, 8, 8, 6, 5, 14, 14, | |
2552 | ] | |
2553 | ]; | |
2554 | ||
6543b6f8 | 2555 | const VP31_AC_CAT3_CODES: [[u16; 32]; 16] = [ |
5b24175d KS |
2556 | [ |
2557 | 0x0000, 0x0010, 0x0072, 0x0071, 0x0154, 0x0AAB, 0x0AA8, 0x0014, | |
2558 | 0x0070, 0x0002, 0x0003, 0x000C, 0x000B, 0x0003, 0x0011, 0x0073, | |
2559 | 0x0054, 0x00AB, 0x02AB, 0x1553, 0x1552, 0x1555, 0x1554, 0x000D, | |
2560 | 0x001E, 0x0012, 0x003E, 0x002B, 0x0002, 0x003F, 0x001D, 0x0013, | |
2561 | ], [ | |
2562 | 0x0003, 0x001F, 0x0029, 0x003D, 0x000C, 0x0069, 0x0345, 0x0002, | |
2563 | 0x0028, 0x0002, 0x0001, 0x000E, 0x000C, 0x0015, 0x0007, 0x001B, | |
2564 | 0x006B, 0x006A, 0x0344, 0x0347, 0x0346, 0x01A1, 0x01A0, 0x000B, | |
2565 | 0x001A, 0x0012, 0x0000, 0x003C, 0x0008, 0x001B, 0x0013, 0x0001, | |
2566 | ], [ | |
2567 | 0x0004, 0x0004, 0x003F, 0x0014, 0x0056, 0x015C, 0x15D5, 0x003C, | |
2568 | 0x002A, 0x0000, 0x0001, 0x000E, 0x000D, 0x000C, 0x00AF, 0x02BB, | |
2569 | 0x15D4, 0x15D7, 0x15D6, 0x15D1, 0x15D0, 0x15D3, 0x15D2, 0x000B, | |
2570 | 0x0019, 0x000D, 0x003E, 0x0031, 0x0007, 0x0005, 0x003D, 0x0030, | |
2571 | ], [ | |
2572 | 0x0005, 0x0008, 0x001A, 0x0000, 0x0036, 0x0011, 0x0106, 0x000A, | |
2573 | 0x006E, 0x0002, 0x0003, 0x0003, 0x0002, 0x006F, 0x0021, 0x020F, | |
2574 | 0x020E, 0x0101, 0x0100, 0x0103, 0x0102, 0x0105, 0x0104, 0x000C, | |
2575 | 0x001E, 0x0003, 0x003E, 0x003F, 0x0009, 0x000E, 0x000B, 0x0009, | |
2576 | ], [ | |
2577 | 0x0002, 0x000E, 0x001E, 0x000C, 0x001F, 0x006E, 0x00AD, 0x00AF, | |
2578 | 0x0014, 0x0004, 0x0003, 0x001A, 0x0017, 0x002A, 0x0576, 0x0AEF, | |
2579 | 0x0AEE, 0x0571, 0x0570, 0x0573, 0x0572, 0x0575, 0x0574, 0x0003, | |
2580 | 0x0016, 0x0004, 0x0036, 0x000B, 0x000A, 0x0000, 0x006F, 0x00AC, | |
2581 | ], [ | |
2582 | 0x0004, 0x0005, 0x0003, 0x0001, 0x0004, 0x002F, 0x0526, 0x1495, | |
2583 | 0x00A6, 0x0007, 0x0006, 0x002D, 0x002C, 0x1494, 0x1497, 0x1496, | |
2584 | 0x1491, 0x1490, 0x1493, 0x1492, 0x293D, 0x293C, 0x293F, 0x0000, | |
2585 | 0x0028, 0x00A5, 0x0148, 0x00A7, 0x002E, 0x0015, 0x0A4E, 0x293E, | |
2586 | ], [ | |
2587 | 0x0004, 0x0005, 0x0003, 0x0001, 0x0004, 0x002F, 0x0526, 0x1495, | |
2588 | 0x00A6, 0x0007, 0x0006, 0x002D, 0x002C, 0x1494, 0x1497, 0x1496, | |
2589 | 0x1491, 0x1490, 0x1493, 0x1492, 0x293D, 0x293C, 0x293F, 0x0000, | |
2590 | 0x0028, 0x00A5, 0x0148, 0x00A7, 0x002E, 0x0015, 0x0A4E, 0x293E, | |
2591 | ], [ | |
2592 | 0x0004, 0x0005, 0x0003, 0x0001, 0x0004, 0x002F, 0x0526, 0x1495, | |
2593 | 0x00A6, 0x0007, 0x0006, 0x002D, 0x002C, 0x1494, 0x1497, 0x1496, | |
2594 | 0x1491, 0x1490, 0x1493, 0x1492, 0x293D, 0x293C, 0x293F, 0x0000, | |
2595 | 0x0028, 0x00A5, 0x0148, 0x00A7, 0x002E, 0x0015, 0x0A4E, 0x293E, | |
2596 | ], [ | |
2597 | 0x0003, 0x0011, 0x0020, 0x0074, 0x010D, 0x0863, 0x0860, 0x000A, | |
2598 | 0x0075, 0x0001, 0x0000, 0x000B, 0x000A, 0x0018, 0x0038, 0x0042, | |
2599 | 0x010F, 0x010E, 0x0219, 0x10C3, 0x10C2, 0x10C5, 0x10C4, 0x000F, | |
2600 | 0x0004, 0x0019, 0x000B, 0x0039, 0x0009, 0x001B, 0x001A, 0x003B, | |
2601 | ], [ | |
2602 | 0x0005, 0x0001, 0x003E, 0x0001, 0x00E2, 0x1C6F, 0x38D9, 0x0039, | |
2603 | 0x001F, 0x0002, 0x0001, 0x0009, 0x0008, 0x0000, 0x0070, 0x01C7, | |
2604 | 0x038C, 0x071A, 0x38D8, 0x38DB, 0x38DA, 0x38DD, 0x38DC, 0x000D, | |
2605 | 0x001D, 0x000E, 0x003F, 0x003C, 0x000C, 0x0006, 0x003D, 0x001E, | |
2606 | ], [ | |
2607 | 0x0006, 0x000B, 0x0011, 0x001E, 0x0074, 0x03AA, 0x1D5C, 0x0001, | |
2608 | 0x0021, 0x0001, 0x0002, 0x0007, 0x0006, 0x003E, 0x00EB, 0x01D4, | |
2609 | 0x0EAF, 0x3ABB, 0x3ABA, 0x1D59, 0x1D58, 0x1D5B, 0x1D5A, 0x000A, | |
2610 | 0x001C, 0x0001, 0x003F, 0x003B, 0x0001, 0x0009, 0x0020, 0x0000, | |
2611 | ], [ | |
2612 | 0x0004, 0x000A, 0x0017, 0x0004, 0x0016, 0x016A, 0x16B1, 0x0017, | |
2613 | 0x005B, 0x0006, 0x0007, 0x0001, 0x0000, 0x000A, 0x02D7, 0x0B5A, | |
2614 | 0x16B0, 0x16B3, 0x16B2, 0x2D6D, 0x2D6C, 0x2D6F, 0x2D6E, 0x0006, | |
2615 | 0x000A, 0x0004, 0x002C, 0x0017, 0x0003, 0x0007, 0x0016, 0x00B4, | |
2616 | ], [ | |
2617 | 0x0005, 0x000D, 0x0005, 0x0009, 0x0033, 0x0193, 0x192C, 0x0061, | |
2618 | 0x0031, 0x0000, 0x0007, 0x0010, 0x0011, 0x00C8, 0x192F, 0x325B, | |
2619 | 0x325A, 0x1929, 0x1928, 0x192B, 0x192A, 0x325D, 0x325C, 0x0018, | |
2620 | 0x001A, 0x001B, 0x0065, 0x0019, 0x0004, 0x0007, 0x0060, 0x0324, | |
2621 | ], [ | |
2622 | 0x0006, 0x0000, 0x0002, 0x000F, 0x0039, 0x01D9, 0x1D82, 0x0761, | |
2623 | 0x03BE, 0x0001, 0x0002, 0x000F, 0x000E, 0x0762, 0x3B07, 0x3B06, | |
2624 | 0x3B1D, 0x3B1C, 0x3B1F, 0x3B1E, 0x3B19, 0x3B18, 0x3B1B, 0x0038, | |
2625 | 0x01DE, 0x00ED, 0x03BF, 0x00EE, 0x003A, 0x0006, 0x0EC0, 0x3B1A, | |
2626 | ], [ | |
2627 | 0x0000, 0x0002, 0x000F, 0x0006, 0x001C, 0x01D0, 0x0E8C, 0x1D1B, | |
2628 | 0x1D1A, 0x0003, 0x0002, 0x00EA, 0x00E9, 0x0E89, 0x0E88, 0x0E8B, | |
2629 | 0x0E8A, 0x1D65, 0x1D64, 0x1D67, 0x1D66, 0x1D61, 0x1D60, 0x03AD, | |
2630 | 0x1D63, 0x1D62, 0x1D1D, 0x1D1C, 0x003B, 0x01D7, 0x1D1F, 0x1D1E, | |
2631 | ], [ | |
2632 | 0x0002, 0x000F, 0x001C, 0x000C, 0x003B, 0x01AC, 0x1AD8, 0x35B3, | |
2633 | 0x35B2, 0x0001, 0x0000, 0x0069, 0x0068, 0x35BD, 0x35BC, 0x35BF, | |
2634 | 0x35BE, 0x35B9, 0x35B8, 0x35BB, 0x35BA, 0x35B5, 0x35B4, 0x01A9, | |
2635 | 0x01A8, 0x035A, 0x00D7, 0x00D5, 0x003A, 0x001B, 0x35B7, 0x35B6, | |
2636 | ] | |
2637 | ]; | |
2638 | ||
6543b6f8 | 2639 | const VP31_AC_CAT3_BITS: [[u8; 32]; 16] = [ |
5b24175d KS |
2640 | [ |
2641 | 3, 5, 7, 7, 9, 12, 12, 5, 7, 3, 3, 4, 4, 4, 5, 7, | |
2642 | 7, 8, 10, 13, 13, 13, 13, 4, 5, 5, 6, 6, 4, 6, 5, 5, | |
2643 | ], [ | |
2644 | 3, 5, 6, 6, 7, 10, 13, 5, 6, 3, 3, 4, 4, 5, 6, 8, | |
2645 | 10, 10, 13, 13, 13, 12, 12, 4, 5, 5, 5, 6, 4, 5, 5, 5, | |
2646 | ], [ | |
2647 | 3, 4, 6, 5, 7, 9, 13, 6, 6, 3, 3, 4, 4, 5, 8, 10, | |
2648 | 13, 13, 13, 13, 13, 13, 13, 4, 5, 5, 6, 6, 4, 4, 6, 6, | |
2649 | ], [ | |
2650 | 3, 4, 5, 4, 6, 8, 12, 7, 7, 3, 3, 4, 4, 7, 9, 13, | |
2651 | 13, 12, 12, 12, 12, 12, 12, 4, 5, 5, 6, 6, 4, 4, 7, 7, | |
2652 | ], [ | |
2653 | 3, 4, 5, 4, 5, 7, 10, 10, 7, 3, 3, 5, 5, 8, 13, 14, | |
2654 | 14, 13, 13, 13, 13, 13, 13, 4, 5, 5, 6, 6, 4, 3, 7, 10, | |
2655 | ], [ | |
2656 | 3, 4, 3, 3, 4, 6, 11, 13, 8, 3, 3, 6, 6, 13, 13, 13, | |
2657 | 13, 13, 13, 13, 14, 14, 14, 3, 6, 8, 9, 8, 6, 5, 12, 14, | |
2658 | ], [ | |
2659 | 3, 4, 3, 3, 4, 6, 11, 13, 8, 3, 3, 6, 6, 13, 13, 13, | |
2660 | 13, 13, 13, 13, 14, 14, 14, 3, 6, 8, 9, 8, 6, 5, 12, 14, | |
2661 | ], [ | |
2662 | 3, 4, 3, 3, 4, 6, 11, 13, 8, 3, 3, 6, 6, 13, 13, 13, | |
2663 | 13, 13, 13, 13, 14, 14, 14, 3, 6, 8, 9, 8, 6, 5, 12, 14, | |
2664 | ], [ | |
2665 | 3, 5, 6, 7, 9, 12, 12, 5, 7, 3, 3, 4, 4, 5, 6, 7, | |
2666 | 9, 9, 10, 13, 13, 13, 13, 4, 4, 5, 5, 6, 4, 5, 5, 6, | |
2667 | ], [ | |
2668 | 3, 4, 6, 5, 8, 13, 14, 6, 6, 3, 3, 4, 4, 5, 7, 9, | |
2669 | 10, 11, 14, 14, 14, 14, 14, 4, 5, 5, 6, 6, 4, 4, 6, 6, | |
2670 | ], [ | |
2671 | 3, 4, 5, 5, 7, 10, 13, 6, 6, 3, 3, 4, 4, 6, 8, 9, | |
2672 | 12, 14, 14, 13, 13, 13, 13, 4, 5, 5, 6, 6, 4, 4, 6, 6, | |
2673 | ], [ | |
2674 | 3, 4, 5, 4, 6, 9, 13, 7, 7, 3, 3, 4, 4, 6, 10, 12, | |
2675 | 13, 13, 13, 14, 14, 14, 14, 4, 5, 5, 6, 6, 4, 4, 7, 8, | |
2676 | ], [ | |
2677 | 3, 4, 4, 4, 6, 9, 13, 8, 7, 2, 3, 5, 5, 8, 13, 14, | |
2678 | 14, 13, 13, 13, 13, 14, 14, 5, 6, 6, 7, 6, 4, 4, 8, 10, | |
2679 | ], [ | |
2680 | 3, 3, 4, 4, 6, 9, 13, 11, 10, 2, 2, 6, 6, 11, 14, 14, | |
2681 | 14, 14, 14, 14, 14, 14, 14, 6, 9, 8, 10, 8, 6, 5, 12, 14, | |
2682 | ], [ | |
2683 | 2, 3, 5, 4, 6, 10, 13, 14, 14, 2, 2, 9, 9, 13, 13, 13, | |
2684 | 13, 14, 14, 14, 14, 14, 14, 11, 14, 14, 14, 14, 7, 10, 14, 14, | |
2685 | ], [ | |
2686 | 2, 4, 5, 4, 6, 9, 13, 14, 14, 2, 2, 7, 7, 14, 14, 14, | |
2687 | 14, 14, 14, 14, 14, 14, 14, 9, 9, 10, 8, 8, 6, 5, 14, 14, | |
2688 | ] | |
2689 | ]; | |
2690 | ||
6543b6f8 | 2691 | const VP31_DC_WEIGHTS: [[i16; 5]; 16] = [ |
5b24175d KS |
2692 | [ 0, 0, 0, 0, 0 ], |
2693 | [ 1, 0, 0, 0, 1 ], | |
2694 | [ 0, 1, 0, 0, 1 ], | |
2695 | [ 1, 0, 0, 0, 1 ], | |
2696 | ||
2697 | [ 0, 0, 1, 0, 1 ], | |
2698 | [ 1, 0, 1, 0, 2 ], | |
2699 | [ 0, 0, 1, 0, 1 ], | |
2700 | [ 29, -26, 29, 0, 32 ], | |
2701 | ||
2702 | [ 0, 0, 0, 1, 1 ], | |
2703 | [ 75, 0, 0, 53, 128 ], | |
2704 | [ 0, 1, 0, 1, 2 ], | |
2705 | [ 75, 0, 0, 53, 128 ], | |
2706 | ||
2707 | [ 0, 0, 1, 0, 1 ], | |
2708 | [ 75, 0, 0, 53, 128 ], | |
2709 | [ 0, 3, 10, 3, 16 ], | |
2710 | [ 29, -26, 29, 0, 32 ], | |
2711 | ]; | |
3567fcdb KS |
2712 | |
2713 | const VP30_DC_SCALES: [i16; 64] = [ | |
2714 | 24, 20, 20, 20, 20, 20, 20, 20, | |
2715 | 19, 19, 19, 19, 18, 18, 18, 18, | |
2716 | 17, 17, 17, 17, 16, 16, 15, 15, | |
2717 | 14, 14, 13, 13, 12, 12, 11, 11, | |
2718 | 10, 10, 9, 9, 8, 8, 7, 7, | |
2719 | 6, 6, 6, 6, 5, 5, 5, 5, | |
2720 | 4, 4, 4, 4, 3, 3, 3, 3, | |
2721 | 2, 2, 2, 2, 1, 1, 1, 1 | |
2722 | ]; | |
2723 | ||
2724 | const VP30_AC_SCALES: [i16; 64] = [ | |
2725 | 3000, 2500, 2000, 1500, 1200, 1000, 900, 800, | |
2726 | 750, 700, 650, 630, 600, 550, 500, 450, | |
2727 | 410, 380, 350, 320, 290, 260, 240, 220, | |
2728 | 200, 180, 165, 150, 140, 130, 120, 115, | |
2729 | 110, 100, 95, 90, 85, 80, 75, 70, | |
2730 | 67, 65, 63, 61, 57, 55, 53, 50, | |
2731 | 49, 46, 44, 42, 39, 36, 33, 30, | |
2732 | 27, 24, 21, 19, 17, 15, 12, 10 | |
2733 | ]; | |
2734 | ||
2735 | const VP30_DC_CODES: [[u16; 32]; 5] = [ | |
2736 | [ | |
2737 | 0x0005, 0x002D, 0x0004, 0x0009, 0x0088, 0x0225, 0x0224, 0x0005, | |
2738 | 0x0011, 0x0007, 0x0006, 0x0009, 0x000A, 0x0007, 0x0017, 0x000C, | |
2739 | 0x002C, 0x0005, 0x0008, 0x0003, 0x0012, 0x0010, 0x0113, 0x0003, | |
2740 | 0x0010, 0x0000, 0x0013, 0x001A, 0x0023, 0x0045, 0x0001, 0x001B | |
2741 | ], [ | |
2742 | 0x000B, 0x0012, 0x0029, 0x0010, 0x000D, 0x00A2, 0x0020, 0x0009, | |
2743 | 0x0050, 0x0007, 0x0006, 0x0006, 0x0005, 0x0002, 0x0008, 0x0027, | |
2744 | 0x0005, 0x0022, 0x0023, 0x0057, 0x00A3, 0x0011, 0x0021, 0x0007, | |
2745 | 0x0000, 0x0009, 0x002A, 0x0003, 0x0007, 0x0026, 0x000C, 0x0056 | |
2746 | ], [ | |
2747 | 0x000D, 0x0018, 0x0009, 0x0017, 0x0033, 0x0056, 0x00F7, 0x00F1, | |
2748 | 0x007A, 0x0000, 0x0007, 0x0009, 0x0008, 0x0005, 0x000D, 0x002D, | |
2749 | 0x0010, 0x001D, 0x001C, 0x0057, 0x00CB, 0x00F6, 0x00F0, 0x0014, | |
2750 | 0x000C, 0x002C, 0x0011, 0x001F, 0x002A, 0x0064, 0x00CA, 0x0079 | |
2751 | ], [ | |
2752 | 0x000F, 0x001A, 0x0013, 0x001B, 0x003B, 0x0072, 0x01D3, 0x0707, | |
2753 | 0x0E0D, 0x0001, 0x0000, 0x000C, 0x000B, 0x0008, 0x0012, 0x002A, | |
2754 | 0x0073, 0x0028, 0x0075, 0x0056, 0x0052, 0x01C0, 0x0E0C, 0x0071, | |
2755 | 0x0057, 0x00E1, 0x00A6, 0x00E8, 0x00A7, 0x03A5, 0x03A4, 0x0382 | |
2756 | ], [ | |
2757 | 0x000F, 0x001B, 0x0014, 0x001D, 0x0010, 0x0073, 0x00E2, 0x023C, | |
2758 | 0x11C9, 0x0001, 0x0000, 0x000C, 0x000B, 0x0009, 0x0015, 0x0035, | |
2759 | 0x0072, 0x0034, 0x0022, 0x0070, 0x0046, 0x011D, 0x11C8, 0x01C7, | |
2760 | 0x01C6, 0x0238, 0x047E, 0x023E, 0x0473, 0x08E5, 0x023D, 0x047F | |
2761 | ] | |
2762 | ]; | |
2763 | const VP30_DC_BITS: [[u8; 32]; 5] = [ | |
2764 | [ | |
2765 | 4, 6, 6, 6, 8, 10, 10, 6, 7, 3, 3, 4, 4, 4, 5, 5, | |
2766 | 6, 5, 5, 5, 6, 7, 9, 4, 5, 5, 6, 6, 6, 7, 5, 6 | |
2767 | ], [ | |
2768 | 4, 5, 6, 5, 6, 8, 9, 7, 7, 3, 3, 4, 4, 4, 5, 6, | |
2769 | 6, 6, 6, 7, 8, 8, 9, 4, 4, 5, 6, 5, 5, 6, 6, 7 | |
2770 | ], [ | |
2771 | 4, 5, 5, 5, 6, 7, 9, 9, 8, 2, 3, 4, 4, 4, 5, 6, | |
2772 | 6, 6, 6, 7, 8, 9, 9, 5, 5, 6, 6, 6, 6, 7, 8, 8 | |
2773 | ], [ | |
2774 | 4, 5, 5, 5, 6, 7, 9, 11, 12, 2, 2, 4, 4, 4, 5, 6, | |
2775 | 7, 6, 7, 7, 7, 9, 12, 7, 7, 8, 8, 8, 8, 10, 10, 10 | |
2776 | ], [ | |
2777 | 4, 5, 5, 5, 5, 7, 8, 10, 13, 2, 2, 4, 4, 4, 5, 6, | |
2778 | 7, 6, 6, 7, 7, 9, 13, 9, 9, 10, 11, 10, 11, 12, 10, 11 | |
2779 | ] | |
2780 | ]; | |
2781 | const VP30_AC_INTRA_CODES: [[u16; 32]; 5] = [ | |
2782 | [ | |
2783 | 0x0008, 0x0033, 0x0008, 0x004B, 0x0089, 0x0221, 0x0220, 0x001F, | |
2784 | 0x0045, 0x0000, 0x000E, 0x000B, 0x000A, 0x000D, 0x0006, 0x001E, | |
2785 | 0x000A, 0x0018, 0x0013, 0x0005, 0x0009, 0x0046, 0x0111, 0x0007, | |
2786 | 0x000B, 0x0032, 0x0010, 0x004A, 0x0024, 0x0047, 0x0003, 0x0009 | |
2787 | ], [ | |
2788 | 0x000E, 0x000E, 0x007B, 0x001E, 0x007E, 0x03EF, 0x07DD, 0x0018, | |
2789 | 0x00FA, 0x0002, 0x0000, 0x000A, 0x0008, 0x000B, 0x0003, 0x0012, | |
2790 | 0x0033, 0x000C, 0x003C, 0x001A, 0x007F, 0x01F6, 0x07DC, 0x000D, | |
2791 | 0x0013, 0x0004, 0x001B, 0x007A, 0x0032, 0x007C, 0x001F, 0x0005 | |
2792 | ], [ | |
2793 | 0x0000, 0x0018, 0x0034, 0x000C, 0x006A, 0x01F9, 0x07EA, 0x0016, | |
2794 | 0x0FD7, 0x0002, 0x0001, 0x000A, 0x0009, 0x0007, 0x001B, 0x003E, | |
2795 | 0x0020, 0x0021, 0x006B, 0x01FB, 0x03F4, 0x1FAD, 0x1FAC, 0x000E, | |
2796 | 0x0019, 0x0011, 0x002F, 0x007F, 0x002E, 0x01F8, 0x001E, 0x000D | |
2797 | ], [ | |
2798 | 0x000E, 0x0016, 0x002E, 0x0003, 0x006E, 0x008B, 0x0113, 0x0018, | |
2799 | 0x0221, 0x0001, 0x0002, 0x000A, 0x0009, 0x0007, 0x001A, 0x0002, | |
2800 | 0x001B, 0x0023, 0x006F, 0x008A, 0x0111, 0x0441, 0x0440, 0x000F, | |
2801 | 0x0019, 0x0010, 0x0036, 0x001A, 0x002F, 0x0112, 0x0000, 0x000C | |
2802 | ], [ | |
2803 | 0x000E, 0x000F, 0x001B, 0x0033, 0x005A, 0x00B6, 0x0008, 0x001A, | |
2804 | 0x004D, 0x0001, 0x0002, 0x000A, 0x0009, 0x0008, 0x001B, 0x0003, | |
2805 | 0x002C, 0x002E, 0x0005, 0x00B7, 0x0027, 0x0099, 0x0098, 0x000F, | |
2806 | 0x0018, 0x000E, 0x002F, 0x001A, 0x0032, 0x0012, 0x0000, 0x000C | |
2807 | ] | |
2808 | ]; | |
2809 | const VP30_AC_INTRA_BITS: [[u8; 32]; 5] = [ | |
2810 | [ | |
2811 | 4, 6, 6, 7, 9, 11, 11, 5, 8, 3, 4, 4, 4, 4, 4, 5, | |
2812 | 5, 5, 5, 5, 6, 8, 10, 4, 5, 6, 6, 7, 6, 8, 4, 5 | |
2813 | ], [ | |
2814 | 4, 5, 7, 6, 8, 11, 12, 5, 9, 3, 3, 4, 4, 4, 4, 5, | |
2815 | 6, 5, 6, 6, 8, 10, 12, 4, 5, 5, 6, 7, 6, 8, 5, 5 | |
2816 | ], [ | |
2817 | 3, 5, 6, 5, 7, 9, 11, 5, 12, 3, 3, 4, 4, 4, 5, 6, | |
2818 | 6, 6, 7, 9, 10, 13, 13, 4, 5, 5, 6, 7, 6, 9, 5, 5 | |
2819 | ], [ | |
2820 | 4, 5, 6, 5, 7, 8, 9, 5, 10, 3, 3, 4, 4, 4, 5, 5, | |
2821 | 6, 6, 7, 8, 9, 11, 11, 4, 5, 5, 6, 6, 6, 9, 4, 5 | |
2822 | ], [ | |
2823 | 4, 5, 6, 6, 7, 8, 7, 5, 10, 3, 3, 4, 4, 4, 5, 5, | |
2824 | 6, 6, 6, 8, 9, 11, 11, 4, 5, 5, 6, 6, 6, 8, 4, 5 | |
2825 | ] | |
2826 | ]; | |
2827 | const VP30_AC_INTER_CODES: [[u16; 32]; 5] = [ | |
2828 | [ | |
2829 | 0x000D, 0x0038, 0x0061, 0x0060, 0x0393, 0x1C95, 0x1C94, 0x0014, | |
2830 | 0x0073, 0x0001, 0x0000, 0x000B, 0x0009, 0x001D, 0x000E, 0x0022, | |
2831 | 0x0046, 0x0047, 0x00E5, 0x01C8, 0x0724, 0x1C97, 0x1C96, 0x000F, | |
2832 | 0x0006, 0x0019, 0x000F, 0x0031, 0x0004, 0x0010, 0x0005, 0x0015 | |
2833 | ], [ | |
2834 | 0x0004, 0x001B, 0x0030, 0x0034, 0x00D5, 0x06B3, 0x3595, 0x0031, | |
2835 | 0x001A, 0x0002, 0x0001, 0x001F, 0x001E, 0x000C, 0x001B, 0x00D7, | |
2836 | 0x00D4, 0x01AD, 0x0358, 0x0D64, 0x3594, 0x3597, 0x3596, 0x0000, | |
2837 | 0x000A, 0x001D, 0x0017, 0x0039, 0x0007, 0x0019, 0x0016, 0x0038 | |
2838 | ], [ | |
2839 | 0x0005, 0x0009, 0x001A, 0x001E, 0x001F, 0x00E2, 0x038E, 0x0070, | |
2840 | 0x003B, 0x0001, 0x0000, 0x0019, 0x0018, 0x001E, 0x003A, 0x01C6, | |
2841 | 0x071E, 0x0E3E, 0x1C7E, 0x71FD, 0x71FC, 0x71FF, 0x71FE, 0x0002, | |
2842 | 0x0008, 0x001D, 0x001B, 0x0039, 0x001F, 0x000D, 0x000C, 0x001C | |
2843 | ], [ | |
2844 | 0x0003, 0x000B, 0x001C, 0x000D, 0x0004, 0x000A, 0x0076, 0x00E8, | |
2845 | 0x01DC, 0x0001, 0x0000, 0x0033, 0x0032, 0x00E9, 0x03BB, 0x0774, | |
2846 | 0x1DD5, 0x3BAD, 0x3BAC, 0x3BAF, 0x3BAE, 0x3BA9, 0x3BA8, 0x0004, | |
2847 | 0x000A, 0x001F, 0x001E, 0x0030, 0x000B, 0x0075, 0x0031, 0x00EF | |
2848 | ], [ | |
2849 | 0x0009, 0x001E, 0x000F, 0x000E, 0x000C, 0x0008, 0x0001, 0x00E3, | |
2850 | 0x00E2, 0x0002, 0x0000, 0x003A, 0x0039, 0x0070, 0x01DC, 0x0776, | |
2851 | 0x0775, 0x0EEF, 0x0EE8, 0x1DD3, 0x1DD2, 0x1DDD, 0x1DDC, 0x0005, | |
2852 | 0x001F, 0x001B, 0x0006, 0x006A, 0x0034, 0x0076, 0x006B, 0x00EF | |
2853 | ] | |
2854 | ]; | |
2855 | const VP30_AC_INTER_BITS: [[u8; 32]; 5] = [ | |
2856 | [ | |
2857 | 4, 6, 7, 7, 10, 13, 13, 5, 7, 3, 3, 4, 4, 5, 5, 6, | |
2858 | 7, 7, 8, 9, 11, 13, 13, 4, 4, 5, 5, 6, 4, 5, 4, 5 | |
2859 | ], [ | |
2860 | 3, 5, 6, 6, 8, 11, 14, 6, 6, 3, 3, 5, 5, 5, 6, 8, | |
2861 | 8, 9, 10, 12, 14, 14, 14, 3, 4, 5, 5, 6, 4, 5, 5, 6 | |
2862 | ], [ | |
2863 | 3, 4, 5, 5, 6, 8, 10, 7, 7, 3, 3, 5, 5, 6, 7, 9, | |
2864 | 11, 12, 13, 15, 15, 15, 15, 3, 4, 5, 5, 6, 5, 5, 5, 6 | |
2865 | ], [ | |
2866 | 3, 4, 5, 4, 4, 5, 7, 8, 9, 3, 3, 6, 6, 8, 10, 11, | |
2867 | 13, 14, 14, 14, 14, 14, 14, 3, 4, 5, 5, 6, 5, 7, 6, 8 | |
2868 | ], [ | |
2869 | 4, 5, 5, 4, 4, 4, 3, 9, 9, 3, 3, 7, 7, 8, 10, 12, | |
2870 | 12, 13, 13, 14, 14, 14, 14, 3, 5, 5, 4, 7, 6, 8, 7, 9 | |
2871 | ] | |
2872 | ]; | |
2873 | const VP30_MBTYPE_CODES: [u8; 7] = [ 0x00, 0x08, 0x0A, 0x03, 0x0B, 0x13, 0x12 ]; | |
2874 | const VP30_MBTYPE_BITS: [u8; 7] = [ 1, 4, 4, 2, 4, 5, 5 ]; | |
2875 | const VP30_MBTYPE_SYMS: [VPMBType; 7] = [ | |
2876 | VPMBType::InterNoMV, VPMBType::Intra, VPMBType::InterMV, VPMBType::InterNearest, | |
2877 | VPMBType::GoldenNoMV, VPMBType::GoldenMV, VPMBType::InterFourMV | |
2878 | ]; | |
8e4b2f44 KS |
2879 | |
2880 | const VP40_DC_CODES: [[u32; 32]; 16] = [ | |
2881 | [ | |
2882 | 0x000C, 0x0070, 0x01CA, 0x01CB, 0x0391, 0x1C9B, 0x3935, 0x0071, | |
2883 | 0x3934, 0x000B, 0x000F, 0x0019, 0x0002, 0x0009, 0x0003, 0x001D, | |
2884 | 0x0018, 0x0007, 0x000D, 0x0002, 0x0000, 0x000A, 0x0008, 0x001A, | |
2885 | 0x0073, 0x006F, 0x0E4C, 0x0727, 0x0392, 0x0390, 0x0036, 0x006E | |
2886 | ], [ | |
2887 | 0x0011, 0x007A, 0x0083, 0x0040, 0x0105, 0x0413, 0x0410, 0x007B, | |
2888 | 0x0822, 0x000E, 0x0002, 0x0002, 0x0006, 0x000A, 0x0007, 0x001F, | |
2889 | 0x0017, 0x0009, 0x000D, 0x0000, 0x000C, 0x0003, 0x003C, 0x002C, | |
2890 | 0x0021, 0x0169, 0x0412, 0x02D0, 0x02D1, 0x0823, 0x005B, 0x00B5 | |
2891 | ], [ | |
2892 | 0x0017, 0x0010, 0x00B6, 0x0022, 0x016A, 0x02D0, 0x0B48, 0x0077, | |
2893 | 0x1692, 0x0000, 0x0003, 0x0003, 0x0009, 0x000C, 0x0005, 0x0002, | |
2894 | 0x001C, 0x0008, 0x000D, 0x000F, 0x000A, 0x0009, 0x0023, 0x003A, | |
2895 | 0x002C, 0x016B, 0x05A5, 0x02D3, 0x02D1, 0x1693, 0x0076, 0x00B7 | |
2896 | ], [ | |
2897 | 0x001E, 0x0013, 0x00FB, 0x007C, 0x0046, 0x07D6, 0x0FA9, 0x0012, | |
2898 | 0x1F50, 0x0001, 0x0004, 0x0005, 0x000A, 0x000E, 0x0007, 0x0000, | |
2899 | 0x0017, 0x0006, 0x000D, 0x000C, 0x0001, 0x002C, 0x008F, 0x003F, | |
2900 | 0x002D, 0x01F4, 0x07D5, 0x008E, 0x07D7, 0x1F51, 0x0010, 0x0022 | |
2901 | ], [ | |
2902 | 0x0001, 0x002B, 0x0012, 0x0055, 0x0027, 0x03B0, 0x0762, 0x0077, | |
2903 | 0x0261, 0x0002, 0x0006, 0x0007, 0x000B, 0x000F, 0x0008, 0x0000, | |
2904 | 0x001C, 0x0003, 0x0009, 0x0006, 0x0014, 0x0054, 0x0131, 0x0005, | |
2905 | 0x003A, 0x01D9, 0x0099, 0x004D, 0x0763, 0x0260, 0x0008, 0x00ED | |
2906 | ], [ | |
2907 | 0x0004, 0x0033, 0x0060, 0x0065, 0x00C2, 0x030D, 0x0619, 0x0064, | |
2908 | 0x1862, 0x0004, 0x0007, 0x000A, 0x000B, 0x000D, 0x0006, 0x0000, | |
2909 | 0x000F, 0x0003, 0x0005, 0x0002, 0x0002, 0x0077, 0x0C30, 0x0003, | |
2910 | 0x0031, 0x0187, 0x01D9, 0x00ED, 0x01D8, 0x1863, 0x001C, 0x003A | |
2911 | ], [ | |
2912 | 0x0008, 0x000A, 0x006A, 0x0016, 0x001E, 0x034E, 0x069F, 0x0068, | |
2913 | 0x0D28, 0x0005, 0x0007, 0x0007, 0x000C, 0x0000, 0x0006, 0x001B, | |
2914 | 0x0012, 0x0002, 0x0004, 0x0013, 0x000E, 0x034B, 0x1A53, 0x0006, | |
2915 | 0x0017, 0x01A6, 0x069E, 0x01A4, 0x0695, 0x1A52, 0x006B, 0x001F | |
2916 | ], [ | |
2917 | 0x000E, 0x000F, 0x0017, 0x0025, 0x009F, 0x0138, 0x024B, 0x0093, | |
2918 | 0x092A, 0x0005, 0x0000, 0x0008, 0x000D, 0x000F, 0x0006, 0x0004, | |
2919 | 0x000E, 0x0019, 0x0018, 0x000A, 0x009E, 0x0494, 0x1256, 0x0026, | |
2920 | 0x0016, 0x0124, 0x04E5, 0x0273, 0x04E4, 0x1257, 0x0048, 0x009D | |
2921 | ], [ | |
2922 | 0x0004, 0x002C, 0x0050, 0x001E, 0x0071, 0x00E1, 0x00E0, 0x001D, | |
2923 | 0x0006, 0x0007, 0x0006, 0x0007, 0x0005, 0x0006, 0x0015, 0x0000, | |
2924 | 0x0029, 0x0002, 0x0006, 0x0001, 0x0023, 0x001F, 0x0039, 0x0009, | |
2925 | 0x0002, 0x0010, 0x0007, 0x002D, 0x002F, 0x002E, 0x0022, 0x0051 | |
2926 | ], [ | |
2927 | 0x0008, 0x002F, 0x0051, 0x0050, 0x02ED, 0x05D9, 0x05D8, 0x00BA, | |
2928 | 0x005C, 0x0007, 0x0006, 0x0009, 0x0006, 0x0007, 0x0016, 0x0005, | |
2929 | 0x002B, 0x0006, 0x000A, 0x0001, 0x000F, 0x001D, 0x0177, 0x0004, | |
2930 | 0x0001, 0x0004, 0x0001, 0x002A, 0x000B, 0x0029, 0x0000, 0x001C | |
2931 | ], [ | |
2932 | 0x000A, 0x003C, 0x0074, 0x004E, 0x026D, 0x04D9, 0x04D8, 0x009A, | |
2933 | 0x004C, 0x0000, 0x0006, 0x0008, 0x0007, 0x0006, 0x0016, 0x0008, | |
2934 | 0x002E, 0x000A, 0x000B, 0x003D, 0x0024, 0x00EB, 0x0137, 0x001F, | |
2935 | 0x001C, 0x003B, 0x0012, 0x0025, 0x002F, 0x0013, 0x004F, 0x00EA | |
2936 | ], [ | |
2937 | 0x000A, 0x000A, 0x0003, 0x0016, 0x0009, 0x0021, 0x0020, 0x00B3, | |
2938 | 0x0058, 0x0007, 0x0006, 0x0007, 0x0006, 0x0004, 0x0013, 0x0002, | |
2939 | 0x0025, 0x0000, 0x0003, 0x002D, 0x005D, 0x00B2, 0x0011, 0x0008, | |
2940 | 0x0002, 0x0006, 0x0017, 0x002F, 0x0007, 0x0024, 0x005C, 0x0005 | |
2941 | ], [ | |
2942 | 0x000B, 0x0013, 0x001F, 0x0031, 0x0021, 0x0295, 0x0528, 0x00A4, | |
2943 | 0x003C, 0x0000, 0x0007, 0x0006, 0x0005, 0x001B, 0x0012, 0x0032, | |
2944 | 0x001D, 0x002B, 0x0030, 0x001C, 0x003D, 0x014B, 0x0529, 0x0008, | |
2945 | 0x001A, 0x0033, 0x0011, 0x002A, 0x0009, 0x0028, 0x0053, 0x0020 | |
2946 | ], [ | |
2947 | 0x000E, 0x0015, 0x0029, 0x003F, 0x004D, 0x02F1, 0x05E0, 0x0092, | |
2948 | 0x0048, 0x0000, 0x0006, 0x0006, 0x0005, 0x0004, 0x000F, 0x002E, | |
2949 | 0x001D, 0x0028, 0x0027, 0x005F, 0x00BD, 0x0179, 0x05E1, 0x0008, | |
2950 | 0x001E, 0x002D, 0x001C, 0x002C, 0x003E, 0x0025, 0x004C, 0x0093 | |
2951 | ], [ | |
2952 | 0x000C, 0x0017, 0x0035, 0x0013, 0x0021, 0x00AD, 0x06F1, 0x01BD, | |
2953 | 0x00D9, 0x0000, 0x0007, 0x0007, 0x0006, 0x0004, 0x0011, 0x002A, | |
2954 | 0x006E, 0x0025, 0x0024, 0x0057, 0x00D8, 0x0379, 0x06F0, 0x0005, | |
2955 | 0x0016, 0x0029, 0x006D, 0x0028, 0x0034, 0x0020, 0x00DF, 0x00AC | |
2956 | ], [ | |
2957 | 0x0000, 0x001A, 0x0006, 0x0019, 0x0030, 0x005A, 0x018A, 0x02DD, | |
2958 | 0x018B, 0x0001, 0x0007, 0x000A, 0x0009, 0x0002, 0x0010, 0x002E, | |
2959 | 0x006E, 0x002C, 0x000E, 0x005E, 0x00C4, 0x05B9, 0x05B8, 0x0011, | |
2960 | 0x0036, 0x005F, 0x001E, 0x0063, 0x006F, 0x001F, 0x00B6, 0x016F | |
2961 | ] | |
2962 | ]; | |
2963 | const VP40_DC_BITS: [[u8; 32]; 16] = [ | |
2964 | [ | |
2965 | 5, 7, 9, 9, 10, 13, 14, 7, 14, 4, 4, 5, 4, 4, 4, 5, | |
2966 | 5, 4, 4, 3, 3, 4, 4, 6, 7, 8, 12, 11, 10, 10, 7, 8 | |
2967 | ], [ | |
2968 | 5, 7, 8, 7, 9, 11, 11, 7, 12, 4, 3, 4, 4, 4, 4, 5, | |
2969 | 5, 4, 4, 3, 4, 4, 6, 6, 6, 9, 11, 10, 10, 12, 7, 8 | |
2970 | ], [ | |
2971 | 5, 6, 8, 7, 9, 10, 12, 7, 13, 3, 3, 4, 4, 4, 4, 4, | |
2972 | 5, 4, 4, 4, 4, 5, 7, 6, 6, 9, 11, 10, 10, 13, 7, 8 | |
2973 | ], [ | |
2974 | 5, 6, 8, 7, 8, 11, 12, 6, 13, 3, 3, 4, 4, 4, 4, 4, | |
2975 | 5, 4, 4, 4, 4, 6, 9, 6, 6, 9, 11, 9, 11, 13, 6, 7 | |
2976 | ], [ | |
2977 | 4, 6, 7, 7, 8, 10, 11, 7, 12, 3, 3, 4, 4, 4, 4, 4, | |
2978 | 5, 4, 4, 4, 5, 7, 11, 5, 6, 9, 10, 9, 11, 12, 6, 8 | |
2979 | ], [ | |
2980 | 4, 6, 7, 7, 8, 10, 11, 7, 13, 3, 3, 4, 4, 4, 4, 4, | |
2981 | 5, 4, 4, 4, 5, 8, 12, 5, 6, 9, 10, 9, 10, 13, 6, 7 | |
2982 | ], [ | |
2983 | 4, 5, 7, 6, 7, 10, 11, 7, 12, 3, 3, 4, 4, 3, 4, 5, | |
2984 | 5, 4, 4, 5, 6, 10, 13, 5, 6, 9, 11, 9, 11, 13, 7, 7 | |
2985 | ], [ | |
2986 | 4, 5, 6, 6, 8, 9, 10, 8, 12, 3, 2, 4, 4, 4, 4, 4, | |
2987 | 5, 5, 5, 5, 8, 11, 13, 6, 6, 9, 11, 10, 11, 13, 7, 8 | |
2988 | ], [ | |
2989 | 4, 6, 7, 7, 9, 10, 10, 7, 6, 3, 3, 4, 4, 4, 5, 5, | |
2990 | 6, 5, 5, 5, 6, 7, 8, 4, 4, 5, 6, 6, 6, 6, 6, 7 | |
2991 | ], [ | |
2992 | 4, 6, 7, 7, 10, 11, 11, 8, 7, 3, 3, 4, 4, 4, 5, 5, | |
2993 | 6, 5, 5, 5, 6, 7, 9, 4, 4, 5, 6, 6, 5, 6, 6, 7 | |
2994 | ], [ | |
2995 | 4, 6, 7, 7, 10, 11, 11, 8, 7, 2, 3, 4, 4, 4, 5, 5, | |
2996 | 6, 5, 5, 6, 6, 8, 9, 5, 5, 6, 6, 6, 6, 6, 7, 8 | |
2997 | ], [ | |
2998 | 4, 5, 6, 6, 8, 10, 10, 8, 7, 3, 3, 4, 4, 4, 5, 5, | |
2999 | 6, 5, 5, 6, 7, 8, 9, 4, 4, 5, 6, 6, 5, 6, 7, 7 | |
3000 | ], [ | |
3001 | 4, 5, 6, 6, 7, 10, 11, 8, 7, 2, 3, 4, 4, 5, 5, 6, | |
3002 | 6, 6, 6, 6, 7, 9, 11, 4, 5, 6, 6, 6, 5, 6, 7, 7 | |
3003 | ], [ | |
3004 | 4, 5, 6, 6, 7, 10, 11, 8, 7, 2, 3, 4, 4, 4, 5, 6, | |
3005 | 6, 6, 6, 7, 8, 9, 11, 4, 5, 6, 6, 6, 6, 6, 7, 8 | |
3006 | ], [ | |
3007 | 4, 5, 6, 5, 6, 8, 11, 9, 8, 2, 3, 4, 4, 4, 5, 6, | |
3008 | 7, 6, 6, 7, 8, 10, 11, 4, 5, 6, 7, 6, 6, 6, 8, 8 | |
3009 | ], [ | |
3010 | 3, 5, 5, 5, 6, 7, 9, 10, 9, 2, 3, 4, 4, 4, 5, 6, | |
3011 | 7, 6, 6, 7, 8, 11, 11, 5, 6, 7, 7, 7, 7, 7, 8, 9 | |
3012 | ] | |
3013 | ]; | |
3014 | const VP40_AC_CAT0_CODES: [[u32; 32]; 16] = [ | |
3015 | [ | |
3016 | 0x0006, 0x001E, 0x01CC, 0x01CE, 0x0734, 0x1CD5, 0x1CD4, 0x0018, | |
3017 | 0x0E6B, 0x0000, 0x000F, 0x0006, 0x0007, 0x000D, 0x0008, 0x0002, | |
3018 | 0x0019, 0x0005, 0x000B, 0x000A, 0x001D, 0x0027, 0x01CF, 0x0004, | |
3019 | 0x0038, 0x000E, 0x004C, 0x001F, 0x004D, 0x039B, 0x0012, 0x0072 | |
3020 | ], [ | |
3021 | 0x0009, 0x004B, 0x0090, 0x0091, 0x0745, 0x1D11, 0x1D10, 0x0019, | |
3022 | 0x0E89, 0x0000, 0x000F, 0x0008, 0x0007, 0x000D, 0x000B, 0x0002, | |
3023 | 0x001C, 0x0003, 0x000A, 0x0005, 0x0018, 0x0010, 0x01D0, 0x0006, | |
3024 | 0x003B, 0x0011, 0x004A, 0x0049, 0x00E9, 0x03A3, 0x0013, 0x0075 | |
3025 | ], [ | |
3026 | 0x0019, 0x0074, 0x001D, 0x00EA, 0x0073, 0x01CA, 0x0396, 0x001C, | |
3027 | 0x00E4, 0x0002, 0x0001, 0x0007, 0x0008, 0x000D, 0x0009, 0x001F, | |
3028 | 0x0018, 0x0000, 0x0006, 0x001E, 0x003B, 0x00EB, 0x0397, 0x000A, | |
3029 | 0x0002, 0x002C, 0x005B, 0x005A, 0x000F, 0x0038, 0x0017, 0x0006 | |
3030 | ], [ | |
3031 | 0x001E, 0x006F, 0x00AE, 0x00AF, 0x0187, 0x061B, 0x0C35, 0x001A, | |
3032 | 0x030C, 0x0002, 0x0001, 0x0007, 0x0008, 0x000E, 0x0009, 0x001F, | |
3033 | 0x0014, 0x0000, 0x0001, 0x0019, 0x002A, 0x0060, 0x0C34, 0x000B, | |
3034 | 0x000D, 0x0036, 0x006E, 0x0056, 0x0031, 0x00C2, 0x0018, 0x0019 | |
3035 | ], [ | |
3036 | 0x0001, 0x002C, 0x0005, 0x0015, 0x0008, 0x0097, 0x012D, 0x0017, | |
3037 | 0x004A, 0x0003, 0x0002, 0x0009, 0x000A, 0x000E, 0x0008, 0x001F, | |
3038 | 0x0007, 0x001E, 0x001B, 0x0004, 0x005A, 0x0024, 0x012C, 0x000C, | |
3039 | 0x0006, 0x0000, 0x0003, 0x005B, 0x0014, 0x0013, 0x001A, 0x000B | |
3040 | ], [ | |
3041 | 0x0004, 0x0000, 0x0017, 0x0063, 0x018B, 0x0310, 0x0C44, 0x0019, | |
3042 | 0x0623, 0x0004, 0x0003, 0x000A, 0x000B, 0x000D, 0x0003, 0x001C, | |
3043 | 0x0003, 0x000A, 0x0004, 0x0003, 0x018A, 0x188B, 0x188A, 0x000F, | |
3044 | 0x000B, 0x0002, 0x000A, 0x0002, 0x0016, 0x0189, 0x001D, 0x0030 | |
3045 | ], [ | |
3046 | 0x000D, 0x0003, 0x0077, 0x000D, 0x0082, 0x020D, 0x0830, 0x0019, | |
3047 | 0x0419, 0x0003, 0x0002, 0x000A, 0x0009, 0x000B, 0x0002, 0x0011, | |
3048 | 0x0039, 0x0002, 0x0021, 0x0040, 0x1063, 0x20C5, 0x20C4, 0x000F, | |
3049 | 0x0018, 0x0007, 0x0038, 0x000C, 0x0076, 0x0107, 0x0000, 0x003A | |
3050 | ], [ | |
3051 | 0x000F, 0x001C, 0x0036, 0x0008, 0x0061, 0x0091, 0x0243, 0x0009, | |
3052 | 0x0120, 0x0005, 0x0003, 0x0008, 0x0005, 0x0001, 0x0013, 0x0031, | |
3053 | 0x0076, 0x0060, 0x0093, 0x0909, 0x0908, 0x090B, 0x090A, 0x0001, | |
3054 | 0x001A, 0x0019, 0x003A, 0x0025, 0x0077, 0x0092, 0x0000, 0x0037 | |
3055 | ], [ | |
3056 | 0x001F, 0x0079, 0x00F1, 0x00F0, 0x011B, 0x0469, 0x0468, 0x003B, | |
3057 | 0x0022, 0x0005, 0x0004, 0x0007, 0x0005, 0x0006, 0x001C, 0x0001, | |
3058 | 0x0035, 0x003D, 0x003A, 0x0010, 0x0047, 0x008C, 0x0235, 0x0001, | |
3059 | 0x0001, 0x0019, 0x0000, 0x0030, 0x0009, 0x0031, 0x001B, 0x0034 | |
3060 | ], [ | |
3061 | 0x0003, 0x001B, 0x00F3, 0x00FD, 0x03C9, 0x0F20, 0x1E42, 0x003D, | |
3062 | 0x00FC, 0x0006, 0x0004, 0x0002, 0x0000, 0x0001, 0x0017, 0x003E, | |
3063 | 0x001A, 0x0039, 0x002B, 0x0078, 0x01E5, 0x0791, 0x1E43, 0x0002, | |
3064 | 0x0007, 0x001D, 0x000C, 0x0038, 0x0014, 0x007F, 0x0016, 0x002A | |
3065 | ], [ | |
3066 | 0x0007, 0x0039, 0x0051, 0x0078, 0x03CB, 0x0F29, 0x1E51, 0x003D, | |
3067 | 0x00F3, 0x0006, 0x0004, 0x0002, 0x0000, 0x0001, 0x0017, 0x003E, | |
3068 | 0x007F, 0x002B, 0x007E, 0x0050, 0x01E4, 0x0795, 0x1E50, 0x0002, | |
3069 | 0x0006, 0x001D, 0x0006, 0x0038, 0x0007, 0x0029, 0x0016, 0x002A | |
3070 | ], [ | |
3071 | 0x0008, 0x003B, 0x001D, 0x0072, 0x01CC, 0x0734, 0x1CD5, 0x003A, | |
3072 | 0x001C, 0x0006, 0x0005, 0x0002, 0x0001, 0x0000, 0x0012, 0x003E, | |
3073 | 0x007F, 0x001E, 0x007E, 0x00E7, 0x039B, 0x0E6B, 0x1CD4, 0x0002, | |
3074 | 0x0006, 0x001E, 0x000E, 0x0038, 0x0006, 0x000F, 0x0013, 0x001F | |
3075 | ], [ | |
3076 | 0x000D, 0x003F, 0x0073, 0x000C, 0x00E4, 0x072B, 0x0E54, 0x003A, | |
3077 | 0x001A, 0x0005, 0x0004, 0x0002, 0x0001, 0x0000, 0x0007, 0x0038, | |
3078 | 0x0076, 0x0077, 0x001B, 0x01CB, 0x0394, 0x1CAB, 0x1CAA, 0x0002, | |
3079 | 0x0006, 0x001E, 0x000E, 0x003E, 0x0019, 0x001F, 0x0018, 0x001E | |
3080 | ], [ | |
3081 | 0x000E, 0x0007, 0x000C, 0x001C, 0x00BD, 0x02F3, 0x0BC9, 0x001F, | |
3082 | 0x00BF, 0x0006, 0x0004, 0x0002, 0x0001, 0x001E, 0x0001, 0x000D, | |
3083 | 0x003A, 0x003B, 0x00BE, 0x0178, 0x05E5, 0x1791, 0x1790, 0x0002, | |
3084 | 0x0006, 0x001F, 0x0016, 0x0000, 0x0015, 0x002E, 0x0014, 0x001E | |
3085 | ], [ | |
3086 | 0x0000, 0x001B, 0x0031, 0x003A, 0x0060, 0x006F, 0x01B9, 0x000E, | |
3087 | 0x001A, 0x0005, 0x0003, 0x0002, 0x001F, 0x001A, 0x0039, 0x000C, | |
3088 | 0x00C3, 0x00C2, 0x0036, 0x00DD, 0x0370, 0x06E3, 0x06E2, 0x0002, | |
3089 | 0x0008, 0x001E, 0x0019, 0x003B, 0x0012, 0x000F, 0x0013, 0x0038 | |
3090 | ], [ | |
3091 | 0x0002, 0x0000, 0x0003, 0x001C, 0x0032, 0x001C, 0x0199, 0x0004, | |
3092 | 0x00CD, 0x0004, 0x0003, 0x001B, 0x001A, 0x003D, 0x0067, 0x003B, | |
3093 | 0x0198, 0x0075, 0x00E9, 0x03A1, 0x03A0, 0x03A3, 0x03A2, 0x0005, | |
3094 | 0x0002, 0x001F, 0x001D, 0x003C, 0x0018, 0x000F, 0x0006, 0x0005 | |
3095 | ] | |
3096 | ]; | |
3097 | const VP40_AC_CAT0_BITS: [[u8; 32]; 16] = [ | |
3098 | [ | |
3099 | 5, 7, 9, 9, 11, 13, 13, 5, 12, 3, 4, 4, 4, 4, 4, 4, | |
3100 | 5, 4, 4, 4, 5, 6, 9, 4, 6, 6, 7, 7, 7, 10, 5, 7 | |
3101 | ], [ | |
3102 | 5, 7, 8, 8, 11, 13, 13, 5, 12, 3, 4, 4, 4, 4, 4, 4, | |
3103 | 5, 4, 4, 4, 5, 6, 9, 4, 6, 6, 7, 7, 8, 10, 5, 7 | |
3104 | ], [ | |
3105 | 5, 7, 8, 8, 10, 12, 13, 5, 11, 3, 3, 4, 4, 4, 4, 5, | |
3106 | 5, 4, 4, 5, 6, 8, 13, 4, 5, 6, 7, 7, 7, 9, 5, 6 | |
3107 | ], [ | |
3108 | 5, 7, 8, 8, 10, 12, 13, 5, 11, 3, 3, 4, 4, 4, 4, 5, | |
3109 | 5, 4, 4, 5, 6, 8, 13, 4, 5, 6, 7, 7, 7, 9, 5, 6 | |
3110 | ], [ | |
3111 | 4, 6, 7, 7, 8, 12, 13, 5, 11, 3, 3, 4, 4, 4, 4, 5, | |
3112 | 5, 5, 5, 5, 7, 10, 13, 4, 5, 5, 6, 7, 7, 9, 5, 6 | |
3113 | ], [ | |
3114 | 4, 5, 7, 7, 9, 10, 12, 5, 11, 3, 3, 4, 4, 4, 4, 5, | |
3115 | 5, 5, 5, 6, 9, 13, 13, 4, 5, 5, 6, 6, 7, 9, 5, 6 | |
3116 | ], [ | |
3117 | 4, 5, 7, 6, 8, 10, 12, 5, 11, 3, 3, 4, 4, 4, 4, 5, | |
3118 | 6, 5, 6, 7, 13, 14, 14, 4, 5, 5, 6, 6, 7, 9, 4, 6 | |
3119 | ], [ | |
3120 | 4, 5, 6, 5, 7, 8, 10, 5, 9, 3, 3, 4, 4, 4, 5, 6, | |
3121 | 7, 7, 8, 12, 12, 12, 12, 3, 5, 5, 6, 6, 7, 8, 4, 6 | |
3122 | ], [ | |
3123 | 5, 7, 8, 8, 10, 12, 12, 6, 7, 3, 3, 4, 4, 4, 5, 5, | |
3124 | 6, 6, 6, 6, 8, 9, 11, 3, 4, 5, 5, 6, 5, 6, 5, 6 | |
3125 | ], [ | |
3126 | 4, 6, 8, 8, 10, 12, 13, 6, 8, 3, 3, 4, 4, 4, 5, 6, | |
3127 | 6, 6, 6, 7, 9, 11, 13, 3, 4, 5, 5, 6, 5, 7, 5, 6 | |
3128 | ], [ | |
3129 | 4, 6, 7, 7, 10, 12, 13, 6, 8, 3, 3, 4, 4, 4, 5, 6, | |
3130 | 7, 6, 7, 7, 9, 11, 13, 3, 4, 5, 5, 6, 5, 6, 5, 6 | |
3131 | ], [ | |
3132 | 4, 6, 7, 7, 9, 11, 13, 6, 7, 3, 3, 4, 4, 4, 5, 6, | |
3133 | 7, 6, 7, 8, 10, 12, 13, 3, 4, 5, 5, 6, 5, 6, 5, 6 | |
3134 | ], [ | |
3135 | 4, 6, 7, 6, 8, 11, 12, 6, 7, 3, 3, 4, 4, 4, 5, 6, | |
3136 | 7, 7, 7, 9, 10, 13, 13, 3, 4, 5, 5, 6, 5, 6, 5, 6 | |
3137 | ], [ | |
3138 | 4, 5, 6, 6, 8, 10, 12, 6, 8, 3, 3, 4, 4, 5, 5, 6, | |
3139 | 7, 7, 8, 9, 11, 13, 13, 3, 4, 5, 5, 5, 5, 6, 5, 6 | |
3140 | ], [ | |
3141 | 3, 5, 6, 6, 7, 9, 11, 6, 7, 3, 3, 4, 5, 5, 6, 6, | |
3142 | 8, 8, 8, 10, 12, 13, 13, 3, 4, 5, 5, 6, 5, 6, 5, 6 | |
3143 | ], [ | |
3144 | 3, 4, 5, 5, 6, 7, 9, 6, 8, 3, 3, 5, 5, 6, 7, 8, | |
3145 | 9, 9, 10, 12, 12, 12, 12, 3, 4, 5, 5, 6, 5, 6, 5, 6 | |
3146 | ] | |
3147 | ]; | |
3148 | const VP40_AC_CAT1_CODES: [[u32; 32]; 16] = [ | |
3149 | [ | |
3150 | 0x0004, 0x00F5, 0x0182, 0x060F, 0x1839, 0x1838, 0x183B, 0x0013, | |
3151 | 0x00C0, 0x0003, 0x0002, 0x000B, 0x000A, 0x000E, 0x0008, 0x0001, | |
3152 | 0x0012, 0x001F, 0x0000, 0x0006, 0x007B, 0x0306, 0x183A, 0x000D, | |
3153 | 0x0007, 0x0031, 0x000A, 0x0061, 0x003C, 0x00F4, 0x0019, 0x000B | |
3154 | ], [ | |
3155 | 0x000A, 0x001A, 0x01D8, 0x03B3, 0x0ECA, 0x1D96, 0x3B2F, 0x0014, | |
3156 | 0x0036, 0x0004, 0x0003, 0x000C, 0x000B, 0x0000, 0x0004, 0x001C, | |
3157 | 0x0005, 0x0015, 0x0007, 0x0017, 0x0037, 0x0764, 0x3B2E, 0x000F, | |
3158 | 0x001A, 0x003A, 0x000C, 0x0077, 0x0004, 0x00ED, 0x001B, 0x0016 | |
3159 | ], [ | |
3160 | 0x001A, 0x002D, 0x0058, 0x01F4, 0x07D4, 0x1F55, 0x1F54, 0x0014, | |
3161 | 0x0059, 0x0004, 0x0003, 0x000B, 0x000C, 0x000E, 0x0004, 0x0015, | |
3162 | 0x0005, 0x0007, 0x0004, 0x007C, 0x03EB, 0x1F57, 0x1F56, 0x0000, | |
3163 | 0x001B, 0x003F, 0x000D, 0x000C, 0x000A, 0x00FB, 0x001E, 0x0017 | |
3164 | ], [ | |
3165 | 0x0000, 0x0075, 0x004A, 0x0097, 0x025B, 0x0969, 0x0968, 0x000B, | |
3166 | 0x00E8, 0x0005, 0x0004, 0x0007, 0x000C, 0x000D, 0x0001, 0x000A, | |
3167 | 0x0039, 0x003B, 0x0018, 0x00E9, 0x012C, 0x096B, 0x096A, 0x0001, | |
3168 | 0x001F, 0x0008, 0x0019, 0x0013, 0x000D, 0x0024, 0x001E, 0x0038 | |
3169 | ], [ | |
3170 | 0x0004, 0x0014, 0x006E, 0x0057, 0x0159, 0x0562, 0x0AC7, 0x000B, | |
3171 | 0x006F, 0x0006, 0x0005, 0x0008, 0x0009, 0x0007, 0x001E, 0x0002, | |
3172 | 0x0007, 0x0006, 0x002A, 0x00AD, 0x0AC6, 0x0561, 0x0560, 0x0001, | |
3173 | 0x001F, 0x000C, 0x0039, 0x001A, 0x0000, 0x0036, 0x001D, 0x0038 | |
3174 | ], [ | |
3175 | 0x0007, 0x001B, 0x000E, 0x000D, 0x03E1, 0x1F06, 0x3E0F, 0x0002, | |
3176 | 0x00F9, 0x0005, 0x0006, 0x0008, 0x0009, 0x0004, 0x000C, 0x001A, | |
3177 | 0x000F, 0x000C, 0x01F1, 0x07C0, 0x3E0E, 0x1F05, 0x1F04, 0x0001, | |
3178 | 0x0000, 0x001C, 0x003F, 0x003D, 0x0005, 0x007D, 0x001D, 0x003C | |
3179 | ], [ | |
3180 | 0x000F, 0x000A, 0x0071, 0x0006, 0x01C2, 0x0702, 0x1C0E, 0x0002, | |
3181 | 0x000E, 0x0005, 0x0004, 0x0006, 0x0007, 0x001D, 0x0017, 0x000F, | |
3182 | 0x01C3, 0x01C1, 0x0380, 0x381F, 0x381E, 0x1C0D, 0x1C0C, 0x0001, | |
3183 | 0x0004, 0x0018, 0x0001, 0x0000, 0x000D, 0x0016, 0x0019, 0x0039 | |
3184 | ], [ | |
3185 | 0x0002, 0x001E, 0x003B, 0x000D, 0x0061, 0x01FA, 0x1FB5, 0x0031, | |
3186 | 0x00FC, 0x0004, 0x0005, 0x0001, 0x0007, 0x003A, 0x0060, 0x03F7, | |
3187 | 0x07EC, 0x1FB7, 0x3F6C, 0x7EDB, 0x7EDA, 0x3F69, 0x3F68, 0x0001, | |
3188 | 0x0000, 0x0019, 0x003E, 0x0039, 0x000D, 0x0038, 0x000C, 0x007F | |
3189 | ], [ | |
3190 | 0x001E, 0x0070, 0x0127, 0x0126, 0x0492, 0x124D, 0x124C, 0x0001, | |
3191 | 0x007F, 0x0006, 0x0005, 0x0005, 0x0004, 0x0001, 0x0007, 0x0025, | |
3192 | 0x0071, 0x007E, 0x0048, 0x0125, 0x0248, 0x124F, 0x124E, 0x0003, | |
3193 | 0x0008, 0x001D, 0x0006, 0x003E, 0x0002, 0x0000, 0x0013, 0x0039 | |
3194 | ], [ | |
3195 | 0x0001, 0x0001, 0x00E7, 0x0091, 0x0240, 0x120D, 0x120C, 0x003C, | |
3196 | 0x0000, 0x0006, 0x0005, 0x0005, 0x0004, 0x001F, 0x0004, 0x0025, | |
3197 | 0x0072, 0x0049, 0x00E6, 0x0121, 0x0482, 0x120F, 0x120E, 0x0003, | |
3198 | 0x0008, 0x001D, 0x0005, 0x003D, 0x0003, 0x0001, 0x0013, 0x0038 | |
3199 | ], [ | |
3200 | 0x0004, 0x000F, 0x00F4, 0x005B, 0x02D3, 0x0B4A, 0x1697, 0x003C, | |
3201 | 0x000E, 0x0006, 0x0005, 0x0002, 0x0001, 0x001D, 0x0000, 0x007B, | |
3202 | 0x002C, 0x00F5, 0x00B5, 0x0168, 0x1696, 0x0B49, 0x0B48, 0x0003, | |
3203 | 0x0009, 0x001F, 0x000A, 0x0001, 0x0008, 0x0006, 0x001C, 0x0017 | |
3204 | ], [ | |
3205 | 0x0008, 0x0039, 0x001A, 0x0003, 0x00DB, 0x06D6, 0x0DAF, 0x003C, | |
3206 | 0x000C, 0x0006, 0x0005, 0x0002, 0x0001, 0x001D, 0x003D, 0x0000, | |
3207 | 0x0002, 0x0037, 0x006C, 0x01B4, 0x0DAE, 0x06D5, 0x06D4, 0x0002, | |
3208 | 0x0007, 0x001F, 0x0007, 0x0001, 0x0009, 0x000D, 0x000C, 0x0038 | |
3209 | ], [ | |
3210 | 0x000F, 0x0004, 0x002F, 0x002E, 0x0054, 0x0555, 0x0554, 0x0016, | |
3211 | 0x000E, 0x0006, 0x0005, 0x0001, 0x0000, 0x0009, 0x000B, 0x0014, | |
3212 | 0x0057, 0x0056, 0x00AB, 0x0557, 0x0556, 0x02A9, 0x02A8, 0x0003, | |
3213 | 0x0008, 0x0013, 0x000A, 0x0008, 0x000E, 0x0012, 0x0006, 0x000F | |
3214 | ], [ | |
3215 | 0x0001, 0x000E, 0x0006, 0x0004, 0x00DA, 0x0DBE, 0x1B7E, 0x0007, | |
3216 | 0x001A, 0x0005, 0x0004, 0x001C, 0x001B, 0x003A, 0x0037, 0x006C, | |
3217 | 0x01B6, 0x036E, 0x0DBD, 0x36FF, 0x36FE, 0x1B79, 0x1B78, 0x0002, | |
3218 | 0x000C, 0x0000, 0x000F, 0x000C, 0x000F, 0x001A, 0x003B, 0x0005 | |
3219 | ], [ | |
3220 | 0x0005, 0x001E, 0x003A, 0x003E, 0x00FC, 0x0FD7, 0x3F55, 0x0077, | |
3221 | 0x0030, 0x0003, 0x0004, 0x001A, 0x0019, 0x007F, 0x01FB, 0x03F4, | |
3222 | 0x0FD6, 0x1FA9, 0x3F54, 0x3F57, 0x3F56, 0x3F51, 0x3F50, 0x0001, | |
3223 | 0x0004, 0x001C, 0x000B, 0x000A, 0x0000, 0x001B, 0x0031, 0x0076 | |
3224 | ], [ | |
3225 | 0x0005, 0x000C, 0x001B, 0x0008, 0x0038, 0x0015, 0x00A3, 0x00E6, | |
3226 | 0x0004, 0x0001, 0x0002, 0x0012, 0x0003, 0x000B, 0x0029, 0x00A0, | |
3227 | 0x0142, 0x0287, 0x0286, 0x0289, 0x0288, 0x028B, 0x028A, 0x000F, | |
3228 | 0x001D, 0x0013, 0x0001, 0x0000, 0x0003, 0x001A, 0x0072, 0x00E7 | |
3229 | ] | |
3230 | ]; | |
3231 | const VP40_AC_CAT1_BITS: [[u8; 32]; 16] = [ | |
3232 | [ | |
3233 | 5, 8, 9, 11, 13, 13, 13, 5, 8, 3, 3, 4, 4, 4, 4, 4, | |
3234 | 5, 5, 4, 5, 7, 10, 13, 4, 5, 6, 6, 7, 6, 8, 5, 6 | |
3235 | ], [ | |
3236 | 5, 7, 9, 10, 12, 13, 14, 5, 8, 3, 3, 4, 4, 3, 4, 5, | |
3237 | 5, 5, 5, 6, 8, 11, 14, 4, 5, 6, 6, 7, 5, 8, 5, 6 | |
3238 | ], [ | |
3239 | 5, 7, 8, 9, 11, 13, 13, 5, 8, 3, 3, 4, 4, 4, 4, 5, | |
3240 | 5, 5, 5, 7, 10, 13, 13, 3, 5, 6, 6, 6, 5, 8, 5, 6 | |
3241 | ], [ | |
3242 | 4, 7, 8, 9, 11, 13, 13, 5, 8, 3, 3, 4, 4, 4, 4, 5, | |
3243 | 6, 6, 6, 8, 10, 13, 13, 3, 5, 5, 6, 6, 5, 7, 5, 6 | |
3244 | ], [ | |
3245 | 4, 6, 8, 8, 10, 12, 13, 5, 8, 3, 3, 4, 4, 4, 5, 5, | |
3246 | 6, 6, 7, 9, 13, 12, 12, 3, 5, 5, 6, 6, 4, 7, 5, 6 | |
3247 | ], [ | |
3248 | 4, 6, 7, 7, 10, 13, 14, 5, 8, 3, 3, 4, 4, 4, 5, 6, | |
3249 | 7, 7, 9, 11, 14, 13, 13, 3, 4, 5, 6, 6, 4, 7, 5, 6 | |
3250 | ], [ | |
3251 | 4, 5, 7, 6, 9, 11, 13, 5, 7, 3, 3, 4, 4, 5, 6, 7, | |
3252 | 9, 9, 10, 14, 14, 13, 13, 3, 4, 5, 5, 5, 4, 6, 5, 6 | |
3253 | ], [ | |
3254 | 3, 5, 6, 5, 7, 9, 13, 6, 8, 3, 3, 4, 4, 6, 7, 10, | |
3255 | 11, 13, 14, 15, 15, 14, 14, 3, 4, 5, 6, 6, 4, 6, 5, 7 | |
3256 | ], [ | |
3257 | 5, 7, 9, 9, 11, 13, 13, 5, 7, 3, 3, 4, 4, 4, 5, 6, | |
3258 | 7, 7, 7, 9, 10, 13, 13, 3, 4, 5, 5, 6, 4, 5, 5, 6 | |
3259 | ], [ | |
3260 | 4, 6, 8, 8, 10, 13, 13, 6, 6, 3, 3, 4, 4, 5, 5, 6, | |
3261 | 7, 7, 8, 9, 11, 13, 13, 3, 4, 5, 5, 6, 4, 5, 5, 6 | |
3262 | ], [ | |
3263 | 4, 6, 8, 8, 11, 13, 14, 6, 6, 3, 3, 4, 4, 5, 5, 7, | |
3264 | 7, 8, 9, 10, 14, 13, 13, 3, 4, 5, 5, 5, 4, 5, 5, 6 | |
3265 | ], [ | |
3266 | 4, 6, 7, 7, 10, 13, 14, 6, 6, 3, 3, 4, 4, 5, 6, 6, | |
3267 | 7, 8, 9, 11, 14, 13, 13, 3, 4, 5, 5, 5, 4, 5, 5, 6 | |
3268 | ], [ | |
3269 | 4, 5, 7, 7, 9, 13, 13, 6, 6, 3, 3, 4, 4, 5, 6, 7, | |
3270 | 9, 9, 10, 13, 13, 12, 12, 3, 4, 5, 5, 5, 4, 5, 5, 6 | |
3271 | ], [ | |
3272 | 3, 5, 6, 6, 9, 13, 14, 6, 6, 3, 3, 5, 5, 6, 7, 8, | |
3273 | 10, 11, 13, 15, 15, 14, 14, 3, 4, 4, 5, 5, 4, 5, 6, 6 | |
3274 | ], [ | |
3275 | 3, 5, 6, 6, 8, 12, 14, 7, 6, 3, 3, 5, 5, 7, 9, 10, | |
3276 | 12, 13, 14, 14, 14, 14, 14, 3, 4, 5, 5, 5, 3, 5, 6, 7 | |
3277 | ], [ | |
3278 | 3, 4, 5, 4, 6, 8, 11, 8, 6, 3, 3, 5, 5, 7, 9, 11, | |
3279 | 12, 13, 13, 13, 13, 13, 13, 4, 5, 5, 5, 5, 3, 5, 7, 8 | |
3280 | ] | |
3281 | ]; | |
3282 | const VP40_AC_CAT2_CODES: [[u32; 32]; 16] = [ | |
3283 | [ | |
3284 | 0x0009, 0x0015, 0x0028, 0x0052, 0x029A, 0x0537, 0x0536, 0x000A, | |
3285 | 0x0054, 0x0004, 0x0003, 0x000C, 0x000B, 0x000D, 0x0003, 0x0014, | |
3286 | 0x003A, 0x0004, 0x0038, 0x0055, 0x00A7, 0x0299, 0x0298, 0x0000, | |
3287 | 0x001E, 0x0008, 0x002B, 0x000B, 0x000B, 0x003B, 0x001F, 0x0039 | |
3288 | ], [ | |
3289 | 0x001D, 0x002F, 0x0002, 0x0007, 0x0019, 0x0035, 0x0034, 0x0009, | |
3290 | 0x002E, 0x0006, 0x0005, 0x0009, 0x0008, 0x0007, 0x001F, 0x0008, | |
3291 | 0x0018, 0x0019, 0x0001, 0x0000, 0x0018, 0x0037, 0x0036, 0x0001, | |
3292 | 0x0001, 0x000A, 0x0039, 0x0016, 0x000D, 0x0001, 0x001E, 0x0038 | |
3293 | ], [ | |
3294 | 0x0001, 0x0071, 0x00E0, 0x01C3, 0x0708, 0x1C26, 0x384F, 0x0001, | |
3295 | 0x0031, 0x0006, 0x0005, 0x0009, 0x0008, 0x0005, 0x000F, 0x0039, | |
3296 | 0x0077, 0x0076, 0x0030, 0x0385, 0x384E, 0x1C25, 0x1C24, 0x0001, | |
3297 | 0x0004, 0x000D, 0x0000, 0x0019, 0x001F, 0x000E, 0x001E, 0x003A | |
3298 | ], [ | |
3299 | 0x0006, 0x000C, 0x00D6, 0x007B, 0x01E8, 0x07A4, 0x0F4B, 0x0036, | |
3300 | 0x006A, 0x0007, 0x0005, 0x0008, 0x0009, 0x0001, 0x0007, 0x000D, | |
3301 | 0x003C, 0x00D7, 0x00F5, 0x07A7, 0x0F4A, 0x0F4D, 0x0F4C, 0x0002, | |
3302 | 0x0002, 0x000E, 0x0037, 0x0034, 0x0000, 0x0019, 0x0018, 0x001F | |
3303 | ], [ | |
3304 | 0x000A, 0x0027, 0x00BF, 0x00BE, 0x0224, 0x225D, 0x225C, 0x0026, | |
3305 | 0x005E, 0x0007, 0x0006, 0x0006, 0x0007, 0x0016, 0x002E, 0x0045, | |
3306 | 0x0088, 0x0113, 0x044A, 0x225F, 0x225E, 0x112D, 0x112C, 0x0002, | |
3307 | 0x0002, 0x0012, 0x0003, 0x0002, 0x0003, 0x0000, 0x0010, 0x0023 | |
3308 | ], [ | |
3309 | 0x000F, 0x0006, 0x0075, 0x0074, 0x000A, 0x00BF, 0x00B9, 0x0022, | |
3310 | 0x0003, 0x0005, 0x0006, 0x0001, 0x0002, 0x0007, 0x0000, 0x0004, | |
3311 | 0x0016, 0x005E, 0x00B8, 0x00BB, 0x00BA, 0x017D, 0x017C, 0x0002, | |
3312 | 0x0006, 0x001C, 0x0010, 0x003B, 0x0009, 0x0007, 0x0001, 0x0023 | |
3313 | ], [ | |
3314 | 0x0001, 0x001C, 0x0036, 0x003B, 0x00EA, 0x075B, 0x1D65, 0x0019, | |
3315 | 0x0074, 0x0004, 0x0005, 0x0000, 0x0001, 0x0037, 0x01D7, 0x075A, | |
3316 | 0x1D64, 0x1D67, 0x1D66, 0x1D61, 0x1D60, 0x1D63, 0x1D62, 0x0002, | |
3317 | 0x001F, 0x001A, 0x000D, 0x003D, 0x000C, 0x0007, 0x003C, 0x0018 | |
3318 | ], [ | |
3319 | 0x0002, 0x0001, 0x0014, 0x0000, 0x002F, 0x00BB, 0x02E4, 0x007D, | |
3320 | 0x00BA, 0x0003, 0x0004, 0x0016, 0x001A, 0x00B8, 0x172E, 0x2E5F, | |
3321 | 0x2E5E, 0x1729, 0x1728, 0x172B, 0x172A, 0x172D, 0x172C, 0x0001, | |
3322 | 0x001E, 0x0015, 0x001B, 0x003F, 0x000C, 0x000E, 0x007C, 0x0173 | |
3323 | ], [ | |
3324 | 0x0003, 0x007B, 0x0058, 0x01EA, 0x1EB1, 0x1EB0, 0x1EB3, 0x0013, | |
3325 | 0x0012, 0x0005, 0x0006, 0x0002, 0x0001, 0x0013, 0x003C, 0x002D, | |
3326 | 0x00F4, 0x0059, 0x03D7, 0x0F5B, 0x1EB2, 0x1EB5, 0x1EB4, 0x0003, | |
3327 | 0x000E, 0x001F, 0x0012, 0x0008, 0x0008, 0x0000, 0x000A, 0x0017 | |
3328 | ], [ | |
3329 | 0x0008, 0x003C, 0x00F5, 0x00F4, 0x1EF7, 0x3DE9, 0x3DE8, 0x001C, | |
3330 | 0x000D, 0x0005, 0x0006, 0x0001, 0x0000, 0x0007, 0x000C, 0x00F6, | |
3331 | 0x01EE, 0x03DF, 0x07BC, 0x3DEB, 0x3DEA, 0x3DED, 0x3DEC, 0x0002, | |
3332 | 0x0009, 0x001F, 0x000F, 0x0005, 0x000E, 0x0006, 0x0004, 0x001D | |
3333 | ], [ | |
3334 | 0x0009, 0x0039, 0x0019, 0x0018, 0x0706, 0x383D, 0x383C, 0x000D, | |
3335 | 0x000F, 0x0005, 0x0006, 0x0000, 0x001D, 0x0003, 0x0071, 0x00E1, | |
3336 | 0x01C0, 0x0382, 0x1C1D, 0x383F, 0x383E, 0x3839, 0x3838, 0x0002, | |
3337 | 0x0008, 0x0002, 0x000D, 0x000C, 0x000F, 0x0007, 0x0002, 0x000E | |
3338 | ], [ | |
3339 | 0x0000, 0x0006, 0x0035, 0x0034, 0x0777, 0x1DD4, 0x3BAB, 0x000E, | |
3340 | 0x000F, 0x0005, 0x0004, 0x001C, 0x0019, 0x003A, 0x00EF, 0x01DC, | |
3341 | 0x0776, 0x0774, 0x3BAA, 0x3BAD, 0x3BAC, 0x3BAF, 0x3BAE, 0x0002, | |
3342 | 0x0007, 0x0002, 0x0018, 0x000C, 0x000F, 0x000D, 0x001B, 0x0076 | |
3343 | ], [ | |
3344 | 0x0002, 0x0011, 0x0006, 0x004F, 0x0130, 0x1319, 0x1318, 0x004E, | |
3345 | 0x0007, 0x0006, 0x0005, 0x0010, 0x000D, 0x0005, 0x0099, 0x0262, | |
3346 | 0x098E, 0x131B, 0x131A, 0x263D, 0x263C, 0x263F, 0x263E, 0x0001, | |
3347 | 0x0007, 0x0000, 0x0012, 0x000C, 0x000E, 0x000F, 0x0004, 0x004D | |
3348 | ], [ | |
3349 | 0x0003, 0x0000, 0x0002, 0x0037, 0x01B7, 0x0DB5, 0x36DD, 0x006C, | |
3350 | 0x0016, 0x0005, 0x0004, 0x0003, 0x000A, 0x002E, 0x036C, 0x0DB4, | |
3351 | 0x36DC, 0x36DF, 0x36DE, 0x36D9, 0x36D8, 0x36DB, 0x36DA, 0x000E, | |
3352 | 0x0004, 0x001A, 0x0019, 0x0018, 0x000F, 0x0001, 0x002F, 0x00DA | |
3353 | ], [ | |
3354 | 0x0006, 0x0006, 0x000F, 0x0000, 0x0075, 0x03B8, 0x1DCA, 0x0074, | |
3355 | 0x0076, 0x0004, 0x0005, 0x0003, 0x0002, 0x01DE, 0x0EE6, 0x3B97, | |
3356 | 0x3B96, 0x3B9D, 0x3B9C, 0x3B9F, 0x3B9E, 0x1DC9, 0x1DC8, 0x0005, | |
3357 | 0x001C, 0x0009, 0x000E, 0x0008, 0x000F, 0x0001, 0x01DF, 0x01DD | |
3358 | ], [ | |
3359 | 0x0004, 0x000B, 0x001D, 0x000C, 0x0014, 0x00E0, 0x3875, 0x0386, | |
3360 | 0x01C2, 0x0000, 0x0001, 0x0071, 0x0072, 0x1C3F, 0x3874, 0x3877, | |
3361 | 0x3876, 0x3871, 0x3870, 0x3873, 0x3872, 0x3879, 0x3878, 0x003C, | |
3362 | 0x0073, 0x002A, 0x003D, 0x002B, 0x001F, 0x000D, 0x1C3E, 0x1C3D | |
3363 | ] | |
3364 | ]; | |
3365 | const VP40_AC_CAT2_BITS: [[u8; 32]; 16] = [ | |
3366 | [ | |
3367 | 5, 7, 8, 9, 12, 13, 13, 5, 7, 3, 3, 4, 4, 4, 4, 5, | |
3368 | 6, 5, 6, 7, 10, 12, 12, 3, 5, 5, 6, 6, 5, 6, 5, 6 | |
3369 | ], [ | |
3370 | 5, 7, 8, 9, 11, 12, 12, 5, 7, 3, 3, 4, 4, 4, 5, 5, | |
3371 | 6, 6, 6, 7, 11, 12, 12, 3, 4, 5, 6, 6, 5, 5, 5, 6 | |
3372 | ], [ | |
3373 | 4, 7, 8, 9, 11, 13, 14, 5, 7, 3, 3, 4, 4, 4, 5, 6, | |
3374 | 7, 7, 7, 10, 14, 13, 13, 3, 4, 5, 5, 6, 5, 5, 5, 6 | |
3375 | ], [ | |
3376 | 4, 6, 8, 8, 10, 12, 13, 6, 7, 3, 3, 4, 4, 4, 5, 6, | |
3377 | 7, 8, 9, 12, 13, 13, 13, 3, 4, 5, 6, 6, 4, 5, 5, 6 | |
3378 | ], [ | |
3379 | 4, 6, 8, 8, 10, 14, 14, 6, 7, 3, 3, 4, 4, 5, 6, 7, | |
3380 | 8, 9, 11, 14, 14, 13, 13, 3, 4, 5, 5, 5, 4, 4, 5, 6 | |
3381 | ], [ | |
3382 | 4, 5, 7, 7, 9, 13, 13, 6, 7, 3, 3, 4, 4, 5, 6, 8, | |
3383 | 10, 12, 13, 13, 13, 14, 14, 3, 4, 5, 5, 6, 4, 4, 5, 6 | |
3384 | ], [ | |
3385 | 3, 5, 6, 6, 8, 11, 13, 6, 7, 3, 3, 4, 4, 6, 9, 11, | |
3386 | 13, 13, 13, 13, 13, 13, 13, 3, 5, 5, 5, 6, 4, 4, 6, 6 | |
3387 | ], [ | |
3388 | 3, 4, 5, 4, 6, 8, 10, 7, 8, 3, 3, 5, 5, 8, 13, 14, | |
3389 | 14, 13, 13, 13, 13, 13, 13, 3, 5, 5, 5, 6, 4, 4, 7, 9 | |
3390 | ], [ | |
3391 | 4, 7, 8, 9, 13, 13, 13, 6, 6, 3, 3, 4, 4, 5, 6, 7, | |
3392 | 8, 8, 10, 12, 13, 13, 13, 3, 4, 5, 5, 5, 4, 4, 5, 6 | |
3393 | ], [ | |
3394 | 4, 6, 8, 8, 13, 14, 14, 6, 6, 3, 3, 4, 4, 5, 6, 8, | |
3395 | 9, 10, 11, 14, 14, 14, 14, 3, 4, 5, 5, 5, 4, 4, 5, 6 | |
3396 | ], [ | |
3397 | 4, 6, 7, 7, 11, 14, 14, 6, 6, 3, 3, 4, 5, 5, 7, 8, | |
3398 | 9, 10, 13, 14, 14, 14, 14, 3, 4, 4, 5, 5, 4, 4, 5, 6 | |
3399 | ], [ | |
3400 | 3, 5, 7, 7, 11, 13, 14, 6, 6, 3, 3, 5, 5, 6, 8, 9, | |
3401 | 11, 11, 14, 14, 14, 14, 14, 3, 4, 4, 5, 5, 4, 4, 6, 7 | |
3402 | ], [ | |
3403 | 3, 5, 6, 7, 9, 13, 13, 7, 6, 3, 3, 5, 5, 6, 8, 10, | |
3404 | 12, 13, 13, 14, 14, 14, 14, 3, 4, 4, 5, 5, 4, 4, 6, 7 | |
3405 | ], [ | |
3406 | 3, 4, 5, 6, 9, 12, 14, 7, 6, 3, 3, 5, 5, 7, 10, 12, | |
3407 | 14, 14, 14, 14, 14, 14, 14, 4, 4, 5, 5, 5, 4, 3, 7, 8 | |
3408 | ], [ | |
3409 | 3, 4, 5, 4, 7, 10, 13, 7, 7, 3, 3, 5, 5, 9, 12, 14, | |
3410 | 14, 14, 14, 14, 14, 13, 13, 4, 5, 5, 5, 5, 4, 3, 9, 9 | |
3411 | ], [ | |
3412 | 3, 4, 5, 4, 5, 8, 14, 10, 9, 2, 2, 7, 7, 13, 14, 14, | |
3413 | 14, 14, 14, 14, 14, 14, 14, 6, 7, 6, 6, 6, 5, 4, 13, 13 | |
3414 | ] | |
3415 | ]; | |
3416 | const VP40_AC_CAT3_CODES: [[u32; 32]; 16] = [ | |
3417 | [ | |
3418 | 0x0007, 0x000F, 0x00BB, 0x00BA, 0x05CF, 0x173A, 0x2E77, 0x0029, | |
3419 | 0x0172, 0x0007, 0x0006, 0x0009, 0x0008, 0x0001, 0x0005, 0x000D, | |
3420 | 0x001D, 0x001C, 0x00B8, 0x02E6, 0x2E76, 0x1739, 0x1738, 0x0002, | |
3421 | 0x0006, 0x0016, 0x0004, 0x0028, 0x0015, 0x000C, 0x0000, 0x002F | |
3422 | ], [ | |
3423 | 0x000B, 0x0002, 0x0054, 0x002F, 0x02AC, 0x156B, 0x1568, 0x0016, | |
3424 | 0x0154, 0x0007, 0x0006, 0x0004, 0x0003, 0x0013, 0x0028, 0x002E, | |
3425 | 0x0157, 0x0155, 0x055B, 0x2AD3, 0x2AD2, 0x2AD5, 0x2AD4, 0x0003, | |
3426 | 0x0008, 0x0000, 0x000A, 0x0003, 0x0002, 0x002B, 0x0012, 0x0029 | |
3427 | ], [ | |
3428 | 0x000F, 0x0007, 0x0001, 0x0000, 0x01C4, 0x0703, 0x0E02, 0x0011, | |
3429 | 0x00E1, 0x0005, 0x0006, 0x0002, 0x0001, 0x0009, 0x0010, 0x00E3, | |
3430 | 0x01C5, 0x01C1, 0x0702, 0x1C07, 0x1C06, 0x0E01, 0x0E00, 0x0004, | |
3431 | 0x0007, 0x001D, 0x000D, 0x0001, 0x0005, 0x0006, 0x000C, 0x0039 | |
3432 | ], [ | |
3433 | 0x0001, 0x001C, 0x0011, 0x0013, 0x0042, 0x0207, 0x0815, 0x0075, | |
3434 | 0x0041, 0x0005, 0x0006, 0x0000, 0x001F, 0x003B, 0x0074, 0x0043, | |
3435 | 0x0080, 0x0206, 0x0814, 0x0817, 0x0816, 0x0409, 0x0408, 0x0003, | |
3436 | 0x0009, 0x001E, 0x0011, 0x0003, 0x0005, 0x0010, 0x0002, 0x0012 | |
3437 | ], [ | |
3438 | 0x0001, 0x001F, 0x0027, 0x0001, 0x004B, 0x0123, 0x0915, 0x0000, | |
3439 | 0x0049, 0x0005, 0x0006, 0x001D, 0x001C, 0x0013, 0x004A, 0x0090, | |
3440 | 0x0914, 0x0917, 0x0916, 0x0911, 0x0910, 0x0913, 0x0912, 0x0003, | |
3441 | 0x0005, 0x0001, 0x0012, 0x0008, 0x0008, 0x001E, 0x0026, 0x0001 | |
3442 | ], [ | |
3443 | 0x0003, 0x0001, 0x003F, 0x000B, 0x004E, 0x0132, 0x099A, 0x004F, | |
3444 | 0x0098, 0x0006, 0x0005, 0x001D, 0x001C, 0x007C, 0x0267, 0x1331, | |
3445 | 0x1330, 0x1333, 0x1332, 0x266D, 0x266C, 0x266F, 0x266E, 0x0001, | |
3446 | 0x0004, 0x001E, 0x0012, 0x000A, 0x0008, 0x0000, 0x007D, 0x004D | |
3447 | ], [ | |
3448 | 0x0002, 0x0007, 0x0015, 0x0003, 0x0004, 0x00A7, 0x0536, 0x0028, | |
3449 | 0x029A, 0x0006, 0x0004, 0x001C, 0x0017, 0x00A4, 0x29BE, 0x537F, | |
3450 | 0x537E, 0x29B9, 0x29B8, 0x29BB, 0x29BA, 0x29BD, 0x29BC, 0x000F, | |
3451 | 0x0000, 0x0005, 0x0016, 0x001D, 0x0006, 0x0001, 0x00A5, 0x014C | |
3452 | ], [ | |
3453 | 0x0004, 0x0007, 0x001A, 0x000C, 0x0006, 0x0029, 0x01BD, 0x1BE3, | |
3454 | 0x1BE0, 0x0000, 0x0007, 0x006E, 0x01BC, 0x37C3, 0x37C2, 0x37CD, | |
3455 | 0x37CC, 0x37CF, 0x37CE, 0x37C9, 0x37C8, 0x37CB, 0x37CA, 0x0015, | |
3456 | 0x01BF, 0x037D, 0x0036, 0x0002, 0x000B, 0x0028, 0x37C5, 0x37C4 | |
3457 | ], [ | |
3458 | 0x0001, 0x0009, 0x0003, 0x0002, 0x011F, 0x08E9, 0x08E8, 0x002D, | |
3459 | 0x0022, 0x0006, 0x0007, 0x0010, 0x0011, 0x0017, 0x002C, 0x0046, | |
3460 | 0x011E, 0x011C, 0x0477, 0x08EB, 0x08EA, 0x08ED, 0x08EC, 0x0003, | |
3461 | 0x000B, 0x0001, 0x0014, 0x000A, 0x0009, 0x0015, 0x0000, 0x0010 | |
3462 | ], [ | |
3463 | 0x0001, 0x001D, 0x0022, 0x0013, 0x011E, 0x08FC, 0x23F5, 0x0023, | |
3464 | 0x0022, 0x0005, 0x0006, 0x0010, 0x000B, 0x0010, 0x008E, 0x023E, | |
3465 | 0x08FF, 0x11FD, 0x23F4, 0x23F7, 0x23F6, 0x23F9, 0x23F8, 0x0003, | |
3466 | 0x0009, 0x0000, 0x001C, 0x000A, 0x000F, 0x0001, 0x0012, 0x0046 | |
3467 | ], [ | |
3468 | 0x0003, 0x001F, 0x003C, 0x003D, 0x0086, 0x0877, 0x10E8, 0x0041, | |
3469 | 0x0040, 0x0005, 0x0006, 0x0007, 0x0006, 0x0004, 0x010F, 0x021C, | |
3470 | 0x0875, 0x21D3, 0x21D2, 0x21D9, 0x21D8, 0x21DB, 0x21DA, 0x0002, | |
3471 | 0x0009, 0x0000, 0x0011, 0x0003, 0x000E, 0x0002, 0x0005, 0x0042 | |
3472 | ], [ | |
3473 | 0x0004, 0x0001, 0x003D, 0x0009, 0x00F3, 0x0793, 0x1E45, 0x0000, | |
3474 | 0x0002, 0x0005, 0x0006, 0x0008, 0x0001, 0x0003, 0x01E5, 0x0792, | |
3475 | 0x1E44, 0x1E47, 0x1E46, 0x1E41, 0x1E40, 0x1E43, 0x1E42, 0x0001, | |
3476 | 0x0006, 0x001F, 0x000F, 0x000E, 0x000E, 0x0005, 0x0078, 0x0001 | |
3477 | ], [ | |
3478 | 0x0004, 0x0005, 0x000E, 0x0017, 0x003E, 0x00F0, 0x0F1E, 0x007A, | |
3479 | 0x007F, 0x0006, 0x0007, 0x0005, 0x0004, 0x007B, 0x01E2, 0x1E3F, | |
3480 | 0x1E3E, 0x0F19, 0x0F18, 0x0F1B, 0x0F1A, 0x0F1D, 0x0F1C, 0x0000, | |
3481 | 0x0003, 0x0016, 0x0009, 0x0008, 0x000A, 0x0006, 0x007E, 0x0079 | |
3482 | ], [ | |
3483 | 0x0005, 0x000C, 0x001A, 0x0004, 0x001A, 0x00DE, 0x0DF4, 0x00DD, | |
3484 | 0x006D, 0x0000, 0x0007, 0x0025, 0x0024, 0x00DC, 0x0DF7, 0x1BEB, | |
3485 | 0x1BEA, 0x0DF1, 0x0DF0, 0x0DF3, 0x0DF2, 0x1BED, 0x1BEC, 0x0008, | |
3486 | 0x0013, 0x000C, 0x0037, 0x0036, 0x0005, 0x0007, 0x006C, 0x01BF | |
3487 | ], [ | |
3488 | 0x0005, 0x000D, 0x001F, 0x000C, 0x003B, 0x0040, 0x041A, 0x0104, | |
3489 | 0x0107, 0x0001, 0x0000, 0x0024, 0x0021, 0x020B, 0x106E, 0x20DF, | |
3490 | 0x20DE, 0x1055, 0x1054, 0x1057, 0x1056, 0x106D, 0x106C, 0x0011, | |
3491 | 0x003A, 0x0025, 0x0038, 0x0039, 0x0013, 0x001E, 0x020C, 0x0414 | |
3492 | ], [ | |
3493 | 0x0000, 0x0007, 0x000D, 0x0005, 0x0009, 0x0022, 0x0CD1, 0x0CD0, | |
3494 | 0x0CD3, 0x0003, 0x0002, 0x008D, 0x00CC, 0x066B, 0x0CD2, 0x19B5, | |
3495 | 0x19B4, 0x19B7, 0x19B6, 0x19B1, 0x19B0, 0x19B3, 0x19B2, 0x0047, | |
3496 | 0x008C, 0x0337, 0x0067, 0x0018, 0x0010, 0x0032, 0x0CD5, 0x0CD4 | |
3497 | ] | |
3498 | ]; | |
3499 | const VP40_AC_CAT3_BITS: [[u8; 32]; 16] = [ | |
3500 | [ | |
3501 | 4, 6, 8, 8, 11, 13, 14, 6, 9, 3, 3, 4, 4, 4, 5, 6, | |
3502 | 7, 7, 8, 10, 14, 13, 13, 3, 4, 5, 5, 6, 5, 6, 4, 6 | |
3503 | ], [ | |
3504 | 4, 5, 7, 7, 10, 13, 13, 6, 9, 3, 3, 4, 4, 5, 6, 7, | |
3505 | 9, 9, 11, 14, 14, 14, 14, 3, 4, 4, 5, 5, 4, 6, 5, 6 | |
3506 | ], [ | |
3507 | 4, 5, 6, 6, 9, 11, 12, 6, 8, 3, 3, 4, 4, 5, 6, 8, | |
3508 | 9, 9, 11, 13, 13, 12, 12, 3, 4, 5, 5, 5, 4, 5, 5, 6 | |
3509 | ], [ | |
3510 | 3, 5, 6, 6, 8, 11, 13, 7, 8, 3, 3, 4, 5, 6, 7, 8, | |
3511 | 9, 11, 13, 13, 13, 12, 12, 3, 4, 5, 5, 5, 4, 5, 5, 6 | |
3512 | ], [ | |
3513 | 3, 5, 6, 5, 8, 10, 13, 6, 8, 3, 3, 5, 5, 6, 8, 9, | |
3514 | 13, 13, 13, 13, 13, 13, 13, 3, 4, 4, 5, 5, 4, 5, 6, 6 | |
3515 | ], [ | |
3516 | 3, 4, 6, 5, 7, 9, 12, 7, 8, 3, 3, 5, 5, 7, 10, 13, | |
3517 | 13, 13, 13, 14, 14, 14, 14, 3, 4, 5, 5, 5, 4, 4, 7, 7 | |
3518 | ], [ | |
3519 | 3, 4, 5, 4, 5, 8, 11, 6, 10, 3, 3, 5, 5, 8, 14, 15, | |
3520 | 15, 14, 14, 14, 14, 14, 14, 4, 4, 5, 5, 5, 4, 4, 8, 9 | |
3521 | ], [ | |
3522 | 3, 4, 5, 4, 4, 6, 9, 13, 13, 2, 3, 7, 9, 14, 14, 14, | |
3523 | 14, 14, 14, 14, 14, 14, 14, 5, 9, 10, 6, 3, 4, 6, 14, 14 | |
3524 | ], [ | |
3525 | 3, 5, 6, 6, 10, 13, 13, 7, 7, 3, 3, 5, 5, 6, 7, 8, | |
3526 | 10, 10, 12, 13, 13, 13, 13, 3, 4, 4, 5, 5, 4, 5, 5, 6 | |
3527 | ], [ | |
3528 | 3, 5, 6, 6, 9, 12, 14, 7, 7, 3, 3, 5, 5, 6, 8, 10, | |
3529 | 12, 13, 14, 14, 14, 14, 14, 3, 4, 4, 5, 5, 4, 4, 6, 7 | |
3530 | ], [ | |
3531 | 3, 5, 6, 6, 8, 12, 13, 7, 7, 3, 3, 5, 5, 6, 9, 10, | |
3532 | 12, 14, 14, 14, 14, 14, 14, 3, 4, 4, 5, 5, 4, 4, 6, 7 | |
3533 | ], [ | |
3534 | 3, 4, 6, 5, 8, 11, 13, 7, 7, 3, 3, 5, 5, 7, 9, 11, | |
3535 | 13, 13, 13, 13, 13, 13, 13, 3, 4, 5, 5, 5, 4, 4, 7, 7 | |
3536 | ], [ | |
3537 | 3, 4, 5, 5, 7, 9, 13, 8, 8, 3, 3, 5, 5, 8, 10, 14, | |
3538 | 14, 13, 13, 13, 13, 13, 13, 3, 4, 5, 5, 5, 4, 4, 8, 8 | |
3539 | ], [ | |
3540 | 3, 4, 5, 4, 6, 9, 13, 9, 8, 2, 3, 6, 6, 9, 13, 14, | |
3541 | 14, 13, 13, 13, 13, 14, 14, 4, 5, 5, 6, 6, 4, 4, 8, 10 | |
3542 | ], [ | |
3543 | 3, 4, 5, 4, 6, 7, 11, 9, 9, 2, 2, 6, 6, 10, 13, 14, | |
3544 | 14, 13, 13, 13, 13, 13, 13, 5, 6, 6, 6, 6, 5, 5, 10, 11 | |
3545 | ], [ | |
3546 | 2, 4, 5, 4, 5, 7, 13, 13, 13, 2, 2, 9, 9, 12, 13, 14, | |
3547 | 14, 14, 14, 14, 14, 14, 14, 8, 9, 11, 8, 6, 6, 7, 13, 13 | |
3548 | ] | |
3549 | ]; | |
3550 | ||
3551 | const VP40_QMAT: &[i16; 64] = &[ | |
3552 | 16, 17, 18, 20, 22, 24, 26, 28, | |
3553 | 17, 18, 20, 22, 24, 26, 28, 32, | |
3554 | 18, 20, 22, 24, 26, 28, 32, 36, | |
3555 | 20, 22, 24, 26, 28, 32, 36, 40, | |
3556 | 22, 24, 26, 28, 32, 36, 40, 44, | |
3557 | 24, 26, 28, 32, 36, 40, 44, 48, | |
3558 | 26, 28, 32, 36, 40, 44, 48, 52, | |
3559 | 28, 32, 36, 40, 44, 48, 52, 56 | |
3560 | ]; | |
3561 | const VP40_DC_Y_SCALES: [i16; 64] = [ | |
3562 | 180, 180, 180, 180, 180, 180, 175, 170, | |
3563 | 165, 160, 157, 155, 152, 150, 147, 145, | |
3564 | 142, 140, 137, 135, 132, 130, 127, 125, | |
3565 | 122, 120, 117, 115, 112, 110, 107, 105, | |
3566 | 102, 100, 97, 95, 92, 90, 87, 85, | |
3567 | 82, 80, 77, 75, 72, 70, 67, 65, | |
3568 | 62, 60, 57, 55, 52, 50, 47, 45, | |
3569 | 42, 40, 37, 35, 32, 30, 27, 25 | |
3570 | ]; | |
3571 | const VP40_DC_C_SCALES: [i16; 64] = [ | |
3572 | 150, 150, 150, 150, 150, 150, 150, 150, | |
3573 | 150, 150, 150, 150, 150, 150, 147, 145, | |
3574 | 142, 140, 137, 135, 132, 130, 127, 125, | |
3575 | 122, 120, 117, 115, 112, 110, 107, 105, | |
3576 | 102, 100, 97, 95, 92, 90, 87, 85, | |
3577 | 82, 80, 77, 75, 72, 70, 67, 65, | |
3578 | 62, 60, 57, 55, 52, 50, 47, 45, | |
3579 | 42, 40, 37, 35, 32, 30, 27, 25 | |
3580 | ]; | |
3581 | const VP40_AC_SCALES: [i16; 64] = [ | |
3582 | 500, 475, 450, 430, 410, 390, 370, 350, | |
3583 | 330, 315, 300, 285, 270, 260, 250, 240, | |
3584 | 230, 220, 210, 200, 190, 185, 180, 170, | |
3585 | 160, 150, 143, 135, 128, 120, 113, 106, | |
3586 | 100, 94, 90, 85, 80, 75, 70, 66, | |
3587 | 62, 57, 52, 49, 45, 41, 38, 35, | |
3588 | 33, 30, 27, 24, 22, 20, 18, 16, | |
3589 | 14, 12, 10, 9, 7, 6, 4, 1 | |
3590 | ]; | |
3591 | ||
3592 | const VP40_MBPAT_CODES: [[u8; 14]; 2] = [ | |
3593 | [ 0b000, 0b1111, 0b1001, 0b010, 0b1101, 0b01110, 0b1011, 0b001, 0b01111, 0b1000, 0b0110, 0b1110, 0b1100, 0b1010 ], | |
3594 | [ 0b0111, 0b1010, 0b1001, 0b1100, 0b1000, 0b01101, 0b000, 0b1110, 0b01100, 0b1101, 0b001, 0b1011, 0b1111, 0b010 ] | |
3595 | ]; | |
3596 | const VP40_MBPAT_BITS: [[u8; 14]; 2] = [ | |
3597 | [ 3, 4, 4, 3, 4, 5, 4, 3, 5, 4, 4, 4, 4, 4 ], | |
3598 | [ 4, 4, 4, 4, 4, 5, 3, 4, 5, 4, 3, 4, 4, 3 ] | |
3599 | ]; | |
3600 | const VP40_BP_PREDICTOR: [u8; 15] = [ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1 ]; | |
3601 | const VP40_MV_X_CODES: [[u32; 63]; 7] = [ | |
3602 | [ | |
3603 | 0x06A, 0x11A, 0x18E, 0x237, 0x04A, 0x236, 0x07A, 0x0D6, | |
3604 | 0x07E, 0x1FD, 0x08C, 0x0D7, 0x087, 0x183, 0x03C, 0x061, | |
3605 | 0x047, 0x069, 0x040, 0x048, 0x049, 0x086, 0x013, 0x0D2, | |
3606 | 0x01C, 0x042, 0x025, 0x01B, 0x013, 0x005, 0x000, 0x007, | |
3607 | 0x005, 0x01B, 0x019, 0x019, 0x008, 0x045, 0x01D, 0x0C6, | |
3608 | 0x068, 0x090, 0x041, 0x04B, 0x031, 0x18F, 0x062, 0x03E, | |
3609 | 0x044, 0x068, 0x030, 0x182, 0x0C0, 0x1A7, 0x091, 0x092, | |
3610 | 0x07B, 0x0FF, 0x1A6, 0x1FC, 0x06A, 0x093, 0x06B | |
3611 | ], [ | |
3612 | 0x039, 0x259, 0x01B, 0x1D1, 0x137, 0x1D0, 0x01A, 0x1B5, | |
3613 | 0x01D, 0x4BC, 0x06C, 0x038, 0x071, 0x02D, 0x07D, 0x075, | |
3614 | 0x019, 0x0E9, 0x037, 0x015, 0x01E, 0x0DB, 0x04C, 0x070, | |
3615 | 0x00D, 0x00C, 0x027, 0x004, 0x002, 0x000, 0x005, 0x007, | |
3616 | 0x006, 0x002, 0x008, 0x024, 0x00C, 0x03B, 0x01E, 0x09A, | |
3617 | 0x00E, 0x069, 0x04A, 0x12D, 0x035, 0x0F9, 0x018, 0x07F, | |
3618 | 0x00F, 0x0F8, 0x07E, 0x25F, 0x068, 0x02C, 0x014, 0x258, | |
3619 | 0x136, 0x4BD, 0x12E, 0x1B4, 0x017, 0x039, 0x01F | |
3620 | ], [ | |
3621 | 0x029, 0x3CB, 0x1F5, 0x263, 0x1F4, 0x3DA, 0x050, 0x260, | |
3622 | 0x1EC, 0x3D3, 0x109, 0x3D2, 0x051, 0x792, 0x0F3, 0x09A, | |
3623 | 0x0F7, 0x132, 0x0C1, 0x1E8, 0x02A, 0x085, 0x061, 0x1F7, | |
3624 | 0x078, 0x0C7, 0x023, 0x07C, 0x012, 0x00B, 0x00E, 0x00D, | |
3625 | 0x000, 0x005, 0x003, 0x004, 0x019, 0x020, 0x03F, 0x043, | |
3626 | 0x062, 0x09F, 0x04E, 0x181, 0x02B, 0x137, 0x0F5, 0x089, | |
3627 | 0x0C6, 0x262, 0x088, 0x3C8, 0x1F6, 0x3CA, 0x09E, 0x261, | |
3628 | 0x136, 0x108, 0x133, 0x793, 0x180, 0x3DB, 0x045 | |
3629 | ], [ | |
3630 | 0x001, 0x1C7, 0x067, 0x0B5, 0x066, 0x139, 0x099, 0x0B4, | |
3631 | 0x0C3, 0x130, 0x000, 0x131, 0x09E, 0x0B7, 0x02C, 0x001, | |
3632 | 0x028, 0x138, 0x04B, 0x031, 0x060, 0x091, 0x003, 0x09D, | |
3633 | 0x017, 0x04D, 0x031, 0x070, 0x007, 0x03A, 0x007, 0x002, | |
3634 | 0x00B, 0x001, 0x00F, 0x008, 0x00D, 0x004, 0x00A, 0x00D, | |
3635 | 0x019, 0x002, 0x03B, 0x04A, 0x015, 0x0C2, 0x018, 0x032, | |
3636 | 0x072, 0x1C6, 0x029, 0x1C5, 0x049, 0x121, 0x01B, 0x030, | |
3637 | 0x01A, 0x1C4, 0x09F, 0x0B6, 0x019, 0x120, 0x073 | |
3638 | ], [ | |
3639 | 0x023, 0x1C8, 0x043, 0x110, 0x00C, 0x153, 0x022, 0x111, | |
3640 | 0x00F, 0x042, 0x023, 0x1C9, 0x02A, 0x01B, 0x073, 0x045, | |
3641 | 0x06E, 0x089, 0x06C, 0x01A, 0x06F, 0x0B6, 0x00B, 0x0E5, | |
3642 | 0x025, 0x020, 0x029, 0x04D, 0x002, 0x014, 0x01A, 0x017, | |
3643 | 0x01E, 0x027, 0x018, 0x028, 0x01F, 0x000, 0x006, 0x010, | |
3644 | 0x007, 0x00B, 0x003, 0x004, 0x01D, 0x02C, 0x019, 0x02B, | |
3645 | 0x009, 0x055, 0x038, 0x00E, 0x024, 0x0A8, 0x00A, 0x099, | |
3646 | 0x05A, 0x098, 0x06D, 0x152, 0x02B, 0x0B7, 0x001 | |
3647 | ], [ | |
3648 | 0x03D, 0x0B1, 0x0DD, 0x1F6, 0x0C5, 0x188, 0x037, 0x03F, | |
3649 | 0x01E, 0x189, 0x00F, 0x03E, 0x06A, 0x1F7, 0x061, 0x079, | |
3650 | 0x018, 0x0B0, 0x00E, 0x0B3, 0x00C, 0x0DF, 0x006, 0x0DC, | |
3651 | 0x019, 0x0DE, 0x027, 0x00E, 0x01A, 0x063, 0x00F, 0x00E, | |
3652 | 0x014, 0x07C, 0x036, 0x06B, 0x03F, 0x060, 0x008, 0x074, | |
3653 | 0x009, 0x078, 0x012, 0x00D, 0x015, 0x02D, 0x002, 0x01C, | |
3654 | 0x005, 0x03B, 0x000, 0x034, 0x019, 0x026, 0x010, 0x075, | |
3655 | 0x002, 0x036, 0x023, 0x0B2, 0x022, 0x0FA, 0x017 | |
3656 | ], [ | |
3657 | 0x015, 0x0DD, 0x03E, 0x16E, 0x04C, 0x012, 0x05D, 0x0B6, | |
3658 | 0x06F, 0x1F1, 0x069, 0x1F0, 0x01D, 0x16F, 0x002, 0x06B, | |
3659 | 0x00C, 0x0DC, 0x068, 0x09B, 0x07D, 0x09A, 0x00D, 0x013, | |
3660 | 0x008, 0x0F9, 0x02C, 0x012, 0x033, 0x04F, 0x00D, 0x005, | |
3661 | 0x012, 0x03F, 0x032, 0x013, 0x03B, 0x005, 0x02F, 0x05A, | |
3662 | 0x03F, 0x01C, 0x03A, 0x008, 0x036, 0x05C, 0x010, 0x000, | |
3663 | 0x00C, 0x04E, 0x003, 0x06A, 0x00E, 0x003, 0x014, 0x01E, | |
3664 | 0x01C, 0x00F, 0x018, 0x023, 0x01E, 0x022, 0x002 | |
3665 | ] | |
3666 | ]; | |
3667 | const VP40_MV_X_BITS: [[u8; 63]; 7] = [ | |
3668 | [ | |
3669 | 7, 9, 9, 10, 8, 10, 8, 9, 8, 10, 8, 9, 8, 9, 7, 7, | |
3670 | 7, 8, 7, 8, 7, 8, 6, 8, 6, 7, 6, 6, 5, 4, 2, 3, | |
3671 | 3, 5, 5, 6, 5, 7, 6, 8, 7, 8, 7, 8, 7, 9, 7, 7, | |
3672 | 7, 8, 7, 9, 8, 9, 8, 9, 8, 9, 9, 10, 8, 9, 7 | |
3673 | ], [ | |
3674 | 7, 10, 8, 10, 9, 10, 8, 10, 8, 11, 8, 9, 8, 9, 8, 8, | |
3675 | 7, 9, 7, 8, 7, 9, 7, 8, 6, 7, 6, 6, 4, 4, 3, 3, | |
3676 | 3, 3, 4, 6, 5, 7, 6, 8, 6, 8, 7, 9, 7, 9, 7, 8, | |
3677 | 7, 9, 8, 10, 8, 9, 8, 10, 9, 11, 9, 10, 8, 9, 7 | |
3678 | ], [ | |
3679 | 7, 10, 9, 10, 9, 10, 8, 10, 9, 10, 9, 10, 8, 11, 8, 8, | |
3680 | 8, 9, 8, 9, 7, 8, 7, 9, 7, 8, 6, 7, 5, 5, 4, 4, | |
3681 | 2, 3, 3, 4, 5, 6, 6, 7, 7, 8, 7, 9, 7, 9, 8, 8, | |
3682 | 8, 10, 8, 10, 9, 10, 8, 10, 9, 9, 9, 11, 9, 10, 7 | |
3683 | ], [ | |
3684 | 6, 9, 8, 9, 8, 9, 8, 9, 8, 9, 7, 9, 8, 9, 7, 7, | |
3685 | 7, 9, 7, 8, 7, 8, 6, 8, 6, 7, 6, 7, 5, 6, 4, 4, | |
3686 | 4, 4, 4, 4, 4, 4, 4, 5, 5, 6, 6, 7, 6, 8, 6, 7, | |
3687 | 7, 9, 7, 9, 7, 9, 7, 8, 7, 9, 8, 9, 7, 9, 7 | |
3688 | ], [ | |
3689 | 6, 9, 8, 9, 7, 9, 7, 9, 7, 8, 7, 9, 7, 8, 7, 7, | |
3690 | 7, 8, 7, 8, 7, 8, 6, 8, 6, 7, 6, 7, 5, 6, 5, 5, | |
3691 | 5, 6, 5, 6, 5, 5, 4, 5, 4, 5, 4, 5, 5, 6, 5, 6, | |
3692 | 5, 7, 6, 7, 6, 8, 6, 8, 7, 8, 7, 9, 7, 8, 5 | |
3693 | ], [ | |
3694 | 6, 8, 8, 9, 8, 9, 7, 8, 7, 9, 7, 8, 7, 9, 7, 7, | |
3695 | 6, 8, 6, 8, 6, 8, 6, 8, 6, 8, 6, 7, 6, 7, 5, 5, | |
3696 | 5, 7, 6, 7, 6, 7, 5, 7, 5, 7, 5, 6, 5, 6, 4, 5, | |
3697 | 4, 6, 4, 6, 5, 6, 5, 7, 5, 7, 6, 8, 6, 8, 5 | |
3698 | ], [ | |
3699 | 5, 8, 7, 9, 7, 8, 7, 8, 7, 9, 7, 9, 7, 9, 6, 7, | |
3700 | 6, 8, 7, 8, 7, 8, 6, 8, 6, 8, 6, 7, 6, 7, 5, 5, | |
3701 | 5, 7, 6, 7, 6, 6, 6, 7, 6, 7, 6, 7, 6, 7, 5, 5, | |
3702 | 5, 7, 5, 7, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 3 | |
3703 | ] | |
3704 | ]; | |
3705 | const VP40_MV_Y_CODES: [[u32; 63]; 7] = [ | |
3706 | [ | |
3707 | 0x052, 0x14C, 0x1FA, 0x124, 0x082, 0x29E, 0x08E, 0x24B, | |
3708 | 0x09C, 0x3F7, 0x086, 0x114, 0x083, 0x3A5, 0x0FA, 0x04F, | |
3709 | 0x0FB, 0x13B, 0x0FC, 0x172, 0x044, 0x173, 0x051, 0x087, | |
3710 | 0x05F, 0x0BA, 0x026, 0x05E, 0x016, 0x015, 0x006, 0x001, | |
3711 | 0x000, 0x01C, 0x01E, 0x075, 0x03B, 0x0FF, 0x025, 0x0BB, | |
3712 | 0x07C, 0x08B, 0x048, 0x171, 0x042, 0x14E, 0x046, 0x0FE, | |
3713 | 0x040, 0x13A, 0x093, 0x115, 0x08F, 0x3F6, 0x170, 0x29F, | |
3714 | 0x1D1, 0x24A, 0x1D3, 0x3A4, 0x1D0, 0x14D, 0x050 | |
3715 | ], [ | |
3716 | 0x0DE, 0x223, 0x136, 0x7C5, 0x12F, 0x4A1, 0x3D7, 0x7AC, | |
3717 | 0x133, 0x7C4, 0x1B8, 0x222, 0x096, 0x251, 0x095, 0x1F0, | |
3718 | 0x0DA, 0x110, 0x09A, 0x360, 0x0DD, 0x12E, 0x048, 0x092, | |
3719 | 0x078, 0x098, 0x027, 0x045, 0x01A, 0x010, 0x005, 0x000, | |
3720 | 0x001, 0x00E, 0x00C, 0x023, 0x03F, 0x0F4, 0x07D, 0x089, | |
3721 | 0x07B, 0x1BE, 0x0F9, 0x3E3, 0x0F3, 0x127, 0x0DB, 0x1EA, | |
3722 | 0x0D9, 0x6E7, 0x1BF, 0x4A0, 0x1B1, 0x6E6, 0x137, 0x7AD, | |
3723 | 0x126, 0x6C2, 0x132, 0x6C3, 0x129, 0x372, 0x0F2 | |
3724 | ], [ | |
3725 | 0x016, 0x09C, 0x13C, 0x09E, 0x12B, 0x0BA, 0x181, 0x317, | |
3726 | 0x084, 0x04E, 0x026, 0x316, 0x180, 0x05C, 0x0C1, 0x02F, | |
3727 | 0x010, 0x045, 0x012, 0x189, 0x024, 0x13D, 0x066, 0x023, | |
3728 | 0x067, 0x0C6, 0x024, 0x04B, 0x011, 0x032, 0x00D, 0x000, | |
3729 | 0x007, 0x005, 0x003, 0x003, 0x005, 0x020, 0x008, 0x025, | |
3730 | 0x026, 0x04F, 0x061, 0x02B, 0x04E, 0x18A, 0x043, 0x09F, | |
3731 | 0x014, 0x254, 0x094, 0x310, 0x085, 0x311, 0x02A, 0x0BB, | |
3732 | 0x18F, 0x255, 0x09D, 0x09F, 0x18E, 0x044, 0x026 | |
3733 | ], [ | |
3734 | 0x061, 0x12A, 0x00D, 0x3BD, 0x089, 0x109, 0x18E, 0x210, | |
3735 | 0x1D3, 0x211, 0x088, 0x019, 0x085, 0x018, 0x0E8, 0x0CE, | |
3736 | 0x040, 0x119, 0x045, 0x1D2, 0x04B, 0x1DD, 0x062, 0x094, | |
3737 | 0x075, 0x00C, 0x027, 0x00D, 0x002, 0x026, 0x006, 0x01E, | |
3738 | 0x00D, 0x01F, 0x001, 0x00A, 0x002, 0x007, 0x00B, 0x000, | |
3739 | 0x01C, 0x076, 0x032, 0x007, 0x024, 0x0C0, 0x007, 0x041, | |
3740 | 0x002, 0x18F, 0x047, 0x1DC, 0x043, 0x12B, 0x0CF, 0x118, | |
3741 | 0x0C6, 0x3BC, 0x08D, 0x3BF, 0x0C1, 0x3BE, 0x066 | |
3742 | ], [ | |
3743 | 0x007, 0x14D, 0x0A0, 0x09E, 0x0CF, 0x39C, 0x0A1, 0x39D, | |
3744 | 0x0AB, 0x1C5, 0x026, 0x14C, 0x025, 0x19C, 0x03F, 0x0E1, | |
3745 | 0x066, 0x1CF, 0x03E, 0x1C4, 0x072, 0x04E, 0x006, 0x0AA, | |
3746 | 0x01C, 0x0E6, 0x032, 0x051, 0x03B, 0x005, 0x01F, 0x018, | |
3747 | 0x002, 0x03A, 0x000, 0x036, 0x005, 0x008, 0x008, 0x016, | |
3748 | 0x009, 0x00D, 0x003, 0x02F, 0x01E, 0x02E, 0x01A, 0x02B, | |
3749 | 0x00C, 0x024, 0x01E, 0x0E0, 0x004, 0x0A7, 0x054, 0x1C7, | |
3750 | 0x052, 0x19D, 0x03A, 0x09F, 0x03B, 0x1C6, 0x037 | |
3751 | ], [ | |
3752 | 0x02A, 0x039, 0x025, 0x115, 0x024, 0x1FA, 0x02F, 0x114, | |
3753 | 0x075, 0x038, 0x0FC, 0x036, 0x01E, 0x1FB, 0x07F, 0x068, | |
3754 | 0x016, 0x037, 0x01F, 0x05C, 0x013, 0x08B, 0x001, 0x0FB, | |
3755 | 0x021, 0x044, 0x02B, 0x06B, 0x03B, 0x00C, 0x01C, 0x019, | |
3756 | 0x001, 0x020, 0x016, 0x07C, 0x00C, 0x074, 0x00A, 0x01C, | |
3757 | 0x012, 0x069, 0x00F, 0x06A, 0x014, 0x011, 0x01E, 0x017, | |
3758 | 0x002, 0x031, 0x01B, 0x030, 0x00D, 0x000, 0x001, 0x01D, | |
3759 | 0x023, 0x01A, 0x01D, 0x05D, 0x010, 0x0FA, 0x013 | |
3760 | ], [ | |
3761 | 0x012, 0x026, 0x041, 0x022, 0x01A, 0x0A9, 0x04C, 0x1B2, | |
3762 | 0x05C, 0x0A8, 0x058, 0x1B3, 0x040, 0x079, 0x00C, 0x055, | |
3763 | 0x01F, 0x0D8, 0x076, 0x023, 0x05F, 0x078, 0x00B, 0x01B, | |
3764 | 0x02D, 0x010, 0x037, 0x06D, 0x032, 0x00A, 0x01A, 0x01E, | |
3765 | 0x01F, 0x02B, 0x00D, 0x077, 0x031, 0x05D, 0x038, 0x027, | |
3766 | 0x00C, 0x0E9, 0x033, 0x05E, 0x030, 0x04D, 0x00A, 0x021, | |
3767 | 0x007, 0x03D, 0x039, 0x0E8, 0x00B, 0x059, 0x014, 0x027, | |
3768 | 0x011, 0x075, 0x00E, 0x009, 0x008, 0x012, 0x000 | |
3769 | ] | |
3770 | ]; | |
3771 | const VP40_MV_Y_BITS: [[u8; 63]; 7] = [ | |
3772 | [ | |
3773 | 7, 9, 9, 9, 8, 10, 8, 10, 8, 10, 8, 9, 8, 10, 8, 7, | |
3774 | 8, 9, 8, 9, 7, 9, 7, 8, 7, 8, 6, 7, 5, 5, 3, 2, | |
3775 | 2, 5, 5, 7, 6, 8, 6, 8, 7, 8, 7, 9, 7, 9, 7, 8, | |
3776 | 7, 9, 8, 9, 8, 10, 9, 10, 9, 10, 9, 10, 9, 9, 7 | |
3777 | ], [ | |
3778 | 8, 10, 9, 11, 9, 11, 10, 11, 9, 11, 9, 10, 8, 10, 8, 9, | |
3779 | 8, 9, 8, 10, 8, 9, 7, 8, 7, 8, 6, 7, 5, 5, 3, 2, | |
3780 | 2, 4, 4, 6, 6, 8, 7, 8, 7, 9, 8, 10, 8, 9, 8, 9, | |
3781 | 8, 11, 9, 11, 9, 11, 9, 11, 9, 11, 9, 11, 9, 10, 8 | |
3782 | ], [ | |
3783 | 7, 9, 9, 10, 9, 10, 9, 10, 8, 9, 8, 10, 9, 9, 8, 8, | |
3784 | 7, 9, 7, 9, 7, 9, 7, 8, 7, 8, 6, 7, 5, 6, 4, 3, | |
3785 | 3, 3, 3, 4, 4, 6, 5, 7, 6, 8, 7, 8, 7, 9, 7, 8, | |
3786 | 7, 10, 8, 10, 8, 10, 8, 10, 9, 10, 9, 10, 9, 9, 7 | |
3787 | ], [ | |
3788 | 7, 9, 8, 10, 8, 9, 9, 10, 9, 10, 8, 9, 8, 9, 8, 8, | |
3789 | 7, 9, 7, 9, 7, 9, 7, 8, 7, 7, 6, 7, 5, 6, 4, 5, | |
3790 | 4, 5, 3, 4, 3, 4, 4, 5, 5, 7, 6, 7, 6, 8, 6, 7, | |
3791 | 6, 9, 7, 9, 7, 9, 8, 9, 8, 10, 8, 10, 8, 10, 7 | |
3792 | ], [ | |
3793 | 6, 9, 8, 9, 8, 10, 8, 10, 8, 9, 7, 9, 7, 9, 7, 8, | |
3794 | 7, 9, 7, 9, 7, 8, 6, 8, 6, 8, 6, 7, 6, 6, 5, 5, | |
3795 | 4, 6, 4, 6, 4, 5, 4, 5, 4, 5, 4, 6, 5, 6, 5, 6, | |
3796 | 5, 7, 6, 8, 6, 8, 7, 9, 7, 9, 7, 9, 7, 9, 6 | |
3797 | ], [ | |
3798 | 6, 8, 7, 9, 7, 9, 7, 9, 7, 8, 8, 8, 7, 9, 7, 7, | |
3799 | 6, 8, 7, 8, 6, 8, 6, 8, 6, 7, 6, 7, 6, 6, 5, 5, | |
3800 | 4, 6, 5, 7, 5, 7, 5, 6, 5, 7, 5, 7, 5, 6, 5, 5, | |
3801 | 4, 6, 5, 6, 5, 6, 5, 7, 6, 7, 6, 8, 6, 8, 5 | |
3802 | ], [ | |
3803 | 5, 7, 7, 8, 7, 8, 7, 9, 7, 8, 7, 9, 7, 8, 6, 7, | |
3804 | 6, 8, 7, 8, 7, 8, 6, 7, 6, 7, 6, 7, 6, 6, 5, 5, | |
3805 | 5, 6, 5, 7, 6, 7, 6, 7, 5, 8, 6, 7, 6, 7, 5, 6, | |
3806 | 5, 7, 6, 8, 5, 7, 5, 6, 5, 7, 5, 6, 5, 6, 3 | |
3807 | ] | |
3808 | ]; | |
3809 | ||
3810 | const VP40_LOOP_STRENGTH: [i16; 64] = [ | |
3811 | 30, 25, 20, 20, 15, 15, 14, 14, | |
3812 | 13, 13, 12, 12, 11, 11, 10, 10, | |
3813 | 9, 9, 8, 8, 7, 7, 7, 7, | |
3814 | 6, 6, 6, 6, 5, 5, 5, 5, | |
3815 | 4, 4, 4, 4, 3, 3, 3, 3, | |
3816 | 2, 2, 2, 2, 2, 2, 2, 2, | |
3817 | 2, 2, 2, 2, 2, 2, 2, 2, | |
3818 | 1, 1, 1, 1, 1, 1, 1, 1 | |
3819 | ]; | |
3820 | const VP40_MV_LUT_INDEX: [usize; 32] = [ | |
3821 | 0, 1, 2, 2, 3, 3, 3, 3, | |
3822 | 4, 4, 4, 4, 4, 4, 4, 4, | |
3823 | 5, 5, 5, 5, 5, 5, 5, 5, | |
3824 | 6, 6, 6, 6, 6, 6, 6, 6 | |
3825 | ]; |