forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'simplify/s12' into simplify/w2

Browse files at this commit

21b7b72ef80f0e4438634fee829be97a2e5a0f75Ahmet Kaan GümüşParent: f05fdb1d0cb9ef
crates/ec-dnxhd/src/decoder.rsmodified+2 -2
@@ -575,7 +575,7 @@ pub(crate) fn to_picture(c: Canvas) -> Picture {
575575 if c.bps == 1 {
576576 out.extend(row.iter().map(|&v| u16::from(v)));
577577 } else {
578- out.extend(row.chunks_exact(2).map(|b| u16::from_le_bytes([b[0], b[1]])));
578+ out.extend(row.as_chunks::<2>().0.iter().map(|b| u16::from_le_bytes(*b)));
579579 }
580580 }
581581 out
@@ -596,7 +596,7 @@ pub(crate) fn to_video_frame(mut c: Canvas) -> Result<VideoFrame> {
596596 };
597597 if info.bit_depth == 12 {
598598 for p in &mut c.planes {
599- for b in p.chunks_exact_mut(2) {
599+ for b in p.as_chunks_mut::<2>().0 {
600600 let v = (u32::from(u16::from_le_bytes([b[0], b[1]])) + 2) >> 2;
601601 b.copy_from_slice(&(v.min(1023) as u16).to_le_bytes());
602602 }
crates/ec-dnxhd/src/idct.rsmodified+1 -1
@@ -155,7 +155,7 @@ pub(crate) fn idct_put<const BD: u32>(blk: &mut Block, dst: &mut [u8], stride: u
155155 }
156156 } else {
157157 for (row, o) in dst.chunks_mut(stride).zip(out.iter()) {
158- for (d, &v) in row[..16].chunks_exact_mut(2).zip(o) {
158+ for (d, &v) in row[..16].as_chunks_mut::<2>().0.iter_mut().zip(o) {
159159 d.copy_from_slice(&v.to_le_bytes());
160160 }
161161 }
crates/ec-dnxhd/src/lib.rsmodified+0 -1
@@ -12,7 +12,6 @@
1212 //! ec-core has no 12-bit pixel formats, so [`DnxhdDecoder::decode`] narrows
1313 //! 12-bit pictures to 10 bits (`(v + 2) >> 2`, clamped); [`DnxhdDecoder::decode_native`]
1414 //! returns the samples at their coded depth.
15-#![allow(clippy::chunks_exact_to_as_chunks, clippy::needless_range_loop)]
1615 #![forbid(unsafe_code)]
1716 mod bits;
1817 mod codec;
crates/ec-dv/src/lib.rsmodified+0 -1
@@ -14,7 +14,6 @@
1414 //! this crate as PCM, and [`DvDemuxer`] publishes it as `PcmS16Le` streams.
1515 //! * [`DvDemuxer`], [`is_dv`] -- raw `.dv` / `.dif` files.
1616 #![forbid(unsafe_code)]
17-#![allow(clippy::needless_range_loop, clippy::too_many_arguments)]
1817
1918 mod audio;
2019 mod decoder;
crates/ec-dv/src/video.rsmodified+5 -5
@@ -263,10 +263,10 @@ impl DvVideoDecoder {
263263 let mut f1 = Vec::with_capacity(4096);
264264 let mut f2 = Vec::with_capacity(4096);
265265 for c in 0..4 {
266- for s in 0..16 {
266+ for q in QSTEP {
267267 for i in 0..64 {
268- f1.push((QSTEP[s] << (c + 9)).wrapping_mul(u32::from(w1[i])));
269- f2.push((QSTEP[s] << (c + 9)).wrapping_mul(u32::from(w2[i])));
268+ f1.push((q << (c + 9)).wrapping_mul(u32::from(w1[i])));
269+ f2.push((q << (c + 9)).wrapping_mul(u32::from(w2[i])));
270270 }
271271 }
272272 }
@@ -277,11 +277,11 @@ impl DvVideoDecoder {
277277 let mut f1 = Vec::with_capacity(2816);
278278 let mut f2 = Vec::with_capacity(2816);
279279 for iw in [&IWEIGHT_88, &IWEIGHT_248] {
280- for s in 0..22 {
280+ for shifts in QUANT_SHIFTS {
281281 let mut i = 0;
282282 for c in 0..4 {
283283 while i < AREAS[c] {
284- let v = u32::from(iw[i]) << (QUANT_SHIFTS[s][c] + 1);
284+ let v = u32::from(iw[i]) << (shifts[c] + 1);
285285 f1.push(v);
286286 f2.push(v << 1);
287287 i += 1;
crates/ec-mjpeg/src/lib.rsmodified+3 -7
@@ -81,13 +81,9 @@ impl MjpegDecoder {
8181
8282 /// Decode one packet to one frame.
8383 pub fn decode(&mut self, data: &[u8], pts: Option<Timestamp>) -> Result<VideoFrame> {
84- let container_height = match &self.params.media {
85- MediaParameters::Video(v) => v.height,
86- _ => 0,
87- };
88- let container_color = match &self.params.media {
89- MediaParameters::Video(v) => v.color,
90- _ => ColorInfo::default(),
84+ let (container_height, container_color) = match &self.params.media {
85+ MediaParameters::Video(v) => (v.height, v.color),
86+ _ => (0, ColorInfo::default()),
9187 };
9288 let mut frame = decode_frame(data, container_height, self.field_order, self.limits)?;
9389 frame.pts = pts;
crates/ec-mpeg2/src/decoder.rsmodified+63 -55
@@ -14,6 +14,14 @@ use crate::idct::{idct_add, idct_add_dc, idct_put, idct_put_dc};
1414 use crate::mc::{Image, predict};
1515 use crate::tables::*;
1616
17+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
18+enum SliceError {
19+ Picture,
20+ Address,
21+ Quant,
22+ Bitstream,
23+}
24+
1725 /// Facts about a decoded picture that [`VideoFrame`] cannot carry.
1826 #[derive(Debug, Clone, PartialEq, Eq)]
1927 pub struct PictureInfo {
@@ -79,12 +87,16 @@ struct PicState {
7987 second_field: bool,
8088 }
8189
82-const MV_FRAME: u8 = 0;
83-const MV_FIELD_IN_FRAME: u8 = 1;
84-const MV_DUAL_FRAME: u8 = 2;
85-const MV_FIELD16: u8 = 3;
86-const MV_16X8: u8 = 4;
87-const MV_DUAL_FIELD: u8 = 5;
90+#[derive(Clone, Copy, Default, PartialEq, Eq)]
91+enum MotionKind {
92+ #[default]
93+ Frame,
94+ FieldInFrame,
95+ DualFrame,
96+ Field16,
97+ Mv16x8,
98+ DualField,
99+}
88100
89101 #[derive(Clone, Copy, Default)]
90102 struct Motion {
@@ -92,7 +104,7 @@ struct Motion {
92104 mv: [[[i32; 2]; 2]; 2],
93105 sel: [[u8; 2]; 2],
94106 dmv: [i32; 2],
95- kind: u8,
107+ kind: MotionKind,
96108 fwd: bool,
97109 bwd: bool,
98110 }
@@ -659,10 +671,10 @@ impl Core {
659671 }
660672
661673 #[allow(clippy::too_many_lines)]
662- fn decode_slice(&mut self, code: u8, data: &[u8]) -> std::result::Result<(), ()> {
663- let seq = self.seq.clone().ok_or(())?;
674+ fn decode_slice(&mut self, code: u8, data: &[u8]) -> std::result::Result<(), SliceError> {
675+ let seq = self.seq.clone().ok_or(SliceError::Picture)?;
664676 let t = tables();
665- let mut st = self.pic.take().ok_or(())?;
677+ let mut st = self.pic.take().ok_or(SliceError::Picture)?;
666678 let r = self.slice_inner(&seq, t, &mut st, code, data);
667679 self.pic = Some(st);
668680 r
@@ -675,7 +687,7 @@ impl Core {
675687 st: &mut PicState,
676688 code: u8,
677689 data: &[u8],
678- ) -> std::result::Result<(), ()> {
690+ ) -> std::result::Result<(), SliceError> {
679691 let hdr = st.hdr.clone();
680692 let mpeg1 = !seq.mpeg2;
681693 let mut b = Bits::new(data);
@@ -685,19 +697,19 @@ impl Core {
685697 }
686698 let mw = seq.mb_width();
687699 if mb_row >= st.rows {
688- return Err(());
700+ return Err(SliceError::Address);
689701 }
690702 let qcode = b.read(5) as usize;
691703 if qcode == 0 {
692- return Err(());
704+ return Err(SliceError::Quant);
693705 }
694706 while b.read1() {
695707 b.skip(8);
696708 }
697- let cur_idx = self.cur.as_ref().ok_or(())?.idx;
709+ let cur_idx = self.cur.as_ref().ok_or(SliceError::Picture)?.idx;
698710 // The picture must match this slice's geometry, or macroblock rows fall outside its planes.
699711 if self.pool[cur_idx].height[0] != seq.mb_height() * 16 {
700- return Err(());
712+ return Err(SliceError::Picture);
701713 }
702714 let ptype = hdr.picture_type;
703715 let field_pic = hdr.structure != Structure::Frame;
@@ -717,8 +729,7 @@ impl Core {
717729 let dc_mult = if mpeg1 { 8 } else { 8 >> hdr.intra_dc_precision };
718730 let mut dc_pred = [dc_reset; 3];
719731 let mut pmv = [[[0i32; 2]; 2]; 2]; // [r][s][t]
720- let mut motion = Motion::default();
721- motion.fwd = true;
732+ let mut motion = Motion { fwd: true, ..Motion::default() };
722733 let mut addr: isize = (mb_row * mw) as isize - 1;
723734 let mut first = true;
724735 let nblocks = if seq.chroma_format == 1 { 6 } else { 8 };
@@ -728,7 +739,7 @@ impl Core {
728739 // macroblock_address_increment
729740 let mut inc = 0usize;
730741 loop {
731- let v = b.vlc(&t.mba).ok_or(())?;
742+ let v = b.vlc(&t.mba).ok_or(SliceError::Bitstream)?;
732743 if v == 34 {
733744 inc += 33;
734745 } else if v == 35 {
@@ -738,7 +749,7 @@ impl Core {
738749 break;
739750 }
740751 if b.overrun() {
741- return Err(());
752+ return Err(SliceError::Bitstream);
742753 }
743754 }
744755 if first {
@@ -749,7 +760,7 @@ impl Core {
749760 for _ in 1..inc {
750761 addr += 1;
751762 if addr as usize >= total {
752- return Err(());
763+ return Err(SliceError::Address);
753764 }
754765 let a = addr as usize;
755766 // Skipped macroblock.
@@ -759,7 +770,7 @@ impl Core {
759770 // Same directions and vectors as the previous macroblock,
760771 // predicted frame-wise (field-wise from the same-parity
761772 // field in a field picture).
762- m.kind = if field_pic { MV_FIELD16 } else { MV_FRAME };
773+ m.kind = if field_pic { MotionKind::Field16 } else { MotionKind::Frame };
763774 for s2 in 0..2 {
764775 m.mv[s2][0] = pmv[0][s2];
765776 m.mv[s2][1] = pmv[0][s2];
@@ -770,13 +781,13 @@ impl Core {
770781 pmv = [[[0; 2]; 2]; 2];
771782 m = Motion::default();
772783 m.fwd = true;
773- m.kind = if field_pic { MV_FIELD16 } else { MV_FRAME };
784+ m.kind = if field_pic { MotionKind::Field16 } else { MotionKind::Frame };
774785 let sel = st.parity as u8;
775786 m.sel = [[sel; 2]; 2];
776787 motion = m;
777788 }
778789 if ptype == PictureType::I {
779- return Err(());
790+ return Err(SliceError::Address);
780791 }
781792 let info = MbInfo { intra: false, m, dct_field: false, cbp: 0, last: [0; 8] };
782793 self.recon_mb(seq, &hdr, st, cur_idx, a % mw, a / mw, &info, &mut blocks);
@@ -785,7 +796,7 @@ impl Core {
785796 addr += 1;
786797 }
787798 if addr < 0 || addr as usize >= total {
788- return Err(());
799+ return Err(SliceError::Bitstream);
789800 }
790801 let a = addr as usize;
791802 let mb_x = a % mw;
@@ -797,7 +808,7 @@ impl Core {
797808 PictureType::P => 1,
798809 PictureType::B => 2,
799810 };
800- let flags = b.vlc(&t.mbtype[ti]).ok_or(())? as u16;
811+ let flags = b.vlc(&t.mbtype[ti]).ok_or(SliceError::Bitstream)? as u16;
801812 let intra = flags & MB_INTRA != 0;
802813 let mut m = Motion { fwd: flags & MB_FWD != 0, bwd: flags & MB_BWD != 0, ..Motion::default() };
803814 let mut dct_field = false;
@@ -808,7 +819,7 @@ impl Core {
808819 } else {
809820 kind_code = b.read(2);
810821 if kind_code == 0 {
811- return Err(());
822+ return Err(SliceError::Bitstream);
812823 }
813824 }
814825 } else if mpeg1 {
@@ -820,25 +831,25 @@ impl Core {
820831 if flags & MB_QUANT != 0 {
821832 let qc = b.read(5) as usize;
822833 if qc == 0 {
823- return Err(());
834+ return Err(SliceError::Quant);
824835 }
825836 qscale = qscale_of(qc);
826837 }
827838 m.kind = if field_pic {
828839 match kind_code {
829- 1 => MV_FIELD16,
830- 2 => MV_16X8,
831- _ => MV_DUAL_FIELD,
840+ 1 => MotionKind::Field16,
841+ 2 => MotionKind::Mv16x8,
842+ _ => MotionKind::DualField,
832843 }
833844 } else {
834845 match kind_code {
835- 1 => MV_FIELD_IN_FRAME,
836- 2 => MV_FRAME,
837- _ => MV_DUAL_FRAME,
846+ 1 => MotionKind::FieldInFrame,
847+ 2 => MotionKind::Frame,
848+ _ => MotionKind::DualFrame,
838849 }
839850 };
840851 if intra && hdr.concealment_motion_vectors {
841- m.kind = if field_pic { MV_FIELD16 } else { MV_FRAME };
852+ m.kind = if field_pic { MotionKind::Field16 } else { MotionKind::Frame };
842853 }
843854 // Motion vectors.
844855 if m.fwd || (intra && hdr.concealment_motion_vectors) {
@@ -861,7 +872,7 @@ impl Core {
861872 // No motion compensation: zero vector.
862873 pmv = [[[0; 2]; 2]; 2];
863874 m.fwd = true;
864- m.kind = if field_pic { MV_FIELD16 } else { MV_FRAME };
875+ m.kind = if field_pic { MotionKind::Field16 } else { MotionKind::Frame };
865876 m.sel = [[st.parity as u8; 2]; 2];
866877 m.mv = [[[0; 2]; 2]; 2];
867878 }
@@ -872,7 +883,7 @@ impl Core {
872883 if intra {
873884 cbp = (1 << nblocks) - 1;
874885 } else if flags & MB_PAT != 0 {
875- cbp = b.vlc(&t.cbp).ok_or(())?;
886+ cbp = b.vlc(&t.cbp).ok_or(SliceError::Bitstream)?;
876887 if seq.chroma_format == 2 {
877888 cbp = (cbp << 2) | b.read(2);
878889 }
@@ -927,7 +938,7 @@ impl Core {
927938 for blk in blocks.iter_mut() {
928939 *blk = [0; 64];
929940 }
930- return Err(());
941+ return Err(SliceError::Bitstream);
931942 }
932943 let info = MbInfo { intra, m, dct_field, cbp, last };
933944 self.recon_mb(seq, &hdr, st, cur_idx, mb_x, mb_y, &info, &mut blocks);
@@ -939,7 +950,7 @@ impl Core {
939950 motion = Motion { fwd: true, ..Motion::default() };
940951 }
941952 if b.overrun() {
942- return Err(());
953+ return Err(SliceError::Bitstream);
943954 }
944955 if b.peek(23) == 0 {
945956 break;
@@ -999,18 +1010,17 @@ impl Core {
9991010 let mvv = |r: usize| (m.mv[s][r][0], m.mv[s][r][1]);
10001011 let ptype = hdr.picture_type;
10011012 match m.kind {
1002- MV_FRAME => {
1013+ MotionKind::Frame => {
10031014 let (x, y) = mvv(0);
10041015 push(Part { dst0: 0, step: 1, rows: 16, src: self.ref_for(ptype, s, None, st, cur), field: None, src_row: (mb_y * 16) as i32, mvx: x, mvy: y, avg: false });
10051016 }
1006- MV_FIELD_IN_FRAME => {
1007- for r in 0..2 {
1017+ MotionKind::FieldInFrame => {
1018+ for (r, &f) in m.sel[s].iter().enumerate() {
10081019 let (x, y) = mvv(r);
1009- let f = m.sel[s][r];
10101020 push(Part { dst0: r, step: 2, rows: 8, src: self.ref_for(ptype, s, Some(f), st, cur), field: Some(f), src_row: (mb_y * 8) as i32, mvx: x, mvy: y, avg: false });
10111021 }
10121022 }
1013- MV_DUAL_FRAME => {
1023+ MotionKind::DualFrame => {
10141024 let (x, y) = mvv(0);
10151025 for p in 0..2usize {
10161026 let mm = if (p == 0) == hdr.top_field_first { 1 } else { 3 };
@@ -1022,20 +1032,18 @@ impl Core {
10221032 push(Part { dst0: p, step: 2, rows: 8, src, field: Some(1 - p as u8), src_row: (mb_y * 8) as i32, mvx: ox, mvy: oy, avg: true });
10231033 }
10241034 }
1025- MV_FIELD16 => {
1035+ MotionKind::Field16 => {
10261036 let (x, y) = mvv(0);
10271037 let f = m.sel[s][0];
10281038 push(Part { dst0: 0, step: 1, rows: 16, src: self.ref_for(ptype, s, Some(f), st, cur), field: Some(f), src_row: (mb_y * 16) as i32, mvx: x, mvy: y, avg: false });
10291039 }
1030- MV_16X8 => {
1031- for r in 0..2 {
1040+ MotionKind::Mv16x8 => {
1041+ for (r, &f) in m.sel[s].iter().enumerate() {
10321042 let (x, y) = mvv(r);
1033- let f = m.sel[s][r];
10341043 push(Part { dst0: 8 * r, step: 1, rows: 8, src: self.ref_for(ptype, s, Some(f), st, cur), field: Some(f), src_row: (mb_y * 16 + 8 * r) as i32, mvx: x, mvy: y, avg: false });
10351044 }
10361045 }
1037- _ => {
1038- // MV_DUAL_FIELD
1046+ MotionKind::DualField => {
10391047 let (x, y) = mvv(0);
10401048 let p = st.parity as u8;
10411049 let e = if p == 0 { -1 } else { 1 };
@@ -1207,12 +1215,12 @@ fn read_motion(
12071215 m: &mut Motion,
12081216 pmv: &mut [[[i32; 2]; 2]; 2],
12091217 s: usize,
1210-) -> std::result::Result<(), ()> {
1218+) -> std::result::Result<(), SliceError> {
12111219 let field_pic = hdr.structure != Structure::Frame;
1212- let dual = matches!(m.kind, MV_DUAL_FRAME | MV_DUAL_FIELD);
1213- let field_fmt = field_pic || m.kind != MV_FRAME;
1220+ let dual = matches!(m.kind, MotionKind::DualFrame | MotionKind::DualField);
1221+ let field_fmt = field_pic || m.kind != MotionKind::Frame;
12141222 let frame_field = !field_pic && field_fmt;
1215- let n = if matches!(m.kind, MV_FIELD_IN_FRAME | MV_16X8) { 2 } else { 1 };
1223+ let n = if matches!(m.kind, MotionKind::FieldInFrame | MotionKind::Mv16x8) { 2 } else { 1 };
12161224 let shift = if mpeg1 && hdr.full_pel[s] { 1 } else { 0 };
12171225 for r in 0..n {
12181226 if field_fmt && !dual {
@@ -1223,7 +1231,7 @@ fn read_motion(
12231231 if tc == 1 && frame_field {
12241232 pred >>= 1;
12251233 }
1226- let v = decode_component(b, t, hdr.f_code[s][tc], pred).ok_or(())?;
1234+ let v = decode_component(b, t, hdr.f_code[s][tc], pred).ok_or(SliceError::Bitstream)?;
12271235 pmv[r][s][tc] = if tc == 1 && frame_field { v << 1 } else { v };
12281236 m.mv[s][r][tc] = v << shift;
12291237 if dual {
@@ -1236,7 +1244,7 @@ fn read_motion(
12361244 m.mv[s][1] = m.mv[s][0];
12371245 m.sel[s][1] = m.sel[s][0];
12381246 }
1239- if b.overrun() { Err(()) } else { Ok(()) }
1247+ if b.overrun() { Err(SliceError::Bitstream) } else { Ok(()) }
12401248 }
12411249
12421250 #[allow(clippy::too_many_arguments)]
crates/ec-mpeg2/src/header.rsmodified+3 -3
@@ -309,9 +309,9 @@ pub(crate) fn parse_picture_header(data: &[u8]) -> Result<PictureHeader> {
309309
310310 pub(crate) fn parse_picture_coding_extension(b: &mut Bits, h: &mut PictureHeader) -> Result<()> {
311311 let mut f_code = [[0u8; 2]; 2];
312- for s in 0..2 {
313- for t in 0..2 {
314- f_code[s][t] = b.read(4) as u8;
312+ for row in f_code.iter_mut() {
313+ for v in row.iter_mut() {
314+ *v = b.read(4) as u8;
315315 }
316316 }
317317 let dc = b.read(2) as u8;
crates/ec-mpeg2/src/lib.rsmodified+0 -1
@@ -1,4 +1,3 @@
1-#![allow(clippy::needless_range_loop, clippy::field_reassign_with_default, clippy::too_many_arguments, clippy::type_complexity)]
21 //! MPEG-1 and MPEG-2 video decoder.
32 #![forbid(unsafe_code)]
43 mod bits;
crates/ec-mpeg4/src/core.rsmodified+3 -3
@@ -364,12 +364,12 @@ impl Core {
364364 }
365365 }
366366 let wc = self.wc as isize;
367- for p in 1..3 {
367+ for ac in self.ac[1..3].iter_mut() {
368368 let start = (my - 1 + 1) * wc + (mx - 1 + 1);
369369 for k in 0..(wc + 1) {
370370 let i = (start + k) as usize;
371- if i < self.ac[p].len() {
372- self.ac[p][i] = [0; 16];
371+ if i < ac.len() {
372+ ac[i] = [0; 16];
373373 }
374374 }
375375 }
crates/ec-mpeg4/src/dsp.rsmodified+3 -0
@@ -483,6 +483,7 @@ fn hpel_mode<const W: usize, const AVG: bool>(
483483 /// the full (w+1)x(h+1). ffmpeg only has `put_no_rnd` tables for w = 16 and 8, so
484484 /// `no_rnd` is ignored (rounding variant used) for w = 4 and 2.
485485 /// Rounding: x2/y2 = (a+b+1)>>1 (no_rnd: (a+b)>>1); xy2 = (a+b+c+d+2)>>2 (no_rnd: +1).
486+#[allow(clippy::too_many_arguments)]
486487 pub fn put_hpel(
487488 dst: &mut [u8],
488489 dst_stride: usize,
@@ -513,6 +514,7 @@ pub fn put_hpel(
513514 /// is avg_pixels16). For w = 8/4/2 `no_rnd` is ignored.
514515 /// Quirk reproduced from the C: `avg_pixels2_xy2_8_c` does NOT average with dst (it just
515516 /// stores, like put) -- the hand-written 2-wide xy2 loop has `/* FIXME non put */`.
517+#[allow(clippy::too_many_arguments)]
516518 pub fn avg_hpel(
517519 dst: &mut [u8],
518520 dst_stride: usize,
@@ -799,6 +801,7 @@ pub fn avg_qpel(
799801
800802 /// gmc1_c: 8-wide, `h` rows. Reads 9 columns x (h+1) rows of `src` starting at src[0].
801803 /// dst = (A*s[0] + B*s[1] + C*s[stride] + D*s[stride+1] + rounder) >> 8 (truncated to u8).
804+#[allow(clippy::too_many_arguments)]
802805 pub fn gmc1(
803806 dst: &mut [u8],
804807 dst_stride: usize,
crates/ec-mpeg4/src/h263.rsmodified+2 -2
@@ -290,11 +290,11 @@ impl Core {
290290 } else {
291291 kind = K_8X8;
292292 w.mvt = Mvt::M8;
293- for i in 0..4 {
293+ for (i, mv) in w.mv[0].iter_mut().enumerate() {
294294 let (px, py) = self.pred_motion(i);
295295 let mx = self.decode_motion(br, px, 1)?;
296296 let my = self.decode_motion(br, py, 1)?;
297- w.mv[0][i] = [mx, my];
297+ *mv = [mx, my];
298298 let bx = 2 * self.mb_x as isize + (i & 1) as isize;
299299 let by = 2 * self.mb_y as isize + (i >> 1) as isize;
300300 let ci = self.mvi(bx, by);
crates/ec-mpeg4/src/h263data.rsmodified+2 -2
@@ -489,8 +489,8 @@ mod spec_tests {
489489 (c, n)
490490 );
491491 }
492- for slot in 21..24 {
493- assert_eq!(H263_INTER_MCBPC_BITS[slot], 0);
492+ for &bits in &H263_INTER_MCBPC_BITS[21..24] {
493+ assert_eq!(bits, 0);
494494 }
495495 }
496496
crates/ec-mpeg4/src/header.rsmodified+1 -0
@@ -700,6 +700,7 @@ pub fn parse_sprite_trajectory(
700700 let vlc = &vlcs().sprite_traj;
701701 let div500_413 = ident.divx_version == 500 && ident.divx_build == 413;
702702 let mut d = [[0i64; 2]; 4];
703+ #[allow(clippy::needless_range_loop)]
703704 for i in 0..npts {
704705 let mut x = 0;
705706 let mut y = 0;
crates/ec-mpeg4/src/lib.rsmodified+0 -5
@@ -1,8 +1,3 @@
1-#![allow(
2- clippy::needless_range_loop,
3- clippy::too_many_arguments,
4- clippy::type_complexity
5-)]
61 #![forbid(unsafe_code)]
72 //! MPEG-4 Part 2 Visual (Simple and Advanced Simple profile) and H.263 baseline decoder.
83
crates/ec-mpeg4/src/mb.rsmodified+4 -4
@@ -775,10 +775,10 @@ impl Core {
775775 w.field_select[0][0] = br.bit() as u8;
776776 w.field_select[0][1] = br.bit() as u8;
777777 let (px, py) = self.pred_motion(0);
778- for i in 0..2 {
778+ for mv in &mut w.mv[0][..2] {
779779 let mx = self.decode_motion(br, px, self.f_code)?;
780780 let my = self.decode_motion(br, py / 2, self.f_code)?;
781- w.mv[0][i] = [mx, my];
781+ *mv = [mx, my];
782782 }
783783 } else {
784784 w.mvt = Mvt::M16;
@@ -790,11 +790,11 @@ impl Core {
790790 } else {
791791 kind = K_8X8;
792792 w.mvt = Mvt::M8;
793- for i in 0..4 {
793+ for (i, mv) in w.mv[0].iter_mut().enumerate() {
794794 let (px, py) = self.pred_motion(i);
795795 let mx = self.decode_motion(br, px, self.f_code)?;
796796 let my = self.decode_motion(br, py, self.f_code)?;
797- w.mv[0][i] = [mx, my];
797+ *mv = [mx, my];
798798 let bx = 2 * self.mb_x as isize + (i & 1) as isize;
799799 let by = 2 * self.mb_y as isize + (i >> 1) as isize;
800800 let ci = self.mvi(bx, by);
crates/ec-mpeg4/src/recon.rsmodified+5 -2
@@ -25,6 +25,7 @@ struct Geo {
2525 }
2626
2727 /// A source window: either a view straight into the plane or a clamped copy.
28+#[allow(clippy::too_many_arguments)]
2829 fn window<'a>(
2930 plane: &'a [u8],
3031 stride: usize,
@@ -54,6 +55,7 @@ fn window<'a>(
5455 (&buf[..], WS)
5556 }
5657
58+#[allow(clippy::too_many_arguments)]
5759 fn put_or_avg_hpel(
5860 avg: bool,
5961 dst: &mut [u8],
@@ -72,6 +74,7 @@ fn put_or_avg_hpel(
7274 }
7375 }
7476
77+#[allow(clippy::too_many_arguments)]
7578 fn put_or_avg_qpel(
7679 avg: bool,
7780 dst: &mut [u8],
@@ -351,8 +354,8 @@ fn apply_8x8(
351354 ) {
352355 let aw = g.aw;
353356 let (mut sx, mut sy) = (0, 0);
354- for i in 0..4 {
355- let (mx, my) = (mv[i][0], mv[i][1]);
357+ for (i, m) in mv.iter().enumerate() {
358+ let (mx, my) = (m[0], m[1]);
356359 let bx = (i & 1) as i32 * 8;
357360 let by = (i >> 1) as i32 * 8;
358361 let doff = (g.mb_y as usize * 16 + by as usize) * aw + g.mb_x as usize * 16 + bx as usize;
crates/ec-prores/src/encode.rsmodified+6 -6
@@ -214,15 +214,15 @@ fn tabs() -> &'static Tabs {
214214 T.get_or_init(|| {
215215 let mut t = Tabs { run: [[(0, 0); TAB]; 16], lvl: [[(0, 0); TAB]; 10] };
216216 for (i, &cb) in RUN_CB.iter().enumerate() {
217- for v in 0..TAB {
217+ for (v, slot) in t.run[i].iter_mut().enumerate() {
218218 let (c, l) = cw_code(cb, v as u32);
219- t.run[i][v] = (c, l as u8);
219+ *slot = (c, l as u8);
220220 }
221221 }
222222 for (i, &cb) in LEVEL_CB.iter().enumerate() {
223- for v in 0..TAB {
223+ for (v, slot) in t.lvl[i].iter_mut().enumerate() {
224224 let (c, l) = cw_code(cb, v as u32);
225- t.lvl[i][v] = (c, l as u8);
225+ *slot = (c, l as u8);
226226 }
227227 }
228228 t
@@ -322,8 +322,8 @@ fn code_component<S: Sink>(s: &mut S, q: &[i16], nb: usize) {
322322 let mut prev = first;
323323 let mut prev_neg = false;
324324 let mut cbi = 5usize;
325- for b in 1..nb {
326- let cur = i32::from(q[b]);
325+ for &qb in q.iter().take(nb).skip(1) {
326+ let cur = i32::from(qb);
327327 let d = cur - prev;
328328 let neg = d < 0;
329329 let code = if d == 0 { 0 } else { 2 * d.unsigned_abs() - u32::from(neg != prev_neg) };
crates/ec-prores/src/idct.rsmodified+4 -3
@@ -28,7 +28,8 @@ pub mod reference {
2828 pub col_shift: u32,
2929 }
3030
31- const fn k(w1: i32, w2: i32, w3: i32, w4: i32, w5: i32, w6: i32, w7: i32, row_shift: u32, col_shift: u32) -> K {
31+ const fn k(w: [i32; 7], row_shift: u32, col_shift: u32) -> K {
32+ let [w1, w2, w3, w4, w5, w6, w7] = w;
3233 K {
3334 a2: [w2, w6, -w6, -w2],
3435 a4: [w4, -w4, -w4, w4],
@@ -43,8 +44,8 @@ pub mod reference {
4344 }
4445 }
4546
46- pub static K10: K = k(22725, 21407, 19265, 16384, 12873, 8867, 4520, 13 + 2, 18);
47- pub static K12: K = k(45451, 42813, 38531, 32767, 25746, 17734, 9041, 16, 17);
47+ pub static K10: K = k([22725, 21407, 19265, 16384, 12873, 8867, 4520], 13 + 2, 18);
48+ pub static K12: K = k([45451, 42813, 38531, 32767, 25746, 17734, 9041], 16, 17);
4849
4950 #[inline(always)]
5051 fn row_pass(k: &K, row: &mut [i16; 8]) {
crates/ec-prores/src/lib.rsmodified+0 -1
@@ -1,4 +1,3 @@
1-#![allow(clippy::needless_range_loop, clippy::too_many_arguments)]
21 //! Apple ProRes video decoder (SMPTE RDD 36).
32 //!
43 //! Profiles 422 Proxy / LT / Standard / HQ (`apco`, `apcs`, `apcn`, `apch`) decode to
crates/ec-prores/src/slice.rsmodified+2 -2
@@ -105,10 +105,10 @@ fn luts() -> &'static Luts {
105105 L.get_or_init(|| {
106106 let mut l = Box::new(Luts { run: [0; 16 * 256], level: [0; 10 * 256], dc: [[0; 256]; 7] });
107107 for ctx in 0..7 {
108- for i in 0..256usize {
108+ for (i, slot) in l.dc[ctx].iter_mut().enumerate() {
109109 let (v, n) = Br::decode_w(DC_CB[ctx], (i as u64) << 56);
110110 if n <= 8 && v < 4096 {
111- l.dc[ctx][i] = (v as u16) << 4 | n as u16;
111+ *slot = (v as u16) << 4 | n as u16;
112112 }
113113 }
114114 }