[x265] [PATCH] added ang_intra_pred_c C primitive, modified aregument list

praveen at multicorewareinc.com praveen at multicorewareinc.com
Tue Nov 26 09:10:07 CET 2013


# HG changeset patch
# User Praveen Tiwari
# Date 1385453396 -19800
# Node ID c34a7f9b58bd59b5a6530c170dfbaeece5dea24c
# Parent  fdaa754dfbd4fd1cd1ffc05fd34c7fe11a20fd72
added ang_intra_pred_c C primitive, modified aregument list

diff -r fdaa754dfbd4 -r c34a7f9b58bd source/common/intrapred.cpp
--- a/source/common/intrapred.cpp	Mon Nov 25 18:12:07 2013 -0600
+++ b/source/common/intrapred.cpp	Tue Nov 26 13:39:56 2013 +0530
@@ -285,6 +285,147 @@
         }
     }
 }
+
+template<int size>
+void all_angs_intra_pred_c(pixel *dest, pixel *above0, pixel *left0, pixel *above1, pixel *left1, bool bLuma)
+{
+    for (int mode = 2; mode <= 34; mode++)
+    {
+        pixel *left = (IntraFilterType[(int)g_convertToBit[size]][mode] ? left1 : left0);
+        pixel *above = (IntraFilterType[(int)g_convertToBit[size]][mode] ? above1 : above0);
+        pixel *out = dest + (mode - 2) * (size * size);
+
+        ang_pred_c(out, left, above)<size, size, mode, bLuma>;
+
+        // Optimize code don't flip buffer
+        bool modeHor = (mode < 18);
+
+        // transpose the block if this is a horizontal mode
+        if (modeHor)
+        {
+            for (int k = 0; k < size - 1; k++)
+            {
+                for (int l = k + 1; l < size; l++)
+                {
+                    pixel tmp         = out[k * size + l];
+                    out[k * size + l] = out[l * size + k];
+                    out[l * size + k] = tmp;
+                }
+            }
+        }
+    }
+}
+
+template<int dstStride, int width, int dirMode, bool bFilter>
+void ang_intra_pred_c(pixel* dst, pixel *refLeft, pixel *refAbove)
+{
+    // Map the mode index to main prediction direction and angle
+    int k, l;
+    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;
+
+    // Do angular predictions
+    {
+        pixel* refMain;
+        pixel* refSide;
+
+        // Initialise the Main and Left reference array.
+        if (intraPredAngle < 0)
+        {
+            refMain = (modeVer ? refAbove : refLeft); // + (width - 1);
+            refSide = (modeVer ? refLeft : refAbove); // + (width - 1);
+
+            // Extend the Main reference to the left.
+            int invAngleSum    = 128; // rounding for (shift by 8)
+            for (k = -1; k > width * intraPredAngle >> 5; k--)
+            {
+                invAngleSum += invAngle;
+                refMain[k] = refSide[invAngleSum >> 8];
+            }
+        }
+        else
+        {
+            refMain = modeVer ? refAbove : refLeft;
+            refSide = modeVer ? refLeft  : refAbove;
+        }
+
+        if (intraPredAngle == 0)
+        {
+            for (k = 0; k < width; k++)
+            {
+                for (l = 0; l < width; l++)
+                {
+                    dst[k * dstStride + l] = refMain[l + 1];
+                }
+            }
+
+            if (bFilter)
+            {
+                for (k = 0; k < width; k++)
+                {
+                    dst[k * dstStride] = (pixel)Clip3((int16_t)0, (int16_t)((1 << X265_DEPTH) - 1), static_cast<int16_t>((dst[k * dstStride]) + ((refSide[k + 1] - refSide[0]) >> 1)));
+                }
+            }
+        }
+        else
+        {
+            int deltaPos = 0;
+            int deltaInt;
+            int deltaFract;
+            int refMainIndex;
+
+            for (k = 0; k < width; k++)
+            {
+                deltaPos += intraPredAngle;
+                deltaInt   = deltaPos >> 5;
+                deltaFract = deltaPos & (32 - 1);
+
+                if (deltaFract)
+                {
+                    // Do linear filtering
+                    for (l = 0; l < width; l++)
+                    {
+                        refMainIndex = l + deltaInt + 1;
+                        dst[k * dstStride + l] = (pixel)(((32 - deltaFract) * refMain[refMainIndex] + deltaFract * refMain[refMainIndex + 1] + 16) >> 5);
+                    }
+                }
+                else
+                {
+                    // Just copy the integer samples
+                    for (l = 0; l < width; l++)
+                    {
+                        dst[k * dstStride + l] = refMain[l + deltaInt + 1];
+                    }
+                }
+            }
+        }
+
+        // Flip the block if this is the horizontal mode
+        if (modeHor)
+        {
+            for (k = 0; k < width - 1; k++)
+            {
+                for (l = k + 1; l < width; l++)
+                {
+                    pixel tmp              = dst[k * dstStride + l];
+                    dst[k * dstStride + l] = dst[l * dstStride + k];
+                    dst[l * dstStride + k] = tmp;
+                }
+            }
+        }
+    }
+}
 }
 
 namespace x265 {


More information about the x265-devel mailing list