[x265-commits] [x265] nal: concatenate and escape row data while building row-s...

Steve Borho steve at borho.org
Tue Jun 17 07:37:01 CEST 2014


details:   http://hg.videolan.org/x265/rev/9198ff2e0125
branches:  
changeset: 7075:9198ff2e0125
user:      Steve Borho <steve at borho.org>
date:      Mon Jun 16 21:30:25 2014 -0500
description:
nal: concatenate and escape row data while building row-start array for header

This way we only need to do a single pass over each slice NAL looking for start
code emulations; and there is one less memcopy. countStartCodeEmulations() and
appendSubstream() methods could be removed.
Subject: [x265] move lfcuParam to local

details:   http://hg.videolan.org/x265/rev/4c204b14ad0e
branches:  
changeset: 7076:4c204b14ad0e
user:      Min Chen <chenm003 at 163.com>
date:      Tue Jun 17 10:18:13 2014 +0800
description:
move lfcuParam to local
Subject: [x265] move m_bEdgeFilter to local

details:   http://hg.videolan.org/x265/rev/a99fb0ffe53a
branches:  
changeset: 7077:a99fb0ffe53a
user:      Min Chen <chenm003 at 163.com>
date:      Tue Jun 17 10:18:55 2014 +0800
description:
move m_bEdgeFilter to local
Subject: [x265] cleanup unused TComLoopFilter::loopFilterPic

details:   http://hg.videolan.org/x265/rev/55ba291c2c5b
branches:  
changeset: 7078:55ba291c2c5b
user:      Min Chen <chenm003 at 163.com>
date:      Tue Jun 17 10:19:10 2014 +0800
description:
cleanup unused TComLoopFilter::loopFilterPic
Subject: [x265] writer: nits

details:   http://hg.videolan.org/x265/rev/ab8124028030
branches:  
changeset: 7079:ab8124028030
user:      Steve Borho <steve at borho.org>
date:      Tue Jun 17 00:15:47 2014 -0500
description:
writer: nits

diffstat:

 source/Lib/TLibCommon/TComBitStream.cpp      |   43 --------
 source/Lib/TLibCommon/TComBitStream.h        |    3 -
 source/Lib/TLibCommon/TComLoopFilter.cpp     |  136 ++++++++------------------
 source/Lib/TLibCommon/TComLoopFilter.h       |   17 +--
 source/Lib/TLibEncoder/SyntaxElementWriter.h |   13 +-
 source/encoder/frameencoder.cpp              |   94 ++++++++---------
 source/encoder/framefilter.cpp               |    8 +-
 source/encoder/nal.cpp                       |   53 +++++++++-
 source/encoder/nal.h                         |    3 +-
 9 files changed, 156 insertions(+), 214 deletions(-)

diffs (truncated from 695 to 300 lines):

diff -r f25ed8618509 -r ab8124028030 source/Lib/TLibCommon/TComBitStream.cpp
--- a/source/Lib/TLibCommon/TComBitStream.cpp	Mon Jun 16 20:32:13 2014 -0500
+++ b/source/Lib/TLibCommon/TComBitStream.cpp	Tue Jun 17 00:15:47 2014 -0500
@@ -134,46 +134,3 @@ void TComOutputBitstream::writeByteAlign
     write(1, 1);
     writeAlignZero();
 }
-
-int TComOutputBitstream::countStartCodeEmulations()
-{
-    int numStartCodes = 0;
-
-    for (uint32_t i = 0; i + 2 < m_byteOccupancy; i++)
-    {
-        if (!m_fifo[i] && !m_fifo[i + 1] && m_fifo[i + 2] <= 3)
-        {
-            numStartCodes++;
-            i++;
-        }
-    }
-
-    return numStartCodes;
-}
-
-void TComOutputBitstream::appendSubstream(TComOutputBitstream* substream)
-{
-    X265_CHECK(!m_partialByteBits, "appending to a non-aligned buffer\n");
-    X265_CHECK(!substream->m_partialByteBits, "appending a non-aligned buffer\n");
-
-    if (m_byteOccupancy + substream->m_byteOccupancy > m_byteAlloc)
-    {
-        /* reallocate buffer with doubled size */
-        uint8_t *temp = X265_MALLOC(uint8_t, (m_byteOccupancy + substream->m_byteOccupancy) * 2);
-        if (temp)
-        {
-            ::memcpy(temp, m_fifo, m_byteOccupancy);
-            X265_FREE(m_fifo);
-            m_fifo = temp;
-            m_byteAlloc = (m_byteOccupancy + substream->m_byteOccupancy) * 2;
-        }
-        else
-        {
-            x265_log(NULL, X265_LOG_ERROR, "Unable to realloc bitstream buffer");
-            return;
-        }
-    }
-
-    memcpy(m_fifo + m_byteOccupancy, substream->m_fifo, substream->m_byteOccupancy);
-    m_byteOccupancy += substream->m_byteOccupancy;
-}
diff -r f25ed8618509 -r ab8124028030 source/Lib/TLibCommon/TComBitStream.h
--- a/source/Lib/TLibCommon/TComBitStream.h	Mon Jun 16 20:32:13 2014 -0500
+++ b/source/Lib/TLibCommon/TComBitStream.h	Tue Jun 17 00:15:47 2014 -0500
@@ -90,9 +90,6 @@ public:
     void     writeAlignZero();     // insert zero bits until the bitstream is byte-aligned
     void     writeByteAlignment(); // insert 1 bit, then pad to byte-align with zero
 
-    void     appendSubstream(TComOutputBitstream* substream);
-    int      countStartCodeEmulations();
-
 private:
 
     uint8_t *m_fifo;
diff -r f25ed8618509 -r ab8124028030 source/Lib/TLibCommon/TComLoopFilter.cpp
--- a/source/Lib/TLibCommon/TComLoopFilter.cpp	Mon Jun 16 20:32:13 2014 -0500
+++ b/source/Lib/TLibCommon/TComLoopFilter.cpp	Tue Jun 17 00:15:47 2014 -0500
@@ -75,7 +75,6 @@ TComLoopFilter::TComLoopFilter()
     for (uint32_t dir = 0; dir < 2; dir++)
     {
         m_blockingStrength[dir] = NULL;
-        m_bEdgeFilter[dir] = NULL;
     }
 }
 
@@ -97,7 +96,6 @@ void TComLoopFilter::create(uint32_t max
     for (uint32_t dir = 0; dir < 2; dir++)
     {
         m_blockingStrength[dir] = new uint8_t[m_numPartitions];
-        m_bEdgeFilter[dir] = new bool[m_numPartitions];
     }
 }
 
@@ -107,59 +105,16 @@ void TComLoopFilter::destroy()
     {
         delete [] m_blockingStrength[dir];
         m_blockingStrength[dir] = NULL;
-        delete [] m_bEdgeFilter[dir];
-        m_bEdgeFilter[dir] = NULL;
     }
 }
 
-/**
- - call deblocking function for every CU
- .
- \param  pic   picture class (TComPic) pointer
- */
-void TComLoopFilter::loopFilterPic(TComPic* pic)
-{
-    // TODO: Min, thread parallelism later
-    // Horizontal filtering
-    for (uint32_t cuAddr = 0; cuAddr < pic->getNumCUsInFrame(); cuAddr++)
-    {
-        TComDataCU* cu = pic->getCU(cuAddr);
-
-        ::memset(m_blockingStrength[EDGE_VER], 0, sizeof(uint8_t) * m_numPartitions);
-        ::memset(m_bEdgeFilter[EDGE_VER], 0, sizeof(bool) * m_numPartitions);
-
-        // CU-based deblocking
-        xDeblockCU(cu, 0, 0, EDGE_VER);
-
-        // Vertical filtering
-        // NOTE: delay one CU to avoid conflict between V and H
-        if (cuAddr > 0)
-        {
-            cu = pic->getCU(cuAddr - 1);
-            ::memset(m_blockingStrength[EDGE_HOR], 0, sizeof(uint8_t) * m_numPartitions);
-            ::memset(m_bEdgeFilter[EDGE_HOR], 0, sizeof(bool) * m_numPartitions);
-
-            xDeblockCU(cu, 0, 0, EDGE_HOR);
-        }
-    }
-
-    // Last H-Filter
-    {
-        TComDataCU* cu = pic->getCU(pic->getNumCUsInFrame() - 1);
-        ::memset(m_blockingStrength[EDGE_HOR], 0, sizeof(uint8_t) * m_numPartitions);
-        ::memset(m_bEdgeFilter[EDGE_HOR], 0, sizeof(bool) * m_numPartitions);
-
-        xDeblockCU(cu, 0, 0, EDGE_HOR);
-    }
-}
-
-void TComLoopFilter::loopFilterCU(TComDataCU* cu, int dir)
+void TComLoopFilter::loopFilterCU(TComDataCU* cu, int dir, bool edgeFilter[])
 {
     ::memset(m_blockingStrength[dir], 0, sizeof(uint8_t) * m_numPartitions);
-    ::memset(m_bEdgeFilter[dir], 0, sizeof(bool) * m_numPartitions);
+    ::memset(edgeFilter, 0, sizeof(bool) * m_numPartitions);
 
     // CU-based deblocking
-    xDeblockCU(cu, 0, 0, dir);
+    xDeblockCU(cu, 0, 0, dir, edgeFilter);
 }
 
 // ====================================================================================================================
@@ -171,7 +126,7 @@ void TComLoopFilter::loopFilterCU(TComDa
  .
  \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, int edge)
+void TComLoopFilter::xDeblockCU(TComDataCU* cu, uint32_t absZOrderIdx, uint32_t depth, const int dir, bool edgeFilter[])
 {
     if (cu->getPic() == 0 || cu->getPartitionSize(absZOrderIdx) == SIZE_NONE)
     {
@@ -189,19 +144,20 @@ void TComLoopFilter::xDeblockCU(TComData
             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, edge);
+                xDeblockCU(cu, absZOrderIdx, depth + 1, dir, edgeFilter);
             }
         }
 
         return;
     }
 
-    xSetLoopfilterParam(cu, absZOrderIdx);
+    ///< status structure
+    LFCUParam lfcuParam;
+    xSetLoopfilterParam(cu, absZOrderIdx, &lfcuParam);
 
-    xSetEdgefilterTU(cu, absZOrderIdx, absZOrderIdx, depth);
-    xSetEdgefilterPU(cu, absZOrderIdx);
+    xSetEdgefilterTU(cu, absZOrderIdx, absZOrderIdx, depth, dir, edgeFilter);
+    xSetEdgefilterPU(cu, absZOrderIdx, dir, &lfcuParam, edgeFilter);
 
-    int dir = edge;
     for (uint32_t partIdx = absZOrderIdx; partIdx < absZOrderIdx + curNumParts; partIdx++)
     {
         uint32_t bsCheck;
@@ -214,7 +170,7 @@ void TComLoopFilter::xDeblockCU(TComData
             bsCheck = 1;
         }
 
-        if (m_bEdgeFilter[dir][partIdx] && bsCheck)
+        if (edgeFilter[partIdx] && bsCheck)
         {
             xGetBoundaryStrengthSingle(cu, dir, partIdx);
         }
@@ -224,7 +180,7 @@ void TComLoopFilter::xDeblockCU(TComData
     uint32_t partIdxIncr = DEBLOCK_SMALLEST_BLOCK / pelsInPart ? DEBLOCK_SMALLEST_BLOCK / pelsInPart : 1;
 
     uint32_t sizeInPU = pic->getNumPartInCUSize() >> (depth);
-    uint32_t shiftFactor = (edge == EDGE_VER) ? cu->getHorzChromaShift() : cu->getVertChromaShift();
+    uint32_t shiftFactor = (dir == EDGE_VER) ? cu->getHorzChromaShift() : cu->getVertChromaShift();
     const bool bAlwaysDoChroma = (cu->getChromaFormat() == CHROMA_444);
     for (uint32_t e = 0; e < sizeInPU; e += partIdxIncr)
     {
@@ -236,7 +192,7 @@ void TComLoopFilter::xDeblockCU(TComData
     }
 }
 
-void TComLoopFilter::xSetEdgefilterMultiple(TComDataCU* cu, uint32_t scanIdx, uint32_t depth, int dir, int edgeIdx, bool bValue, uint32_t widthInBaseUnits, uint32_t heightInBaseUnits)
+void TComLoopFilter::xSetEdgefilterMultiple(TComDataCU* cu, uint32_t scanIdx, uint32_t depth, int dir, int edgeIdx, bool bValue, bool edgeFilter[], uint32_t widthInBaseUnits, uint32_t heightInBaseUnits)
 {
     if (widthInBaseUnits == 0)
     {
@@ -253,7 +209,7 @@ void TComLoopFilter::xSetEdgefilterMulti
     for (uint32_t i = 0; i < numElem; i++)
     {
         const uint32_t bsidx = xCalcBsIdx(cu, scanIdx, dir, edgeIdx, i);
-        m_bEdgeFilter[dir][bsidx] = bValue;
+        edgeFilter[bsidx] = bValue;
         if (edgeIdx == 0)
         {
             m_blockingStrength[dir][bsidx] = bValue;
@@ -261,7 +217,7 @@ void TComLoopFilter::xSetEdgefilterMulti
     }
 }
 
-void TComLoopFilter::xSetEdgefilterTU(TComDataCU* cu, uint32_t absTUPartIdx, uint32_t absZOrderIdx, uint32_t depth)
+void TComLoopFilter::xSetEdgefilterTU(TComDataCU* cu, uint32_t absTUPartIdx, uint32_t absZOrderIdx, uint32_t depth, int dir, bool edgeFilter[])
 {
     if (cu->getTransformIdx(absZOrderIdx) + cu->getDepth(absZOrderIdx) > depth)
     {
@@ -270,7 +226,7 @@ void TComLoopFilter::xSetEdgefilterTU(TC
         for (uint32_t partIdx = 0; partIdx < 4; partIdx++, absZOrderIdx += qNumParts)
         {
             uint32_t nsAddr = absZOrderIdx;
-            xSetEdgefilterTU(cu, nsAddr, absZOrderIdx, depth + 1);
+            xSetEdgefilterTU(cu, nsAddr, absZOrderIdx, depth + 1, dir, edgeFilter);
         }
 
         return;
@@ -282,63 +238,55 @@ void TComLoopFilter::xSetEdgefilterTU(TC
     uint32_t widthInBaseUnits  = trWidth / (g_maxCUSize >> g_maxCUDepth);
     uint32_t heightInBaseUnits = trHeight / (g_maxCUSize >> g_maxCUDepth);
 
-    xSetEdgefilterMultiple(cu, absTUPartIdx, depth, EDGE_VER, 0, true, widthInBaseUnits, heightInBaseUnits);
-    xSetEdgefilterMultiple(cu, absTUPartIdx, depth, EDGE_HOR, 0, true, widthInBaseUnits, heightInBaseUnits);
+    xSetEdgefilterMultiple(cu, absTUPartIdx, depth, dir, 0, true, edgeFilter, widthInBaseUnits, heightInBaseUnits);
 }
 
-void TComLoopFilter::xSetEdgefilterPU(TComDataCU* cu, uint32_t absZOrderIdx)
+void TComLoopFilter::xSetEdgefilterPU(TComDataCU* cu, uint32_t absZOrderIdx, int dir, LFCUParam *lfcuParam, bool edgeFilter[])
 {
     const uint32_t depth = cu->getDepth(absZOrderIdx);
     const uint32_t widthInBaseUnits  = cu->getPic()->getNumPartInCUSize() >> depth;
-    const uint32_t heightInBaseUnits = cu->getPic()->getNumPartInCUSize() >> depth;
     const uint32_t hWidthInBaseUnits  = widthInBaseUnits  >> 1;
-    const uint32_t hHeightInBaseUnits = heightInBaseUnits >> 1;
     const uint32_t qWidthInBaseUnits  = widthInBaseUnits  >> 2;
-    const uint32_t qHeightInBaseUnits = heightInBaseUnits >> 2;
 
-    xSetEdgefilterMultiple(cu, absZOrderIdx, depth, EDGE_VER, 0, m_lfcuParam.bLeftEdge);
-    xSetEdgefilterMultiple(cu, absZOrderIdx, depth, EDGE_HOR, 0, m_lfcuParam.bTopEdge);
+    xSetEdgefilterMultiple(cu, absZOrderIdx, depth, dir, 0, (dir == EDGE_VER ? lfcuParam->bLeftEdge : lfcuParam->bTopEdge), edgeFilter);
 
-    switch (cu->getPartitionSize(absZOrderIdx))
+    int mode = cu->getPartitionSize(absZOrderIdx);
+    switch (mode)
     {
     case SIZE_2Nx2N:
     {
         break;
     }
     case SIZE_2NxN:
-    {
-        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, EDGE_HOR, hHeightInBaseUnits, true);
-        break;
-    }
     case SIZE_Nx2N:
     {
-        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, EDGE_VER, hWidthInBaseUnits, true);
+        const int realDir = (mode == SIZE_2NxN ? EDGE_HOR : EDGE_VER);
+
+        if (realDir == dir)
+            xSetEdgefilterMultiple(cu, absZOrderIdx, depth, realDir, hWidthInBaseUnits, true, edgeFilter);
         break;
     }
     case SIZE_NxN:
     {
-        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, EDGE_VER, hWidthInBaseUnits, true);
-        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, EDGE_HOR, hHeightInBaseUnits, true);
+        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, dir, hWidthInBaseUnits, true, edgeFilter);
         break;
     }
     case SIZE_2NxnU:
+    case SIZE_nLx2N:
     {
-        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, EDGE_HOR, qHeightInBaseUnits, true);
+        const int realDir = (mode == SIZE_2NxnU ? EDGE_HOR : EDGE_VER);
+
+        if (realDir == dir)
+            xSetEdgefilterMultiple(cu, absZOrderIdx, depth, dir, qWidthInBaseUnits, true, edgeFilter);
         break;
     }
     case SIZE_2NxnD:
-    {
-        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, EDGE_HOR, heightInBaseUnits - qHeightInBaseUnits, true);


More information about the x265-commits mailing list