<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 3, 2014 at 7:06 AM, <span dir="ltr"><<a href="mailto:ashok@multicorewareinc.com" target="_blank">ashok@multicorewareinc.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User <a href="mailto:ashok@multicorewareinc.com">ashok@multicorewareinc.com</a><br>
# Date 1388754397 -19800<br>
# Fri Jan 03 18:36:37 2014 +0530<br>
# Node ID be8c07a80a181f9a20d51abd01b90ac9fe94f4ea<br>
# Parent e4ab306e0347e5a65c52be2d0845a6cf592c5713<br>
Modify TEncEntropy structure to support multiple color space formats<br>
<br>
diff -r e4ab306e0347 -r be8c07a80a18 source/Lib/TLibEncoder/TEncEntropy.cpp<br>
--- a/source/Lib/TLibEncoder/TEncEntropy.cpp Fri Jan 03 18:35:01 2014 +0530<br>
+++ b/source/Lib/TLibEncoder/TEncEntropy.cpp Fri Jan 03 18:36:37 2014 +0530<br>
@@ -225,7 +225,8 @@<br>
{<br>
m_bakAbsPartIdxCU = absPartIdx;<br>
}<br>
- if (log2TrafoSize == 2)<br>
+<br>
+ if ((log2TrafoSize == 2) && !(cu->getChromaFormat() == CHROMA_444))<br></blockquote><div><br></div><div>Keep in mind that at some point we will want to make 4:4:4 a build option, so all of these checks and shifts will need to be turned into macros eventually.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
{<br>
uint32_t partNum = cu->getPic()->getNumPartInCU() >> ((depth - 1) << 1);<br>
if ((absPartIdx % partNum) == 0)<br>
@@ -275,7 +276,15 @@<br>
<br>
const uint32_t trDepthCurr = depth - cu->getDepth(absPartIdx);<br>
const bool bFirstCbfOfCU = trDepthCurr == 0;<br>
- if (bFirstCbfOfCU || log2TrafoSize > 2)<br>
+<br>
+ bool mCodeAll = true;<br>
+ const uint32_t numPels = (width >> cu->getHorzChromaShift()) * (height >> cu->getHorzChromaShift());<br>
+ if(numPels < (MIN_TU_SIZE * MIN_TU_SIZE))<br></blockquote><div><br></div><div>white-space</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ {<br>
+ mCodeAll = false;<br>
+ }<br>
+<br>
+ if (bFirstCbfOfCU || mCodeAll)<br>
{<br>
if (bFirstCbfOfCU || cu->getCbf(absPartIdx, TEXT_CHROMA_U, trDepthCurr - 1))<br>
{<br>
@@ -286,7 +295,7 @@<br>
m_entropyCoderIf->codeQtCbf(cu, absPartIdx, TEXT_CHROMA_V, trDepthCurr);<br>
}<br>
}<br>
- else if (log2TrafoSize == 2)<br>
+ else<br>
{<br>
assert(cu->getCbf(absPartIdx, TEXT_CHROMA_U, trDepthCurr) == cu->getCbf(absPartIdx, TEXT_CHROMA_U, trDepthCurr - 1));<br>
assert(cu->getCbf(absPartIdx, TEXT_CHROMA_V, trDepthCurr) == cu->getCbf(absPartIdx, TEXT_CHROMA_V, trDepthCurr - 1));<br>
@@ -306,17 +315,17 @@<br>
<br>
absPartIdx += partNum;<br>
offsetLuma += size;<br>
- offsetChroma += (size >> 2);<br>
+ offsetChroma += (size >> (cu->getHorzChromaShift() + cu->getVertChromaShift()));<br>
xEncodeTransform(cu, offsetLuma, offsetChroma, absPartIdx, depth, width, height, trIdx, bCodeDQP);<br>
<br>
absPartIdx += partNum;<br>
offsetLuma += size;<br>
- offsetChroma += (size >> 2);<br>
+ offsetChroma += (size >> (cu->getHorzChromaShift() + cu->getVertChromaShift()));<br>
xEncodeTransform(cu, offsetLuma, offsetChroma, absPartIdx, depth, width, height, trIdx, bCodeDQP);<br>
<br>
absPartIdx += partNum;<br>
offsetLuma += size;<br>
- offsetChroma += (size >> 2);<br>
+ offsetChroma += (size >> (cu->getHorzChromaShift() + cu->getVertChromaShift()));<br>
xEncodeTransform(cu, offsetLuma, offsetChroma, absPartIdx, depth, width, height, trIdx, bCodeDQP);<br>
}<br>
else<br>
@@ -358,20 +367,8 @@<br>
{<br>
m_entropyCoderIf->codeCoeffNxN(cu, (cu->getCoeffY() + offsetLuma), absPartIdx, width, height, depth, TEXT_LUMA);<br>
}<br>
- if (log2TrafoSize > 2)<br>
- {<br>
- int trWidth = width >> 1;<br>
- int trHeight = height >> 1;<br>
- if (cbfU)<br>
- {<br>
- m_entropyCoderIf->codeCoeffNxN(cu, (cu->getCoeffCb() + offsetChroma), absPartIdx, trWidth, trHeight, depth, TEXT_CHROMA_U);<br>
- }<br>
- if (cbfV)<br>
- {<br>
- m_entropyCoderIf->codeCoeffNxN(cu, (cu->getCoeffCr() + offsetChroma), absPartIdx, trWidth, trHeight, depth, TEXT_CHROMA_V);<br>
- }<br>
- }<br>
- else<br>
+<br>
+ if ((log2TrafoSize == 2) && !(cu->getChromaFormat() == CHROMA_444))<br>
{<br>
uint32_t partNum = cu->getPic()->getNumPartInCU() >> ((depth - 1) << 1);<br>
if ((absPartIdx % partNum) == (partNum - 1))<br>
@@ -386,6 +383,19 @@<br>
}<br>
}<br>
}<br>
+ else<br>
+ {<br>
+ int trWidth = width >> cu->getHorzChromaShift();<br>
+ int trHeight = height >> cu->getVertChromaShift();<br>
+ if (cbfU)<br>
+ {<br>
+ m_entropyCoderIf->codeCoeffNxN(cu, (cu->getCoeffCb() + offsetChroma), absPartIdx, trWidth, trHeight, depth, TEXT_CHROMA_U);<br>
+ }<br>
+ if (cbfV)<br>
+ {<br>
+ m_entropyCoderIf->codeCoeffNxN(cu, (cu->getCoeffCr() + offsetChroma), absPartIdx, trWidth, trHeight, depth, TEXT_CHROMA_V);<br>
+ }<br>
+ }<br>
}<br>
}<br>
<br>
@@ -412,10 +422,22 @@<br>
{<br>
absPartIdx = 0;<br>
}<br>
+<br>
if (cu->isIntra(absPartIdx)) // If it is Intra mode, encode intra prediction mode.<br>
{<br>
encodeIntraDirModeLuma(cu, absPartIdx, true);<br>
- encodeIntraDirModeChroma(cu, absPartIdx, bRD);<br>
+ if (cu->getChromaFormat() != CHROMA_400)<br>
+ {<br>
+ encodeIntraDirModeChroma(cu, absPartIdx, bRD);<br>
+<br>
+ if ((cu->getChromaFormat() == CHROMA_444) && (cu->getPartitionSize(absPartIdx) == SIZE_NxN))<br>
+ {<br>
+ uint32_t partOffset = (cu->getPic()->getNumPartInCU() >> (cu->getDepth(absPartIdx) << 1)) >> 2;<br>
+ encodeIntraDirModeChroma(cu, absPartIdx + partOffset, bRD);<br>
+ encodeIntraDirModeChroma(cu, absPartIdx + partOffset*2, bRD);<br>
+ encodeIntraDirModeChroma(cu, absPartIdx + partOffset*3, bRD);<br>
+ }<br>
+ }<br>
}<br>
else // if it is Inter mode, encode motion vector and reference index<br>
{<br>
@@ -572,7 +594,7 @@<br>
{<br>
uint32_t minCoeffSize = cu->getPic()->getMinCUWidth() * cu->getPic()->getMinCUHeight();<br>
uint32_t lumaOffset = minCoeffSize * absPartIdx;<br>
- uint32_t chromaOffset = lumaOffset >> 2;<br>
+ uint32_t chromaOffset = lumaOffset >> (cu->getHorzChromaShift() + cu->getVertChromaShift());<br>
<br>
if (cu->isIntra(absPartIdx))<br>
{<br>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Steve Borho
</div></div>