From: Kostya Shishkov Date: Wed, 6 Nov 2024 17:03:44 +0000 (+0100) Subject: nihav_codec_support: fix or prune some clippy warnings X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=b86c9575d0b3b8c92f124b22f6f313e3dcfdf938;p=nihav.git nihav_codec_support: fix or prune some clippy warnings --- diff --git a/nihav-codec-support/src/lib.rs b/nihav-codec-support/src/lib.rs index 076b0ae..974e4d4 100644 --- a/nihav-codec-support/src/lib.rs +++ b/nihav-codec-support/src/lib.rs @@ -1,22 +1,12 @@ //! Code and data for easier development of NihAV decoders. -#[allow(clippy::cast_lossless)] -#[allow(clippy::identity_op)] -#[allow(clippy::too_many_arguments)] -#[allow(clippy::unreadable_literal)] 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)] @@ -24,7 +14,6 @@ pub mod imgwrite; 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/dec_video.rs b/nihav-codec-support/src/test/dec_video.rs index 9833f23..ba28535 100644 --- a/nihav-codec-support/src/test/dec_video.rs +++ b/nihav-codec-support/src/test/dec_video.rs @@ -13,6 +13,8 @@ pub use super::ExpectedTestResult; const OUTPUT_PREFIX: &str = "assets/test_out/"; +type PossibleDecoder = Option<(Box, Box)>; + /*fn open_wav_out(pfx: &str, strno: usize) -> WavWriter { let name = format!("assets/{}out{:02}.wav", pfx, strno); let mut file = File::create(name).unwrap(); @@ -42,7 +44,7 @@ pub fn test_file_decoding(demuxer: &str, name: &str, limit: Option, let mut br = ByteReader::new(&mut fr); let mut dmx = create_demuxer(dmx_f, &mut br).unwrap(); - let mut decs: Vec, Box)>> = Vec::new(); + let mut decs: Vec = Vec::new(); for i in 0..dmx.get_num_streams() { let s = dmx.get_stream(i).unwrap(); let info = s.get_info(); @@ -98,7 +100,7 @@ pub fn test_decode_audio(demuxer: &str, name: &str, limit: Option, audio_pf let mut br = ByteReader::new(&mut fr); let mut dmx = create_demuxer(dmx_f, &mut br).unwrap(); - let mut decs: Vec, Box)>> = Vec::new(); + let mut decs: Vec = Vec::new(); for i in 0..dmx.get_num_streams() { let s = dmx.get_stream(i).unwrap(); let info = s.get_info(); @@ -268,7 +270,7 @@ pub fn test_decoding(demuxer: &str, dec_name: &str, filename: &str, limit: Optio let mut br = ByteReader::new(&mut fr); let mut dmx = create_demuxer(dmx_f, &mut br).unwrap(); - let mut decs: Vec, Box)>> = Vec::new(); + let mut decs: Vec = Vec::new(); let mut found = false; for i in 0..dmx.get_num_streams() { let s = dmx.get_stream(i).unwrap(); @@ -654,7 +656,7 @@ pub fn test_decode_images(demuxer: &str, name: &str, video_pfx: &str, limit: Opt let mut br = ByteReader::new(&mut fr); let mut dmx = create_demuxer(dmx_f, &mut br).unwrap(); - let mut decs: Vec, Box)>> = Vec::new(); + let mut decs: Vec = Vec::new(); for i in 0..dmx.get_num_streams() { let s = dmx.get_stream(i).unwrap(); let info = s.get_info(); diff --git a/nihav-codec-support/src/vq/generic_elbg.rs b/nihav-codec-support/src/vq/generic_elbg.rs index d6c30d2..3925914 100644 --- a/nihav-codec-support/src/vq/generic_elbg.rs +++ b/nihav-codec-support/src/vq/generic_elbg.rs @@ -253,11 +253,11 @@ impl> ELBG { let mut closest_idx = *low_idx; let mut closest_dist = std::u32::MAX; let low_centr = self.clusters[*low_idx].centroid; - for i in 0..dst.len() {//low_u.iter() { - if i == *low_idx || used[i] { + for (i, (&used, cluster)) in used.iter().zip(self.clusters.iter()).take(dst.len()).enumerate() { + if i == *low_idx || used { continue; } - let dist = self.clusters[i].centroid.dist(low_centr); + let dist = cluster.centroid.dist(low_centr); if closest_dist > dist { closest_dist = dist; closest_idx = i;