[x265] [PATCH 19 of 24] sao: share fast lookup table m_clipTable

Min Chen chenm003 at 163.com
Tue Dec 8 00:54:56 CET 2015


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1449511598 21600
# Node ID f023dda04a265ff507746af68c213e61303805f6
# Parent  04c67fe19c5fbf025ecddbdd59f6d71f73539f58
sao: share fast lookup table m_clipTable
---
 source/encoder/sao.cpp |   39 +++++++++++++++++++++++----------------
 1 files changed, 23 insertions(+), 16 deletions(-)

diff -r 04c67fe19c5f -r f023dda04a26 source/encoder/sao.cpp
--- a/source/encoder/sao.cpp	Mon Dec 07 12:06:35 2015 -0600
+++ b/source/encoder/sao.cpp	Mon Dec 07 12:06:38 2015 -0600
@@ -115,9 +115,6 @@
     const pixel rangeExt = maxY >> 1;
     int numCtu = m_numCuInWidth * m_numCuInHeight;
 
-    CHECKED_MALLOC(m_clipTableBase,  pixel, maxY + 2 * rangeExt);
-
-
     for (int i = 0; i < 3; i++)
     {
         CHECKED_MALLOC(m_tmpL1[i], pixel, g_maxCUSize + 1);
@@ -133,25 +130,32 @@
     {
         CHECKED_MALLOC(m_countPreDblk, PerPlane, numCtu);
         CHECKED_MALLOC(m_offsetOrgPreDblk, PerPlane, numCtu);
+
+        CHECKED_MALLOC(m_clipTableBase,  pixel, maxY + 2 * rangeExt);
+        m_clipTable = &(m_clipTableBase[rangeExt]);
+
+        // Share with fast clip lookup table
+        if (initCommon)
+        {
+            for (int i = 0; i < rangeExt; i++)
+                m_clipTableBase[i] = 0;
+
+            for (int i = 0; i < maxY; i++)
+                m_clipTable[i] = (pixel)i;
+
+            for (int i = maxY; i < maxY + rangeExt; i++)
+                m_clipTable[i] = maxY;
+        }
     }
     else
     {
         // must initialize these common pointer outside of function
         m_countPreDblk = NULL;
         m_offsetOrgPreDblk = NULL;
+        m_clipTableBase = NULL;
+        m_clipTable = NULL;
     }
 
-    m_clipTable = &(m_clipTableBase[rangeExt]);
-
-    for (int i = 0; i < rangeExt; i++)
-        m_clipTableBase[i] = 0;
-
-    for (int i = 0; i < maxY; i++)
-        m_clipTable[i] = (pixel)i;
-
-    for (int i = maxY; i < maxY + rangeExt; i++)
-        m_clipTable[i] = maxY;
-
     return true;
 
 fail:
@@ -162,15 +166,17 @@
 {
     X265_CHECK(m_countPreDblk == NULL, "duplicate initialize on m_countPreDblk");
     X265_CHECK(m_offsetOrgPreDblk == NULL, "duplicate initialize on m_offsetOrgPreDblk");
+    X265_CHECK(m_clipTableBase == NULL, "duplicate initialize on m_clipTableBase");
+    X265_CHECK(m_clipTable == NULL, "duplicate initialize on m_clipTable");
 
     m_countPreDblk = root->m_countPreDblk;
     m_offsetOrgPreDblk = root->m_offsetOrgPreDblk;
+    m_clipTableBase = root->m_clipTableBase; // Unnecessary
+    m_clipTable = root->m_clipTable;
 }
 
 void SAO::destroy(int destoryCommon)
 {
-    X265_FREE_ZERO(m_clipTableBase);
-
     for (int i = 0; i < 3; i++)
     {
         if (m_tmpL1[i])
@@ -196,6 +202,7 @@
     {
         X265_FREE_ZERO(m_countPreDblk);
         X265_FREE_ZERO(m_offsetOrgPreDblk);
+        X265_FREE_ZERO(m_clipTableBase);
     }
 }
 



More information about the x265-devel mailing list