]> git.nihav.org Git - nihav.git/blob - nihav-realmedia/src/codecs/rv40.rs
vp5: fix chroma MV
[nihav.git] / nihav-realmedia / src / codecs / rv40.rs
1 use nihav_core::formats;
2 use nihav_core::frame::*;
3 use nihav_core::io::bitreader::*;
4 use nihav_core::io::codebook::*;
5 use nihav_core::io::intcode::*;
6 use nihav_core::codecs::*;
7 use super::rv3040::*;
8 use super::rv40dsp::*;
9
10 struct AICCodeReader8 {
11 lengths: &'static [u8],
12 codes: &'static [u8],
13 }
14
15 impl CodebookDescReader<i8> for AICCodeReader8 {
16 fn bits(&mut self, idx: usize) -> u8 { self.lengths[idx] }
17 fn code(&mut self, idx: usize) -> u32 { self.codes[idx] as u32 }
18 fn sym (&mut self, idx: usize) -> i8 { idx as i8 }
19 fn len (&mut self) -> usize { self.lengths.len() }
20 }
21
22 struct AICCodeReader16 {
23 lengths: &'static [u8],
24 codes: &'static [u16],
25 }
26
27 impl CodebookDescReader<i8> for AICCodeReader16 {
28 fn bits(&mut self, idx: usize) -> u8 { self.lengths[idx] }
29 fn code(&mut self, idx: usize) -> u32 { self.codes[idx] as u32 }
30 fn sym (&mut self, idx: usize) -> i8 { idx as i8 }
31 fn len (&mut self) -> usize { self.lengths.len() }
32 }
33
34 struct TypeCodeReader {
35 lengths: &'static [u8],
36 codes: &'static [u8],
37 syms: &'static [MBType],
38 }
39
40 impl CodebookDescReader<MBType> for TypeCodeReader {
41 fn bits(&mut self, idx: usize) -> u8 { self.lengths[idx] }
42 fn code(&mut self, idx: usize) -> u32 { self.codes[idx] as u32 }
43 fn sym (&mut self, idx: usize) -> MBType{ self.syms[idx] }
44 fn len (&mut self) -> usize { self.lengths.len() }
45 }
46
47 struct RealVideo40BR {
48 width: usize,
49 height: usize,
50 aic_top_cb: Codebook<i8>,
51 aic_mode1_cb: Vec<Codebook<i8>>,
52 aic_mode2_cb: Vec<Codebook<i8>>,
53 ptype_cb: Vec<Codebook<MBType>>,
54 btype_cb: Vec<Codebook<MBType>>,
55 had_skip_run: bool,
56 }
57
58 impl RealVideo40BR {
59 fn new() -> Self {
60 let mut coderead = AICCodeReader8{ lengths: &RV40_AIC_TOP_BITS, codes: &RV40_AIC_TOP_CODES };
61 let aic_top_cb = Codebook::new(&mut coderead, CodebookMode::MSB).unwrap();
62
63 let mut aic_mode1_cb: Vec<Codebook<i8>> = Vec::with_capacity(RV40_AIC_MODE1_BITS.len());
64 for i in 0..RV40_AIC_MODE1_BITS.len() {
65 if (i % 10) != 9 {
66 let mut coderead = AICCodeReader8{ lengths: &RV40_AIC_MODE1_BITS[i], codes: &RV40_AIC_MODE1_CODES[i] };
67 let cb = Codebook::new(&mut coderead, CodebookMode::MSB).unwrap();
68 aic_mode1_cb.push(cb);
69 } else {
70 let mut coderead = AICCodeReader8{ lengths: &RV40_AIC_MODE1_BITS_DUMMY, codes: &RV40_AIC_MODE1_CODES_DUMMY };
71 let cb = Codebook::new(&mut coderead, CodebookMode::MSB).unwrap();
72 aic_mode1_cb.push(cb);
73 }
74 }
75
76 let mut aic_mode2_cb: Vec<Codebook<i8>> = Vec::with_capacity(RV40_AIC_MODE2_BITS.len());
77 for i in 0..RV40_AIC_MODE2_BITS.len() {
78 let mut coderead = AICCodeReader16{ lengths: &RV40_AIC_MODE2_BITS[i], codes: &RV40_AIC_MODE2_CODES[i] };
79 let cb = Codebook::new(&mut coderead, CodebookMode::MSB).unwrap();
80 aic_mode2_cb.push(cb);
81 }
82
83 let mut ptype_cb: Vec<Codebook<MBType>> = Vec::with_capacity(RV40_PTYPE_BITS.len());
84 for i in 0..RV40_PTYPE_BITS.len() {
85 let mut coderead = TypeCodeReader{ lengths: &RV40_PTYPE_BITS[i], codes: &RV40_PTYPE_CODES[i], syms: RV40_PTYPE_SYMS };
86 let cb = Codebook::new(&mut coderead, CodebookMode::MSB).unwrap();
87 ptype_cb.push(cb);
88 }
89
90 let mut btype_cb: Vec<Codebook<MBType>> = Vec::with_capacity(RV40_BTYPE_BITS.len());
91 for i in 0..RV40_BTYPE_BITS.len() {
92 let mut coderead = TypeCodeReader{ lengths: &RV40_BTYPE_BITS[i], codes: &RV40_BTYPE_CODES[i], syms: RV40_BTYPE_SYMS };
93 let cb = Codebook::new(&mut coderead, CodebookMode::MSB).unwrap();
94 btype_cb.push(cb);
95 }
96
97 RealVideo40BR {
98 width: 0,
99 height: 0,
100 aic_top_cb,
101 aic_mode1_cb,
102 aic_mode2_cb,
103 ptype_cb,
104 btype_cb,
105 had_skip_run: false,
106 }
107 }
108 fn predict_b_mv_component(&self, sstate: &SState, mvi: &MVInfo, mbinfo: &[RV34MBInfo], mbtype: MBType, fwd: bool) -> MV {
109 let mut pred_mvs: [MV; 3] = [ZERO_MV; 3];
110 let mut mv_count: usize = 0;
111 let mb_x = sstate.mb_x;
112 let mb_y = sstate.mb_y;
113 let mb_stride = sstate.mb_w;
114 let mb_idx = mb_x + mb_y * mb_stride;
115
116 if !mbtype.has_mv_dir(fwd) {
117 return ZERO_MV;
118 }
119
120 if sstate.has_left && mbinfo[mb_idx - 1].mbtype.has_mv_dir(fwd) {
121 pred_mvs[mv_count] = mvi.get_mv(mb_x - 1, mb_y, 0, 0, fwd);
122 mv_count += 1;
123 }
124 if !sstate.has_top {
125 return pred_mvs[0];
126 }
127 if mbinfo[mb_idx - mb_stride].mbtype.has_mv_dir(fwd) {
128 pred_mvs[mv_count] = mvi.get_mv(mb_x, mb_y - 1, 0, 0, fwd);
129 mv_count += 1;
130 }
131 if sstate.has_tr {
132 if mbinfo[mb_idx - mb_stride + 1].mbtype.has_mv_dir(fwd) {
133 pred_mvs[mv_count] = mvi.get_mv(mb_x + 1, mb_y - 1, 0, 0, fwd);
134 mv_count += 1;
135 }
136 } else {
137 if sstate.has_tl && mbinfo[mb_idx - mb_stride - 1].mbtype.has_mv_dir(fwd) {
138 pred_mvs[mv_count] = mvi.get_mv(mb_x - 1, mb_y - 1, 0, 0, fwd);
139 mv_count += 1;
140 }
141 }
142
143 match mv_count {
144 3 => MV::pred(pred_mvs[0], pred_mvs[1], pred_mvs[2]),
145 2 => { let sum_mv = pred_mvs[0] + pred_mvs[1]; MV { x: sum_mv.x / 2, y: sum_mv.y / 2 } },
146 1 => pred_mvs[0],
147 _ => ZERO_MV,
148 }
149 }
150 }
151
152 fn get_dimension(br: &mut BitReader, tab: &'static [i16]) -> DecoderResult<usize> {
153 let t = br.read(3)? as usize;
154 if tab[t] > 0 { return Ok(tab[t] as usize); }
155 if tab[t] < 0 {
156 let idx = (-tab[t] as usize) + (br.read(1)? as usize);
157 if tab[idx] != 0 { return Ok(tab[idx] as usize); }
158 }
159 let mut size: usize = 0;
160 loop {
161 let t = br.read(8)? as usize;
162 size += t << 2;
163 if t != 255 { break; }
164 }
165 Ok(size)
166 }
167
168 impl RV34BitstreamDecoder for RealVideo40BR {
169 fn decode_slice_header(&mut self, br: &mut BitReader, old_w: usize, old_h: usize) -> DecoderResult<RV34SliceHeader> {
170 if br.read(1)? != 0 { return Err(DecoderError::InvalidData); }
171 let ft_idx = br.read(2)?;
172 let ftype = match ft_idx {
173 0|1 => FrameType::I,
174 2 => FrameType::P,
175 _ => FrameType::B,
176 };
177 let q = br.read(5)? as u8;
178 if br.read(2)? != 0 { return Err(DecoderError::InvalidData); }
179 let set_idx = br.read(2)? as usize;
180 let deblock = !br.read_bool()?;
181 let pts = br.read(13)? as u16;
182 let w;
183 let h;
184 if (ftype == FrameType::I) || !br.read_bool()? {
185 w = get_dimension(br, &RV40_STANDARD_WIDTHS)?;
186 h = get_dimension(br, &RV40_STANDARD_HEIGHTS)?;
187 } else {
188 w = old_w;
189 h = old_h;
190 }
191 let start = br.read(get_slice_start_offset_bits(w, h))? as usize;
192
193 self.had_skip_run = false;
194
195 Ok(RV34SliceHeader{ ftype, quant: q, deblock, pts, width: w, height: h, start, end: 0, set_idx })
196 }
197 fn decode_intra_pred(&mut self, br: &mut BitReader, types: &mut [i8], mut pos: usize, tstride: usize, has_top: bool) -> DecoderResult<()> {
198 let start;
199 if has_top {
200 start = 0;
201 } else {
202 let code = br.read_cb(&self.aic_top_cb)?;
203 types[pos + 0] = (code >> 2) & 2;
204 types[pos + 1] = (code >> 1) & 2;
205 types[pos + 2] = (code >> 0) & 2;
206 types[pos + 3] = (code << 1) & 2;
207 pos += tstride;
208 start = 1;
209 }
210 for _ in start..4 {
211 let mut x: usize = 0;
212 while x < 4 {
213 let tr = types[pos + x - tstride + 1];
214 let t = types[pos + x - tstride];
215 let l = types[pos + x - 1];
216 let ctx = if x < 3 { ((tr & 0xF) as u16) + (((t as u16) & 0xF) << 4) + (((l as u16) & 0xF) << 8) } else { 0xFFF };
217 let res = RV40_AIC_PATTERNS.iter().position(|&x| x == ctx);
218 if let Some(idx) = res {
219 let code = br.read_cb(&self.aic_mode2_cb[idx])?;
220 types[pos + x + 0] = code / 9;
221 types[pos + x + 1] = code % 9;
222 x += 2;
223 } else {
224 if (t != -1) && (l != -1) {
225 let idx = (t as usize) + (l as usize) * 10;
226 types[pos + x] = br.read_cb(&self.aic_mode1_cb[idx])?;
227 } else {
228 match l {
229 -1 if t < 2 => { types[pos + x] = (br.read(1)? as i8) ^ 1; },
230 0 | 2 => { types[pos + x] = ((br.read(1)? as i8) ^ 1) << 1; },
231 _ => { types[pos + x] = 0; },
232 };
233 }
234 x += 1;
235 }
236 }
237 pos += tstride;
238 }
239 Ok(())
240 }
241 fn decode_inter_mb_hdr(&mut self, br: &mut BitReader, ftype: FrameType, mbtype_ref: MBType) -> DecoderResult<MBInfo> {
242 let skip_run = if self.had_skip_run { 0 } else { br.read_code(UintCodeType::Gamma)? as usize };
243 if skip_run > 0 {
244 self.had_skip_run = true;
245 return Ok(MBInfo { mbtype: MBType::MBSkip, skip_run: skip_run - 1, dquant: false })
246 }
247 self.had_skip_run = false;
248 let mut mbtype;
249 let idx;
250 if ftype == FrameType::P {
251 idx = match mbtype_ref {
252 MBType::MBIntra => 0,
253 MBType::MBIntra16 => 1,
254 MBType::MBP16x16 => 2,
255 MBType::MBP8x8 => 3,
256 MBType::MBP16x8 => 4,
257 MBType::MBP8x16 => 5,
258 MBType::MBP16x16Mix => 6,
259 _ => unreachable!(),
260 };
261 mbtype = br.read_cb(&self.ptype_cb[idx])?;
262 } else {
263 idx = match mbtype_ref {
264 MBType::MBIntra => 0,
265 MBType::MBIntra16 => 1,
266 MBType::MBForward => 2,
267 MBType::MBBackward => 3,
268 MBType::MBBidir => 4,
269 MBType::MBDirect => 5,
270 _ => 0,
271 };
272 mbtype = br.read_cb(&self.btype_cb[idx])?;
273 }
274 let dquant = mbtype == MBType::Invalid;
275 if dquant {
276 mbtype = if ftype == FrameType::P { br.read_cb(&self.ptype_cb[idx])? }
277 else { br.read_cb(&self.btype_cb[idx])? };
278 }
279 Ok(MBInfo { mbtype, skip_run: 0, dquant })
280 }
281 fn predict_b_mv(&self, sstate: &SState, mvi: &MVInfo, mbtype: MBType, mvs: &[MV], mbinfo: &[RV34MBInfo]) -> (MV, MV) {
282 let mut mv_f = self.predict_b_mv_component(sstate, mvi, mbinfo, mbtype, true);
283 let mut mv_b = self.predict_b_mv_component(sstate, mvi, mbinfo, mbtype, false);
284
285 match mbtype {
286 MBType::MBForward => { mv_f += mvs[0]; },
287 MBType::MBBackward => { mv_b += mvs[0]; },
288 MBType::MBBidir => {
289 mv_f += mvs[0];
290 mv_b += mvs[1];
291 },
292 _ => {},
293 };
294
295 (mv_f, mv_b)
296 }
297 fn quant_dc(&self, is_intra: bool, q: u8) -> u8 { RV40_QUANT_DC[if is_intra { 0 } else { 1 }][q as usize] }
298 }
299
300 struct RealVideo40Decoder {
301 bd: RealVideo40BR,
302 info: NACodecInfoRef,
303 dec: RV34Decoder,
304 }
305
306 impl RealVideo40Decoder {
307 fn new() -> Self {
308 RealVideo40Decoder{
309 bd: RealVideo40BR::new(),
310 info: NACodecInfoRef::default(),
311 dec: RV34Decoder::new(false, Box::new(RV40DSP::new())),
312 }
313 }
314 }
315
316 impl NADecoder for RealVideo40Decoder {
317 fn init(&mut self, supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
318 if let NACodecTypeInfo::Video(vinfo) = info.get_properties() {
319 let fmt = formats::YUV420_FORMAT;
320 let myinfo = NACodecTypeInfo::Video(NAVideoInfo::new(0, 0, false, fmt));
321 self.info = NACodecInfo::new_ref(info.get_name(), myinfo, info.get_extradata()).into_ref();
322
323 let edata = info.get_extradata().unwrap();
324 let src: &[u8] = &edata;
325
326 {
327 println!("edata:");
328 for i in 0..src.len() { print!(" {:02X}", src[i]); } println!();
329 }
330 if src.len() < 2 { return Err(DecoderError::InvalidData); }
331
332 self.bd.width = vinfo.get_width();
333 self.bd.height = vinfo.get_height();
334
335 supp.pool_u8.set_dec_bufs(3);
336 supp.pool_u8.prealloc_video(NAVideoInfo::new(self.bd.width, self.bd.height, false, fmt), 4)?;
337
338 Ok(())
339 } else {
340 println!("???");
341 Err(DecoderError::InvalidData)
342 }
343 }
344 fn decode(&mut self, supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
345 let src = pkt.get_buffer();
346
347 let (bufinfo, ftype, ts) = self.dec.parse_frame(supp, src.as_slice(), &mut self.bd)?;
348
349 let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), bufinfo);
350 frm.set_keyframe(ftype == FrameType::I);
351 frm.set_frame_type(ftype);
352 frm.set_pts(Some(ts));
353 Ok(frm.into_ref())
354 }
355 fn flush(&mut self) {
356 self.dec.flush();
357 }
358 }
359
360 pub fn get_decoder() -> Box<dyn NADecoder + Send> {
361 Box::new(RealVideo40Decoder::new())
362 }
363
364 #[cfg(test)]
365 mod test {
366 use nihav_core::codecs::RegisteredDecoders;
367 use nihav_core::demuxers::RegisteredDemuxers;
368 use nihav_core::test::dec_video::*;
369 use crate::codecs::realmedia_register_all_codecs;
370 use crate::demuxers::realmedia_register_all_demuxers;
371 #[test]
372 fn test_rv40() {
373 let mut dmx_reg = RegisteredDemuxers::new();
374 realmedia_register_all_demuxers(&mut dmx_reg);
375 let mut dec_reg = RegisteredDecoders::new();
376 realmedia_register_all_codecs(&mut dec_reg);
377
378 // test_file_decoding("realmedia", "assets/RV/rv40_ralf.rmvb", Some(1000), true, false, /*None*/Some("rv40"));
379 test_file_decoding("realmedia", "assets/RV/rv40_weighted_mc.rmvb", Some(400), true, false, None/*Some("rv40")*/, &dmx_reg, &dec_reg);
380 // test_file_decoding("realmedia", "assets/RV/rv40_weighted_mc_2.rmvb", Some(1000), true, false, /*None*/Some("rv40"));
381 //panic!("end");
382 }
383 }
384
385 const RV40_STANDARD_WIDTHS: [i16; 8] = [ 160, 172, 240, 320, 352, 640, 704, 0 ];
386 const RV40_STANDARD_HEIGHTS: [i16; 12] = [ 120, 132, 144, 240, 288, 480, -8, -10, 180, 360, 576, 0 ];
387
388 const RV40_QUANT_DC: [[u8; 32]; 2] = [
389 [
390 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
391 16, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 22, 22, 22, 22
392 ], [
393 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
394 16, 17, 18, 19, 20, 20, 21, 21, 22, 23, 23, 23, 24, 24, 24, 24
395 ]
396 ];
397
398 const RV40_AIC_PATTERNS: [u16; 20] = [
399 0x000, 0x100, 0x200,
400 0x011, 0x111, 0x211, 0x511, 0x611,
401 0x022, 0x122, 0x222, 0x722,
402 0x272, 0x227,
403 0x822, 0x282, 0x228,
404 0x112, 0x116, 0x221
405 ];
406
407 const RV40_AIC_TOP_CODES: [u8; 16] = [
408 0x01, 0x05, 0x01, 0x00, 0x03, 0x3D, 0x1D, 0x02,
409 0x04, 0x3C, 0x3F, 0x1C, 0x0D, 0x3E, 0x0C, 0x01
410 ];
411 const RV40_AIC_TOP_BITS: [u8; 16] = [
412 1, 4, 5, 5, 5, 7, 6, 5, 4, 7, 7, 6, 5, 7, 5, 3
413 ];
414
415 const RV40_AIC_MODE1_CODES_DUMMY: [u8; 1] = [ 0 ];
416 const RV40_AIC_MODE1_BITS_DUMMY: [u8; 1] = [ 1 ];
417
418 const RV40_AIC_MODE1_CODES: [[u8; 9]; 90] = [
419 [ 0x01, 0x01, 0x01, 0x11, 0x00, 0x09, 0x03, 0x10, 0x05 ],
420 [ 0x09, 0x01, 0x01, 0x05, 0x11, 0x00, 0x03, 0x21, 0x20 ],
421 [ 0x01, 0x01, 0x01, 0x11, 0x09, 0x10, 0x05, 0x00, 0x03 ],
422 [ 0x01, 0x01, 0x00, 0x03, 0x21, 0x05, 0x09, 0x20, 0x11 ],
423 [ 0x01, 0x09, 0x00, 0x29, 0x08, 0x15, 0x03, 0x0B, 0x28 ],
424 [ 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x03, 0x02 ],
425 [ 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x01, 0x09, 0x08 ],
426 [ 0x01, 0x01, 0x01, 0x09, 0x01, 0x08, 0x00, 0x03, 0x05 ],
427 [ 0x01, 0x01, 0x01, 0x00, 0x05, 0x11, 0x09, 0x10, 0x03 ],
428 [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ],
429
430 [ 0x01, 0x01, 0x01, 0x05, 0x01, 0x00, 0x03, 0x09, 0x08 ],
431 [ 0x09, 0x01, 0x01, 0x05, 0x11, 0x00, 0x03, 0x21, 0x20 ],
432 [ 0x01, 0x01, 0x01, 0x0D, 0x05, 0x04, 0x00, 0x07, 0x0C ],
433 [ 0x01, 0x01, 0x00, 0x05, 0x11, 0x03, 0x09, 0x21, 0x20 ],
434 [ 0x05, 0x01, 0x01, 0x11, 0x00, 0x09, 0x03, 0x21, 0x20 ],
435 [ 0x09, 0x01, 0x01, 0x00, 0x05, 0x01, 0x03, 0x11, 0x10 ],
436 [ 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x03, 0x02 ],
437 [ 0x01, 0x01, 0x01, 0x09, 0x00, 0x05, 0x01, 0x03, 0x08 ],
438 [ 0x01, 0x01, 0x01, 0x09, 0x11, 0x05, 0x00, 0x10, 0x03 ],
439 [ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ],
440
441 [ 0x01, 0x00, 0x01, 0x09, 0x08, 0x15, 0x14, 0x0B, 0x03 ],
442 [ 0x0D, 0x01, 0x01, 0x05, 0x0C, 0x04, 0x01, 0x00, 0x07 ],
443 [ 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x03, 0x01, 0x01 ],
444 [ 0x05, 0x01, 0x01, 0x04, 0x19, 0x07, 0x18, 0x0D, 0x00 ],
445 [ 0x11, 0x09, 0x01, 0x21, 0x05, 0x20, 0x01, 0x00, 0x03 ],
446 [ 0x41, 0x01, 0x00, 0x05, 0x40, 0x03, 0x09, 0x21, 0x11 ],
447 [ 0x29, 0x01, 0x00, 0x28, 0x09, 0x15, 0x03, 0x08, 0x0B ],
448 [ 0x01, 0x00, 0x01, 0x11, 0x09, 0x10, 0x05, 0x01, 0x03 ],
449 [ 0x05, 0x01, 0x01, 0x04, 0x0D, 0x0C, 0x07, 0x00, 0x01 ],
450 [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ],
451
452 [ 0x01, 0x00, 0x03, 0x05, 0x11, 0x10, 0x25, 0x24, 0x13 ],
453 [ 0x21, 0x01, 0x01, 0x00, 0x11, 0x03, 0x05, 0x20, 0x09 ],
454 [ 0x01, 0x01, 0x01, 0x00, 0x09, 0x11, 0x10, 0x05, 0x03 ],
455 [ 0x21, 0x05, 0x01, 0x01, 0x09, 0x00, 0x11, 0x20, 0x03 ],
456 [ 0x05, 0x01, 0x00, 0x04, 0x01, 0x19, 0x07, 0x18, 0x0D ],
457 [ 0x11, 0x01, 0x00, 0x01, 0x09, 0x01, 0x03, 0x10, 0x05 ],
458 [ 0x1D, 0x01, 0x05, 0x0D, 0x0C, 0x04, 0x00, 0x1C, 0x0F ],
459 [ 0x05, 0x19, 0x01, 0x04, 0x00, 0x18, 0x1B, 0x1A, 0x07 ],
460 [ 0x09, 0x01, 0x00, 0x01, 0x05, 0x03, 0x11, 0x10, 0x01 ],
461 [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ],
462
463 [ 0x01, 0x00, 0x03, 0x41, 0x05, 0x40, 0x09, 0x11, 0x21 ],
464 [ 0x05, 0x01, 0x01, 0x19, 0x04, 0x07, 0x00, 0x18, 0x0D ],
465 [ 0x01, 0x01, 0x01, 0x05, 0x01, 0x04, 0x01, 0x00, 0x03 ],
466 [ 0x01, 0x05, 0x00, 0x0D, 0x01, 0x04, 0x07, 0x19, 0x18 ],
467 [ 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x03, 0x02 ],
468 [ 0x31, 0x01, 0x05, 0x19, 0x04, 0x07, 0x00, 0x30, 0x0D ],
469 [ 0x01, 0x00, 0x03, 0x11, 0x01, 0x05, 0x01, 0x09, 0x10 ],
470 [ 0x01, 0x05, 0x01, 0x11, 0x01, 0x10, 0x00, 0x03, 0x09 ],
471 [ 0x01, 0x09, 0x00, 0x29, 0x03, 0x08, 0x28, 0x15, 0x0B ],
472 [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ],
473
474 [ 0x01, 0x01, 0x00, 0x09, 0x15, 0x03, 0x08, 0x14, 0x0B ],
475 [ 0x11, 0x01, 0x01, 0x00, 0x09, 0x01, 0x03, 0x10, 0x05 ],
476 [ 0x01, 0x00, 0x03, 0x25, 0x11, 0x05, 0x10, 0x24, 0x13 ],
477 [ 0x11, 0x01, 0x00, 0x01, 0x09, 0x01, 0x05, 0x10, 0x03 ],
478 [ 0x05, 0x01, 0x00, 0x0D, 0x0C, 0x04, 0x0F, 0x1D, 0x1C ],
479 [ 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x03, 0x02 ],
480 [ 0x21, 0x01, 0x05, 0x09, 0x11, 0x00, 0x03, 0x41, 0x40 ],
481 [ 0x05, 0x01, 0x00, 0x1D, 0x1C, 0x0D, 0x0C, 0x0F, 0x04 ],
482 [ 0x05, 0x01, 0x00, 0x0D, 0x31, 0x04, 0x19, 0x30, 0x07 ],
483 [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ],
484
485 [ 0x01, 0x01, 0x00, 0x21, 0x05, 0x11, 0x03, 0x09, 0x20 ],
486 [ 0x01, 0x01, 0x00, 0x11, 0x03, 0x05, 0x01, 0x09, 0x10 ],
487 [ 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x03, 0x02 ],
488 [ 0x05, 0x01, 0x04, 0x19, 0x07, 0x0D, 0x00, 0x31, 0x30 ],
489 [ 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x03, 0x02 ],
490 [ 0x05, 0x01, 0x01, 0x11, 0x09, 0x00, 0x03, 0x21, 0x20 ],
491 [ 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x03, 0x02 ],
492 [ 0x01, 0x01, 0x01, 0x00, 0x01, 0x03, 0x01, 0x01, 0x02 ],
493 [ 0x09, 0x01, 0x00, 0x29, 0x08, 0x15, 0x03, 0x28, 0x0B ],
494 [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ],
495
496 [ 0x01, 0x01, 0x01, 0x05, 0x01, 0x04, 0x00, 0x01, 0x03 ],
497 [ 0x09, 0x01, 0x00, 0x29, 0x28, 0x15, 0x08, 0x03, 0x0B ],
498 [ 0x01, 0x00, 0x01, 0x11, 0x05, 0x10, 0x09, 0x01, 0x03 ],
499 [ 0x05, 0x04, 0x01, 0x1D, 0x0D, 0x0C, 0x1C, 0x00, 0x0F ],
500 [ 0x09, 0x11, 0x01, 0x41, 0x00, 0x40, 0x05, 0x03, 0x21 ],
501 [ 0x0D, 0x05, 0x01, 0x1D, 0x1C, 0x0C, 0x04, 0x00, 0x0F ],
502 [ 0x41, 0x09, 0x01, 0x40, 0x00, 0x11, 0x05, 0x03, 0x21 ],
503 [ 0x01, 0x01, 0x01, 0x05, 0x01, 0x04, 0x00, 0x01, 0x03 ],
504 [ 0x05, 0x04, 0x01, 0x0D, 0x01, 0x0C, 0x07, 0x01, 0x00 ],
505 [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ],
506
507 [ 0x05, 0x04, 0x01, 0x07, 0x19, 0x31, 0x30, 0x0D, 0x00 ],
508 [ 0x21, 0x01, 0x01, 0x00, 0x11, 0x09, 0x20, 0x05, 0x03 ],
509 [ 0x05, 0x01, 0x01, 0x04, 0x07, 0x0D, 0x0C, 0x00, 0x01 ],
510 [ 0x21, 0x09, 0x01, 0x00, 0x20, 0x05, 0x23, 0x22, 0x03 ],
511 [ 0x31, 0x0D, 0x01, 0x19, 0x05, 0x30, 0x04, 0x07, 0x00 ],
512 [ 0x31, 0x05, 0x01, 0x04, 0x19, 0x00, 0x0D, 0x30, 0x07 ],
513 [ 0x31, 0x01, 0x00, 0x0D, 0x05, 0x19, 0x04, 0x30, 0x07 ],
514 [ 0x01, 0x01, 0x01, 0x00, 0x01, 0x03, 0x02, 0x01, 0x01 ],
515 [ 0x01, 0x00, 0x01, 0x01, 0x05, 0x09, 0x08, 0x03, 0x01 ],
516 [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ],
517 ];
518 static RV40_AIC_MODE1_BITS: [[u8; 9]; 90] = [
519 [ 1, 4, 2, 7, 4, 6, 4, 7, 5 ],
520 [ 5, 1, 3, 4, 6, 3, 3, 7, 7 ],
521 [ 1, 4, 2, 7, 6, 7, 5, 4, 4 ],
522 [ 1, 3, 3, 3, 7, 4, 5, 7, 6 ],
523 [ 2, 4, 2, 6, 4, 5, 2, 4, 6 ],
524 [ 7, 2, 3, 4, 7, 1, 5, 7, 7 ],
525 [ 5, 1, 3, 6, 5, 5, 2, 7, 7 ],
526 [ 2, 5, 1, 7, 3, 7, 5, 5, 6 ],
527 [ 2, 4, 1, 4, 5, 7, 6, 7, 4 ],
528 [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
529
530 [ 2, 1, 3, 6, 5, 5, 5, 7, 7 ],
531 [ 5, 1, 3, 4, 6, 3, 3, 7, 7 ],
532 [ 4, 1, 2, 6, 5, 5, 4, 5, 6 ],
533 [ 3, 1, 3, 4, 6, 3, 5, 7, 7 ],
534 [ 4, 1, 3, 6, 3, 5, 3, 7, 7 ],
535 [ 6, 1, 4, 4, 5, 2, 4, 7, 7 ],
536 [ 7, 1, 5, 7, 4, 3, 2, 7, 7 ],
537 [ 5, 3, 2, 7, 5, 6, 1, 5, 7 ],
538 [ 4, 1, 2, 6, 7, 5, 4, 7, 4 ],
539 [ 1, 0, 1, 0, 0, 0, 0, 0, 0 ],
540
541 [ 3, 3, 1, 5, 5, 6, 6, 5, 3 ],
542 [ 6, 2, 1, 5, 6, 5, 4, 4, 5 ],
543 [ 6, 4, 1, 7, 6, 7, 6, 3, 2 ],
544 [ 4, 3, 1, 4, 6, 4, 6, 5, 3 ],
545 [ 6, 5, 1, 7, 4, 7, 3, 3, 3 ],
546 [ 7, 2, 2, 3, 7, 2, 4, 6, 5 ],
547 [ 6, 2, 2, 6, 4, 5, 2, 4, 4 ],
548 [ 4, 4, 1, 7, 6, 7, 5, 2, 4 ],
549 [ 5, 4, 1, 5, 6, 6, 5, 4, 2 ],
550 [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
551
552 [ 2, 2, 2, 3, 5, 5, 6, 6, 5 ],
553 [ 7, 1, 3, 3, 6, 3, 4, 7, 5 ],
554 [ 2, 4, 1, 4, 6, 7, 7, 5, 4 ],
555 [ 7, 4, 3, 1, 5, 3, 6, 7, 3 ],
556 [ 4, 3, 3, 4, 1, 6, 4, 6, 5 ],
557 [ 7, 4, 4, 2, 6, 1, 4, 7, 5 ],
558 [ 5, 2, 3, 4, 4, 3, 2, 5, 4 ],
559 [ 3, 5, 2, 3, 2, 5, 5, 5, 3 ],
560 [ 6, 4, 4, 2, 5, 4, 7, 7, 1 ],
561 [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
562
563 [ 2, 2, 2, 7, 3, 7, 4, 5, 6 ],
564 [ 4, 1, 3, 6, 4, 4, 3, 6, 5 ],
565 [ 2, 4, 1, 7, 3, 7, 6, 6, 6 ],
566 [ 3, 4, 3, 5, 1, 4, 4, 6, 6 ],
567 [ 4, 5, 2, 7, 1, 7, 3, 7, 7 ],
568 [ 6, 2, 3, 5, 3, 3, 2, 6, 4 ],
569 [ 4, 4, 4, 7, 2, 5, 1, 6, 7 ],
570 [ 4, 5, 2, 7, 1, 7, 4, 4, 6 ],
571 [ 2, 4, 2, 6, 2, 4, 6, 5, 4 ],
572 [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
573
574 [ 1, 3, 3, 5, 6, 3, 5, 6, 5 ],
575 [ 7, 1, 4, 4, 6, 2, 4, 7, 5 ],
576 [ 2, 2, 2, 6, 5, 3, 5, 6, 5 ],
577 [ 7, 4, 4, 2, 6, 1, 5, 7, 4 ],
578 [ 3, 2, 2, 4, 4, 3, 4, 5, 5 ],
579 [ 7, 2, 5, 3, 7, 1, 4, 7, 7 ],
580 [ 6, 2, 3, 4, 5, 2, 2, 7, 7 ],
581 [ 3, 2, 2, 5, 5, 4, 4, 4, 3 ],
582 [ 3, 2, 2, 4, 6, 3, 5, 6, 3 ],
583 [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
584
585 [ 1, 3, 3, 7, 4, 6, 3, 5, 7 ],
586 [ 4, 1, 4, 7, 4, 5, 2, 6, 7 ],
587 [ 2, 4, 1, 7, 5, 7, 3, 7, 7 ],
588 [ 3, 2, 3, 5, 3, 4, 2, 6, 6 ],
589 [ 3, 5, 4, 7, 2, 7, 1, 7, 7 ],
590 [ 4, 1, 3, 6, 5, 3, 3, 7, 7 ],
591 [ 4, 2, 5, 7, 3, 7, 1, 7, 7 ],
592 [ 7, 4, 1, 7, 3, 7, 2, 5, 7 ],
593 [ 4, 2, 2, 6, 4, 5, 2, 6, 4 ],
594 [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
595
596 [ 3, 4, 1, 7, 6, 7, 6, 2, 6 ],
597 [ 4, 2, 2, 6, 6, 5, 4, 2, 4 ],
598 [ 4, 4, 1, 7, 5, 7, 6, 2, 4 ],
599 [ 3, 3, 2, 5, 4, 4, 5, 2, 4 ],
600 [ 4, 5, 2, 7, 2, 7, 3, 2, 6 ],
601 [ 4, 3, 2, 5, 5, 4, 3, 2, 4 ],
602 [ 7, 4, 2, 7, 2, 5, 3, 2, 6 ],
603 [ 4, 6, 2, 7, 3, 7, 6, 1, 6 ],
604 [ 5, 5, 1, 6, 4, 6, 5, 2, 4 ],
605 [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
606
607 [ 3, 3, 2, 3, 5, 6, 6, 4, 2 ],
608 [ 7, 1, 3, 3, 6, 5, 7, 4, 3 ],
609 [ 5, 4, 1, 5, 5, 6, 6, 4, 2 ],
610 [ 6, 4, 2, 2, 6, 3, 6, 6, 2 ],
611 [ 6, 4, 2, 5, 3, 6, 3, 3, 2 ],
612 [ 6, 3, 2, 3, 5, 2, 4, 6, 3 ],
613 [ 6, 2, 2, 4, 3, 5, 3, 6, 3 ],
614 [ 7, 5, 1, 7, 4, 7, 7, 3, 2 ],
615 [ 5, 5, 2, 3, 6, 7, 7, 5, 1 ],
616 [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
617 ];
618
619 const RV40_AIC_MODE2_CODES: [[u16; 81]; 20] = [
620 [
621 0x0001, 0x0001, 0x0005, 0x01F5, 0x0011, 0x0049, 0x0000, 0x0048, 0x004B,
622 0x0035, 0x0003, 0x0034, 0x03C9, 0x01F4, 0x00C9, 0x004A, 0x0FD9, 0x03C8,
623 0x0010, 0x0037, 0x0001, 0x00C8, 0x0075, 0x01F7, 0x00CB, 0x0074, 0x0002,
624 0x01F6, 0x00CA, 0x01F1, 0x01F0, 0x1F81, 0x07F9, 0x1F80, 0x1F83, 0x07F8,
625 0x0077, 0x00F5, 0x0036, 0x07FB, 0x0076, 0x1F82, 0x00F4, 0x00F7, 0x07FA,
626 0x0071, 0x00F6, 0x03CB, 0x03CA, 0x0FD8, 0x00F1, 0x03F5, 0x1F8D, 0x07E5,
627 0x0013, 0x0031, 0x00F0, 0x0FDB, 0x00F3, 0x07E4, 0x0030, 0x01F3, 0x07E7,
628 0x03F4, 0x07E6, 0x0070, 0x3F19, 0x01F2, 0x3F18, 0x0FDA, 0x0033, 0x07E1,
629 0x01FD, 0x01FC, 0x0073, 0x01FF, 0x0FC5, 0x0FC4, 0x0FC7, 0x03F7, 0x0072,
630 ], [
631 0x0005, 0x0005, 0x0005, 0x0079, 0x0005, 0x000D, 0x001D, 0x0078, 0x0069,
632 0x0004, 0x0001, 0x0007, 0x0068, 0x001C, 0x001F, 0x0004, 0x006B, 0x000C,
633 0x0004, 0x001E, 0x0006, 0x006A, 0x0015, 0x000F, 0x0014, 0x0017, 0x0007,
634 0x0016, 0x000E, 0x0011, 0x0009, 0x00D1, 0x00D0, 0x0181, 0x00D3, 0x007B,
635 0x0010, 0x0013, 0x0004, 0x00D2, 0x0007, 0x0319, 0x0008, 0x007A, 0x00DD,
636 0x0019, 0x0006, 0x000B, 0x0065, 0x00DC, 0x0012, 0x0064, 0x0180, 0x00DF,
637 0x0006, 0x0018, 0x0001, 0x00DE, 0x001D, 0x00D9, 0x001B, 0x0067, 0x000A,
638 0x00D8, 0x00DB, 0x001C, 0x0318, 0x00DA, 0x0635, 0x0183, 0x0000, 0x00C5,
639 0x0066, 0x0061, 0x0035, 0x00C4, 0x0182, 0x0634, 0x031B, 0x00C7, 0x001F,
640 ], [
641 0x0005, 0x0001, 0x001D, 0x01C1, 0x0035, 0x00F1, 0x006D, 0x00F0, 0x0049,
642 0x0000, 0x0004, 0x0003, 0x00F3, 0x0048, 0x0034, 0x006C, 0x01C0, 0x01C3,
643 0x0007, 0x0006, 0x0001, 0x006F, 0x0002, 0x004B, 0x006E, 0x001C, 0x0005,
644 0x0069, 0x0068, 0x006B, 0x0037, 0x01C2, 0x00F2, 0x0395, 0x01CD, 0x00FD,
645 0x006A, 0x0036, 0x0015, 0x01CC, 0x0014, 0x0394, 0x004A, 0x00FC, 0x00FF,
646 0x0017, 0x0031, 0x00FE, 0x01CF, 0x0397, 0x00F9, 0x01CE, 0x0725, 0x0396,
647 0x0016, 0x0030, 0x0075, 0x0724, 0x00F8, 0x0727, 0x0033, 0x0391, 0x0390,
648 0x0011, 0x0032, 0x001F, 0x00FB, 0x0074, 0x0726, 0x00FA, 0x001E, 0x0077,
649 0x0019, 0x0018, 0x0004, 0x0010, 0x003D, 0x0076, 0x0071, 0x0013, 0x0001,
650 ], [
651 0x000D, 0x0019, 0x0011, 0x0015, 0x0061, 0x0019, 0x0014, 0x01AD, 0x0060,
652 0x0018, 0x0001, 0x0005, 0x001B, 0x0010, 0x0019, 0x0005, 0x0017, 0x0018,
653 0x0016, 0x0004, 0x0004, 0x0013, 0x000C, 0x0012, 0x001A, 0x0018, 0x0005,
654 0x000F, 0x001B, 0x0004, 0x001D, 0x0011, 0x001C, 0x0010, 0x000E, 0x001B,
655 0x0013, 0x001F, 0x001A, 0x0029, 0x0005, 0x0063, 0x001E, 0x0009, 0x0062,
656 0x0008, 0x0007, 0x0007, 0x0019, 0x0004, 0x001A, 0x0018, 0x006D, 0x0007,
657 0x001B, 0x0007, 0x001A, 0x006C, 0x0006, 0x0012, 0x0005, 0x006F, 0x000B,
658 0x006E, 0x0069, 0x001D, 0x0359, 0x0028, 0x002B, 0x002A, 0x001C, 0x00D5,
659 0x0358, 0x001F, 0x0001, 0x001E, 0x0068, 0x00D4, 0x00D7, 0x0019, 0x0000,
660 ], [
661 0x00B9, 0x0061, 0x0060, 0x00B8, 0x02B5, 0x01AD, 0x00BB, 0x0AF5, 0x0151,
662 0x0001, 0x0001, 0x0005, 0x0000, 0x0003, 0x0005, 0x0004, 0x0063, 0x0025,
663 0x00BA, 0x0004, 0x0007, 0x0062, 0x00A5, 0x0024, 0x006D, 0x0002, 0x006C,
664 0x02B4, 0x000D, 0x006F, 0x0027, 0x00A4, 0x0026, 0x01AC, 0x0150, 0x01AF,
665 0x01AE, 0x0021, 0x006E, 0x02B7, 0x0020, 0x0153, 0x0023, 0x00A7, 0x0152,
666 0x00A6, 0x0006, 0x000C, 0x0022, 0x01A9, 0x0019, 0x002D, 0x02B6, 0x01A8,
667 0x000F, 0x0007, 0x000E, 0x00A1, 0x0069, 0x002C, 0x0001, 0x01AB, 0x00A0,
668 0x02B1, 0x00A3, 0x002F, 0x0AF4, 0x02B0, 0x0AF7, 0x02B3, 0x0068, 0x015D,
669 0x0AF6, 0x01AA, 0x0055, 0x015C, 0x02B2, 0x0579, 0x0578, 0x015F, 0x00A2,
670 ], [
671 0x0905, 0x013D, 0x013C, 0x0904, 0x121D, 0x049D, 0x049C, 0x243D, 0x0907,
672 0x00ED, 0x0001, 0x0015, 0x0041, 0x013F, 0x0031, 0x0014, 0x025D, 0x025C,
673 0x013E, 0x000D, 0x0000, 0x0040, 0x0139, 0x0043, 0x0030, 0x0017, 0x0033,
674 0x0906, 0x0032, 0x0042, 0x00EC, 0x025F, 0x00EF, 0x025E, 0x049F, 0x0138,
675 0x0901, 0x013B, 0x0259, 0x121C, 0x049E, 0x0900, 0x0258, 0x243C, 0x121F,
676 0x0903, 0x003D, 0x00EE, 0x025B, 0x025A, 0x004D, 0x013A, 0x0902, 0x0245,
677 0x00E9, 0x0016, 0x00E8, 0x0499, 0x0125, 0x0244, 0x004C, 0x0498, 0x090D,
678 0x00EB, 0x003C, 0x0011, 0x049B, 0x049A, 0x0485, 0x00EA, 0x003F, 0x0124,
679 0x090C, 0x003E, 0x0039, 0x0095, 0x0247, 0x0246, 0x0484, 0x0094, 0x0038,
680 ], [
681 0x0F09, 0x00CD, 0x01FD, 0x0791, 0x1E6D, 0x0790, 0x03D9, 0x3CD1, 0x3CD0,
682 0x0075, 0x0001, 0x0001, 0x0035, 0x00CC, 0x0011, 0x0000, 0x03D8, 0x01FC,
683 0x03DB, 0x0010, 0x0003, 0x00CF, 0x03DA, 0x00CE, 0x0074, 0x0034, 0x0077,
684 0x0793, 0x0013, 0x0076, 0x0071, 0x03C5, 0x0070, 0x01FF, 0x0792, 0x01FE,
685 0x01F9, 0x0037, 0x00C9, 0x0F08, 0x01F8, 0x03C4, 0x00C8, 0x0F0B, 0x079D,
686 0x03C7, 0x0001, 0x0012, 0x0073, 0x00CB, 0x0005, 0x0036, 0x03C6, 0x0072,
687 0x007D, 0x0002, 0x00CA, 0x079C, 0x01FB, 0x00F5, 0x0031, 0x079F, 0x0F0A,
688 0x0F35, 0x079E, 0x01FA, 0x1E6C, 0x1E6F, 0x3CD3, 0x0799, 0x03C1, 0x1E6E,
689 0x3CD2, 0x0030, 0x00F4, 0x007C, 0x03C0, 0x03C3, 0x0798, 0x01E5, 0x00F7,
690 ], [
691 0x01A5, 0x0001, 0x001D, 0x0021, 0x00A1, 0x000D, 0x0061, 0x06B9, 0x00A0,
692 0x0060, 0x0001, 0x0005, 0x000C, 0x0020, 0x001C, 0x0004, 0x01A4, 0x01A7,
693 0x00A3, 0x001F, 0x001E, 0x0023, 0x0022, 0x002D, 0x002C, 0x0063, 0x0062,
694 0x1A81, 0x01A6, 0x01A1, 0x06B8, 0x06BB, 0x00A2, 0x06BA, 0x0D59, 0x06A5,
695 0x01A0, 0x000F, 0x006D, 0x06A4, 0x002F, 0x00AD, 0x006C, 0x06A7, 0x00AC,
696 0x0D58, 0x000E, 0x01A3, 0x00AF, 0x00AE, 0x006F, 0x01A2, 0x0D5B, 0x00A9,
697 0x0019, 0x0001, 0x0009, 0x00A8, 0x006E, 0x002E, 0x0000, 0x01AD, 0x00AB,
698 0x00AA, 0x0355, 0x0029, 0x1A80, 0x1A83, 0x1A82, 0x0354, 0x01AC, 0x0D5A,
699 0x1A8D, 0x01AF, 0x0357, 0x0D45, 0x0D44, 0x0D47, 0x1A8C, 0x06A6, 0x06A1,
700 ], [
701 0x0001, 0x0011, 0x0005, 0x0775, 0x00F9, 0x00F8, 0x0031, 0x0030, 0x0049,
702 0x00FB, 0x0010, 0x0033, 0x0EC9, 0x038D, 0x038C, 0x00FA, 0x038F, 0x0774,
703 0x0048, 0x0032, 0x0000, 0x01D5, 0x00E5, 0x038E, 0x00E4, 0x0013, 0x000D,
704 0x0389, 0x0777, 0x0388, 0x038B, 0x1DF9, 0x0EC8, 0x3BC9, 0x1DF8, 0x038A,
705 0x03B5, 0x0776, 0x00E7, 0x3BC8, 0x01D4, 0x3BCB, 0x0ECB, 0x0771, 0x0ECA,
706 0x01D7, 0x03B4, 0x01D6, 0x1DFB, 0x0EF5, 0x0770, 0x0EF4, 0x3BCA, 0x0773,
707 0x00E6, 0x03B7, 0x004B, 0x1DFA, 0x03B6, 0x0EF7, 0x00E1, 0x0EF6, 0x0EF1,
708 0x03B1, 0x01D1, 0x003D, 0x0EF0, 0x0772, 0x077D, 0x077C, 0x003C, 0x01D0,
709 0x03B0, 0x01D3, 0x003F, 0x03B3, 0x01D2, 0x0EF3, 0x077F, 0x00E0, 0x004A,
710 ], [
711 0x0015, 0x0049, 0x0014, 0x07D1, 0x03FD, 0x03FC, 0x01C1, 0x01C0, 0x00F1,
712 0x0017, 0x0001, 0x0001, 0x01C3, 0x0048, 0x004B, 0x0016, 0x0031, 0x01C2,
713 0x004A, 0x0011, 0x0000, 0x01CD, 0x00F0, 0x01CC, 0x0075, 0x0010, 0x000D,
714 0x03FF, 0x01CF, 0x01CE, 0x07D0, 0x0F81, 0x07D3, 0x1F1D, 0x0F80, 0x07D2,
715 0x01C9, 0x03FE, 0x0074, 0x07DD, 0x00F3, 0x1F1C, 0x07DC, 0x03F9, 0x07DF,
716 0x00F2, 0x00FD, 0x0077, 0x07DE, 0x07D9, 0x01C8, 0x07D8, 0x0F83, 0x03F8,
717 0x0030, 0x0076, 0x0013, 0x0F82, 0x00FC, 0x03FB, 0x0033, 0x03FA, 0x03E5,
718 0x03E4, 0x01CB, 0x0032, 0x1F1F, 0x03E7, 0x07DB, 0x07DA, 0x003D, 0x01CA,
719 0x07C5, 0x03E6, 0x0071, 0x0F8D, 0x07C4, 0x1F1E, 0x0F8C, 0x03E1, 0x01F5,
720 ], [
721 0x0019, 0x0065, 0x0018, 0x0351, 0x0350, 0x0353, 0x0021, 0x0020, 0x0064,
722 0x001D, 0x0005, 0x0005, 0x01A5, 0x0023, 0x0067, 0x0005, 0x0066, 0x0022,
723 0x001B, 0x0004, 0x0001, 0x0004, 0x001C, 0x0061, 0x001A, 0x0005, 0x0004,
724 0x0007, 0x002D, 0x0006, 0x002C, 0x01A4, 0x002F, 0x0352, 0x035D, 0x0060,
725 0x0001, 0x002E, 0x001F, 0x035C, 0x0000, 0x06B1, 0x01A7, 0x0029, 0x01A6,
726 0x0028, 0x0063, 0x0062, 0x035F, 0x01A1, 0x002B, 0x06B0, 0x06B3, 0x01A0,
727 0x0003, 0x006D, 0x001E, 0x035E, 0x006C, 0x06B2, 0x0002, 0x01A3, 0x01A2,
728 0x000D, 0x0005, 0x0007, 0x01AD, 0x006F, 0x002A, 0x006E, 0x0004, 0x0004,
729 0x000C, 0x0007, 0x0006, 0x000F, 0x000E, 0x00D5, 0x0009, 0x0006, 0x0007,
730 ], [
731 0x0065, 0x0181, 0x0064, 0x36C9, 0x06D5, 0x0DB5, 0x0379, 0x0180, 0x0183,
732 0x00D5, 0x001D, 0x001C, 0x0DB4, 0x0182, 0x0378, 0x00D4, 0x00D7, 0x06D4,
733 0x0067, 0x001F, 0x0001, 0x00D6, 0x00D1, 0x018D, 0x0066, 0x0001, 0x0000,
734 0x037B, 0x06D7, 0x037A, 0x0DB7, 0x36C8, 0x06D6, 0x0DB6, 0x1B79, 0x0DB1,
735 0x018C, 0x0365, 0x00D0, 0x1B78, 0x00D3, 0x1B7B, 0x0364, 0x06D1, 0x06D0,
736 0x018F, 0x018E, 0x00D2, 0x36CB, 0x0367, 0x0366, 0x06D3, 0x0DB0, 0x06D2,
737 0x0361, 0x06DD, 0x0189, 0x36CA, 0x0360, 0x36F5, 0x0188, 0x0DB3, 0x36F4,
738 0x0009, 0x0008, 0x0005, 0x06DC, 0x00DD, 0x018B, 0x00DC, 0x0004, 0x000B,
739 0x018A, 0x0061, 0x0003, 0x0363, 0x00DF, 0x06DF, 0x0362, 0x000A, 0x001E,
740 ], [
741 0x001D, 0x0061, 0x000D, 0x0D55, 0x06B9, 0x06B8, 0x01A5, 0x0021, 0x0020,
742 0x0023, 0x000C, 0x0060, 0x0D54, 0x00AD, 0x00AC, 0x0022, 0x00AF, 0x06BB,
743 0x000F, 0x001C, 0x0001, 0x002D, 0x0063, 0x01A4, 0x000E, 0x0001, 0x0005,
744 0x01A7, 0x06BA, 0x01A6, 0x06A5, 0x0D57, 0x0D56, 0x1ABD, 0x0D51, 0x00AE,
745 0x002C, 0x00A9, 0x002F, 0x0D50, 0x01A1, 0x1ABC, 0x06A4, 0x06A7, 0x06A6,
746 0x00A8, 0x06A1, 0x01A0, 0x1ABF, 0x0D53, 0x06A0, 0x0D52, 0x1ABE, 0x06A3,
747 0x0062, 0x002E, 0x0009, 0x0D5D, 0x01A3, 0x0D5C, 0x006D, 0x00AB, 0x06A2,
748 0x006C, 0x001F, 0x0001, 0x06AD, 0x0029, 0x01A2, 0x0028, 0x0004, 0x001E,
749 0x01AD, 0x006F, 0x0000, 0x01AC, 0x01AF, 0x06AC, 0x00AA, 0x006E, 0x0019,
750 ], [
751 0x0019, 0x007D, 0x0018, 0x01B5, 0x000D, 0x01B4, 0x007C, 0x007F, 0x01B7,
752 0x000C, 0x001B, 0x001A, 0x01B6, 0x000F, 0x00D5, 0x0019, 0x007E, 0x00D4,
753 0x0018, 0x001B, 0x0001, 0x000E, 0x0011, 0x0009, 0x0005, 0x0005, 0x0005,
754 0x00D7, 0x01B1, 0x0008, 0x01B0, 0x0079, 0x06FD, 0x0371, 0x0370, 0x00D6,
755 0x0078, 0x01B3, 0x0010, 0x0373, 0x0013, 0x06FC, 0x007B, 0x007A, 0x00D1,
756 0x00D0, 0x00D3, 0x0065, 0x0372, 0x06FF, 0x0064, 0x06FE, 0x037D, 0x00D2,
757 0x00DD, 0x0067, 0x0004, 0x037C, 0x0012, 0x01B2, 0x0007, 0x0066, 0x01BD,
758 0x0006, 0x0061, 0x0004, 0x01BC, 0x001A, 0x0060, 0x001D, 0x0004, 0x001C,
759 0x0063, 0x0001, 0x0007, 0x000B, 0x0000, 0x0062, 0x000A, 0x0005, 0x0007,
760 ], [
761 0x0069, 0x0045, 0x0068, 0x04BD, 0x0255, 0x04BC, 0x00E5, 0x00E4, 0x0031,
762 0x0030, 0x0019, 0x0001, 0x0121, 0x00E7, 0x00E6, 0x0033, 0x00E1, 0x00E0,
763 0x006B, 0x0018, 0x0001, 0x0044, 0x0032, 0x0047, 0x006A, 0x001B, 0x0005,
764 0x003D, 0x0046, 0x0015, 0x0041, 0x0120, 0x0123, 0x04BF, 0x0122, 0x0040,
765 0x003C, 0x00E3, 0x0014, 0x0254, 0x0043, 0x0975, 0x012D, 0x00E2, 0x00ED,
766 0x0042, 0x00EC, 0x004D, 0x0257, 0x0256, 0x0251, 0x04BE, 0x0974, 0x0250,
767 0x00EF, 0x00EE, 0x004C, 0x04B9, 0x012C, 0x04B8, 0x004F, 0x04BB, 0x0253,
768 0x003F, 0x0017, 0x0001, 0x0252, 0x00E9, 0x00E8, 0x00EB, 0x0000, 0x0003,
769 0x0016, 0x0002, 0x0004, 0x004E, 0x003E, 0x00EA, 0x0049, 0x000D, 0x0007,
770 ], [
771 0x000D, 0x01BD, 0x000C, 0x0D31, 0x0D30, 0x0D33, 0x0359, 0x0358, 0x002D,
772 0x0065, 0x001D, 0x001C, 0x0D32, 0x035B, 0x035A, 0x002C, 0x01BC, 0x0345,
773 0x000F, 0x001F, 0x0001, 0x002F, 0x0064, 0x01BF, 0x0067, 0x0001, 0x0005,
774 0x0066, 0x002E, 0x0061, 0x0029, 0x0695, 0x0694, 0x0697, 0x0696, 0x0060,
775 0x01BE, 0x0D3D, 0x0028, 0x1A49, 0x0344, 0x1A48, 0x1A4B, 0x0D3C, 0x0691,
776 0x002B, 0x01B9, 0x002A, 0x0D3F, 0x0690, 0x0347, 0x0D3E, 0x1A4A, 0x0346,
777 0x00D5, 0x0341, 0x0063, 0x0D39, 0x0340, 0x0D38, 0x01B8, 0x0D3B, 0x0D3A,
778 0x00D4, 0x0062, 0x0000, 0x0693, 0x01BB, 0x0343, 0x0342, 0x001E, 0x000E,
779 0x006D, 0x0009, 0x0001, 0x006C, 0x00D7, 0x034D, 0x01BA, 0x0008, 0x0004,
780 ], [
781 0x0075, 0x00CD, 0x0035, 0x03C1, 0x03C0, 0x07F9, 0x03C3, 0x1F8D, 0x00CC,
782 0x0074, 0x0011, 0x0010, 0x03C2, 0x0FD9, 0x01F1, 0x00CF, 0x03CD, 0x00CE,
783 0x0034, 0x0001, 0x0001, 0x0037, 0x00C9, 0x00C8, 0x0036, 0x0000, 0x0001,
784 0x0FD8, 0x03CC, 0x00CB, 0x01F0, 0x07F8, 0x03CF, 0x07FB, 0x07FA, 0x00CA,
785 0x01F3, 0x03CE, 0x00F5, 0x0FDB, 0x00F4, 0x07E5, 0x07E4, 0x07E7, 0x01F2,
786 0x07E6, 0x03C9, 0x01FD, 0x0FDA, 0x1F8C, 0x07E1, 0x1F8F, 0x1F8E, 0x03C8,
787 0x03CB, 0x0077, 0x0076, 0x0FC5, 0x03CA, 0x07E0, 0x00F7, 0x0FC4, 0x03F5,
788 0x00F6, 0x01FC, 0x0003, 0x03F4, 0x0071, 0x03F7, 0x00F1, 0x0013, 0x0031,
789 0x0030, 0x0070, 0x0005, 0x0012, 0x0073, 0x01FF, 0x0072, 0x007D, 0x0002,
790 ], [
791 0x0061, 0x0055, 0x0060, 0x02C9, 0x02C8, 0x02CB, 0x0171, 0x00B5, 0x0054,
792 0x0001, 0x0001, 0x0001, 0x0057, 0x0001, 0x0063, 0x001D, 0x0062, 0x0039,
793 0x006D, 0x0000, 0x0005, 0x0038, 0x0056, 0x00B4, 0x006C, 0x0003, 0x001C,
794 0x006F, 0x003B, 0x0002, 0x003A, 0x0170, 0x00B7, 0x0173, 0x0051, 0x006E,
795 0x0025, 0x0050, 0x0069, 0x02CA, 0x0024, 0x0027, 0x0172, 0x00B6, 0x00B1,
796 0x000D, 0x000C, 0x001F, 0x017D, 0x0026, 0x0068, 0x0053, 0x017C, 0x006B,
797 0x001E, 0x000F, 0x0004, 0x017F, 0x006A, 0x02F5, 0x0019, 0x0021, 0x0052,
798 0x02F4, 0x02F7, 0x0020, 0x0BCD, 0x05E5, 0x05E4, 0x0BCC, 0x0023, 0x00B0,
799 0x02F6, 0x00B3, 0x0022, 0x02F1, 0x02F0, 0x0BCF, 0x0BCE, 0x017E, 0x005D,
800 ], [
801 0x00BD, 0x0025, 0x01A1, 0x0159, 0x0299, 0x00BC, 0x0024, 0x0505, 0x0504,
802 0x01A0, 0x0001, 0x001D, 0x006D, 0x001C, 0x0001, 0x0005, 0x0027, 0x01A3,
803 0x0158, 0x001F, 0x001E, 0x01A2, 0x0026, 0x0021, 0x000D, 0x0020, 0x0023,
804 0x0298, 0x006C, 0x0022, 0x00BF, 0x00BE, 0x01AD, 0x002D, 0x029B, 0x00B9,
805 0x01AC, 0x00B8, 0x01AF, 0x029A, 0x006F, 0x015B, 0x006E, 0x0285, 0x0284,
806 0x01AE, 0x0019, 0x002C, 0x01A9, 0x01A8, 0x000C, 0x000F, 0x015A, 0x00BB,
807 0x000E, 0x0000, 0x0069, 0x01AB, 0x0018, 0x01AA, 0x0004, 0x0055, 0x00BA,
808 0x0507, 0x0145, 0x0054, 0x0506, 0x00A5, 0x0501, 0x00A4, 0x0057, 0x0500,
809 0x0A05, 0x0144, 0x00A7, 0x0287, 0x0286, 0x0503, 0x0147, 0x0A04, 0x0146,
810 ], [
811 0x0759, 0x0041, 0x00E5, 0x03BD, 0x0E9D, 0x012D, 0x012C, 0x3A1D, 0x03BC,
812 0x012F, 0x000D, 0x0040, 0x00E4, 0x03BF, 0x0043, 0x0042, 0x0758, 0x03BE,
813 0x00E7, 0x0001, 0x0000, 0x003D, 0x00E6, 0x0015, 0x0014, 0x0017, 0x003C,
814 0x743D, 0x012E, 0x03B9, 0x03B8, 0x0E9C, 0x03BB, 0x075B, 0x3A1C, 0x0E9F,
815 0x0129, 0x00E1, 0x0128, 0x0E9E, 0x012B, 0x075A, 0x00E0, 0x0E99, 0x0745,
816 0x3A1F, 0x03BA, 0x0744, 0x0E98, 0x1D0D, 0x03A5, 0x0E9B, 0x743C, 0x0E9A,
817 0x012A, 0x004D, 0x00E3, 0x0E85, 0x01D5, 0x0E84, 0x004C, 0x0747, 0x1D0C,
818 0x01D4, 0x003F, 0x0016, 0x0746, 0x03A4, 0x0741, 0x004F, 0x003E, 0x01D7,
819 0x0740, 0x000C, 0x0011, 0x004E, 0x00E2, 0x00ED, 0x00EC, 0x0049, 0x0048,
820 ]
821 ];
822 const RV40_AIC_MODE2_BITS: [[u8; 81]; 20] = [
823 [
824 1, 5, 4, 10, 6, 8, 5, 8, 8,
825 7, 5, 7, 11, 10, 9, 8, 13, 11,
826 6, 7, 3, 9, 8, 10, 9, 8, 5,
827 10, 9, 10, 10, 14, 12, 14, 14, 12,
828 8, 9, 7, 12, 8, 14, 9, 9, 12,
829 8, 9, 11, 11, 13, 9, 11, 14, 12,
830 6, 7, 9, 13, 9, 12, 7, 10, 12,
831 11, 12, 8, 15, 10, 15, 13, 7, 12,
832 10, 10, 8, 10, 13, 13, 13, 11, 8,
833 ], [
834 4, 6, 5, 11, 8, 10, 7, 11, 9,
835 4, 1, 4, 9, 7, 7, 5, 9, 10,
836 6, 7, 4, 9, 9, 10, 9, 9, 6,
837 9, 10, 9, 10, 12, 12, 13, 12, 11,
838 9, 9, 8, 12, 8, 14, 10, 11, 12,
839 7, 8, 10, 11, 12, 9, 11, 13, 12,
840 6, 7, 8, 12, 9, 12, 7, 11, 10,
841 12, 12, 9, 14, 12, 15, 13, 8, 12,
842 11, 11, 10, 12, 13, 15, 14, 12, 9,
843 ], [
844 5, 7, 6, 12, 9, 11, 8, 11, 10,
845 7, 5, 7, 11, 10, 9, 8, 12, 12,
846 5, 5, 1, 8, 7, 10, 8, 6, 4,
847 8, 8, 8, 9, 12, 11, 13, 12, 11,
848 8, 9, 8, 12, 8, 13, 10, 11, 11,
849 8, 9, 11, 12, 13, 11, 12, 14, 13,
850 8, 9, 10, 14, 11, 14, 9, 13, 13,
851 8, 9, 6, 11, 10, 14, 11, 6, 10,
852 6, 6, 4, 8, 9, 10, 10, 8, 5,
853 ], [
854 11, 7, 8, 10, 12, 9, 10, 14, 12,
855 7, 1, 5, 7, 8, 6, 4, 10, 9,
856 10, 5, 4, 8, 11, 8, 7, 6, 7,
857 11, 6, 7, 8, 10, 8, 10, 11, 9,
858 10, 8, 9, 13, 9, 12, 8, 11, 12,
859 11, 4, 7, 8, 9, 6, 8, 12, 9,
860 8, 5, 8, 12, 9, 10, 6, 12, 11,
861 12, 12, 10, 15, 13, 13, 13, 10, 13,
862 15, 10, 9, 10, 12, 13, 13, 10, 9,
863 ], [
864 11, 8, 8, 11, 13, 10, 11, 15, 12,
865 7, 1, 4, 7, 7, 5, 4, 8, 9,
866 11, 5, 5, 8, 11, 9, 8, 7, 8,
867 13, 7, 8, 9, 11, 9, 10, 12, 10,
868 10, 9, 8, 13, 9, 12, 9, 11, 12,
869 11, 5, 7, 9, 10, 6, 9, 13, 10,
870 7, 4, 7, 11, 8, 9, 5, 10, 11,
871 13, 11, 9, 15, 13, 15, 13, 8, 12,
872 15, 10, 10, 12, 13, 14, 14, 12, 11,
873 ], [
874 12, 9, 9, 12, 13, 11, 11, 14, 12,
875 8, 2, 5, 7, 9, 6, 5, 10, 10,
876 9, 4, 2, 7, 9, 7, 6, 5, 6,
877 12, 6, 7, 8, 10, 8, 10, 11, 9,
878 12, 9, 10, 13, 11, 12, 10, 14, 13,
879 12, 6, 8, 10, 10, 7, 9, 12, 10,
880 8, 5, 8, 11, 9, 10, 7, 11, 12,
881 8, 6, 5, 11, 11, 11, 8, 6, 9,
882 12, 6, 6, 8, 10, 10, 11, 8, 6,
883 ], [
884 13, 9, 10, 12, 14, 12, 11, 15, 15,
885 8, 1, 5, 7, 9, 6, 5, 11, 10,
886 11, 6, 5, 9, 11, 9, 8, 7, 8,
887 12, 6, 8, 8, 11, 8, 10, 12, 10,
888 10, 7, 9, 13, 10, 11, 9, 13, 12,
889 11, 3, 6, 8, 9, 4, 7, 11, 8,
890 8, 5, 9, 12, 10, 9, 7, 12, 13,
891 13, 12, 10, 14, 14, 15, 12, 11, 14,
892 15, 7, 9, 8, 11, 11, 12, 10, 9,
893 ], [
894 10, 5, 6, 9, 11, 7, 8, 12, 11,
895 8, 1, 4, 7, 9, 6, 4, 10, 10,
896 11, 6, 6, 9, 9, 9, 9, 8, 8,
897 14, 10, 10, 12, 12, 11, 12, 13, 12,
898 10, 7, 8, 12, 9, 11, 8, 12, 11,
899 13, 7, 10, 11, 11, 8, 10, 13, 11,
900 6, 3, 7, 11, 8, 9, 5, 10, 11,
901 11, 11, 9, 14, 14, 14, 11, 10, 13,
902 14, 10, 11, 13, 13, 13, 14, 12, 12,
903 ], [
904 2, 5, 3, 11, 8, 8, 6, 6, 7,
905 8, 5, 6, 12, 10, 10, 8, 10, 11,
906 7, 6, 2, 9, 8, 10, 8, 5, 4,
907 10, 11, 10, 10, 13, 12, 14, 13, 10,
908 10, 11, 8, 14, 9, 14, 12, 11, 12,
909 9, 10, 9, 13, 12, 11, 12, 14, 11,
910 8, 10, 7, 13, 10, 12, 8, 12, 12,
911 10, 9, 6, 12, 11, 11, 11, 6, 9,
912 10, 9, 6, 10, 9, 12, 11, 8, 7,
913 ], [
914 6, 8, 6, 12, 11, 11, 10, 10, 9,
915 6, 1, 3, 10, 8, 8, 6, 7, 10,
916 8, 6, 3, 10, 9, 10, 8, 6, 5,
917 11, 10, 10, 12, 13, 12, 14, 13, 12,
918 10, 11, 8, 12, 9, 14, 12, 11, 12,
919 9, 9, 8, 12, 12, 10, 12, 13, 11,
920 7, 8, 6, 13, 9, 11, 7, 11, 11,
921 11, 10, 7, 14, 11, 12, 12, 7, 10,
922 12, 11, 8, 13, 12, 14, 13, 11, 10,
923 ], [
924 7, 10, 7, 13, 13, 13, 11, 11, 10,
925 8, 5, 6, 12, 11, 10, 9, 10, 11,
926 7, 5, 1, 9, 8, 10, 7, 4, 4,
927 9, 11, 9, 11, 12, 11, 13, 13, 10,
928 9, 11, 8, 13, 9, 14, 12, 11, 12,
929 11, 10, 10, 13, 12, 11, 14, 14, 12,
930 9, 10, 8, 13, 10, 14, 9, 12, 12,
931 9, 7, 4, 12, 10, 11, 10, 6, 7,
932 9, 7, 4, 9, 9, 11, 9, 7, 5,
933 ], [
934 7, 9, 7, 14, 11, 12, 10, 9, 9,
935 8, 5, 5, 12, 9, 10, 8, 8, 11,
936 7, 5, 2, 8, 8, 9, 7, 4, 4,
937 10, 11, 10, 12, 14, 11, 12, 13, 12,
938 9, 10, 8, 13, 8, 13, 10, 11, 11,
939 9, 9, 8, 14, 10, 10, 11, 12, 11,
940 10, 11, 9, 14, 10, 14, 9, 12, 14,
941 6, 6, 3, 11, 8, 9, 8, 3, 6,
942 9, 7, 4, 10, 8, 11, 10, 6, 5,
943 ], [
944 6, 8, 7, 13, 12, 12, 10, 9, 9,
945 9, 7, 8, 13, 11, 11, 9, 11, 12,
946 7, 6, 1, 9, 8, 10, 7, 5, 4,
947 10, 12, 10, 12, 13, 13, 14, 13, 11,
948 9, 11, 9, 13, 10, 14, 12, 12, 12,
949 11, 12, 10, 14, 13, 12, 13, 14, 12,
950 8, 9, 7, 13, 10, 13, 8, 11, 12,
951 8, 6, 3, 12, 9, 10, 9, 4, 6,
952 10, 8, 5, 10, 10, 12, 11, 8, 6,
953 ], [
954 7, 10, 7, 12, 9, 12, 10, 10, 12,
955 9, 7, 7, 12, 9, 11, 6, 10, 11,
956 6, 6, 1, 9, 8, 9, 7, 4, 5,
957 11, 12, 9, 12, 10, 14, 13, 13, 11,
958 10, 12, 8, 13, 8, 14, 10, 10, 11,
959 11, 11, 10, 13, 14, 10, 14, 13, 11,
960 11, 10, 7, 13, 8, 12, 7, 10, 12,
961 7, 10, 4, 12, 6, 10, 8, 5, 8,
962 10, 7, 4, 9, 7, 10, 9, 6, 5,
963 ], [
964 7, 9, 7, 13, 12, 13, 10, 10, 8,
965 8, 5, 6, 11, 10, 10, 8, 10, 10,
966 7, 5, 2, 9, 8, 9, 7, 5, 3,
967 8, 9, 7, 9, 11, 11, 13, 11, 9,
968 8, 10, 7, 12, 9, 14, 11, 10, 10,
969 9, 10, 9, 12, 12, 12, 13, 14, 12,
970 10, 10, 9, 13, 11, 13, 9, 13, 12,
971 8, 7, 4, 12, 10, 10, 10, 6, 6,
972 7, 6, 3, 9, 8, 10, 9, 6, 3,
973 ], [
974 7, 10, 7, 13, 13, 13, 11, 11, 9,
975 8, 6, 6, 13, 11, 11, 9, 10, 11,
976 7, 6, 1, 9, 8, 10, 8, 5, 4,
977 8, 9, 8, 9, 12, 12, 12, 12, 8,
978 10, 13, 9, 14, 11, 14, 14, 13, 12,
979 9, 10, 9, 13, 12, 11, 13, 14, 11,
980 9, 11, 8, 13, 11, 13, 10, 13, 13,
981 9, 8, 5, 12, 10, 11, 11, 6, 7,
982 8, 7, 3, 8, 9, 11, 10, 7, 4,
983 ], [
984 8, 9, 7, 11, 11, 12, 11, 14, 9,
985 8, 6, 6, 11, 13, 10, 9, 11, 9,
986 7, 5, 1, 7, 9, 9, 7, 5, 3,
987 13, 11, 9, 10, 12, 11, 12, 12, 9,
988 10, 11, 9, 13, 9, 12, 12, 12, 10,
989 12, 11, 10, 13, 14, 12, 14, 14, 11,
990 11, 8, 8, 13, 11, 12, 9, 13, 11,
991 9, 10, 5, 11, 8, 11, 9, 6, 7,
992 7, 8, 4, 6, 8, 10, 8, 8, 5,
993 ], [
994 8, 10, 8, 13, 13, 13, 12, 11, 10,
995 5, 1, 3, 10, 7, 8, 6, 8, 9,
996 8, 7, 4, 9, 10, 11, 8, 7, 6,
997 8, 9, 7, 9, 12, 11, 12, 10, 8,
998 9, 10, 8, 13, 9, 9, 12, 11, 11,
999 7, 7, 6, 12, 9, 8, 10, 12, 8,
1000 6, 7, 4, 12, 8, 13, 6, 9, 10,
1001 13, 13, 9, 15, 14, 14, 15, 9, 11,
1002 13, 11, 9, 13, 13, 15, 15, 12, 10,
1003 ], [
1004 10, 8, 9, 11, 12, 10, 8, 13, 13,
1005 9, 2, 5, 7, 5, 4, 3, 8, 9,
1006 11, 5, 5, 9, 8, 8, 6, 8, 8,
1007 12, 7, 8, 10, 10, 9, 8, 12, 10,
1008 9, 10, 9, 12, 7, 11, 7, 12, 12,
1009 9, 5, 8, 9, 9, 6, 6, 11, 10,
1010 6, 4, 7, 9, 5, 9, 3, 9, 10,
1011 13, 11, 9, 13, 10, 13, 10, 9, 13,
1012 14, 11, 10, 12, 12, 13, 11, 14, 11,
1013 ], [
1014 11, 7, 8, 10, 12, 9, 9, 14, 10,
1015 9, 4, 7, 8, 10, 7, 7, 11, 10,
1016 8, 2, 2, 6, 8, 5, 5, 5, 6,
1017 15, 9, 10, 10, 12, 10, 11, 14, 12,
1018 9, 8, 9, 12, 9, 11, 8, 12, 11,
1019 14, 10, 11, 12, 13, 10, 12, 15, 12,
1020 9, 7, 8, 12, 9, 12, 7, 11, 13,
1021 9, 6, 5, 11, 10, 11, 7, 6, 9,
1022 11, 4, 5, 7, 8, 8, 8, 7, 7,
1023 ]
1024 ];
1025
1026 const RV40_PTYPE_CODES: &[[u8; 8]; 7] = &[
1027 [ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00 ],
1028 [ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00 ],
1029 [ 0x0D, 0x05, 0x01, 0x04, 0x01, 0x00, 0x07, 0x0C ],
1030 [ 0x09, 0x11, 0x01, 0x00, 0x05, 0x03, 0x21, 0x20 ],
1031 [ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00 ],
1032 [ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00 ],
1033 [ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00 ]
1034 ];
1035 const RV40_PTYPE_BITS: &[[u8; 8]; 7] = &[
1036 [ 1, 2, 3, 6, 5, 4, 7, 7 ],
1037 [ 3, 1, 2, 7, 6, 5, 4, 7 ],
1038 [ 5, 4, 1, 4, 3, 3, 4, 5 ],
1039 [ 4, 5, 2, 2, 3, 2, 6, 6 ],
1040 [ 5, 6, 1, 4, 2, 3, 7, 7 ],
1041 [ 5, 6, 1, 4, 3, 2, 7, 7 ],
1042 [ 6, 3, 2, 7, 5, 4, 1, 7 ]
1043 ];
1044 const RV40_PTYPE_SYMS: &[MBType; 8] = &[
1045 MBType::MBIntra,
1046 MBType::MBIntra16,
1047 MBType::MBP16x16,
1048 MBType::MBP8x8,
1049 MBType::MBP16x8,
1050 MBType::MBP8x16,
1051 MBType::MBP16x16Mix,
1052 MBType::Invalid,
1053 ];
1054
1055 const RV40_BTYPE_CODES: &[[u8; 7]; 6] = &[
1056 [ 0x01, 0x05, 0x00, 0x03, 0x11, 0x09, 0x10 ],
1057 [ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00 ],
1058 [ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00 ],
1059 [ 0x09, 0x01, 0x00, 0x01, 0x05, 0x03, 0x08 ],
1060 [ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00 ],
1061 [ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00 ]
1062 ];
1063 const RV40_BTYPE_BITS: &[[u8; 7]; 6] = &[
1064 [ 2, 3, 2, 2, 5, 4, 5 ],
1065 [ 4, 1, 3, 2, 6, 5, 6 ],
1066 [ 6, 4, 1, 2, 5, 3, 6 ],
1067 [ 5, 3, 3, 1, 4, 3, 5 ],
1068 [ 6, 5, 3, 2, 4, 1, 6 ],
1069 [ 6, 5, 3, 1, 4, 2, 6 ]
1070 ];
1071 const RV40_BTYPE_SYMS: &[MBType; 7] = &[
1072 MBType::MBIntra,
1073 MBType::MBIntra16,
1074 MBType::MBForward,
1075 MBType::MBBackward,
1076 MBType::MBBidir,
1077 MBType::MBDirect,
1078 MBType::Invalid,
1079 ];