[x265] [PATCH 18 of 24] sao: convert dynamic memory alloc to class static memory

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


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1449511595 21600
# Node ID 04c67fe19c5fbf025ecddbdd59f6d71f73539f58
# Parent  294ae06be8aab74f7113a60a4abb0b63efc18ea3
sao: convert dynamic memory alloc to class static memory
---
 source/encoder/sao.cpp |   25 +++++++------------------
 source/encoder/sao.h   |    6 +++---
 2 files changed, 10 insertions(+), 21 deletions(-)

diff -r 294ae06be8aa -r 04c67fe19c5f source/encoder/sao.cpp
--- a/source/encoder/sao.cpp	Mon Dec 07 12:06:32 2015 -0600
+++ b/source/encoder/sao.cpp	Mon Dec 07 12:06:35 2015 -0600
@@ -73,9 +73,6 @@
 
 SAO::SAO()
 {
-    m_count = NULL;
-    m_offset = NULL;
-    m_offsetOrg = NULL;
     m_countPreDblk = NULL;
     m_offsetOrgPreDblk = NULL;
     m_refDepth = 0;
@@ -132,10 +129,6 @@
         m_tmpU[i] += 1;
     }
 
-    CHECKED_MALLOC(m_count, PerClass, NUM_PLANE);
-    CHECKED_MALLOC(m_offset, PerClass, NUM_PLANE);
-    CHECKED_MALLOC(m_offsetOrg, PerClass, NUM_PLANE);
-
     if (initCommon)
     {
         CHECKED_MALLOC(m_countPreDblk, PerPlane, numCtu);
@@ -199,10 +192,6 @@
         }
     }
 
-    if (m_count) X265_FREE_ZERO(m_count);
-    if (m_offset) X265_FREE_ZERO(m_offset);
-    if (m_offsetOrg) X265_FREE_ZERO(m_offsetOrg);
-
     if (destoryCommon)
     {
         X265_FREE_ZERO(m_countPreDblk);
@@ -1214,9 +1203,9 @@
 /* reset offset statistics */
 void SAO::resetStats()
 {
-    memset(m_count, 0, sizeof(PerClass) * NUM_PLANE);
-    memset(m_offset, 0, sizeof(PerClass) * NUM_PLANE);
-    memset(m_offsetOrg, 0, sizeof(PerClass) * NUM_PLANE);
+    memset(m_count, 0, sizeof(m_count));
+    memset(m_offset, 0, sizeof(m_offset));
+    memset(m_offsetOrg, 0, sizeof(m_offsetOrg));
 }
 
 void SAO::rdoSaoUnitRowEnd(const SAOParam* saoParam, int numctus)
@@ -1259,13 +1248,13 @@
         // TODO: Confirm the address space is continuous
         if (m_param->bSaoNonDeblocked)
         {
-            memcpy(m_count, m_countPreDblk[addr], 3 * sizeof(m_count[0]));
-            memcpy(m_offsetOrg, m_offsetOrgPreDblk[addr], 3 * sizeof(m_offsetOrg[0]));
+            memcpy(m_count, m_countPreDblk[addr], sizeof(m_count));
+            memcpy(m_offsetOrg, m_offsetOrgPreDblk[addr], sizeof(m_offsetOrg));
         }
         else
         {
-            memset(m_count, 0, 3 * sizeof(m_count[0]));
-            memset(m_offsetOrg, 0, 3 * sizeof(m_offsetOrg[0]));
+            memset(m_count, 0, sizeof(m_count));
+            memset(m_offsetOrg, 0, sizeof(m_offsetOrg));
         }
 
         saoParam->ctuParam[0][addr].reset();
diff -r 294ae06be8aa -r 04c67fe19c5f source/encoder/sao.h
--- a/source/encoder/sao.h	Mon Dec 07 12:06:32 2015 -0600
+++ b/source/encoder/sao.h	Mon Dec 07 12:06:35 2015 -0600
@@ -71,9 +71,9 @@
 protected:
 
     /* allocated per part */
-    PerClass*   m_count;
-    PerClass*   m_offset;
-    PerClass*   m_offsetOrg;
+    PerPlane    m_count;
+    PerPlane    m_offset;
+    PerPlane    m_offsetOrg;
 
     /* allocated per CTU */
     PerPlane*   m_countPreDblk;



More information about the x265-devel mailing list