]> git.nihav.org Git - nihav.git/blame_incremental - src/codecs/indeo/indeo4.rs
remove unused import
[nihav.git] / src / codecs / indeo / indeo4.rs
... / ...
CommitLineData
1use std::cell::Ref;
2use io::bitreader::*;
3use formats;
4use super::super::*;
5use super::ivi::*;
6use super::ivibr::*;
7
8#[inline(always)]
9fn mclip8(a: i32) -> u8 {
10 if (a as u16) > 255 { !(a >> 16) as u8 }
11 else { a as u8 }
12}
13
14struct Indeo4Parser {
15 mb_cb: IVICodebook,
16 blk_cb: IVICodebook,
17}
18
19fn calc_quant(glob_q: u32, qd: i16) -> u8 {
20 let q = (glob_q as i16) + qd;
21 if q < 0 {
22 0
23 } else if q > 31 {
24 31
25 } else {
26 q as u8
27 }
28}
29
30impl Indeo4Parser {
31 fn new() -> Self {
32 Indeo4Parser {
33 mb_cb: IVI_CB_ZERO,
34 blk_cb: IVI_CB_ZERO,
35 }
36 }
37}
38
39impl IndeoXParser for Indeo4Parser {
40#[allow(unused_variables,unused_assignments)]
41 fn decode_picture_header(&mut self, br: &mut BitReader) -> DecoderResult<PictureHeader> {
42 let sync = br.read(18)?;
43 validate!(sync == 0x3FFF8);
44 let ftype_idx = br.read(3)?;
45 validate!(ftype_idx < 7);
46 let ftype = INDEO4_FRAME_TYPE[ftype_idx as usize];
47 let transparent = br.read_bool()?;
48 br.skip(1)?;
49 let data_size;
50 if br.read_bool()? {
51 data_size = br.read(24)? as usize;
52 } else {
53 data_size = 0;
54 }
55 if ftype.is_null() {
56 return Ok(PictureHeader::new_null(ftype));
57 }
58 if br.read_bool()? {
59 br.skip(32)?; // key lock
60 }
61 let width;
62 let height;
63 let pic_size_idx = br.read(3)?;
64 if pic_size_idx < 7 {
65 width = INDEO4_PICTURE_SIZE_TAB[pic_size_idx as usize][0];
66 height = INDEO4_PICTURE_SIZE_TAB[pic_size_idx as usize][1];
67 } else {
68 height = br.read(16)? as usize;
69 width = br.read(16)? as usize;
70 validate!((width > 0) && ((width & 3) == 0));
71 validate!((height > 0) && ((height & 3) == 0));
72 }
73
74 let slice_w;
75 let slice_h;
76 if br.read_bool()? {
77 let idx = br.read(4)? as usize;
78 if idx < 15 {
79 slice_w = INDEO4_SLICE_SIZE_TAB[idx];
80 slice_h = INDEO4_SLICE_SIZE_TAB[idx];
81 } else {
82 slice_w = width;
83 slice_h = height;
84 }
85 } else {
86 slice_w = width;
87 slice_h = height;
88 }
89 let subsampling = br.read(2)?;
90 validate!(subsampling == 0);
91 let sc_idx = br.read(2)?;
92 match sc_idx {
93 3 => { },
94 2 => { validate!(br.read(2*4)? == 0xFF); }
95 _ => { return Err(DecoderError::InvalidData); }
96 };
97 let luma_bands = if sc_idx == 2 { 4 } else { 1 };
98 let sc_idx = br.read(2)?;
99 match sc_idx {
100 3 => { },
101 2 => { validate!(br.read(2*4)? == 0xFF); }
102 _ => { return Err(DecoderError::InvalidData); }
103 };
104 let chroma_bands = if sc_idx == 2 { 4 } else { 1 };
105 let frame_no;
106 if br.read_bool()? {
107 frame_no = br.read(20)?;
108 } else {
109 frame_no = 0;
110 }
111 if br.read_bool()? {
112 br.skip(8)?; // decTimeEst
113 }
114 let desc_coded = br.read_bool()?;
115 self.mb_cb = br.read_ivi_codebook_desc(true, desc_coded)?;
116 let desc_coded = br.read_bool()?;
117 self.blk_cb = br.read_ivi_codebook_desc(false, desc_coded)?;
118 let rvmap = if br.read_bool()? { br.read(3)? as usize } else { 8 };
119 let in_imf = br.read_bool()?;
120 let in_q = br.read_bool()?;
121 let glob_q = br.read(5)? as u8;
122 if br.read_bool()? {
123 br.skip(3)?;
124 }
125 let checksum = if br.read_bool()? { br.read(16)? } else { 0 };
126 if br.read_bool()? {
127 br.skip(8)?; // pic hdr extension
128 }
129 if br.read_bool()? {
130 println!("bad blocks bits!");
131 }
132 br.align();
133
134 Ok(PictureHeader::new(ftype, width, height, slice_w, slice_h, transparent, luma_bands, chroma_bands, in_q))
135 }
136
137#[allow(unused_variables,unused_assignments)]
138 fn decode_band_header(&mut self, br: &mut BitReader, pic_hdr: &PictureHeader, plane: usize, band: usize) -> DecoderResult<BandHeader> {
139 let plane_no = br.read(2)? as usize;
140 let band_no = br.read(4)? as usize;
141 validate!(plane_no == plane);
142 validate!(band_no == band);
143 if br.read_bool()? {
144 br.align();
145 return Ok(BandHeader::new_empty(plane_no, band_no));
146 }
147 let hdr_size;
148 if br.read_bool()? {
149 hdr_size = br.read(16)? as usize;
150 } else {
151 hdr_size = 32;
152 }
153 let mv_mode = br.read(2)?;
154 validate!(mv_mode < 2);
155 if br.read_bool()? {
156 br.skip(16)?; //checksum
157 }
158
159 let scale = br.read(2)?;
160 validate!(scale != 3);
161 let mb_size = 16 >> scale;
162 let blk_size = 8 >> (scale >> 1);
163 let inherit_mv = br.read_bool()?;
164 let inherit_qd = br.read_bool()?;
165 let quant = br.read(5)?;
166
167 let tr: IVITransformType;
168 let txtype: TxType;
169 if !br.read_bool()? || pic_hdr.ftype == IVIFrameType::Intra {
170 let tr_id = br.read(5)?;
171 validate!(tr_id < 18);
172 let scan_idx = br.read(4)? as usize;
173 validate!(scan_idx != 15);
174 let qmat_idx = br.read(5)? as usize;
175
176 tr = INDEO4_TRANSFORMS[tr_id as usize];
177 if (scan_idx < 5) || (scan_idx >= 10) {
178 validate!(tr.is_8x8());
179 validate!(qmat_idx < 15);
180 let scan = if scan_idx < 5 { INDEO4_SCANS_8X8[scan_idx] }
181 else { INDEO4_SCANS_8X8[4] };
182 let qidx = INDEO4_Q8X8_IDX[qmat_idx];
183 let qintra = INDEO4_Q8_INTRA[qidx];
184 let qinter = INDEO4_Q8_INTER[qidx];
185 txtype = TxType::Transform8(TxParams8x8::new(qintra, qinter, scan));
186 } else if scan_idx < 10 {
187 validate!(!tr.is_8x8());
188 validate!((qmat_idx >= 15) && (qmat_idx < 22));
189 let scan = INDEO4_SCANS_4X4[scan_idx - 5];
190 let qidx = INDEO4_Q4X4_IDX[qmat_idx - 15];
191 let qintra = INDEO4_Q4_INTRA[qidx];
192 let qinter = INDEO4_Q4_INTER[qidx];
193 txtype = TxType::Transform4(TxParams4x4::new(qintra, qinter, scan));
194 } else {
195 unreachable!();
196 }
197 } else {
198 tr = IVITransformType::None(TSize::T8x8);
199 txtype = TxType::None;
200 }
201
202 let blk_cb;
203 if br.read_bool()? {
204
205 blk_cb = br.read_ivi_codebook_desc(false, true)?;
206 } else {
207 blk_cb = self.blk_cb;
208 }
209 let rvmap_idx;
210 if br.read_bool()? {
211 rvmap_idx = br.read(3)? as usize;
212 } else {
213 rvmap_idx = 8;
214 }
215 let num_corr;
216 let mut corr_map: [u8; CORR_MAP_SIZE] = [0; CORR_MAP_SIZE];
217 if br.read_bool()? {
218 num_corr = br.read(8)? as usize;
219 validate!(num_corr*2 <= CORR_MAP_SIZE);
220 for i in 0..num_corr*2 {
221 corr_map[i] = br.read(8)? as u8;
222 }
223 } else {
224 num_corr = 0;
225 }
226
227 br.align();
228 Ok(BandHeader::new(plane_no, band_no, mb_size, blk_size, mv_mode == 1, inherit_mv, false, inherit_qd, quant, rvmap_idx, num_corr, corr_map, blk_cb, tr, txtype))
229 }
230
231 fn decode_mb_info(&mut self, br: &mut BitReader, pic_hdr: &PictureHeader, band: &BandHeader, tile: &mut IVITile, ref_tile: Option<Ref<IVITile>>, mv_scale: u8) -> DecoderResult<()> {
232 let mut mv_x = 0;
233 let mut mv_y = 0;
234 let mut mb_idx = 0;
235
236 for mb_y in 0..tile.mb_h {
237 for mb_x in 0..tile.mb_w {
238 let mut mb = MB::new(tile.pos_x + mb_x * band.mb_size, tile.pos_y + mb_y * band.mb_size);
239 if !br.read_bool()? {
240 if pic_hdr.ftype.is_intra() {
241 mb.mtype = MBType::Intra;
242 } else if band.inherit_mv {
243 if let Some(ref tileref) = ref_tile {
244 mb.mtype = tileref.mb[mb_idx].mtype;
245 } else {
246 return Err(DecoderError::MissingReference);
247 }
248 } else {
249 if !pic_hdr.ftype.is_bidir() {
250 mb.mtype = if br.read_bool()? { MBType::Inter } else { MBType::Intra };
251 } else {
252 mb.mtype = match br.read(2)? {
253 0 => { MBType::Intra },
254 1 => { MBType::Inter },
255 2 => { MBType::Backward },
256 _ => { MBType::Bidir },
257 };
258 }
259 }
260 if band.mb_size == band.blk_size {
261 mb.cbp = br.read(1)? as u8;
262 } else {
263 mb.cbp = br.read(4)? as u8;
264 }
265 if band.inherit_qd {
266 if let Some(ref tileref) = ref_tile {
267 mb.qd = tileref.mb[mb_idx].qd;
268 mb.q = calc_quant(band.quant, mb.qd);
269 } else {
270 mb.q = band.quant as u8;
271 }
272 } else if (mb.cbp != 0) || ((band.plane_no == 0) && (band.band_no == 0) && pic_hdr.in_q) {
273 mb.qd = br.read_ivi_cb_s(&self.mb_cb)? as i16;
274 mb.q = calc_quant(band.quant, mb.qd);
275 } else {
276 mb.q = band.quant as u8;
277 }
278
279 if mb.mtype != MBType::Intra {
280 if band.inherit_mv {
281 if let Some(ref tileref) = ref_tile {
282 let mx = tileref.mb[mb_idx].mv_x;
283 let my = tileref.mb[mb_idx].mv_y;
284 if mv_scale == 0 {
285 mb.mv_x = mx;
286 mb.mv_y = my;
287 } else {
288 mb.mv_x = scale_mv(mx, mv_scale);
289 mb.mv_y = scale_mv(my, mv_scale);
290 }
291 }
292 } else {
293 mv_y += br.read_ivi_cb_s(&self.mb_cb)?;
294 mv_x += br.read_ivi_cb_s(&self.mb_cb)?;
295 mb.mv_x = mv_x;
296 mb.mv_y = mv_y;
297 if mb.mtype == MBType::Backward {
298 mb.mv_x = -mb.mv_x;
299 mb.mv_y = -mb.mv_y;
300 } else if mb.mtype == MBType::Bidir {
301 mv_y += br.read_ivi_cb_s(&self.mb_cb)?;
302 mv_x += br.read_ivi_cb_s(&self.mb_cb)?;
303 mb.mv2_x = -mv_x;
304 mb.mv2_y = -mv_y;
305 }
306 }
307 }
308 } else {
309 validate!(!pic_hdr.ftype.is_intra());
310 mb.mtype = MBType::Inter;
311 mb.cbp = 0;
312 mb.qd = 0;
313 if (band.plane_no == 0) && (band.band_no == 0) && pic_hdr.in_q {
314 mb.qd = br.read_ivi_cb_s(&self.mb_cb)? as i16;
315 mb.q = calc_quant(band.quant, mb.qd);
316 }
317 if band.inherit_mv {
318 if let Some(ref tileref) = ref_tile {
319 let mx = tileref.mb[mb_idx].mv_x;
320 let my = tileref.mb[mb_idx].mv_y;
321 if mv_scale == 0 {
322 mb.mv_x = mx;
323 mb.mv_y = my;
324 } else {
325 mb.mv_x = scale_mv(mx, mv_scale);
326 mb.mv_y = scale_mv(my, mv_scale);
327 }
328 }
329 }
330 }
331 tile.mb[mb_idx] = mb;
332 mb_idx += 1;
333 }
334 }
335 br.align();
336 Ok(())
337 }
338
339 fn recombine_plane(&mut self, src: &[i16], sstride: usize, dst: &mut [u8], dstride: usize, w: usize, h: usize) {
340/* let mut idx0 = 0;
341 let mut idx1 = w / 2;
342 let mut idx2 = (h / 2) * sstride;
343 let mut idx3 = idx2 + idx1;
344 let mut oidx0 = 0;
345 let mut oidx1 = dstride;
346
347 for _ in 0..(h/2) {
348 for x in 0..(w/2) {
349 let p0 = src[idx0 + x];
350 let p1 = src[idx1 + x];
351 let p2 = src[idx2 + x];
352 let p3 = src[idx3 + x];
353 let s0 = p0 + p2;
354 let d0 = p0 - p2;
355 let s1 = p1 + p3;
356 let d1 = p1 - p3;
357 dst[oidx0 + x * 2 + 0] = clip8(((s0 + s1 + 2) >> 2) + 128);
358 dst[oidx0 + x * 2 + 1] = clip8(((d0 + d1 + 2) >> 2) + 128);
359 dst[oidx1 + x * 2 + 0] = clip8(((s0 - s1 + 2) >> 2) + 128);
360 dst[oidx1 + x * 2 + 1] = clip8(((d0 - d1 + 2) >> 2) + 128);
361 }
362 idx0 += sstride;
363 idx1 += sstride;
364 idx2 += sstride;
365 idx3 += sstride;
366 oidx0 += dstride * 2;
367 oidx1 += dstride * 2;
368 }*/
369 unsafe {
370 let hw = (w / 2) as isize;
371 let hh = (h / 2) as isize;
372 let mut band0 = src.as_ptr();
373 let mut band1 = band0.offset(hw);
374 let mut band2 = band0.offset(((h / 2) * sstride) as isize);
375 let mut band3 = band2.offset(hw);
376 let mut dst0 = dst.as_mut_ptr();
377 let mut dst1 = dst0.offset(dstride as isize);
378 for _ in 0..hh {
379 let mut b0_ptr = band0;
380 let mut b1_ptr = band1;
381 let mut b2_ptr = band2;
382 let mut b3_ptr = band3;
383 let mut d0_ptr = dst0;
384 let mut d1_ptr = dst1;
385 for _ in 0..hw {
386 let p0 = *b0_ptr as i32;
387 let p1 = *b1_ptr as i32;
388 let p2 = *b2_ptr as i32;
389 let p3 = *b3_ptr as i32;
390 let s0 = p0.wrapping_add(p2);
391 let s1 = p1.wrapping_add(p3);
392 let d0 = p0.wrapping_sub(p2);
393 let d1 = p1.wrapping_sub(p3);
394 let o0 = s0.wrapping_add(s1).wrapping_add(2);
395 let o1 = d0.wrapping_add(d1).wrapping_add(2);
396 let o2 = s0.wrapping_sub(s1).wrapping_add(2);
397 let o3 = d0.wrapping_sub(d1).wrapping_add(2);
398 *d0_ptr.offset(0) = mclip8((o0 >> 2).wrapping_add(128));
399 *d0_ptr.offset(1) = mclip8((o1 >> 2).wrapping_add(128));
400 *d1_ptr.offset(0) = mclip8((o2 >> 2).wrapping_add(128));
401 *d1_ptr.offset(1) = mclip8((o3 >> 2).wrapping_add(128));
402 b0_ptr = b0_ptr.offset(1);
403 b1_ptr = b1_ptr.offset(1);
404 b2_ptr = b2_ptr.offset(1);
405 b3_ptr = b3_ptr.offset(1);
406 d0_ptr = d0_ptr.offset(2);
407 d1_ptr = d1_ptr.offset(2);
408 }
409 band0 = band0.offset(sstride as isize);
410 band1 = band1.offset(sstride as isize);
411 band2 = band2.offset(sstride as isize);
412 band3 = band3.offset(sstride as isize);
413 dst0 = dst0.offset((dstride * 2) as isize);
414 dst1 = dst1.offset((dstride * 2) as isize);
415 }
416 }
417 }
418}
419
420struct Indeo4Decoder {
421 info: Rc<NACodecInfo>,
422 dec: IVIDecoder,
423}
424
425impl Indeo4Decoder {
426 fn new() -> Self {
427 Indeo4Decoder {
428 info: NACodecInfo::new_dummy(),
429 dec: IVIDecoder::new(),
430 }
431 }
432}
433
434impl NADecoder for Indeo4Decoder {
435 fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
436 if let NACodecTypeInfo::Video(vinfo) = info.get_properties() {
437 let w = vinfo.get_width();
438 let h = vinfo.get_height();
439 let f = vinfo.is_flipped();
440 let fmt = formats::YUV410_FORMAT;
441 let myinfo = NACodecTypeInfo::Video(NAVideoInfo::new(w, h, f, fmt));
442 self.info = Rc::new(NACodecInfo::new_ref(info.get_name(), myinfo, info.get_extradata()));
443 Ok(())
444 } else {
445 Err(DecoderError::InvalidData)
446 }
447 }
448 fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
449 let src = pkt.get_buffer();
450 let mut br = BitReader::new(src.as_slice(), src.len(), BitReaderMode::LE);
451
452 let mut ip = Indeo4Parser::new();
453 let bufinfo = self.dec.decode_frame(&mut ip, &mut br)?;
454 let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), bufinfo);
455 frm.set_keyframe(self.dec.is_intra());
456 frm.set_frame_type(self.dec.get_frame_type());
457 Ok(Rc::new(RefCell::new(frm)))
458 }
459}
460
461const INDEO4_PICTURE_SIZE_TAB: [[usize; 2]; 7] = [
462 [640, 480], [320, 240], [160, 120], [704, 480], [352, 240], [352, 288], [176, 144]
463];
464
465const INDEO4_SLICE_SIZE_TAB: [usize; 15] = [
466 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480
467];
468
469const INDEO4_FRAME_TYPE: [IVIFrameType; 7] = [
470 IVIFrameType::Intra, IVIFrameType::Intra1, IVIFrameType::Inter, IVIFrameType::Bidir,
471 IVIFrameType::InterDroppable, IVIFrameType::NULL, IVIFrameType::NULL2
472];
473
474const INDEO4_TRANSFORMS: [IVITransformType; 18] = [
475 IVITransformType::Haar(TSize::T8x8, TDir::TwoD),
476 IVITransformType::Haar(TSize::T8x8, TDir::Row),
477 IVITransformType::Haar(TSize::T8x8, TDir::Col),
478 IVITransformType::None(TSize::T8x8),
479 IVITransformType::Slant(TSize::T8x8, TDir::TwoD),
480 IVITransformType::Slant(TSize::T8x8, TDir::Row),
481 IVITransformType::Slant(TSize::T8x8, TDir::Col),
482 IVITransformType::DCT(TSize::T8x8, TDir::TwoD),
483 IVITransformType::DCT(TSize::T8x8, TDir::Row),
484 IVITransformType::DCT(TSize::T8x8, TDir::Col),
485 IVITransformType::Haar(TSize::T4x4, TDir::TwoD),
486 IVITransformType::Slant(TSize::T4x4, TDir::TwoD),
487 IVITransformType::None(TSize::T4x4),
488 IVITransformType::Haar(TSize::T4x4, TDir::Row),
489 IVITransformType::Haar(TSize::T4x4, TDir::Col),
490 IVITransformType::Slant(TSize::T4x4, TDir::Row),
491 IVITransformType::Slant(TSize::T4x4, TDir::Col),
492 IVITransformType::DCT(TSize::T4x4, TDir::TwoD),
493];
494
495const INDEO4_SCAN_8X8_ALT: [usize; 64] = [
496 0, 8, 1, 9, 16, 24, 2, 3,
497 17, 25, 10, 11, 32, 40, 48, 56,
498 4, 5, 6, 7, 33, 41, 49, 57,
499 18, 19, 26, 27, 12, 13, 14, 15,
500 34, 35, 43, 42, 50, 51, 59, 58,
501 20, 21, 22, 23, 31, 30, 29, 28,
502 36, 37, 38, 39, 47, 46, 45, 44,
503 52, 53, 54, 55, 63, 62, 61, 60
504];
505const INDEO4_SCAN_4X4_ALT: [usize; 16] = [ 0, 1, 4, 5, 8, 12, 2, 3, 9, 13, 6, 7, 10, 11, 14, 15 ];
506const INDEO4_SCAN_4X4_VER: [usize; 16] = [ 0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15 ];
507const INDEO4_SCAN_4X4_HOR: [usize; 16] = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ];
508
509const INDEO4_SCANS_8X8: [&[usize; 64]; 5] = [
510 &IVI_ZIGZAG, &INDEO4_SCAN_8X8_ALT, &IVI_SCAN_8X8_HOR, &IVI_SCAN_8X8_VER, &IVI_ZIGZAG
511];
512const INDEO4_SCANS_4X4: [&[usize; 16]; 5] = [
513 &IVI_SCAN_4X4, &INDEO4_SCAN_4X4_ALT, &INDEO4_SCAN_4X4_VER, &INDEO4_SCAN_4X4_HOR, &IVI_SCAN_4X4
514];
515
516const INDEO4_Q8X8_IDX: [usize; 15] = [ 0, 1, 0, 2, 1, 3, 0, 4, 1, 5, 0, 1, 6, 7, 8 ];
517const INDEO4_Q4X4_IDX: [usize; 7] = [ 0, 1, 2, 2, 3, 3, 4 ];
518
519const INDEO4_QUANT8X8_INTRA: [[u16; 64]; 9] = [
520 [
521 43, 342, 385, 470, 555, 555, 598, 726,
522 342, 342, 470, 513, 555, 598, 726, 769,
523 385, 470, 555, 555, 598, 726, 726, 811,
524 470, 470, 555, 555, 598, 726, 769, 854,
525 470, 555, 555, 598, 683, 726, 854, 1025,
526 555, 555, 598, 683, 726, 854, 1025, 1153,
527 555, 555, 598, 726, 811, 982, 1195, 1451,
528 555, 598, 726, 811, 982, 1195, 1451, 1793
529 ], [
530 86, 1195, 2390, 2390, 4865, 4865, 4865, 4865,
531 1195, 1195, 2390, 2390, 4865, 4865, 4865, 4865,
532 2390, 2390, 4865, 4865, 6827, 6827, 6827, 6827,
533 2390, 2390, 4865, 4865, 6827, 6827, 6827, 6827,
534 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
535 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
536 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
537 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827
538 ], [
539 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
540 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
541 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
542 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
543 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
544 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
545 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
546 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835
547 ], [
548 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
549 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
550 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
551 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
552 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
553 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
554 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
555 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414
556 ], [
557 897, 897, 897, 897, 897, 897, 897, 897,
558 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067,
559 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238,
560 1409, 1409, 1409, 1409, 1409, 1409, 1409, 1409,
561 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579,
562 1750, 1750, 1750, 1750, 1750, 1750, 1750, 1750,
563 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921,
564 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091
565 ], [
566 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
567 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
568 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
569 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
570 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
571 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
572 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
573 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414
574 ], [
575 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
576 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
577 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
578 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
579 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
580 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
581 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
582 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390
583 ], [
584 22, 171, 214, 257, 257, 299, 299, 342,
585 171, 171, 257, 257, 299, 299, 342, 385,
586 214, 257, 257, 299, 299, 342, 342, 385,
587 257, 257, 257, 299, 299, 342, 385, 427,
588 257, 257, 299, 299, 342, 385, 427, 513,
589 257, 299, 299, 342, 385, 427, 513, 598,
590 299, 299, 299, 385, 385, 470, 598, 726,
591 299, 299, 385, 385, 470, 598, 726, 897
592 ], [
593 86, 598, 1195, 1195, 2390, 2390, 2390, 2390,
594 598, 598, 1195, 1195, 2390, 2390, 2390, 2390,
595 1195, 1195, 2390, 2390, 3414, 3414, 3414, 3414,
596 1195, 1195, 2390, 2390, 3414, 3414, 3414, 3414,
597 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
598 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
599 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
600 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414
601 ]
602];
603const INDEO4_QUANT8X8_INTER: [[u16; 64]; 9] = [
604 [
605 427, 427, 470, 427, 427, 427, 470, 470,
606 427, 427, 470, 427, 427, 427, 470, 470,
607 470, 470, 470, 470, 470, 470, 470, 470,
608 427, 427, 470, 470, 427, 427, 470, 470,
609 427, 427, 470, 427, 427, 427, 470, 470,
610 427, 427, 470, 427, 427, 427, 470, 470,
611 470, 470, 470, 470, 470, 470, 470, 470,
612 470, 470, 470, 470, 470, 470, 470, 470
613 ], [
614 1707, 1707, 2433, 2433, 3414, 3414, 3414, 3414,
615 1707, 1707, 2433, 2433, 3414, 3414, 3414, 3414,
616 2433, 2433, 3414, 3414, 4822, 4822, 4822, 4822,
617 2433, 2433, 3414, 3414, 4822, 4822, 4822, 4822,
618 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
619 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
620 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
621 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414
622 ], [
623 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
624 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
625 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
626 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
627 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
628 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
629 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
630 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281
631 ], [
632 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
633 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
634 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
635 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
636 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
637 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
638 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
639 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433
640 ], [
641 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
642 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
643 1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281,
644 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238,
645 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
646 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
647 1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281,
648 1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281
649 ], [
650 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
651 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
652 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
653 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
654 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
655 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
656 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
657 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433
658 ], [
659 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
660 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
661 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
662 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
663 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
664 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
665 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
666 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707
667 ], [
668 86, 171, 171, 214, 214, 214, 214, 257,
669 171, 171, 214, 214, 214, 214, 257, 257,
670 171, 214, 214, 214, 214, 257, 257, 257,
671 214, 214, 214, 214, 257, 257, 257, 299,
672 214, 214, 214, 257, 257, 257, 299, 299,
673 214, 214, 257, 257, 257, 299, 299, 299,
674 214, 257, 257, 257, 299, 299, 299, 342,
675 257, 257, 257, 299, 299, 299, 342, 342
676 ], [
677 854, 854, 1195, 1195, 1707, 1707, 1707, 1707,
678 854, 854, 1195, 1195, 1707, 1707, 1707, 1707,
679 1195, 1195, 1707, 1707, 2390, 2390, 2390, 2390,
680 1195, 1195, 1707, 1707, 2390, 2390, 2390, 2390,
681 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
682 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
683 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
684 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707
685 ]
686];
687const INDEO4_QUANT4X4_INTRA: [[u16; 16]; 5] = [
688 [
689 22, 214, 257, 299,
690 214, 257, 299, 342,
691 257, 299, 342, 427,
692 299, 342, 427, 513
693 ], [
694 129, 1025, 1451, 1451,
695 1025, 1025, 1451, 1451,
696 1451, 1451, 2049, 2049,
697 1451, 1451, 2049, 2049
698 ], [
699 43, 171, 171, 171,
700 43, 171, 171, 171,
701 43, 171, 171, 171,
702 43, 171, 171, 171
703 ], [
704 43, 43, 43, 43,
705 171, 171, 171, 171,
706 171, 171, 171, 171,
707 171, 171, 171, 171
708 ], [
709 43, 43, 43, 43,
710 43, 43, 43, 43,
711 43, 43, 43, 43,
712 43, 43, 43, 43
713 ]
714];
715const INDEO4_QUANT4X4_INTER: [[u16; 16]; 5] = [
716 [
717 107, 214, 257, 299,
718 214, 257, 299, 299,
719 257, 299, 299, 342,
720 299, 299, 342, 342
721 ], [
722 513, 1025, 1238, 1238,
723 1025, 1025, 1238, 1238,
724 1238, 1238, 1451, 1451,
725 1238, 1238, 1451, 1451
726 ], [
727 43, 171, 171, 171,
728 43, 171, 171, 171,
729 43, 171, 171, 171,
730 43, 171, 171, 171
731 ], [
732 43, 43, 43, 43,
733 171, 171, 171, 171,
734 171, 171, 171, 171,
735 171, 171, 171, 171
736 ], [
737 43, 43, 43, 43,
738 43, 43, 43, 43,
739 43, 43, 43, 43,
740 43, 43, 43, 43
741 ]
742];
743const INDEO4_Q8_INTRA: [&[u16; 64]; 9] = [
744 &INDEO4_QUANT8X8_INTRA[0], &INDEO4_QUANT8X8_INTRA[1], &INDEO4_QUANT8X8_INTRA[2],
745 &INDEO4_QUANT8X8_INTRA[3], &INDEO4_QUANT8X8_INTRA[4], &INDEO4_QUANT8X8_INTRA[5],
746 &INDEO4_QUANT8X8_INTRA[6], &INDEO4_QUANT8X8_INTRA[7], &INDEO4_QUANT8X8_INTRA[8],
747];
748const INDEO4_Q8_INTER: [&[u16; 64]; 9] = [
749 &INDEO4_QUANT8X8_INTER[0], &INDEO4_QUANT8X8_INTER[1], &INDEO4_QUANT8X8_INTER[2],
750 &INDEO4_QUANT8X8_INTER[3], &INDEO4_QUANT8X8_INTER[4], &INDEO4_QUANT8X8_INTER[5],
751 &INDEO4_QUANT8X8_INTER[6], &INDEO4_QUANT8X8_INTER[7], &INDEO4_QUANT8X8_INTER[8],
752];
753const INDEO4_Q4_INTRA: [&[u16; 16]; 5] = [
754 &INDEO4_QUANT4X4_INTRA[0], &INDEO4_QUANT4X4_INTRA[1], &INDEO4_QUANT4X4_INTRA[2],
755 &INDEO4_QUANT4X4_INTRA[3], &INDEO4_QUANT4X4_INTRA[4]
756];
757const INDEO4_Q4_INTER: [&[u16; 16]; 5] = [
758 &INDEO4_QUANT4X4_INTER[0], &INDEO4_QUANT4X4_INTER[1], &INDEO4_QUANT4X4_INTER[2],
759 &INDEO4_QUANT4X4_INTER[3], &INDEO4_QUANT4X4_INTER[4]
760];
761
762pub fn get_decoder() -> Box<NADecoder> {
763 Box::new(Indeo4Decoder::new())
764}
765
766#[cfg(test)]
767mod test {
768 use test::dec_video::test_file_decoding;
769 #[test]
770 fn test_indeo4() {
771 test_file_decoding("avi", "assets/IV4/volcano.avi", /*None*/Some(16), true, false, Some("iv4"));
772panic!("the end");
773 }
774}