]> git.nihav.org Git - nihav.git/blame_incremental - src/codecs/indeo/ivibr.rs
indeo4: no need to panic
[nihav.git] / src / codecs / indeo / ivibr.rs
... / ...
CommitLineData
1use std::mem;
2use std::rc::Rc;
3use std::cell::{Ref,RefCell};
4use io::bitreader::*;
5//use io::intcode::*;
6use super::super::*;
7use formats::*;
8use super::ivi::*;
9use super::ividsp::*;
10
11pub fn scale_mv(val: i32, scale: u8) -> i32 {
12 (val + (if val > 0 { 1 } else { 0 }) + (scale as i32) - 1) >> scale
13}
14
15#[derive(Clone,Copy)]
16pub struct IVICodebook {
17 len: usize,
18 bits: [u8; 16],
19 offs: [u32; 16],
20}
21
22impl IVICodebook {
23 pub fn init(&self) -> Self {
24 let mut cb = *self;
25 let mut base: u32 = 0;
26 for i in 0..cb.len {
27 cb.offs[i] = base;
28 base += 1 << cb.bits[i];
29 }
30 cb
31 }
32}
33
34pub const IVI_CB_ZERO: IVICodebook = IVICodebook { len: 0, bits: [0; 16], offs: [0; 16] };
35
36const IVI_REV0: [u32; 1] = [0];
37const IVI_REV1: [u32; 2] = [0, 1];
38const IVI_REV2: [u32; 4] = [0, 2, 1, 3];
39const IVI_REV3: [u32; 8] = [0, 4, 2, 6, 1, 5, 3, 7];
40const IVI_REV4: [u32; 16] = [ 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15];
41const IVI_REV5: [u32; 32] = [ 0, 16, 8, 24, 4, 20, 12, 28, 2, 18, 10, 26, 6, 22, 14, 30, 1, 17, 9, 25, 5, 21, 13, 29, 3, 19, 11, 27, 7, 23, 15, 31];
42const IVI_REV6: [u32; 64] = [ 0, 32, 16, 48, 8, 40, 24, 56, 4, 36, 20, 52, 12, 44, 28, 60, 2, 34, 18, 50, 10, 42, 26, 58, 6, 38, 22, 54, 14, 46, 30, 62, 1, 33, 17, 49, 9, 41, 25, 57, 5, 37, 21, 53, 13, 45, 29, 61, 3, 35, 19, 51, 11, 43, 27, 59, 7, 39, 23, 55, 15, 47, 31, 63];
43const IVI_REV7: [u32; 128] = [ 0, 64, 32, 96, 16, 80, 48, 112, 8, 72, 40, 104, 24, 88, 56, 120, 4, 68, 36, 100, 20, 84, 52, 116, 12, 76, 44, 108, 28, 92, 60, 124, 2, 66, 34, 98, 18, 82, 50, 114, 10, 74, 42, 106, 26, 90, 58, 122, 6, 70, 38, 102, 22, 86, 54, 118, 14, 78, 46, 110, 30, 94, 62, 126, 1, 65, 33, 97, 17, 81, 49, 113, 9, 73, 41, 105, 25, 89, 57, 121, 5, 69, 37, 101, 21, 85, 53, 117, 13, 77, 45, 109, 29, 93, 61, 125, 3, 67, 35, 99, 19, 83, 51, 115, 11, 75, 43, 107, 27, 91, 59, 123, 7, 71, 39, 103, 23, 87, 55, 119, 15, 79, 47, 111, 31, 95, 63, 127];
44const IVI_REV8: [u32; 256] = [ 0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240, 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248, 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244, 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252, 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250, 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246, 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254, 1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241, 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245, 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255];
45
46const IVI_REVS: [&[u32]; 9] = [ &IVI_REV0, &IVI_REV1, &IVI_REV2, &IVI_REV3, &IVI_REV4, &IVI_REV5, &IVI_REV6, &IVI_REV7, &IVI_REV8];
47
48pub trait IVICodebookReader {
49 fn read_ivi_codebook_desc(&mut self, mb_cb: bool, try_default: bool) -> DecoderResult<IVICodebook>;
50 fn read_ivi_cb(&mut self, cb: &IVICodebook) -> BitReaderResult<u32>;
51 fn read_ivi_cb_s(&mut self, cb: &IVICodebook) -> BitReaderResult<i32>;
52}
53
54impl<'a> IVICodebookReader for BitReader<'a> {
55 fn read_ivi_codebook_desc(&mut self, mb_cb: bool, desc_coded: bool) -> DecoderResult<IVICodebook> {
56 if !desc_coded {
57 if mb_cb {
58 Ok(IVI_MB_CB[7].init())
59 } else {
60 Ok(IVI_BLK_CB[7].init())
61 }
62 } else {
63 let idx = self.read(3)? as usize;
64 if idx != 7 {
65 if mb_cb {
66 Ok(IVI_MB_CB[idx].init())
67 } else {
68 Ok(IVI_BLK_CB[idx].init())
69 }
70 } else {
71 let mut cb = IVI_CB_ZERO;
72 cb.len = self.read(4)? as usize;
73 if cb.len == 0 { return Err(DecoderError::InvalidData); }
74 for i in 0..cb.len {
75 cb.bits[i] = self.read(4)? as u8;
76 }
77 Ok(cb.init())
78 }
79 }
80 }
81 #[inline(always)]
82 fn read_ivi_cb(&mut self, cb: &IVICodebook) -> BitReaderResult<u32> {
83/* let pfx = if cb.len == 1 { 0 } else { self.read_code(UintCodeType::LimitedUnary((cb.len - 1) as u32, 0))? as usize };
84 let nbits = cb.bits[pfx];
85 let mut base: u32 = 0;
86 for i in 0..pfx { base += 1 << cb.bits[i]; }
87 let rval = self.read(nbits)?;
88 let add = reverse_bits(rval, nbits);
89 Ok(base + add)*/
90 if cb.len > 1 {
91 let len = (!self.peek(16)).trailing_zeros() as usize;
92 let pfx;
93 if len >= cb.len - 1 {
94 pfx = cb.len - 1;
95 self.skip((cb.len - 1) as u32)?;
96 } else {
97 pfx = len;
98 self.skip((len + 1) as u32)?;
99 }
100 let nbits = cb.bits[pfx];
101 let base = cb.offs[pfx];
102 let rval = self.read(nbits)?;
103 let add = IVI_REVS[nbits as usize][rval as usize];
104 Ok(base + add)
105 } else {
106 let nbits = cb.bits[0];
107 return Ok(IVI_REVS[nbits as usize][self.read(nbits)? as usize]);
108 }
109 }
110 #[inline(always)]
111 fn read_ivi_cb_s(&mut self, cb: &IVICodebook) -> BitReaderResult<i32> {
112 let v = self.read_ivi_cb(cb)?;
113 if v == 0 {
114 Ok(0)
115 } else {
116 let sign = (v & 1) == 1;
117 let val = (v >> 1) as i32;
118 if sign {
119 Ok(val + 1)
120 } else {
121 Ok(-val)
122 }
123 }
124 }
125}
126
127pub const IVI_MB_CB: &[IVICodebook; 8] = &[
128 IVICodebook { len: 8, bits: [ 0, 4, 5, 4, 4, 4, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0 ], offs: [0; 16] },
129 IVICodebook { len: 12, bits: [ 0, 2, 2, 3, 3, 3, 3, 5, 3, 2, 2, 2, 0, 0, 0, 0 ], offs: [0; 16] },
130 IVICodebook { len: 12, bits: [ 0, 2, 3, 4, 3, 3, 3, 3, 4, 3, 2, 2, 0, 0, 0, 0 ], offs: [0; 16] },
131 IVICodebook { len: 12, bits: [ 0, 3, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 0, 0, 0, 0 ], offs: [0; 16] },
132 IVICodebook { len: 13, bits: [ 0, 4, 4, 3, 3, 3, 3, 2, 3, 3, 2, 1, 1, 0, 0, 0 ], offs: [0; 16] },
133 IVICodebook { len: 9, bits: [ 0, 4, 4, 4, 4, 3, 3, 3, 2, 0, 0, 0, 0, 0, 0, 0 ], offs: [0; 16] },
134 IVICodebook { len: 10, bits: [ 0, 4, 4, 4, 4, 3, 3, 2, 2, 2, 0, 0, 0, 0, 0, 0 ], offs: [0; 16] },
135 IVICodebook { len: 12, bits: [ 0, 4, 4, 4, 3, 3, 2, 3, 2, 2, 2, 2, 0, 0, 0, 0 ], offs: [0; 16] }
136];
137
138pub const IVI_BLK_CB: &[IVICodebook; 8] = &[
139 IVICodebook { len: 10, bits: [ 1, 2, 3, 4, 4, 7, 5, 5, 4, 1, 0, 0, 0, 0, 0, 0 ], offs: [0; 16] },
140 IVICodebook { len: 11, bits: [ 2, 3, 4, 4, 4, 7, 5, 4, 3, 3, 2, 0, 0, 0, 0, 0 ], offs: [0; 16] },
141 IVICodebook { len: 12, bits: [ 2, 4, 5, 5, 5, 5, 6, 4, 4, 3, 1, 1, 0, 0, 0, 0 ], offs: [0; 16] },
142 IVICodebook { len: 13, bits: [ 3, 3, 4, 4, 5, 6, 6, 4, 4, 3, 2, 1, 1, 0, 0, 0 ], offs: [0; 16] },
143 IVICodebook { len: 11, bits: [ 3, 4, 4, 5, 5, 5, 6, 5, 4, 2, 2, 0, 0, 0, 0, 0 ], offs: [0; 16] },
144 IVICodebook { len: 13, bits: [ 3, 4, 5, 5, 5, 5, 6, 4, 3, 3, 2, 1, 1, 0, 0, 0 ], offs: [0; 16] },
145 IVICodebook { len: 13, bits: [ 3, 4, 5, 5, 5, 6, 5, 4, 3, 3, 2, 1, 1, 0, 0, 0 ], offs: [0; 16] },
146 IVICodebook { len: 9, bits: [ 3, 4, 4, 5, 5, 5, 6, 5, 5, 0, 0, 0, 0, 0, 0, 0 ], offs: [0; 16] }
147];
148
149#[allow(unused_variables)]
150fn read_trans_band_header(br: &mut BitReader, w: usize, h: usize, dst: &mut [i16], dstride: usize) -> DecoderResult<()> {
151 let color_plane = br.read(2)?;
152 let bit_depth = br.read(3)?;
153 let dirty_rects = br.read(8)? as usize;
154 for i in 0..dirty_rects {
155 let x = br.read(16)?;
156 let y = br.read(16)?;
157 let l = br.read(16)?;
158 let r = br.read(16)?;
159 }
160 let has_trans_color = br.read_bool()?;
161 if has_trans_color {
162 let r = br.read(8)?;
163 let g = br.read(8)?;
164 let b = br.read(8)?;
165 }
166
167 br.skip(1)?;
168
169 let mut cb = IVI_CB_ZERO;
170 cb.len = br.read(4)? as usize;
171 if cb.len == 0 { return Err(DecoderError::InvalidData); }
172 for i in 0..cb.len {
173 cb.bits[i] = br.read(4)? as u8;
174 }
175 br.align();
176
177let tile_start = br.tell();
178 let empty = br.read_bool()?;
179 if !empty {
180 br.read_bool()?;
181 let mut len = br.read(8)? as usize;
182 if len == 255 {
183 len = br.read(24)? as usize;
184 }
185 br.align();
186let tile_end = tile_start + len * 8;
187
188 let first_val = br.read_bool()?;
189
190 let mut dec_size = 0;
191 let mut x = 0;
192 let mut y = 0;
193 let mut fill = if !first_val { 255-128 } else { 0-128 };
194 let tr_w = (w + 31) & !31;
195 while br.tell() < tile_end {
196 let code = br.read_ivi_cb(&cb)? as usize;
197 if code == 0 {
198 dec_size += 255;
199 for _ in 0..255 {
200 if (x < w) && (y < h) {
201 dst[x + y * dstride] = fill;
202 }
203 x += 1;
204 if x == tr_w {
205 x = 0;
206 y += 1;
207 }
208 }
209 } else {
210 dec_size += code;
211 for _ in 0..code {
212 if (x < w) && (y < h) {
213 dst[x + y * dstride] = fill;
214 }
215 x += 1;
216 if x == tr_w {
217 x = 0;
218 y += 1;
219 }
220 }
221 fill = !fill;
222 }
223 }
224 br.align();
225 } else {
226 }
227
228 Ok(())
229}
230
231fn decode_block8x8(br: &mut BitReader, blk_cb: &IVICodebook, rvmap: &RVMap, tables: &TxParams8x8, is_intra: bool, is_2d: bool, prev_dc: &mut i32, quant: u8, coeffs: &mut [i32; 64], transform: &TrFunc) -> DecoderResult<()> {
232 let mut idx: isize = -1;
233 let quant_mat = if is_intra { tables.quant_intra } else { tables.quant_inter };
234 while idx <= 64 {
235 let c = br.read_ivi_cb(blk_cb)?;
236 if c == rvmap.eob_sym { break; }
237 let run;
238 let val: i32;
239 if c != rvmap.esc_sym {
240 validate!(c < 256);
241 run = rvmap.runtab[c as usize] as isize;
242 val = rvmap.valtab[c as usize] as i32;
243 } else {
244 run = (br.read_ivi_cb(blk_cb)? as isize) + 1;
245 let lo = br.read_ivi_cb(blk_cb)?;
246 let hi = br.read_ivi_cb(blk_cb)?;
247 let v = (hi << 6) + lo;
248 if v == 0 {
249 val = 0; // should not happen but still...
250 } else {
251 let vv = (v >> 1) as i32;
252 if (v & 1) != 0 {
253 val = vv + 1;
254 } else {
255 val = -vv;
256 }
257 }
258 }
259 idx += run;
260 validate!((idx >= 0) && (idx < 64));
261
262 let spos = tables.scan[idx as usize];
263 let q = ((quant_mat[spos] as u32) * (quant as u32)) >> 9;
264 if q > 1 {
265 let qq = q as i32;
266 let bias = (((q ^ 1) - 1) >> 1) as i32;
267 coeffs[spos] = val * qq;
268 if val > 0 { coeffs[spos] += bias; }
269 else { coeffs[spos] -= bias; }
270 } else {
271 coeffs[spos] = val;
272 }
273 }
274 if is_intra && is_2d {
275 *prev_dc += coeffs[0];
276 coeffs[0] = *prev_dc;
277 }
278 (transform)(coeffs);
279 Ok(())
280}
281fn decode_block4x4(br: &mut BitReader, blk_cb: &IVICodebook, rvmap: &RVMap, tables: &TxParams4x4, is_intra: bool, is_2d: bool, prev_dc: &mut i32, quant: u8, coeffs: &mut [i32; 64], transform: &TrFunc) -> DecoderResult<()> {
282 let mut idx: isize = -1;
283 let quant_mat = if is_intra { tables.quant_intra } else { tables.quant_inter };
284 while idx <= 64 {
285 let c = br.read_ivi_cb(blk_cb)?;
286 if c == rvmap.eob_sym { break; }
287 let run;
288 let val: i32;
289 if c != rvmap.esc_sym {
290 validate!(c < 256);
291 run = rvmap.runtab[c as usize] as isize;
292 val = rvmap.valtab[c as usize] as i32;
293 } else {
294 run = (br.read_ivi_cb(blk_cb)? as isize) + 1;
295 let lo = br.read_ivi_cb(blk_cb)?;
296 let hi = br.read_ivi_cb(blk_cb)?;
297 let v = (hi << 6) + lo;
298 if v == 0 {
299 val = 0; // should not happen but still...
300 } else {
301 if (v & 1) != 0 {
302 val = ((v >> 1) as i32) + 1;
303 } else {
304 val = -((v >> 1) as i32);
305 }
306 }
307 }
308 idx += run;
309 validate!((idx >= 0) && (idx < 16));
310
311 let spos = tables.scan[idx as usize];
312 let q = ((quant_mat[spos] as u32) * (quant as u32)) >> 9;
313 if q > 1 {
314 let qq = q as i32;
315 let bias = (((q ^ 1) - 1) >> 1) as i32;
316 coeffs[spos] = val * qq;
317 if val > 0 { coeffs[spos] += bias; }
318 else { coeffs[spos] -= bias; }
319 } else {
320 coeffs[spos] = val;
321 }
322 }
323 if is_intra && is_2d {
324 *prev_dc += coeffs[0];
325 coeffs[0] = *prev_dc;
326 }
327 (transform)(coeffs);
328 Ok(())
329}
330
331fn put_block(frame: &mut [i16], offs: usize, stride: usize, blk: &[i32], blk_size: usize) {
332 unsafe {
333 let mut dptr = frame.as_mut_ptr().offset(offs as isize);
334 for y in 0..blk_size {
335 for x in 0..blk_size {
336 *dptr.offset(x as isize) = blk[x + y * blk_size] as i16;
337 }
338 dptr = dptr.offset(stride as isize);
339 }
340 }
341}
342
343fn add_block(frame: &mut [i16], offs: usize, stride: usize, blk: &[i32], blk_size: usize) {
344 unsafe {
345 let mut dptr = frame.as_mut_ptr().offset(offs as isize);
346 for y in 0..blk_size {
347 for x in 0..blk_size {
348 *dptr.offset(x as isize) = (*dptr.offset(x as isize)).wrapping_add(blk[x + y * blk_size] as i16);
349 }
350 dptr = dptr.offset(stride as isize);
351 }
352 }
353}
354
355struct FrameData {
356 plane_buf: [Vec<i16>; 4],
357 plane_stride: [usize; 4],
358 pic_hdr: PictureHeader,
359}
360
361fn align(val: usize, bits: u8) -> usize {
362 let mask = (1 << bits) - 1;
363 (val + mask) & !mask
364}
365
366impl FrameData {
367 fn new() -> Rc<RefCell<Self>> {
368 Rc::new(RefCell::new(FrameData {
369 plane_buf: [Vec::new(), Vec::new(), Vec::new(), Vec::new()],
370 plane_stride: [0, 0, 0, 0],
371 pic_hdr: PictureHeader::new_null(IVIFrameType::Intra),
372 }))
373 }
374 fn realloc(&mut self, pic_hdr: &PictureHeader) -> DecoderResult<()> {
375 let width = align(pic_hdr.width, 6);
376 let height = align(pic_hdr.height, 6);
377
378 let stride = width;
379 self.plane_buf[0].resize(stride * height, 0);
380 self.plane_stride[0] = stride;
381 for plane in 1..3 {
382 self.plane_buf[plane].resize((stride >> 1) * (height >> 1), 0);
383 self.plane_stride[plane] = stride >> 1;
384 }
385 if pic_hdr.transparent {
386 self.plane_buf[3].resize(stride * height, 0);
387 self.plane_stride[3] = stride;
388 }
389 self.pic_hdr = *pic_hdr;
390 Ok(())
391 }
392 fn fill_plane(&mut self, vb: &mut NAVideoBuffer<u8>, plane: usize) {
393 let (w, h) = vb.get_dimensions(plane);
394 let mut didx = vb.get_offset(plane);
395 let dstride = vb.get_stride(plane);
396 let mut dst = vb.get_data_mut();
397 let src = &self.plane_buf[plane];
398 let mut sidx = 0;
399 let sstride = self.plane_stride[plane];
400 for _ in 0..h {
401 for x in 0..w {
402 dst[didx + x] = clip8(src[sidx + x] + 128);
403 }
404 didx += dstride;
405 sidx += sstride;
406 }
407 }
408}
409
410fn do_mc(dst: &mut [i16], dstride: usize, src: &[i16], sstride: usize, x: usize, y: usize, l: usize, r: usize, t: usize, b: usize, mv_x: i32, mv_y: i32, is_hpel: bool, blk_size: usize) {
411 let (xoff, yoff, mv_mode) = if is_hpel {
412 (mv_x >> 1, mv_y >> 1, ((mv_x & 1) + (mv_y & 1) * 2) as u8)
413 } else{
414 (mv_x, mv_y, 0)
415 };
416 let xpos = (x as isize) + (xoff as isize);
417 let ypos = (y as isize) + (yoff as isize);
418 if (xpos < (l as isize)) || ((xpos as usize) + blk_size + ((mv_mode & 1) as usize) > r) ||
419 (ypos < (t as isize)) || ((ypos as usize) + blk_size + ((mv_mode >> 1) as usize) > b) {
420//println!(" copy from {},{} of {}-{},{}-{} {}x{}!", xpos, ypos, l,r,t,b,blk_size,blk_size);
421 return;
422 }
423 let sidx = (xpos as usize) + (ypos as usize) * sstride;
424 if blk_size == 8 {
425 ivi_mc_put(dst, dstride, &src[sidx..], sstride, mv_mode, 8, 8);
426 } else {
427 ivi_mc_put(dst, dstride, &src[sidx..], sstride, mv_mode, 4, 4);
428 }
429}
430
431fn do_mc_b(dst: &mut [i16], dstride: usize, src1: &[i16], sstride1: usize, src2: &[i16], sstride2: usize, x: usize, y: usize, l: usize, r: usize, t: usize, b: usize, mv_x: i32, mv_y: i32, mv2_x: i32, mv2_y: i32, is_hpel: bool, blk_size: usize) {
432 let (xoff1, yoff1, mv_mode1) = if is_hpel {
433 (mv_x >> 1, mv_y >> 1, ((mv_x & 1) + (mv_y & 1) * 2) as u8)
434 } else{
435 (mv_x, mv_y, 0)
436 };
437 let xpos1 = (x as isize) + (xoff1 as isize);
438 let ypos1 = (y as isize) + (yoff1 as isize);
439 if (xpos1 < (l as isize)) || ((xpos1 as usize) + blk_size + ((mv_mode1 & 1) as usize) > r) ||
440 (ypos1 < (t as isize)) || ((ypos1 as usize) + blk_size + ((mv_mode1 >> 1) as usize) > b) {
441 return;
442 }
443 let sidx1 = (xpos1 as usize) + (ypos1 as usize) * sstride1;
444 let (xoff2, yoff2, mv_mode2) = if is_hpel {
445 (mv2_x >> 1, mv2_y >> 1, ((mv2_x & 1) + (mv2_y & 1) * 2) as u8)
446 } else{
447 (mv2_x, mv2_y, 0)
448 };
449 let xpos2 = (x as isize) + (xoff2 as isize);
450 let ypos2 = (y as isize) + (yoff2 as isize);
451 if (xpos2 < (l as isize)) || ((xpos2 as usize) + blk_size + ((mv_mode2 & 1) as usize) > r) ||
452 (ypos2 < (t as isize)) || ((ypos2 as usize) + blk_size + ((mv_mode2 >> 1) as usize) > b) {
453 return;
454 }
455 let sidx2 = (xpos2 as usize) + (ypos2 as usize) * sstride2;
456 ivi_mc_avg(dst, dstride, &src1[sidx1..], sstride1, mv_mode1, &src2[sidx2..], sstride2, mv_mode2, blk_size, blk_size);
457}
458
459pub trait IndeoXParser {
460 fn decode_picture_header(&mut self, br: &mut BitReader) -> DecoderResult<PictureHeader>;
461 fn decode_band_header(&mut self, br: &mut BitReader, pic_hdr: &PictureHeader, plane: usize, band: usize) -> DecoderResult<BandHeader>;
462 fn decode_mb_info(&mut self, br: &mut BitReader, pic_hdr: &PictureHeader, band_hdr: &BandHeader, tile: &mut IVITile, ref_tile: Option<Ref<IVITile>>, mv_scale: u8) -> DecoderResult<()>;
463 fn recombine_plane(&mut self, src: &[i16], sstride: usize, dst: &mut [u8], dstride: usize, w: usize, h: usize);
464}
465
466const MISSING_REF: usize = 42;
467
468pub struct IVIDecoder {
469 ftype: IVIFrameType,
470 frames: [Rc<RefCell<FrameData>>; 4],
471 cur_frame: usize,
472 prev_frame: usize,
473 next_frame: usize,
474 iref_0: usize,
475 iref_1: usize,
476 scal_ref: usize,
477 vinfo: NAVideoInfo,
478 vinfoa: NAVideoInfo,
479 bref: Option<NABufferType>,
480
481 bands: Vec<BandHeader>,
482 tiles: Vec<Rc<RefCell<IVITile>>>,
483 num_tiles: [[usize; 4]; 4],
484 tile_start: [[usize; 4]; 4],
485}
486
487impl IVIDecoder {
488 pub fn new() -> Self {
489 let mut bands: Vec<BandHeader> = Vec::with_capacity(12);
490 bands.resize(12, BandHeader::new_empty(42, 42));
491 IVIDecoder {
492 ftype: IVIFrameType::NULL,
493 frames: [FrameData::new(), FrameData::new(), FrameData::new(), FrameData::new()],
494 cur_frame: 0, prev_frame: MISSING_REF, next_frame: MISSING_REF,
495 iref_0: MISSING_REF, iref_1: MISSING_REF, scal_ref: MISSING_REF,
496 vinfo: NAVideoInfo::new(0, 0, false, YUV410_FORMAT),
497 vinfoa: NAVideoInfo::new(0, 0, false, YUVA410_FORMAT),
498 bref: None,
499
500 bands: bands,
501 tiles: Vec::new(), tile_start: [[0; 4]; 4], num_tiles: [[0; 4]; 4],
502 }
503 }
504
505 fn realloc(&mut self, pic_hdr: &PictureHeader) -> DecoderResult<()> {
506 let planes = if pic_hdr.transparent { 4 } else { 3 };
507
508 //self.bands.truncate(0);
509 self.tiles.truncate(0);
510 self.num_tiles = [[0; 4]; 4];
511 self.tile_start = [[0; 4]; 4];
512 let mut tstart: usize = 0;
513 for plane in 0..planes {
514 let is_luma = (plane != 1) && (plane != 2);
515 let bands = if is_luma { pic_hdr.luma_bands } else { pic_hdr.chroma_bands };
516 let mut band_w = if is_luma { pic_hdr.width } else { (pic_hdr.width + 3) >> 2 };
517 let mut band_h = if is_luma { pic_hdr.height } else { (pic_hdr.height + 3) >> 2 };
518 let mut tile_w = if is_luma { pic_hdr.slice_w } else { (pic_hdr.slice_w + 3) >> 2 };
519 let mut tile_h = if is_luma { pic_hdr.slice_h } else { (pic_hdr.slice_h + 3) >> 2 };
520 if bands > 1 {
521 band_w = (band_w + 1) >> 1;
522 band_h = (band_h + 1) >> 1;
523 if plane == 0 {
524 tile_w = (tile_w + 1) >> 1;
525 tile_h = (tile_h + 1) >> 1;
526 }
527 }
528 for band in 0..bands {
529 self.tile_start[plane][band] = tstart;
530 let band_xoff = if (band & 1) == 1 { band_w } else { 0 };
531 let band_yoff = if (band & 2) == 2 { band_h } else { 0 };
532 let mut y = 0;
533 while y < band_h {
534 let cur_h = if y + tile_h <= band_h { tile_h } else { band_h - y };
535 let mut x = 0;
536 while x < band_w {
537 let cur_w = if x + tile_w <= band_w { tile_w } else { band_w - x };
538 let tile = IVITile::new(band_xoff + x, band_yoff + y, cur_w, cur_h);
539 self.tiles.push(Rc::new(RefCell::new(tile)));
540 self.num_tiles[plane][band] += 1;
541 tstart += 1;
542 x += tile_w;
543 }
544 y += tile_h;
545 }
546 }
547 }
548 Ok(())
549 }
550 fn decode_band(&mut self, pic_hdr: &PictureHeader, dec: &mut IndeoXParser, br: &mut BitReader, plane_no: usize, band_no: usize) -> DecoderResult<()> {
551 let bidx = match plane_no {
552 0 => { band_no },
553 _ => { pic_hdr.luma_bands + plane_no - 1 },
554 };
555 let prev_band = if bidx >= self.bands.len() { BandHeader::new_empty(plane_no, band_no) } else { self.bands[bidx].clone() };
556 let mut band = dec.decode_band_header(br, pic_hdr, plane_no, band_no)?;
557 if let TxType::None = band.ttype {
558 validate!(band.plane_no == prev_band.plane_no);
559 validate!(band.band_no == prev_band.band_no);
560 validate!(band.blk_size == prev_band.blk_size);
561 band.tr = prev_band.tr;
562 band.ttype = prev_band.ttype;
563 };
564
565 let tstart = self.tile_start[band.plane_no][band.band_no];
566 let tend = tstart + self.num_tiles[band.plane_no][band.band_no];
567 let mb_size = band.mb_size;
568 let (tr, tr_dc) = match band.ttype {
569 TxType::Transform4(_) => { ivi_get_transform4x4_funcs(band.tr) },
570 TxType::Transform8(_) => { ivi_get_transform8x8_funcs(band.tr) },
571 _ => { ivi_get_transform4x4_funcs(band.tr) },
572 };
573 for tile_no in tstart..tend {
574 {
575 let mut tile = self.tiles[tile_no].borrow_mut();
576 let mb_w = (tile.w + mb_size - 1) / mb_size;
577 let mb_h = (tile.h + mb_size - 1) / mb_size;
578 tile.mb_w = mb_w;
579 tile.mb_h = mb_h;
580 tile.mb.truncate(0);
581 tile.mb.resize(mb_w * mb_h, MB::new(0, 0));
582 }
583
584 let tile_start = br.tell();
585 if !br.read_bool()? {
586 let res = br.read_bool()?;
587 validate!(res);
588 let mut len = br.read(8)? as usize;
589 if len == 255 {
590 len = br.read(24)? as usize;
591 }
592 br.align();
593 validate!(len > 0);
594 let tile_end = tile_start + len * 8;
595 validate!(tile_end > br.tell());
596 validate!(tile_end <= br.tell() + (br.left() as usize));
597 {
598 let mut tile = self.tiles[tile_no].borrow_mut();
599 let ref_tile: Option<Ref<IVITile>>;
600 let mv_scale;
601 if (plane_no == 0) && (band_no == 0) {
602 mv_scale = 0;
603 } else {
604 mv_scale = (((self.bands[0].mb_size >> 3) as i8) - ((band.mb_size >> 3) as i8)) as u8;
605 }
606 if plane_no != 0 || band_no != 0 {
607 let rtile = self.tiles[0].borrow();
608 if (tile.mb_w != rtile.mb_w) || (tile.mb_h != rtile.mb_h) {
609 ref_tile = None;
610 } else {
611 ref_tile = Some(rtile);
612 }
613 } else {
614 ref_tile = None;
615 }
616 dec.decode_mb_info(br, pic_hdr, &band, &mut tile, ref_tile, mv_scale)?;
617 }
618
619 self.decode_tile(br, &band, tile_no, &tr, &tr_dc)?;
620let skip_part = tile_end - br.tell();
621br.skip(skip_part as u32)?;
622 } else {
623 {
624 let mut tile = self.tiles[tile_no].borrow_mut();
625 let ref_tile: Option<Ref<IVITile>>;
626 let mv_scale;
627 if (plane_no == 0) && (band_no == 0) {
628 mv_scale = 0;
629 } else {
630 mv_scale = (((self.bands[0].mb_size >> 3) as i8) - ((band.mb_size >> 3) as i8)) as u8;
631 }
632 if plane_no != 0 || band_no != 0 {
633 let rtile = self.tiles[0].borrow();
634 if (tile.mb_w != rtile.mb_w) || (tile.mb_h != rtile.mb_h) {
635 ref_tile = None;
636 } else {
637 ref_tile = Some(rtile);
638 }
639 } else {
640 ref_tile = None;
641 }
642 let mut mb_idx = 0;
643 for mb_y in 0..tile.mb_h {
644 for mb_x in 0..tile.mb_w {
645 let mut mb = MB::new(tile.pos_x + mb_x * band.mb_size, tile.pos_y + mb_y * band.mb_size);
646 mb.mtype = MBType::Inter;
647 mb.cbp = 0;
648 if band.inherit_mv {
649 if let Some(ref tileref) = ref_tile {
650 let mx = tileref.mb[mb_idx].mv_x;
651 let my = tileref.mb[mb_idx].mv_y;
652 mb.mv_x = scale_mv(mx, mv_scale);
653 mb.mv_y = scale_mv(my, mv_scale);
654 }
655 }
656 tile.mb[mb_idx] = mb;
657 mb_idx += 1;
658 }
659 }
660 }
661 self.decode_tile(br, &band, tile_no, &tr, &tr_dc)?;
662 }
663 }
664 self.bands[bidx] = band;
665 br.align();
666 Ok(())
667 }
668 fn decode_tile(&mut self, br: &mut BitReader, band: &BandHeader, tile_no: usize, tr: &TrFunc, transform_dc: &TrFuncDC) -> DecoderResult<()> {
669 let mut mb_idx = 0;
670 let mut prev_dc: i32 = 0;
671 let mut tile = self.tiles[tile_no].borrow_mut();
672 let mut frame = self.frames[self.cur_frame].borrow_mut();
673
674 let stride = frame.plane_stride[band.plane_no];
675 let mut dstidx = tile.pos_x + tile.pos_y * stride;
676 let mut dst = &mut frame.plane_buf[band.plane_no];
677 let pos_x = tile.pos_x;
678 let pos_y = tile.pos_y;
679 let tile_w = (tile.w + 15) & !15;
680 let tile_h = (tile.h + 15) & !15;
681 for mb_y in 0..tile.mb_h {
682 for mb_x in 0..tile.mb_w {
683 let mb = &mut tile.mb[mb_idx];
684
685 let is_intra = mb.mtype == MBType::Intra;
686
687 if band.mb_size != band.blk_size {
688 let mut cbp = mb.cbp;
689 for blk_no in 0..4 {
690 let mut blk: [i32; 64] = [0; 64];
691 let boff = (blk_no & 1) * 8 + (blk_no & 2) * 4 * stride + mb_x * 16;
692 if !is_intra {
693 if mb.mtype != MBType::Bidir {
694 let idx;
695 if mb.mtype != MBType::Backward {
696 idx = self.prev_frame;
697 } else {
698 idx = self.next_frame;
699 }
700 let pf = self.frames[idx].borrow();
701 do_mc(&mut dst[dstidx + boff..], stride,
702 &pf.plane_buf[band.plane_no], pf.plane_stride[band.plane_no],
703 pos_x + mb_x * 16 + (blk_no & 1) * 8,
704 pos_y + mb_y * 16 + (blk_no & 2) * 4,
705 pos_x, pos_x + tile_w, pos_y, pos_y + tile_h,
706 mb.mv_x, mb.mv_y, band.halfpel, 8);
707 } else {
708 let pf = self.frames[self.prev_frame].borrow();
709 let nf = self.frames[self.next_frame].borrow();
710 do_mc_b(&mut dst[dstidx + boff..], stride,
711 &pf.plane_buf[band.plane_no], pf.plane_stride[band.plane_no],
712 &nf.plane_buf[band.plane_no], nf.plane_stride[band.plane_no],
713 pos_x + mb_x * 16 + (blk_no & 1) * 8,
714 pos_y + mb_y * 16 + (blk_no & 2) * 4,
715 pos_x, pos_x + tile_w, pos_y, pos_y + tile_h,
716 mb.mv_x, mb.mv_y, mb.mv2_x, mb.mv2_y, band.halfpel,
717 band.blk_size);
718 }
719 }
720 if (cbp & 1) != 0 {
721 if let TxType::Transform8(ref params) = band.ttype {
722 decode_block8x8(br, &band.blk_cb, &band.rvmap, params, is_intra, band.tr.is_2d(), &mut prev_dc, mb.q, &mut blk, tr)?;
723 if is_intra {
724 put_block(&mut dst, dstidx + boff, stride, &blk, 8);
725 } else {
726 add_block(&mut dst, dstidx + boff, stride, &blk, 8);
727 }
728 }
729 } else {
730 if is_intra {
731 (transform_dc)(&mut blk, prev_dc);
732 put_block(&mut dst, dstidx + boff, stride, &blk, 8);
733 }
734 }
735 cbp >>= 1;
736 }
737 } else {
738 let mut blk: [i32; 64] = [0; 64];
739 if !is_intra {
740 if mb.mtype != MBType::Bidir {
741 let idx;
742 if mb.mtype != MBType::Backward {
743 idx = self.prev_frame;
744 } else {
745 idx = self.next_frame;
746 }
747 let pf = self.frames[idx].borrow();
748 do_mc(&mut dst[dstidx + mb_x * band.blk_size..], stride,
749 &pf.plane_buf[band.plane_no], pf.plane_stride[band.plane_no],
750 pos_x + mb_x * band.mb_size,
751 pos_y + mb_y * band.mb_size,
752 pos_x, pos_x + tile_w, pos_y, pos_y + tile_h,
753 mb.mv_x, mb.mv_y, band.halfpel, band.blk_size);
754 } else {
755 let pf = self.frames[self.prev_frame].borrow();
756 let nf = self.frames[self.next_frame].borrow();
757 do_mc_b(&mut dst[dstidx + mb_x * band.blk_size..], stride,
758 &pf.plane_buf[band.plane_no], pf.plane_stride[band.plane_no],
759 &nf.plane_buf[band.plane_no], nf.plane_stride[band.plane_no],
760 pos_x + mb_x * band.mb_size,
761 pos_y + mb_y * band.mb_size,
762 pos_x, pos_x + tile_w, pos_y, pos_y + tile_h,
763 mb.mv_x, mb.mv_y, mb.mv2_x, mb.mv2_y, band.halfpel,
764 band.blk_size);
765 }
766 }
767 if mb.cbp != 0 {
768 if let TxType::Transform8(ref params) = band.ttype {
769 decode_block8x8(br, &band.blk_cb, &band.rvmap, params, is_intra, band.tr.is_2d(), &mut prev_dc, mb.q, &mut blk, tr)?;
770 }
771 if let TxType::Transform4(ref params) = band.ttype {
772 decode_block4x4(br, &band.blk_cb, &band.rvmap, params, is_intra, band.tr.is_2d(), &mut prev_dc, mb.q, &mut blk, tr)?;
773 }
774 if is_intra {
775 if band.blk_size == 8 {
776 put_block(&mut dst, dstidx + mb_x * band.blk_size, stride, &blk, 8);
777 } else {
778 put_block(&mut dst, dstidx + mb_x * band.blk_size, stride, &blk, 4);
779 }
780 } else {
781 if band.blk_size == 8 {
782 add_block(&mut dst, dstidx + mb_x * band.blk_size, stride, &blk, 8);
783 } else {
784 add_block(&mut dst, dstidx + mb_x * band.blk_size, stride, &blk, 4);
785 }
786 }
787 } else {
788 if is_intra {
789 (transform_dc)(&mut blk, prev_dc);
790 if band.blk_size == 8 {
791 put_block(&mut dst, dstidx + mb_x * band.blk_size, stride, &blk, 8);
792 } else {
793 put_block(&mut dst, dstidx + mb_x * band.blk_size, stride, &blk, 4);
794 }
795 }
796 }
797 }
798 mb_idx += 1;
799 }
800 dstidx += stride * band.mb_size;
801 }
802 br.align();
803 Ok(())
804 }
805
806 fn find_unused_frame(&self) -> usize {
807 for fno in 0..4 {
808 if (fno != self.iref_0) && (fno != self.iref_1) && (fno != self.scal_ref) {
809 return fno;
810 }
811 }
812 unreachable!();
813 }
814
815 fn decode_single_frame<'a>(&mut self, dec: &mut IndeoXParser, br: &mut BitReader<'a>) -> DecoderResult<NABufferType> {
816 let pic_hdr = dec.decode_picture_header(br)?;
817 self.ftype = pic_hdr.ftype;
818 if pic_hdr.ftype.is_null() {
819 return Ok(NABufferType::None);
820 }
821
822 self.cur_frame = self.find_unused_frame();
823 match self.ftype {
824 IVIFrameType::Inter => {
825 self.prev_frame = self.iref_0;
826 if self.prev_frame == MISSING_REF {
827 return Err(DecoderError::MissingReference);
828 }
829 },
830 IVIFrameType::InterDroppable => {
831 self.prev_frame = self.scal_ref;
832 if self.prev_frame == MISSING_REF {
833 return Err(DecoderError::MissingReference);
834 }
835 },
836 IVIFrameType::InterScal => {
837 self.prev_frame = self.scal_ref;
838 if self.prev_frame == MISSING_REF {
839 return Err(DecoderError::MissingReference);
840 }
841 },
842 IVIFrameType::Bidir => {
843 self.prev_frame = self.iref_1;
844 self.next_frame = self.iref_0;
845 if (self.prev_frame == MISSING_REF) || (self.next_frame == MISSING_REF) {
846 return Err(DecoderError::MissingReference);
847 }
848 },
849 _ => {},
850 };
851
852 let mut vinfo;
853 if pic_hdr.transparent {
854 vinfo = self.vinfoa.clone();
855 } else {
856 vinfo = self.vinfo.clone();
857 }
858 vinfo.set_width(pic_hdr.width);
859 vinfo.set_height(pic_hdr.height);
860 let mut buftype = alloc_video_buffer(vinfo, 0)?;
861 self.realloc(&pic_hdr)?;
862 self.frames[self.cur_frame].borrow_mut().realloc(&pic_hdr)?;
863
864 for plane in 0..3 {
865 let num_bands = if plane == 0 { pic_hdr.luma_bands } else { pic_hdr.chroma_bands };
866 for band in 0..num_bands {
867 self.decode_band(&pic_hdr, dec, br, plane, band)?;
868 }
869 if let NABufferType::Video(ref mut vb) = buftype {
870 let mut frame = self.frames[self.cur_frame].borrow_mut();
871 if num_bands == 1 {
872 frame.fill_plane(vb, plane);
873 } else {
874 let (w, h) = vb.get_dimensions(plane);
875 let dstride = vb.get_stride(plane);
876 let off = vb.get_offset(plane);
877 let mut dst = vb.get_data_mut();
878 dec.recombine_plane(&frame.plane_buf[plane], frame.plane_stride[plane], &mut dst[off..], dstride, w, h);
879 }
880 }
881 }
882 if pic_hdr.transparent {
883 let mut frame = self.frames[self.cur_frame].borrow_mut();
884 let stride = frame.plane_stride[3];
885 read_trans_band_header(br, pic_hdr.width, pic_hdr.height, &mut frame.plane_buf[3], stride)?;
886 if let NABufferType::Video(ref mut vb) = buftype {
887 frame.fill_plane(vb, 3);
888 }
889 }
890
891 match self.ftype {
892 IVIFrameType::Intra | IVIFrameType::Inter => {
893 self.iref_1 = self.iref_0;
894 self.iref_0 = self.cur_frame;
895 self.scal_ref = self.cur_frame;
896 },
897 IVIFrameType::InterScal => {
898 self.scal_ref = self.cur_frame;
899 },
900 _ => {},
901 };
902
903 Ok(buftype)
904 }
905
906 pub fn decode_frame<'a>(&mut self, dec: &mut IndeoXParser, br: &mut BitReader<'a>) -> DecoderResult<NABufferType> {
907 let res = self.decode_single_frame(dec, br);
908 if res.is_err() { return res; }
909 if (self.ftype == IVIFrameType::Intra) && (br.left() > 16) {
910 loop {
911 if br.left() < 8 { break; }
912 if br.read(8)? == 0 { break; }
913 }
914 loop {
915 if br.left() < 8 { break; }
916 if br.peek(8) != 0 { break; }
917 br.skip(8)?;
918 }
919 if br.left() > 24 {
920 let seq = br.peek(21);
921 if seq == 0xBFFF8 {
922 let res2 = self.decode_single_frame(dec, br);
923 if res2.is_ok() {
924 self.bref = Some(res2.unwrap());
925 }
926 }
927 self.ftype = IVIFrameType::Intra;
928 }
929 }
930 if let Ok(NABufferType::None) = res {
931 if self.bref.is_some() {
932 let mut bref: Option<NABufferType> = None;
933 mem::swap(&mut bref, &mut self.bref);
934 self.ftype = IVIFrameType::Inter;
935 return Ok(bref.unwrap());
936 }
937 }
938 res
939 }
940
941 pub fn is_intra(&mut self) -> bool {
942 self.ftype.is_intra()
943 }
944 pub fn get_frame_type(&mut self) -> FrameType {
945 match self.ftype {
946 IVIFrameType::Intra => { FrameType::I },
947 IVIFrameType::Intra1 => { FrameType::I },
948 IVIFrameType::Inter => { FrameType::P },
949 IVIFrameType::InterDroppable => { FrameType::P },
950 IVIFrameType::InterScal => { FrameType::P },
951 IVIFrameType::Bidir => { FrameType::B },
952 _ => { FrameType::Skip },
953 }
954 }
955}
956
957pub struct RVMap {
958 pub eob_sym: u32,
959 pub esc_sym: u32,
960 pub runtab: [u8; 256],
961 pub valtab: [i8; 256],
962}
963
964impl Clone for RVMap {
965 fn clone(&self) -> RVMap {
966 let mut runtab: [u8; 256] = [0; 256];
967 let mut valtab: [i8; 256] = [0; 256];
968 runtab.copy_from_slice(&self.runtab);
969 valtab.copy_from_slice(&self.valtab);
970 RVMap { eob_sym: self.eob_sym, esc_sym: self.esc_sym, runtab: runtab, valtab: valtab }
971 }
972}
973
974pub const IVI_ZERO_RVMAP: RVMap = RVMap { eob_sym: 0, esc_sym: 0, runtab: [0; 256], valtab: [0; 256] };
975
976pub static IVI_RVMAPS: [RVMap; 9] = [
977 RVMap { eob_sym: 5, esc_sym: 2, runtab: [
978 1, 1, 0, 1, 1, 0, 1, 1, 2, 2, 1, 1, 1, 1, 3, 3,
979 1, 1, 2, 2, 1, 1, 4, 4, 1, 1, 1, 1, 2, 2, 5, 5,
980 1, 1, 3, 3, 1, 1, 6, 6, 1, 2, 1, 2, 7, 7, 1, 1,
981 8, 8, 1, 1, 4, 2, 1, 4, 2, 1, 3, 3, 1, 1, 1, 9,
982 9, 1, 2, 1, 2, 1, 5, 5, 1, 1, 10, 10, 1, 1, 3, 3,
983 2, 2, 1, 1, 11, 11, 6, 4, 4, 1, 6, 1, 2, 1, 2, 12,
984 8, 1, 12, 7, 8, 7, 1, 16, 1, 16, 1, 3, 3, 13, 1, 13,
985 2, 2, 1, 15, 1, 5, 14, 15, 1, 5, 14, 1, 17, 8, 17, 8,
986 1, 4, 4, 2, 2, 1, 25, 25, 24, 24, 1, 3, 1, 3, 1, 8,
987 6, 7, 6, 1, 18, 8, 18, 1, 7, 23, 2, 2, 23, 1, 1, 21,
988 22, 9, 9, 22, 19, 1, 21, 5, 19, 5, 1, 33, 20, 33, 20, 8,
989 4, 4, 1, 32, 2, 2, 8, 3, 32, 26, 3, 1, 7, 7, 26, 6,
990 1, 6, 1, 1, 16, 1, 10, 1, 10, 2, 16, 29, 28, 2, 29, 28,
991 1, 27, 5, 8, 5, 27, 1, 8, 3, 7, 3, 31, 41, 31, 1, 41,
992 6, 1, 6, 7, 4, 4, 1, 1, 2, 1, 2, 11, 34, 30, 11, 1,
993 30, 15, 15, 34, 36, 40, 36, 40, 35, 35, 37, 37, 39, 39, 38, 38 ],
994 valtab: [
995 1, -1, 0, 2, -2, 0, 3, -3, 1, -1, 4, -4, 5, -5, 1, -1,
996 6, -6, 2, -2, 7, -7, 1, -1, 8, -8, 9, -9, 3, -3, 1, -1,
997 10, -10, 2, -2, 11, -11, 1, -1, 12, 4, -12, -4, 1, -1, 13, -13,
998 1, -1, 14, -14, 2, 5, 15, -2, -5, -15, -3, 3, 16, -16, 17, 1,
999 -1, -17, 6, 18, -6, -18, 2, -2, 19, -19, 1, -1, 20, -20, 4, -4,
1000 7, -7, 21, -21, 1, -1, 2, 3, -3, 22, -2, -22, 8, 23, -8, 1,
1001 2, -23, -1, 2, -2, -2, 24, 1, -24, -1, 25, 5, -5, 1, -25, -1,
1002 9, -9, 26, 1, -26, 3, 1, -1, 27, -3, -1, -27, 1, 3, -1, -3,
1003 28, -4, 4, 10, -10, -28, 1, -1, 1, -1, 29, 6, -29, -6, 30, -4,
1004 3, 3, -3, -30, 1, 4, -1, 31, -3, 1, 11, -11, -1, -31, 32, -1,
1005 -1, 2, -2, 1, 1, -32, 1, 4, -1, -4, 33, -1, 1, 1, -1, 5,
1006 5, -5, -33, -1, -12, 12, -5, -7, 1, 1, 7, 34, 4, -4, -1, 4,
1007 -34, -4, 35, 36, -2, -35, -2, -36, 2, 13, 2, -1, 1, -13, 1, -1,
1008 37, 1, -5, 6, 5, -1, 38, -6, -8, 5, 8, -1, 1, 1, -37, -1,
1009 5, 39, -5, -5, 6, -6, -38, -39, -14, 40, 14, 2, 1, 1, -2, -40,
1010 -1, -2, 2, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1 ],
1011 },
1012 RVMap { eob_sym: 0, esc_sym: 38, runtab: [
1013 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 8, 6, 8, 7,
1014 7, 9, 9, 10, 10, 11, 11, 1, 12, 1, 12, 13, 13, 16, 14, 16,
1015 14, 15, 15, 17, 17, 18, 0, 18, 19, 20, 21, 19, 22, 21, 20, 22,
1016 25, 24, 2, 25, 24, 23, 23, 2, 26, 28, 26, 28, 29, 27, 29, 27,
1017 33, 33, 1, 32, 1, 3, 32, 30, 36, 3, 36, 30, 31, 31, 35, 34,
1018 37, 41, 34, 35, 37, 4, 41, 4, 49, 8, 8, 49, 40, 38, 5, 38,
1019 40, 39, 5, 39, 42, 43, 42, 7, 57, 6, 43, 44, 6, 50, 7, 44,
1020 57, 48, 50, 48, 45, 45, 46, 47, 51, 46, 47, 58, 1, 51, 58, 1,
1021 52, 59, 53, 9, 52, 55, 55, 59, 53, 56, 54, 56, 54, 9, 64, 64,
1022 60, 63, 60, 63, 61, 62, 61, 62, 2, 10, 2, 10, 11, 1, 11, 13,
1023 12, 1, 12, 13, 16, 16, 8, 8, 14, 3, 3, 15, 14, 15, 4, 4,
1024 1, 17, 17, 5, 1, 7, 7, 5, 6, 1, 2, 2, 6, 22, 1, 25,
1025 21, 22, 8, 24, 1, 21, 25, 24, 8, 18, 18, 23, 9, 20, 23, 33,
1026 29, 33, 20, 1, 19, 1, 29, 36, 9, 36, 19, 41, 28, 57, 32, 3,
1027 28, 3, 1, 27, 49, 49, 1, 32, 26, 26, 2, 4, 4, 7, 57, 41,
1028 2, 7, 10, 5, 37, 16, 10, 27, 8, 8, 13, 16, 37, 13, 1, 5 ],
1029 valtab: [
1030 0, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1,
1031 -1, 1, -1, 1, -1, 1, -1, 2, 1, -2, -1, 1, -1, 1, 1, -1,
1032 -1, 1, -1, 1, -1, 1, 0, -1, 1, 1, 1, -1, 1, -1, -1, -1,
1033 1, 1, 2, -1, -1, 1, -1, -2, 1, 1, -1, -1, 1, 1, -1, -1,
1034 1, -1, 3, 1, -3, 2, -1, 1, 1, -2, -1, -1, -1, 1, 1, 1,
1035 1, 1, -1, -1, -1, 2, -1, -2, 1, 2, -2, -1, 1, 1, 2, -1,
1036 -1, 1, -2, -1, 1, 1, -1, 2, 1, 2, -1, 1, -2, -1, -2, -1,
1037 -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 4, -1, -1, -4,
1038 1, 1, 1, 2, -1, -1, 1, -1, -1, 1, -1, -1, 1, -2, 1, -1,
1039 1, 1, -1, -1, 1, 1, -1, -1, 3, 2, -3, -2, 2, 5, -2, 2,
1040 2, -5, -2, -2, -2, 2, -3, 3, 2, 3, -3, 2, -2, -2, 3, -3,
1041 6, 2, -2, 3, -6, 3, -3, -3, 3, 7, -4, 4, -3, 2, -7, 2,
1042 2, -2, -4, 2, 8, -2, -2, -2, 4, 2, -2, 2, 3, 2, -2, -2,
1043 2, 2, -2, -8, -2, 9, -2, 2, -3, -2, 2, -2, 2, 2, 2, 4,
1044 -2, -4, 10, 2, 2, -2, -9, -2, 2, -2, 5, 4, -4, 4, -2, 2,
1045 -5, -4, -3, 4, 2, -3, 3, -2, -5, 5, 3, 3, -2, -3, -10, -4 ],
1046 },
1047 RVMap { eob_sym: 2, esc_sym: 11, runtab: [
1048 1, 1, 0, 2, 2, 1, 1, 3, 3, 4, 4, 0, 1, 1, 5, 5,
1049 2, 2, 6, 6, 7, 7, 1, 8, 1, 8, 3, 3, 9, 9, 1, 2,
1050 2, 1, 4, 10, 4, 10, 11, 11, 1, 5, 12, 12, 1, 5, 13, 13,
1051 3, 3, 6, 6, 2, 2, 14, 14, 16, 16, 15, 7, 15, 8, 8, 7,
1052 1, 1, 17, 17, 4, 4, 1, 1, 18, 18, 2, 2, 5, 5, 25, 3,
1053 9, 3, 25, 9, 19, 24, 19, 24, 1, 21, 20, 1, 21, 22, 20, 22,
1054 23, 23, 8, 6, 33, 6, 8, 33, 7, 7, 26, 26, 1, 32, 1, 32,
1055 28, 4, 28, 10, 29, 27, 27, 10, 41, 4, 29, 2, 2, 41, 36, 31,
1056 49, 31, 34, 30, 34, 36, 30, 35, 1, 49, 11, 5, 35, 11, 1, 3,
1057 3, 5, 37, 37, 8, 40, 8, 40, 12, 12, 42, 42, 1, 38, 16, 57,
1058 1, 6, 16, 39, 38, 6, 7, 7, 13, 13, 39, 43, 2, 43, 57, 2,
1059 50, 9, 44, 9, 50, 4, 15, 48, 44, 4, 1, 15, 48, 14, 14, 1,
1060 45, 45, 8, 3, 5, 8, 51, 47, 3, 46, 46, 47, 5, 51, 1, 17,
1061 17, 58, 1, 58, 2, 52, 52, 2, 53, 7, 59, 6, 6, 56, 53, 55,
1062 7, 55, 1, 54, 59, 56, 54, 10, 1, 10, 4, 60, 1, 60, 8, 4,
1063 8, 64, 64, 61, 1, 63, 3, 63, 62, 61, 5, 11, 5, 3, 11, 62 ],
1064 valtab: [
1065 1, -1, 0, 1, -1, 2, -2, 1, -1, 1, -1, 0, 3, -3, 1, -1,
1066 2, -2, 1, -1, 1, -1, 4, 1, -4, -1, 2, -2, 1, -1, 5, 3,
1067 -3, -5, 2, 1, -2, -1, 1, -1, 6, 2, 1, -1, -6, -2, 1, -1,
1068 3, -3, 2, -2, 4, -4, 1, -1, 1, -1, 1, 2, -1, 2, -2, -2,
1069 7, -7, 1, -1, 3, -3, 8, -8, 1, -1, 5, -5, 3, -3, 1, 4,
1070 2, -4, -1, -2, 1, 1, -1, -1, 9, 1, 1, -9, -1, 1, -1, -1,
1071 1, -1, 3, -3, 1, 3, -3, -1, 3, -3, 1, -1, 10, 1, -10, -1,
1072 1, 4, -1, 2, 1, -1, 1, -2, 1, -4, -1, 6, -6, -1, 1, 1,
1073 1, -1, 1, 1, -1, -1, -1, 1, 11, -1, -2, 4, -1, 2, -11, 5,
1074 -5, -4, -1, 1, 4, 1, -4, -1, -2, 2, 1, -1, 12, 1, -2, 1,
1075 -12, 4, 2, 1, -1, -4, 4, -4, 2, -2, -1, 1, 7, -1, -1, -7,
1076 -1, -3, 1, 3, 1, 5, 2, 1, -1, -5, 13, -2, -1, 2, -2, -13,
1077 1, -1, 5, 6, 5, -5, 1, 1, -6, 1, -1, -1, -5, -1, 14, 2,
1078 -2, 1, -14, -1, 8, 1, -1, -8, 1, 5, 1, 5, -5, 1, -1, 1,
1079 -5, -1, 15, 1, -1, -1, -1, 3, -15, -3, 6, 1, 16, -1, 6, -6,
1080 -6, 1, -1, 1, -16, 1, 7, -1, 1, -1, -6, -3, 6, -7, 3, -1 ]
1081 },
1082 RVMap { eob_sym: 0, esc_sym: 35, runtab: [
1083 0, 1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 5, 5, 6, 6, 7,
1084 7, 8, 8, 9, 9, 2, 2, 10, 10, 1, 1, 11, 11, 12, 12, 3,
1085 3, 13, 13, 0, 14, 14, 16, 15, 16, 15, 4, 4, 17, 1, 17, 1,
1086 5, 5, 18, 18, 2, 2, 6, 6, 8, 19, 7, 8, 7, 19, 20, 20,
1087 21, 21, 22, 24, 22, 24, 23, 23, 1, 1, 25, 25, 3, 3, 26, 26,
1088 9, 9, 27, 27, 28, 28, 33, 29, 4, 33, 29, 1, 4, 1, 32, 32,
1089 2, 2, 31, 10, 30, 10, 30, 31, 34, 34, 5, 5, 36, 36, 35, 41,
1090 35, 11, 41, 11, 37, 1, 8, 8, 37, 6, 1, 6, 40, 7, 7, 40,
1091 12, 38, 12, 39, 39, 38, 49, 13, 49, 13, 3, 42, 3, 42, 16, 16,
1092 43, 43, 14, 14, 1, 1, 44, 15, 44, 15, 2, 2, 57, 48, 50, 48,
1093 57, 50, 4, 45, 45, 4, 46, 47, 47, 46, 1, 51, 1, 17, 17, 51,
1094 8, 9, 9, 5, 58, 8, 58, 5, 52, 52, 55, 56, 53, 56, 55, 59,
1095 59, 53, 54, 1, 6, 54, 7, 7, 6, 1, 2, 3, 2, 3, 64, 60,
1096 60, 10, 10, 64, 61, 62, 61, 63, 1, 63, 62, 1, 18, 24, 18, 4,
1097 25, 4, 8, 21, 21, 1, 24, 22, 25, 22, 8, 11, 19, 11, 23, 1,
1098 20, 23, 19, 20, 5, 12, 5, 1, 16, 2, 12, 13, 2, 13, 1, 16 ],
1099 valtab: [
1100 0, 1, -1, 1, -1, 1, -1, 1, -1, 2, -2, 1, -1, 1, -1, 1,
1101 -1, 1, -1, 1, -1, 2, -2, 1, -1, 3, -3, 1, -1, 1, -1, 2,
1102 -2, 1, -1, 0, 1, -1, 1, 1, -1, -1, 2, -2, 1, 4, -1, -4,
1103 2, -2, 1, -1, -3, 3, 2, -2, 2, 1, 2, -2, -2, -1, 1, -1,
1104 1, -1, 1, 1, -1, -1, 1, -1, 5, -5, 1, -1, 3, -3, 1, -1,
1105 2, -2, 1, -1, 1, -1, 1, 1, 3, -1, -1, 6, -3, -6, -1, 1,
1106 4, -4, 1, 2, 1, -2, -1, -1, 1, -1, 3, -3, 1, -1, 1, 1,
1107 -1, 2, -1, -2, 1, 7, -3, 3, -1, 3, -7, -3, 1, -3, 3, -1,
1108 2, 1, -2, 1, -1, -1, 1, 2, -1, -2, -4, -1, 4, 1, 2, -2,
1109 1, -1, -2, 2, 8, -8, -1, 2, 1, -2, -5, 5, 1, -1, -1, 1,
1110 -1, 1, 4, -1, 1, -4, -1, -1, 1, 1, 9, 1, -9, 2, -2, -1,
1111 -4, 3, -3, -4, -1, 4, 1, 4, 1, -1, 1, -1, 1, 1, -1, 1,
1112 -1, -1, -1, 10, 4, 1, 4, -4, -4, -10, 6, 5, -6, -5, 1, -1,
1113 1, 3, -3, -1, 1, -1, -1, -1, 11, 1, 1, -11, -2, -2, 2, 5,
1114 -2, -5, -5, 2, -2, 12, 2, -2, 2, 2, 5, -3, -2, 3, -2, -12,
1115 -2, 2, 2, 2, -5, 3, 5, 13, -3, 7, -3, -3, -7, 3, -13, 3 ]
1116 },
1117 RVMap { eob_sym: 0, esc_sym: 34, runtab: [
1118 0, 1, 1, 1, 2, 2, 1, 3, 3, 1, 1, 1, 4, 4, 1, 5,
1119 2, 1, 5, 2, 1, 1, 6, 6, 1, 1, 1, 1, 1, 7, 3, 1,
1120 2, 3, 0, 1, 2, 7, 1, 1, 1, 8, 1, 1, 8, 1, 1, 1,
1121 9, 1, 9, 1, 2, 1, 1, 2, 1, 1, 10, 4, 1, 10, 1, 4,
1122 1, 1, 1, 1, 1, 3, 1, 1, 1, 3, 2, 1, 5, 1, 1, 1,
1123 2, 5, 1, 11, 1, 11, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1124 2, 1, 6, 1, 6, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 12,
1125 3, 1, 12, 1, 1, 1, 2, 1, 1, 3, 1, 1, 1, 1, 1, 1,
1126 4, 1, 1, 1, 2, 1, 1, 4, 1, 1, 1, 1, 1, 1, 2, 1,
1127 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 2, 1, 1, 5,
1128 1, 1, 1, 1, 1, 7, 1, 7, 1, 1, 2, 3, 1, 1, 1, 1,
1129 5, 1, 1, 1, 1, 1, 1, 2, 13, 1, 1, 1, 1, 1, 1, 1,
1130 1, 1, 1, 1, 1, 1, 1, 1, 13, 2, 1, 1, 4, 1, 1, 1,
1131 3, 1, 6, 1, 1, 1, 14, 1, 1, 1, 1, 1, 14, 6, 1, 1,
1132 1, 1, 15, 2, 4, 1, 2, 3, 15, 1, 1, 1, 8, 1, 1, 8,
1133 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1 ],
1134 valtab: [
1135 0, 1, -1, 2, 1, -1, -2, 1, -1, 3, -3, 4, 1, -1, -4, 1,
1136 2, 5, -1, -2, -5, 6, 1, -1, -6, 7, -7, 8, -8, 1, 2, 9,
1137 3, -2, 0, -9, -3, -1, 10, -10, 11, 1, -11, 12, -1, -12, 13, -13,
1138 1, 14, -1, -14, 4, 15, -15, -4, 16, -16, 1, 2, 17, -1, -17, -2,
1139 18, -18, 19, -19, 20, 3, -20, 21, -21, -3, 5, 22, 2, -22, -23, 23,
1140 -5, -2, 24, 1, -24, -1, 25, -25, 26, -26, -27, 27, 28, 29, -28, -29,
1141 6, 30, 2, -31, -2, -30, 31, -6, -32, 32, 33, -33, 34, -35, -34, 1,
1142 4, -36, -1, 35, 37, 36, 7, -37, 38, -4, -38, 39, 41, 40, -40, -39,
1143 3, 42, -43, -41, -7, -42, 43, -3, 44, -44, 45, -45, 46, 47, 8, -47,
1144 -48, -46, 50, -50, 48, 49, 51, -49, 52, -52, 5, -51, -8, -53, 53, 3,
1145 -56, 56, 55, 54, -54, 2, 60, -2, -55, 58, 9, -5, 59, 57, -57, -63,
1146 -3, -58, -60, -61, 61, -59, -62, -9, 1, 64, 62, 69, -64, 63, 65, -67,
1147 -68, 66, -65, 68, -66, -69, 67, -70, -1, 10, 71, -71, 4, 73, 72, 70,
1148 6, -76, -3, 74, -78, -74, 1, 78, 80, -72, -75, 76, -1, 3, -73, 79,
1149 75, 77, 1, 11, -4, -79, -10, -6, -1, -77, -83, -80, 2, 81, -84, -2,
1150 83, -81, 82, -82, 84, -87, -86, 85, -11, -85, 86, -89, 87, -88, 88, 89 ]
1151 },
1152 RVMap { eob_sym: 2, esc_sym: 33, runtab: [
1153 1, 1, 0, 2, 1, 2, 1, 3, 3, 1, 1, 4, 4, 2, 2, 1,
1154 1, 5, 5, 6, 1, 6, 1, 7, 7, 3, 3, 2, 8, 2, 8, 1,
1155 1, 0, 9, 9, 1, 1, 10, 4, 10, 4, 11, 11, 2, 1, 2, 1,
1156 12, 12, 3, 3, 1, 1, 13, 5, 5, 13, 14, 1, 1, 14, 2, 2,
1157 6, 6, 15, 1, 1, 15, 16, 4, 7, 16, 4, 7, 1, 1, 3, 3,
1158 8, 8, 2, 2, 1, 1, 17, 17, 1, 1, 18, 18, 5, 5, 2, 2,
1159 1, 1, 9, 19, 9, 19, 20, 3, 3, 20, 1, 10, 21, 1, 10, 4,
1160 4, 21, 22, 6, 6, 22, 1, 1, 23, 24, 2, 2, 23, 24, 11, 1,
1161 1, 11, 7, 25, 7, 1, 1, 25, 8, 8, 3, 26, 3, 1, 12, 2,
1162 2, 26, 1, 12, 5, 5, 27, 4, 1, 4, 1, 27, 28, 1, 28, 13,
1163 1, 13, 2, 29, 2, 1, 32, 6, 1, 30, 14, 29, 14, 6, 3, 31,
1164 3, 1, 30, 1, 32, 31, 33, 9, 33, 1, 1, 7, 9, 7, 2, 2,
1165 1, 1, 4, 36, 34, 4, 5, 10, 10, 5, 34, 1, 1, 35, 8, 8,
1166 36, 3, 35, 1, 15, 3, 2, 1, 16, 15, 16, 2, 37, 1, 37, 1,
1167 1, 1, 6, 6, 38, 1, 38, 11, 1, 39, 39, 40, 11, 2, 41, 4,
1168 40, 1, 2, 4, 1, 1, 1, 41, 3, 1, 3, 1, 5, 7, 5, 7 ],
1169 valtab: [
1170 1, -1, 0, 1, 2, -1, -2, 1, -1, 3, -3, 1, -1, 2, -2, 4,
1171 -4, 1, -1, 1, 5, -1, -5, 1, -1, 2, -2, 3, 1, -3, -1, 6,
1172 -6, 0, 1, -1, 7, -7, 1, 2, -1, -2, 1, -1, 4, 8, -4, -8,
1173 1, -1, 3, -3, 9, -9, 1, 2, -2, -1, 1, 10, -10, -1, 5, -5,
1174 2, -2, 1, 11, -11, -1, 1, 3, 2, -1, -3, -2, 12, -12, 4, -4,
1175 2, -2, -6, 6, 13, -13, 1, -1, 14, -14, 1, -1, 3, -3, 7, -7,
1176 15, -15, 2, 1, -2, -1, 1, 5, -5, -1, -16, 2, 1, 16, -2, 4,
1177 -4, -1, 1, 3, -3, -1, 17, -17, 1, 1, -8, 8, -1, -1, 2, 18,
1178 -18, -2, 3, 1, -3, 19, -19, -1, 3, -3, 6, 1, -6, 20, 2, 9,
1179 -9, -1, -20, -2, 4, -4, 1, -5, 21, 5, -21, -1, 1, -22, -1, 2,
1180 22, -2, 10, 1, -10, 23, 1, 4, -23, 1, 2, -1, -2, -4, -7, 1,
1181 7, -24, -1, 24, -1, -1, 1, 3, -1, -25, 25, 4, -3, -4, 11, -11,
1182 26, -26, 6, 1, 1, -6, -5, -3, 3, 5, -1, -27, 27, 1, 4, -4,
1183 -1, -8, -1, 28, 2, 8, -12, -28, -2, -2, 2, 12, -1, 29, 1, -29,
1184 30, -30, 5, -5, 1, -31, -1, 3, 31, -1, 1, 1, -3, -13, 1, -7,
1185 -1, -32, 13, 7, 32, 33, -33, -1, -9, -34, 9, 34, -6, 5, 6, -5 ]
1186 },
1187 RVMap { eob_sym: 2, esc_sym: 13, runtab: [
1188 1, 1, 0, 1, 1, 2, 2, 1, 1, 3, 3, 1, 1, 0, 2, 2,
1189 4, 1, 4, 1, 1, 1, 5, 5, 1, 1, 6, 6, 2, 2, 1, 1,
1190 3, 3, 7, 7, 1, 1, 8, 8, 1, 1, 2, 2, 1, 9, 1, 9,
1191 4, 4, 10, 1, 1, 10, 1, 1, 11, 11, 3, 3, 1, 2, 1, 2,
1192 1, 1, 12, 12, 5, 5, 1, 1, 13, 1, 1, 13, 2, 2, 1, 1,
1193 6, 6, 1, 1, 4, 14, 4, 14, 3, 1, 3, 1, 1, 1, 15, 7,
1194 15, 2, 2, 7, 1, 1, 1, 8, 1, 8, 16, 16, 1, 1, 1, 1,
1195 2, 1, 1, 2, 1, 1, 3, 5, 5, 3, 4, 1, 1, 4, 1, 1,
1196 17, 17, 9, 1, 1, 9, 2, 2, 1, 1, 10, 10, 1, 6, 1, 1,
1197 6, 18, 1, 1, 18, 1, 1, 1, 2, 2, 3, 1, 3, 1, 1, 1,
1198 4, 1, 19, 1, 19, 7, 1, 1, 20, 1, 4, 20, 1, 7, 11, 2,
1199 1, 11, 21, 2, 8, 5, 1, 8, 1, 5, 21, 1, 1, 1, 22, 1,
1200 1, 22, 1, 1, 3, 3, 1, 23, 2, 12, 24, 1, 1, 2, 1, 1,
1201 12, 23, 1, 1, 24, 1, 1, 1, 4, 1, 1, 1, 2, 1, 6, 6,
1202 4, 2, 1, 1, 1, 1, 1, 1, 1, 14, 13, 3, 1, 25, 9, 25,
1203 14, 1, 9, 3, 13, 1, 1, 1, 1, 1, 10, 1, 1, 2, 10, 2 ],
1204 valtab: [
1205 -20, -1, 0, 2, -2, 1, -1, 3, -3, 1, -1, 4, -4, 0, 2, -2,
1206 1, 5, -1, -5, 6, -6, 1, -1, 7, -7, 1, -1, 3, -3, 8, -8,
1207 2, -2, 1, -1, 9, -9, 1, -1, 10, -10, 4, -4, 11, 1, -11, -1,
1208 2, -2, 1, 12, -12, -1, 13, -13, 1, -1, 3, -3, 14, 5, -14, -5,
1209 -15, 15, -1, 1, 2, -2, 16, -16, 1, 17, -17, -1, 6, -6, 18, -18,
1210 2, -2, -19, 19, -3, 1, 3, -1, 4, 20, -4, 1, -21, 21, 1, 2,
1211 -1, -7, 7, -2, 22, -22, 23, 2, -23, -2, 1, -1, -24, 24, -25, 25,
1212 -8, -26, 26, 8, -27, 27, 5, 3, -3, -5, -4, 28, -28, 4, 29, -29,
1213 1, -1, -2, -30, 30, 2, 9, -9, -31, 31, 2, -2, -32, 3, 32, -33,
1214 -3, 1, 33, -34, -1, 34, -35, 35, -10, 10, -6, 36, 6, -36, 37, -37,
1215 -5, 38, 1, -38, -1, 3, 39, -39, -1, 40, 5, 1, -40, -3, 2, -11,
1216 -41, -2, 1, 11, -3, -4, 41, 3, 42, 4, -1, -43, -42, 43, 1, -44,
1217 45, -1, 44, -45, -7, 7, -46, 1, -12, 2, 1, -47, 46, 12, 47, 48,
1218 -2, -1, -48, 49, -1, -50, -49, 50, -6, -51, 51, 52, -13, 53, -4, 4,
1219 6, 13, -53, -52, -54, 55, 54, -55, -56, -2, 2, -8, 56, 1, -3, -1,
1220 2, 58, 3, 8, -2, 57, -58, -60, -59, -57, -3, 60, 59, -14, 3, 14 ]
1221 },
1222 RVMap { eob_sym: 2, esc_sym: 38, runtab: [
1223 1, 1, 0, 2, 2, 1, 1, 3, 3, 4, 4, 5, 5, 1, 1, 6,
1224 6, 2, 2, 7, 7, 8, 8, 1, 1, 3, 3, 9, 9, 10, 10, 1,
1225 1, 2, 2, 4, 4, 11, 0, 11, 12, 12, 13, 13, 1, 1, 5, 5,
1226 14, 14, 15, 16, 15, 16, 3, 3, 1, 6, 1, 6, 2, 2, 7, 7,
1227 8, 8, 17, 17, 1, 1, 4, 4, 18, 18, 2, 2, 1, 19, 1, 20,
1228 19, 20, 21, 21, 3, 3, 22, 22, 5, 5, 24, 1, 1, 23, 9, 23,
1229 24, 9, 2, 2, 10, 1, 1, 10, 6, 6, 25, 4, 4, 25, 7, 7,
1230 26, 8, 1, 8, 3, 1, 26, 3, 11, 11, 27, 27, 2, 28, 1, 2,
1231 28, 1, 12, 12, 5, 5, 29, 13, 13, 29, 32, 1, 1, 33, 31, 30,
1232 32, 4, 30, 33, 4, 31, 3, 14, 1, 1, 3, 34, 34, 2, 2, 14,
1233 6, 6, 35, 36, 35, 36, 1, 15, 1, 16, 16, 15, 7, 9, 7, 9,
1234 37, 8, 8, 37, 1, 1, 39, 2, 38, 39, 2, 40, 5, 38, 40, 5,
1235 3, 3, 4, 4, 10, 10, 1, 1, 1, 1, 41, 2, 41, 2, 6, 6,
1236 1, 1, 11, 42, 11, 43, 3, 42, 3, 17, 4, 43, 1, 17, 7, 1,
1237 8, 44, 4, 7, 44, 5, 8, 2, 5, 1, 2, 48, 45, 1, 12, 45,
1238 12, 48, 13, 13, 1, 9, 9, 46, 1, 46, 47, 47, 49, 18, 18, 49 ],
1239 valtab: [
1240 1, -1, 0, 1, -1, 2, -2, 1, -1, 1, -1, 1, -1, 3, -3, 1,
1241 -1, -2, 2, 1, -1, 1, -1, 4, -4, -2, 2, 1, -1, 1, -1, 5,
1242 -5, -3, 3, 2, -2, 1, 0, -1, 1, -1, 1, -1, 6, -6, 2, -2,
1243 1, -1, 1, 1, -1, -1, -3, 3, 7, 2, -7, -2, -4, 4, 2, -2,
1244 2, -2, 1, -1, 8, -8, 3, -3, 1, -1, -5, 5, 9, 1, -9, 1,
1245 -1, -1, 1, -1, -4, 4, 1, -1, 3, -3, 1, -10, 10, 1, 2, -1,
1246 -1, -2, 6, -6, 2, 11, -11, -2, 3, -3, 1, -4, 4, -1, 3, -3,
1247 1, 3, 12, -3, -5, -12, -1, 5, 2, -2, 1, -1, -7, 1, 13, 7,
1248 -1, -13, 2, -2, 4, -4, 1, 2, -2, -1, 1, 14, -14, 1, 1, 1,
1249 -1, -5, -1, -1, 5, -1, -6, 2, -15, 15, 6, 1, -1, -8, 8, -2,
1250 -4, 4, 1, 1, -1, -1, 16, 2, -16, -2, 2, -2, 4, 3, -4, -3,
1251 -1, -4, 4, 1, -17, 17, -1, -9, 1, 1, 9, 1, -5, -1, -1, 5,
1252 -7, 7, 6, -6, 3, -3, 18, -18, 19, -19, 1, -10, -1, 10, -5, 5,
1253 20, -20, -3, 1, 3, 1, 8, -1, -8, 2, 7, -1, -21, -2, 5, 21,
1254 5, -1, -7, -5, 1, -6, -5, -11, 6, 22, 11, 1, 1, -22, -3, -1,
1255 3, -1, 3, -3, -23, 4, -4, 1, 23, -1, 1, -1, 1, -2, 2, -1 ]
1256 },
1257 RVMap { eob_sym: 4, esc_sym: 11, runtab: [
1258 1, 1, 1, 1, 0, 2, 2, 1, 1, 3, 3, 0, 1, 1, 2, 2,
1259 4, 4, 1, 1, 5, 5, 1, 1, 2, 2, 3, 3, 6, 6, 1, 1,
1260 7, 7, 8, 1, 8, 2, 2, 1, 4, 4, 1, 3, 1, 3, 9, 9,
1261 2, 2, 1, 5, 1, 5, 10, 10, 1, 1, 11, 11, 3, 6, 3, 4,
1262 4, 6, 2, 2, 1, 12, 1, 12, 7, 13, 7, 13, 1, 1, 8, 8,
1263 2, 2, 14, 14, 16, 15, 16, 5, 5, 1, 3, 15, 1, 3, 4, 4,
1264 1, 1, 17, 17, 2, 2, 6, 6, 1, 18, 1, 18, 22, 21, 22, 21,
1265 25, 24, 25, 19, 9, 20, 9, 23, 19, 24, 20, 3, 23, 7, 3, 1,
1266 1, 7, 28, 26, 29, 5, 28, 26, 5, 8, 29, 4, 8, 27, 2, 2,
1267 4, 27, 1, 1, 10, 36, 10, 33, 33, 36, 30, 1, 32, 32, 1, 30,
1268 6, 31, 31, 35, 3, 6, 11, 11, 3, 2, 35, 2, 34, 1, 34, 1,
1269 37, 37, 12, 7, 12, 5, 41, 5, 4, 7, 1, 8, 13, 4, 1, 41,
1270 13, 38, 8, 38, 9, 1, 40, 40, 9, 1, 39, 2, 2, 49, 39, 42,
1271 3, 3, 14, 16, 49, 14, 16, 42, 43, 43, 6, 6, 15, 1, 1, 15,
1272 44, 44, 1, 1, 50, 48, 4, 5, 4, 7, 5, 2, 10, 10, 48, 7,
1273 50, 45, 2, 1, 45, 8, 8, 1, 46, 46, 3, 47, 47, 3, 1, 1 ],
1274 valtab: [
1275 1, -1, 2, -2, 0, 1, -1, 3, -3, 1, -1, 0, 4, -4, 2, -2,
1276 1, -1, 5, -5, 1, -1, 6, -6, 3, -3, 2, -2, 1, -1, 7, -7,
1277 1, -1, 1, 8, -1, 4, -4, -8, 2, -2, 9, 3, -9, -3, 1, -1,
1278 5, -5, 10, 2, -10, -2, 1, -1, 11, -11, 1, -1, -4, 2, 4, 3,
1279 -3, -2, 6, -6, 12, 1, -12, -1, 2, 1, -2, -1, 13, -13, 2, -2,
1280 7, -7, 1, -1, 1, 1, -1, 3, -3, 14, 5, -1, -14, -5, 4, -4,
1281 15, -15, 1, -1, 8, -8, -3, 3, 16, 1, -16, -1, 1, 1, -1, -1,
1282 1, 1, -1, 1, 2, 1, -2, 1, -1, -1, -1, 6, -1, 3, -6, 17,
1283 -17, -3, 1, 1, 1, 4, -1, -1, -4, 3, -1, 5, -3, -1, -9, 9,
1284 -5, 1, 18, -18, 2, 1, -2, 1, -1, -1, 1, 19, -1, 1, -19, -1,
1285 4, 1, -1, 1, 7, -4, -2, 2, -7, 10, -1, -10, 1, 20, -1, -20,
1286 1, -1, 2, 4, -2, 5, 1, -5, 6, -4, 21, 4, 2, -6, -21, -1,
1287 -2, 1, -4, -1, -3, 22, -1, 1, 3, -22, -1, 11, -11, 1, 1, 1,
1288 8, -8, 2, 2, -1, -2, -2, -1, 1, -1, -5, 5, 2, 23, -23, -2,
1289 1, -1, 24, -24, -1, -1, 7, 6, -7, 5, -6, 12, -3, 3, 1, -5,
1290 1, 1, -12, 25, -1, -5, 5, -25, -1, 1, 9, 1, -1, -9, 26, -26 ]
1291 }
1292];