[x265] [PATCH] SAO: modified IDBI()
ashok at multicorewareinc.com
ashok at multicorewareinc.com
Tue Feb 16 16:11:37 CET 2016
# HG changeset patch
# User Ashok Kumar Mishra<ashok at multicorewareinc.com>
# Date 1455633570 -19800
# Tue Feb 16 20:09:30 2016 +0530
# Node ID 33b02e2af5a4b38cd54d3f94f163aae640855dbf
# Parent 5f1817e5ff55689c45b12e1982a4c4fc46201382
SAO: modified IDBI()
diff -r 5f1817e5ff55 -r 33b02e2af5a4 source/common/common.h
--- a/source/common/common.h Tue Feb 16 20:08:54 2016 +0530
+++ b/source/common/common.h Tue Feb 16 20:09:30 2016 +0530
@@ -168,6 +168,9 @@
template<typename T>
inline T x265_clip3(T minVal, T maxVal, T a) { return x265_min(x265_max(minVal, a), maxVal); }
+template<typename T>
+inline T x265_abs(T a) { return (a < 0) ? -a : a;}
+
template<typename T> /* clip to pixel range, 0..255 or 0..1023 */
inline pixel x265_clip(T x) { return (pixel)x265_min<T>(T((1 << X265_DEPTH) - 1), x265_max<T>(T(0), x)); }
diff -r 5f1817e5ff55 -r 33b02e2af5a4 source/encoder/sao.cpp
--- a/source/encoder/sao.cpp Tue Feb 16 20:08:54 2016 +0530
+++ b/source/encoder/sao.cpp Tue Feb 16 20:09:30 2016 +0530
@@ -33,16 +33,6 @@
#define signOf(X) (((X) >> 31) | (((uint32_t)-(X)) >> 31))
#define signOf2(A, B) (((A) < (B)) ? -1 : ((A) > (B)) ? 1 : 0)
-namespace {
-
-inline int32_t roundIBDI(int32_t num, int32_t den)
-{
- return num >= 0 ? ((num * 2 + den) / (den * 2)) : -((-num * 2 + den) / (den * 2));
-}
-
-} // end anonymous namespace
-
-
namespace X265_NS {
const uint32_t SAO::s_eoTable[NUM_EDGETYPE] =
@@ -1366,8 +1356,10 @@
if (count)
{
- offsetOut = roundIBDI(offsetOrg, count << SAO_BIT_INC);
- offsetOut = x265_clip3(-OFFSET_THRESH + 1, OFFSET_THRESH - 1, offsetOut);
+ int absOffset = (x265_abs(offsetOrg) + ((count << SAO_BIT_INC) >> 1)) / count;
+ offsetOut = x265_min(OFFSET_THRESH - 1, absOffset);
+ offsetOut = offsetOrg < 0 ? -offsetOut : offsetOut;
+
if (classIdx < 3)
offsetOut = X265_MAX(offsetOut, 0);
@@ -1389,8 +1381,9 @@
if (count)
{
- offsetOut = roundIBDI(offsetOrg, count << SAO_BIT_INC);
- offsetOut = x265_clip3(-OFFSET_THRESH + 1, OFFSET_THRESH - 1, offsetOut);
+ int absOffset = (x265_abs(offsetOrg) + ((count << SAO_BIT_INC) >> 1)) / count;
+ offsetOut = x265_min(OFFSET_THRESH - 1, absOffset);
+ offsetOut = offsetOrg < 0 ? -offsetOut : offsetOut;
}
}
}
More information about the x265-devel
mailing list