X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-realmedia%2Fsrc%2Fcodecs%2Frv60dsp.rs;h=be88a3e1b9fbfcf6d67f4f23783c500612b06957;hb=2eefcf7983adde9c24942ae6fe9a2ed2164bbca3;hp=e03736603d7e633f2ffbce6331bf6c6f99bf1ba8;hpb=86081fed61d59fb1ea35ac34628450c9b0c00702;p=nihav.git diff --git a/nihav-realmedia/src/codecs/rv60dsp.rs b/nihav-realmedia/src/codecs/rv60dsp.rs index e037366..be88a3e 100644 --- a/nihav-realmedia/src/codecs/rv60dsp.rs +++ b/nihav-realmedia/src/codecs/rv60dsp.rs @@ -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,17 +103,19 @@ 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; } return; } if (x > 0) && (y > 0) { - let a = ((4 - x) * (4 - y)) as u16; - let b = (( x) * (4 - y)) as u16; - let c = ((4 - x) * ( y)) as u16; - let d = (( x) * ( y)) as u16; + // 3,3 case is the same as 3,2 for some reason + let ymod = if (x == 3) && (y == 3) { 2 } else { y }; + let a = ((4 - x) * (4 - ymod)) as u16; + let b = (( x) * (4 - ymod)) as u16; + let c = ((4 - x) * ( ymod)) as u16; + let d = (( x) * ( ymod)) as u16; for _ in 0..h { for x in 0..w { dst[didx + x] = ((a * (src[sidx + x] as u16) @@ -491,7 +494,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, 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, 4); luma_mc(dst, doffset, dstride, &ebuf, 70*2 + 2, 70, w, h, cx, cy); } } @@ -519,7 +522,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, 0); + 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, 3); chroma_mc(frame.data, doffset, dstride, &ebuf, 0, 40, cw, ch, cx, cy); } } @@ -542,7 +545,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 +570,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 +760,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 +786,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]; @@ -880,9 +882,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 {