[x265] cip: add is*AvailableCIP()

Satoshi Nakagawa nakagawa424 at oki.com
Wed Apr 9 11:06:27 CEST 2014


# HG changeset patch
# User Satoshi Nakagawa <nakagawa424 at oki.com>
# Date 1397034101 -32400
#      Wed Apr 09 18:01:41 2014 +0900
# Node ID 0d2bf32b01da417e824eca95e053eb6a8966a7aa
# Parent  bdca492dc1d7f0e1d2df34d5d1d97a86e7e6a29f
cip: add is*AvailableCIP()

simplify no CIP case.

diff -r bdca492dc1d7 -r 0d2bf32b01da source/Lib/TLibCommon/TComDataCU.cpp
--- a/source/Lib/TLibCommon/TComDataCU.cpp	Wed Apr 09 14:06:29 2014 +0530
+++ b/source/Lib/TLibCommon/TComDataCU.cpp	Wed Apr 09 18:01:41 2014 +0900
@@ -884,7 +884,6 @@
 
     if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_rasterToPelX[absPartIdxRT] + m_pic->getUnitSize()) >= m_slice->getSPS()->getPicWidthInLumaSamples())
     {
-        arPartUnitIdx = MAX_UINT;
         return NULL;
     }
 
@@ -905,7 +904,6 @@
                     return this;
                 }
             }
-            arPartUnitIdx = MAX_UINT;
             return NULL;
         }
         arPartUnitIdx = g_rasterToZscan[absPartIdxRT + m_pic->getNumPartInCU() - numPartInCUSize + 1];
@@ -918,7 +916,6 @@
 
     if (!RasterAddress::isZeroRow(absPartIdxRT, numPartInCUSize))
     {
-        arPartUnitIdx = MAX_UINT;
         return NULL;
     }
 
@@ -939,7 +936,6 @@
 
     if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_rasterToPelY[absPartIdxLB] + m_pic->getUnitSize()) >= m_slice->getSPS()->getPicHeightInLumaSamples())
     {
-        blPartUnitIdx = MAX_UINT;
         return NULL;
     }
 
@@ -960,7 +956,6 @@
                     return this;
                 }
             }
-            blPartUnitIdx = MAX_UINT;
             return NULL;
         }
         blPartUnitIdx = g_rasterToZscan[absPartIdxLB + numPartInCUSize * 2 - 1];
@@ -971,7 +966,6 @@
         return m_cuLeft;
     }
 
-    blPartUnitIdx = MAX_UINT;
     return NULL;
 }
 
@@ -984,7 +978,6 @@
     if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_rasterToPelY[absPartIdxLB] + (partUnitOffset << m_pic->getPicSym()->getLog2UnitSize())) >=
         m_slice->getSPS()->getPicHeightInLumaSamples())
     {
-        blPartUnitIdx = MAX_UINT;
         return NULL;
     }
 
@@ -1005,7 +998,6 @@
                     return this;
                 }
             }
-            blPartUnitIdx = MAX_UINT;
             return NULL;
         }
         blPartUnitIdx = g_rasterToZscan[absPartIdxLB + (1 + partUnitOffset) * numPartInCUSize - 1];
@@ -1016,7 +1008,6 @@
         return m_cuLeft;
     }
 
-    blPartUnitIdx = MAX_UINT;
     return NULL;
 }
 
@@ -1029,7 +1020,6 @@
     if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_rasterToPelX[absPartIdxRT] + (partUnitOffset << m_pic->getPicSym()->getLog2UnitSize())) >=
         m_slice->getSPS()->getPicWidthInLumaSamples())
     {
-        arPartUnitIdx = MAX_UINT;
         return NULL;
     }
 
@@ -1050,7 +1040,6 @@
                     return this;
                 }
             }
-            arPartUnitIdx = MAX_UINT;
             return NULL;
         }
         arPartUnitIdx = g_rasterToZscan[absPartIdxRT + m_pic->getNumPartInCU() - numPartInCUSize + partUnitOffset];
@@ -1063,7 +1052,6 @@
 
     if (!RasterAddress::isZeroRow(absPartIdxRT, numPartInCUSize))
     {
-        arPartUnitIdx = MAX_UINT;
         return NULL;
     }
 
diff -r bdca492dc1d7 -r 0d2bf32b01da source/Lib/TLibCommon/TComPattern.cpp
--- a/source/Lib/TLibCommon/TComPattern.cpp	Wed Apr 09 14:06:29 2014 +0530
+++ b/source/Lib/TLibCommon/TComPattern.cpp	Wed Apr 09 18:01:41 2014 +0900
@@ -75,12 +75,24 @@
     numUnitsInCU  = cuWidth / unitSize;
     totalUnits    = (numUnitsInCU << 2) + 1;
 
-    bNeighborFlags[numUnitsInCU * 2] = isAboveLeftAvailable(cu, partIdxLT);
-    numIntraNeighbor  += (int)(bNeighborFlags[numUnitsInCU * 2]);
-    numIntraNeighbor  += isAboveAvailable(cu, partIdxLT, partIdxRT, bNeighborFlags + (numUnitsInCU * 2) + 1);
-    numIntraNeighbor  += isAboveRightAvailable(cu, partIdxLT, partIdxRT, bNeighborFlags + (numUnitsInCU * 3) + 1);
-    numIntraNeighbor  += isLeftAvailable(cu, partIdxLT, partIdxLB, bNeighborFlags + (numUnitsInCU * 2) - 1);
-    numIntraNeighbor  += isBelowLeftAvailable(cu, partIdxLT, partIdxLB, bNeighborFlags + numUnitsInCU   - 1);
+    if (!cu->getSlice()->getPPS()->getConstrainedIntraPred())
+    {
+        bNeighborFlags[numUnitsInCU * 2] = isAboveLeftAvailable(cu, partIdxLT);
+        numIntraNeighbor += (int)(bNeighborFlags[numUnitsInCU * 2]);
+        numIntraNeighbor += isAboveAvailable(cu, partIdxLT, partIdxRT, bNeighborFlags + (numUnitsInCU * 2) + 1);
+        numIntraNeighbor += isAboveRightAvailable(cu, partIdxLT, partIdxRT, bNeighborFlags + (numUnitsInCU * 3) + 1);
+        numIntraNeighbor += isLeftAvailable(cu, partIdxLT, partIdxLB, bNeighborFlags + (numUnitsInCU * 2) - 1);
+        numIntraNeighbor += isBelowLeftAvailable(cu, partIdxLT, partIdxLB, bNeighborFlags + numUnitsInCU   - 1);
+    }
+    else
+    {
+        bNeighborFlags[numUnitsInCU * 2] = isAboveLeftAvailableCIP(cu, partIdxLT);
+        numIntraNeighbor += (int)(bNeighborFlags[numUnitsInCU * 2]);
+        numIntraNeighbor += isAboveAvailableCIP(cu, partIdxLT, partIdxRT, bNeighborFlags + (numUnitsInCU * 2) + 1);
+        numIntraNeighbor += isAboveRightAvailableCIP(cu, partIdxLT, partIdxRT, bNeighborFlags + (numUnitsInCU * 3) + 1);
+        numIntraNeighbor += isLeftAvailableCIP(cu, partIdxLT, partIdxLB, bNeighborFlags + (numUnitsInCU * 2) - 1);
+        numIntraNeighbor += isBelowLeftAvailableCIP(cu, partIdxLT, partIdxLB, bNeighborFlags + numUnitsInCU   - 1);
+    }
 
     width = cuWidth2 + 1;
     height = cuHeight2 + 1;
@@ -229,12 +241,24 @@
     numUnitsInCU  = (cuWidth / unitSize) >> cu->getHorzChromaShift();           // for chroma
     totalUnits    = (numUnitsInCU << 2) + 1;
 
-    bNeighborFlags[numUnitsInCU * 2] = isAboveLeftAvailable(cu, partIdxLT);
-    numIntraNeighbor += (int)(bNeighborFlags[numUnitsInCU * 2]);
-    numIntraNeighbor += isAboveAvailable(cu, partIdxLT, partIdxRT, bNeighborFlags + (numUnitsInCU * 2) + 1);
-    numIntraNeighbor += isAboveRightAvailable(cu, partIdxLT, partIdxRT, bNeighborFlags + (numUnitsInCU * 3) + 1);
-    numIntraNeighbor += isLeftAvailable(cu, partIdxLT, partIdxLB, bNeighborFlags + (numUnitsInCU * 2) - 1);
-    numIntraNeighbor += isBelowLeftAvailable(cu, partIdxLT, partIdxLB, bNeighborFlags + numUnitsInCU   - 1);
+    if (!cu->getSlice()->getPPS()->getConstrainedIntraPred())
+    {
+        bNeighborFlags[numUnitsInCU * 2] = isAboveLeftAvailable(cu, partIdxLT);
+        numIntraNeighbor += (int)(bNeighborFlags[numUnitsInCU * 2]);
+        numIntraNeighbor += isAboveAvailable(cu, partIdxLT, partIdxRT, bNeighborFlags + (numUnitsInCU * 2) + 1);
+        numIntraNeighbor += isAboveRightAvailable(cu, partIdxLT, partIdxRT, bNeighborFlags + (numUnitsInCU * 3) + 1);
+        numIntraNeighbor += isLeftAvailable(cu, partIdxLT, partIdxLB, bNeighborFlags + (numUnitsInCU * 2) - 1);
+        numIntraNeighbor += isBelowLeftAvailable(cu, partIdxLT, partIdxLB, bNeighborFlags + numUnitsInCU   - 1);
+    }
+    else
+    {
+        bNeighborFlags[numUnitsInCU * 2] = isAboveLeftAvailableCIP(cu, partIdxLT);
+        numIntraNeighbor += (int)(bNeighborFlags[numUnitsInCU * 2]);
+        numIntraNeighbor += isAboveAvailableCIP(cu, partIdxLT, partIdxRT, bNeighborFlags + (numUnitsInCU * 2) + 1);
+        numIntraNeighbor += isAboveRightAvailableCIP(cu, partIdxLT, partIdxRT, bNeighborFlags + (numUnitsInCU * 3) + 1);
+        numIntraNeighbor += isLeftAvailableCIP(cu, partIdxLT, partIdxLB, bNeighborFlags + (numUnitsInCU * 2) - 1);
+        numIntraNeighbor += isBelowLeftAvailableCIP(cu, partIdxLT, partIdxLB, bNeighborFlags + numUnitsInCU   - 1);
+    }
 
     cuWidth = cuWidth >> cu->getHorzChromaShift(); // for chroma
     cuHeight = cuHeight >> cu->getVertChromaShift(); // for chroma
@@ -415,19 +439,10 @@
 
 bool TComPattern::isAboveLeftAvailable(TComDataCU* cu, uint32_t partIdxLT)
 {
-    bool bAboveLeftFlag;
     uint32_t partAboveLeft;
     TComDataCU* pcCUAboveLeft = cu->getPUAboveLeft(partAboveLeft, partIdxLT);
 
-    if (cu->getSlice()->getPPS()->getConstrainedIntraPred())
-    {
-        bAboveLeftFlag = (pcCUAboveLeft && pcCUAboveLeft->getPredictionMode(partAboveLeft) == MODE_INTRA);
-    }
-    else
-    {
-        bAboveLeftFlag = (pcCUAboveLeft ? true : false);
-    }
-    return bAboveLeftFlag;
+    return (pcCUAboveLeft ? true : false);
 }
 
 int TComPattern::isAboveAvailable(TComDataCU* cu, uint32_t partIdxLT, uint32_t partIdxRT, bool *bValidFlags)
@@ -442,29 +457,14 @@
     {
         uint32_t uiPartAbove;
         TComDataCU* pcCUAbove = cu->getPUAbove(uiPartAbove, g_rasterToZscan[rasterPart]);
-        if (cu->getSlice()->getPPS()->getConstrainedIntraPred())
+        if (pcCUAbove)
         {
-            if (pcCUAbove && pcCUAbove->getPredictionMode(uiPartAbove) == MODE_INTRA)
-            {
-                numIntra++;
-                *validFlagPtr = true;
-            }
-            else
-            {
-                *validFlagPtr = false;
-            }
+            numIntra++;
+            *validFlagPtr = true;
         }
         else
         {
-            if (pcCUAbove)
-            {
-                numIntra++;
-                *validFlagPtr = true;
-            }
-            else
-            {
-                *validFlagPtr = false;
-            }
+            *validFlagPtr = false;
         }
         validFlagPtr++;
     }
@@ -484,29 +484,14 @@
     {
         uint32_t partLeft;
         TComDataCU* pcCULeft = cu->getPULeft(partLeft, g_rasterToZscan[rasterPart]);
-        if (cu->getSlice()->getPPS()->getConstrainedIntraPred())
+        if (pcCULeft)
         {
-            if (pcCULeft && pcCULeft->getPredictionMode(partLeft) == MODE_INTRA)
-            {
-                numIntra++;
-                *validFlagPtr = true;
-            }
-            else
-            {
-                *validFlagPtr = false;
-            }
+            numIntra++;
+            *validFlagPtr = true;
         }
         else
         {
-            if (pcCULeft)
-            {
-                numIntra++;
-                *validFlagPtr = true;
-            }
-            else
-            {
-                *validFlagPtr = false;
-            }
+            *validFlagPtr = false;
         }
         validFlagPtr--; // opposite direction
     }
@@ -524,29 +509,14 @@
     {
         uint32_t uiPartAboveRight;
         TComDataCU* pcCUAboveRight = cu->getPUAboveRightAdi(uiPartAboveRight, partIdxRT, offset);
-        if (cu->getSlice()->getPPS()->getConstrainedIntraPred())
+        if (pcCUAboveRight)
         {
-            if (pcCUAboveRight && pcCUAboveRight->getPredictionMode(uiPartAboveRight) == MODE_INTRA)
-            {
-                numIntra++;
-                *validFlagPtr = true;
-            }
-            else
-            {
-                *validFlagPtr = false;
-            }
+            numIntra++;
+            *validFlagPtr = true;
         }
         else
         {
-            if (pcCUAboveRight)
-            {
-                numIntra++;
-                *validFlagPtr = true;
-            }
-            else
-            {
-                *validFlagPtr = false;
-            }
+            *validFlagPtr = false;
         }
         validFlagPtr++;
     }
@@ -564,29 +534,126 @@
     {
         uint32_t uiPartBelowLeft;
         TComDataCU* pcCUBelowLeft = cu->getPUBelowLeftAdi(uiPartBelowLeft, partIdxLB, offset);
-        if (cu->getSlice()->getPPS()->getConstrainedIntraPred())
+        if (pcCUBelowLeft)
         {
-            if (pcCUBelowLeft && pcCUBelowLeft->getPredictionMode(uiPartBelowLeft) == MODE_INTRA)
-            {
-                numIntra++;
-                *validFlagPtr = true;
-            }
-            else
-            {
-                *validFlagPtr = false;
-            }
+            numIntra++;
+            *validFlagPtr = true;
         }
         else
         {
-            if (pcCUBelowLeft)
-            {
-                numIntra++;
-                *validFlagPtr = true;
-            }
-            else
-            {
-                *validFlagPtr = false;
-            }
+            *validFlagPtr = false;
+        }
+        validFlagPtr--; // opposite direction
+    }
+
+    return numIntra;
+}
+
+bool TComPattern::isAboveLeftAvailableCIP(TComDataCU* cu, uint32_t partIdxLT)
+{
+    uint32_t partAboveLeft;
+    TComDataCU* pcCUAboveLeft = cu->getPUAboveLeft(partAboveLeft, partIdxLT);
+
+    return (pcCUAboveLeft && pcCUAboveLeft->isIntra(partAboveLeft));
+}
+
+int TComPattern::isAboveAvailableCIP(TComDataCU* cu, uint32_t partIdxLT, uint32_t partIdxRT, bool *bValidFlags)
+{
+    const uint32_t rasterPartBegin = g_zscanToRaster[partIdxLT];
+    const uint32_t rasterPartEnd = g_zscanToRaster[partIdxRT] + 1;
+    const uint32_t idxStep = 1;
+    bool *validFlagPtr = bValidFlags;
+    int numIntra = 0;
+
+    for (uint32_t rasterPart = rasterPartBegin; rasterPart < rasterPartEnd; rasterPart += idxStep)
+    {
+        uint32_t uiPartAbove;
+        TComDataCU* pcCUAbove = cu->getPUAbove(uiPartAbove, g_rasterToZscan[rasterPart]);
+        if (pcCUAbove && pcCUAbove->isIntra(uiPartAbove))
+        {
+            numIntra++;
+            *validFlagPtr = true;
+        }
+        else
+        {
+            *validFlagPtr = false;
+        }
+        validFlagPtr++;
+    }
+
+    return numIntra;
+}
+
+int TComPattern::isLeftAvailableCIP(TComDataCU* cu, uint32_t partIdxLT, uint32_t partIdxLB, bool *bValidFlags)
+{
+    const uint32_t rasterPartBegin = g_zscanToRaster[partIdxLT];
+    const uint32_t rasterPartEnd = g_zscanToRaster[partIdxLB] + 1;
+    const uint32_t idxStep = cu->getPic()->getNumPartInCUSize();
+    bool *validFlagPtr = bValidFlags;
+    int numIntra = 0;
+
+    for (uint32_t rasterPart = rasterPartBegin; rasterPart < rasterPartEnd; rasterPart += idxStep)
+    {
+        uint32_t partLeft;
+        TComDataCU* pcCULeft = cu->getPULeft(partLeft, g_rasterToZscan[rasterPart]);
+        if (pcCULeft && pcCULeft->isIntra(partLeft))
+        {
+            numIntra++;
+            *validFlagPtr = true;
+        }
+        else
+        {
+            *validFlagPtr = false;
+        }
+        validFlagPtr--; // opposite direction
+    }
+
+    return numIntra;
+}
+
+int TComPattern::isAboveRightAvailableCIP(TComDataCU* cu, uint32_t partIdxLT, uint32_t partIdxRT, bool *bValidFlags)
+{
+    const uint32_t numUnitsInPU = g_zscanToRaster[partIdxRT] - g_zscanToRaster[partIdxLT] + 1;
+    bool *validFlagPtr = bValidFlags;
+    int numIntra = 0;
+
+    for (uint32_t offset = 1; offset <= numUnitsInPU; offset++)
+    {
+        uint32_t uiPartAboveRight;
+        TComDataCU* pcCUAboveRight = cu->getPUAboveRightAdi(uiPartAboveRight, partIdxRT, offset);
+        if (pcCUAboveRight && pcCUAboveRight->isIntra(uiPartAboveRight))
+        {
+            numIntra++;
+            *validFlagPtr = true;
+        }
+        else
+        {
+            *validFlagPtr = false;
+        }
+        validFlagPtr++;
+    }
+
+    return numIntra;
+}
+
+int TComPattern::isBelowLeftAvailableCIP(TComDataCU* cu, uint32_t partIdxLT, uint32_t partIdxLB, bool *bValidFlags)
+{
+    const uint32_t numUnitsInPU = (g_zscanToRaster[partIdxLB] - g_zscanToRaster[partIdxLT]) / cu->getPic()->getNumPartInCUSize() + 1;
+    bool *validFlagPtr = bValidFlags;
+    int numIntra = 0;
+
+    for (uint32_t offset = 1; offset <= numUnitsInPU; offset++)
+    {
+        uint32_t uiPartBelowLeft;
+        TComDataCU* pcCUBelowLeft = cu->getPUBelowLeftAdi(uiPartBelowLeft, partIdxLB, offset);
+        if (pcCUBelowLeft && pcCUBelowLeft->isIntra(uiPartBelowLeft))
+        {
+            numIntra++;
+            *validFlagPtr = true;
+        }
+        else
+        {
+            *validFlagPtr = false;
         }
         validFlagPtr--; // opposite direction
     }
diff -r bdca492dc1d7 -r 0d2bf32b01da source/Lib/TLibCommon/TComPattern.h
--- a/source/Lib/TLibCommon/TComPattern.h	Wed Apr 09 14:06:29 2014 +0530
+++ b/source/Lib/TLibCommon/TComPattern.h	Wed Apr 09 18:01:41 2014 +0900
@@ -91,6 +91,12 @@
     static int   isLeftAvailable(TComDataCU* cu, uint32_t partIdxLT, uint32_t partIdxLB, bool* bValidFlags);
     static int   isAboveRightAvailable(TComDataCU* cu, uint32_t partIdxLT, uint32_t partIdxRT, bool* bValidFlags);
     static int   isBelowLeftAvailable(TComDataCU* cu, uint32_t partIdxLT, uint32_t partIdxLB, bool* bValidFlags);
+
+    static bool  isAboveLeftAvailableCIP(TComDataCU* cu, uint32_t partIdxLT);
+    static int   isAboveAvailableCIP(TComDataCU* cu, uint32_t partIdxLT, uint32_t partIdxRT, bool* bValidFlags);
+    static int   isLeftAvailableCIP(TComDataCU* cu, uint32_t partIdxLT, uint32_t partIdxLB, bool* bValidFlags);
+    static int   isAboveRightAvailableCIP(TComDataCU* cu, uint32_t partIdxLT, uint32_t partIdxRT, bool* bValidFlags);
+    static int   isBelowLeftAvailableCIP(TComDataCU* cu, uint32_t partIdxLT, uint32_t partIdxLB, bool* bValidFlags);
 };
 }
 //! \}


More information about the x265-devel mailing list