[x265-commits] [x265] use std::swap() for readability

Satoshi Nakagawa nakagawa424 at oki.com
Thu Jul 10 08:40:15 CEST 2014


details:   http://hg.videolan.org/x265/rev/194432db28b9
branches:  
changeset: 7281:194432db28b9
user:      Satoshi Nakagawa <nakagawa424 at oki.com>
date:      Wed Jul 09 18:27:26 2014 +0900
description:
use std::swap() for readability
Subject: [x265] entropy: remove m_ prefix from struct TURecurse members

details:   http://hg.videolan.org/x265/rev/e776ead24445
branches:  
changeset: 7282:e776ead24445
user:      Steve Borho <steve at borho.org>
date:      Wed Jul 09 23:52:05 2014 -0500
description:
entropy: remove m_ prefix from struct TURecurse members
Subject: [x265] entropy: replace SBac and TEncSearch methods with TURecurse methods

details:   http://hg.videolan.org/x265/rev/657bfd3423a5
branches:  
changeset: 7283:657bfd3423a5
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 10 00:15:54 2014 -0500
description:
entropy: replace SBac and TEncSearch methods with TURecurse methods

Both classes had nearly the exact same methods for managing this external
structure.  how wierd?
Subject: [x265] TEncSearch: nits

details:   http://hg.videolan.org/x265/rev/9914e8d8e2e4
branches:  
changeset: 7284:9914e8d8e2e4
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 10 00:17:14 2014 -0500
description:
TEncSearch: nits
Subject: [x265] entropy: convert initSection into a constructor, since it was used as such

details:   http://hg.videolan.org/x265/rev/ac568c7796b8
branches:  
changeset: 7285:ac568c7796b8
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 10 00:20:58 2014 -0500
description:
entropy: convert initSection into a constructor, since it was used as such
Subject: [x265] merge CABAC into SBac class

details:   http://hg.videolan.org/x265/rev/ef1b1da7264c
branches:  
changeset: 7286:ef1b1da7264c
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 10 00:44:40 2014 -0500
description:
merge CABAC into SBac class
Subject: [x265] entropy: hoist trivial functions for later optimizations

details:   http://hg.videolan.org/x265/rev/898fc94ae9e9
branches:  
changeset: 7287:898fc94ae9e9
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 10 00:52:41 2014 -0500
description:
entropy: hoist trivial functions for later optimizations
Subject: [x265] entropy: nits

details:   http://hg.videolan.org/x265/rev/8084d123f14d
branches:  
changeset: 7288:8084d123f14d
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 10 00:52:47 2014 -0500
description:
entropy: nits
Subject: [x265] TComTrQuant: rename estBitsSbacStruct to EstBitsSbac

details:   http://hg.videolan.org/x265/rev/4fcd24d23994
branches:  
changeset: 7289:4fcd24d23994
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 10 01:02:58 2014 -0500
description:
TComTrQuant: rename estBitsSbacStruct to EstBitsSbac
Subject: [x265] entropy: remove include of TComSampleAdaptiveOffset.h

details:   http://hg.videolan.org/x265/rev/6c95abc53d26
branches:  
changeset: 7290:6c95abc53d26
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 10 01:08:58 2014 -0500
description:
entropy: remove include of TComSampleAdaptiveOffset.h
Subject: [x265] entropy: re-order methods again for better clarity, make many private

details:   http://hg.videolan.org/x265/rev/dd179bdba7fd
branches:  
changeset: 7291:dd179bdba7fd
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 10 01:33:27 2014 -0500
description:
entropy: re-order methods again for better clarity, make many private
Subject: [x265] entropy: nits

details:   http://hg.videolan.org/x265/rev/cbfe2ac89d41
branches:  
changeset: 7292:cbfe2ac89d41
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 10 01:33:35 2014 -0500
description:
entropy: nits

diffstat:

 source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp  |   20 +-
 source/Lib/TLibCommon/TComSampleAdaptiveOffset.h    |    4 +-
 source/Lib/TLibCommon/TComTrQuant.cpp               |    2 +-
 source/Lib/TLibCommon/TComTrQuant.h                 |    6 +-
 source/Lib/TLibEncoder/TEncCu.cpp                   |   29 +-
 source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp |   10 +-
 source/Lib/TLibEncoder/TEncSearch.cpp               |  277 ++++++---------
 source/Lib/TLibEncoder/TEncSearch.h                 |    3 -
 source/encoder/compress.cpp                         |   98 +----
 source/encoder/cturow.h                             |    4 +-
 source/encoder/entropy.cpp                          |  346 ++++++-------------
 source/encoder/entropy.h                            |  200 ++++++-----
 source/encoder/framefilter.cpp                      |    8 +-
 13 files changed, 386 insertions(+), 621 deletions(-)

diffs (truncated from 2430 to 300 lines):

diff -r 30e20a7b6fdd -r cbfe2ac89d41 source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp
--- a/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp	Wed Jul 09 20:33:52 2014 -0500
+++ b/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp	Thu Jul 10 01:33:35 2014 -0500
@@ -535,12 +535,10 @@ void TComSampleAdaptiveOffset::processSa
     int isChroma = (yCbCr != 0) ? 1 : 0;
     int shift;
     int cuHeightTmp;
-    pixel* tmpLSwap;
     pixel* tmpL;
     pixel* tmpU;
     pixel* clipTbl = NULL;
     int32_t *offsetBo = NULL;
-    int32_t *tmp_swap;
 
     picWidthTmp  = (isChroma == 0) ? m_picWidth  : m_picWidth  >> m_hChromaShift;
     picHeightTmp = (isChroma == 0) ? m_picHeight : m_picHeight >> m_vChromaShift;
@@ -707,9 +705,7 @@ void TComSampleAdaptiveOffset::processSa
 
             m_upBufft[startX] = signDown2;
 
-            tmp_swap  = m_upBuff1;
-            m_upBuff1 = m_upBufft;
-            m_upBufft = tmp_swap;
+            std::swap(m_upBuff1, m_upBufft);
 
             rec += stride;
         }
@@ -775,9 +771,7 @@ void TComSampleAdaptiveOffset::processSa
 
 //   if (iSaoType!=SAO_BO_0 || iSaoType!=SAO_BO_1)
     {
-        tmpLSwap = m_tmpL1;
-        m_tmpL1  = m_tmpL2;
-        m_tmpL2  = tmpLSwap;
+        std::swap(m_tmpL1, m_tmpL2);
     }
 }
 
@@ -864,7 +858,6 @@ void TComSampleAdaptiveOffset::processSa
     int frameWidthInCU = m_pic->getFrameWidthInCU();
     int frameHeightInCU = m_pic->getFrameHeightInCU();
     int stride;
-    pixel *tmpUSwap;
     int sChroma = (yCbCr == 0) ? 0 : 1;
     bool mergeLeftFlag;
     int saoBitIncrease = (yCbCr == 0) ? m_saoBitIncreaseY : m_saoBitIncreaseC;
@@ -976,9 +969,7 @@ void TComSampleAdaptiveOffset::processSa
             }
         }
 
-        tmpUSwap       = m_tmpU1[yCbCr];
-        m_tmpU1[yCbCr] = m_tmpU2[yCbCr];
-        m_tmpU2[yCbCr] = tmpUSwap;
+        std::swap(m_tmpU1[yCbCr], m_tmpU2[yCbCr]);
     }
 }
 
@@ -1018,7 +1009,6 @@ void TComSampleAdaptiveOffset::processSa
     int addr;
     int frameWidthInCU = m_pic->getFrameWidthInCU();
     int stride;
-    pixel *tmpUSwap;
     int sChroma = (yCbCr == 0) ? 0 : 1;
     bool mergeLeftFlag;
     int saoBitIncrease = (yCbCr == 0) ? m_saoBitIncreaseY : m_saoBitIncreaseC;
@@ -1122,9 +1112,7 @@ void TComSampleAdaptiveOffset::processSa
             }
         }
 
-        tmpUSwap       = m_tmpU1[yCbCr];
-        m_tmpU1[yCbCr] = m_tmpU2[yCbCr];
-        m_tmpU2[yCbCr] = tmpUSwap;
+        std::swap(m_tmpU1[yCbCr], m_tmpU2[yCbCr]);
     }
 }
 
diff -r 30e20a7b6fdd -r cbfe2ac89d41 source/Lib/TLibCommon/TComSampleAdaptiveOffset.h
--- a/source/Lib/TLibCommon/TComSampleAdaptiveOffset.h	Wed Jul 09 20:33:52 2014 -0500
+++ b/source/Lib/TLibCommon/TComSampleAdaptiveOffset.h	Thu Jul 10 01:33:35 2014 -0500
@@ -95,7 +95,7 @@ typedef struct _SaoQTPart
     //---- encoder only end -----//
 } SAOQTPart;
 
-typedef struct _SaoLcuParam
+struct SaoLcuParam
 {
     bool       mergeUpFlag;
     bool       mergeLeftFlag;
@@ -117,7 +117,7 @@ typedef struct _SaoLcuParam
         offset[2]     = 0;
         offset[3]     = 0;
     }
-} SaoLcuParam;
+};
 
 struct SAOParam
 {
diff -r 30e20a7b6fdd -r cbfe2ac89d41 source/Lib/TLibCommon/TComTrQuant.cpp
--- a/source/Lib/TLibCommon/TComTrQuant.cpp	Wed Jul 09 20:33:52 2014 -0500
+++ b/source/Lib/TLibCommon/TComTrQuant.cpp	Thu Jul 10 01:33:35 2014 -0500
@@ -77,7 +77,7 @@ TComTrQuant::TComTrQuant()
     m_tmpCoeff = X265_MALLOC(int32_t, MAX_CU_SIZE * MAX_CU_SIZE);
 
     // allocate bit estimation class (for RDOQ)
-    m_estBitsSbac = new estBitsSbacStruct;
+    m_estBitsSbac = new EstBitsSbac;
     initScalingList();
 }
 
diff -r 30e20a7b6fdd -r cbfe2ac89d41 source/Lib/TLibCommon/TComTrQuant.h
--- a/source/Lib/TLibCommon/TComTrQuant.h	Wed Jul 09 20:33:52 2014 -0500
+++ b/source/Lib/TLibCommon/TComTrQuant.h	Thu Jul 10 01:33:35 2014 -0500
@@ -59,7 +59,7 @@ namespace x265 {
 // Type definition
 // ====================================================================================================================
 
-typedef struct
+struct EstBitsSbac
 {
     int significantCoeffGroupBits[NUM_SIG_CG_FLAG_CTX][2];
     uint32_t significantBits[NUM_SIG_FLAG_CTX][2];
@@ -70,7 +70,7 @@ typedef struct
 
     int blockCbpBits[NUM_QT_CBF_CTX][2];
     int blockRootCbpBits[NUM_QT_ROOT_CBF_CTX][2];
-} estBitsSbacStruct;
+};
 
 // ====================================================================================================================
 // Class definition
@@ -197,7 +197,7 @@ public:
         }
     }
 
-    estBitsSbacStruct* m_estBitsSbac;
+    EstBitsSbac*    m_estBitsSbac;
 
     NoiseReduction* m_nr;
 
diff -r 30e20a7b6fdd -r cbfe2ac89d41 source/Lib/TLibEncoder/TEncCu.cpp
--- a/source/Lib/TLibEncoder/TEncCu.cpp	Wed Jul 09 20:33:52 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncCu.cpp	Thu Jul 10 01:33:35 2014 -0500
@@ -1252,19 +1252,9 @@ void TEncCu::xCheckRDCostMerge2Nx2N(TCom
                     uint64_t bestCost = m_rdCost->psyRdEnabled() ? outBestCU->m_totalPsyCost : outBestCU->m_totalRDCost;
                     if (tempCost < bestCost)
                     {
-                        TComDataCU* tmp = outTempCU;
-                        outTempCU = outBestCU;
-                        outBestCU = tmp;
-
-                        // Change Prediction data
-                        TComYuv* yuv = NULL;
-                        yuv = outBestPredYuv;
-                        outBestPredYuv = m_tmpPredYuv[depth];
-                        m_tmpPredYuv[depth] = yuv;
-
-                        yuv = rpcYuvReconBest;
-                        rpcYuvReconBest = m_tmpRecoYuv[depth];
-                        m_tmpRecoYuv[depth] = yuv;
+                        std::swap(outBestCU, outTempCU);
+                        std::swap(outBestPredYuv, m_tmpPredYuv[depth]);
+                        std::swap(rpcYuvReconBest, m_tmpRecoYuv[depth]);
                         
                         m_rdSbacCoders[depth][CI_TEMP_BEST].store(m_rdSbacCoders[depth][CI_NEXT_BEST]);
                     }                    
@@ -1438,21 +1428,14 @@ void TEncCu::xCheckBestMode(TComDataCU*&
 
     if (tempCost < bestCost)
     {
-        TComYuv* yuv;
         // Change Information data
-        TComDataCU* cu = outBestCU;
-        outBestCU = outTempCU;
-        outTempCU = cu;
+        std::swap(outBestCU, outTempCU);
 
         // Change Prediction data
-        yuv = m_bestPredYuv[depth];
-        m_bestPredYuv[depth] = m_tmpPredYuv[depth];
-        m_tmpPredYuv[depth] = yuv;
+        std::swap(m_bestPredYuv[depth], m_tmpPredYuv[depth]);
 
         // Change Reconstruction data
-        yuv = m_bestRecoYuv[depth];
-        m_bestRecoYuv[depth] = m_tmpRecoYuv[depth];
-        m_tmpRecoYuv[depth] = yuv;
+        std::swap(m_bestRecoYuv[depth], m_tmpRecoYuv[depth]);
 
         m_rdSbacCoders[depth][CI_TEMP_BEST].store(m_rdSbacCoders[depth][CI_NEXT_BEST]);
     }
diff -r 30e20a7b6fdd -r cbfe2ac89d41 source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp
--- a/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp	Wed Jul 09 20:33:52 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp	Thu Jul 10 01:33:35 2014 -0500
@@ -524,7 +524,6 @@ void TEncSampleAdaptiveOffset::calcSaoSt
     int iEndX;
     int iEndY;
     pixel* pTableBo = (yCbCr == 0) ? m_lumaTableBo : m_chromaTableBo;
-    int32_t *tmp_swap;
 
     int iIsChroma = (yCbCr != 0) ? 1 : 0;
     int numSkipLine = iIsChroma ? 4 - (2 * m_vChromaShift) : 4;
@@ -714,9 +713,7 @@ void TEncSampleAdaptiveOffset::calcSaoSt
                 }
 
                 m_upBufft[iStartX] = iSignDown2;
-                tmp_swap  = m_upBuff1;
-                m_upBuff1 = m_upBufft;
-                m_upBufft = tmp_swap;
+                std::swap(m_upBuff1, m_upBufft);
 
                 pRec += stride;
                 fenc += stride;
@@ -802,7 +799,6 @@ void TEncSampleAdaptiveOffset::calcSaoSt
     uint32_t lPelX, tPelY;
     TComDataCU *pTmpCu;
     pixel* pTableBo;
-    int32_t *tmp_swap;
 
     // NOTE: Row
     {
@@ -1012,9 +1008,7 @@ void TEncSampleAdaptiveOffset::calcSaoSt
                     }
 
                     m_upBufft[firstX] = signDown2;
-                    tmp_swap  = m_upBuff1;
-                    m_upBuff1 = m_upBufft;
-                    m_upBufft = tmp_swap;
+                    std::swap(m_upBuff1, m_upBufft);
 
                     pRec += stride;
                     fenc += stride;
diff -r 30e20a7b6fdd -r cbfe2ac89d41 source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp	Wed Jul 09 20:33:52 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp	Thu Jul 10 01:33:35 2014 -0500
@@ -1069,13 +1069,12 @@ void TEncSearch::xRecurIntraChromaCoding
         uint32_t singlePsyEnergy = 0;
         for (uint32_t chromaId = TEXT_CHROMA_U; chromaId <= TEXT_CHROMA_V; chromaId++)
         {
-            TURecurse tuIterator;
-            uint32_t curPartNum = cu->getPic()->getNumPartInCU() >> ((cu->getDepth(0) +  trDepthC) << 1);
-            initSection(&tuIterator, splitIntoSubTUs ? VERTICAL_SPLIT : DONT_SPLIT, curPartNum, absPartIdx);
+            uint32_t curPartNum = cu->getPic()->getNumPartInCU() >> ((cu->getDepth(0) + trDepthC) << 1);
+            TURecurse tuIterator(splitIntoSubTUs ? VERTICAL_SPLIT : DONT_SPLIT, curPartNum, absPartIdx);
 
             do
             {
-                uint32_t absPartIdxC = tuIterator.m_absPartIdxTURelCU;
+                uint32_t absPartIdxC = tuIterator.absPartIdxTURelCU;
                 pixel*   pred        = predYuv->getChromaAddr(chromaId, absPartIdxC);
 
                 //===== init availability pattern =====
@@ -1124,11 +1123,11 @@ void TEncSearch::xRecurIntraChromaCoding
                         int16_t* recon = (chromaModeId ? tsReconC : reconQt);
                         uint32_t reconStride = (chromaModeId ? tuSize : reconQtStride);
 
-                        cu->setTransformSkipPartRange(chromaModeId, (TextType)chromaId, absPartIdxC, tuIterator.m_absPartIdxStep);
+                        cu->setTransformSkipPartRange(chromaModeId, (TextType)chromaId, absPartIdxC, tuIterator.absPartIdxStep);
 
                         singleDistCTmp = 0;
                         xIntraCodingChromaBlk(cu, absPartIdxC, fencYuv, predYuv, resiYuv, recon, reconStride, coeff, singleCbfCTmp, singleDistCTmp, chromaId, log2TrSizeC);
-                        cu->setCbfPartRange(singleCbfCTmp << trDepth, (TextType)chromaId, absPartIdxC, tuIterator.m_absPartIdxStep);
+                        cu->setCbfPartRange(singleCbfCTmp << trDepth, (TextType)chromaId, absPartIdxC, tuIterator.absPartIdxStep);
 
                         if (chromaModeId == 1 && singleCbfCTmp == 0)
                             //In order not to code TS flag when cbf is zero, the case for TS with cbf being zero is forbidden.
@@ -1164,7 +1163,7 @@ void TEncSearch::xRecurIntraChromaCoding
                     if (bestModeId == firstCheckId)
                     {
                         xLoadIntraResultChromaQT(cu, absPartIdxC, log2TrSizeC, chromaId, reconQt, reconQtStride);
-                        cu->setCbfPartRange(singleCbfC << trDepth, (TextType)chromaId, absPartIdxC, tuIterator.m_absPartIdxStep);
+                        cu->setCbfPartRange(singleCbfC << trDepth, (TextType)chromaId, absPartIdxC, tuIterator.absPartIdxStep);
                         m_rdGoOnSbacCoder->load(m_rdSbacCoders[fullDepth][CI_TEMP_BEST]);
                     }
                     else
@@ -1174,7 +1173,7 @@ void TEncSearch::xRecurIntraChromaCoding
                         primitives.square_copy_ss[sizeIdxC](reconQt, reconQtStride, tsReconC, tuSize);
                     }
 
-                    cu->setTransformSkipPartRange(bestModeId, (TextType)chromaId, absPartIdxC, tuIterator.m_absPartIdxStep);
+                    cu->setTransformSkipPartRange(bestModeId, (TextType)chromaId, absPartIdxC, tuIterator.absPartIdxStep);
 
                     outDist += singleDistC;
 
@@ -1183,7 +1182,7 @@ void TEncSearch::xRecurIntraChromaCoding
                 }
                 else
                 {
-                    cu->setTransformSkipPartRange(0, (TextType)chromaId, absPartIdxC, tuIterator.m_absPartIdxStep);
+                    cu->setTransformSkipPartRange(0, (TextType)chromaId, absPartIdxC, tuIterator.absPartIdxStep);
                     xIntraCodingChromaBlk(cu, absPartIdxC, fencYuv, predYuv, resiYuv, reconQt, reconQtStride, coeffC, singleCbfC, outDist, chromaId, log2TrSizeC);
                     if (m_rdCost->psyRdEnabled())
                     {
@@ -1191,11 +1190,11 @@ void TEncSearch::xRecurIntraChromaCoding
                         singlePsyEnergyTmp = m_rdCost->psyCost(log2TrSizeC - 2, fencYuv->getChromaAddr(chromaId, absPartIdxC), fencYuv->getCStride(),
                             cu->getPic()->getPicYuvRec()->getChromaAddr(chromaId, cu->getAddr(), zorder), cu->getPic()->getPicYuvRec()->getCStride());
                     }
-                    cu->setCbfPartRange(singleCbfC << trDepth, (TextType)chromaId, absPartIdxC, tuIterator.m_absPartIdxStep);
+                    cu->setCbfPartRange(singleCbfC << trDepth, (TextType)chromaId, absPartIdxC, tuIterator.absPartIdxStep);
                 }
                 singlePsyEnergy += singlePsyEnergyTmp;


More information about the x265-commits mailing list