codec_support: fix or silence clippy warnings
authorKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 16 Jun 2020 10:10:57 +0000 (12:10 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 16 Jun 2020 10:10:57 +0000 (12:10 +0200)
nihav-codec-support/src/codecs/h263/code.rs
nihav-codec-support/src/codecs/h263/decoder.rs
nihav-codec-support/src/codecs/h263/mod.rs
nihav-codec-support/src/codecs/imaadpcm.rs
nihav-codec-support/src/codecs/mod.rs
nihav-codec-support/src/dsp/dct.rs
nihav-codec-support/src/lib.rs
nihav-codec-support/src/test/enc_video.rs
nihav-codec-support/src/test/mod.rs
nihav-codec-support/src/vq/generic_elbg.rs
nihav-codec-support/src/vq/generic_mediancut.rs

index 05779910524202310de2906e4b42d787a41666f4..51aa1e743145fe88f69811d81a8961b8fecb5937 100644 (file)
@@ -339,6 +339,7 @@ fn h263_interp11_avg(dst: &mut [u8], dstride: usize, src: &[u8], sstride: usize,
 pub const H263_INTERP_AVG_FUNCS: &[blockdsp::BlkInterpFunc] = &[
         h263_interp00_avg, h263_interp01_avg, h263_interp10_avg, h263_interp11_avg ];
 
+#[derive(Default)]
 pub struct H263BlockDSP { }
 
 impl H263BlockDSP {
index 71c574ca0f3e807aadcc9a81a6dc43a65f4e0e26..f5c528ac420e9e0905f88980e0d002c324f83337 100644 (file)
@@ -301,6 +301,7 @@ impl H263BaseDecoder {
             bi.mv_f[blk_no]
         }
     }
+    #[allow(clippy::cyclomatic_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;
@@ -404,6 +405,7 @@ impl H263BaseDecoder {
         }
         mb_pos
     }
+    #[allow(clippy::cyclomatic_complexity)]
     pub fn parse_frame(&mut self, bd: &mut BlockDecoder, bdsp: &BlockDSP) -> DecoderResult<NABufferType> {
         let pinfo = bd.decode_pichdr()?;
         let mut mvi = MVInfo::new();
index 8c3ca655088008480e30e64f32c7d63d66123770..0ddfed597f65beed0472d4cffb10cc07b65df5a2 100644 (file)
@@ -2,6 +2,7 @@ use nihav_core::codecs::DecoderResult;
 use super::{MV, ZERO_MV};
 use nihav_core::frame::{NAVideoBuffer, NAVideoBufferRef};
 
+#[allow(clippy::erasing_op)]
 #[allow(clippy::many_single_char_names)]
 pub mod code;
 pub mod data;
index 6ff92eb6b2d9856fad9b491dbde14f035bace044..a2da1d316bc90dd42abddce01d26941b4d3a00ff 100644 (file)
@@ -57,4 +57,8 @@ impl IMAState {
     }
 }
 
-
+impl Default for IMAState {
+    fn default() -> Self {
+        Self::new()
+    }
+}
index 0d5307c01aa5f314d0a34a104c6d4438023f2ec6..6589e477e4e3eaab4f57d9a0a9498c06a2ed39df 100644 (file)
@@ -298,6 +298,9 @@ impl fmt::Display for MV {
 pub mod blockdsp;
 
 #[cfg(feature="h263")]
+#[allow(clippy::collapsible_if)]
+#[allow(clippy::manual_memcpy)]
+#[allow(clippy::needless_range_loop)]
 pub mod h263;
 
 /// The common 8x8 zigzag scan.
index 2a744492f53a13c2a2f85e04689013b0c24a5ccf..2206350f50b6fe7ec2f30a7a712bb133f8f7d536 100644 (file)
@@ -159,7 +159,7 @@ fn reverse_bits(inval: u32) -> u32 {
     let mut ret = 0;
     let mut val = inval;
     for _ in 0..8 {
-        ret = (ret << 4) | (REV_TAB[(val & 0xF) as usize] as u32);
+        ret = (ret << 4) | u32::from(REV_TAB[(val & 0xF) as usize]);
         val >>= 4;
     }
     ret
index 9139a2ae0b4fc10eeec9fd3c083829ed26e42eb9..076b0ae1fa86c05abd160ab362eee75113dbf30d 100644 (file)
@@ -8,17 +8,23 @@ pub mod codecs;
 #[cfg(feature="dsp")]
 #[allow(clippy::excessive_precision)]
 #[allow(clippy::identity_op)]
+#[allow(clippy::manual_memcpy)]
 #[allow(clippy::needless_range_loop)]
 #[allow(clippy::unreadable_literal)]
 pub mod dsp;
 
 pub mod data;
 
+#[allow(clippy::identity_op)]
+#[allow(clippy::many_single_char_names)]
 pub mod imgwrite;
 
+#[allow(clippy::too_many_arguments)]
+#[allow(clippy::type_complexity)]
 pub mod test;
 
 #[cfg(feature="vq")]
+#[allow(clippy::needless_range_loop)]
 pub mod vq;
 
 extern crate nihav_core;
index bde9e7874e46fbd969fd0a05f321b468398de1ee..c27459e035e6ade504e327194b96c2f144ebe45b 100644 (file)
@@ -133,7 +133,7 @@ pub fn test_remuxing_md5(dec_config: &DecoderTestParams, muxer: &str, mux_reg: &
 
     let mux_f = mux_reg.find_muxer(muxer).unwrap();
 
-    let mut dst = Vec::with_capacity(1048576);
+    let mut dst = Vec::with_capacity(1 << 10);
     let mut gw = GrowableMemoryWriter::new_write(&mut dst);
     let mut bw = ByteWriter::new(&mut gw);
     let mut out_sm = StreamManager::new();
index 2d2cda7ea28fa8d41588dc071c4db673d470059e..28a19f6c01a58b1bd2e44c1a6863b65d9b3e02fa 100644 (file)
@@ -1,10 +1,13 @@
 //! Decoder testing functionality.
 //!
 //! This module provides functions that may be used in internal test to check that decoders produce output and that they produce expected output.
+#[allow(clippy::identity_op)]
 pub mod dec_video;
 pub mod enc_video;
 pub mod wavwriter;
 
+#[allow(clippy::identity_op)]
+#[allow(clippy::unreadable_literal)]
 mod md5; // for internal checksums only
 
 /// Decoder testing modes.
index 2dfed5bf9f08496f272508064551ef014fdcd102..87ea16e90560935816658f9ac5d9c29ddf770886 100644 (file)
@@ -9,7 +9,7 @@ impl RNG {
     fn new() -> Self { Self { seed: 0x1234 } }
     fn next(&mut self) -> u8 {
         if (self.seed & 0x8000) != 0 {
-            self.seed = (self.seed & 0x7FFF) * 2 ^ 0x1B2B;
+            self.seed = ((self.seed & 0x7FFF) * 2) ^ 0x1B2B;
         } else {
             self.seed <<= 1;
         }
@@ -148,8 +148,9 @@ impl<T: VQElement+Default, TS: VQElementSum<T>> ELBG<T, TS> {
         clu1.calc_dist();
         clu0.dist + clu1.dist
     }
+    #[allow(clippy::cyclomatic_complexity)]
     pub fn quantise(&mut self, src: &[T], dst: &mut [T]) -> usize {
-        if src.len() < 1 || dst.len() != self.clusters.len() {
+        if src.is_empty() || dst.len() != self.clusters.len() {
             return 0;
         }
         let mut old_cb = vec![T::default(); self.clusters.len()];
@@ -244,7 +245,7 @@ impl<T: VQElement+Default, TS: VQElementSum<T>> ELBG<T, TS> {
             if do_elbg_step {
                 do_elbg_step = false;
                 for low_idx in low_u.iter() {
-                    if high_u.len() == 0 {
+                    if high_u.is_empty() {
                         break;
                     }
                     let high_idx_idx = (rng.next() as usize) % high_u.len();
index e6b35e66b344eeb70f03a737c644e97aff2f3d9c..b35e53546ed6b34be108134ed4620263ed462f25 100644 (file)
@@ -60,7 +60,7 @@ impl<'a, T: VQElement> VQBox<'a, T> {
 
 pub fn quantise_median_cut<T: VQElement, TS: VQElementSum<T>>(src: &[T], dst: &mut [T]) -> usize {
     let mut points = Vec::with_capacity(src.len());
-    points.extend(src.into_iter());
+    points.extend(src.iter());
     for comp in 0..T::num_components() {
         T::sort_by_component(points.as_mut_slice(), comp);
     }