[x265] [PATCH 11 of 15] sao: split SAO Left reference pixel buffer into row base

Min Chen chenm003 at 163.com
Wed Dec 2 18:28:34 CET 2015


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1449076371 21600
# Node ID 3a423fcb4b4089de2c05a9067556f20a6fca0d1b
# Parent  82f6a10f44b88400f0f875025b9e8b6caff3acd3
sao: split SAO Left reference pixel buffer into row base
---
 source/encoder/sao.cpp |   35 +++++++++++++++++++++++++----------
 source/encoder/sao.h   |    4 ++--
 2 files changed, 27 insertions(+), 12 deletions(-)

diff -r 82f6a10f44b8 -r 3a423fcb4b40 source/encoder/sao.cpp
--- a/source/encoder/sao.cpp	Wed Dec 02 11:12:48 2015 -0600
+++ b/source/encoder/sao.cpp	Wed Dec 02 11:12:51 2015 -0600
@@ -87,8 +87,12 @@
     m_tmpU[0] = NULL;
     m_tmpU[1] = NULL;
     m_tmpU[2] = NULL;
-    m_tmpL1 = NULL;
-    m_tmpL2 = NULL;
+    m_tmpL1[0] = NULL;
+    m_tmpL1[1] = NULL;
+    m_tmpL1[2] = NULL;
+    m_tmpL2[0] = NULL;
+    m_tmpL2[1] = NULL;
+    m_tmpL2[2] = NULL;
 
     m_depthSaoRate[0][0] = 0;
     m_depthSaoRate[0][1] = 0;
@@ -116,11 +120,12 @@
 
     CHECKED_MALLOC(m_clipTableBase,  pixel, maxY + 2 * rangeExt);
 
-    CHECKED_MALLOC(m_tmpL1, pixel, g_maxCUSize + 1);
-    CHECKED_MALLOC(m_tmpL2, pixel, g_maxCUSize + 1);
 
     for (int i = 0; i < 3; i++)
     {
+        CHECKED_MALLOC(m_tmpL1[i], pixel, g_maxCUSize + 1);
+        CHECKED_MALLOC(m_tmpL2[i], pixel, g_maxCUSize + 1);
+
         // SAO asm code will read 1 pixel before and after, so pad by 2
         // NOTE: m_param->sourceWidth+2 enough, to avoid condition check in copySaoAboveRef(), I alloc more up to 63 bytes in here
         CHECKED_MALLOC(m_tmpU[i], pixel, m_numCuInWidth * g_maxCUSize + 2);
@@ -182,11 +187,21 @@
 {
     X265_FREE_ZERO(m_clipTableBase);
 
-    X265_FREE_ZERO(m_tmpL1);
-    X265_FREE_ZERO(m_tmpL2);
 
     for (int i = 0; i < 3; i++)
     {
+        if (m_tmpL1[i])
+        {
+            X265_FREE(m_tmpL1[i]);
+            m_tmpL1[i] = NULL;
+        }
+
+        if (m_tmpL2[i])
+        {
+            X265_FREE(m_tmpL2[i]);
+            m_tmpL2[i] = NULL;
+        }
+
         if (m_tmpU[i])
         {
             X265_FREE(m_tmpU[i] - 1);
@@ -307,7 +322,7 @@
 
     memset(_upBuff1 + MAX_CU_SIZE, 0, 2 * sizeof(int8_t)); /* avoid valgrind uninit warnings */
 
-    tmpL = m_tmpL1;
+    tmpL = m_tmpL1[plane];
     tmpU = &(m_tmpU[plane][lpelx]);
 
     switch (typeIdx)
@@ -607,7 +622,7 @@
 
     for (int i = 0; i < ctuHeight + 1; i++)
     {
-        m_tmpL1[i] = rec[0];
+        m_tmpL1[plane][i] = rec[0];
         rec += stride;
     }
 
@@ -623,7 +638,7 @@
             rec = reconPic->getPlaneAddr(plane, addr);
             for (int i = 0; i < ctuHeight + 1; i++)
             {
-                m_tmpL2[i] = rec[ctuWidth - 1];
+                m_tmpL2[plane][i] = rec[ctuWidth - 1];
                 rec += stride;
             }
         }
@@ -652,7 +667,7 @@
             }
             processSaoCu(addr, typeIdx, plane);
         }
-        std::swap(m_tmpL1, m_tmpL2);
+        std::swap(m_tmpL1[plane], m_tmpL2[plane]);
     }
 }
 
diff -r 82f6a10f44b8 -r 3a423fcb4b40 source/encoder/sao.h
--- a/source/encoder/sao.h	Wed Dec 02 11:12:48 2015 -0600
+++ b/source/encoder/sao.h	Wed Dec 02 11:12:51 2015 -0600
@@ -93,8 +93,8 @@
     pixel*      m_clipTableBase;
 
     pixel*      m_tmpU[3];
-    pixel*      m_tmpL1;
-    pixel*      m_tmpL2;
+    pixel*      m_tmpL1[3];
+    pixel*      m_tmpL2[3];
 
 public:
 



More information about the x265-devel mailing list