2 use std::cell::{Ref, RefCell};
3 use nihav_core::io::bitreader::*;
4 use nihav_core::formats;
5 use nihav_core::frame::*;
6 use nihav_core::codecs::*;
10 fn calc_quant(glob_q: u32, qd: i16) -> usize {
11 let qq = (glob_q as i16) + (qd as i16);
55 fn skip_extension(br: &mut BitReader) -> DecoderResult<()> {
57 let len = br.read(8)?;
58 if len == 0 { break; }
64 impl IndeoXParser for Indeo5Parser {
65 #[allow(unused_variables)]
66 #[allow(unused_assignments)]
67 fn decode_picture_header(&mut self, br: &mut BitReader) -> DecoderResult<PictureHeader> {
68 let sync = br.read(5)?;
69 validate!(sync == 0x1F);
70 let ftype_idx = br.read(3)?;
71 validate!(ftype_idx < 5);
72 let ftype = INDEO5_FRAME_TYPE[ftype_idx as usize];
73 let fnum = br.read(8)?;
74 if ftype == IVIFrameType::Intra {
75 let gop_flags = br.read(8)?;
77 if (gop_flags & 0x01) != 0 {
78 hdr_size = br.read(16)?;
82 if (gop_flags & 0x20) != 0 {
83 br.skip(32)?; // lock word
87 if (gop_flags & 0x40) != 0 {
88 self.tile_w = 64 << br.read(2)?;
89 self.tile_h = self.tile_w;
91 validate!(self.tile_w < 256);
92 self.luma_bands = (br.read(2)? * 3 + 1) as usize;
93 self.chroma_bands = (br.read(1)? * 3 + 1) as usize;
94 validate!((self.luma_bands == 4) || (self.luma_bands == 1));
95 validate!(self.chroma_bands == 1);
96 let pic_size_idx = br.read(4)? as usize;
99 if pic_size_idx < 15 {
100 w = INDEO5_PICTURE_SIZE_TAB[pic_size_idx][0];
101 h = INDEO5_PICTURE_SIZE_TAB[pic_size_idx][1];
103 h = br.read(13)? as usize;
104 w = br.read(13)? as usize;
106 validate!((w != 0) && (h != 0));
110 validate!((gop_flags & 0x02) == 0);
111 if self.tile_w == 0 {
115 for b in 0..self.luma_bands+self.chroma_bands {
116 self.is_hpel[b] = br.read_bool()?;
117 let mb_scale = br.read(1)?;
118 self.blk_size[b] = 8 >> br.read(1)?;
119 self.mb_size[b] = self.blk_size[b] << (1 - mb_scale);
120 let ext_tr = br.read_bool()?;
122 let end_marker = br.read(2)?;
123 validate!(end_marker == 0);
125 if (gop_flags & 0x08) != 0 {
126 let align = br.read(3)?;
127 validate!(align == 0);
129 br.skip(24)?; // transparency color
134 if br.read_bool()? { // gop extension
136 let v = br.read(16)?;
137 if (v & 0x8000) == 0 { break; }
144 return Ok(PictureHeader::new_null(ftype));
146 let flags = br.read(8)?;
148 if (flags & 0x01) != 0 {
154 if (flags & 0x10) != 0 {
155 checksum = br.read(16)?;
159 if (flags & 0x20) != 0 {
162 let in_q = (flags & 0x08) != 0;
163 self.mb_cb = br.read_ivi_codebook_desc(true, (flags & 0x40) != 0)?;
167 Ok(PictureHeader::new(ftype, self.width, self.height, self.tile_w, self.tile_h, false, self.luma_bands, self.chroma_bands, in_q))
170 #[allow(unused_variables)]
171 fn decode_band_header(&mut self, br: &mut BitReader, pic_hdr: &PictureHeader, plane_no: usize, band_no: usize) -> DecoderResult<BandHeader> {
172 let band_flags = br.read(8)?;
174 if (band_flags & 0x01) != 0 {
176 return Ok(BandHeader::new_empty(plane_no, band_no));
178 let inherit_mv = (band_flags & 0x02) != 0;
179 let has_qdelta = (band_flags & 0x04) != 0;
180 let inherit_qd = ((band_flags & 0x08) != 0) || !has_qdelta;
181 let data_size: usize;
182 if (band_flags & 0x80) != 0 {
183 data_size = br.read(24)? as usize;
187 validate!(data_size <= ((br.left() / 8) as usize));
190 let mut corr_map: [u8; CORR_MAP_SIZE] = [0; CORR_MAP_SIZE];
191 if (band_flags & 0x10) != 0 {
192 num_corr = br.read(8)? as usize;
193 validate!(num_corr*2 <= CORR_MAP_SIZE);
194 for i in 0..num_corr*2 {
195 corr_map[i] = br.read(8)? as u8;
201 if (band_flags & 0x40) != 0 {
202 rvmap_idx = br.read(3)? as usize;
206 let blk_cb = br.read_ivi_codebook_desc(false, (band_flags & 0x80) != 0)?;
208 br.skip(16)?; // checksum
210 let band_q = br.read(5)?;
211 if (band_flags & 0x20) != 0 {
218 let band_id = if plane_no == 0 { band_no } else { self.luma_bands };
221 let scan = INDEO5_SCAN8X8[band_no];
224 validate!(self.blk_size[band_id] == 8);
227 tr = IVITransformType::Slant(TSize::T8x8, TDir::TwoD);
228 if self.luma_bands == 1 {
229 qintra = INDEO5_Q8_INTRA[0];
230 qinter = INDEO5_Q8_INTER[0];
232 qintra = INDEO5_Q8_INTRA[1];
233 qinter = INDEO5_Q8_INTER[1];
237 tr = IVITransformType::Slant(TSize::T8x8, TDir::Row);
238 qintra = INDEO5_Q8_INTRA[2];
239 qinter = INDEO5_Q8_INTER[2];
242 tr = IVITransformType::Slant(TSize::T8x8, TDir::Col);
243 qintra = INDEO5_Q8_INTRA[3];
244 qinter = INDEO5_Q8_INTER[3];
247 tr = IVITransformType::None(TSize::T8x8);
248 qintra = INDEO5_Q8_INTRA[4];
249 qinter = INDEO5_Q8_INTER[4];
251 _ => { unreachable!(); }
253 txtype = TxType::Transform8(TxParams8x8::new(qintra, qinter, scan));
256 validate!(self.blk_size[band_id] == 4);
257 tr = IVITransformType::Slant(TSize::T4x4, TDir::TwoD);
258 let scan = INDEO5_SCAN4X4;
259 let qintra = INDEO5_Q4_INTRA;
260 let qinter = INDEO5_Q4_INTER;
261 txtype = TxType::Transform4(TxParams4x4::new(qintra, qinter, scan));
263 _ => { unreachable!(); }
266 Ok(BandHeader::new(plane_no, band_no, self.mb_size[band_id], self.blk_size[band_id], self.is_hpel[band_id], inherit_mv, has_qdelta, inherit_qd, band_q, rvmap_idx, num_corr, corr_map, blk_cb, tr, txtype))
269 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<()> {
272 let band_id = if pic_hdr.luma_bands == 4 { band.band_no + 1 } else { 0 };
274 for mb_y in 0..tile.mb_h {
275 for mb_x in 0..tile.mb_w {
276 let mut mb = MB::new(tile.pos_x + mb_x * band.mb_size, tile.pos_y + mb_y * band.mb_size);
277 if !br.read_bool()? {
278 if pic_hdr.ftype.is_intra() {
279 mb.mtype = MBType::Intra;
280 } else if band.inherit_mv {
281 if let Some(ref tileref) = ref_tile {
282 mb.mtype = tileref.mb[mb_idx].mtype;
284 return Err(DecoderError::MissingReference);
287 mb.mtype = if br.read_bool()? { MBType::Inter } else { MBType::Intra };
289 if band.mb_size == band.blk_size {
290 mb.cbp = br.read(1)? as u8;
292 mb.cbp = br.read(4)? as u8;
297 if let Some(ref tileref) = ref_tile {
298 mb.qd = tileref.mb[mb_idx].qd;
299 q = calc_quant(band.quant, mb.qd);
301 return Err(DecoderError::MissingReference);
303 } else if (mb.cbp != 0) || ((band.plane_no == 0) && (band.band_no == 0) && pic_hdr.in_q) {
304 mb.qd = br.read_ivi_cb_s(&self.mb_cb)? as i16;
305 q = calc_quant(band.quant, mb.qd);
307 q = band.quant as usize;
310 q = band.quant as usize;
313 if mb.mtype == MBType::Intra {
314 if band.blk_size == 8 {
315 mb.q = INDEO5_QSCALE8_INTRA[band_id][q];
317 mb.q = INDEO5_QSCALE4_INTRA[q];
320 if band.blk_size == 8 {
321 mb.q = INDEO5_QSCALE8_INTER[band_id][q];
323 mb.q = INDEO5_QSCALE4_INTER[q];
327 if mb.mtype != MBType::Intra {
329 if let Some(ref tileref) = ref_tile {
330 let mx = tileref.mb[mb_idx].mv_x;
331 let my = tileref.mb[mb_idx].mv_y;
336 mb.mv_x = scale_mv(mx, mv_scale);
337 mb.mv_y = scale_mv(my, mv_scale);
341 mv_y += br.read_ivi_cb_s(&self.mb_cb)?;
342 mv_x += br.read_ivi_cb_s(&self.mb_cb)?;
348 validate!(!pic_hdr.ftype.is_intra());
349 mb.mtype = MBType::Inter;
352 if (band.plane_no == 0) && (band.band_no == 0) && pic_hdr.in_q {
353 mb.qd = br.read_ivi_cb_s(&self.mb_cb)? as i16;
354 let q = calc_quant(band.quant, mb.qd);
355 if mb.mtype == MBType::Intra {
356 if band.blk_size == 8 {
357 mb.q = INDEO5_QSCALE8_INTRA[band_id][q];
359 mb.q = INDEO5_QSCALE4_INTRA[q];
362 if band.blk_size == 8 {
363 mb.q = INDEO5_QSCALE8_INTER[band_id][q];
365 mb.q = INDEO5_QSCALE4_INTER[q];
370 if let Some(ref tileref) = ref_tile {
371 let mx = tileref.mb[mb_idx].mv_x;
372 let my = tileref.mb[mb_idx].mv_y;
377 mb.mv_x = scale_mv(mx, mv_scale);
378 mb.mv_y = scale_mv(my, mv_scale);
383 tile.mb[mb_idx] = mb;
391 fn recombine_plane(&mut self, src: &[i16], sstride: usize, dst: &mut [u8], dstride: usize, w: usize, h: usize) {
393 let mut idx1 = w / 2;
394 let mut idx2 = (h / 2) * sstride;
395 let mut idx3 = idx2 + idx1;
396 let mut bidx1 = idx1;
397 let mut bidx3 = idx3;
399 let mut oidx1 = dstride;
400 let filt_lo = |a: i16, b: i16| a + b;
401 let filt_hi = |a: i16, b: i16, c: i16| a - b * 6 + c;
404 let mut b0_1 = src[idx0];
405 let mut b0_2 = src[idx0 + sstride];
406 let mut b1_1 = src[bidx1];
407 let mut b1_2 = src[idx1];
408 let mut b1_3 = filt_hi(b1_1, b1_2, src[idx1 + sstride]);
410 let mut b2_2 = src[idx2];
413 let mut b2_5 = src[idx2 + sstride];
416 let mut b3_2 = src[bidx3];
419 let mut b3_5 = src[idx3];
421 let mut b3_8 = filt_hi(b3_2, b3_5, src[idx3 + sstride]);
439 b0_1 = src[idx0 + x + 1];
440 b0_2 = src[idx0 + x + 1 + sstride];
441 let mut p0 = tmp0 << 4;
442 let mut p1 = (tmp0 + b0_1) << 3;
443 let mut p2 = (tmp0 + tmp1) << 3;
444 let mut p3 = (tmp0 + tmp1 + b0_1 + b0_2) << 2;
448 let tmp2 = filt_lo(tmp0, tmp1);
449 let tmp3 = filt_hi(tmp0, tmp1, b1_3);
450 b1_2 = src[ idx1 + x + 1];
451 b1_1 = src[bidx1 + x + 1];
452 b1_3 = filt_hi(b1_1, b1_2, src[idx1 + x + 1 + sstride]);
454 p1 += (tmp2 + b1_1 + b1_2) << 2;
456 p3 += (tmp3 + b1_3) << 1;
458 b2_3 = src[idx2 + x + 1];
459 b2_6 = src[idx2 + x + 1 + sstride];
460 let tmp0 = filt_lo(b2_1, b2_2);
461 let tmp1 = filt_hi(b2_1, b2_2, b2_3);
464 p2 += (tmp0 + filt_lo(b2_4, b2_5)) << 2;
465 p3 += (tmp1 + filt_hi(b2_4, b2_5, b2_6)) << 1;
467 b3_6 = src[idx3 + x + 1];
468 b3_3 = src[bidx3 + x + 1];
469 b3_9 = filt_hi(b3_3, b3_6, src[idx3 + x + 1 + sstride]);
470 let tmp0 = b3_1 + b3_4;
471 let tmp1 = b3_2 + b3_5;
472 let tmp2 = b3_3 + b3_6;
473 p0 += filt_lo(tmp0, tmp1) << 2;
474 p1 += filt_hi(tmp0, tmp1, tmp2) << 1;
475 p2 += filt_lo(b3_7, b3_8) << 1;
476 p3 += filt_hi(b3_7, b3_8, b3_9) << 0;
478 dst[oidx0 + x * 2 + 0] = clip8((p0 >> 6) + 128);
479 dst[oidx0 + x * 2 + 1] = clip8((p1 >> 6) + 128);
480 dst[oidx1 + x * 2 + 0] = clip8((p2 >> 6) + 128);
481 dst[oidx1 + x * 2 + 1] = clip8((p3 >> 6) + 128);
489 oidx0 += dstride * 2;
490 oidx1 += dstride * 2;
495 struct Indeo5Decoder {
496 info: Rc<NACodecInfo>,
504 info: NACodecInfo::new_dummy(),
505 dec: IVIDecoder::new(),
506 ip: Indeo5Parser::new(),
511 impl NADecoder for Indeo5Decoder {
512 fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
513 if let NACodecTypeInfo::Video(vinfo) = info.get_properties() {
514 let w = vinfo.get_width();
515 let h = vinfo.get_height();
516 let f = vinfo.is_flipped();
517 let fmt = formats::YUV410_FORMAT;
518 let myinfo = NACodecTypeInfo::Video(NAVideoInfo::new(w, h, f, fmt));
519 self.info = Rc::new(NACodecInfo::new_ref(info.get_name(), myinfo, info.get_extradata()));
522 Err(DecoderError::InvalidData)
525 fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
526 let src = pkt.get_buffer();
527 let mut br = BitReader::new(src.as_slice(), src.len(), BitReaderMode::LE);
529 let bufinfo = self.dec.decode_frame(&mut self.ip, &mut br)?;
530 let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), bufinfo);
531 frm.set_keyframe(self.dec.is_intra());
532 frm.set_frame_type(self.dec.get_frame_type());
533 Ok(Rc::new(RefCell::new(frm)))
537 const INDEO5_PICTURE_SIZE_TAB: [[usize; 2]; 15] = [
538 [640, 480], [320, 240], [160, 120], [704, 480], [352, 240], [352, 288], [176, 144],
539 [240, 180], [640, 240], [704, 240], [80, 60], [88, 72], [0, 0], [0, 0], [0, 0]
542 const INDEO5_FRAME_TYPE: [IVIFrameType; 5] = [
543 IVIFrameType::Intra, IVIFrameType::Inter, IVIFrameType::InterScal,
544 IVIFrameType::InterDroppable, IVIFrameType::NULL,
547 const INDEO5_QUANT8X8_INTRA: [[u16; 64]; 5] = [
549 0x1a, 0x2e, 0x36, 0x42, 0x46, 0x4a, 0x4e, 0x5a,
550 0x2e, 0x32, 0x3e, 0x42, 0x46, 0x4e, 0x56, 0x6a,
551 0x36, 0x3e, 0x3e, 0x44, 0x4a, 0x54, 0x66, 0x72,
552 0x42, 0x42, 0x44, 0x4a, 0x52, 0x62, 0x6c, 0x7a,
553 0x46, 0x46, 0x4a, 0x52, 0x5e, 0x66, 0x72, 0x8e,
554 0x4a, 0x4e, 0x54, 0x62, 0x66, 0x6e, 0x86, 0xa6,
555 0x4e, 0x56, 0x66, 0x6c, 0x72, 0x86, 0x9a, 0xca,
556 0x5a, 0x6a, 0x72, 0x7a, 0x8e, 0xa6, 0xca, 0xfe,
558 0x26, 0x3a, 0x3e, 0x46, 0x4a, 0x4e, 0x52, 0x5a,
559 0x3a, 0x3e, 0x42, 0x46, 0x4a, 0x4e, 0x56, 0x5e,
560 0x3e, 0x42, 0x46, 0x48,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, 0xc2, 0xc2,
585 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
586 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
587 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
588 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
589 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
590 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
591 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
592 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
595 const INDEO5_QUANT8X8_INTER: [[u16; 64]; 5] = [
597 0x26, 0x3a, 0x3e, 0x46, 0x4a, 0x4e, 0x52, 0x5a,
598 0x3a, 0x3e, 0x42, 0x46, 0x4a, 0x4e, 0x56, 0x5e,
599 0x3e, 0x42, 0x46, 0x48, 0x4c, 0x52, 0x5a, 0x62,
600 0x46, 0x46, 0x48, 0x4a, 0x4e, 0x56, 0x5e, 0x66,
601 0x4a, 0x4a, 0x4c, 0x4e, 0x52, 0x5a, 0x62, 0x6a,
602 0x4e, 0x4e, 0x52, 0x56, 0x5a, 0x5e, 0x66, 0x6e,
603 0x52, 0x56, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x72,
604 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x6e, 0x72, 0x76,
606 0x26, 0x3a, 0x3e, 0x46, 0x4a, 0x4e, 0x52, 0x5a,
607 0x3a, 0x3e, 0x42, 0x46, 0x4a, 0x4e, 0x56, 0x5e,
608 0x3e, 0x42, 0x46, 0x48, 0x4c, 0x52, 0x5a, 0x62,
609 0x46, 0x46, 0x48, 0x4a, 0x4e, 0x56, 0x5e, 0x66,
610 0x4a, 0x4a, 0x4c, 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, 0x5e, 0x5e, 0x5e, 0x5e,
635 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
636 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
637 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
638 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
639 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
640 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
643 const INDEO5_QUANT4X4_INTRA: [u16; 16] = [
644 0x1e, 0x3e, 0x4a, 0x52,
645 0x3e, 0x4a, 0x52, 0x5e,
646 0x4a, 0x52, 0x5e, 0x7a,
647 0x52, 0x5e, 0x7a, 0x92
649 const INDEO5_QUANT4X4_INTER: [u16; 16] = [
650 0x1e, 0x3e, 0x4a, 0x52,
651 0x3e, 0x4a, 0x52, 0x56,
652 0x4a, 0x52, 0x56, 0x5e,
653 0x52, 0x56, 0x5e, 0x66
655 const INDEO5_Q8_INTRA: [&[u16; 64]; 5] = [
656 &INDEO5_QUANT8X8_INTRA[0], &INDEO5_QUANT8X8_INTRA[1], &INDEO5_QUANT8X8_INTRA[2],
657 &INDEO5_QUANT8X8_INTRA[3], &INDEO5_QUANT8X8_INTRA[4],
659 const INDEO5_Q8_INTER: [&[u16; 64]; 5] = [
660 &INDEO5_QUANT8X8_INTER[0], &INDEO5_QUANT8X8_INTER[1], &INDEO5_QUANT8X8_INTER[2],
661 &INDEO5_QUANT8X8_INTER[3], &INDEO5_QUANT8X8_INTER[4],
663 const INDEO5_Q4_INTRA: &[u16; 16] = &INDEO5_QUANT4X4_INTRA;
664 const INDEO5_Q4_INTER: &[u16; 16] = &INDEO5_QUANT4X4_INTER;
666 const INDEO5_SCAN8X8: [&[usize; 64]; 4] = [
667 &IVI_ZIGZAG, &IVI_SCAN_8X8_VER, &IVI_SCAN_8X8_HOR, &IVI_SCAN_8X8_HOR
669 const INDEO5_SCAN4X4: &[usize; 16] = &IVI_SCAN_4X4;
671 const INDEO5_QSCALE8_INTRA: [[u8; 24]; 5] = [
673 0x0b, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x17, 0x18, 0x1a, 0x1c, 0x1e, 0x20,
674 0x22, 0x24, 0x27, 0x28, 0x2a, 0x2d, 0x2f, 0x31, 0x34, 0x37, 0x39, 0x3c,
676 0x01, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1b, 0x1e, 0x22, 0x25, 0x28, 0x2c,
677 0x30, 0x34, 0x38, 0x3d, 0x42, 0x47, 0x4c, 0x52, 0x58, 0x5e, 0x65, 0x6c,
679 0x13, 0x22, 0x27, 0x2a, 0x2d, 0x33, 0x36, 0x3c, 0x41, 0x45, 0x49, 0x4e,
680 0x53, 0x58, 0x5d, 0x63, 0x69, 0x6f, 0x75, 0x7c, 0x82, 0x88, 0x8e, 0x95,
682 0x13, 0x1f, 0x21, 0x24, 0x27, 0x29, 0x2d, 0x2f, 0x34, 0x37, 0x3a, 0x3d,
683 0x40, 0x44, 0x48, 0x4c, 0x4f, 0x52, 0x56, 0x5a, 0x5e, 0x62, 0x66, 0x6b,
685 0x31, 0x42, 0x47, 0x47, 0x4d, 0x52, 0x58, 0x58, 0x5d, 0x63, 0x67, 0x6b,
686 0x6f, 0x73, 0x78, 0x7c, 0x80, 0x84, 0x89, 0x8e, 0x93, 0x98, 0x9d, 0xa4,
689 const INDEO5_QSCALE8_INTER: [[u8; 24]; 5] = [
691 0x0b, 0x11, 0x13, 0x14, 0x15, 0x16, 0x18, 0x1a, 0x1b, 0x1d, 0x20, 0x22,
692 0x23, 0x25, 0x28, 0x2a, 0x2e, 0x32, 0x35, 0x39, 0x3d, 0x41, 0x44, 0x4a,
694 0x07, 0x14, 0x16, 0x18, 0x1b, 0x1e, 0x22, 0x25, 0x29, 0x2d, 0x31, 0x35,
695 0x3a, 0x3f, 0x44, 0x4a, 0x50, 0x56, 0x5c, 0x63, 0x6a, 0x71, 0x78, 0x7e,
697 0x15, 0x25, 0x28, 0x2d, 0x30, 0x34, 0x3a, 0x3d, 0x42, 0x48, 0x4c, 0x51,
698 0x56, 0x5b, 0x60, 0x65, 0x6b, 0x70, 0x76, 0x7c, 0x82, 0x88, 0x8f, 0x97,
700 0x13, 0x1f, 0x20, 0x22, 0x25, 0x28, 0x2b, 0x2d, 0x30, 0x33, 0x36, 0x39,
701 0x3c, 0x3f, 0x42, 0x45, 0x48, 0x4b, 0x4e, 0x52, 0x56, 0x5a, 0x5e, 0x62,
703 0x3c, 0x52, 0x58, 0x5d, 0x63, 0x68, 0x68, 0x6d, 0x73, 0x78, 0x7c, 0x80,
704 0x84, 0x89, 0x8e, 0x93, 0x98, 0x9d, 0xa3, 0xa9, 0xad, 0xb1, 0xb5, 0xba
707 const INDEO5_QSCALE4_INTRA: [u8; 24] = [
708 0x01, 0x0b, 0x0b, 0x0d, 0x0d, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x13, 0x14,
709 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20
711 const INDEO5_QSCALE4_INTER: [u8; 24] = [
712 0x0b, 0x0d, 0x0d, 0x0e, 0x11, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
713 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23
716 pub fn get_decoder() -> Box<NADecoder> {
717 Box::new(Indeo5Decoder::new())
722 use nihav_core::codecs::RegisteredDecoders;
723 use nihav_core::demuxers::RegisteredDemuxers;
724 use nihav_core::test::dec_video::*;
725 use crate::codecs::indeo_register_all_codecs;
726 use nihav_commonfmt::demuxers::generic_register_all_demuxers;
729 let mut dmx_reg = RegisteredDemuxers::new();
730 generic_register_all_demuxers(&mut dmx_reg);
731 let mut dec_reg = RegisteredDecoders::new();
732 indeo_register_all_codecs(&mut dec_reg);
734 test_file_decoding("avi", "assets/IV5/sample.avi", /*None*/Some(2), true, false, None, &dmx_reg, &dec_reg);
735 // test_file_decoding("avi", "assets/IV5/W32mdl_1.avi", None/*Some(2)*/, true, false, Some("iv5"));