[x265] [PATCH] SAO: modified IDBI()

Ashok Kumar Mishra ashok at multicorewareinc.com
Wed Feb 17 09:17:48 CET 2016


On Wed, Feb 17, 2016 at 9:11 AM, chen <chenm003 at 163.com> wrote:

>
> At 2016-02-16 23:11:37,ashok at multicorewareinc.com wrote:
> ># 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;
>
> origin code is more clear, the new one we will difficult to know what to get in this step.
> if you just want to share abs(), you may modify roundIBDI, of course, the generate code will slower since there no hardware ABS instruction
>
> This modified code is as clear as the previous code. Only difference is I
wrote it in 2 steps without multiplication operation. And removed the
"anonymous" namespace.
Can you explain how the generate code will become slow ? And where this
hardware ABS instruction is coming into picture ? x265_abs is a inline
template function as
x265_min and x265_max functions. x265_abs function will be replaced in
compile time as in the case of x265_min and x265_max. I couldn't understand
this hardware ABS instruction.

>
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20160217/39dc55ad/attachment.html>


More information about the x265-devel mailing list