[x265] [PATCH 2 of 4] framepp: replace static class array countPreDblk and offsetOrgPreDblk

Min Chen chenm003 at 163.com
Thu Aug 22 09:18:31 CEST 2013


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1377155800 -28800
# Node ID 78f36991d73034630b123c6b98d00e6fffde468f
# Parent  5855cec9604808b34e8cebf7e4a159fbc2977855
 framepp: replace static class array countPreDblk and offsetOrgPreDblk

diff -r 5855cec96048 -r 78f36991d730 source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp
--- a/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp	Thu Aug 22 15:16:24 2013 +0800
+++ b/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp	Thu Aug 22 15:16:40 2013 +0800
@@ -53,6 +53,8 @@
     m_count = NULL;
     m_offset = NULL;
     m_offsetOrg = NULL;
+    m_countPreDblk = NULL;
+    m_offsetOrgPreDblk = NULL;
     m_rate = NULL;
     m_dist = NULL;
     m_cost = NULL;
@@ -75,8 +77,6 @@
 // ====================================================================================================================
 // Static
 // ====================================================================================================================
-Int64  ****TEncSampleAdaptiveOffset::m_countPreDblk = NULL;
-Int64  ****TEncSampleAdaptiveOffset::m_offsetOrgPreDblk = NULL;
 
 // ====================================================================================================================
 // Constants
@@ -470,56 +470,14 @@
         delete [] m_offsetOrg;
         m_offsetOrg = NULL;
     }
-    Int numLcu = m_numCuInWidth * m_numCuInHeight;
 
     if (m_countPreDblk)
     {
-        for (Int i = 0; i < numLcu; i++)
-        {
-            for (Int j = 0; j < 3; j++)
-            {
-                for (Int k = 0; k < MAX_NUM_SAO_TYPE; k++)
-                {
-                    if (m_countPreDblk[i][j][k])
-                    {
-                        delete [] m_countPreDblk[i][j][k];
-                    }
-                    if (m_offsetOrgPreDblk[i][j][k])
-                    {
-                        delete [] m_offsetOrgPreDblk[i][j][k];
-                    }
-                }
+        delete[] m_countPreDblk;
+        m_countPreDblk = NULL;
 
-                if (m_countPreDblk[i][j])
-                {
-                    delete [] m_countPreDblk[i][j];
-                }
-                if (m_offsetOrgPreDblk[i][j])
-                {
-                    delete [] m_offsetOrgPreDblk[i][j];
-                }
-            }
-
-            if (m_countPreDblk[i])
-            {
-                delete [] m_countPreDblk[i];
-            }
-            if (m_offsetOrgPreDblk[i])
-            {
-                delete [] m_offsetOrgPreDblk[i];
-            }
-        }
-
-        if (m_countPreDblk)
-        {
-            delete [] m_countPreDblk;
-            m_countPreDblk = NULL;
-        }
-        if (m_offsetOrgPreDblk)
-        {
-            delete [] m_offsetOrgPreDblk;
-            m_offsetOrgPreDblk = NULL;
-        }
+        delete[] m_offsetOrgPreDblk;
+        m_offsetOrgPreDblk = NULL;
     }
 
     Int maxDepth = 4;
@@ -583,25 +541,8 @@
     {
         assert(m_offsetOrgPreDblk == NULL);
 
-        m_countPreDblk  = new Int64 * **[numLcu];
-        m_offsetOrgPreDblk = new Int64 * **[numLcu];
-        for (Int i = 0; i < numLcu; i++)
-        {
-            m_countPreDblk[i]  = new Int64 * *[3];
-            m_offsetOrgPreDblk[i] = new Int64 * *[3];
-
-            for (Int j = 0; j < 3; j++)
-            {
-                m_countPreDblk[i][j] = new Int64 *[MAX_NUM_SAO_TYPE];
-                m_offsetOrgPreDblk[i][j] = new Int64 *[MAX_NUM_SAO_TYPE];
-
-                for (Int k = 0; k < MAX_NUM_SAO_TYPE; k++)
-                {
-                    m_countPreDblk[i][j][k]   = new Int64[MAX_NUM_SAO_CLASS];
-                    m_offsetOrgPreDblk[i][j][k] = new Int64[MAX_NUM_SAO_CLASS];
-                }
-            }
-        }
+        m_countPreDblk  = new Int64[numLcu][3][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];
+        m_offsetOrgPreDblk = new Int64[numLcu][3][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];
     }
 
     Int maxDepth = 4;
@@ -1218,7 +1159,6 @@
 
     Int idxX;
     Int frameWidthInCU  = m_numCuInWidth;
-    Int j, k;
 
     Int isChroma;
     Int numSkipLine, numSkipLineRight;
@@ -1237,19 +1177,13 @@
             pTmpCu = pic->getCU(addr);
             lPelX   = pTmpCu->getCUPelX();
             tPelY   = pTmpCu->getCUPelY();
+
+            memset(m_countPreDblk[addr], 0, 3 * MAX_NUM_SAO_TYPE * MAX_NUM_SAO_CLASS * sizeof(Int64));
+            memset(m_offsetOrgPreDblk[addr], 0, 3 * MAX_NUM_SAO_TYPE * MAX_NUM_SAO_CLASS * sizeof(Int64));
             for (yCbCr = 0; yCbCr < 3; yCbCr++)
             {
                 isChroma = (yCbCr != 0) ? 1 : 0;
 
-                for (j = 0; j < MAX_NUM_SAO_TYPE; j++)
-                {
-                    for (k = 0; k < MAX_NUM_SAO_CLASS; k++)
-                    {
-                        m_countPreDblk[addr][yCbCr][j][k] = 0;
-                        m_offsetOrgPreDblk[addr][yCbCr][j][k] = 0;
-                    }
-                }
-
                 if (yCbCr == 0)
                 {
                     picWidthTmp  = m_picWidth;
diff -r 5855cec96048 -r 78f36991d730 source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.h
--- a/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.h	Thu Aug 22 15:16:24 2013 +0800
+++ b/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.h	Thu Aug 22 15:16:40 2013 +0800
@@ -65,8 +65,8 @@
     Int64  ***m_count;    //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];
     Int64  ***m_offset;   //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];
     Int64  ***m_offsetOrg; //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE];
-    static Int64  ****m_countPreDblk;    //[LCU][YCbCr][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];
-    static Int64  ****m_offsetOrgPreDblk; //[LCU][YCbCr][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];
+    Int64  (*m_countPreDblk)[3][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];    //[LCU][YCbCr][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];
+    Int64  (*m_offsetOrgPreDblk)[3][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS]; //[LCU][YCbCr][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];
     Int64  **m_rate;      //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE];
     Int64  **m_dist;      //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE];
     Double **m_cost;      //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE];



More information about the x265-devel mailing list