codec_support/h263: fix delta calculation in the deblocking filter
authorKostya Shishkov <kostya.shishkov@gmail.com>
Wed, 8 Apr 2020 10:41:14 +0000 (12:41 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Wed, 8 Apr 2020 10:41:14 +0000 (12:41 +0200)
nihav-codec-support/src/codecs/h263/code.rs

index 1f00beb77881d0b978f8413233d1c67d27efa617..05779910524202310de2906e4b42d787a41666f4 100644 (file)
@@ -360,7 +360,7 @@ fn deblock_hor(buf: &mut NAVideoBuffer<u8>, comp: usize, strength: u8, off: usiz
         let diff = ((a - d) + (c - b) * 4) / 8;
         if (diff != 0) && (diff > -24) && (diff < 24) {
             let d1a = (diff.abs() - 2 * (diff.abs() - (strength as i16)).max(0)).max(0);
-            let d1  = if d1a < 0 { 0 } else { d1a };
+            let d1  = if diff < 0 { -d1a } else { d1a };
             let hd1 = d1a / 2;
             let d2  = ((a - d) / 4).max(-hd1).min(hd1);
 
@@ -384,7 +384,7 @@ fn deblock_ver(buf: &mut NAVideoBuffer<u8>, comp: usize, strength: u8, off: usiz
         let diff = (a - d + (c - b) * 4) / 8;
         if (diff != 0) && (diff > -24) && (diff < 24) {
             let d1a = (diff.abs() - 2 * (diff.abs() - (strength as i16)).max(0)).max(0);
-            let d1  = if d1a < 0 { 0 } else { d1a };
+            let d1  = if diff < 0 { -d1a } else { d1a };
             let hd1 = d1a / 2;
             let d2  = ((a - d) / 4).max(-hd1).min(hd1);