diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2023-07-26 19:03:18 +0200 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2023-07-26 19:03:18 +0200 |
commit | e6aaad5c5273cd814b5748b7faf3751835a37217 (patch) | |
tree | 77becc9c5a0a8bd31b1eb464fbf90c4c3699a35c /nihav-commonfmt | |
parent | 625751036014b099fd9c126397bc973cb0543130 (diff) | |
download | nihav-e6aaad5c5273cd814b5748b7faf3751835a37217.tar.gz |
fix clippy warnings
Diffstat (limited to 'nihav-commonfmt')
-rw-r--r-- | nihav-commonfmt/src/codecs/clearvideo.rs | 2 | ||||
-rw-r--r-- | nihav-commonfmt/src/codecs/jpeg.rs | 4 | ||||
-rw-r--r-- | nihav-commonfmt/src/codecs/mod.rs | 1 | ||||
-rw-r--r-- | nihav-commonfmt/src/codecs/pcm.rs | 6 | ||||
-rw-r--r-- | nihav-commonfmt/src/demuxers/mov.rs | 8 | ||||
-rw-r--r-- | nihav-commonfmt/src/demuxers/y4m.rs | 6 | ||||
-rw-r--r-- | nihav-commonfmt/src/lib.rs | 3 |
7 files changed, 16 insertions, 14 deletions
diff --git a/nihav-commonfmt/src/codecs/clearvideo.rs b/nihav-commonfmt/src/codecs/clearvideo.rs index 52bfe2b..50794ab 100644 --- a/nihav-commonfmt/src/codecs/clearvideo.rs +++ b/nihav-commonfmt/src/codecs/clearvideo.rs @@ -572,7 +572,7 @@ fn decode_dct_block(br: &mut BitReader, blk: &mut [i32; 64], ac_quant: i32, has_ } else { eob = br.read_bool()?; let run = br.read(6)? as usize; - let lev = br.read_s(8)? as i32; + let lev = br.read_s(8)?; (lev, run) }; idx += skip; diff --git a/nihav-commonfmt/src/codecs/jpeg.rs b/nihav-commonfmt/src/codecs/jpeg.rs index 957104c..08f30a7 100644 --- a/nihav-commonfmt/src/codecs/jpeg.rs +++ b/nihav-commonfmt/src/codecs/jpeg.rs @@ -637,9 +637,7 @@ impl NADecoder for JPEGDecoder { std::mem::swap(&mut self.buf, &mut data); let ret = self.decode_scan(&data, buf, &ci[..ns], ss, se); std::mem::swap(&mut self.buf, &mut data); - if let Err(err) = ret { - return Err(err); - } + ret?; } else { unreachable!(); } }, JPEGType::Progressive => { diff --git a/nihav-commonfmt/src/codecs/mod.rs b/nihav-commonfmt/src/codecs/mod.rs index 4c6569e..ad8a8c6 100644 --- a/nihav-commonfmt/src/codecs/mod.rs +++ b/nihav-commonfmt/src/codecs/mod.rs @@ -30,6 +30,7 @@ mod atrac3; mod pcm; #[cfg(feature="decoder_sipro")] #[allow(clippy::collapsible_if)] +#[allow(clippy::collapsible_else_if)] #[allow(clippy::identity_op)] #[allow(clippy::manual_memcpy)] mod sipro; diff --git a/nihav-commonfmt/src/codecs/pcm.rs b/nihav-commonfmt/src/codecs/pcm.rs index b2dd817..c0ef5d3 100644 --- a/nihav-commonfmt/src/codecs/pcm.rs +++ b/nihav-commonfmt/src/codecs/pcm.rs @@ -79,12 +79,12 @@ fn get_default_chmap(nch: u8) -> NAChannelMap { #[cfg(feature="decoder_pcm")] fn get_duration(ainfo: &NAAudioInfo, duration: Option<u64>, data_size: usize) -> u64 { - if duration == None { + if let Some(dur) = duration { + dur + } else { let size_bits = (data_size as u64) * 8; let blk_size = u64::from(ainfo.get_channels()) * u64::from(ainfo.get_format().get_bits()); size_bits / blk_size - } else { - duration.unwrap() } } diff --git a/nihav-commonfmt/src/demuxers/mov.rs b/nihav-commonfmt/src/demuxers/mov.rs index 54a6c52..87eb2f1 100644 --- a/nihav-commonfmt/src/demuxers/mov.rs +++ b/nihav-commonfmt/src/demuxers/mov.rs @@ -573,6 +573,7 @@ fn parse_audio_edata(br: &mut ByteReader, start_pos: u64, size: u64) -> DemuxerR } } +#[allow(clippy::neg_cmp_op_on_partial_ord)] fn read_stsd(track: &mut Track, br: &mut ByteReader, size: u64) -> DemuxerResult<u64> { const KNOWN_STSD_SIZE: u64 = 24; validate!(size >= KNOWN_STSD_SIZE); @@ -625,12 +626,12 @@ fn read_stsd(track: &mut Track, br: &mut ByteReader, size: u64) -> DemuxerResult match depth & 0x1F { 2 => { let mut pal = [0; 1024]; - (&mut pal[..4 * 4]).copy_from_slice(&MOV_DEFAULT_PAL_2BIT); + pal[..4 * 4].copy_from_slice(&MOV_DEFAULT_PAL_2BIT); track.pal = Some(Arc::new(pal)); }, 4 => { let mut pal = [0; 1024]; - (&mut pal[..16 * 4]).copy_from_slice(&MOV_DEFAULT_PAL_4BIT); + pal[..16 * 4].copy_from_slice(&MOV_DEFAULT_PAL_4BIT); track.pal = Some(Arc::new(pal)); }, 8 => { @@ -1276,7 +1277,7 @@ impl Track { for kf_time in self.keyframes.iter() { let pts = tsearch.map_time(*kf_time - 1, &self.time_to_sample); let time = NATimeInfo::ts_to_time(pts, 1000, self.tb_num, self.tb_den); - seek_index.add_entry(self.track_no as u32, SeekEntry { time, pts: u64::from(*kf_time - 1), pos: 0 }); + seek_index.add_entry(self.track_no, SeekEntry { time, pts: u64::from(*kf_time - 1), pos: 0 }); } } fn calculate_chunk_size(&self, nsamp: usize) -> usize { @@ -1409,6 +1410,7 @@ impl Track { } } #[allow(clippy::collapsible_if)] + #[allow(clippy::collapsible_else_if)] fn seek(&mut self, pts: u64, tpoint: NATimePoint) -> DemuxerResult<u64> { self.cur_sample = pts as usize; self.samples_left = 0; diff --git a/nihav-commonfmt/src/demuxers/y4m.rs b/nihav-commonfmt/src/demuxers/y4m.rs index 89bf933..3571ea9 100644 --- a/nihav-commonfmt/src/demuxers/y4m.rs +++ b/nihav-commonfmt/src/demuxers/y4m.rs @@ -151,10 +151,8 @@ impl<'a> Y4MDemuxer<'a> { } validate!(self.width > 0 && self.height > 0); self.frame_size = 0; - for chromaton in format.comp_info.iter() { - if let Some(ref chr) = chromaton { - self.frame_size += chr.get_data_size(self.width, self.height); - } + for chr in format.comp_info.iter().flatten() { + self.frame_size += chr.get_data_size(self.width, self.height); } validate!(self.frame_size > 0); diff --git a/nihav-commonfmt/src/lib.rs b/nihav-commonfmt/src/lib.rs index 528b8b7..cdd2cd9 100644 --- a/nihav-commonfmt/src/lib.rs +++ b/nihav-commonfmt/src/lib.rs @@ -9,6 +9,9 @@ extern crate nihav_registry; #[allow(clippy::unreadable_literal)] #[allow(clippy::too_many_arguments)] #[allow(clippy::excessive_precision)] +#[allow(clippy::upper_case_acronyms)] +#[allow(clippy::manual_range_contains)] +#[allow(clippy::collapsible_else_if)] mod codecs; #[cfg(feature="decoders")] |