fix clippy warnings
[nihav.git] / nihav-qt / src / codecs / svq3.rs
index 07331c688e9c83200922ea28058a109aa6043d50..1a87ca62200fd76958a8f8ba898789ef0f38a2c2 100644 (file)
@@ -261,7 +261,7 @@ fn decode_alt_slice(br: &mut BitReader, blk: &mut [i16; 16], mut idx: usize, end
                 SVQ3_RUNLEVEL_ALT[val as usize]
             } else {
                 let run = (val & 0x7) as usize;
-                (run, ((val >> 3) as i16) + RUN_ADD_ALT[(run as usize).min(RUN_ADD_ALT.len() - 1)])
+                (run, ((val >> 3) as i16) + RUN_ADD_ALT[run.min(RUN_ADD_ALT.len() - 1)])
             };
         idx += run;
         validate!(idx < end);
@@ -289,7 +289,7 @@ fn decode_block(br: &mut BitReader, blk: &mut [i16; 16], start: usize, alt: bool
                     SVQ3_RUNLEVEL[val as usize]
                 } else {
                     let run = (val & 0xF) as usize;
-                    (run, ((val >> 4) as i16) + RUN_ADD[(run as usize).min(RUN_ADD.len() - 1)])
+                    (run, ((val >> 4) as i16) + RUN_ADD[run.min(RUN_ADD.len() - 1)])
                 };
             idx += run;
             validate!(idx < blk.len());
@@ -540,7 +540,7 @@ unimplemented!();
             let mbs = self.mb_w * self.mb_h;
             let mb_bits = if mbs < 64 { 6 } else { 32 - (mbs - 1).leading_zeros() } as u8;
             let _offset                 = br.read(mb_bits)?;
-println!("slice offset {}", _offset);
+//println!("slice offset {}", _offset);
         }
         let ts                          = br.read(8)? as u8;
         let quant                       = br.read(5)? as u8;
@@ -602,7 +602,7 @@ println!("slice offset {}", _offset);
         if !is_4x4 || (hdr.dquant && hdr.ftype != FrameType::I && cbp != 0) {
             let dq                      = br.read_code_signed(IntCodeType::Gamma)?;
             let new_q = i32::from(sstate.q) + dq;
-            validate!(new_q >= 0 && new_q < 32);
+            validate!((0..32).contains(&new_q));
             sstate.q = new_q as u8;
         }
         if !is_4x4 {
@@ -674,7 +674,7 @@ println!("slice offset {}", _offset);
             } else {
                 MCMode::Pixel
             };
-        let (bw, bh) = SVQ3_PART_SIZES[mb_type as usize];
+        let (bw, bh) = SVQ3_PART_SIZES[mb_type];
         let bw = (bw >> 2) as usize;
         let bh = (bh >> 2) as usize;
 
@@ -857,7 +857,7 @@ println!("slice offset {}", _offset);
         if hdr.dquant && cbp != 0 {
             let dq                      = br.read_code_signed(IntCodeType::Gamma)?;
             let new_q = i32::from(sstate.q) + dq;
-            validate!(new_q >= 0 && new_q < 32);
+            validate!((0..32).contains(&new_q));
             sstate.q = new_q as u8;
         }
         for sb in 0..4 {
@@ -1167,9 +1167,7 @@ impl NADecoder for SVQ3Decoder {
             }
             let ret = self.decode_slice(&mut br, &hdr, &mut dframe);
             std::mem::swap(&mut sbuf, &mut self.slice_buf);
-            if let Err(err) = ret {
-                return Err(err);
-            }
+            ret?;
             slice_prepared = false;
             off += slice_len;
         }