]> git.nihav.org Git - nihav.git/blobdiff - nihav-indeo/src/codecs/indeo4.rs
Acorn Super Moving Blocks Decoder
[nihav.git] / nihav-indeo / src / codecs / indeo4.rs
index a7263c6736ee508c4bcb7561e4fc5787e9d71928..cc737024a17d8ed8d8a50be8b7e49dc2243dd586 100644 (file)
@@ -76,13 +76,9 @@ impl IndeoXParser for Indeo4Parser {
         let slice_h;
         if br.read_bool()? {
             let idx = br.read(4)? as usize;
-            if idx < 15 {
-                slice_w = INDEO4_SLICE_SIZE_TAB[idx];
-                slice_h = INDEO4_SLICE_SIZE_TAB[idx];
-            } else {
-                slice_w = width;
-                slice_h = height;
-            }
+            slice_h = if idx < 15 { INDEO4_SLICE_SIZE_TAB[idx] } else { height };
+            let idx = br.read(4)? as usize;
+            slice_w = if idx < 15 { INDEO4_SLICE_SIZE_TAB[idx] } else { width };
         } else {
             slice_w = width;
             slice_h = height;
@@ -186,7 +182,7 @@ impl IndeoXParser for Indeo4Parser {
                 txtype = TxType::Transform8(TxParams8x8::new(qintra, qinter, scan));
             } else if scan_idx < 10 {
                 validate!(!tr.is_8x8());
-                validate!((qmat_idx >= 15) && (qmat_idx < 22));
+                validate!((15..22).contains(&qmat_idx));
                 let scan = INDEO4_SCANS_4X4[scan_idx - 5];
                 let qidx = INDEO4_Q4X4_IDX[qmat_idx - 15];
                 let qintra = INDEO4_Q4_INTRA[qidx];
@@ -240,7 +236,7 @@ impl IndeoXParser for Indeo4Parser {
                     if pic_hdr.ftype.is_intra() {
                         mb.mtype = MBType::Intra;
                     } else if band.inherit_mv {
-                        if let Some(ref tileref) = ref_tile {
+                        if let Some(tileref) = ref_tile {
                             mb.mtype = tileref.mb[mb_idx].mtype;
                         } else {
                             return Err(DecoderError::MissingReference);
@@ -263,7 +259,7 @@ impl IndeoXParser for Indeo4Parser {
                         mb.cbp = br.read(4)? as u8;
                     }
                     if band.inherit_qd {
-                        if let Some(ref tileref) = ref_tile {
+                        if let Some(tileref) = ref_tile {
                             mb.qd = tileref.mb[mb_idx].qd;
                             mb.q  = calc_quant(band.quant, mb.qd);
                         } else {
@@ -278,7 +274,7 @@ impl IndeoXParser for Indeo4Parser {
 
                     if mb.mtype != MBType::Intra {
                         if band.inherit_mv {
-                            if let Some(ref tileref) = ref_tile {
+                            if let Some(tileref) = ref_tile {
                                 let mx = tileref.mb[mb_idx].mv_x;
                                 let my = tileref.mb[mb_idx].mv_y;
                                 if mv_scale == 0 {
@@ -315,7 +311,7 @@ impl IndeoXParser for Indeo4Parser {
                         mb.q  = calc_quant(band.quant, mb.qd);
                     }
                     if band.inherit_mv {
-                        if let Some(ref tileref) = ref_tile {
+                        if let Some(tileref) = ref_tile {
                             let mx = tileref.mb[mb_idx].mv_x;
                             let my = tileref.mb[mb_idx].mv_y;
                             if mv_scale == 0 {
@@ -426,7 +422,7 @@ impl Indeo4Decoder {
     fn new() -> Self {
         Indeo4Decoder {
             info:   NACodecInfo::new_dummy(),
-            dec:    IVIDecoder::new(),
+            dec:    IVIDecoder::new(false),
         }
     }
 }