X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-realmedia%2Fsrc%2Fcodecs%2Frv60dsp.rs;h=8a030e962bd32d1ba4e9fbf5fddede0e1e19092d;hb=0091a5084a0eb195f5f3a7d6924d8885f1c769d3;hp=829d32591ef0a03dc3d9b17c141640899c879826;hpb=70d30944dffff71a2b6fed6f8143c4ef2aecea3c;p=nihav.git diff --git a/nihav-realmedia/src/codecs/rv60dsp.rs b/nihav-realmedia/src/codecs/rv60dsp.rs index 829d325..8a030e9 100644 --- a/nihav-realmedia/src/codecs/rv60dsp.rs +++ b/nihav-realmedia/src/codecs/rv60dsp.rs @@ -110,10 +110,12 @@ fn chroma_mc(dst: &mut [u8], mut didx: usize, dstride: usize, src: &[u8], mut si 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) @@ -152,7 +154,7 @@ macro_rules! diff{ ) } macro_rules! strength{ - ($el: expr, $lim: expr) => (if $el < $lim { 3 } else { 1 }) + ($el: expr, $lim: expr) => (if $el.abs() < $lim { 3 } else { 1 }) } fn clip_symm(val: i16, lim: i16) -> i16 { val.max(-lim).min(lim) } @@ -182,7 +184,7 @@ fn filter_luma_edge(dst: &mut [u8], mut offset: usize, step: usize, stride: usiz }; dst[offset - step] = clip8((dst[offset - step] as i16) + delta); dst[offset] = clip8((dst[offset] as i16) - delta); - if (str_q != 1) && (diff_q1q2.abs() <= (lim1 >> 2)) { + if (str_q != 1) && (diff_q1q2.abs() <= (lim2 >> 2)) { let diff = (diff_q1q0[y] + diff_q1q2 - delta) >> 1; let delta_q1 = if weak { clip_symm(diff, (mode1 >> 1) as i16) @@ -191,7 +193,7 @@ fn filter_luma_edge(dst: &mut [u8], mut offset: usize, step: usize, stride: usiz }; dst[offset - 2 * step] = clip8((dst[offset - 2 * step] as i16) - delta_q1); } - if (str_p != 1) && (diff_p1p2.abs() <= (lim1 >> 2)) { + if (str_p != 1) && (diff_p1p2.abs() <= (lim2 >> 2)) { let diff = (diff_p1p0[y] + diff_p1p2 + delta) >> 1; let delta_p1 = if weak { clip_symm(diff, (mode2 >> 1) as i16) @@ -409,7 +411,7 @@ impl RV60DSP { blk[off + 0 * step] = ((tm0 + tt0 + 64) >> 7) as i16; blk[off + 1 * step] = ((tm4 + tt1 + 64) >> 7) as i16; blk[off + 2 * step] = ((tm6 + tt2 + 64) >> 7) as i16; - blk[off + 3 * step] = ((tm4 + tt3 + 64) >> 7) as i16; + blk[off + 3 * step] = ((tm2 + tt3 + 64) >> 7) as i16; blk[off + 4 * step] = ((tm3 + tt4 + 64) >> 7) as i16; blk[off + 5 * step] = ((tm7 + tt5 + 64) >> 7) as i16; blk[off + 6 * step] = ((tm5 + tt6 + 64) >> 7) as i16; @@ -579,46 +581,46 @@ impl RV60DSP { xpos: usize, ypos: usize, top_str: &[u8], left_str: &[u8], dblkpos: usize) { if xpos > 0 { if ypos > 0 { - let str_l = left_str[dblkpos - dparams.dblkstride]; - let str_r = left_str[dblkpos]; - if (str_l | str_r) != 0 { + let str_l = left_str[dblkpos - dparams.dblkstride - 1]; + let str_r = left_str[dblkpos - dparams.dblkstride]; + if ((str_l | str_r) & 3) != 0 { self.deblock_edge4_ver(frame, xpos, ypos - 4, str_l, str_r, dparams.deblock_chroma); } } { - let str_l = left_str[dblkpos]; - let str_r = left_str[dblkpos + dparams.dblkstride]; - if (str_l | str_r) != 0 { + let str_l = left_str[dblkpos - 1]; + let str_r = left_str[dblkpos]; + if ((str_l | str_r) & 3) != 0 { self.deblock_edge4_ver(frame, xpos, ypos + 0, str_l, str_r, dparams.deblock_chroma); } } - if ypos + 4 >= dparams.height { - let str_l = left_str[dblkpos + dparams.dblkstride]; - let str_r = left_str[dblkpos + dparams.dblkstride * 2]; - if (str_l | str_r) != 0 { + if ypos + 8 >= dparams.height { + let str_l = left_str[dblkpos + dparams.dblkstride - 1]; + let str_r = left_str[dblkpos + dparams.dblkstride]; + if ((str_l | str_r) & 3) != 0 { self.deblock_edge4_ver(frame, xpos, ypos + 4, str_l, str_r, dparams.deblock_chroma); } } } if ypos > 0 { if xpos > 0 { - let str_t = top_str[dblkpos - 1]; - let str_d = top_str[dblkpos]; - if (str_t | str_d) != 0 { + let str_t = top_str[dblkpos - dparams.dblkstride - 1]; + let str_d = top_str[dblkpos - 1]; + if ((str_t | str_d) & 3) != 0 { self.deblock_edge4_hor(frame, xpos - 4, ypos, str_t, str_d, dparams.deblock_chroma); } } { - let str_t = top_str[dblkpos]; - let str_d = top_str[dblkpos + 1]; - if (str_t | str_d) != 0 { + let str_t = top_str[dblkpos - dparams.dblkstride]; + let str_d = top_str[dblkpos]; + if ((str_t | str_d) & 3) != 0 { self.deblock_edge4_hor(frame, xpos + 0, ypos, str_t, str_d, dparams.deblock_chroma); } } - if xpos + 4 >= dparams.width { - let str_t = top_str[dblkpos + 1]; - let str_d = top_str[dblkpos + 2]; - if (str_t | str_d) != 0 { + if xpos + 8 >= dparams.width { + let str_t = top_str[dblkpos - dparams.dblkstride + 1]; + let str_d = top_str[dblkpos + 1]; + if ((str_t | str_d) & 3) != 0 { self.deblock_edge4_hor(frame, xpos + 4, ypos, str_t, str_d, dparams.deblock_chroma); } }