[x265] [PATCH 04 of 15] optimize SAO statistics initialize

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


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1449076349 21600
# Node ID 2601513575c7511d109ed906626b126d6e4f29fb
# Parent  c6e9344c5d47c029344369099ac63d5a52bdb3ed
optimize SAO statistics initialize
---
 source/encoder/sao.cpp |   50 +++++++++++++++++++++++++----------------------
 1 files changed, 27 insertions(+), 23 deletions(-)

diff -r c6e9344c5d47 -r 2601513575c7 source/encoder/sao.cpp
--- a/source/encoder/sao.cpp	Wed Dec 02 11:12:27 2015 -0600
+++ b/source/encoder/sao.cpp	Wed Dec 02 11:12:29 2015 -0600
@@ -1146,30 +1146,34 @@
         if (allowMerge[1])
             m_entropyCoder.codeSaoMerge(0);
         m_entropyCoder.store(m_rdContexts.temp);
+
         // reset stats Y, Cb, Cr
-        for (int plane = 0; plane < 3; plane++)
+        X265_CHECK(sizeof(PerPlane) == (sizeof(int32_t) * (NUM_PLANE * MAX_NUM_SAO_TYPE * MAX_NUM_SAO_CLASS)), "Found Padding space in struct PerPlane");
+
+        // TODO: Confirm the address space is continuous
+        memset(m_count, 0, 3 * sizeof(m_count[0]));
+        if (m_param->bSaoNonDeblocked)
         {
-            for (int j = 0; j < MAX_NUM_SAO_TYPE; j++)
-            {
-                for (int k = 0; k < MAX_NUM_SAO_CLASS; k++)
-                {
-                    m_offset[plane][j][k] = 0;
-                    if (m_param->bSaoNonDeblocked)
-                    {
-                        m_count[plane][j][k] = m_countPreDblk[addr][plane][j][k];
-                        m_offsetOrg[plane][j][k] = m_offsetOrgPreDblk[addr][plane][j][k];
-                    }
-                    else
-                    {
-                        m_count[plane][j][k] = 0;
-                        m_offsetOrg[plane][j][k] = 0;
-                    }
-                }
-            }
+            memcpy(m_count, m_countPreDblk[addr], 3 * sizeof(m_count[0]));
+            memcpy(m_offsetOrg, m_offsetOrgPreDblk[addr], 3 * sizeof(m_offsetOrg[0]));
+        }
+        else
+        {
+            memset(m_count, 0, 3 * sizeof(m_count[0]));
+            memset(m_offsetOrg, 0, 3 * sizeof(m_offsetOrg[0]));
+        }
 
-            saoParam->ctuParam[plane][addr].reset();
-            if (saoParam->bSaoFlag[plane > 0])
-                calcSaoStatsCu(addr, plane);
+        saoParam->ctuParam[0][addr].reset();
+        saoParam->ctuParam[1][addr].reset();
+        saoParam->ctuParam[2][addr].reset();
+
+        if (saoParam->bSaoFlag[0])
+            calcSaoStatsCu(addr, 0);
+
+        if (saoParam->bSaoFlag[1])
+        {
+            calcSaoStatsCu(addr, 1);
+            calcSaoStatsCu(addr, 2);
         }
 
         saoComponentParamDist(saoParam, addr, addrUp, addrLeft, &mergeSaoParam[0][0], mergeDist);



More information about the x265-devel mailing list