[x265] [PATCH] slicetype: added Intra SATD Cost analysis

gopu at multicorewareinc.com gopu at multicorewareinc.com
Mon Aug 12 14:18:35 CEST 2013


# HG changeset patch
# User ggopu
# Date 1376309907 -19800
# Node ID 28af0c3bde0dadc175ef1536bf36de3158732406
# Parent  9f604820f7ef0a2d780cb1476921860b94d26a42
slicetype: added Intra SATD Cost analysis

diff -r 9f604820f7ef -r 28af0c3bde0d source/encoder/motion.h
--- a/source/encoder/motion.h	Mon Aug 12 17:11:34 2013 +0530
+++ b/source/encoder/motion.h	Mon Aug 12 17:48:27 2013 +0530
@@ -37,8 +37,7 @@
 protected:
 
     /* Aligned copy of original pixels, extra room for manual alignment */
-    pixel  fenc_buf[64 * FENC_STRIDE + 32];
-    pixel *fenc;
+    pixel  fenc_buf[64 * FENC_STRIDE + 32];  
 
     pixel *fencplane;
     intptr_t fencLumaStride;
@@ -57,6 +56,7 @@
 
 public:
 
+    pixel *fenc;
     MotionEstimate();
 
     ~MotionEstimate() {}
diff -r 9f604820f7ef -r 28af0c3bde0d source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp	Mon Aug 12 17:11:34 2013 +0530
+++ b/source/encoder/slicetype.cpp	Mon Aug 12 17:48:27 2013 +0530
@@ -211,7 +211,56 @@
         // TODO: add bidir
     }
 
-    // TODO: copy intra SATD cost analysis here (DC + planar + all-angs)
+    UInt numModesAvailable = 35; //total number of Intra modes
+    Int nLog2SizeMinus2 = g_convertToBit[cu_size]; // partition size
+    x265::pixelcmp_t sa8d = x265::primitives.sa8d[nLog2SizeMinus2]; // get the Primitive function
+    UInt b_cost = 0, cost = 0;
+
+    /* need review on this buffer */
+    pixel *pAbove0 = fenc->m_lumaPlane[0][0] + pel_offset - fenc->m_lumaStride;
+    pixel *pAbove1 = fenc->m_lumaPlane[0][0] + pel_offset - fenc->cuHeight;
+    pixel *pLeft0  = fenc->m_lumaPlane[0][0] + pel_offset + fenc->m_lumaStride;
+    pixel *pLeft1  = fenc->m_lumaPlane[0][0] + pel_offset + fenc->cuWidth;
+
+    // 33 Angle modes once
+    ALIGN_VAR_32(pixel, buf_trans[32 * 32]);
+    ALIGN_VAR_32(pixel, tmp[33 * 32 * 32]);
+
+    if (cu_size <= 32)
+    {
+        // 1
+        primitives.intra_pred_dc(pAbove0 + 1, pLeft0 + 1, me.fenc, stride, cu_size, (cu_size <= 16));
+        cost = b_cost = sa8d(fenc->m_lumaPlane[0][0], fenc->m_lumaStride, me.fenc, fenc->stride);
+
+        // 0
+        pixel *above = pAbove0;
+        pixel *left  = pLeft0;
+        if (cu_size >= 8 && cu_size <= 32)
+        {
+            above = pAbove1;
+            left  = pLeft1;
+        }
+        primitives.intra_pred_planar((pixel*)above + 1, (pixel*)left + 1, me.fenc, fenc->stride, cu_size);
+        b_cost = sa8d(fenc->m_lumaPlane[0][0], fenc->m_lumaStride, me.fenc, fenc->stride);
+        if(b_cost < cost)
+            cost = b_cost;
+         
+        // Transpose NxN
+        x265::primitives.transpose[nLog2SizeMinus2](buf_trans, (pixel*)fenc, stride);
+
+        x265::primitives.intra_pred_allangs[nLog2SizeMinus2](tmp, pAbove0, pLeft0, pAbove1, pLeft1, (cu_size <= 16));
+
+        // TODO: We need SATD_x4 here
+        for (UInt mode = 2; mode < numModesAvailable; mode++)
+        {
+            bool modeHor = (mode < 18);
+            pixel *cmp = (modeHor ? buf_trans : fenc->m_lumaPlane[0][0]);
+            intptr_t srcStride = (modeHor ? cu_size : stride);
+            b_cost = sa8d(cmp, srcStride, &tmp[(mode - 2) * (cu_size * cu_size)], cu_size);
+            if(b_cost < cost )
+                 cost = b_cost; // cost always having least  satd cost
+        }
+    }
     return 0;
 }
 


More information about the x265-devel mailing list