[x265] [PATCH] Modify TEncEntropy structure to support multiple color space formats
ashok at multicorewareinc.com
ashok at multicorewareinc.com
Fri Dec 20 15:07:30 CET 2013
# HG changeset patch
# User ashok at multicorewareinc.com
# Date 1387548437 -19800
# Fri Dec 20 19:37:17 2013 +0530
# Node ID a2e9fb27bb041900ae334496ecdc1ecb13e0f7fa
# Parent d773e9cbc7c73f7888d1d1867c7d13256917b17e
Modify TEncEntropy structure to support multiple color space formats
diff -r d773e9cbc7c7 -r a2e9fb27bb04 source/Lib/TLibEncoder/TEncEntropy.cpp
--- a/source/Lib/TLibEncoder/TEncEntropy.cpp Fri Dec 20 19:36:07 2013 +0530
+++ b/source/Lib/TLibEncoder/TEncEntropy.cpp Fri Dec 20 19:37:17 2013 +0530
@@ -225,7 +225,8 @@
{
m_bakAbsPartIdxCU = absPartIdx;
}
- if (log2TrafoSize == 2)
+
+ if ((log2TrafoSize == 2) && !(cu->getChromaFormat() == CHROMA_444))
{
uint32_t partNum = cu->getPic()->getNumPartInCU() >> ((depth - 1) << 1);
if ((absPartIdx % partNum) == 0)
@@ -275,7 +276,15 @@
const uint32_t trDepthCurr = depth - cu->getDepth(absPartIdx);
const bool bFirstCbfOfCU = trDepthCurr == 0;
- if (bFirstCbfOfCU || log2TrafoSize > 2)
+
+ bool mCodeAll = true;
+ const uint32_t numPels = (width >> cu->getHorzChromaShift()) * (height >> cu->getHorzChromaShift());
+ if(numPels < (MIN_TU_SIZE * MIN_TU_SIZE))
+ {
+ mCodeAll = false;
+ }
+
+ if (bFirstCbfOfCU || mCodeAll)
{
if (bFirstCbfOfCU || cu->getCbf(absPartIdx, TEXT_CHROMA_U, trDepthCurr - 1))
{
@@ -286,7 +295,7 @@
m_entropyCoderIf->codeQtCbf(cu, absPartIdx, TEXT_CHROMA_V, trDepthCurr);
}
}
- else if (log2TrafoSize == 2)
+ else
{
assert(cu->getCbf(absPartIdx, TEXT_CHROMA_U, trDepthCurr) == cu->getCbf(absPartIdx, TEXT_CHROMA_U, trDepthCurr - 1));
assert(cu->getCbf(absPartIdx, TEXT_CHROMA_V, trDepthCurr) == cu->getCbf(absPartIdx, TEXT_CHROMA_V, trDepthCurr - 1));
@@ -306,17 +315,17 @@
absPartIdx += partNum;
offsetLuma += size;
- offsetChroma += (size >> 2);
+ offsetChroma += (size >> (cu->getHorzChromaShift() + cu->getVertChromaShift()));
xEncodeTransform(cu, offsetLuma, offsetChroma, absPartIdx, depth, width, height, trIdx, bCodeDQP);
absPartIdx += partNum;
offsetLuma += size;
- offsetChroma += (size >> 2);
+ offsetChroma += (size >> (cu->getHorzChromaShift() + cu->getVertChromaShift()));
xEncodeTransform(cu, offsetLuma, offsetChroma, absPartIdx, depth, width, height, trIdx, bCodeDQP);
absPartIdx += partNum;
offsetLuma += size;
- offsetChroma += (size >> 2);
+ offsetChroma += (size >> (cu->getHorzChromaShift() + cu->getVertChromaShift()));
xEncodeTransform(cu, offsetLuma, offsetChroma, absPartIdx, depth, width, height, trIdx, bCodeDQP);
}
else
@@ -354,24 +363,13 @@
}
}
}
+
if (cbfY)
{
m_entropyCoderIf->codeCoeffNxN(cu, (cu->getCoeffY() + offsetLuma), absPartIdx, width, height, depth, TEXT_LUMA);
}
- if (log2TrafoSize > 2)
- {
- int trWidth = width >> 1;
- int trHeight = height >> 1;
- if (cbfU)
- {
- m_entropyCoderIf->codeCoeffNxN(cu, (cu->getCoeffCb() + offsetChroma), absPartIdx, trWidth, trHeight, depth, TEXT_CHROMA_U);
- }
- if (cbfV)
- {
- m_entropyCoderIf->codeCoeffNxN(cu, (cu->getCoeffCr() + offsetChroma), absPartIdx, trWidth, trHeight, depth, TEXT_CHROMA_V);
- }
- }
- else
+
+ if ((log2TrafoSize == 2) && !(cu->getChromaFormat() == CHROMA_444))
{
uint32_t partNum = cu->getPic()->getNumPartInCU() >> ((depth - 1) << 1);
if ((absPartIdx % partNum) == (partNum - 1))
@@ -386,6 +384,19 @@
}
}
}
+ else
+ {
+ int trWidth = width >> cu->getHorzChromaShift();
+ int trHeight = height >> cu->getVertChromaShift();
+ if (cbfU)
+ {
+ m_entropyCoderIf->codeCoeffNxN(cu, (cu->getCoeffCb() + offsetChroma), absPartIdx, trWidth, trHeight, depth, TEXT_CHROMA_U);
+ }
+ if (cbfV)
+ {
+ m_entropyCoderIf->codeCoeffNxN(cu, (cu->getCoeffCr() + offsetChroma), absPartIdx, trWidth, trHeight, depth, TEXT_CHROMA_V);
+ }
+ }
}
}
@@ -412,10 +423,22 @@
{
absPartIdx = 0;
}
+
if (cu->isIntra(absPartIdx)) // If it is Intra mode, encode intra prediction mode.
{
encodeIntraDirModeLuma(cu, absPartIdx, true);
- encodeIntraDirModeChroma(cu, absPartIdx, bRD);
+ if (cu->getChromaFormat() != CHROMA_400)
+ {
+ encodeIntraDirModeChroma(cu, absPartIdx, bRD);
+
+ if ((cu->getChromaFormat() == CHROMA_444) && (cu->getPartitionSize(absPartIdx) == SIZE_NxN))
+ {
+ uint32_t partOffset = (cu->getPic()->getNumPartInCU() >> (cu->getDepth(absPartIdx) << 1)) >> 2;
+ encodeIntraDirModeChroma(cu, absPartIdx + partOffset, bRD);
+ encodeIntraDirModeChroma(cu, absPartIdx + partOffset*2, bRD);
+ encodeIntraDirModeChroma(cu, absPartIdx + partOffset*3, bRD);
+ }
+ }
}
else // if it is Inter mode, encode motion vector and reference index
{
@@ -572,7 +595,7 @@
{
uint32_t minCoeffSize = cu->getPic()->getMinCUWidth() * cu->getPic()->getMinCUHeight();
uint32_t lumaOffset = minCoeffSize * absPartIdx;
- uint32_t chromaOffset = lumaOffset >> 2;
+ uint32_t chromaOffset = lumaOffset >> (cu->getHorzChromaShift() + cu->getVertChromaShift());
if (cu->isIntra(absPartIdx))
{
More information about the x265-devel
mailing list