[x265] [PATCH 1 of 1] primitives: xPredIntraAng function table implementation - stage 1

Steve Borho steve at borho.org
Mon Jun 24 20:30:45 CEST 2013


Always inline the patches so they can be reviewed and commented on as text.
 I'm pasting bits of it here so I can give feedback.

First, this function table does not have to be exposed in primitives.h, it
can be a private function table to intrapred.inc.  So remove all the
changes to primitives.h

+void xPredIntraAng4x4_m_32(pixel* pDst, int dstStride, int width, int
dirMode, pixel *refLeft, pixel *refAbove)

SJB:  we don't need to copy the HM's strange x prefix for function names in
our primitives..

 {

SJB:  All the code from here..

     int blkSize        = width;

@@ -1692,6 +1693,86 @@
     intraPredAngle     = signAng * absAng;

     // Do angular predictions
+    pixel* refMain;
+    pixel* refSide;
+
+    // Initialise the Main and Left reference array.
+    if (intraPredAngle < 0)
+    {
+        refMain = (modeVer ? refAbove : refLeft);     // + (blkSize - 1);
+        refSide = (modeVer ? refLeft : refAbove);     // + (blkSize - 1);
+
+        // Extend the Main reference to the left.
+        int invAngleSum    = 128;     // rounding for (shift by 8)
+        for (int k = -1; k > blkSize * intraPredAngle >> 5; k--)
+        {
+            invAngleSum += invAngle;
+            refMain[k] = refSide[invAngleSum >> 8];
+        }
+    }
+    else
+    {
+        refMain = modeVer ? refAbove : refLeft;
+        refSide = modeVer ? refLeft  : refAbove;
+    }

SJB: .. to here should be handled by the caller.  The function arguments
should only
           include what these few lines of code below need.

+    Vec8s row11, row12, row21, row22, row31, row32, row41, row42;
+    Vec16uc tmp16_1, tmp16_2;
+    Vec2uq tmp2uq;
+    Vec8s v_deltaFract, v_deltaPos(0), thirty2(32), thirty1(31),
v_ipAngle(0);
+
+    tmp16_1 = (Vec16uc)load_partial(const_int(8), refMain);    //-1,0,1,2
+    store_partial(const_int(4), pDst, tmp16_1);
+    tmp16_2 = (Vec16uc)load_partial(const_int(8), refMain - 1); //-2,-1,0,1
+    store_partial(const_int(4), pDst + dstStride, tmp16_2);
+    tmp16_2 = (Vec16uc)load_partial(const_int(8), refMain - 2);
+    store_partial(const_int(4), pDst + 2 * dstStride, tmp16_2);
+    tmp16_2 = (Vec16uc)load_partial(const_int(8), refMain - 3);
+    store_partial(const_int(4), pDst + 3 * dstStride, tmp16_2);
+    return;

SJB: .. drop this return statement

+}
+
+int get_xPredIntraAng_func(int dirMode)
+{
+    bool modeHor       = (dirMode < 18);
+    bool modeVer       = !modeHor;
+    int intraPredAngle = modeVer ? (int)dirMode - VER_IDX : modeHor ?
-((int)dirMode - HOR_IDX) : 0;
+    int func_num  = abs(intraPredAngle);
+    if(intraPredAngle < 0)
+    {
+        func_num  += 8;
+    }
+    return func_num;
+}

SJB: Why bother with this at all?  Why not just index into the table with
dirMode?

+void xPredIntraAng4x4(int /*bitDepth*/, pixel* pDst, int dstStride, int
width, int dirMode, pixel *refLeft, pixel *refAbove, bool bFilter = true)
+{
+    int blkSize        = width;
+
+    // Map the mode index to main prediction direction and angle
+    assert(dirMode > 1); //no planar and dc
+    bool modeHor       = (dirMode < 18);
+    bool modeVer       = !modeHor;
+    int intraPredAngle = modeVer ? (int)dirMode - VER_IDX : modeHor ?
-((int)dirMode - HOR_IDX) : 0;
+    int absAng         = abs(intraPredAngle);
+    int signAng        = intraPredAngle < 0 ? -1 : 1;
+
+    // Set bitshifts and scale the angle parameter to block size
+    int angTable[9]    = { 0,    2,    5,   9,  13,  17,  21,  26,  32 };
+    int invAngTable[9] = { 0, 4096, 1638, 910, 630, 482, 390, 315, 256 };
// (256 * 32) / Angle
+    int invAngle       = invAngTable[absAng];
+    absAng             = angTable[absAng];
+    intraPredAngle     = signAng * absAng;
+
+    if(dirMode==18)

SJB: mind your white-space

+    {
+        x265::EncoderPrimitives p;
+        p.xPredIntraAng4x4_table[X_PRED_INTRA_ANG_M_32] =
xPredIntraAng4x4_m_32;
+        p.xPredIntraAng4x4_table[get_xPredIntraAng_func(dirMode)](pDst,
dstStride, width, dirMode, refLeft, refAbove);
+        return;

SJB: this is all kinds of ugly.  You can't instantiate an encoder primitive
struct here.  You should define a function table as a file static and setup
that table in the setup function at the bottom of the file, and (repeating
above) the table should be indexed by dirMode and the arguments should only
be the bare minimum needed to generate the prediction.

+    }
+    // Do angular predictions



On Mon, Jun 24, 2013 at 7:11 AM, <mandar at multicorewareinc.com> wrote:

> Patch subject is complete summary.
>
>
>
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> http://mailman.videolan.org/listinfo/x265-devel
>
>


-- 
Steve Borho
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20130624/15a0c6cb/attachment.html>


More information about the x265-devel mailing list