[x265] [PATCH] slicetype: satd cost analysis bug fixed

gopu at multicorewareinc.com gopu at multicorewareinc.com
Tue Aug 13 07:02:33 CEST 2013


# HG changeset patch
# User ggopu
# Date 1376370142 -19800
# Node ID 9880bd95e95b16eb530a8616b9730f4723365c02
# Parent  c8fff4b1bec8716803984b5d378e917f01720e8b
slicetype: satd cost analysis bug fixed

diff -r c8fff4b1bec8 -r 9880bd95e95b source/encoder/motion.h
--- a/source/encoder/motion.h	Mon Aug 12 22:38:13 2013 -0500
+++ b/source/encoder/motion.h	Tue Aug 13 10:32:22 2013 +0530
@@ -38,7 +38,6 @@
 
     /* Aligned copy of original pixels, extra room for manual alignment */
     pixel  fenc_buf[64 * FENC_STRIDE + 32];
-    pixel *fenc;
 
     pixel *fencplane;
     intptr_t fencLumaStride;
@@ -57,6 +56,7 @@
 
 public:
 
+    pixel *fenc;
     MotionEstimate();
 
     ~MotionEstimate() {}
diff -r c8fff4b1bec8 -r 9880bd95e95b source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp	Mon Aug 12 22:38:13 2013 -0500
+++ b/source/encoder/slicetype.cpp	Tue Aug 13 10:32:22 2013 +0530
@@ -211,7 +211,55 @@
         // 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 bcost = 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]);
+
+    // 1
+    primitives.intra_pred_dc(pAbove0 + 1, pLeft0 + 1, tmp, stride, cu_size, (cu_size <= 16));
+    bcost = sa8d(fenc->m_lumaPlane[0][0], fenc->m_lumaStride, tmp, 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, tmp, fenc->stride, cu_size);
+    cost = sa8d(fenc->m_lumaPlane[0][0], fenc->m_lumaStride, tmp, fenc->stride);
+    if (cost < bcost)
+        bcost = cost;
+
+    // Transpose NxN
+    x265::primitives.transpose[nLog2SizeMinus2](buf_trans, me.fenc, stride);
+
+    x265::primitives.intra_pred_allangs[nLog2SizeMinus2](tmp, pAbove0, pLeft0, pAbove1, pLeft1, (cu_size <= 16));
+
+    for (UInt mode = 2; mode < numModesAvailable; mode++)
+    {
+        bool modeHor = (mode < 18);
+        pixel *cmp = (modeHor ? buf_trans : me.fenc);
+        intptr_t srcStride = (modeHor ? cu_size : stride);
+        cost = sa8d(cmp, srcStride, &tmp[(mode - 2) * (cu_size * cu_size)], cu_size);
+        if (cost < bcost)
+            bcost = cost;
+    }
+
+    fenc->lowresMvCosts[0][0][cu_size] = bcost;
+
     return 0;
 }
 


More information about the x265-devel mailing list