From: Kostya Shishkov Date: Tue, 16 Jun 2020 10:49:20 +0000 (+0200) Subject: ms: fix or silence clippy warnings X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=4efceb69a4604c623de2ca48c841d06615558365;p=nihav.git ms: fix or silence clippy warnings --- diff --git a/nihav-ms/src/codecs/msadpcm.rs b/nihav-ms/src/codecs/msadpcm.rs index a69db74..418dc9b 100644 --- a/nihav-ms/src/codecs/msadpcm.rs +++ b/nihav-ms/src/codecs/msadpcm.rs @@ -58,6 +58,7 @@ impl MSADPCMDecoder { } impl NADecoder for MSADPCMDecoder { + #[allow(clippy::int_plus_one)] fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> { if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() { self.block_len = ainfo.get_block_len(); @@ -96,7 +97,7 @@ impl NADecoder for MSADPCMDecoder { if let NACodecTypeInfo::Audio(_) = info.get_properties() { let pktbuf = pkt.get_buffer(); let channels = self.chmap.num_channels(); - validate!(pktbuf.len() > 0 && (pktbuf.len() % self.block_len) == 0); + validate!(!pktbuf.is_empty() && (pktbuf.len() % self.block_len) == 0); let nblocks = pktbuf.len() / self.block_len; let nsamples = nblocks * self.block_samps; let abuf = alloc_audio_buffer(self.ainfo, nsamples, self.chmap.clone())?; @@ -186,7 +187,7 @@ const DEFAULT_BLOCK_LEN: usize = 256; impl MSADPCMEncoder { fn new() -> Self { Self::default() } fn encode_packet(&mut self) -> EncoderResult { - if self.samples.len() == 0 { + if self.samples.is_empty() { return Err(EncoderError::TryAgain); } let len = (self.samples.len() / self.channels).min(self.block_len); @@ -302,9 +303,9 @@ impl NAEncoder for MSADPCMEncoder { NACodecTypeInfo::None => { let mut ofmt = EncodeParameters::default(); ofmt.format = NACodecTypeInfo::Audio(NAAudioInfo::new(0, 1, SND_S16_FORMAT, DEFAULT_BLOCK_LEN)); - return Ok(ofmt); + Ok(ofmt) }, - NACodecTypeInfo::Video(_) => return Err(EncoderError::FormatError), + NACodecTypeInfo::Video(_) => Err(EncoderError::FormatError), NACodecTypeInfo::Audio(ainfo) => { let mut outinfo = ainfo; outinfo.channels = outinfo.channels.min(2); @@ -322,9 +323,9 @@ impl NAEncoder for MSADPCMEncoder { } let mut ofmt = *encinfo; ofmt.format = NACodecTypeInfo::Audio(outinfo); - return Ok(ofmt); + Ok(ofmt) } - }; + } } fn init(&mut self, stream_id: u32, encinfo: EncodeParameters) -> EncoderResult { match encinfo.format { diff --git a/nihav-ms/src/codecs/msvideo1.rs b/nihav-ms/src/codecs/msvideo1.rs index 938dc0f..34de894 100644 --- a/nihav-ms/src/codecs/msvideo1.rs +++ b/nihav-ms/src/codecs/msvideo1.rs @@ -204,6 +204,7 @@ impl NADecoder for Video1Decoder { Err(DecoderError::InvalidData) } } + #[allow(clippy::identity_op)] fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult { let src = pkt.get_buffer(); validate!(src.len() >= 2); diff --git a/nihav-ms/src/codecs/msvideo1enc.rs b/nihav-ms/src/codecs/msvideo1enc.rs index c6e4e8d..9acfb3c 100644 --- a/nihav-ms/src/codecs/msvideo1enc.rs +++ b/nihav-ms/src/codecs/msvideo1enc.rs @@ -6,7 +6,7 @@ use nihav_codec_support::vq::*; struct Pixel16(u16); impl Pixel16 { - fn unpack(&self) -> (u8, u8, u8) { + fn unpack(self) -> (u8, u8, u8) { (((self.0 >> 10) & 0x1F) as u8, ((self.0 >> 5) & 0x1F) as u8, (self.0 & 0x1F) as u8) } fn pack(r: u8, g: u8, b: u8) -> Self { @@ -409,7 +409,7 @@ impl NAEncoder for MSVideo1Encoder { ofmt.format = NACodecTypeInfo::Video(NAVideoInfo::new(0, 0, true, RGB555_FORMAT)); Ok(ofmt) }, - NACodecTypeInfo::Audio(_) => return Err(EncoderError::FormatError), + NACodecTypeInfo::Audio(_) => Err(EncoderError::FormatError), NACodecTypeInfo::Video(vinfo) => { let outinfo = NAVideoInfo::new((vinfo.width + 3) & !3, (vinfo.height + 3) & !3, true, RGB555_FORMAT); let mut ofmt = *encinfo; @@ -431,11 +431,11 @@ impl NAEncoder for MSVideo1Encoder { } let out_info = NAVideoInfo::new(vinfo.width, vinfo.height, true, RGB555_FORMAT); - let info = NACodecInfo::new("msvideo1", NACodecTypeInfo::Video(out_info.clone()), None); + let info = NACodecInfo::new("msvideo1", NACodecTypeInfo::Video(out_info), None); let mut stream = NAStream::new(StreamType::Video, stream_id, info, encinfo.tb_num, encinfo.tb_den); stream.set_num(stream_id as usize); let stream = stream.into_ref(); - if let Err(_) = self.pool.prealloc_video(out_info, 2) { + if self.pool.prealloc_video(out_info, 2).is_err() { return Err(EncoderError::AllocError); } diff --git a/nihav-ms/src/lib.rs b/nihav-ms/src/lib.rs index 99597a6..6bfdad6 100644 --- a/nihav-ms/src/lib.rs +++ b/nihav-ms/src/lib.rs @@ -1,6 +1,9 @@ extern crate nihav_core; extern crate nihav_codec_support; +#[allow(clippy::needless_range_loop)] +#[allow(clippy::single_match)] +#[allow(clippy::verbose_bit_mask)] mod codecs; pub use crate::codecs::ms_register_all_codecs; pub use crate::codecs::ms_register_all_encoders;