From bf109afe32ce8eb2722ebd830667f9438ba21b54 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Tue, 16 Jun 2020 13:00:32 +0200 Subject: [PATCH] rad: fix or silence clippy warnings --- nihav-rad/src/codecs/bink2.rs | 5 +++-- nihav-rad/src/codecs/binkaud.rs | 1 + nihav-rad/src/codecs/smacker.rs | 3 ++- nihav-rad/src/demuxers/bink.rs | 6 +++--- nihav-rad/src/demuxers/smacker.rs | 3 +++ 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/nihav-rad/src/codecs/bink2.rs b/nihav-rad/src/codecs/bink2.rs index 1305878..2b6ca26 100644 --- a/nihav-rad/src/codecs/bink2.rs +++ b/nihav-rad/src/codecs/bink2.rs @@ -279,7 +279,7 @@ impl Bink2DSP { 0 => { let src = &ppix[poff..]; for (out, row) in dst.chunks_mut(stride).take(16).zip(src.chunks(pstride)) { - for i in 0..16 { out[i] = row[i]; } + out[..16].copy_from_slice(&row[..16]); } }, 1 => { @@ -338,7 +338,7 @@ impl Bink2DSP { if (mx == 0) && (my == 0) { let inpix = &ppix[poff..]; for (out, src) in dst.chunks_mut(stride).take(8).zip(inpix.chunks(pstride)) { - for i in 0..8 { out[i] = src[i]; } + out[..8].copy_from_slice(&src[..8]); } } else if my == 0 { chroma_interp!(dst, stride, 8, u8, &ppix[poff..], pstride, 1, mx, 2); @@ -1027,6 +1027,7 @@ impl Bink2Decoder { Self::default() } + #[allow(clippy::cyclomatic_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/binkaud.rs b/nihav-rad/src/codecs/binkaud.rs index aee9bbc..c94f39d 100644 --- a/nihav-rad/src/codecs/binkaud.rs +++ b/nihav-rad/src/codecs/binkaud.rs @@ -130,6 +130,7 @@ impl BinkAudioDecoder { } Ok(()) } + #[allow(clippy::transmute_ptr_to_ptr)] fn output(&mut self, dst: &mut [f32], off0: usize, off1: usize, chno: usize) { match self.transform { Transform::DCT(ref mut dct) => { diff --git a/nihav-rad/src/codecs/smacker.rs b/nihav-rad/src/codecs/smacker.rs index 8b24c6d..14e5125 100644 --- a/nihav-rad/src/codecs/smacker.rs +++ b/nihav-rad/src/codecs/smacker.rs @@ -367,7 +367,7 @@ impl SmackerVideoDecoder { let mut didx = 0; let mut sidx = 0; for _ in 0..self.h { - for x in 0..self.w { dst[didx + x] = self.frame[sidx + x]; } + dst[didx..][..self.w].copy_from_slice(&self.frame[sidx..][..self.w]); sidx += self.stride; didx += stride; if is_scaled { @@ -510,6 +510,7 @@ impl NADecoder for SmackerAudioDecoder { Err(DecoderError::InvalidData) } } + #[allow(clippy::manual_memcpy)] 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-rad/src/demuxers/bink.rs b/nihav-rad/src/demuxers/bink.rs index 35bdcbf..a5d8169 100644 --- a/nihav-rad/src/demuxers/bink.rs +++ b/nihav-rad/src/demuxers/bink.rs @@ -9,7 +9,7 @@ const BINK_AUD_FLAG_DCT: u8 = 0x10; const BINK_AUD_FLAG_STEREO: u8 = 0x20; impl AudioTrack { - fn new(strmgr: &mut StreamManager, srate: u32, flags: u8, str_id: usize, magic: &[u8; 4]) -> DemuxerResult { + fn new(strmgr: &mut StreamManager, srate: u32, flags: u8, str_id: usize, magic: [u8; 4]) -> DemuxerResult { let channels = if (flags & BINK_AUD_FLAG_STEREO) != 0 { 2 } else { 1 }; let codecname = if (flags & BINK_AUD_FLAG_DCT) != 0 { "bink-audio-dct" @@ -18,7 +18,7 @@ impl AudioTrack { }; let ahdr = NAAudioInfo::new(srate, channels, SND_F32P_FORMAT, 1); let mut edata: Vec = Vec::with_capacity(4); - edata.extend_from_slice(magic); + edata.extend_from_slice(&magic); let ainfo = NACodecInfo::new(codecname, NACodecTypeInfo::Audio(ahdr), Some(edata)); let res = strmgr.add_stream(NAStream::new(StreamType::Audio, (str_id + 1) as u32, ainfo, 1, srate)); validate!(res.is_some()); @@ -93,7 +93,7 @@ impl<'a> DemuxCore<'a> for BinkDemuxer<'a> { let srate = src.read_u24le()?; let flags = src.read_byte()?; validate!(srate > 0); - self.ainfo.push(AudioTrack::new(strmgr, srate, flags, i, &magic)?); + self.ainfo.push(AudioTrack::new(strmgr, srate, flags, i, magic)?); } for _ in 0..num_audio { let _trk_id = src.read_u32le()?; diff --git a/nihav-rad/src/demuxers/smacker.rs b/nihav-rad/src/demuxers/smacker.rs index 41cad05..accbfa5 100644 --- a/nihav-rad/src/demuxers/smacker.rs +++ b/nihav-rad/src/demuxers/smacker.rs @@ -95,6 +95,7 @@ fn get_pts_inc(val: i32) -> u64 { } impl<'a> DemuxCore<'a> for SmackerVideoDemuxer<'a> { + #[allow(clippy::unreadable_literal)] fn open(&mut self, strmgr: &mut StreamManager, _seek_idx: &mut SeekIndex) -> DemuxerResult<()> { let src = &mut self.src; let mut magic: [u8; 4] = [0; 4]; @@ -164,6 +165,8 @@ impl<'a> DemuxCore<'a> for SmackerVideoDemuxer<'a> { Ok(()) } + #[allow(clippy::identity_op)] + #[allow(clippy::unreadable_literal)] fn get_frame(&mut self, strmgr: &mut StreamManager) -> DemuxerResult { if !self.queued_packets.is_empty() { let pkt = self.queued_packets.pop().unwrap(); -- 2.39.5