X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-realmedia%2Fsrc%2Fcodecs%2Frv60dsp.rs;h=3a90123f44d9571a24acc747e43d530385bfdac3;hb=a15d97ad1e674adeebbc73f36aed9cf826d4af31;hp=ab9010520032dcf0c26849cb1b0569a12b0bb10b;hpb=cd830591a8770b4a56ce9b938574adcee3ed33f5;p=nihav.git diff --git a/nihav-realmedia/src/codecs/rv60dsp.rs b/nihav-realmedia/src/codecs/rv60dsp.rs index ab90105..3a90123 100644 --- a/nihav-realmedia/src/codecs/rv60dsp.rs +++ b/nihav-realmedia/src/codecs/rv60dsp.rs @@ -1,6 +1,6 @@ use nihav_core::frame::{NAVideoBuffer, NASimpleVideoFrame}; -use nihav_core::codecs::MV; -use nihav_core::codecs::blockdsp::edge_emu; +use nihav_codec_support::codecs::MV; +use nihav_codec_support::codecs::blockdsp::edge_emu; fn clip8(val: i16) -> u8 { val.min(255).max(0) as u8 } @@ -58,10 +58,11 @@ macro_rules! filter_row { }); } +#[allow(clippy::cognitive_complexity)] fn luma_mc(dst: &mut [u8], mut didx: usize, dstride: usize, src: &[u8], mut sidx: usize, sstride: usize, w: usize, h: usize, cx: usize, cy: usize) { if (cx == 0) && (cy == 0) { for _ in 0..h { - for x in 0..w { dst[didx + x] = src[sidx + x]; } + dst[didx..][..w].copy_from_slice(&src[sidx..][..w]); didx += dstride; sidx += sstride; } @@ -102,7 +103,7 @@ fn luma_mc(dst: &mut [u8], mut didx: usize, dstride: usize, src: &[u8], mut sidx fn chroma_mc(dst: &mut [u8], mut didx: usize, dstride: usize, src: &[u8], mut sidx: usize, sstride: usize, w: usize, h: usize, x: usize, y: usize) { if (x == 0) && (y == 0) { for _ in 0..h { - for x in 0..w { dst[didx + x] = src[sidx + x]; } + dst[didx..][..w].copy_from_slice(&src[sidx..][..w]); didx += dstride; sidx += sstride; } @@ -167,7 +168,7 @@ fn filter_luma_edge(dst: &mut [u8], mut offset: usize, step: usize, stride: usiz let str_q = strength!(diff_p1p0[0] + diff_p1p0[1] + diff_p1p0[2] + diff_p1p0[3], lim2); if str_p + str_q > 2 { let msum = ((mode1 + mode2 + str_q + str_p) >> 1) as i16; - let (maxprod, weak) = if (str_q == 1) || (str_p == 1) { (512, true) } else { (384, false) }; + let (maxprod, weak) = if (str_q == 1) || (str_p == 1) { (512, true) } else { (384, false) }; for y in 0..4 { let diff_p0q0 = diff!(dst, offset, offset - step); if (diff_p0q0 != 0) && (lim1 * diff_p0q0.abs() < maxprod) { @@ -491,7 +492,7 @@ impl RV60DSP { luma_mc(dst, doffset, dstride, src, soffset, sstride, w, h, cx, cy); } else { let mut ebuf: [u8; 70*70] = [0; 70*70]; - edge_emu(prev_frame, (x as isize) + (dx as isize) - 2, (y as isize) + (dy as isize) - 2, w+5, h+5, &mut ebuf, 70, 0); + edge_emu(prev_frame, (x as isize) + (dx as isize) - 2, (y as isize) + (dy as isize) - 2, w+5, h+5, &mut ebuf, 70, 0, 0); luma_mc(dst, doffset, dstride, &ebuf, 70*2 + 2, 70, w, h, cx, cy); } } @@ -519,7 +520,7 @@ impl RV60DSP { chroma_mc(frame.data, doffset, dstride, src, soffset, sstride, cw, ch, cx, cy); } else { let mut ebuf: [u8; 40*40] = [0; 40*40]; - edge_emu(prev_frame, ((x >> 1) as isize) + (dx as isize), ((y >> 1) as isize) + (dy as isize), cw+1, ch+1, &mut ebuf, 40, comp); + edge_emu(prev_frame, ((x >> 1) as isize) + (dx as isize), ((y >> 1) as isize) + (dy as isize), cw+1, ch+1, &mut ebuf, 40, comp, 0); chroma_mc(frame.data, doffset, dstride, &ebuf, 0, 40, cw, ch, cx, cy); } } @@ -542,7 +543,7 @@ impl RV60DSP { filter_luma_edge(frame.data, offset, 1, stride, mode_l, mode_r, lim1, lim2); } if ((str_l | str_r) >= 2) && deblock_chroma { - for comp in 1..2 { + for comp in 1..3 { let stride = frame.stride[comp]; let offset = frame.offset[comp] + (xpos >> 1) + (ypos >> 1) * stride; filter_chroma_edge(frame.data, offset, 1, stride, mode_l, mode_r, lim1, lim2); @@ -567,7 +568,7 @@ impl RV60DSP { filter_luma_edge(frame.data, offset, stride, 1, mode_t, mode_d, lim1, lim2); } if ((str_t | str_d) >= 2) && deblock_chroma { - for comp in 1..2 { + for comp in 1..3 { let stride = frame.stride[comp]; let offset = frame.offset[comp] + (xpos >> 1) + (ypos >> 1) * stride; filter_chroma_edge(frame.data, offset, stride, 1, mode_t, mode_d, lim1, lim2); @@ -757,9 +758,7 @@ impl IntraPredContext { let off = ((sum >> 5) + 32) as usize; let frac = (sum & 0x1F) as u16; if frac == 0 { - for x in 0..size { - dst[doff + x] = src[off + x]; - } + dst[doff..][..size].copy_from_slice(&src[off..][..size]); } else { for x in 0..size { let a = src[off + x + 0] as u16; @@ -785,6 +784,7 @@ impl IntraPredContext { sum += diff; } } + #[allow(clippy::cognitive_complexity)] pub fn pred_angle(&self, dst: &mut [u8], mut doff: usize, dstride: usize, size: usize, angle: usize, filter: bool) { let mut filtered1: [u8; 96] = [0; 96]; let mut filtered2: [u8; 96] = [0; 96]; @@ -826,10 +826,10 @@ impl IntraPredContext { let inv_angle = RV60_IPRED_INV_ANGLE[angle - 10]; let add_size = (size * (ang_weight as usize) + 31) >> 5; if size <= 16 { - for i in 0..size+1 { + for i in 0..=size { filtered1[32-1 + i] = self.l[i]; } - for i in 0..size+1 { + for i in 0..=size { filtered2[32-1 + i] = self.t[i]; } } else { @@ -852,10 +852,10 @@ impl IntraPredContext { let inv_angle = RV60_IPRED_INV_ANGLE[26 - angle]; let add_size = (size * (ang_weight as usize) + 31) >> 5; if size <= 16 { - for i in 0..size+1 { + for i in 0..=size { filtered1[32-1 + i] = self.t[i]; } - for i in 0..size+1 { + for i in 0..=size { filtered2[32-1 + i] = self.l[i]; } } else { @@ -880,9 +880,7 @@ impl IntraPredContext { Self::filter_bilin32(&mut filtered1[32..], self.t[1], self.t[33], 32); } for _ in 0..size { - for x in 0..size { - dst[doff + x] = filtered1[32 + x]; - } + dst[doff..][..size].copy_from_slice(&filtered1[32..][..size]); doff += dstride; } if filter {