fix clippy warnings for update to rustc 1.46
[nihav.git] / nihav-codec-support / src / codecs / h263 / decoder.rs
index 591840673f392214b3e3431139713004494d1559..e1af173bca458a8d052f4b1479c121c070d492e7 100644 (file)
@@ -287,6 +287,7 @@ impl H263BaseDecoder {
         }
         Ok(())
     }
+    #[allow(clippy::comparison_chain)]
     fn decode_intra_mb_pred_quant(&mut self, bd: &mut dyn BlockDecoder, bdsp: &dyn BlockDSP, mb_pos: usize, binfo: &BlockInfo, sstate: &SliceState, apply_acpred: bool) -> DecoderResult<()> {
         for i in 0..6 {
             bd.decode_block_intra(&binfo, &sstate, binfo.get_q(), i, (binfo.cbp & (1 << (5 - i))) != 0, &mut self.blk[i])?;
@@ -295,6 +296,7 @@ impl H263BaseDecoder {
                 } else {
                     i16::from(binfo.get_q() * 2)
                 };
+            let qadd = (q + 1) >> 1;
             let quant_gray = 1024 / q;
             if apply_acpred && (binfo.acpred != ACPredMode::None) {
                 let has_b = (i == 1) || (i == 3) || !sstate.first_mb;
@@ -372,7 +374,19 @@ impl H263BaseDecoder {
                 for t in 0..8 { self.pred_coeffs[mb_pos].ver[i][t] = self.blk[i][t]; }
             }
             if apply_acpred {
-                self.blk[i][0] *= q;
+                let start = if binfo.get_q() < 8 {
+                        self.blk[i][0] <<= 3;
+                        1
+                    } else {
+                        0
+                    };
+                for el in self.blk[i].iter_mut().skip(start) {
+                    if *el > 0 {
+                        *el = *el * q + qadd;
+                    } else if *el < 0 {
+                        *el = *el * q - qadd;
+                    }
+                }
             }
             bdsp.idct(&mut self.blk[i]);
         }
@@ -397,7 +411,7 @@ impl H263BaseDecoder {
             bi.mv_f[blk_no]
         }
     }
-    #[allow(clippy::cyclomatic_complexity)]
+    #[allow(clippy::cognitive_complexity)]
     fn reconstruct_obmc(&mut self, buf: &mut NAVideoBuffer<u8>, slice_start: usize, start: usize, end: usize, slice_end: bool) -> usize {
         let mut mb_x = start % self.mb_w;
         let mut mb_y = start / self.mb_w;
@@ -501,7 +515,7 @@ impl H263BaseDecoder {
         }
         mb_pos
     }
-    #[allow(clippy::cyclomatic_complexity)]
+    #[allow(clippy::cognitive_complexity)]
     pub fn parse_frame(&mut self, bd: &mut dyn BlockDecoder, bdsp: &dyn BlockDSP) -> DecoderResult<NABufferType> {
         let pinfo = bd.decode_pichdr()?;
         let mut mvi = MVInfo::new();