[x265] [PATCH 3 of 3] move m_blockingStrength to local

Min Chen chenm003 at 163.com
Thu Jun 19 23:57:18 CEST 2014


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1403215023 25200
# Node ID 7f213d2e3a275bf6dcd200dabf1656944e926c86
# Parent  9fd5f9f6e1de1567adca64f26c8c5a34e2b1caa2
move m_blockingStrength to local

diff -r 9fd5f9f6e1de -r 7f213d2e3a27 source/Lib/TLibCommon/TComLoopFilter.cpp
--- a/source/Lib/TLibCommon/TComLoopFilter.cpp	Thu Jun 19 14:56:46 2014 -0700
+++ b/source/Lib/TLibCommon/TComLoopFilter.cpp	Thu Jun 19 14:57:03 2014 -0700
@@ -73,10 +73,6 @@
 TComLoopFilter::TComLoopFilter()
     : m_numPartitions(0)
 {
-    for (uint32_t dir = 0; dir < 2; dir++)
-    {
-        m_blockingStrength[dir] = NULL;
-    }
 }
 
 TComLoopFilter::~TComLoopFilter()
@@ -94,28 +90,19 @@
 {
     destroy();
     m_numPartitions = 1 << (maxCuDepth << 1);
-    for (uint32_t dir = 0; dir < 2; dir++)
-    {
-        m_blockingStrength[dir] = new uint8_t[m_numPartitions];
-    }
 }
 
 void TComLoopFilter::destroy()
 {
-    for (uint32_t dir = 0; dir < 2; dir++)
-    {
-        delete [] m_blockingStrength[dir];
-        m_blockingStrength[dir] = NULL;
-    }
 }
 
-void TComLoopFilter::loopFilterCU(TComDataCU* cu, int dir, bool edgeFilter[])
+void TComLoopFilter::loopFilterCU(TComDataCU* cu, int dir, bool edgeFilter[], uint8_t blockingStrength[])
 {
-    ::memset(m_blockingStrength[dir], 0, sizeof(uint8_t) * m_numPartitions);
+    ::memset(blockingStrength, 0, sizeof(uint8_t) * m_numPartitions);
     ::memset(edgeFilter, 0, sizeof(bool) * m_numPartitions);
 
     // CU-based deblocking
-    xDeblockCU(cu, 0, 0, dir, edgeFilter);
+    xDeblockCU(cu, 0, 0, dir, edgeFilter, blockingStrength);
 }
 
 // ====================================================================================================================
@@ -127,7 +114,7 @@
  .
  \param Edge          the direction of the edge in block boundary (horizonta/vertical), which is added newly
 */
-void TComLoopFilter::xDeblockCU(TComDataCU* cu, uint32_t absZOrderIdx, uint32_t depth, const int dir, bool edgeFilter[])
+void TComLoopFilter::xDeblockCU(TComDataCU* cu, uint32_t absZOrderIdx, uint32_t depth, const int dir, bool edgeFilter[], uint8_t blockingStrength[])
 {
     if (cu->getPic() == 0 || cu->getPartitionSize(absZOrderIdx) == SIZE_NONE)
     {
@@ -145,7 +132,7 @@
             uint32_t tpely   = cu->getCUPelY() + g_rasterToPelY[g_zscanToRaster[absZOrderIdx]];
             if ((lpelx < cu->getSlice()->getSPS()->getPicWidthInLumaSamples()) && (tpely < cu->getSlice()->getSPS()->getPicHeightInLumaSamples()))
             {
-                xDeblockCU(cu, absZOrderIdx, depth + 1, dir, edgeFilter);
+                xDeblockCU(cu, absZOrderIdx, depth + 1, dir, edgeFilter, blockingStrength);
             }
         }
 
@@ -156,8 +143,8 @@
     LFCUParam lfcuParam;
     xSetLoopfilterParam(cu, absZOrderIdx, &lfcuParam);
 
-    xSetEdgefilterTU(cu, absZOrderIdx, absZOrderIdx, depth, dir, edgeFilter);
-    xSetEdgefilterPU(cu, absZOrderIdx, dir, &lfcuParam, edgeFilter);
+    xSetEdgefilterTU(cu, absZOrderIdx, absZOrderIdx, depth, dir, edgeFilter, blockingStrength);
+    xSetEdgefilterPU(cu, absZOrderIdx, dir, &lfcuParam, edgeFilter, blockingStrength);
 
     for (uint32_t partIdx = absZOrderIdx; partIdx < absZOrderIdx + curNumParts; partIdx++)
     {
@@ -173,7 +160,7 @@
 
         if (edgeFilter[partIdx] && bsCheck)
         {
-            xGetBoundaryStrengthSingle(cu, dir, partIdx);
+            xGetBoundaryStrengthSingle(cu, dir, partIdx, blockingStrength);
         }
     }
 
@@ -185,15 +172,15 @@
     const bool bAlwaysDoChroma = (cu->getChromaFormat() == CHROMA_444);
     for (uint32_t e = 0; e < sizeInPU; e += partIdxIncr)
     {
-        xEdgeFilterLuma(cu, absZOrderIdx, depth, dir, e);
+        xEdgeFilterLuma(cu, absZOrderIdx, depth, dir, e, blockingStrength);
         if (bAlwaysDoChroma || (pelsInPart > DEBLOCK_SMALLEST_BLOCK) || (e % ((DEBLOCK_SMALLEST_BLOCK << shiftFactor) / pelsInPart)) == 0)
         {
-            xEdgeFilterChroma(cu, absZOrderIdx, depth, dir, e);
+            xEdgeFilterChroma(cu, absZOrderIdx, depth, dir, e, blockingStrength);
         }
     }
 }
 
-void TComLoopFilter::xSetEdgefilterMultiple(TComDataCU* cu, uint32_t scanIdx, uint32_t depth, int dir, int edgeIdx, bool bValue, bool edgeFilter[], uint32_t widthInBaseUnits)
+void TComLoopFilter::xSetEdgefilterMultiple(TComDataCU* cu, uint32_t scanIdx, uint32_t depth, int dir, int edgeIdx, bool bValue, bool edgeFilter[], uint8_t blockingStrength[], uint32_t widthInBaseUnits)
 {
     if (widthInBaseUnits == 0)
     {
@@ -208,12 +195,12 @@
         edgeFilter[bsidx] = bValue;
         if (edgeIdx == 0)
         {
-            m_blockingStrength[dir][bsidx] = bValue;
+            blockingStrength[bsidx] = bValue;
         }
     }
 }
 
-void TComLoopFilter::xSetEdgefilterTU(TComDataCU* cu, uint32_t absTUPartIdx, uint32_t absZOrderIdx, uint32_t depth, int dir, bool edgeFilter[])
+void TComLoopFilter::xSetEdgefilterTU(TComDataCU* cu, uint32_t absTUPartIdx, uint32_t absZOrderIdx, uint32_t depth, int dir, bool edgeFilter[], uint8_t blockingStrength[])
 {
     if (cu->getTransformIdx(absZOrderIdx) + cu->getDepth(absZOrderIdx) > depth)
     {
@@ -222,7 +209,7 @@
         for (uint32_t partIdx = 0; partIdx < 4; partIdx++, absZOrderIdx += qNumParts)
         {
             uint32_t nsAddr = absZOrderIdx;
-            xSetEdgefilterTU(cu, nsAddr, absZOrderIdx, depth + 1, dir, edgeFilter);
+            xSetEdgefilterTU(cu, nsAddr, absZOrderIdx, depth + 1, dir, edgeFilter, blockingStrength);
         }
 
         return;
@@ -232,17 +219,17 @@
 
     uint32_t widthInBaseUnits  = trWidth / (g_maxCUSize >> g_maxCUDepth);
 
-    xSetEdgefilterMultiple(cu, absTUPartIdx, depth, dir, 0, true, edgeFilter, widthInBaseUnits);
+    xSetEdgefilterMultiple(cu, absTUPartIdx, depth, dir, 0, true, edgeFilter, blockingStrength, widthInBaseUnits);
 }
 
-void TComLoopFilter::xSetEdgefilterPU(TComDataCU* cu, uint32_t absZOrderIdx, int dir, LFCUParam *lfcuParam, bool edgeFilter[])
+void TComLoopFilter::xSetEdgefilterPU(TComDataCU* cu, uint32_t absZOrderIdx, int dir, LFCUParam *lfcuParam, bool edgeFilter[], uint8_t blockingStrength[])
 {
     const uint32_t depth = cu->getDepth(absZOrderIdx);
     const uint32_t widthInBaseUnits  = cu->getPic()->getNumPartInCUSize() >> depth;
     const uint32_t hWidthInBaseUnits  = widthInBaseUnits  >> 1;
     const uint32_t qWidthInBaseUnits  = widthInBaseUnits  >> 2;
 
-    xSetEdgefilterMultiple(cu, absZOrderIdx, depth, dir, 0, (dir == EDGE_VER ? lfcuParam->bLeftEdge : lfcuParam->bTopEdge), edgeFilter);
+    xSetEdgefilterMultiple(cu, absZOrderIdx, depth, dir, 0, (dir == EDGE_VER ? lfcuParam->bLeftEdge : lfcuParam->bTopEdge), edgeFilter, blockingStrength);
 
     int mode = cu->getPartitionSize(absZOrderIdx);
     switch (mode)
@@ -257,12 +244,12 @@
         const int realDir = (mode == SIZE_2NxN ? EDGE_HOR : EDGE_VER);
 
         if (realDir == dir)
-            xSetEdgefilterMultiple(cu, absZOrderIdx, depth, dir, hWidthInBaseUnits, true, edgeFilter);
+            xSetEdgefilterMultiple(cu, absZOrderIdx, depth, dir, hWidthInBaseUnits, true, edgeFilter, blockingStrength);
         break;
     }
     case SIZE_NxN:
     {
-        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, dir, hWidthInBaseUnits, true, edgeFilter);
+        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, dir, hWidthInBaseUnits, true, edgeFilter, blockingStrength);
         break;
     }
     case SIZE_2NxnU:
@@ -271,7 +258,7 @@
         const int realDir = (mode == SIZE_2NxnU ? EDGE_HOR : EDGE_VER);
 
         if (realDir == dir)
-            xSetEdgefilterMultiple(cu, absZOrderIdx, depth, dir, qWidthInBaseUnits, true, edgeFilter);
+            xSetEdgefilterMultiple(cu, absZOrderIdx, depth, dir, qWidthInBaseUnits, true, edgeFilter, blockingStrength);
         break;
     }
     case SIZE_2NxnD:
@@ -280,7 +267,7 @@
         const int realDir = (mode == SIZE_2NxnD ? EDGE_HOR : EDGE_VER);
 
         if (realDir == dir)
-            xSetEdgefilterMultiple(cu, absZOrderIdx, depth, dir, widthInBaseUnits - qWidthInBaseUnits, true, edgeFilter);
+            xSetEdgefilterMultiple(cu, absZOrderIdx, depth, dir, widthInBaseUnits - qWidthInBaseUnits, true, edgeFilter, blockingStrength);
         break;
     }
     default:
@@ -336,7 +323,7 @@
     }
 }
 
-void TComLoopFilter::xGetBoundaryStrengthSingle(TComDataCU* cu, int dir, uint32_t absPartIdx)
+void TComLoopFilter::xGetBoundaryStrengthSingle(TComDataCU* cu, int dir, uint32_t absPartIdx, uint8_t blockingStrength[])
 {
     TComSlice* const slice = cu->getSlice();
 
@@ -369,7 +356,7 @@
         uint32_t nsPartQ = partQ;
         uint32_t nsPartP = partP;
 
-        if (m_blockingStrength[dir][absPartIdx] && (cuQ->getCbf(nsPartQ, TEXT_LUMA, cuQ->getTransformIdx(nsPartQ)) != 0 || cuP->getCbf(nsPartP, TEXT_LUMA, cuP->getTransformIdx(nsPartP)) != 0))
+        if (blockingStrength[absPartIdx] && (cuQ->getCbf(nsPartQ, TEXT_LUMA, cuQ->getTransformIdx(nsPartQ)) != 0 || cuP->getCbf(nsPartP, TEXT_LUMA, cuP->getTransformIdx(nsPartP)) != 0))
         {
             bs = 1;
         }
@@ -459,10 +446,10 @@
         } // enf of "if( one of BCBP == 0 )"
     } // enf of "if( not Intra )"
 
-    m_blockingStrength[dir][absPartIdx] = bs;
+    blockingStrength[absPartIdx] = bs;
 }
 
-void TComLoopFilter::xEdgeFilterLuma(TComDataCU* cu, uint32_t absZOrderIdx, uint32_t depth, int dir, int edge)
+void TComLoopFilter::xEdgeFilterLuma(TComDataCU* cu, uint32_t absZOrderIdx, uint32_t depth, int dir, int edge, uint8_t blockingStrength[])
 {
     TComPicYuv* reconYuv = cu->getPic()->getPicYuvRec();
     pixel* src = reconYuv->getLumaAddr(cu->getAddr(), absZOrderIdx);
@@ -504,7 +491,7 @@
     for (uint32_t idx = 0; idx < numParts; idx++)
     {
         bsAbsIdx = xCalcBsIdx(cu, absZOrderIdx, dir, edge, idx);
-        bs = m_blockingStrength[dir][bsAbsIdx];
+        bs = blockingStrength[bsAbsIdx];
         if (bs)
         {
             qpQ = cu->getQP(bsAbsIdx);
@@ -574,7 +561,7 @@
     }
 }
 
-void TComLoopFilter::xEdgeFilterChroma(TComDataCU* cu, uint32_t absZOrderIdx, uint32_t depth, int dir, int edge)
+void TComLoopFilter::xEdgeFilterChroma(TComDataCU* cu, uint32_t absZOrderIdx, uint32_t depth, int dir, int edge, uint8_t blockingStrength[])
 {
     TComPicYuv* reconYuv = cu->getPic()->getPicYuvRec();
     int stride = reconYuv->getCStride();
@@ -638,7 +625,7 @@
     for (uint32_t idx = 0; idx < numParts; idx++)
     {
         bsAbsIdx = xCalcBsIdx(cu, absZOrderIdx, dir, edge, idx);
-        bs = m_blockingStrength[dir][bsAbsIdx];
+        bs = blockingStrength[bsAbsIdx];
 
         if (bs > 1)
         {
diff -r 9fd5f9f6e1de -r 7f213d2e3a27 source/Lib/TLibCommon/TComLoopFilter.h
--- a/source/Lib/TLibCommon/TComLoopFilter.h	Thu Jun 19 14:56:46 2014 -0700
+++ b/source/Lib/TLibCommon/TComLoopFilter.h	Thu Jun 19 14:57:03 2014 -0700
@@ -68,21 +68,19 @@
 private:
 
     uint32_t    m_numPartitions;
-    uint8_t*    m_blockingStrength[2]; ///< Bs for [Ver/Hor][Y/U/V][Blk_Idx]
-
     static bool m_bLFCrossTileBoundary;
 
 protected:
 
     /// CU-level deblocking function
-    void xDeblockCU(TComDataCU* cu, uint32_t absZOrderIdx, uint32_t depth, const int Edge, bool edgeFilter[]);
+    void xDeblockCU(TComDataCU* cu, uint32_t absZOrderIdx, uint32_t depth, const int Edge, bool edgeFilter[], uint8_t blockingStrength[]);
 
     // set / get functions
     void xSetLoopfilterParam(TComDataCU* cu, uint32_t absZOrderIdx, LFCUParam *lfcuParam);
     // filtering functions
-    void xSetEdgefilterTU(TComDataCU* cu, uint32_t absTUPartIdx, uint32_t absZOrderIdx, uint32_t depth, int dir, bool edgeFilter[]);
-    void xSetEdgefilterPU(TComDataCU* cu, uint32_t absZOrderIdx, int dir, LFCUParam *lfcuParam, bool edgeFilter[]);
-    void xGetBoundaryStrengthSingle(TComDataCU* cu, int dir, uint32_t partIdx);
+    void xSetEdgefilterTU(TComDataCU* cu, uint32_t absTUPartIdx, uint32_t absZOrderIdx, uint32_t depth, int dir, bool edgeFilter[], uint8_t blockingStrength[]);
+    void xSetEdgefilterPU(TComDataCU* cu, uint32_t absZOrderIdx, int dir, LFCUParam *lfcuParam, bool edgeFilter[], uint8_t blockingStrength[]);
+    void xGetBoundaryStrengthSingle(TComDataCU* cu, int dir, uint32_t partIdx, uint8_t blockingStrength[]);
     uint32_t xCalcBsIdx(TComDataCU* cu, uint32_t absZOrderIdx, int dir, int edgeIdx, int baseUnitIdx)
     {
         TComPic* const pic = cu->getPic();
@@ -98,10 +96,10 @@
         }
     }
 
-    void xSetEdgefilterMultiple(TComDataCU* cu, uint32_t absZOrderIdx, uint32_t depth, int dir, int edgeIdx, bool bValue, bool edgeFilter[], uint32_t widthInBaseUnits = 0);
+    void xSetEdgefilterMultiple(TComDataCU* cu, uint32_t absZOrderIdx, uint32_t depth, int dir, int edgeIdx, bool bValue, bool edgeFilter[], uint8_t blockingStrength[], uint32_t widthInBaseUnits = 0);
 
-    void xEdgeFilterLuma(TComDataCU* cu, uint32_t absZOrderIdx, uint32_t depth, int dir, int edge);
-    void xEdgeFilterChroma(TComDataCU* cu, uint32_t absZOrderIdx, uint32_t depth, int dir, int edge);
+    void xEdgeFilterLuma(TComDataCU* cu, uint32_t absZOrderIdx, uint32_t depth, int dir, int edge, uint8_t blockingStrength[]);
+    void xEdgeFilterChroma(TComDataCU* cu, uint32_t absZOrderIdx, uint32_t depth, int dir, int edge, uint8_t blockingStrength[]);
 
     inline void xPelFilterLuma(pixel* src, int offset, int tc, bool sw, bool bPartPNoFilter, bool bPartQNoFilter, int iThrCut, bool bFilterSecondP, bool bFilterSecondQ);
     inline void xPelFilterChroma(pixel* src, int offset, int tc, bool bPartPNoFilter, bool bPartQNoFilter);
@@ -124,7 +122,7 @@
     /// set configuration
     void setCfg(bool bLFCrossTileBoundary);
 
-    void loopFilterCU(TComDataCU* cu, int dir, bool edgeFilter[]);
+    void loopFilterCU(TComDataCU* cu, int dir, bool edgeFilter[], uint8_t blockingStrength[]);
 
     static int getBeta(int qp)
     {
diff -r 9fd5f9f6e1de -r 7f213d2e3a27 source/encoder/framefilter.cpp
--- a/source/encoder/framefilter.cpp	Thu Jun 19 14:56:46 2014 -0700
+++ b/source/encoder/framefilter.cpp	Thu Jun 19 14:57:03 2014 -0700
@@ -152,24 +152,25 @@
     if (m_param->bEnableLoopFilter)
     {
         bool edgeFilter[256];    // NOTE: the maximum LCU 64x64 have 256 partitions
+        uint8_t blockingStrength[256];
 
         for (uint32_t col = 0; col < numCols; col++)
         {
             const uint32_t cuAddr = lineStartCUAddr + col;
             TComDataCU* cu = m_pic->getCU(cuAddr);
 
-            m_loopFilter.loopFilterCU(cu, EDGE_VER, edgeFilter);
+            m_loopFilter.loopFilterCU(cu, EDGE_VER, edgeFilter, blockingStrength);
 
             if (col > 0)
             {
                 TComDataCU* cu_prev = m_pic->getCU(cuAddr - 1);
-                m_loopFilter.loopFilterCU(cu_prev, EDGE_HOR, edgeFilter);
+                m_loopFilter.loopFilterCU(cu_prev, EDGE_HOR, edgeFilter, blockingStrength);
             }
         }
 
         {
             TComDataCU* cu_prev = m_pic->getCU(lineStartCUAddr + numCols - 1);
-            m_loopFilter.loopFilterCU(cu_prev, EDGE_HOR, edgeFilter);
+            m_loopFilter.loopFilterCU(cu_prev, EDGE_HOR, edgeFilter, blockingStrength);
         }
     }
 



More information about the x265-devel mailing list