[x265-commits] [x265] sao: fix MSVC warnings

Steve Borho steve at borho.org
Mon Aug 25 22:37:12 CEST 2014


details:   http://hg.videolan.org/x265/rev/c9cf8ae5f7a0
branches:  
changeset: 7873:c9cf8ae5f7a0
user:      Steve Borho <steve at borho.org>
date:      Fri Aug 22 12:35:48 2014 -0500
description:
sao: fix MSVC warnings
Subject: [x265] sao: fix inf loop bounds

details:   http://hg.videolan.org/x265/rev/6e6756f94b27
branches:  
changeset: 7874:6e6756f94b27
user:      Steve Borho <steve at borho.org>
date:      Fri Aug 22 15:53:34 2014 -0500
description:
sao: fix inf loop bounds
Subject: [x265] sao: simplify entropy coder initialization [CHANGES OUTPUTS]

details:   http://hg.videolan.org/x265/rev/f2fc8b1e1c3f
branches:  
changeset: 7875:f2fc8b1e1c3f
user:      Steve Borho <steve at borho.org>
date:      Fri Aug 22 01:07:32 2014 -0500
description:
sao: simplify entropy coder initialization [CHANGES OUTPUTS]

Remove the hack from the HM that preserves fract_bits from the first row to all
rows; it never made any sense and we don't pretend to be anywhere near close to
bit accurate with the HM anymore.

This commit removes the Entrppy coder in FrameFilter since it was only used by
SAO and moves it into the SAO class.  The startSaoEnc() method is removed
entirely and another call to resetEntropy() (an expensive method) is replaced
with a load of the frame encoder's m_initSliceContext
Subject: [x265] sao: nit

details:   http://hg.videolan.org/x265/rev/a683fffa5245
branches:  
changeset: 7876:a683fffa5245
user:      Steve Borho <steve at borho.org>
date:      Fri Aug 22 01:33:37 2014 -0500
description:
sao: nit
Subject: [x265] sao: remove unused m_qp member

details:   http://hg.videolan.org/x265/rev/e95c628b90ab
branches:  
changeset: 7877:e95c628b90ab
user:      Steve Borho <steve at borho.org>
date:      Fri Aug 22 18:03:32 2014 -0500
description:
sao: remove unused m_qp member
Subject: [x265] sao: nits

details:   http://hg.videolan.org/x265/rev/e1f1e836e833
branches:  
changeset: 7878:e1f1e836e833
user:      Steve Borho <steve at borho.org>
date:      Sat Aug 23 10:42:08 2014 -0500
description:
sao: nits
Subject: [x265] fix lossless

details:   http://hg.videolan.org/x265/rev/ad31cbb8c754
branches:  stable
changeset: 7879:ad31cbb8c754
user:      Satoshi Nakagawa <nakagawa424 at oki.com>
date:      Sat Aug 23 23:11:54 2014 +0900
description:
fix lossless
Subject: [x265] rc: write I/i slice in stats file based on whether openGop is enabled or not.

details:   http://hg.videolan.org/x265/rev/f0de8275ed4d
branches:  stable
changeset: 7880:f0de8275ed4d
user:      Aarthi Thirumalai
date:      Mon Aug 25 11:28:27 2014 +0530
description:
rc: write I/i slice in stats file based on whether openGop is enabled or not.
Subject: [x265] rc: don't read slicetypes from qpfile in 2nd pass.

details:   http://hg.videolan.org/x265/rev/5fe473327183
branches:  stable
changeset: 7881:5fe473327183
user:      Aarthi Thirumalai
date:      Mon Aug 25 11:59:51 2014 +0530
description:
rc: don't read slicetypes from qpfile in 2nd pass.

slicetype has to be taken from the stats file from prev pass.
Subject: [x265] Merge with stable

details:   http://hg.videolan.org/x265/rev/44433a2d65dd
branches:  
changeset: 7882:44433a2d65dd
user:      Steve Borho <steve at borho.org>
date:      Mon Aug 25 11:57:02 2014 -0500
description:
Merge with stable
Subject: [x265] replace g_rasterToPelX[g_zscanToRaster[idx]] by g_zscanToPelX[idx]

details:   http://hg.videolan.org/x265/rev/5acfb12ec5d1
branches:  
changeset: 7883:5acfb12ec5d1
user:      Satoshi Nakagawa <nakagawa424 at oki.com>
date:      Mon Aug 25 17:53:12 2014 +0900
description:
replace g_rasterToPelX[g_zscanToRaster[idx]] by g_zscanToPelX[idx]

diffstat:

 source/Lib/TLibCommon/TComDataCU.cpp |  142 ++++++++++-------------
 source/Lib/TLibCommon/TComRom.cpp    |   72 ++++++-----
 source/Lib/TLibCommon/TComRom.h      |    6 +-
 source/Lib/TLibCommon/TComYuv.h      |   12 +-
 source/common/deblock.cpp            |   12 +-
 source/common/param.cpp              |    3 -
 source/common/quant.cpp              |    4 +-
 source/common/shortyuv.h             |   10 +-
 source/common/slice.cpp              |   23 +++
 source/common/slice.h                |    2 +
 source/encoder/analysis.cpp          |   13 +-
 source/encoder/encoder.cpp           |   10 +-
 source/encoder/entropy.cpp           |   85 ++++---------
 source/encoder/frameencoder.cpp      |    7 +-
 source/encoder/frameencoder.h        |   55 ++++----
 source/encoder/framefilter.cpp       |   49 +++----
 source/encoder/framefilter.h         |   42 ++----
 source/encoder/ratecontrol.cpp       |    5 +-
 source/encoder/sao.cpp               |  205 ++++++++++++++++------------------
 source/encoder/sao.h                 |    9 +-
 source/x265.cpp                      |    2 +-
 21 files changed, 362 insertions(+), 406 deletions(-)

diffs (truncated from 1591 to 300 lines):

diff -r bad70432b1d3 -r 5acfb12ec5d1 source/Lib/TLibCommon/TComDataCU.cpp
--- a/source/Lib/TLibCommon/TComDataCU.cpp	Thu Aug 21 22:42:58 2014 -0500
+++ b/source/Lib/TLibCommon/TComDataCU.cpp	Mon Aug 25 17:53:12 2014 +0900
@@ -816,12 +816,12 @@ TComDataCU* TComDataCU::getPUAboveLeft(u
 
 TComDataCU* TComDataCU::getPUAboveRight(uint32_t& arPartUnitIdx, uint32_t curPartUnitIdx)
 {
+    if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_zscanToPelX[curPartUnitIdx] + UNIT_SIZE) >= m_slice->m_sps->picWidthInLumaSamples)
+        return NULL;
+
     uint32_t absPartIdxRT    = g_zscanToRaster[curPartUnitIdx];
     uint32_t numPartInCUSize = m_pic->getNumPartInCUSize();
 
-    if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_rasterToPelX[absPartIdxRT] + UNIT_SIZE) >= m_slice->m_sps->picWidthInLumaSamples)
-        return NULL;
-
     if (RasterAddress::lessThanCol(absPartIdxRT, numPartInCUSize - 1, numPartInCUSize))
     {
         if (!RasterAddress::isZeroRow(absPartIdxRT, numPartInCUSize))
@@ -857,14 +857,11 @@ TComDataCU* TComDataCU::getPUAboveRight(
 
 TComDataCU* TComDataCU::getPUBelowLeft(uint32_t& blPartUnitIdx, uint32_t curPartUnitIdx)
 {
-    uint32_t absPartIdxLB     = g_zscanToRaster[curPartUnitIdx];
+    if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_zscanToPelY[curPartUnitIdx] + UNIT_SIZE) >= m_slice->m_sps->picHeightInLumaSamples)
+        return NULL;
 
-    if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_rasterToPelY[absPartIdxLB] + UNIT_SIZE) >= m_slice->m_sps->picHeightInLumaSamples)
-    {
-        return NULL;
-    }
-
-    uint32_t numPartInCUSize  = m_pic->getNumPartInCUSize();
+    uint32_t absPartIdxLB    = g_zscanToRaster[curPartUnitIdx];
+    uint32_t numPartInCUSize = m_pic->getNumPartInCUSize();
 
     if (RasterAddress::lessThanRow(absPartIdxLB, numPartInCUSize - 1, numPartInCUSize))
     {
@@ -895,15 +892,14 @@ TComDataCU* TComDataCU::getPUBelowLeft(u
 
 TComDataCU* TComDataCU::getPUBelowLeftAdi(uint32_t& blPartUnitIdx,  uint32_t curPartUnitIdx, uint32_t partUnitOffset)
 {
-    uint32_t absPartIdxLB     = g_zscanToRaster[curPartUnitIdx];
-
-    if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_rasterToPelY[absPartIdxLB] + (partUnitOffset << LOG2_UNIT_SIZE)) >=
+    if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_zscanToPelY[curPartUnitIdx] + (partUnitOffset << LOG2_UNIT_SIZE)) >=
         m_slice->m_sps->picHeightInLumaSamples)
     {
         return NULL;
     }
 
-    uint32_t numPartInCUSize  = m_pic->getNumPartInCUSize();
+    uint32_t absPartIdxLB    = g_zscanToRaster[curPartUnitIdx];
+    uint32_t numPartInCUSize = m_pic->getNumPartInCUSize();
 
     if (RasterAddress::lessThanRow(absPartIdxLB, numPartInCUSize - partUnitOffset, numPartInCUSize))
     {
@@ -938,14 +934,13 @@ TComDataCU* TComDataCU::getPUBelowLeftAd
 
 TComDataCU* TComDataCU::getPUAboveRightAdi(uint32_t& arPartUnitIdx, uint32_t curPartUnitIdx, uint32_t partUnitOffset)
 {
-    uint32_t absPartIdxRT    = g_zscanToRaster[curPartUnitIdx];
-
-    if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_rasterToPelX[absPartIdxRT] + (partUnitOffset << LOG2_UNIT_SIZE)) >=
+    if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_zscanToPelX[curPartUnitIdx] + (partUnitOffset << LOG2_UNIT_SIZE)) >=
         m_slice->m_sps->picWidthInLumaSamples)
     {
         return NULL;
     }
 
+    uint32_t absPartIdxRT    = g_zscanToRaster[curPartUnitIdx];
     uint32_t numPartInCUSize = m_pic->getNumPartInCUSize();
 
     if (RasterAddress::lessThanCol(absPartIdxRT, numPartInCUSize - partUnitOffset, numPartInCUSize))
@@ -954,7 +949,7 @@ TComDataCU* TComDataCU::getPUAboveRightA
         {
             if (curPartUnitIdx > g_rasterToZscan[absPartIdxRT - numPartInCUSize + partUnitOffset])
             {
-                uint32_t absZorderCUIdx  = g_zscanToRaster[m_absIdxInLCU] + (1 << (m_log2CUSize[0] - LOG2_UNIT_SIZE)) - 1;
+                uint32_t absZorderCUIdx = g_zscanToRaster[m_absIdxInLCU] + (1 << (m_log2CUSize[0] - LOG2_UNIT_SIZE)) - 1;
                 arPartUnitIdx = g_rasterToZscan[absPartIdxRT - numPartInCUSize + partUnitOffset];
                 if (RasterAddress::isEqualRowOrCol(absPartIdxRT, absZorderCUIdx, numPartInCUSize))
                 {
@@ -1817,48 +1812,42 @@ void TComDataCU::getInterMergeCandidates
     }
     // TMVP always enabled
     {
-        //>> MTK colocated-RightBottom
+        MV colmv;
         uint32_t partIdxRB;
 
         deriveRightBottomIdx(puIdx, partIdxRB);
 
-        uint32_t absPartIdxTmp = g_zscanToRaster[partIdxRB];
-        uint32_t numPartInCUSize = m_pic->getNumPartInCUSize();
-
-        MV colmv;
-        int refIdx;
         int lcuIdx = -1;
 
-        if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_rasterToPelX[absPartIdxTmp] + UNIT_SIZE) >= m_slice->m_sps->picWidthInLumaSamples)  // image boundary check
+        // image boundary check
+        if (m_pic->getCU(m_cuAddr)->getCUPelX() + g_zscanToPelX[partIdxRB] + UNIT_SIZE < m_slice->m_sps->picWidthInLumaSamples &&
+            m_pic->getCU(m_cuAddr)->getCUPelY() + g_zscanToPelY[partIdxRB] + UNIT_SIZE < m_slice->m_sps->picHeightInLumaSamples)
         {
-        }
-        else if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_rasterToPelY[absPartIdxTmp] + UNIT_SIZE) >= m_slice->m_sps->picHeightInLumaSamples)
-        {
-        }
-        else
-        {
-            if ((absPartIdxTmp % numPartInCUSize < numPartInCUSize - 1) &&        // is not at the last column of LCU
-                (absPartIdxTmp / numPartInCUSize < numPartInCUSize - 1)) // is not at the last row    of LCU
+            uint32_t absPartIdxRB = g_zscanToRaster[partIdxRB];
+            uint32_t numPartInCUSize = m_pic->getNumPartInCUSize();
+            bool bNotLastCol = RasterAddress::lessThanCol(absPartIdxRB, numPartInCUSize - 1, numPartInCUSize); // is not at the last column of LCU
+            bool bNotLastRow = RasterAddress::lessThanRow(absPartIdxRB, numPartInCUSize - 1, numPartInCUSize); // is not at the last row    of LCU
+
+            if (bNotLastCol && bNotLastRow)
             {
-                absPartAddr = g_rasterToZscan[absPartIdxTmp + numPartInCUSize + 1];
+                absPartAddr = g_rasterToZscan[absPartIdxRB + numPartInCUSize + 1];
                 lcuIdx = getAddr();
             }
-            else if (absPartIdxTmp % numPartInCUSize < numPartInCUSize - 1)       // is not at the last column of LCU But is last row of LCU
-                absPartAddr = g_rasterToZscan[(absPartIdxTmp + numPartInCUSize + 1) % m_pic->getNumPartInCU()];
-            else if (absPartIdxTmp / numPartInCUSize < numPartInCUSize - 1) // is not at the last row of LCU But is last column of LCU
+            else if (bNotLastCol)
+                absPartAddr = g_rasterToZscan[(absPartIdxRB + numPartInCUSize + 1) & (numPartInCUSize - 1)];
+            else if (bNotLastRow)
             {
-                absPartAddr = g_rasterToZscan[absPartIdxTmp + 1];
+                absPartAddr = g_rasterToZscan[absPartIdxRB + 1];
                 lcuIdx = getAddr() + 1;
             }
-            else //is the right bottom corner of LCU
+            else // is the right bottom corner of LCU
                 absPartAddr = 0;
         }
 
-        refIdx = 0;
+        int refIdx = 0;
         uint32_t partIdxCenter;
         uint32_t curLCUIdx = getAddr();
         int dir = 0;
-        uint32_t arrayAddr = count;
         xDeriveCenterIdx(puIdx, partIdxCenter);
         bool bExistMV = lcuIdx >= 0 && xGetColMVP(REF_PIC_LIST_0, lcuIdx, absPartAddr, colmv, refIdx);
         if (!bExistMV)
@@ -1866,7 +1855,7 @@ void TComDataCU::getInterMergeCandidates
         if (bExistMV)
         {
             dir |= 1;
-            mvFieldNeighbours[arrayAddr][0].setMvField(colmv, refIdx);
+            mvFieldNeighbours[count][0].setMvField(colmv, refIdx);
         }
 
         if (isInterB)
@@ -1878,13 +1867,13 @@ void TComDataCU::getInterMergeCandidates
             if (bExistMV)
             {
                 dir |= 2;
-                mvFieldNeighbours[arrayAddr][1].setMvField(colmv, refIdx);
+                mvFieldNeighbours[count][1].setMvField(colmv, refIdx);
             }
         }
 
         if (dir != 0)
         {
-            interDirNeighbours[arrayAddr] = dir;
+            interDirNeighbours[count] = dir;
 
             count++;
         
@@ -1893,8 +1882,6 @@ void TComDataCU::getInterMergeCandidates
         }
     }
 
-    uint32_t arrayAddr = count;
-
     if (isInterB)
     {
         const uint32_t cutoff = count * (count - 1);
@@ -1917,13 +1904,13 @@ void TComDataCU::getInterMergeCandidates
                 int refPOCL1 = m_slice->m_refPOCList[1][refIdxL1];
                 if (!(refPOCL0 == refPOCL1 && mvFieldNeighbours[i][0].mv == mvFieldNeighbours[j][1].mv))
                 {
-                    mvFieldNeighbours[arrayAddr][0].setMvField(mvFieldNeighbours[i][0].mv, refIdxL0);
-                    mvFieldNeighbours[arrayAddr][1].setMvField(mvFieldNeighbours[j][1].mv, refIdxL1);
-                    interDirNeighbours[arrayAddr] = 3;
+                    mvFieldNeighbours[count][0].setMvField(mvFieldNeighbours[i][0].mv, refIdxL0);
+                    mvFieldNeighbours[count][1].setMvField(mvFieldNeighbours[j][1].mv, refIdxL1);
+                    interDirNeighbours[count] = 3;
 
-                    arrayAddr++;
+                    count++;
 
-                    if (arrayAddr == maxNumMergeCand)
+                    if (count == maxNumMergeCand)
                         return;
                 }
             }
@@ -1932,18 +1919,18 @@ void TComDataCU::getInterMergeCandidates
     int numRefIdx = (isInterB) ? X265_MIN(m_slice->m_numRefIdx[0], m_slice->m_numRefIdx[1]) : m_slice->m_numRefIdx[0];
     int r = 0;
     int refcnt = 0;
-    while (arrayAddr < maxNumMergeCand)
+    while (count < maxNumMergeCand)
     {
-        interDirNeighbours[arrayAddr] = 1;
-        mvFieldNeighbours[arrayAddr][0].setMvField(MV(0, 0), r);
+        interDirNeighbours[count] = 1;
+        mvFieldNeighbours[count][0].setMvField(MV(0, 0), r);
 
         if (isInterB)
         {
-            interDirNeighbours[arrayAddr] = 3;
-            mvFieldNeighbours[arrayAddr][1].setMvField(MV(0, 0), r);
+            interDirNeighbours[count] = 3;
+            mvFieldNeighbours[count][1].setMvField(MV(0, 0), r);
         }
 
-        arrayAddr++;
+        count++;
 
         if (refcnt == numRefIdx - 1)
             r = 0;
@@ -2078,45 +2065,40 @@ int TComDataCU::fillMvpCand(uint32_t par
 
     // TMVP always enabled
     {
-        // Get Temporal Motion Predictor
-        int refIdxCol = refIdx;
-        MV  colmv;
+        uint32_t absPartAddr = m_absIdxInLCU + partAddr;
+        MV colmv;
         uint32_t partIdxRB;
-        uint32_t absPartIdx;
-        uint32_t absPartAddr;
 
         deriveRightBottomIdx(partIdx, partIdxRB);
-        absPartAddr = m_absIdxInLCU + partAddr;
 
         //----  co-located RightBottom Temporal Predictor (H) ---//
-        absPartIdx = g_zscanToRaster[partIdxRB];
         int lcuIdx = -1;
-        if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_rasterToPelX[absPartIdx] + UNIT_SIZE) >= m_slice->m_sps->picWidthInLumaSamples)  // image boundary check
+
+        // image boundary check
+        if (m_pic->getCU(m_cuAddr)->getCUPelX() + g_zscanToPelX[partIdxRB] + UNIT_SIZE < m_slice->m_sps->picWidthInLumaSamples &&
+            m_pic->getCU(m_cuAddr)->getCUPelY() + g_zscanToPelY[partIdxRB] + UNIT_SIZE < m_slice->m_sps->picHeightInLumaSamples)
         {
-        }
-        else if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_rasterToPelY[absPartIdx] + UNIT_SIZE) >= m_slice->m_sps->picHeightInLumaSamples)
-        {
-        }
-        else
-        {
+            uint32_t absPartIdxRB = g_zscanToRaster[partIdxRB];
             uint32_t numPartInCUSize = m_pic->getNumPartInCUSize();
-            if ((absPartIdx % numPartInCUSize < numPartInCUSize - 1) && // is not at the last column of LCU
-                (absPartIdx / numPartInCUSize < numPartInCUSize - 1))   // is not at the last row    of LCU
+            bool bNotLastCol = RasterAddress::lessThanCol(absPartIdxRB, numPartInCUSize - 1, numPartInCUSize); // is not at the last column of LCU
+            bool bNotLastRow = RasterAddress::lessThanRow(absPartIdxRB, numPartInCUSize - 1, numPartInCUSize); // is not at the last row    of LCU
+
+            if (bNotLastCol && bNotLastRow)
             {
-                absPartAddr = g_rasterToZscan[absPartIdx + numPartInCUSize + 1];
+                absPartAddr = g_rasterToZscan[absPartIdxRB + numPartInCUSize + 1];
                 lcuIdx = getAddr();
             }
-            else if (absPartIdx % numPartInCUSize < numPartInCUSize - 1) // is not at the last column of LCU But is last row of LCU
-                absPartAddr = g_rasterToZscan[(absPartIdx + numPartInCUSize + 1) % m_pic->getNumPartInCU()];
-            else if (absPartIdx / numPartInCUSize < numPartInCUSize - 1) // is not at the last row of LCU But is last column of LCU
+            else if (bNotLastCol)
+                absPartAddr = g_rasterToZscan[(absPartIdxRB + numPartInCUSize + 1) & (numPartInCUSize - 1)];
+            else if (bNotLastRow)
             {
-                absPartAddr = g_rasterToZscan[absPartIdx + 1];
+                absPartAddr = g_rasterToZscan[absPartIdxRB + 1];
                 lcuIdx = getAddr() + 1;
             }
             else // is the right bottom corner of LCU
                 absPartAddr = 0;
         }
-        if (lcuIdx >= 0 && xGetColMVP(picList, lcuIdx, absPartAddr, colmv, refIdxCol))
+        if (lcuIdx >= 0 && xGetColMVP(picList, lcuIdx, absPartAddr, colmv, refIdx))
         {
             amvpCand[num++] = colmv;
             mvc[numMvc++] = colmv;
@@ -2126,7 +2108,7 @@ int TComDataCU::fillMvpCand(uint32_t par
             uint32_t partIdxCenter;
             uint32_t curLCUIdx = getAddr();
             xDeriveCenterIdx(partIdx, partIdxCenter);
-            if (xGetColMVP(picList, curLCUIdx, partIdxCenter, colmv, refIdxCol))
+            if (xGetColMVP(picList, curLCUIdx, partIdxCenter, colmv, refIdx))
             {
                 amvpCand[num++] = colmv;
                 mvc[numMvc++] = colmv;
diff -r bad70432b1d3 -r 5acfb12ec5d1 source/Lib/TLibCommon/TComRom.cpp


More information about the x265-commits mailing list