[x265-commits] [x265] rest: fix typo

Steve Borho steve at borho.org
Tue May 13 06:59:28 CEST 2014


details:   http://hg.videolan.org/x265/rev/8b75aa2cc06d
branches:  
changeset: 6850:8b75aa2cc06d
user:      Steve Borho <steve at borho.org>
date:      Mon May 12 06:49:53 2014 -0500
description:
rest: fix typo
Subject: [x265] reduce xModeBitsIntra() call

details:   http://hg.videolan.org/x265/rev/dd1635326993
branches:  
changeset: 6851:dd1635326993
user:      Satoshi Nakagawa <nakagawa424 at oki.com>
date:      Fri May 09 16:49:26 2014 +0900
description:
reduce xModeBitsIntra() call
Subject: [x265] ratecontrol: do not low-clip first I frame with ABR

details:   http://hg.videolan.org/x265/rev/4fe2705adb5b
branches:  
changeset: 6852:4fe2705adb5b
user:      Steve Borho <steve at borho.org>
date:      Mon May 12 06:51:16 2014 -0500
description:
ratecontrol: do not low-clip first I frame with ABR
Subject: [x265] refine intra reference samples

details:   http://hg.videolan.org/x265/rev/e0a3b7e79d4d
branches:  
changeset: 6853:e0a3b7e79d4d
user:      Satoshi Nakagawa <nakagawa424 at oki.com>
date:      Sat May 10 15:27:26 2014 +0900
description:
refine intra reference samples
Subject: [x265] fix 4:2:2 coeff rate calc

details:   http://hg.videolan.org/x265/rev/a4d0d5679c28
branches:  
changeset: 6854:a4d0d5679c28
user:      Satoshi Nakagawa <nakagawa424 at oki.com>
date:      Sun May 11 17:32:37 2014 +0900
description:
fix 4:2:2 coeff rate calc

diffstat:

 doc/reST/api.rst                         |    2 +-
 source/Lib/TLibCommon/CommonDef.h        |    1 +
 source/Lib/TLibCommon/TComDataCU.cpp     |    4 +-
 source/Lib/TLibCommon/TComDataCU.h       |    2 +-
 source/Lib/TLibCommon/TComPattern.cpp    |  317 +++++++++++++-----------------
 source/Lib/TLibCommon/TComPattern.h      |   32 ++-
 source/Lib/TLibCommon/TComPrediction.cpp |   83 +++----
 source/Lib/TLibCommon/TComPrediction.h   |    8 +-
 source/Lib/TLibEncoder/TEncSbac.cpp      |    2 +-
 source/Lib/TLibEncoder/TEncSearch.cpp    |  232 ++++++++++++----------
 source/Lib/TLibEncoder/TEncSearch.h      |    3 +-
 source/encoder/compress.cpp              |   48 ++--
 source/encoder/ratecontrol.cpp           |    5 +-
 13 files changed, 355 insertions(+), 384 deletions(-)

diffs (truncated from 1485 to 300 lines):

diff -r e7f11c87d7db -r a4d0d5679c28 doc/reST/api.rst
--- a/doc/reST/api.rst	Sun May 11 22:09:22 2014 -0500
+++ b/doc/reST/api.rst	Sun May 11 17:32:37 2014 +0900
@@ -13,7 +13,7 @@ variables and enumerations meant to be u
 in this header.
 
 Where possible, x265 has tried to keep its public API as close as
-possible to x264'a public API. So those familiar with using x264 through
+possible to x264's public API. So those familiar with using x264 through
 its C interface will find x265 quite familiar.
 
 This file is meant to be read in-order; the narrative follows linearly
diff -r e7f11c87d7db -r a4d0d5679c28 source/Lib/TLibCommon/CommonDef.h
--- a/source/Lib/TLibCommon/CommonDef.h	Sun May 11 22:09:22 2014 -0500
+++ b/source/Lib/TLibCommon/CommonDef.h	Sun May 11 17:32:37 2014 +0900
@@ -100,6 +100,7 @@
 
 #define FAST_UDI_MAX_RDMODE_NUM     35 ///< maximum number of RD comparison in fast-UDI estimation loop
 
+#define ALL_IDX                     -1
 #define PLANAR_IDX                  0
 #define VER_IDX                     26 // index for intra VERTICAL   mode
 #define HOR_IDX                     10 // index for intra HORIZONTAL mode
diff -r e7f11c87d7db -r a4d0d5679c28 source/Lib/TLibCommon/TComDataCU.cpp
--- a/source/Lib/TLibCommon/TComDataCU.cpp	Sun May 11 22:09:22 2014 -0500
+++ b/source/Lib/TLibCommon/TComDataCU.cpp	Sun May 11 17:32:37 2014 +0900
@@ -1188,11 +1188,11 @@ void TComDataCU::getAllowedChromaDir(uin
 *\param   mode          it is set with MPM mode in case both MPM are equal. It is used to restrict RD search at encode side.
 *\returns Number of MPM
 */
-int TComDataCU::getIntraDirLumaPredictor(uint32_t absPartIdx, int32_t* intraDirPred)
+int TComDataCU::getIntraDirLumaPredictor(uint32_t absPartIdx, uint32_t* intraDirPred)
 {
     TComDataCU* tempCU;
     uint32_t    tempPartIdx;
-    int         leftIntraDir, aboveIntraDir;
+    uint32_t    leftIntraDir, aboveIntraDir;
 
     // Get intra direction of left PU
     tempCU = getPULeft(tempPartIdx, m_absIdxInLCU + absPartIdx);
diff -r e7f11c87d7db -r a4d0d5679c28 source/Lib/TLibCommon/TComDataCU.h
--- a/source/Lib/TLibCommon/TComDataCU.h	Sun May 11 22:09:22 2014 -0500
+++ b/source/Lib/TLibCommon/TComDataCU.h	Sun May 11 17:32:37 2014 +0900
@@ -431,7 +431,7 @@ public:
     // -------------------------------------------------------------------------------------------------------------------
 
     void          getAllowedChromaDir(uint32_t absPartIdx, uint32_t* modeList);
-    int           getIntraDirLumaPredictor(uint32_t absPartIdx, int32_t* intraDirPred);
+    int           getIntraDirLumaPredictor(uint32_t absPartIdx, uint32_t* intraDirPred);
 
     // -------------------------------------------------------------------------------------------------------------------
     // member functions for SBAC context
diff -r e7f11c87d7db -r a4d0d5679c28 source/Lib/TLibCommon/TComPattern.cpp
--- a/source/Lib/TLibCommon/TComPattern.cpp	Sun May 11 22:09:22 2014 -0500
+++ b/source/Lib/TLibCommon/TComPattern.cpp	Sun May 11 17:32:37 2014 +0900
@@ -38,6 +38,7 @@
 #include "TComPic.h"
 #include "TComPattern.h"
 #include "TComDataCU.h"
+#include "TComPrediction.h"
 
 using namespace x265;
 
@@ -49,116 +50,84 @@ using namespace x265;
 // ====================================================================================================================
 
 void TComPattern::initAdiPattern(TComDataCU* cu, uint32_t zOrderIdxInPart, uint32_t partDepth, pixel* adiBuf,
-                                 int strideOrig, int heightOrig)
+                                 pixel* refAbove, pixel* refLeft, pixel* refAboveFlt, pixel* refLeftFlt, int dirMode)
 {
     pixel* roiOrigin;
     pixel* adiTemp;
-    uint32_t cuWidth = cu->getCUSize(0) >> partDepth;
-    uint32_t cuHeight = cu->getCUSize(0) >> partDepth;
-    uint32_t cuWidth2 = cuWidth << 1;
-    uint32_t cuHeight2 = cuHeight << 1;
 
-    uint32_t width;
-    uint32_t height;
-    int  picStride = cu->getPic()->getStride();
-    bool bNeighborFlags[4 * MAX_NUM_SPU_W + 1];
-    int  numIntraNeighbor = 0;
+    int picStride = cu->getPic()->getStride();
 
-    uint32_t partIdxLT, partIdxRT, partIdxLB;
+    IntraNeighbors intraNeighbors;
 
-    cu->deriveLeftRightTopIdxAdi(partIdxLT, partIdxRT, zOrderIdxInPart, partDepth);
-
-    int  partIdxStride   = cu->getPic()->getNumPartInCUSize();
-    int  baseUnitSize    = g_maxCUSize >> g_maxCUDepth;
-    int  unitWidth       = baseUnitSize;
-    int  unitHeight      = baseUnitSize;
-    int  cuHeightInUnits = cuHeight / unitHeight;
-    int  cuWidthInUnits  = cuWidth / unitWidth;
-    int  iAboveUnits     = cuWidthInUnits << 1;
-    int  leftUnits       = cuHeightInUnits << 1;
-    partIdxLB            = g_rasterToZscan[g_zscanToRaster[partIdxLT] + ((cuHeightInUnits - 1) * partIdxStride)];
-
-    if (!cu->getSlice()->getPPS()->getConstrainedIntraPred())
-    {
-        bNeighborFlags[leftUnits] = isAboveLeftAvailable(cu, partIdxLT);
-        numIntraNeighbor += (int)(bNeighborFlags[leftUnits]);
-        numIntraNeighbor += isAboveAvailable(cu, partIdxLT, partIdxRT, (bNeighborFlags + leftUnits + 1));
-        numIntraNeighbor += isAboveRightAvailable(cu, partIdxLT, partIdxRT, (bNeighborFlags + leftUnits + 1 + cuWidthInUnits));
-        numIntraNeighbor += isLeftAvailable(cu, partIdxLT, partIdxLB, (bNeighborFlags + leftUnits - 1));
-        numIntraNeighbor += isBelowLeftAvailable(cu, partIdxLT, partIdxLB, (bNeighborFlags + leftUnits   - 1 - cuHeightInUnits));
-    }
-    else
-    {
-        bNeighborFlags[leftUnits] = isAboveLeftAvailableCIP(cu, partIdxLT);
-        numIntraNeighbor += (int)(bNeighborFlags[leftUnits]);
-        numIntraNeighbor += isAboveAvailableCIP(cu, partIdxLT, partIdxRT, (bNeighborFlags + leftUnits + 1));
-        numIntraNeighbor += isAboveRightAvailableCIP(cu, partIdxLT, partIdxRT, (bNeighborFlags + leftUnits + 1 + cuWidthInUnits));
-        numIntraNeighbor += isLeftAvailableCIP(cu, partIdxLT, partIdxLB, (bNeighborFlags + leftUnits - 1));
-        numIntraNeighbor += isBelowLeftAvailableCIP(cu, partIdxLT, partIdxLB, (bNeighborFlags + leftUnits   - 1 - cuHeightInUnits));
-    }
-
-    width = cuWidth2 + 1;
-    height = cuHeight2 + 1;
-
-    if (((width << 2) > strideOrig) || ((height << 2) > heightOrig))
-    {
-        return;
-    }
+    initIntraNeighbors(cu, zOrderIdxInPart, partDepth, TEXT_LUMA, &intraNeighbors);
+    uint32_t tuSize = intraNeighbors.tuSize;
+    uint32_t tuSize2 = tuSize << 1;
 
     roiOrigin = cu->getPic()->getPicYuvRec()->getLumaAddr(cu->getAddr(), cu->getZorderIdxInCU() + zOrderIdxInPart);
     adiTemp   = adiBuf;
 
-    fillReferenceSamples(roiOrigin, adiTemp, bNeighborFlags, numIntraNeighbor, unitWidth, unitHeight, iAboveUnits, leftUnits,
-                         cuWidth, cuHeight, width, height, picStride);
+    fillReferenceSamples(roiOrigin, picStride, adiTemp, intraNeighbors);
 
-    // generate filtered intra prediction samples
-    // left and left above border + above and above right border + top left corner = length of 3. filter buffer
-    int bufSize = cuHeight2 + cuWidth2 + 1;
-    uint32_t wh = ADI_BUF_STRIDE * height;         // number of elements in one buffer
+    bool bUseFilteredPredictions = (dirMode == ALL_IDX || TComPrediction::filteringIntraReferenceSamples(dirMode, tuSize));
 
-    pixel* filteredBuf1 = adiBuf + wh;         // 1. filter buffer
-    pixel* filteredBuf2 = filteredBuf1 + wh; // 2. filter buffer
-    pixel* filterBuf = filteredBuf2 + wh;    // buffer for 2. filtering (sequential)
-    pixel* filterBufN = filterBuf + bufSize; // buffer for 1. filtering (sequential)
+    if (bUseFilteredPredictions && 8 <= tuSize && tuSize <= 32)
+    {
+        // generate filtered intra prediction samples
+        // left and left above border + above and above right border + top left corner = length of 3. filter buffer
+        int bufSize = tuSize2 + tuSize2 + 1;
+        uint32_t wh = ADI_BUF_STRIDE * (tuSize2 + 1);         // number of elements in one buffer
 
-    int l = 0;
-    // left border from bottom to top
-    for (int i = 0; i < cuHeight2; i++)
-    {
-        filterBuf[l++] = adiTemp[ADI_BUF_STRIDE * (cuHeight2 - i)];
-    }
+        pixel* filterBuf  = adiBuf + wh;         // buffer for 2. filtering (sequential)
+        pixel* filterBufN = filterBuf + bufSize; // buffer for 1. filtering (sequential)
 
-    // top left corner
-    filterBuf[l++] = adiTemp[0];
+        int l = 0;
+        // left border from bottom to top
+        for (int i = 0; i < tuSize2; i++)
+        {
+            filterBuf[l++] = adiTemp[ADI_BUF_STRIDE * (tuSize2 - i)];
+        }
 
-    // above border from left to right
-    memcpy(&filterBuf[l], &adiTemp[1], cuWidth2 * sizeof(*filterBuf));
+        // top left corner
+        filterBuf[l++] = adiTemp[0];
 
-    if (cu->getSlice()->getSPS()->getUseStrongIntraSmoothing())
-    {
-        int blkSize = 32;
-        int bottomLeft = filterBuf[0];
-        int topLeft = filterBuf[cuHeight2];
-        int topRight = filterBuf[bufSize - 1];
-        int threshold = 1 << (X265_DEPTH - 5);
-        bool bilinearLeft = abs(bottomLeft + topLeft - 2 * filterBuf[cuHeight]) < threshold;
-        bool bilinearAbove  = abs(topLeft + topRight - 2 * filterBuf[cuHeight2 + cuHeight]) < threshold;
+        // above border from left to right
+        memcpy(&filterBuf[l], &adiTemp[1], tuSize2 * sizeof(*filterBuf));
 
-        if (cuWidth >= blkSize && (bilinearLeft && bilinearAbove))
+        if (tuSize >= 32 && cu->getSlice()->getSPS()->getUseStrongIntraSmoothing())
         {
-            int shift = g_convertToBit[cuWidth] + 3; // log2(uiCuHeight2)
-            filterBufN[0] = filterBuf[0];
-            filterBufN[cuHeight2] = filterBuf[cuHeight2];
-            filterBufN[bufSize - 1] = filterBuf[bufSize - 1];
-            //TODO: Performance Primitive???
-            for (int i = 1; i < cuHeight2; i++)
+            int bottomLeft = filterBuf[0];
+            int topLeft = filterBuf[tuSize2];
+            int topRight = filterBuf[bufSize - 1];
+            int threshold = 1 << (X265_DEPTH - 5);
+            bool bilinearLeft = abs(bottomLeft + topLeft - 2 * filterBuf[tuSize]) < threshold;
+            bool bilinearAbove  = abs(topLeft + topRight - 2 * filterBuf[tuSize2 + tuSize]) < threshold;
+
+            if (bilinearLeft && bilinearAbove)
             {
-                filterBufN[i] = ((cuHeight2 - i) * bottomLeft + i * topLeft + cuHeight) >> shift;
+                int shift = g_convertToBit[tuSize] + 3; // log2(tuSize2)
+                filterBufN[0] = filterBuf[0];
+                filterBufN[tuSize2] = filterBuf[tuSize2];
+                filterBufN[bufSize - 1] = filterBuf[bufSize - 1];
+                //TODO: Performance Primitive???
+                for (int i = 1; i < tuSize2; i++)
+                {
+                    filterBufN[i] = ((tuSize2 - i) * bottomLeft + i * topLeft + tuSize) >> shift;
+                }
+
+                for (int i = 1; i < tuSize2; i++)
+                {
+                    filterBufN[tuSize2 + i] = ((tuSize2 - i) * topLeft + i * topRight + tuSize) >> shift;
+                }
             }
-
-            for (int i = 1; i < cuWidth2; i++)
+            else
             {
-                filterBufN[cuHeight2 + i] = ((cuWidth2 - i) * topLeft + i * topRight + cuWidth) >> shift;
+                // 1. filtering with [1 2 1]
+                filterBufN[0] = filterBuf[0];
+                filterBufN[bufSize - 1] = filterBuf[bufSize - 1];
+                for (int i = 1; i < bufSize - 1; i++)
+                {
+                    filterBufN[i] = (filterBuf[i - 1] + 2 * filterBuf[i] + filterBuf[i + 1] + 2) >> 2;
+                }
             }
         }
         else
@@ -171,165 +140,151 @@ void TComPattern::initAdiPattern(TComDat
                 filterBufN[i] = (filterBuf[i - 1] + 2 * filterBuf[i] + filterBuf[i + 1] + 2) >> 2;
             }
         }
-    }
-    else
-    {
-        // 1. filtering with [1 2 1]
-        filterBufN[0] = filterBuf[0];
-        filterBufN[bufSize - 1] = filterBuf[bufSize - 1];
-        for (int i = 1; i < bufSize - 1; i++)
+
+        // initialization of ADI buffers
+        refAboveFlt += tuSize - 1;
+        refLeftFlt += tuSize - 1;
+        memcpy(refAboveFlt, filterBufN + tuSize2, (tuSize2 + 1) * sizeof(pixel));
+        for (int k = 0; k < tuSize2 + 1; k++)
         {
-            filterBufN[i] = (filterBuf[i - 1] + 2 * filterBuf[i] + filterBuf[i + 1] + 2) >> 2;
+            refLeftFlt[k] = filterBufN[tuSize2 - k];   // Smoothened
         }
     }
 
-    // fill 1. filter buffer with filtered values
-    l = 0;
-    for (int i = 0; i < cuHeight2; i++)
-    {
-        filteredBuf1[ADI_BUF_STRIDE * (cuHeight2 - i)] = filterBufN[l++];
-    }
+    // initialization of ADI buffers
+    refAbove += tuSize - 1;
+    refLeft += tuSize - 1;
 
-    filteredBuf1[0] = filterBufN[l++];
-    memcpy(&filteredBuf1[1], &filterBufN[l], cuWidth2 * sizeof(*filteredBuf1));
-}
-
-// Overloaded initialization of ADI buffers to support buffered references for xpredIntraAngBufRef
-void TComPattern::initAdiPattern(TComDataCU* cu, uint32_t zOrderIdxInPart, uint32_t partDepth, pixel* adiBuf, int strideOrig, int heightOrig,
-                                 pixel* refAbove, pixel* refLeft, pixel* refAboveFlt, pixel* refLeftFlt)
-{
-    initAdiPattern(cu, zOrderIdxInPart, partDepth, adiBuf, strideOrig, heightOrig);
-    uint32_t cuWidth   = cu->getCUSize(0) >> partDepth;
-    uint32_t cuHeight  = cu->getCUSize(0) >> partDepth;
-    uint32_t cuWidth2  = cuWidth << 1;
-    uint32_t cuHeight2 = cuHeight << 1;
-
-    refAbove += cuWidth - 1;
-    refAboveFlt += cuWidth - 1;
-    refLeft += cuWidth - 1;
-    refLeftFlt += cuWidth - 1;
-
-    //  ADI_BUF_STRIDE * (2 * height + 1);
-    memcpy(refAbove, adiBuf, (cuWidth2 + 1) * sizeof(pixel));
-    memcpy(refAboveFlt, adiBuf + ADI_BUF_STRIDE * (2 * cuHeight + 1), (cuWidth2 + 1) * sizeof(pixel));
-
-    for (int k = 0; k < cuHeight2 + 1; k++)
+    //  ADI_BUF_STRIDE * (2 * tuSize + 1);
+    memcpy(refAbove, adiBuf, (tuSize2 + 1) * sizeof(pixel));
+    for (int k = 0; k < tuSize2 + 1; k++)
     {
         refLeft[k] = adiBuf[k * ADI_BUF_STRIDE];
-        refLeftFlt[k] = (adiBuf + ADI_BUF_STRIDE * (cuHeight2 + 1))[k * ADI_BUF_STRIDE];   // Smoothened


More information about the x265-commits mailing list