[x265] [PATCH] loopfilter: use x265_clip for common clipping operations

nabajit at multicorewareinc.com nabajit at multicorewareinc.com
Wed Jan 7 13:33:50 CET 2015


# HG changeset patch
# User Nabajit Deka
# Date 1420633919 -19800
#      Wed Jan 07 18:01:59 2015 +0530
# Node ID ffbe1a8ec09f25208ae6e0506b04589f2299bc73
# Parent  ff32d97fe59ce9d8dc04d785c605f44d18dcdcee
loopfilter: use x265_clip for common clipping operations

diff -r ff32d97fe59c -r ffbe1a8ec09f source/common/loopfilter.cpp
--- a/source/common/loopfilter.cpp	Wed Jan 07 14:27:33 2015 +0530
+++ b/source/common/loopfilter.cpp	Wed Jan 07 18:01:59 2015 +0530
@@ -51,9 +51,7 @@
         signRight = ((rec[x] - rec[x + 1]) < 0) ? -1 : ((rec[x] - rec[x + 1]) > 0) ? 1 : 0;
         edgeType = signRight + signLeft + 2;
         signLeft  = -signRight;
-
-        short v = rec[x] + offsetEo[edgeType];
-        rec[x] = (pixel)(v < 0 ? 0 : (v > (PIXEL_MAX)) ? (PIXEL_MAX) : v);
+        rec[x] = x265_clip(rec[x] + offsetEo[edgeType]);
     }
 }
 
@@ -68,9 +66,7 @@
         signDown = signOf(rec[x] - rec[x + stride]);
         edgeType = signDown + upBuff1[x] + 2;
         upBuff1[x] = -signDown;
-
-        short v = rec[x] + offsetEo[edgeType];
-        rec[x] = (pixel)(v < 0 ? 0 : (v > (PIXEL_MAX)) ? (PIXEL_MAX) : v);
+        rec[x] = x265_clip(rec[x] + offsetEo[edgeType]);
     }
 }
 
@@ -82,8 +78,7 @@
         int8_t signDown = signOf(rec[x] - rec[x + stride + 1]);
         int edgeType = signDown + buff1[x] + 2;
         bufft[x + 1] = -signDown;
-        short v = rec[x] + offsetEo[edgeType];
-        rec[x] = (pixel)(v < 0 ? 0 : (v > (PIXEL_MAX)) ? (PIXEL_MAX) : v);
+        rec[x] = x265_clip(rec[x] + offsetEo[edgeType]);;
     }
 }
 
@@ -97,9 +92,7 @@
         signDown = signOf(rec[x] - rec[x + stride]);
         edgeType = signDown + upBuff1[x] + 2;
         upBuff1[x - 1] = -signDown;
-
-        short v = rec[x] + offsetEo[edgeType];
-        rec[x] = (pixel)(v < 0 ? 0 : (v > (PIXEL_MAX)) ? (PIXEL_MAX) : v);
+        rec[x] = x265_clip(rec[x] + offsetEo[edgeType]);
     }
 }
 
@@ -112,12 +105,7 @@
     {
         for (x = 0; x < ctuWidth; x++)
         {
-            int val = rec[x] + offset[rec[x] >> boShift];
-            if (val < 0)
-               val = 0;
-            else if (val > ((1 << X265_DEPTH) - 1))
-                 val = ((1 << X265_DEPTH) - 1);
-            rec[x] = (pixel)val;
+            rec[x] = x265_clip(rec[x] + offset[rec[x] >> boShift]);
         }
         rec += stride;
     }


More information about the x265-devel mailing list