From: Kostya Shishkov Date: Sun, 4 Apr 2021 08:06:18 +0000 (+0200) Subject: fix clippy warnings for update to rustc 1.46 X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=b7c882c1ce6f86c07c2340751200e3a060942826;p=nihav.git fix clippy warnings for update to rustc 1.46 --- diff --git a/nihav-codec-support/src/codecs/h263/code.rs b/nihav-codec-support/src/codecs/h263/code.rs index 4d24ec3..cbeb120 100644 --- a/nihav-codec-support/src/codecs/h263/code.rs +++ b/nihav-codec-support/src/codecs/h263/code.rs @@ -600,7 +600,7 @@ impl BlockDSP for H263BlockDSP { blockdsp::copy_block(&mut dst, src.clone(), 0, xpos, ypos, mv.x >> 1, mv.y >> 1, 16, 16, 0, 1, mode, H263_INTERP_FUNCS); blockdsp::copy_block(&mut dst, src.clone(), 1, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_FUNCS); - blockdsp::copy_block(&mut dst, src.clone(), 2, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_FUNCS); + blockdsp::copy_block(&mut dst, src, 2, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_FUNCS); } fn copy_blocks8x8(&self, dst: &mut NAVideoBuffer, src: NAVideoBufferRef, xpos: usize, ypos: usize, mvs: &[MV; 4]) { let mut dst = NASimpleVideoFrame::from_video_buf(dst).unwrap(); @@ -629,7 +629,7 @@ impl BlockDSP for H263BlockDSP { blockdsp::copy_block(&mut dst, src.clone(), 0, xpos, ypos, mv.x >> 1, mv.y >> 1, 16, 16, 0, 1, mode, H263_INTERP_AVG_FUNCS); blockdsp::copy_block(&mut dst, src.clone(), 1, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_AVG_FUNCS); - blockdsp::copy_block(&mut dst, src.clone(), 2, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_AVG_FUNCS); + blockdsp::copy_block(&mut dst, src, 2, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_AVG_FUNCS); } fn avg_blocks8x8(&self, dst: &mut NAVideoBuffer, src: NAVideoBufferRef, xpos: usize, ypos: usize, mvs: &[MV; 4]) { let mut dst = NASimpleVideoFrame::from_video_buf(dst).unwrap(); diff --git a/nihav-codec-support/src/codecs/h263/decoder.rs b/nihav-codec-support/src/codecs/h263/decoder.rs index 6be437b..e1af173 100644 --- a/nihav-codec-support/src/codecs/h263/decoder.rs +++ b/nihav-codec-support/src/codecs/h263/decoder.rs @@ -287,6 +287,7 @@ impl H263BaseDecoder { } Ok(()) } + #[allow(clippy::comparison_chain)] fn decode_intra_mb_pred_quant(&mut self, bd: &mut dyn BlockDecoder, bdsp: &dyn BlockDSP, mb_pos: usize, binfo: &BlockInfo, sstate: &SliceState, apply_acpred: bool) -> DecoderResult<()> { for i in 0..6 { bd.decode_block_intra(&binfo, &sstate, binfo.get_q(), i, (binfo.cbp & (1 << (5 - i))) != 0, &mut self.blk[i])?; @@ -410,7 +411,7 @@ impl H263BaseDecoder { bi.mv_f[blk_no] } } - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_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; @@ -514,7 +515,7 @@ impl H263BaseDecoder { } mb_pos } - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] pub fn parse_frame(&mut self, bd: &mut dyn BlockDecoder, bdsp: &dyn BlockDSP) -> DecoderResult { let pinfo = bd.decode_pichdr()?; let mut mvi = MVInfo::new(); diff --git a/nihav-codec-support/src/vq/generic_elbg.rs b/nihav-codec-support/src/vq/generic_elbg.rs index 87ea16e..32cbb82 100644 --- a/nihav-codec-support/src/vq/generic_elbg.rs +++ b/nihav-codec-support/src/vq/generic_elbg.rs @@ -148,7 +148,7 @@ impl> ELBG { clu1.calc_dist(); clu0.dist + clu1.dist } - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] pub fn quantise(&mut self, src: &[T], dst: &mut [T]) -> usize { if src.is_empty() || dst.len() != self.clusters.len() { return 0; diff --git a/nihav-commonfmt/src/codecs/aac.rs b/nihav-commonfmt/src/codecs/aac.rs index 09a5b6b..59cda62 100644 --- a/nihav-commonfmt/src/codecs/aac.rs +++ b/nihav-commonfmt/src/codecs/aac.rs @@ -558,7 +558,7 @@ impl Codebooks { let scale_cb = Codebook::new(&mut coderead, CodebookMode::MSB).unwrap(); let mut spec_cb: [Codebook; 11]; unsafe { - spec_cb = mem::uninitialized(); + spec_cb = mem::MaybeUninit::uninit().assume_init(); for i in 0..AAC_SPEC_CODES.len() { let mut coderead = TableCodebookDescReader::new(AAC_SPEC_CODES[i], AAC_SPEC_BITS[i], cb_map); ptr::write(&mut spec_cb[i], Codebook::new(&mut coderead, CodebookMode::MSB).unwrap()); @@ -1015,7 +1015,7 @@ impl DSP { tmp: [0.0; 2048], ew_buf: [0.0; 1152], } } - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] fn synth(&mut self, coeffs: &[f32; 1024], delay: &mut [f32; 1024], seq: u8, window_shape: bool, prev_window_shape: bool, dst: &mut [f32]) { let long_win = if window_shape { &self.kbd_long_win } else { &self.sine_long_win }; let short_win = if window_shape { &self.kbd_short_win } else { &self.sine_short_win }; diff --git a/nihav-commonfmt/src/codecs/mod.rs b/nihav-commonfmt/src/codecs/mod.rs index 643e73c..054836e 100644 --- a/nihav-commonfmt/src/codecs/mod.rs +++ b/nihav-commonfmt/src/codecs/mod.rs @@ -54,7 +54,7 @@ const DECODERS: &[DecoderInfo] = &[ /// Registers all available codecs provided by this crate. pub fn generic_register_all_decoders(rd: &mut RegisteredDecoders) { for decoder in DECODERS.iter() { - rd.add_decoder(decoder.clone()); + rd.add_decoder(*decoder); } } @@ -72,7 +72,7 @@ const ENCODERS: &[EncoderInfo] = &[ /// Registers all available encoders provided by this crate. pub fn generic_register_all_encoders(re: &mut RegisteredEncoders) { for encoder in ENCODERS.iter() { - re.add_encoder(encoder.clone()); + re.add_encoder(*encoder); } } diff --git a/nihav-commonfmt/src/codecs/ts102366.rs b/nihav-commonfmt/src/codecs/ts102366.rs index c4b1800..de6a5ad 100644 --- a/nihav-commonfmt/src/codecs/ts102366.rs +++ b/nihav-commonfmt/src/codecs/ts102366.rs @@ -831,7 +831,7 @@ impl AudioBlock { bap_buf_fill: [0; 3], } } - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] fn read(&mut self, br: &mut BitReader, bsi: &BSI, fscod: usize, blk_no: usize) -> DecoderResult { let channels = bsi.acmod.get_num_channels(); let is_stereo = bsi.acmod == ACMode::Stereo; diff --git a/nihav-commonfmt/src/demuxers/mov.rs b/nihav-commonfmt/src/demuxers/mov.rs index 9a77496..8b9526f 100644 --- a/nihav-commonfmt/src/demuxers/mov.rs +++ b/nihav-commonfmt/src/demuxers/mov.rs @@ -1077,7 +1077,7 @@ impl TimeSearcher { fn reset(&mut self) { *self = Self::default(); } - fn map_time(&mut self, sample: u32, tts: &Vec<(u32, u32)>) -> u64 { + fn map_time(&mut self, sample: u32, tts: &[(u32, u32)]) -> u64 { if tts.is_empty() { u64::from(sample) } else if sample >= self.sbase { @@ -1363,6 +1363,7 @@ impl Track { self.bsize } } + #[allow(clippy::collapsible_if)] fn seek(&mut self, pts: u64, tpoint: NATimePoint) -> DemuxerResult<()> { self.cur_sample = pts as usize; self.samples_left = 0; @@ -1604,6 +1605,7 @@ const DEMUXER_OPTIONS: &[NAOptionDefinition] = &[ impl<'a> NAOptionHandler for MOVDemuxer<'a> { fn get_supported_options(&self) -> &[NAOptionDefinition] { DEMUXER_OPTIONS } + #[allow(clippy::single_match)] fn set_options(&mut self, options: &[NAOption]) { for option in options.iter() { for opt_def in DEMUXER_OPTIONS.iter() { diff --git a/nihav-core/src/compr/deflate.rs b/nihav-core/src/compr/deflate.rs index d162306..3462a40 100644 --- a/nihav-core/src/compr/deflate.rs +++ b/nihav-core/src/compr/deflate.rs @@ -359,6 +359,7 @@ impl Inflate { ///! ///! [`DecompressError::ShortData`]: ../enum.DecompressError.html#variant.ShortData ///! [`DecompressError::OutputFull`]: ../enum.DecompressError.html#variant.OutputFull + #[allow(clippy::comparison_chain)] pub fn decompress_data(&mut self, src: &[u8], dst: &mut [u8], continue_block: bool) -> DecompressResult { if src.is_empty() || dst.is_empty() { return Err(DecompressError::InvalidArgument); diff --git a/nihav-core/src/demuxers/mod.rs b/nihav-core/src/demuxers/mod.rs index dfcd118..9c7e46e 100644 --- a/nihav-core/src/demuxers/mod.rs +++ b/nihav-core/src/demuxers/mod.rs @@ -291,11 +291,11 @@ impl SeekIndex { pub fn new() -> Self { Self::default() } pub fn add_stream(&mut self, id: u32) -> usize { let ret = self.stream_id_to_index(id); - if ret.is_none() { + if let Some(res) = ret { + res + } else { self.seek_info.push(StreamSeekInfo::new(id)); self.seek_info.len() - 1 - } else { - ret.unwrap() } } /// Adds a new stream to the index. diff --git a/nihav-core/src/formats.rs b/nihav-core/src/formats.rs index 3501cb0..713a3e5 100644 --- a/nihav-core/src/formats.rs +++ b/nihav-core/src/formats.rs @@ -428,8 +428,8 @@ impl ColorModel { impl fmt::Display for ColorModel { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let name = match *self { - ColorModel::RGB(fmt) => format!("RGB({})", fmt).to_string(), - ColorModel::YUV(fmt) => format!("YUV({})", fmt).to_string(), + ColorModel::RGB(fmt) => format!("RGB({})", fmt), + ColorModel::YUV(fmt) => format!("YUV({})", fmt), ColorModel::CMYK => "CMYK".to_string(), ColorModel::HSV => "HSV".to_string(), ColorModel::LAB => "LAB".to_string(), @@ -710,7 +710,7 @@ impl NAPixelFormaton { } ssamp } - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] /// Returns a short string description of the format if possible. pub fn to_short_string(&self) -> Option { match self.model { @@ -1078,6 +1078,7 @@ fn parse_yuv_format(s: &str) -> Result { impl FromStr for NAPixelFormaton { type Err = FormatParseError; + #[allow(clippy::single_match)] fn from_str(s: &str) -> Result { match s { "pal8" => return Ok(PAL8_FORMAT), diff --git a/nihav-core/src/frame.rs b/nihav-core/src/frame.rs index 5ddec1a..0fcdbca 100644 --- a/nihav-core/src/frame.rs +++ b/nihav-core/src/frame.rs @@ -693,7 +693,7 @@ pub fn alloc_data_buffer(size: usize) -> Result { } /// Creates a clone of current buffer. -pub fn copy_buffer(buf: NABufferType) -> NABufferType { +pub fn copy_buffer(buf: &NABufferType) -> NABufferType { buf.clone() } @@ -937,6 +937,7 @@ impl NATimeInfo { pub fn set_duration(&mut self, dur: Option) { self.duration = dur; } /// Converts time in given scale into timestamp in given base. + #[allow(clippy::collapsible_if)] pub fn time_to_ts(time: u64, base: u64, tb_num: u32, tb_den: u32) -> u64 { let tb_num = u64::from(tb_num); let tb_den = u64::from(tb_den); @@ -1300,6 +1301,7 @@ pub struct NAStream { pub type NAStreamRef = Arc; /// Downscales the timebase by its greatest common denominator. +#[allow(clippy::comparison_chain)] pub fn reduce_timebase(tb_num: u32, tb_den: u32) -> (u32, u32) { if tb_num == 0 { return (tb_num, tb_den); } if (tb_den % tb_num) == 0 { return (1, tb_den / tb_num); } diff --git a/nihav-core/src/scale/palette/elbg.rs b/nihav-core/src/scale/palette/elbg.rs index 8b67a51..a9704f9 100644 --- a/nihav-core/src/scale/palette/elbg.rs +++ b/nihav-core/src/scale/palette/elbg.rs @@ -195,7 +195,7 @@ impl ELBG { clu1.calc_dist(); clu0.dist + clu1.dist } - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] pub fn quantise(&mut self, src: &[Pixel], dst: &mut [[u8; 3]; 256]) { if src.len() < 3 { return; diff --git a/nihav-core/src/scale/palette/neuquant.rs b/nihav-core/src/scale/palette/neuquant.rs index 73d2a3a..0974500 100644 --- a/nihav-core/src/scale/palette/neuquant.rs +++ b/nihav-core/src/scale/palette/neuquant.rs @@ -52,6 +52,7 @@ impl NeuQuantQuantiser { } } } + #[allow(clippy::float_cmp)] fn find_node(&mut self, clr: &[f64; 3]) -> usize { for i in 0..SPECIAL_NODES { if &self.weights[i] == clr { diff --git a/nihav-core/src/scale/scale.rs b/nihav-core/src/scale/scale.rs index eb8ff6c..fc97bd7 100644 --- a/nihav-core/src/scale/scale.rs +++ b/nihav-core/src/scale/scale.rs @@ -7,6 +7,7 @@ impl NNResampler { fn new() -> Self { Self{} } } +#[allow(clippy::comparison_chain)] fn scale_line(src: &[T], dst: &mut [T], src_w: usize, dst_w: usize) { if src_w == dst_w { (&mut dst[..dst_w]).copy_from_slice(&src[..dst_w]); diff --git a/nihav-duck/src/codecs/mod.rs b/nihav-duck/src/codecs/mod.rs index bfdd44e..da702b4 100644 --- a/nihav-duck/src/codecs/mod.rs +++ b/nihav-duck/src/codecs/mod.rs @@ -93,6 +93,6 @@ const DUCK_CODECS: &[DecoderInfo] = &[ /// Registers all available codecs provided by this crate. pub fn duck_register_all_decoders(rd: &mut RegisteredDecoders) { for decoder in DUCK_CODECS.iter() { - rd.add_decoder(decoder.clone()); + rd.add_decoder(*decoder); } } diff --git a/nihav-duck/src/codecs/on2avc.rs b/nihav-duck/src/codecs/on2avc.rs index 17f2d5e..1e3a122 100644 --- a/nihav-duck/src/codecs/on2avc.rs +++ b/nihav-duck/src/codecs/on2avc.rs @@ -346,7 +346,7 @@ impl AVCDecoder { } Ok(()) } - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] fn synth_channel(&mut self, chno: usize, dst: &mut [f32]) { let coeffs = &mut self.coeffs[chno]; let delay = &mut self.delay[chno]; diff --git a/nihav-duck/src/codecs/truemotion2x.rs b/nihav-duck/src/codecs/truemotion2x.rs index 7f4ac52..652b5b0 100644 --- a/nihav-duck/src/codecs/truemotion2x.rs +++ b/nihav-duck/src/codecs/truemotion2x.rs @@ -277,7 +277,7 @@ impl TM2XDecoder { #[allow(clippy::int_plus_one)] #[allow(clippy::manual_memcpy)] - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] fn decode_frame(&mut self, src: &[u8]) -> DecoderResult<()> { let mut mr = MemoryReader::new_read(src); let mut br = ByteReader::new(&mut mr); diff --git a/nihav-duck/src/codecs/vp3.rs b/nihav-duck/src/codecs/vp3.rs index 9d56936..3507fdb 100644 --- a/nihav-duck/src/codecs/vp3.rs +++ b/nihav-duck/src/codecs/vp3.rs @@ -38,9 +38,9 @@ impl VP30Codes { let mut cr = TableCodebookDescReader::new(&VP30_MBTYPE_CODES, &VP30_MBTYPE_BITS, map_mbt); let mbtype_cb = Codebook::new(&mut cr, CodebookMode::MSB).unwrap(); unsafe { - dc_cb = mem::uninitialized(); - ac_i_cb = mem::uninitialized(); - ac_p_cb = mem::uninitialized(); + dc_cb = mem::MaybeUninit::uninit().assume_init(); + ac_i_cb = mem::MaybeUninit::uninit().assume_init(); + ac_p_cb = mem::MaybeUninit::uninit().assume_init(); for i in 0..5 { let mut cr = TableCodebookDescReader::new(&VP30_DC_CODES[i], &VP30_DC_BITS[i], map_idx); let cb = Codebook::new(&mut cr, CodebookMode::MSB).unwrap(); @@ -73,11 +73,11 @@ impl VP31Codes { let mut ac2_cb: [Codebook; 16]; let mut ac3_cb: [Codebook; 16]; unsafe { - dc_cb = mem::uninitialized(); - ac0_cb = mem::uninitialized(); - ac1_cb = mem::uninitialized(); - ac2_cb = mem::uninitialized(); - ac3_cb = mem::uninitialized(); + dc_cb = mem::MaybeUninit::uninit().assume_init(); + ac0_cb = mem::MaybeUninit::uninit().assume_init(); + ac1_cb = mem::MaybeUninit::uninit().assume_init(); + ac2_cb = mem::MaybeUninit::uninit().assume_init(); + ac3_cb = mem::MaybeUninit::uninit().assume_init(); for i in 0..16 { let mut cr = TableCodebookDescReader::new(&VP31_DC_CODES[i], &VP31_DC_BITS[i], map_idx); let cb = Codebook::new(&mut cr, CodebookMode::MSB).unwrap(); @@ -106,11 +106,11 @@ impl VP31Codes { let mut ac2_cb: [Codebook; 16]; let mut ac3_cb: [Codebook; 16]; unsafe { - dc_cb = mem::uninitialized(); - ac0_cb = mem::uninitialized(); - ac1_cb = mem::uninitialized(); - ac2_cb = mem::uninitialized(); - ac3_cb = mem::uninitialized(); + dc_cb = mem::MaybeUninit::uninit().assume_init(); + ac0_cb = mem::MaybeUninit::uninit().assume_init(); + ac1_cb = mem::MaybeUninit::uninit().assume_init(); + ac2_cb = mem::MaybeUninit::uninit().assume_init(); + ac3_cb = mem::MaybeUninit::uninit().assume_init(); for i in 0..16 { let mut cr = TableCodebookDescReader::new(&VP40_DC_CODES[i], &VP40_DC_BITS[i], map_idx); let cb = Codebook::new(&mut cr, CodebookMode::MSB).unwrap(); @@ -149,8 +149,8 @@ impl VP40AuxCodes { let mut mv_x_cb: [Codebook; 7]; let mut mv_y_cb: [Codebook; 7]; unsafe { - mv_x_cb = mem::uninitialized(); - mv_y_cb = mem::uninitialized(); + mv_x_cb = mem::MaybeUninit::uninit().assume_init(); + mv_y_cb = mem::MaybeUninit::uninit().assume_init(); for i in 0..7 { let mut cr = TableCodebookDescReader::new(&VP40_MV_X_CODES[i], &VP40_MV_X_BITS[i], map_mv); let cb = Codebook::new(&mut cr, CodebookMode::MSB).unwrap(); @@ -1553,7 +1553,7 @@ impl VP34Decoder { } } } - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] fn output_blocks_inter(&mut self, frm: &mut NASimpleVideoFrame) { let mut blk_idx = 0; let bstride = self.mb_w * 2; diff --git a/nihav-duck/src/codecs/vp56.rs b/nihav-duck/src/codecs/vp56.rs index b8cad17..797ff91 100644 --- a/nihav-duck/src/codecs/vp56.rs +++ b/nihav-duck/src/codecs/vp56.rs @@ -751,7 +751,7 @@ impl VP56Decoder { } Ok(self.last_mbt) } - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] fn decode_mb(&mut self, frm: &mut NASimpleVideoFrame, bc: &mut BoolCoder, cr: &mut CoeffReader, br: &mut dyn VP56Parser, hdr: &VP56Header, alpha: bool) -> DecoderResult<()> { const FOURMV_SUB_TYPE: [VPMBType; 4] = [ VPMBType::InterNoMV, VPMBType::InterMV, VPMBType::InterNearest, VPMBType::InterNear ]; @@ -946,7 +946,7 @@ impl VP56Decoder { let x = self.fstate.mb_x * 8; let y = self.fstate.mb_y * 8; br.mc_block(frm, self.mc_buf.clone(), src.clone(), 1, x, y, mv, self.loop_thr); - br.mc_block(frm, self.mc_buf.clone(), src.clone(), 2, x, y, mv, self.loop_thr); + br.mc_block(frm, self.mc_buf.clone(), src, 2, x, y, mv, self.loop_thr); } } fn do_fourmv(&mut self, br: &dyn VP56Parser, frm: &mut NASimpleVideoFrame, mvs: &[MV; 4], alpha: bool) { @@ -965,7 +965,7 @@ impl VP56Decoder { let sum = mvs[0] + mvs[1] + mvs[2] + mvs[3]; let mv = MV { x: sum.x / 4, y: sum.y / 4 }; br.mc_block(frm, self.mc_buf.clone(), src.clone(), 1, x, y, mv, self.loop_thr); - br.mc_block(frm, self.mc_buf.clone(), src.clone(), 2, x, y, mv, self.loop_thr); + br.mc_block(frm, self.mc_buf.clone(), src, 2, x, y, mv, self.loop_thr); } } fn predict_dc(&mut self, mb_type: VPMBType, _mb_pos: usize, blk_no: usize, _alpha: bool) { diff --git a/nihav-duck/src/codecs/vp6.rs b/nihav-duck/src/codecs/vp6.rs index 3dda67b..ca8946f 100644 --- a/nihav-duck/src/codecs/vp6.rs +++ b/nihav-duck/src/codecs/vp6.rs @@ -361,7 +361,7 @@ impl VP56Parser for VP6BR { (mv.x >> 3, mv.y >> 3, mv.x & 7, mv.y & 7, mv.x / 8, mv.y / 8) }; let tmp_blk = mc_buf.get_data_mut().unwrap(); - get_block(tmp_blk, 16, src.clone(), plane, x, y, sx, sy); + get_block(tmp_blk, 16, src, plane, x, y, sx, sy); if (msx & 7) != 0 { let foff = (8 - (sx & 7)) as usize; let off = 2 + foff; diff --git a/nihav-duck/src/codecs/vp7.rs b/nihav-duck/src/codecs/vp7.rs index 9243f93..b46cbad 100644 --- a/nihav-duck/src/codecs/vp7.rs +++ b/nihav-duck/src/codecs/vp7.rs @@ -1010,12 +1010,12 @@ impl VP7Decoder { if pitch_smode == 0 { mc_block8x8(dst, uoff, ustride, mb_x * 8, mb_y * 8, chroma_mv.x, chroma_mv.y, refframe.clone(), 1, &mut mc_buf); - mc_block8x8(dst, voff, vstride, mb_x * 8, mb_y * 8, chroma_mv.x, chroma_mv.y, refframe.clone(), 2, &mut mc_buf); + mc_block8x8(dst, voff, vstride, mb_x * 8, mb_y * 8, chroma_mv.x, chroma_mv.y, refframe, 2, &mut mc_buf); } else { mc_block_special(dst, uoff, ustride, mb_x * 8, mb_y * 8, chroma_mv.x, chroma_mv.y, refframe.clone(), 1, &mut mc_buf, 8, pitch_smode); mc_block_special(dst, voff, vstride, mb_x * 8, mb_y * 8, chroma_mv.x, chroma_mv.y, - refframe.clone(), 2, &mut mc_buf, 8, pitch_smode); + refframe, 2, &mut mc_buf, 8, pitch_smode); } } else { for y in 0..2 { @@ -1137,7 +1137,7 @@ impl NADecoder for VP7Decoder { Err(DecoderError::InvalidData) } } - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] fn decode(&mut self, supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult { let src = pkt.get_buffer(); diff --git a/nihav-duck/src/lib.rs b/nihav-duck/src/lib.rs index b0dae19..366a2db 100644 --- a/nihav-duck/src/lib.rs +++ b/nihav-duck/src/lib.rs @@ -2,6 +2,7 @@ extern crate nihav_core; extern crate nihav_codec_support; #[allow(clippy::collapsible_if)] +#[allow(clippy::comparison_chain)] #[allow(clippy::excessive_precision)] #[allow(clippy::identity_op)] #[allow(clippy::unreadable_literal)] diff --git a/nihav-game/src/codecs/mod.rs b/nihav-game/src/codecs/mod.rs index fb30a05..3caa51c 100644 --- a/nihav-game/src/codecs/mod.rs +++ b/nihav-game/src/codecs/mod.rs @@ -65,6 +65,6 @@ const GAME_CODECS: &[DecoderInfo] = &[ /// Registers all available codecs provided by this crate. pub fn game_register_all_decoders(rd: &mut RegisteredDecoders) { for decoder in GAME_CODECS.iter() { - rd.add_decoder(decoder.clone()); + rd.add_decoder(*decoder); } } diff --git a/nihav-game/src/codecs/vmd.rs b/nihav-game/src/codecs/vmd.rs index 40d8c5e..e05899d 100644 --- a/nihav-game/src/codecs/vmd.rs +++ b/nihav-game/src/codecs/vmd.rs @@ -488,7 +488,7 @@ impl NADecoder for VMDAudioDecoder { } } #[allow(clippy::identity_op)] - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult { let info = pkt.get_stream().get_info(); if let NACodecTypeInfo::Audio(_) = info.get_properties() { diff --git a/nihav-indeo/src/codecs/imc.rs b/nihav-indeo/src/codecs/imc.rs index ea84d0a..cb89b8e 100644 --- a/nihav-indeo/src/codecs/imc.rs +++ b/nihav-indeo/src/codecs/imc.rs @@ -103,7 +103,7 @@ impl BitAlloc { self.skip_flag[i] = false; } } - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] fn calculate_bit_allocation(&mut self, ch_data: &mut IMCChannel, bits: usize, fixed_head: bool, adj_idx: usize) -> DecoderResult<()> { let mut peak = 0.0; @@ -360,7 +360,7 @@ impl IMCDecoder { weights2.copy_from_slice(&IMC_WEIGHTS2); } unsafe { - codes = mem::uninitialized(); + codes = mem::MaybeUninit::uninit().assume_init(); for i in 0..4 { for j in 0..4 { let mut cr = IMCCodeReader::new(i, j); diff --git a/nihav-indeo/src/codecs/indeo3.rs b/nihav-indeo/src/codecs/indeo3.rs index cc3bed8..4048385 100644 --- a/nihav-indeo/src/codecs/indeo3.rs +++ b/nihav-indeo/src/codecs/indeo3.rs @@ -325,7 +325,7 @@ impl Indeo3Decoder { Ok((self.bbuf >> self.bpos) & 0x3) } - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] fn decode_cell_data(&mut self, br: &mut ByteReader, cell: IV3Cell, off: usize, stride: usize, params: CellDecParams, vq_idx: u8) -> DecoderResult<()> { let blk_w = cell.w * 4 / params.bw; diff --git a/nihav-indeo/src/codecs/indeo5.rs b/nihav-indeo/src/codecs/indeo5.rs index 3527906..eb0b40c 100644 --- a/nihav-indeo/src/codecs/indeo5.rs +++ b/nihav-indeo/src/codecs/indeo5.rs @@ -265,7 +265,7 @@ impl IndeoXParser for Indeo5Parser { Ok(BandHeader::new(plane_no, band_no, self.mb_size[band_id], self.blk_size[band_id], self.is_hpel[band_id], inherit_mv, has_qdelta, inherit_qd, band_q, rvmap_idx, num_corr, corr_map, blk_cb, tr, txtype)) } - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] fn decode_mb_info(&mut self, br: &mut BitReader, pic_hdr: &PictureHeader, band: &BandHeader, tile: &mut IVITile, ref_tile: Option<&IVITile>, mv_scale: u8) -> DecoderResult<()> { let mut mv_x = 0; let mut mv_y = 0; diff --git a/nihav-indeo/src/codecs/intel263.rs b/nihav-indeo/src/codecs/intel263.rs index ff55e65..7237adf 100644 --- a/nihav-indeo/src/codecs/intel263.rs +++ b/nihav-indeo/src/codecs/intel263.rs @@ -205,7 +205,7 @@ impl BlockDSP for I263BlockDSP { blockdsp::copy_block(&mut dst, src.clone(), 0, xpos, ypos, mv.x >> 1, mv.y >> 1, 16, 16, 0, 1, mode, H263_INTERP_FUNCS); blockdsp::copy_block(&mut dst, src.clone(), 1, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_FUNCS); - blockdsp::copy_block(&mut dst, src.clone(), 2, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_FUNCS); + blockdsp::copy_block(&mut dst, src, 2, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_FUNCS); } fn copy_blocks8x8(&self, dst: &mut NAVideoBuffer, src: NAVideoBufferRef, xpos: usize, ypos: usize, mvs: &[MV; 4]) { let mut dst = NASimpleVideoFrame::from_video_buf(dst).unwrap(); @@ -234,7 +234,7 @@ impl BlockDSP for I263BlockDSP { blockdsp::copy_block(&mut dst, src.clone(), 0, xpos, ypos, mv.x >> 1, mv.y >> 1, 16, 16, 0, 1, mode, H263_INTERP_AVG_FUNCS); blockdsp::copy_block(&mut dst, src.clone(), 1, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_AVG_FUNCS); - blockdsp::copy_block(&mut dst, src.clone(), 2, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_AVG_FUNCS); + blockdsp::copy_block(&mut dst, src, 2, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_AVG_FUNCS); } fn avg_blocks8x8(&self, dst: &mut NAVideoBuffer, src: NAVideoBufferRef, xpos: usize, ypos: usize, mvs: &[MV; 4]) { let mut dst = NASimpleVideoFrame::from_video_buf(dst).unwrap(); diff --git a/nihav-indeo/src/codecs/ivibr.rs b/nihav-indeo/src/codecs/ivibr.rs index c6609cc..141200c 100644 --- a/nihav-indeo/src/codecs/ivibr.rs +++ b/nihav-indeo/src/codecs/ivibr.rs @@ -931,8 +931,8 @@ br.skip(skip_part as u32)?; let seq = br.peek(21); if seq == 0xBFFF8 { let res2 = self.decode_single_frame(dec, br); - if res2.is_ok() { - self.bref = Some(res2.unwrap()); + if let Ok(res) = res2 { + self.bref = Some(res); } } self.ftype = IVIFrameType::Intra; diff --git a/nihav-indeo/src/codecs/mod.rs b/nihav-indeo/src/codecs/mod.rs index 321fe38..a5a8ec3 100644 --- a/nihav-indeo/src/codecs/mod.rs +++ b/nihav-indeo/src/codecs/mod.rs @@ -49,6 +49,6 @@ const INDEO_CODECS: &[DecoderInfo] = &[ /// Registers all available codecs provided by this crate. pub fn indeo_register_all_decoders(rd: &mut RegisteredDecoders) { for decoder in INDEO_CODECS.iter() { - rd.add_decoder(decoder.clone()); + rd.add_decoder(*decoder); } } diff --git a/nihav-itu/src/codecs/h264/cabac.rs b/nihav-itu/src/codecs/h264/cabac.rs index 4be9a0d..01d46af 100644 --- a/nihav-itu/src/codecs/h264/cabac.rs +++ b/nihav-itu/src/codecs/h264/cabac.rs @@ -258,7 +258,7 @@ fn decode_mv(cabac: &mut CABAC, ctx0: usize, ctx1: usize) -> MV { MV{ x, y } } -#[allow(clippy::cyclomatic_complexity)] +#[allow(clippy::cognitive_complexity)] pub fn decode_mb_pred_cabac(cabac: &mut CABAC, slice_hdr: &SliceHeader, mb_type: MBType, sstate: &mut SliceState, mb_info: &mut CurrentMBInfo) { mb_info.mb_type = mb_type; let num_l0 = slice_hdr.num_ref_idx_l0_active; diff --git a/nihav-itu/src/codecs/h264/cavlc.rs b/nihav-itu/src/codecs/h264/cavlc.rs index 73d9c6b..adc28ab 100644 --- a/nihav-itu/src/codecs/h264/cavlc.rs +++ b/nihav-itu/src/codecs/h264/cavlc.rs @@ -106,7 +106,7 @@ fn read_mvs(br: &mut BitReader, mvs: &mut [MV]) -> DecoderResult<()> { Ok(()) } -#[allow(clippy::cyclomatic_complexity)] +#[allow(clippy::cognitive_complexity)] pub fn decode_mb_pred_cavlc(br: &mut BitReader, slice_hdr: &SliceHeader, mb_type: MBType, sstate: &mut SliceState, mb_info: &mut CurrentMBInfo) -> DecoderResult<()> { mb_info.mb_type = mb_type; let num_l0 = slice_hdr.num_ref_idx_l0_active; diff --git a/nihav-itu/src/codecs/h264/mod.rs b/nihav-itu/src/codecs/h264/mod.rs index 976b8b5..803087c 100644 --- a/nihav-itu/src/codecs/h264/mod.rs +++ b/nihav-itu/src/codecs/h264/mod.rs @@ -657,7 +657,7 @@ println!("PAFF?"); } } } - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] fn handle_macroblock(&mut self, mb_info: &mut CurrentMBInfo) { let pps = &self.pps[self.cur_pps]; diff --git a/nihav-itu/src/codecs/h264/pic_ref.rs b/nihav-itu/src/codecs/h264/pic_ref.rs index 81889a2..d75d889 100644 --- a/nihav-itu/src/codecs/h264/pic_ref.rs +++ b/nihav-itu/src/codecs/h264/pic_ref.rs @@ -215,7 +215,7 @@ impl FrameRefs { self.ref_pics.truncate(0); self.long_term.truncate(0); } - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] pub fn select_refs(&mut self, sps: &SeqParameterSet, slice_hdr: &SliceHeader, cur_id: u32) { self.ref_list0.truncate(0); self.ref_list1.truncate(0); diff --git a/nihav-itu/src/codecs/h264/sets.rs b/nihav-itu/src/codecs/h264/sets.rs index 5bd51a9..b02faf1 100644 --- a/nihav-itu/src/codecs/h264/sets.rs +++ b/nihav-itu/src/codecs/h264/sets.rs @@ -50,7 +50,7 @@ pub fn is_high_profile(profile: u8) -> bool { } } -#[allow(clippy::cyclomatic_complexity)] +#[allow(clippy::cognitive_complexity)] pub fn parse_sps(src: &[u8]) -> DecoderResult { let mut br = BitReader::new(src, BitReaderMode::BE); let mut sps: SeqParameterSet = unsafe { std::mem::zeroed() }; diff --git a/nihav-itu/src/codecs/h264/slice.rs b/nihav-itu/src/codecs/h264/slice.rs index 7250faf..864eec7 100644 --- a/nihav-itu/src/codecs/h264/slice.rs +++ b/nihav-itu/src/codecs/h264/slice.rs @@ -124,7 +124,7 @@ pub fn parse_slice_header_minimal(br: &mut BitReader) -> DecoderResult<(usize, S Ok((first_mb_in_slice, slice_type)) } -#[allow(clippy::cyclomatic_complexity)] +#[allow(clippy::cognitive_complexity)] pub fn parse_slice_header(br: &mut BitReader, sps_arr: &[SeqParameterSet], pps_arr: &[PicParameterSet], is_idr: bool, nal_ref_idc: u8) -> DecoderResult { let mut hdr: SliceHeader = unsafe { std::mem::zeroed() }; diff --git a/nihav-itu/src/codecs/mod.rs b/nihav-itu/src/codecs/mod.rs index ec35801..efb24bc 100644 --- a/nihav-itu/src/codecs/mod.rs +++ b/nihav-itu/src/codecs/mod.rs @@ -16,6 +16,6 @@ const ITU_CODECS: &[DecoderInfo] = &[ /// Registers all available codecs provided by this crate. pub fn itu_register_all_decoders(rd: &mut RegisteredDecoders) { for decoder in ITU_CODECS.iter() { - rd.add_decoder(decoder.clone()); + rd.add_decoder(*decoder); } } diff --git a/nihav-itu/src/lib.rs b/nihav-itu/src/lib.rs index 234a472..2cd300f 100644 --- a/nihav-itu/src/lib.rs +++ b/nihav-itu/src/lib.rs @@ -2,6 +2,7 @@ extern crate nihav_core; extern crate nihav_codec_support; #[allow(clippy::collapsible_if)] +#[allow(clippy::comparison_chain)] #[allow(clippy::needless_range_loop)] #[allow(clippy::useless_let_if_seq)] mod codecs; diff --git a/nihav-llaudio/src/codecs/mod.rs b/nihav-llaudio/src/codecs/mod.rs index 5cc1769..87b524d 100644 --- a/nihav-llaudio/src/codecs/mod.rs +++ b/nihav-llaudio/src/codecs/mod.rs @@ -34,6 +34,6 @@ const LL_AUDIO_CODECS: &[DecoderInfo] = &[ /// Registers all available codecs provided by this crate. pub fn llaudio_register_all_decoders(rd: &mut RegisteredDecoders) { for decoder in LL_AUDIO_CODECS.iter() { - rd.add_decoder(decoder.clone()); + rd.add_decoder(*decoder); } } diff --git a/nihav-llaudio/src/codecs/wavpack.rs b/nihav-llaudio/src/codecs/wavpack.rs index 3d1f411..0f561ac 100644 --- a/nihav-llaudio/src/codecs/wavpack.rs +++ b/nihav-llaudio/src/codecs/wavpack.rs @@ -654,7 +654,7 @@ impl WavPackDecoder { dstate: DecorrState::new(), } } - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] fn decode_block(&mut self, hdr: &WVHeader, src: &[u8], start_ch: usize, abuf: &mut NABufferType) -> DecoderResult<()> { let mut mr = MemoryReader::new_read(src); let mut br = ByteReader::new(&mut mr); diff --git a/nihav-llaudio/src/lib.rs b/nihav-llaudio/src/lib.rs index abe4694..78b8ab9 100644 --- a/nihav-llaudio/src/lib.rs +++ b/nihav-llaudio/src/lib.rs @@ -1,6 +1,7 @@ extern crate nihav_core; extern crate nihav_codec_support; +#[allow(clippy::comparison_chain)] #[allow(clippy::unreadable_literal)] #[allow(clippy::verbose_bit_mask)] mod codecs; diff --git a/nihav-ms/src/codecs/mod.rs b/nihav-ms/src/codecs/mod.rs index e01a6bb..752f5e8 100644 --- a/nihav-ms/src/codecs/mod.rs +++ b/nihav-ms/src/codecs/mod.rs @@ -30,7 +30,7 @@ const MS_CODECS: &[DecoderInfo] = &[ /// Registers all available codecs provided by this crate. pub fn ms_register_all_decoders(rd: &mut RegisteredDecoders) { for decoder in MS_CODECS.iter() { - rd.add_decoder(decoder.clone()); + rd.add_decoder(*decoder); } } @@ -47,6 +47,6 @@ const MS_ENCODERS: &[EncoderInfo] = &[ /// Registers all available encoders provided by this crate. pub fn ms_register_all_encoders(re: &mut RegisteredEncoders) { for encoder in MS_ENCODERS.iter() { - re.add_encoder(encoder.clone()); + re.add_encoder(*encoder); } } diff --git a/nihav-ms/src/codecs/msadpcm.rs b/nihav-ms/src/codecs/msadpcm.rs index 19e8146..5010c03 100644 --- a/nihav-ms/src/codecs/msadpcm.rs +++ b/nihav-ms/src/codecs/msadpcm.rs @@ -347,7 +347,7 @@ impl NAEncoder for MSADPCMEncoder { let soniton = NASoniton::new(4, 0); let out_ainfo = NAAudioInfo::new(ainfo.sample_rate, ainfo.channels, soniton, Self::calc_block_size(self.block_len, self.channels)); let info = NACodecInfo::new("ms-adpcm", NACodecTypeInfo::Audio(out_ainfo), None); - let mut stream = NAStream::new(StreamType::Audio, stream_id, info.clone(), self.block_len as u32, ainfo.sample_rate, 0); + let mut stream = NAStream::new(StreamType::Audio, stream_id, info, self.block_len as u32, ainfo.sample_rate, 0); stream.set_num(stream_id as usize); let stream = stream.into_ref(); diff --git a/nihav-qt/src/codecs/mod.rs b/nihav-qt/src/codecs/mod.rs index 0e91176..02de48e 100644 --- a/nihav-qt/src/codecs/mod.rs +++ b/nihav-qt/src/codecs/mod.rs @@ -88,6 +88,6 @@ const QT_CODECS: &[DecoderInfo] = &[ /// Registers all available codecs provided by this crate. pub fn qt_register_all_decoders(rd: &mut RegisteredDecoders) { for decoder in QT_CODECS.iter() { - rd.add_decoder(decoder.clone()); + rd.add_decoder(*decoder); } } diff --git a/nihav-qt/src/codecs/qdm2qmf.rs b/nihav-qt/src/codecs/qdm2qmf.rs index bd018aa..214f7af 100644 --- a/nihav-qt/src/codecs/qdm2qmf.rs +++ b/nihav-qt/src/codecs/qdm2qmf.rs @@ -370,7 +370,7 @@ unimplemented!(); } } } - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] fn read_noise_band(&mut self, br: &mut QdmBitReader, ch: usize, band: usize, samples: &mut [f32; 10], signs: &[bool; 16], jstereo: bool) -> DecoderResult<()> { let mut type34_first = true; let mut type34_pred = 0.0; diff --git a/nihav-qt/src/codecs/smc.rs b/nihav-qt/src/codecs/smc.rs index b78c46b..16f13b4 100644 --- a/nihav-qt/src/codecs/smc.rs +++ b/nihav-qt/src/codecs/smc.rs @@ -55,7 +55,7 @@ impl NADecoder for SmcDecoder { Err(DecoderError::InvalidData) } } - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult { let src = pkt.get_buffer(); validate!(src.len() >= 2); diff --git a/nihav-qt/src/codecs/svq3.rs b/nihav-qt/src/codecs/svq3.rs index c900d3c..46480f5 100644 --- a/nihav-qt/src/codecs/svq3.rs +++ b/nihav-qt/src/codecs/svq3.rs @@ -434,7 +434,7 @@ fn mc_part(dframe: &mut NASimpleVideoFrame, src: NAVideoBufferRef, ebuf: copy_block(dframe, src.clone(), ebuf, 0, xoff, yoff, mx, my, bw * 4, bh * 4, 0, post, mode, ifuncs); copy_block(dframe, src.clone(), ebuf, 1, xoff / 2, yoff / 2, cmx, cmy, bw * 2, bh * 2, 0, post, mode, ifuncs); - copy_block(dframe, src.clone(), ebuf, 2, xoff / 2, yoff / 2, cmx, cmy, bw * 2, bh * 2, 0, post, mode, ifuncs); + copy_block(dframe, src, ebuf, 2, xoff / 2, yoff / 2, cmx, cmy, bw * 2, bh * 2, 0, post, mode, ifuncs); } impl SVQ3Decoder { @@ -813,7 +813,7 @@ println!("slice offset {}", _offset); if let (Some(bwd_ref), true, true) = (self.ipbs.get_b_bwdref(), has_fwd, has_bwd) { let mut aframe = NASimpleVideoFrame::from_video_buf(&mut self.avg_buf).unwrap(); let amv = MV { x: bmv.x + (self.mb_x as i16) * 16 * 6, y: bmv.y + (self.mb_y as i16) * 16 * 6 }; - mc_part(&mut aframe, bwd_ref.clone(), &mut self.ebuf, 0, 0, 4, 4, amv, bmode, ifuncs); + mc_part(&mut aframe, bwd_ref, &mut self.ebuf, 0, 0, 4, 4, amv, bmode, ifuncs); let dstride = dframe.stride[0]; let dst = &mut dframe.data[dframe.offset[0] + self.mb_x * 16 + self.mb_y * 16 * dstride..]; diff --git a/nihav-qt/src/lib.rs b/nihav-qt/src/lib.rs index 29180f0..c434016 100644 --- a/nihav-qt/src/lib.rs +++ b/nihav-qt/src/lib.rs @@ -1,6 +1,7 @@ extern crate nihav_core; extern crate nihav_codec_support; +#[allow(clippy::comparison_chain)] #[allow(clippy::single_match)] mod codecs; pub use crate::codecs::qt_register_all_decoders; diff --git a/nihav-rad/src/codecs/bink2.rs b/nihav-rad/src/codecs/bink2.rs index 9ae02a7..21b48eb 100644 --- a/nihav-rad/src/codecs/bink2.rs +++ b/nihav-rad/src/codecs/bink2.rs @@ -1027,7 +1027,7 @@ impl Bink2Decoder { Self::default() } - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] fn decode_frame_new(&mut self, br: &mut BitReader, buf: &mut NAVideoBuffer, is_intra: bool) -> DecoderResult<()> { let (stride_y, stride_u, stride_v, stride_a) = (buf.get_stride(0), buf.get_stride(1), buf.get_stride(2), buf.get_stride(3)); let (mut off_y, mut off_u, mut off_v, mut off_a) = (buf.get_offset(0), buf.get_offset(1), buf.get_offset(2), buf.get_offset(3)); diff --git a/nihav-rad/src/codecs/binkvid.rs b/nihav-rad/src/codecs/binkvid.rs index 5f5bb56..b0643b0 100644 --- a/nihav-rad/src/codecs/binkvid.rs +++ b/nihav-rad/src/codecs/binkvid.rs @@ -387,7 +387,7 @@ impl Default for BinkTrees { fn default() -> Self { let mut cb: [Codebook; 16]; unsafe { - cb = std::mem::uninitialized(); + cb = std::mem::MaybeUninit::uninit().assume_init(); for i in 0..16 { let mut cr = TableCodebookDescReader::new(&BINK_TREE_CODES[i], &BINK_TREE_BITS[i], map_u8); std::ptr::write(&mut cb[i], Codebook::new(&mut cr, CodebookMode::LSB).unwrap()); diff --git a/nihav-rad/src/codecs/mod.rs b/nihav-rad/src/codecs/mod.rs index a11f5c5..6680c0f 100644 --- a/nihav-rad/src/codecs/mod.rs +++ b/nihav-rad/src/codecs/mod.rs @@ -31,6 +31,6 @@ const RAD_CODECS: &[DecoderInfo] = &[ /// Registers all available codecs provided by this crate. pub fn rad_register_all_decoders(rd: &mut RegisteredDecoders) { for decoder in RAD_CODECS.iter() { - rd.add_decoder(decoder.clone()); + rd.add_decoder(*decoder); } } diff --git a/nihav-rad/src/demuxers/bink.rs b/nihav-rad/src/demuxers/bink.rs index 83da6ac..dbf401f 100644 --- a/nihav-rad/src/demuxers/bink.rs +++ b/nihav-rad/src/demuxers/bink.rs @@ -146,7 +146,7 @@ impl<'a> DemuxCore<'a> for BinkDemuxer<'a> { let stream = strres.unwrap(); let keyframe = (self.frame_pos[self.cur_frame] & 1) != 0; let ts = NATimeInfo::new(Some(self.cur_frame as u64), None, None, self.tb_num, self.tb_den); - let pkt = self.src.read_packet(stream.clone(), ts, keyframe, payload_size)?; + let pkt = self.src.read_packet(stream, ts, keyframe, payload_size)?; self.cur_frame += 1; diff --git a/nihav-rad/src/lib.rs b/nihav-rad/src/lib.rs index 6ce3702..16a622c 100644 --- a/nihav-rad/src/lib.rs +++ b/nihav-rad/src/lib.rs @@ -15,6 +15,7 @@ mod codecs; pub use crate::codecs::rad_register_all_decoders; #[cfg(feature="demuxers")] +#[allow(clippy::comparison_chain)] #[allow(clippy::cast_lossless)] mod demuxers; #[cfg(feature="demuxers")] diff --git a/nihav-realmedia/src/codecs/mod.rs b/nihav-realmedia/src/codecs/mod.rs index d8a36d4..aea7a9e 100644 --- a/nihav-realmedia/src/codecs/mod.rs +++ b/nihav-realmedia/src/codecs/mod.rs @@ -75,6 +75,6 @@ const RM_CODECS: &[DecoderInfo] = &[ /// Registers all available codecs provided by this crate. pub fn realmedia_register_all_decoders(rd: &mut RegisteredDecoders) { for decoder in RM_CODECS.iter() { - rd.add_decoder(decoder.clone()); + rd.add_decoder(*decoder); } } diff --git a/nihav-realmedia/src/codecs/rv20.rs b/nihav-realmedia/src/codecs/rv20.rs index 88b1a60..0781987 100644 --- a/nihav-realmedia/src/codecs/rv20.rs +++ b/nihav-realmedia/src/codecs/rv20.rs @@ -140,7 +140,7 @@ impl BlockDSP for RV20BlockDSP { blockdsp::copy_block(&mut dst, src.clone(), 0, xpos, ypos, mv.x >> 1, mv.y >> 1, 16, 16, 0, 1, mode, H263_INTERP_FUNCS); blockdsp::copy_block(&mut dst, src.clone(), 1, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_FUNCS); - blockdsp::copy_block(&mut dst, src.clone(), 2, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_FUNCS); + blockdsp::copy_block(&mut dst, src, 2, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_FUNCS); } fn copy_blocks8x8(&self, dst: &mut NAVideoBuffer, src: NAVideoBufferRef, xpos: usize, ypos: usize, mvs: &[MV; 4]) { let mut dst = NASimpleVideoFrame::from_video_buf(dst).unwrap(); @@ -169,7 +169,7 @@ impl BlockDSP for RV20BlockDSP { blockdsp::copy_block(&mut dst, src.clone(), 0, xpos, ypos, mv.x >> 1, mv.y >> 1, 16, 16, 0, 1, mode, H263_INTERP_AVG_FUNCS); blockdsp::copy_block(&mut dst, src.clone(), 1, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_AVG_FUNCS); - blockdsp::copy_block(&mut dst, src.clone(), 2, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_AVG_FUNCS); + blockdsp::copy_block(&mut dst, src, 2, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_AVG_FUNCS); } fn avg_blocks8x8(&self, dst: &mut NAVideoBuffer, src: NAVideoBufferRef, xpos: usize, ypos: usize, mvs: &[MV; 4]) { let mut dst = NASimpleVideoFrame::from_video_buf(dst).unwrap(); diff --git a/nihav-realmedia/src/codecs/rv3040.rs b/nihav-realmedia/src/codecs/rv3040.rs index e4d8420..9e8c68a 100644 --- a/nihav-realmedia/src/codecs/rv3040.rs +++ b/nihav-realmedia/src/codecs/rv3040.rs @@ -1095,7 +1095,7 @@ impl RV34Decoder { } } - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] pub fn parse_frame(&mut self, supp: &mut NADecoderSupport, src: &[u8], bd: &mut dyn RV34BitstreamDecoder) -> DecoderResult<(NABufferType, FrameType, u64)> { let mut slice_offs: Vec = Vec::new(); parse_slice_offsets(src, &mut slice_offs)?; diff --git a/nihav-realmedia/src/codecs/rv30dsp.rs b/nihav-realmedia/src/codecs/rv30dsp.rs index ebdd1f3..36ae629 100644 --- a/nihav-realmedia/src/codecs/rv30dsp.rs +++ b/nihav-realmedia/src/codecs/rv30dsp.rs @@ -239,7 +239,7 @@ const RV30_EDGE1: [isize; 3] = [ 0, 1, 1 ]; const RV30_EDGE2: [isize; 3] = [ 0, 2, 2 ]; impl RV34DSP for RV30DSP { - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] fn loop_filter(&self, frame: &mut NAVideoBuffer, _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]; diff --git a/nihav-realmedia/src/codecs/rv40dsp.rs b/nihav-realmedia/src/codecs/rv40dsp.rs index 299c395..a883b0b 100644 --- a/nihav-realmedia/src/codecs/rv40dsp.rs +++ b/nihav-realmedia/src/codecs/rv40dsp.rs @@ -591,7 +591,7 @@ const C_LEFT_COL_MASK: u32 = 0x5; const C_RIGHT_COL_MASK: u32 = 0xA; impl RV34DSP for RV40DSP { - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] fn loop_filter(&self, frame: &mut NAVideoBuffer, _ftype: FrameType, mbinfo: &[RV34MBInfo], mb_w: usize, mb_h: usize, row: usize) { // todo proper B-frame filtering? let mut offs: [usize; 3] = [0; 3]; diff --git a/nihav-realmedia/src/codecs/rv60.rs b/nihav-realmedia/src/codecs/rv60.rs index d1e7c53..5574cb4 100644 --- a/nihav-realmedia/src/codecs/rv60.rs +++ b/nihav-realmedia/src/codecs/rv60.rs @@ -728,7 +728,7 @@ println!(" left {} bits", br.left()); } Ok(()) } - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] fn decode_cb_tree(&mut self, buf: &mut NASimpleVideoFrame, hdr: &FrameHeader, br: &mut BitReader, xpos: usize, ypos: usize, log_size: u8) -> DecoderResult<()> { if (xpos >= hdr.width) || (ypos >= hdr.height) { return Ok(()); } diff --git a/nihav-realmedia/src/codecs/rv60codes.rs b/nihav-realmedia/src/codecs/rv60codes.rs index 43bdce7..a830181 100644 --- a/nihav-realmedia/src/codecs/rv60codes.rs +++ b/nihav-realmedia/src/codecs/rv60codes.rs @@ -101,8 +101,8 @@ impl RV60Codebooks { let mut cbp8_cb: [[Codebook; 4]; NUM_INTER_SETS]; let mut cbp16_cb: [[Codebook; 12]; NUM_INTER_SETS]; unsafe { - cbp8_cb = mem::uninitialized(); - cbp16_cb = mem::uninitialized(); + cbp8_cb = mem::MaybeUninit::uninit().assume_init(); + cbp16_cb = mem::MaybeUninit::uninit().assume_init(); for set_no in 0..NUM_INTER_SETS { for i in 0..4 { let mut cbr = RV60CodebookDescReader::new(&RV60_CBP8_TABS[set_no][i], NUM_CBP_ENTRIES, false); @@ -117,11 +117,11 @@ impl RV60Codebooks { let mut intra_coeff_cb: [CoeffCodebooks; NUM_INTRA_SETS]; let mut inter_coeff_cb: [CoeffCodebooks; NUM_INTER_SETS]; unsafe { - intra_coeff_cb = mem::uninitialized(); + intra_coeff_cb = mem::MaybeUninit::uninit().assume_init(); for set_no in 0..NUM_INTRA_SETS { ptr::write(&mut intra_coeff_cb[set_no], CoeffCodebooks::init(set_no, true)); } - inter_coeff_cb = mem::uninitialized(); + inter_coeff_cb = mem::MaybeUninit::uninit().assume_init(); for set_no in 0..NUM_INTER_SETS { ptr::write(&mut inter_coeff_cb[set_no], CoeffCodebooks::init(set_no, false)); } diff --git a/nihav-realmedia/src/codecs/rv60dsp.rs b/nihav-realmedia/src/codecs/rv60dsp.rs index 760777a..7fa8933 100644 --- a/nihav-realmedia/src/codecs/rv60dsp.rs +++ b/nihav-realmedia/src/codecs/rv60dsp.rs @@ -58,7 +58,7 @@ macro_rules! filter_row { }); } -#[allow(clippy::cyclomatic_complexity)] +#[allow(clippy::cognitive_complexity)] fn luma_mc(dst: &mut [u8], mut didx: usize, dstride: usize, src: &[u8], mut sidx: usize, sstride: usize, w: usize, h: usize, cx: usize, cy: usize) { if (cx == 0) && (cy == 0) { for _ in 0..h { @@ -784,7 +784,7 @@ impl IntraPredContext { sum += diff; } } - #[allow(clippy::cyclomatic_complexity)] + #[allow(clippy::cognitive_complexity)] pub fn pred_angle(&self, dst: &mut [u8], mut doff: usize, dstride: usize, size: usize, angle: usize, filter: bool) { let mut filtered1: [u8; 96] = [0; 96]; let mut filtered2: [u8; 96] = [0; 96]; diff --git a/nihav-realmedia/src/demuxers/realmedia.rs b/nihav-realmedia/src/demuxers/realmedia.rs index 74581d9..248fa6c 100644 --- a/nihav-realmedia/src/demuxers/realmedia.rs +++ b/nihav-realmedia/src/demuxers/realmedia.rs @@ -1185,8 +1185,8 @@ fn read_string_size(src: &mut ByteReader, size: usize) -> DemuxerResult vec.push(c); } let str = String::from_utf8(vec); - if str.is_ok() { - Ok(str.unwrap()) + if let Ok(res) = str { + Ok(res) } else { Ok(String::new()) } @@ -1653,7 +1653,7 @@ impl<'a> RealIVRDemuxer<'a> { } } -static RM_VIDEO_CODEC_REGISTER: &'static [(&[u8;4], &str)] = &[ +static RM_VIDEO_CODEC_REGISTER: &[(&[u8;4], &str)] = &[ (b"RV10", "realvideo1"), (b"RV20", "realvideo2"), (b"RVTR", "realvideo2"), @@ -1663,7 +1663,7 @@ static RM_VIDEO_CODEC_REGISTER: &'static [(&[u8;4], &str)] = &[ (b"CLV1", "clearvideo_rm"), ]; -static RM_AUDIO_CODEC_REGISTER: &'static [(&[u8;4], &str)] = &[ +static RM_AUDIO_CODEC_REGISTER: &[(&[u8;4], &str)] = &[ (b"lpcJ", "ra14.4"), (b"28_8", "ra28.8"), (b"cook", "cook"), diff --git a/nihav-realmedia/src/lib.rs b/nihav-realmedia/src/lib.rs index 0155eac..06efd96 100644 --- a/nihav-realmedia/src/lib.rs +++ b/nihav-realmedia/src/lib.rs @@ -4,6 +4,7 @@ extern crate nihav_codec_support; #[cfg(feature="decoders")] #[allow(clippy::cast_lossless)] #[allow(clippy::collapsible_if)] +#[allow(clippy::comparison_chain)] #[allow(clippy::excessive_precision)] #[allow(clippy::identity_op)] #[allow(clippy::needless_range_loop)] diff --git a/nihav-registry/src/register.rs b/nihav-registry/src/register.rs index 75a13d9..bf5255c 100644 --- a/nihav-registry/src/register.rs +++ b/nihav-registry/src/register.rs @@ -155,7 +155,7 @@ pub fn get_codec_description(name: &str) -> Option<&'static CodecDescription> { None } -static CODEC_REGISTER: &'static [CodecDescription] = &[ +static CODEC_REGISTER: &[CodecDescription] = &[ desc!(audio-ll; "pcm", "PCM"), desc!(audio; "alaw", "A-law PCM"), desc!(audio; "ulaw", "mu-law PCM"), @@ -263,7 +263,7 @@ static CODEC_REGISTER: &'static [CodecDescription] = &[ desc!(video; "h264", "ITU H.264", CODEC_CAP_COMPLEX_REORDER | CODEC_CAP_HYBRID), ]; -static AVI_VIDEO_CODEC_REGISTER: &'static [(&[u8;4], &str)] = &[ +static AVI_VIDEO_CODEC_REGISTER: &[(&[u8;4], &str)] = &[ (&[1, 0, 0, 0], "msrle"), (&[2, 0, 0, 0], "msrle"), @@ -302,7 +302,7 @@ static AVI_VIDEO_CODEC_REGISTER: &'static [(&[u8;4], &str)] = &[ (b"VP70", "vp7"), ]; -static WAV_CODEC_REGISTER: &'static [(u16, &str)] = &[ +static WAV_CODEC_REGISTER: &[(u16, &str)] = &[ (0x0000, "unknown"), (0x0001, "pcm"), (0x0002, "ms-adpcm"), @@ -316,7 +316,7 @@ static WAV_CODEC_REGISTER: &'static [(u16, &str)] = &[ (0x0501, "on2avc-501"), ]; -static MOV_VIDEO_CODEC_REGISTER: &'static [(&[u8;4], &str)] = &[ +static MOV_VIDEO_CODEC_REGISTER: &[(&[u8;4], &str)] = &[ (b"cvid", "cinepak"), (b"jpeg", "jpeg"), //(b"raw ", "raw"), @@ -344,7 +344,7 @@ static MOV_VIDEO_CODEC_REGISTER: &'static [(&[u8;4], &str)] = &[ (b"avc1", "h264"), ]; -static MOV_AUDIO_CODEC_REGISTER: &'static [(&[u8;4], &str)] = &[ +static MOV_AUDIO_CODEC_REGISTER: &[(&[u8;4], &str)] = &[ (b"NONE", "pcm"), (b"raw ", "pcm"), (b"twos", "pcm"), diff --git a/nihav-vivo/src/codecs/mod.rs b/nihav-vivo/src/codecs/mod.rs index 354f585..ea95f23 100644 --- a/nihav-vivo/src/codecs/mod.rs +++ b/nihav-vivo/src/codecs/mod.rs @@ -32,6 +32,6 @@ const VIVO_CODECS: &[DecoderInfo] = &[ /// Registers all available codecs provided by this crate. pub fn vivo_register_all_decoders(rd: &mut RegisteredDecoders) { for decoder in VIVO_CODECS.iter() { - rd.add_decoder(decoder.clone()); + rd.add_decoder(*decoder); } } diff --git a/nihav-vivo/src/codecs/vivo.rs b/nihav-vivo/src/codecs/vivo.rs index c6620b4..7f99a52 100644 --- a/nihav-vivo/src/codecs/vivo.rs +++ b/nihav-vivo/src/codecs/vivo.rs @@ -124,17 +124,17 @@ impl BlockDSP for VivoBlockDSP { blockdsp::copy_block(&mut dst, src.clone(), 0, xpos, ypos, mv.x >> 1, mv.y >> 1, 16, 16, 0, 1, mode, H263_INTERP_FUNCS); blockdsp::copy_block(&mut dst, src.clone(), 1, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_FUNCS); - blockdsp::copy_block(&mut dst, src.clone(), 2, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_FUNCS); + blockdsp::copy_block(&mut dst, src, 2, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_FUNCS); } fn copy_blocks8x8(&self, dst: &mut NAVideoBuffer, src: NAVideoBufferRef, xpos: usize, ypos: usize, mvs: &[MV; 4]) { let mut dst = NASimpleVideoFrame::from_video_buf(dst).unwrap(); - for i in 0..4 { + for (i, mv) in mvs.iter().enumerate() { let xadd = (i & 1) * 8; let yadd = (i & 2) * 4; - let mode = ((mvs[i].x & 1) + (mvs[i].y & 1) * 2) as usize; + let mode = ((mv.x & 1) + (mv.y & 1) * 2) as usize; - blockdsp::copy_block(&mut dst, src.clone(), 0, xpos + xadd, ypos + yadd, mvs[i].x >> 1, mvs[i].y >> 1, 8, 8, 0, 1, mode, H263_INTERP_FUNCS); + blockdsp::copy_block(&mut dst, src.clone(), 0, xpos + xadd, ypos + yadd, mv.x >> 1, mv.y >> 1, 8, 8, 0, 1, mode, H263_INTERP_FUNCS); } let sum_mv = mvs[0] + mvs[1] + mvs[2] + mvs[3]; @@ -153,17 +153,17 @@ impl BlockDSP for VivoBlockDSP { blockdsp::copy_block(&mut dst, src.clone(), 0, xpos, ypos, mv.x >> 1, mv.y >> 1, 16, 16, 0, 1, mode, H263_INTERP_AVG_FUNCS); blockdsp::copy_block(&mut dst, src.clone(), 1, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_AVG_FUNCS); - blockdsp::copy_block(&mut dst, src.clone(), 2, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_AVG_FUNCS); + blockdsp::copy_block(&mut dst, src, 2, xpos >> 1, ypos >> 1, mv.x >> 2, mv.y >> 2, 8, 8, 0, 1, cmode, H263_INTERP_AVG_FUNCS); } fn avg_blocks8x8(&self, dst: &mut NAVideoBuffer, src: NAVideoBufferRef, xpos: usize, ypos: usize, mvs: &[MV; 4]) { let mut dst = NASimpleVideoFrame::from_video_buf(dst).unwrap(); - for i in 0..4 { + for (i, mv) in mvs.iter().enumerate() { let xadd = (i & 1) * 8; let yadd = (i & 2) * 4; - let mode = ((mvs[i].x & 1) + (mvs[i].y & 1) * 2) as usize; + let mode = ((mv.x & 1) + (mv.y & 1) * 2) as usize; - blockdsp::copy_block(&mut dst, src.clone(), 0, xpos + xadd, ypos + yadd, mvs[i].x >> 1, mvs[i].y >> 1, 8, 8, 0, 1, mode, H263_INTERP_AVG_FUNCS); + blockdsp::copy_block(&mut dst, src.clone(), 0, xpos + xadd, ypos + yadd, mv.x >> 1, mv.y >> 1, 8, 8, 0, 1, mode, H263_INTERP_AVG_FUNCS); } let sum_mv = mvs[0] + mvs[1] + mvs[2] + mvs[3];