]> git.nihav.org Git - nihav.git/commitdiff
janitorial: fix some clippy warnings master
authorKostya Shishkov <kostya.shishkov@gmail.com>
Wed, 11 Nov 2026 20:41:05 +0000 (21:41 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Wed, 11 Nov 2026 20:41:05 +0000 (21:41 +0100)
nihav-commonfmt/src/muxers/mov/videotrack.rs
nihav-game/src/codecs/vmd.rs
nihav-game/src/codecs/vx.rs
nihav-indeo/src/codecs/indeo3enc/cell.rs
nihav-indeo/src/codecs/indeo3enc/mv.rs
nihav-indeo/src/codecs/indeo3enc/tree.rs
nihav-itu/src/codecs/h264/baseline/decoder_mt.rs
nihav-itu/src/codecs/h264/baseline/decoder_st.rs
nihav-itu/src/codecs/h264/high/decoder_mt.rs
nihav-itu/src/codecs/h264/high/decoder_st.rs
nihav-llaudio/src/codecs/tta.rs

index ded141585c92a77788fa62765faeec7a41579bef..3710e58e9e7001e9fa636141dfc747bc69ce00aa 100644 (file)
@@ -24,7 +24,7 @@ impl VideoTrackHandler {
                 "pal8" | "rgb24" | "rgb555be" => {},
                 other => {
                     println!("Raw format {other} is not supported!");
-                    return Err(MuxerError::UnsupportedFormat)?;
+                    return Err(MuxerError::UnsupportedFormat);
                 }
             }
         }
index fd0de8f266ae729c8dc589ecf854024d609b4ac5..75a1aae08bb4f3d31b0184142745b4acc9b9b0e0 100644 (file)
@@ -271,7 +271,7 @@ impl NADecoder for VMDVideoDecoder {
                     }
                     (self.width / 2, RGB555_FORMAT)
                 };
-            self.framebuf = vec!(0; self.width * self.height);
+            self.framebuf = vec![0; self.width * self.height];
 
             let myinfo = NACodecTypeInfo::Video(NAVideoInfo::new(disp_width, self.height, false, fmt));
             self.info = NACodecInfo::new_ref(info.get_name(), myinfo, info.get_extradata()).into_ref();
index ae85702a08d4c0e1f0e737074f52aa9c6f939717..2a078fed21bdd6e57fb3735a56082dc20aaa10b9 100644 (file)
@@ -85,7 +85,7 @@ macro_rules! mc {
         let mut doff = $xpos + $ypos * 256;
         for _y in 0..$h {
             for x in 0..$w {
-                $bufs[$dst_id][doff + x] = (i32::from($bufs[$src_id][soff + x]) + $ydelta).max(0).min(255) as u8;
+                $bufs[$dst_id][doff + x] = (i32::from($bufs[$src_id][soff + x]) + $ydelta).clamp(0, 255) as u8;
             }
             soff += 256;
             doff += 256;
@@ -94,8 +94,8 @@ macro_rules! mc {
         let mut doff = CHROMA_OFF + $xpos / 2 + $ypos / 2 * 256;
         for _y in 0..$h / 2 {
             for x in 0..$w / 2 {
-                $bufs[$dst_id][doff + x] = (i32::from($bufs[$src_id][soff + x]) + $udelta).max(0).min(255) as u8;
-                $bufs[$dst_id][doff + x + 128] = (i32::from($bufs[$src_id][soff + x + 128]) + $vdelta).max(0).min(255) as u8;
+                $bufs[$dst_id][doff + x] = (i32::from($bufs[$src_id][soff + x]) + $udelta).clamp(0, 255) as u8;
+                $bufs[$dst_id][doff + x + 128] = (i32::from($bufs[$src_id][soff + x + 128]) + $vdelta).clamp(0, 255) as u8;
             }
             soff += 256;
             doff += 256;
@@ -492,7 +492,7 @@ fn idct_add(qmat: &[i32; 8], blk: &mut [i32; 16], dst: &mut [u8]) {
     for (dline, row) in dst.chunks_mut(256).zip(blk.chunks_mut(4)) {
         transform!(row[0], row[1], row[2], row[3], 1, 1);
         for (out, coef) in dline.iter_mut().zip(row.iter_mut()) {
-            *out = (i32::from(*out) + ((*coef + 0x20) >> 6)).max(0).min(255) as u8;
+            *out = (i32::from(*out) + ((*coef + 0x20) >> 6)).clamp(0, 255) as u8;
         }
     }
 }
@@ -555,12 +555,10 @@ fn decode_coeffs(br: &mut BitReader, codebooks: &Codebooks, qmat: &[i32; 8], ctx
         if num_zero > 0 && coef_left > 0 {
             let run = if num_zero < 7 {
                     br.read_cb(&codebooks.zero_run_cb[num_zero as usize - 1])?
+                } else if br.peek(3) != 0 {
+                    7 - (br.read(3)? as u8)
                 } else {
-                    if br.peek(3) != 0 {
-                        7 - (br.read(3)? as u8)
-                    } else {
-                        (br.read_unary()? as u8) + 4
-                    }
+                    (br.read_unary()? as u8) + 4
                 };
             validate!(run <= num_zero);
             idx      -= run;
@@ -827,7 +825,7 @@ impl VXVideoDecoder {
                 self.decode_block(br, xpos, ypos + hh, w, hh)?;
             },
             3 => { self.do_mc_bias(br, xpos, ypos, w, h)?; },
-            4 | 5 | 6 => {
+            4..=6 => {
                 let ref_id = (mode - 4) as usize;
                 self.do_mc(br, xpos, ypos, w, h, ref_id)?;
             },
@@ -864,7 +862,7 @@ impl VXVideoDecoder {
                     self.intra_pred4x4(br, xpos, ypos, w, h)?;
                 }
             },
-            16 | 17 | 18 => {
+            16..=18 => {
                 let ref_id = (mode - 16) as usize;
                 self.do_mc(br, xpos, ypos, w, h, ref_id)?;
                 self.decode_residue(br, xpos, ypos, w, h)?;
@@ -913,7 +911,7 @@ impl NADecoder for VXVideoDecoder {
             self.info = NACodecInfo::new_ref(info.get_name(), myinfo, info.get_extradata()).into_ref();
 
             if let Some(edata) = info.get_extradata() {
-                validate!(edata.len() > 0);
+                validate!(!edata.is_empty());
                 let fps = edata[0] as usize;
                 validate!(fps <= 60);
                 let base = &QUANTISERS[(fps % 6) * 8..][..8];
index 4372dcf0080f941361fb2f7292bf6c046b257f61..93e6288961cf0417cc856c0254cc04166328a215 100644 (file)
@@ -397,7 +397,7 @@ impl CellEncoder {
 
         let mut cell4 = [0; 20];
         match mode {
-            0 | 1 | 2 => {
+            0..=2 => {
                 for y in (0..self.cell.get_height()).step_by(4) {
                     for x in (0..self.cell.get_width()).step_by(4) {
                         Self::get_cell4(&self.buf, x, y, stride, &mut cell4);
@@ -489,7 +489,7 @@ impl CellEncoder {
         let mut ccell4 = [0; 20];
         let mut pcell4 = [0; 20];
         match mode {
-            0 | 1 | 2 => {
+            0..=2 => {
                 for y in (0..self.cell.get_height()).step_by(4) {
                     for x in (0..self.cell.get_width()).step_by(4) {
                         Self::get_cell4(&self.buf,  x, y, stride, &mut ccell4);
index d234e94f4aa41790c13dde2e0c45ddd38b95587d..c6994df7f82c7efac9275189c5594571aded5c8a 100644 (file)
@@ -119,7 +119,7 @@ fn calc_mv_score(cur: &Plane, prev: &Plane, cell: Indeo3Cell, mv: MV) -> u32 {
 }
 
 pub fn compact_mvs(mvs: &mut Vec<(MV, u16)>) {
-    mvs.sort_by(|a, b| b.1.cmp(&a.1));
+    mvs.sort_by_key(|a| std::cmp::Reverse(a.1));
     mvs.truncate(256);
 }
 
index b359c6557f9e0cbca551539e0a4adc3b68b62d12..a4e5ef0618d23ee8ec8fd38276ce5fa0d0936a5d 100644 (file)
@@ -368,7 +368,7 @@ impl Plane {
             Indeo3PrimaryTree::RelFill(ref mv, ref _sec) => {
                 if find_mv(*mv, &self.mvs).is_none() {
                     let sec = self.split_sec(cell);
-                    *tree = Box::new(Indeo3PrimaryTree::AbsFill(sec));
+                    **tree = Indeo3PrimaryTree::AbsFill(sec);
                 }
             },
         }
index be5f37e8c96e0ba1d1ca3e78ca8e7960ac717d31..275e37156d9cabfa0cc72988bc1f96daa294b95b 100644 (file)
@@ -874,10 +874,8 @@ impl NADecoderMT for H264MTDecoder {
                     FrameSkipMode::IntraOnly => {
                         skip_decoding = pic_type != FrameType::I;
                     },
-                    FrameSkipMode::KeyframesOnly => {
-                        if !is_ref {
-                            skip_decoding = true;
-                        }
+                    FrameSkipMode::KeyframesOnly if !is_ref => {
+                        skip_decoding = true;
                     },
                     _ => {},
                 };
index cf48f61d2b5a6aa71b114cf0db1d47a06dcc0b9d..7ef007b77409945a6a4f2a9569bdac155e2ff324 100644 (file)
@@ -853,10 +853,8 @@ impl NADecoder for H264Decoder {
                     FrameSkipMode::IntraOnly => {
                         skip_decoding = pic_type != FrameType::I;
                     },
-                    FrameSkipMode::KeyframesOnly => {
-                        if !is_ref {
-                            skip_decoding = true;
-                        }
+                    FrameSkipMode::KeyframesOnly if !is_ref => {
+                        skip_decoding = true;
                     },
                     _ => {},
                 };
index b88e378d6d93b34179663983012ddfd7c7ab80b4..1389cb8bbd44bc0c8d4359e3dbac78bd38b6f1d5 100644 (file)
@@ -892,10 +892,8 @@ impl NADecoderMT for H264MTDecoder {
                     FrameSkipMode::IntraOnly => {
                         skip_decoding = pic_type != FrameType::I;
                     },
-                    FrameSkipMode::KeyframesOnly => {
-                        if !is_ref {
-                            skip_decoding = true;
-                        }
+                    FrameSkipMode::KeyframesOnly if !is_ref => {
+                        skip_decoding = true;
                     },
                     _ => {},
                 };
index 37ac3951c560530f390b222b52393e5ee37f50e7..27b09cba277a9ce81a86dab6542654a2a36bd42e 100644 (file)
@@ -870,10 +870,8 @@ impl NADecoder for H264Decoder {
                     FrameSkipMode::IntraOnly => {
                         skip_decoding = pic_type != FrameType::I;
                     },
-                    FrameSkipMode::KeyframesOnly => {
-                        if !is_ref {
-                            skip_decoding = true;
-                        }
+                    FrameSkipMode::KeyframesOnly if !is_ref => {
+                        skip_decoding = true;
                     },
                     _ => {},
                 };
index 9508a0fe7928fffbd90e7810908e82ae0985d3a9..759bb02346e79fc0fadecd797742f2aac1de033e 100644 (file)
@@ -281,7 +281,7 @@ impl NADecoder for TTADecoder {
                         _ => return Err(DecoderError::NotImplemented),
                     };
                 self.ainfo.block_len = self.framelen as usize;
-                self.bpp = (ainfo.format.bits / 8) as u8;
+                self.bpp = ainfo.format.bits / 8;
                 self.ch_dec = Vec::with_capacity(usize::from(ainfo.channels));
                 for _ in 0..ainfo.channels {
                     self.ch_dec.push(ChannelDecoder::new());