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