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