<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 12, 2014 at 6:05 PM,  <span dir="ltr"><<a href="mailto:santhoshini@multicorewareinc.com" target="_blank">santhoshini@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 Santhoshini Sekar <<a href="mailto:santhoshini@multicorewareinc.com">santhoshini@multicorewareinc.com</a>><br>
# Date 1410525310 -19800<br>
#      Fri Sep 12 18:05:10 2014 +0530<br>
# Node ID bf4ebe5df0cab013e4462597b55bd505b2a6a71a<br>
# Parent  7e29b10982d2eb7fd79f581d99996f04184522ba<br>
analysis: add CU specific details to encodeCU()<br>
<br>
diff -r 7e29b10982d2 -r bf4ebe5df0ca source/encoder/analysis.cpp<br>
--- a/source/encoder/analysis.cpp       Thu Sep 11 19:24:28 2014 +0530<br>
+++ b/source/encoder/analysis.cpp       Fri Sep 12 18:05:10 2014 +0530<br>
@@ -301,7 +301,6 @@<br>
 {<br>
     if (cu->m_slice->m_pps->bUseDQP)<br>
         m_bEncodeDQP = true;<br>
-    loadCTUData(cu);<br>
<br>
     // initialize CU data<br>
     m_bestCU[0]->initCU(cu->m_pic, cu->getAddr());<br>
diff -r 7e29b10982d2 -r bf4ebe5df0ca source/encoder/entropy.cpp<br>
--- a/source/encoder/entropy.cpp        Thu Sep 11 19:24:28 2014 +0530<br>
+++ b/source/encoder/entropy.cpp        Fri Sep 12 18:05:10 2014 +0530<br>
@@ -481,14 +481,14 @@<br>
     }<br>
 }<br>
<br>
-void Entropy::encodeCTU(TComDataCU* cu)<br>
+void Entropy::encodeCTU(TComDataCU* cu, CU* cuData)<br>
 {<br>
     bool bEncodeDQP = cu->m_slice->m_pps->bUseDQP;<br>
-    encodeCU(cu, 0, 0, false, bEncodeDQP);<br>
+    encodeCU(cu, 0, 0, bEncodeDQP, cuData);<br>
 }<br>
<br>
 /* encode a CU block recursively */<br>
-void Entropy::encodeCU(TComDataCU* cu, uint32_t absPartIdx, uint32_t depth, bool bInsidePicture, bool& bEncodeDQP)<br>
+void Entropy::encodeCU(TComDataCU* cu, uint32_t absPartIdx, uint32_t depth, bool& bEncodeDQP, CU* cuData)<br>
 {<br>
     Frame* pic = cu->m_pic;<br>
     Slice* slice = cu->m_slice;<br>
@@ -496,30 +496,26 @@<br>
     if (depth <= slice->m_pps->maxCuDQPDepth && slice->m_pps->bUseDQP)<br>
         bEncodeDQP = true;<br>
<br>
-    if (!bInsidePicture)<br>
+    int cu_split_flag = !(cuData->flags & CU::LEAF);<br>
+    int cu_unsplit_flag = !(cuData->flags & CU::SPLIT_MANDATORY);<br>
+<br>
+    uint32_t xmax = slice->m_sps->picWidthInLumaSamples  - cu->getCUPelX();<br>
+    uint32_t ymax = slice->m_sps->picHeightInLumaSamples - cu->getCUPelY();<br>
+<br>
+    if (!cu_unsplit_flag)<br>
     {<br>
-        uint32_t xmax = slice->m_sps->picWidthInLumaSamples  - cu->getCUPelX();<br>
-        uint32_t ymax = slice->m_sps->picHeightInLumaSamples - cu->getCUPelY();<br>
-        uint32_t cuSize = g_maxCUSize >> depth;<br>
-<br>
-        bInsidePicture = (g_zscanToPelX[absPartIdx] + cuSize <= xmax &&<br>
-                          g_zscanToPelY[absPartIdx] + cuSize <= ymax);<br>
-<br>
-        if (!bInsidePicture)<br>
+        uint32_t qNumParts = (pic->getNumPartInCU() >> (depth << 1)) >> 2;<br>
+        for (uint32_t partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++, absPartIdx += qNumParts)<br>
         {<br>
-            uint32_t qNumParts = (pic->getNumPartInCU() >> (depth << 1)) >> 2;<br>
-            for (uint32_t partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++, absPartIdx += qNumParts)<br>
-            {<br>
-                if (g_zscanToPelX[absPartIdx] < xmax && g_zscanToPelY[absPartIdx] < ymax)<br>
-                    encodeCU(cu, absPartIdx, depth + 1, bInsidePicture, bEncodeDQP);<br>
-            }<br>
-<br>
-            return;<br>
+            CU *childCU = cu->m_CULocalData + cuData->childIdx + partUnitIdx;<br>
+            if (g_zscanToPelX[absPartIdx] < xmax && g_zscanToPelY[absPartIdx] < ymax)<br></blockquote><div><br></div><div>Most of the patch looks correct, but can't the above if-check also replaced by one of the childCU flags? <br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+                encodeCU(cu, absPartIdx, depth + 1, bEncodeDQP, childCU);<br>
         }<br>
+        return;<br>
     }<br>
<br>
     // We need to split, so don't try these modes.<br>
-    if (bInsidePicture && depth < g_maxCUDepth)<br>
+    if (cu_split_flag)<br>
         codeSplitFlag(cu, absPartIdx, depth);<br>
<br>
     if (depth < cu->getDepth(absPartIdx) && depth < g_maxCUDepth)<br>
@@ -527,7 +523,10 @@<br>
         uint32_t qNumParts = (pic->getNumPartInCU() >> (depth << 1)) >> 2;<br>
<br>
         for (uint32_t partUnitIdx = 0; partUnitIdx < 4; partUnitIdx++, absPartIdx += qNumParts)<br>
-            encodeCU(cu, absPartIdx, depth + 1, bInsidePicture, bEncodeDQP);<br>
+        {<br>
+            CU *childCU = cu->m_CULocalData + cuData->childIdx + partUnitIdx;<br>
+            encodeCU(cu, absPartIdx, depth + 1, bEncodeDQP, childCU);<br>
+        }<br>
         return;<br>
     }<br>
<br>
diff -r 7e29b10982d2 -r bf4ebe5df0ca source/encoder/entropy.h<br>
--- a/source/encoder/entropy.h  Thu Sep 11 19:24:28 2014 +0530<br>
+++ b/source/encoder/entropy.h  Fri Sep 12 18:05:10 2014 +0530<br>
@@ -148,7 +148,7 @@<br>
     void codeShortTermRefPicSet(RPS* rps);<br>
     void finishSlice()                 { encodeBinTrm(1); finish(); dynamic_cast<Bitstream*>(m_bitIf)->writeByteAlignment(); }<br>
<br>
-    void encodeCTU(TComDataCU* cu);<br>
+    void encodeCTU(TComDataCU* cu, CU *cuData);<br>
     void codeSaoOffset(SaoLcuParam* saoLcuParam, uint32_t compIdx);<br>
     void codeSaoUnitInterleaving(int compIdx, bool saoFlag, int rx, int ry, SaoLcuParam* saoLcuParam, int cuAddrInSlice, int cuAddrUpInSlice, int allowMergeLeft, int allowMergeUp);<br>
     void codeSaoMerge(uint32_t code)   { encodeBin(code, m_contextState[OFF_SAO_MERGE_FLAG_CTX]); }<br>
@@ -193,7 +193,7 @@<br>
     void encodeBinsEP(uint32_t binValues, int numBins);<br>
     void encodeBinTrm(uint32_t binValue);<br>
<br>
-    void encodeCU(TComDataCU* cu, uint32_t absPartIdx, uint32_t depth, bool bInsidePicture, bool& bEncodeDQP);<br>
+    void encodeCU(TComDataCU* cu, uint32_t absPartIdx, uint32_t depth, bool& bEncodeDQP, CU *cuData);<br>
     void finishCU(TComDataCU* cu, uint32_t absPartIdx, uint32_t depth);<br>
<br>
     void writeOut();<br>
diff -r 7e29b10982d2 -r bf4ebe5df0ca source/encoder/frameencoder.cpp<br>
--- a/source/encoder/frameencoder.cpp   Thu Sep 11 19:24:28 2014 +0530<br>
+++ b/source/encoder/frameencoder.cpp   Fri Sep 12 18:05:10 2014 +0530<br>
@@ -470,8 +470,9 @@<br>
             }<br>
         }<br>
<br>
+        m_tld.cuCoder.loadCTUData(cu);<br>
         // final coding (bitstream generation) for this CU<br>
-        m_entropyCoder.encodeCTU(cu);<br>
+        m_entropyCoder.encodeCTU(cu,  cu->m_CULocalData);<br>
<br>
         if (m_param->bEnableWavefront)<br>
         {<br>
@@ -689,12 +690,13 @@<br>
             // load current best state from go-on entropy coder<br>
             curRow.rdEntropyCoders[0][CI_CURR_BEST].load(rowCoder);<br>
<br>
+        tld.cuCoder.loadCTUData(cu);<br>
         tld.cuCoder.m_quant.setQPforQuant(cu);<br>
         tld.cuCoder.compressCU(cu); // Does all the CU analysis<br>
<br>
         /* advance top-level row coder to include the context of this CTU.<br>
          * if SAO is disabled, rowCoder writes the final CTU bitstream */<br>
-        rowCoder.encodeCTU(cu);<br>
+        rowCoder.encodeCTU(cu, cu->m_CULocalData);<br>
<br>
         if (m_param->bEnableWavefront && col == 1)<br>
             // Save CABAC state for next row<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></div></div>