From: Kostya Shishkov Date: Tue, 16 Jun 2020 10:10:57 +0000 (+0200) Subject: codec_support: fix or silence clippy warnings X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=03011b993dc4873b39d981f62abc01591a0544f7;p=nihav.git codec_support: fix or silence clippy warnings --- diff --git a/nihav-codec-support/src/codecs/h263/code.rs b/nihav-codec-support/src/codecs/h263/code.rs index 0577991..51aa1e7 100644 --- a/nihav-codec-support/src/codecs/h263/code.rs +++ b/nihav-codec-support/src/codecs/h263/code.rs @@ -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 { diff --git a/nihav-codec-support/src/codecs/h263/decoder.rs b/nihav-codec-support/src/codecs/h263/decoder.rs index 71c574c..f5c528a 100644 --- a/nihav-codec-support/src/codecs/h263/decoder.rs +++ b/nihav-codec-support/src/codecs/h263/decoder.rs @@ -301,6 +301,7 @@ impl H263BaseDecoder { bi.mv_f[blk_no] } } + #[allow(clippy::cyclomatic_complexity)] fn reconstruct_obmc(&mut self, buf: &mut NAVideoBuffer, 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 { let pinfo = bd.decode_pichdr()?; let mut mvi = MVInfo::new(); diff --git a/nihav-codec-support/src/codecs/h263/mod.rs b/nihav-codec-support/src/codecs/h263/mod.rs index 8c3ca65..0ddfed5 100644 --- a/nihav-codec-support/src/codecs/h263/mod.rs +++ b/nihav-codec-support/src/codecs/h263/mod.rs @@ -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; diff --git a/nihav-codec-support/src/codecs/imaadpcm.rs b/nihav-codec-support/src/codecs/imaadpcm.rs index 6ff92eb..a2da1d3 100644 --- a/nihav-codec-support/src/codecs/imaadpcm.rs +++ b/nihav-codec-support/src/codecs/imaadpcm.rs @@ -57,4 +57,8 @@ impl IMAState { } } - +impl Default for IMAState { + fn default() -> Self { + Self::new() + } +} diff --git a/nihav-codec-support/src/codecs/mod.rs b/nihav-codec-support/src/codecs/mod.rs index 0d5307c..6589e47 100644 --- a/nihav-codec-support/src/codecs/mod.rs +++ b/nihav-codec-support/src/codecs/mod.rs @@ -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. diff --git a/nihav-codec-support/src/dsp/dct.rs b/nihav-codec-support/src/dsp/dct.rs index 2a74449..2206350 100644 --- a/nihav-codec-support/src/dsp/dct.rs +++ b/nihav-codec-support/src/dsp/dct.rs @@ -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 diff --git a/nihav-codec-support/src/lib.rs b/nihav-codec-support/src/lib.rs index 9139a2a..076b0ae 100644 --- a/nihav-codec-support/src/lib.rs +++ b/nihav-codec-support/src/lib.rs @@ -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; diff --git a/nihav-codec-support/src/test/enc_video.rs b/nihav-codec-support/src/test/enc_video.rs index bde9e78..c27459e 100644 --- a/nihav-codec-support/src/test/enc_video.rs +++ b/nihav-codec-support/src/test/enc_video.rs @@ -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(); diff --git a/nihav-codec-support/src/test/mod.rs b/nihav-codec-support/src/test/mod.rs index 2d2cda7..28a19f6 100644 --- a/nihav-codec-support/src/test/mod.rs +++ b/nihav-codec-support/src/test/mod.rs @@ -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. diff --git a/nihav-codec-support/src/vq/generic_elbg.rs b/nihav-codec-support/src/vq/generic_elbg.rs index 2dfed5b..87ea16e 100644 --- a/nihav-codec-support/src/vq/generic_elbg.rs +++ b/nihav-codec-support/src/vq/generic_elbg.rs @@ -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> ELBG { 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> ELBG { 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(); diff --git a/nihav-codec-support/src/vq/generic_mediancut.rs b/nihav-codec-support/src/vq/generic_mediancut.rs index e6b35e6..b35e535 100644 --- a/nihav-codec-support/src/vq/generic_mediancut.rs +++ b/nihav-codec-support/src/vq/generic_mediancut.rs @@ -60,7 +60,7 @@ impl<'a, T: VQElement> VQBox<'a, T> { pub fn quantise_median_cut>(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); }