fix clippy warnings for update to rustc 1.46
[nihav.git] / nihav-realmedia / src / codecs / rv30dsp.rs
index dc7ed094efb7f922856f2fabab63535b581fe74b..36ae629d530468c8f325baee4350c68b450ed994 100644 (file)
@@ -1,6 +1,6 @@
 use nihav_core::frame::{FrameType, NAVideoBuffer};
-use nihav_core::codecs::MV;
-use nihav_core::codecs::blockdsp::edge_emu;
+use nihav_codec_support::codecs::MV;
+use nihav_codec_support::codecs::blockdsp::edge_emu;
 use super::rv3040::{RV34DSP, RV34MBInfo};
 
 fn clip8(a: i16) -> u8 {
@@ -34,7 +34,7 @@ macro_rules! mc_matrix {
             ($c1 * 6) * ($s[$o] as i32) + ($c1 * 9) * ($s[$o + 1] as i32) + ($c1) * ($s[$o + 2] as i32)
         );
     ($s: ident, $o: expr, $c1: expr, $d1: expr, $d2: expr) => (
-            (-$c1) * ($s[$o - 1] as i32) + ($c1 * $d1) * ($s[$o] as i32) + ($c1 * $d2) * ($s[$o + 1] as i32) + (-$c1) * ($s[$o + 2] as i32)
+            -($c1) * ($s[$o - 1] as i32) + ($c1 * $d1) * ($s[$o] as i32) + ($c1 * $d2) * ($s[$o + 1] as i32) + -($c1) * ($s[$o + 2] as i32)
         );
     ($s: ident, $o: expr, $ss: expr, $c1: expr, $c2: expr, $d1: expr, $d2: expr) => (
         ((mc_matrix!($s, $o -     $ss,  -1, $d1, $d2) +
@@ -140,7 +140,7 @@ const RV30_CHROMA_FRAC2: [u16; 3] = [ 0, 3, 5 ];
 fn rv30_chroma_mc(dst: &mut [u8], mut didx: usize, dstride: usize, src: &[u8], mut sidx: usize, sstride: usize, size: usize, x: usize, y: usize) {
     if (x == 0) && (y == 0) {
         for _ in 0..size {
-            for x in 0..size { dst[didx + x] = src[sidx + x]; }
+            dst[didx..][..size].copy_from_slice(&src[sidx..][..size]);
             didx += dstride;
             sidx += sstride;
         }
@@ -162,6 +162,7 @@ fn rv30_chroma_mc(dst: &mut [u8], mut didx: usize, dstride: usize, src: &[u8], m
     }
 }
 
+#[allow(clippy::type_complexity)]
 pub struct RV30DSP {
     luma_mc: [[fn (&mut [u8], usize, usize, &[u8], usize, usize); 9]; 2],
 }
@@ -238,7 +239,8 @@ const RV30_EDGE1: [isize; 3] = [ 0, 1, 1 ];
 const RV30_EDGE2: [isize; 3] = [ 0, 2, 2 ];
 
 impl RV34DSP for RV30DSP {
-    fn loop_filter(&self, frame: &mut NAVideoBuffer<u8>, _ftype: FrameType, mbinfo: &[RV34MBInfo], mb_w: usize, row: usize) {
+    #[allow(clippy::cognitive_complexity)]
+    fn loop_filter(&self, frame: &mut NAVideoBuffer<u8>, _ftype: FrameType, mbinfo: &[RV34MBInfo], mb_w: usize, _mb_h: usize, row: usize) {
         let mut offs:   [usize; 3] = [0; 3];
         let mut stride: [usize; 3] = [0; 3];
 
@@ -248,7 +250,7 @@ impl RV34DSP for RV30DSP {
             offs[comp] = frame.get_offset(comp) + start * stride[comp];
         }
 
-        let mut data = frame.get_data_mut();
+        let data = frame.get_data_mut().unwrap();
         let dst: &mut [u8] = data.as_mut_slice();
 
         // vertical filter
@@ -381,7 +383,7 @@ impl RV34DSP for RV30DSP {
         let size: usize = if use16 { 16 } else { 8 };
         let dstride = frame.get_stride(0);
         let doffset = frame.get_offset(0) + (if !avg { x + y * dstride } else { 0 });
-        let mut data = frame.get_data_mut();
+        let data = frame.get_data_mut().unwrap();
         let dst: &mut [u8] = data.as_mut_slice();
 
         let (w_, h_) = prev_frame.get_dimensions(0);
@@ -401,7 +403,7 @@ impl RV34DSP for RV30DSP {
             self.luma_mc[if use16 { 0 } else { 1 }][mode](dst, doffset, dstride, src, soffset, sstride);
         } else {
             let mut ebuf: [u8; 32*20] = [0; 32*20];
-            edge_emu(prev_frame, (x as isize) + (dx as isize) - 1, (y as isize) + (dy as isize) - 1, 16+3, 16+3, &mut ebuf, 32, 0);
+            edge_emu(prev_frame, (x as isize) + (dx as isize) - 1, (y as isize) + (dy as isize) - 1, 16+3, 16+3, &mut ebuf, 32, 0, 4);
             self.luma_mc[if use16 { 0 } else { 1 }][mode](dst, doffset, dstride, &ebuf, 32 + 1, 32);
         }
     }
@@ -409,7 +411,7 @@ impl RV34DSP for RV30DSP {
         let size: usize = if use8 { 8 } else { 4 };
         let dstride = frame.get_stride(comp);
         let doffset = frame.get_offset(comp) + (if !avg { x + y * dstride } else { 0 });
-        let mut data = frame.get_data_mut();
+        let data = frame.get_data_mut().unwrap();
         let dst: &mut [u8] = data.as_mut_slice();
 
         let (w_, h_) = prev_frame.get_dimensions(comp);
@@ -428,7 +430,7 @@ impl RV34DSP for RV30DSP {
             rv30_chroma_mc(dst, doffset, dstride, src, soffset, sstride, size, cx, cy);
         } else {
             let mut ebuf: [u8; 16*10] = [0; 16*10];
-            edge_emu(prev_frame, (x as isize) + (dx as isize), (y as isize) + (dy as isize), 8+1, 8+1, &mut ebuf, 16, comp);
+            edge_emu(prev_frame, (x as isize) + (dx as isize), (y as isize) + (dy as isize), 8+1, 8+1, &mut ebuf, 16, comp, 4);
             rv30_chroma_mc(dst, doffset, dstride, &ebuf, 0, 16, size, cx, cy);
         }
     }