[x265] [PATCH 12 of 15] sao: new CU level process function

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


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1449076374 21600
# Node ID b1c261378db29a1988d8e27c5eabe1a76821f83d
# Parent  3a423fcb4b4089de2c05a9067556f20a6fca0d1b
sao: new CU level process function
---
 source/encoder/framefilter.cpp |   13 +++++--
 source/encoder/sao.cpp         |   68 ++++++++++++++++++++++++++++++++++++++++
 source/encoder/sao.h           |    1 +
 3 files changed, 78 insertions(+), 4 deletions(-)

diff -r 3a423fcb4b40 -r b1c261378db2 source/encoder/framefilter.cpp
--- a/source/encoder/framefilter.cpp	Wed Dec 02 11:12:51 2015 -0600
+++ b/source/encoder/framefilter.cpp	Wed Dec 02 11:12:54 2015 -0600
@@ -541,19 +541,24 @@
 {
     FrameData& encData = *m_frame->m_encData;
     SAOParam* saoParam = encData.m_saoParam;
+    uint32_t numCols = encData.m_slice->m_sps->numCuInWidth;
 
     if (saoParam->bSaoFlag[0])
-        m_parallelFilter[row].m_sao.processSaoUnitRow(saoParam->ctuParam[0], row, 0);
+    {
+        for(uint32_t col = 0; col < numCols; col++)
+            m_parallelFilter[row].m_sao.processSaoUnitCu(saoParam->ctuParam[0], row, col, 0);
+    }
 
     if (saoParam->bSaoFlag[1])
     {
-        m_parallelFilter[row].m_sao.processSaoUnitRow(saoParam->ctuParam[1], row, 1);
-        m_parallelFilter[row].m_sao.processSaoUnitRow(saoParam->ctuParam[2], row, 2);
+        for(uint32_t col = 0; col < numCols; col++)
+            m_parallelFilter[row].m_sao.processSaoUnitCu(saoParam->ctuParam[1], row, col, 1);
+        for(uint32_t col = 0; col < numCols; col++)
+            m_parallelFilter[row].m_sao.processSaoUnitCu(saoParam->ctuParam[2], row, col, 2);
     }
 
     if (encData.m_slice->m_pps->bTransquantBypassEnabled)
     {
-        uint32_t numCols = encData.m_slice->m_sps->numCuInWidth;
         uint32_t lineStartCUAddr = row * numCols;
 
         const CUGeom* cuGeoms = m_frameEncoder->m_cuGeoms;
diff -r 3a423fcb4b40 -r b1c261378db2 source/encoder/sao.cpp
--- a/source/encoder/sao.cpp	Wed Dec 02 11:12:51 2015 -0600
+++ b/source/encoder/sao.cpp	Wed Dec 02 11:12:54 2015 -0600
@@ -671,6 +671,74 @@
     }
 }
 
+/* Process SAO unit */
+void SAO::processSaoUnitCu(SaoCtuParam* ctuParam, int idxY, int idxX, int plane)
+{
+    PicYuv* reconPic = m_frame->m_reconPic;
+    intptr_t stride = plane ? reconPic->m_strideC : reconPic->m_stride;
+    uint32_t picWidth  = m_param->sourceWidth;
+    int ctuWidth  = g_maxCUSize;
+    int ctuHeight = g_maxCUSize;
+
+    if (plane)
+    {
+        picWidth  >>= m_hChromaShift;
+        ctuWidth  >>= m_hChromaShift;
+        ctuHeight >>= m_vChromaShift;
+    }
+
+    int addr = idxY * m_numCuInWidth + idxX;
+    pixel* rec = reconPic->getPlaneAddr(plane, addr);
+
+    if (idxX == 0)
+    {
+        for (int i = 0; i < ctuHeight + 1; i++)
+        {
+            m_tmpL1[plane][i] = rec[0];
+            rec += stride;
+        }
+    }
+
+    bool mergeLeftFlag = (ctuParam[addr].mergeMode == SAO_MERGE_LEFT);
+    int typeIdx = ctuParam[addr].typeIdx;
+
+    if (idxX != (m_numCuInWidth - 1))
+    {
+        rec = reconPic->getPlaneAddr(plane, addr);
+        for (int i = 0; i < ctuHeight + 1; i++)
+        {
+            m_tmpL2[plane][i] = rec[ctuWidth - 1];
+            rec += stride;
+        }
+    }
+
+    if (typeIdx >= 0)
+    {
+        if (!mergeLeftFlag)
+        {
+            if (typeIdx == SAO_BO)
+            {
+                memset(m_offsetBo, 0, sizeof(m_offsetBo));
+
+                for (int i = 0; i < SAO_NUM_OFFSET; i++)
+                    m_offsetBo[((ctuParam[addr].bandPos + i) & (SAO_NUM_BO_CLASSES - 1))] = (int8_t)(ctuParam[addr].offset[i] << SAO_BIT_INC);
+            }
+            else // if (typeIdx == SAO_EO_0 || typeIdx == SAO_EO_1 || typeIdx == SAO_EO_2 || typeIdx == SAO_EO_3)
+            {
+                int offset[NUM_EDGETYPE];
+                offset[0] = 0;
+                for (int i = 0; i < SAO_NUM_OFFSET; i++)
+                    offset[i + 1] = ctuParam[addr].offset[i] << SAO_BIT_INC;
+
+                for (int edgeType = 0; edgeType < NUM_EDGETYPE; edgeType++)
+                    m_offsetEo[edgeType] = (int8_t)offset[s_eoTable[edgeType]];
+            }
+        }
+        processSaoCu(addr, typeIdx, plane);
+    }
+    std::swap(m_tmpL1[plane], m_tmpL2[plane]);
+}
+
 void SAO::copySaoUnit(SaoCtuParam* saoUnitDst, const SaoCtuParam* saoUnitSrc)
 {
     saoUnitDst->mergeMode   = saoUnitSrc->mergeMode;
diff -r 3a423fcb4b40 -r b1c261378db2 source/encoder/sao.h
--- a/source/encoder/sao.h	Wed Dec 02 11:12:51 2015 -0600
+++ b/source/encoder/sao.h	Wed Dec 02 11:12:54 2015 -0600
@@ -132,6 +132,7 @@
     // CTU-based SAO process without slice granularity
     void processSaoCu(int addr, int typeIdx, int plane);
     void processSaoUnitRow(SaoCtuParam* ctuParam, int idxY, int plane);
+    void processSaoUnitCu(SaoCtuParam* ctuParam, int idxY, int idxX, int plane);
 
     void copySaoUnit(SaoCtuParam* saoUnitDst, const SaoCtuParam* saoUnitSrc);
 



More information about the x265-devel mailing list