[x265] [PATCH] Modify TComSampleAdaptiveOffset structure to support multiple color space formats
ashok at multicorewareinc.com
ashok at multicorewareinc.com
Fri Jan 3 14:01:01 CET 2014
# HG changeset patch
# User ashok at multicorewareinc.com
# Date 1388754046 -19800
# Fri Jan 03 18:30:46 2014 +0530
# Node ID c99bbc0c7adff095695278b016be6163c3fdb812
# Parent 7e09261ecc4bac5e7dd8e0f8fcd77d344c1037d6
Modify TComSampleAdaptiveOffset structure to support multiple color space formats
diff -r 7e09261ecc4b -r c99bbc0c7adf source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp
--- a/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp Fri Jan 03 18:29:15 2014 +0530
+++ b/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp Fri Jan 03 18:30:46 2014 +0530
@@ -150,8 +150,11 @@
/** create SampleAdaptiveOffset memory.
* \param
*/
-void TComSampleAdaptiveOffset::create(uint32_t sourceWidth, uint32_t sourceHeight, uint32_t maxCUWidth, uint32_t maxCUHeight)
+void TComSampleAdaptiveOffset::create(uint32_t sourceWidth, uint32_t sourceHeight, uint32_t maxCUWidth, uint32_t maxCUHeight, int csp)
{
+ m_hChromaShift = CHROMA_H_SHIFT(csp);
+ m_vChromaShift = CHROMA_V_SHIFT(csp);
+
m_picWidth = sourceWidth;
m_picHeight = sourceHeight;
@@ -554,12 +557,14 @@
int32_t *offsetBo = NULL;
int32_t *tmp_swap;
- picWidthTmp = m_picWidth >> isChroma;
- picHeightTmp = m_picHeight >> isChroma;
- lcuWidth = lcuWidth >> isChroma;
- lcuHeight = lcuHeight >> isChroma;
- lpelx = lpelx >> isChroma;
- tpely = tpely >> isChroma;
+ picWidthTmp = (isChroma == 0) ? m_picWidth : m_picWidth >> m_hChromaShift;
+ picHeightTmp = (isChroma == 0) ? m_picHeight : m_picHeight >> m_vChromaShift;
+ lcuWidth = (isChroma == 0) ? lcuWidth : lcuWidth >> m_hChromaShift;
+ lcuHeight = (isChroma == 0) ? lcuHeight : lcuHeight >> m_vChromaShift;
+ lpelx = (isChroma == 0) ? lpelx : lpelx >> m_hChromaShift;
+ tpely = (isChroma == 0) ? tpely : tpely >> m_vChromaShift;
+
+
rpelx = lpelx + lcuWidth;
bpely = tpely + lcuHeight;
rpelx = rpelx > picWidthTmp ? picWidthTmp : rpelx;
@@ -589,8 +594,8 @@
// if (iSaoType!=SAO_BO_0 || iSaoType!=SAO_BO_1)
{
- cuHeightTmp = (m_maxCUHeight >> isChroma);
- shift = (m_maxCUWidth >> isChroma) - 1;
+ cuHeightTmp = (isChroma == 0) ? m_maxCUHeight : (m_maxCUHeight >> m_vChromaShift);
+ shift = (isChroma == 0) ? (m_maxCUWidth- 1) : ((m_maxCUWidth >> m_hChromaShift) - 1);
for (int i = 0; i < cuHeightTmp + 1; i++)
{
m_tmpL2[i] = rec[shift];
@@ -827,12 +832,12 @@
else if (yCbCr == 1)
{
rec = m_pic->getPicYuvRec()->getCbAddr();
- picWidthTmp = m_picWidth >> 1;
+ picWidthTmp = m_picWidth >> m_hChromaShift;
}
else
{
rec = m_pic->getPicYuvRec()->getCrAddr();
- picWidthTmp = m_picWidth >> 1;
+ picWidthTmp = m_picWidth >> m_hChromaShift;
}
memcpy(m_tmpU1[yCbCr], rec, sizeof(Pel) * picWidthTmp);
@@ -872,17 +877,17 @@
{
rec = m_pic->getPicYuvRec()->getCbAddr(addr);
stride = m_pic->getCStride();
- picWidthTmp = m_picWidth >> 1;
+ picWidthTmp = m_picWidth >> m_hChromaShift;
}
else
{
rec = m_pic->getPicYuvRec()->getCrAddr(addr);
stride = m_pic->getCStride();
- picWidthTmp = m_picWidth >> 1;
+ picWidthTmp = m_picWidth >> m_hChromaShift;
}
- // pRec += stride*(m_uiMaxCUHeight-1);
- for (i = 0; i < (m_maxCUHeight >> sChroma) + 1; i++)
+ uint32_t cuHeightTmp = (sChroma == 0) ? m_maxCUHeight : (m_maxCUHeight >> m_vChromaShift);
+ for (i = 0; i < cuHeightTmp + 1; i++)
{
m_tmpL1[i] = rec[0];
rec += stride;
@@ -964,8 +969,9 @@
rec = m_pic->getPicYuvRec()->getCrAddr(addr);
stride = m_pic->getCStride();
}
- int widthShift = m_maxCUWidth >> sChroma;
- for (i = 0; i < (m_maxCUHeight >> sChroma) + 1; i++)
+
+ int widthShift = (sChroma == 0) ? m_maxCUWidth : (m_maxCUWidth >> m_hChromaShift);
+ for (i = 0; i < cuHeightTmp + 1; i++)
{
m_tmpL1[i] = rec[widthShift - 1];
rec += stride;
@@ -998,12 +1004,12 @@
else if (yCbCr == 1)
{
rec = m_pic->getPicYuvRec()->getCbAddr();
- picWidthTmp = m_picWidth >> 1;
+ picWidthTmp = m_picWidth >> m_hChromaShift;
}
else
{
rec = m_pic->getPicYuvRec()->getCrAddr();
- picWidthTmp = m_picWidth >> 1;
+ picWidthTmp = m_picWidth >> m_hChromaShift;
}
if (idxY == 0)
@@ -1041,17 +1047,17 @@
{
rec = m_pic->getPicYuvRec()->getCbAddr(addr);
stride = m_pic->getCStride();
- picWidthTmp = m_picWidth >> 1;
+ picWidthTmp = m_picWidth >> m_hChromaShift;
}
else
{
rec = m_pic->getPicYuvRec()->getCrAddr(addr);
stride = m_pic->getCStride();
- picWidthTmp = m_picWidth >> 1;
+ picWidthTmp = m_picWidth >> m_hChromaShift;
}
- // pRec += stride*(m_uiMaxCUHeight-1);
- for (i = 0; i < (m_maxCUHeight >> sChroma) + 1; i++)
+ uint32_t maxCUHeight = (sChroma == 0) ? m_maxCUHeight : (m_maxCUHeight >> m_vChromaShift);
+ for (i = 0; i < maxCUHeight + 1; i++)
{
m_tmpL1[i] = rec[0];
rec += stride;
@@ -1126,8 +1132,9 @@
rec = m_pic->getPicYuvRec()->getCrAddr(addr);
stride = m_pic->getCStride();
}
- int widthShift = m_maxCUWidth >> sChroma;
- for (i = 0; i < (m_maxCUHeight >> sChroma) + 1; i++)
+
+ int widthShift = (sChroma == 0) ? m_maxCUWidth : (m_maxCUWidth >> m_hChromaShift);
+ for (i = 0; i < maxCUHeight + 1; i++)
{
m_tmpL1[i] = rec[widthShift - 1];
rec += stride;
diff -r 7e09261ecc4b -r c99bbc0c7adf source/Lib/TLibCommon/TComSampleAdaptiveOffset.h
--- a/source/Lib/TLibCommon/TComSampleAdaptiveOffset.h Fri Jan 03 18:29:15 2014 +0530
+++ b/source/Lib/TLibCommon/TComSampleAdaptiveOffset.h Fri Jan 03 18:30:46 2014 +0530
@@ -157,6 +157,9 @@
int m_numCuInHeight;
int m_numTotalParts;
+ int m_hChromaShift;
+ int m_vChromaShift;
+
uint32_t m_saoBitIncreaseY;
uint32_t m_saoBitIncreaseC; //for chroma
uint32_t m_qp;
@@ -185,7 +188,7 @@
TComSampleAdaptiveOffset();
virtual ~TComSampleAdaptiveOffset();
- void create(uint32_t sourceWidth, uint32_t sourceHeight, uint32_t maxCUWidth, uint32_t maxCUHeight);
+ void create(uint32_t sourceWidth, uint32_t sourceHeight, uint32_t maxCUWidth, uint32_t maxCUHeight, int csp);
void destroy();
int convertLevelRowCol2Idx(int level, int row, int col) const;
More information about the x265-devel
mailing list