[x265] [PATCH] Modify TComPattern structure to support multiple color space formats

ashok at multicorewareinc.com ashok at multicorewareinc.com
Fri Jan 3 14:10:54 CET 2014


# HG changeset patch
# User ashok at multicorewareinc.com
# Date 1388754641 -19800
#      Fri Jan 03 18:40:41 2014 +0530
# Node ID c33edcd92866c6cfc3f5593282ef6969e0d9a0af
# Parent  d7f6034a4ead619cde6977033f908d879789b1d1
Modify TComPattern structure to support multiple color space formats

diff -r d7f6034a4ead -r c33edcd92866 source/Lib/TLibCommon/TComPattern.cpp
--- a/source/Lib/TLibCommon/TComPattern.cpp	Fri Jan 03 18:38:52 2014 +0530
+++ b/source/Lib/TLibCommon/TComPattern.cpp	Fri Jan 03 18:40:41 2014 +0530
@@ -164,8 +164,8 @@
 {
     Pel* roiOrigin;
     Pel* adiTemp;
-    uint32_t cuWidth = cu->getWidth(0) >> partDepth;
-    uint32_t cuHeight = cu->getHeight(0) >> partDepth;
+    uint32_t cuWidth   = cu->getWidth(0)  >> partDepth;
+    uint32_t cuHeight  = cu->getHeight(0) >> partDepth;
     uint32_t cuWidth2  = cuWidth << 1;
     uint32_t cuHeight2 = cuHeight << 1;
     uint32_t width;
@@ -193,7 +193,7 @@
     numIntraNeighbor  += isLeftAvailable(cu, partIdxLT, partIdxLB, bNeighborFlags + (numUnitsInCU * 2) - 1);
     numIntraNeighbor  += isBelowLeftAvailable(cu, partIdxLT, partIdxLB, bNeighborFlags + numUnitsInCU   - 1);
 
-    width = cuWidth2 + 1;
+    width  = cuWidth2 + 1;
     height = cuHeight2 + 1;
 
     if (((width << 2) > strideOrig) || ((height << 2) > heightOrig))
@@ -211,10 +211,10 @@
     int bufSize = cuHeight2 + cuWidth2 + 1;
     uint32_t wh = ADI_BUF_STRIDE * height;         // number of elements in one buffer
 
-    Pel* filteredBuf1 = adiBuf + wh;         // 1. filter buffer
-    Pel* filteredBuf2 = filteredBuf1 + wh; // 2. filter buffer
-    Pel* filterBuf = filteredBuf2 + wh;    // buffer for 2. filtering (sequential)
-    Pel* filterBufN = filterBuf + bufSize; // buffer for 1. filtering (sequential)
+    Pel* filteredBuf1 = adiBuf + wh;               // 1. filter buffer
+    Pel* filteredBuf2 = filteredBuf1 + wh;         // 2. filter buffer
+    Pel* filterBuf    = filteredBuf2    + wh;      // buffer for 2. filtering (sequential)
+    Pel* filterBufN   = filterBuf      + bufSize;  // buffer for 1. filtering (sequential)
 
     int l = 0;
     // left border from bottom to top
@@ -299,10 +299,10 @@
     uint32_t cuWidth2  = cuWidth << 1;
     uint32_t cuHeight2 = cuHeight << 1;
 
-    refAbove += cuWidth - 1;
+    refAbove    += cuWidth - 1;
     refAboveFlt += cuWidth - 1;
-    refLeft += cuWidth - 1;
-    refLeftFlt += cuWidth - 1;
+    refLeft     += cuWidth - 1;
+    refLeftFlt  += cuWidth - 1;
 
     //  ADI_BUF_STRIDE * (2 * height + 1);
     memcpy(refAbove, adiBuf, (cuWidth2 + 1) * sizeof(Pel));
@@ -310,12 +310,12 @@
 
     for (int k = 0; k < cuHeight2 + 1; k++)
     {
-        refLeft[k] = adiBuf[k * ADI_BUF_STRIDE];
+        refLeft[k]    = adiBuf[k * ADI_BUF_STRIDE];
         refLeftFlt[k] = (adiBuf + ADI_BUF_STRIDE * (cuHeight2 + 1))[k * ADI_BUF_STRIDE];   // Smoothened
     }
 }
 
-void TComPattern::initAdiPatternChroma(TComDataCU* cu, uint32_t zOrderIdxInPart, uint32_t partDepth, Pel* adiBuf, int strideOrig, int heightOrig)
+void TComPattern::initAdiPatternChroma(TComDataCU* cu, uint32_t zOrderIdxInPart, uint32_t partDepth, Pel* adiBuf, int strideOrig, int heightOrig, int chromaId)
 {
     Pel*  roiOrigin;
     Pel*  adiTemp;
@@ -323,7 +323,7 @@
     uint32_t  cuHeight = cu->getHeight(0) >> partDepth;
     uint32_t  width;
     uint32_t  height;
-    int   picStride = cu->getPic()->getCStride();
+    int       picStride = cu->getPic()->getCStride();
 
     int   unitSize = 0;
     int   numUnitsInCU = 0;
@@ -347,10 +347,10 @@
     numIntraNeighbor += isLeftAvailable(cu, partIdxLT, partIdxLB, bNeighborFlags + (numUnitsInCU * 2) - 1);
     numIntraNeighbor += isBelowLeftAvailable(cu, partIdxLT, partIdxLB, bNeighborFlags + numUnitsInCU   - 1);
 
-    cuWidth = cuWidth >> cu->getHorzChromaShift(); // for chroma
+    cuWidth = cuWidth   >> cu->getHorzChromaShift(); // for chroma
     cuHeight = cuHeight >> cu->getVertChromaShift(); // for chroma
 
-    width = cuWidth * 2 + 1;
+    width = cuWidth   * 2 + 1;
     height = cuHeight * 2 + 1;
 
     if ((4 * width > strideOrig) || (4 * height > heightOrig))
@@ -358,16 +358,8 @@
         return;
     }
 
-    // get Cb pattern
-    roiOrigin = cu->getPic()->getPicYuvRec()->getCbAddr(cu->getAddr(), cu->getZorderIdxInCU() + zOrderIdxInPart);
-    adiTemp   = adiBuf;
-
-    fillReferenceSamples(roiOrigin, adiTemp, bNeighborFlags, numIntraNeighbor, unitSize, numUnitsInCU, totalUnits,
-                         cuWidth, cuHeight, width, height, picStride);
-
-    // get Cr pattern
-    roiOrigin = cu->getPic()->getPicYuvRec()->getCrAddr(cu->getAddr(), cu->getZorderIdxInCU() + zOrderIdxInPart);
-    adiTemp   = adiBuf + ADI_BUF_STRIDE * height;
+    roiOrigin = chromaId > 0 ? cu->getPic()->getPicYuvRec()->getCrAddr(cu->getAddr(), cu->getZorderIdxInCU() + zOrderIdxInPart) : cu->getPic()->getPicYuvRec()->getCbAddr(cu->getAddr(), cu->getZorderIdxInCU() + zOrderIdxInPart);
+    adiTemp   = chromaId > 0 ? (adiBuf + 2 * ADI_BUF_STRIDE * height) : adiBuf;
 
     fillReferenceSamples(roiOrigin, adiTemp, bNeighborFlags, numIntraNeighbor, unitSize, numUnitsInCU, totalUnits,
                          cuWidth, cuHeight, width, height, picStride);
@@ -546,7 +538,7 @@
 
 Pel* TComPattern::getAdiCrBuf(int /*cuWidth*/, int cuHeight, Pel* adiBuf)
 {
-    return adiBuf + ADI_BUF_STRIDE * (cuHeight * 2 + 1);
+    return adiBuf +  2 * ADI_BUF_STRIDE * (cuHeight * 2 + 1);
 }
 
 /** Get pointer to reference samples for intra prediction
diff -r d7f6034a4ead -r c33edcd92866 source/Lib/TLibCommon/TComPattern.h
--- a/source/Lib/TLibCommon/TComPattern.h	Fri Jan 03 18:38:52 2014 +0530
+++ b/source/Lib/TLibCommon/TComPattern.h	Fri Jan 03 18:40:41 2014 +0530
@@ -136,7 +136,7 @@
 
     /// set chroma parameters from CU data for accessing ADI data
     void  initAdiPatternChroma(TComDataCU* cu, uint32_t zOrderIdxInPart, uint32_t partDepth,
-                               Pel* adiBuf, int strideOrig, int heightOrig);
+                               Pel* adiBuf, int strideOrig, int heightOrig, int chromaId);
 
 private:
 


More information about the x265-devel mailing list