<div dir="ltr">But this patch sets m_psyCost = psyRdCost everywhere?<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, May 26, 2014 at 4:44 PM, Sumalatha Polureddy <span dir="ltr"><<a href="mailto:sumalatha@multicorewareinc.com" target="_blank">sumalatha@multicorewareinc.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div class="h5">On Mon, May 26, 2014 at 4:26 PM, Deepthi Nandakumar <span dir="ltr"><<a href="mailto:deepthi@multicorewareinc.com" target="_blank">deepthi@multicorewareinc.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div>On Mon, May 26, 2014 at 3:02 PM,  <span dir="ltr"><<a href="mailto:sumalatha@multicorewareinc.com" target="_blank">sumalatha@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 Sumalatha Polureddy<<a href="mailto:sumalatha@multicorewareinc.com" target="_blank">sumalatha@multicorewareinc.com</a>><br>
# Date 1401087565 -19800<br>
# Node ID cbe5cc0e48b4122518ca732a1b32de16ba25c467<br>
# Parent  5134e76aa729b6fece18701fdc00390c2f2ffb32<br>
psyrd: use psyrdcost for selecting best mode across depth<br>
<br>
diff -r 5134e76aa729 -r cbe5cc0e48b4 source/Lib/TLibCommon/TComDataCU.cpp<br>
--- a/source/Lib/TLibCommon/TComDataCU.cpp      Thu May 22 21:46:21 2014 -0500<br>
+++ b/source/Lib/TLibCommon/TComDataCU.cpp      Mon May 26 12:29:25 2014 +0530<br>
@@ -218,6 +218,7 @@<br>
     m_sa8dCost         = MAX_INT64;<br>
     m_totalDistortion  = 0;<br>
     m_totalBits        = 0;<br>
+    m_psyCost          = 0;<br>
     m_numPartitions    = pic->getNumPartInCU();<br>
     char* qp           = pic->getCU(getAddr())->getQP();<br>
     m_baseQp           = pic->getCU(getAddr())->m_baseQp;<br>
@@ -309,6 +310,7 @@<br>
     m_sa8dCost         = MAX_INT64;<br>
     m_totalDistortion  = 0;<br>
     m_totalBits        = 0;<br>
+    m_psyCost          = 0;<br>
<br>
     uint8_t cuSize = g_maxCUSize >> depth;<br>
<br>
@@ -345,6 +347,7 @@<br>
     m_sa8dCost         = MAX_INT64;<br>
     m_totalDistortion  = 0;<br>
     m_totalBits        = 0;<br>
+    m_psyCost          = 0;<br>
<br>
     uint8_t cuSize = g_maxCUSize >> depth;<br>
<br>
@@ -393,6 +396,7 @@<br>
     m_sa8dCost         = MAX_INT64;<br>
     m_totalDistortion  = 0;<br>
     m_totalBits        = 0;<br>
+    m_psyCost          = 0;<br>
     m_numPartitions    = cu->getTotalNumPart() >> 2;<br>
<br>
     for (int i = 0; i < 4; i++)<br>
@@ -457,6 +461,7 @@<br>
     m_sa8dCost         = MAX_INT64;<br>
     m_totalDistortion  = 0;<br>
     m_totalBits        = 0;<br>
+    m_psyCost          = 0;<br>
     m_numPartitions    = cu->getTotalNumPart() >> 2;<br>
<br>
     for (int i = 0; i < 4; i++)<br>
@@ -520,6 +525,7 @@<br>
     m_sa8dCost         = MAX_INT64;<br>
     m_totalDistortion  = 0;<br>
     m_totalBits        = 0;<br>
+    m_psyCost          = 0;<br>
     m_numPartitions    = cu->getTotalNumPart() >> 2;<br>
<br>
     TComDataCU* rpcCU = m_pic->getCU(m_cuAddr);<br>
@@ -550,6 +556,7 @@<br>
<br>
     m_totalDistortion  += cu->m_totalDistortion;<br>
     m_totalBits        += cu->m_totalBits;<br>
+    m_psyCost          += cu->m_psyCost;<br>
<br>
     uint32_t offset       = cu->getTotalNumPart() * partUnitIdx;<br>
     uint32_t numPartition = cu->getTotalNumPart();<br>
@@ -610,6 +617,7 @@<br>
     rpcCU->m_totalCost       = m_totalCost;<br>
     rpcCU->m_totalDistortion = m_totalDistortion;<br>
     rpcCU->m_totalBits       = m_totalBits;<br>
+    rpcCU->m_psyCost         = m_psyCost;<br>
<br>
     int sizeInBool  = sizeof(bool) * m_numPartitions;<br>
     int sizeInChar  = sizeof(char) * m_numPartitions;<br>
@@ -695,6 +703,7 @@<br>
     cu->m_totalCost       = m_totalCost;<br>
     cu->m_totalDistortion = m_totalDistortion;<br>
     cu->m_totalBits       = m_totalBits;<br>
+    cu->m_psyCost         = m_psyCost;<br>
<br>
     int sizeInBool  = sizeof(bool) * qNumPart;<br>
     int sizeInChar  = sizeof(char) * qNumPart;<br>
diff -r 5134e76aa729 -r cbe5cc0e48b4 source/Lib/TLibCommon/TComDataCU.h<br>
--- a/source/Lib/TLibCommon/TComDataCU.h        Thu May 22 21:46:21 2014 -0500<br>
+++ b/source/Lib/TLibCommon/TComDataCU.h        Mon May 26 12:29:25 2014 +0530<br>
@@ -168,6 +168,7 @@<br>
     uint64_t      m_totalCost;       ///< sum of partition RD costs<br>
     uint32_t      m_totalDistortion; ///< sum of partition distortion<br>
     uint32_t      m_totalBits;       ///< sum of partition signal bits<br>
+    uint32_t      m_psyCost;<br>
     uint64_t      m_avgCost[4];      // stores the avg cost of CU's in frame for each depth<br>
     uint32_t      m_count[4];<br>
     uint64_t      m_sa8dCost;<br>
diff -r 5134e76aa729 -r cbe5cc0e48b4 source/Lib/TLibEncoder/TEncCu.cpp<br>
--- a/source/Lib/TLibEncoder/TEncCu.cpp Thu May 22 21:46:21 2014 -0500<br>
+++ b/source/Lib/TLibEncoder/TEncCu.cpp Mon May 26 12:29:25 2014 +0530<br>
@@ -601,7 +601,14 @@<br>
         m_entropyCoder->resetBits();<br>
         m_entropyCoder->encodeSplitFlag(outBestCU, 0, depth);<br>
         outBestCU->m_totalBits += m_entropyCoder->getNumberOfWrittenBits(); // split bits<br>
-        outBestCU->m_totalCost  = m_rdCost->calcRdCost(outBestCU->m_totalDistortion, outBestCU->m_totalBits);<br>
+        if (m_rdCost->psyRdEnabled())<br>
+        {<br>
+            outBestCU->m_totalCost = m_rdCost->calcPsyRdCost(outBestCU->m_totalDistortion, outBestCU->m_totalBits, outBestCU->m_psyCost);<br></blockquote><div><br></div></div></div><div>If our objective is to catch unintended comparisons between psyCost and regular RD cost, you should save the above cost (with psyRd enabled) into m_psyCost. <br>


</div></div></div></div></blockquote></div></div><div>psyCost is the difference in energy between src and recon and it is calculated for each mode when psyrd is enabled</div><div>psyRdCost is calculated from dist, bits and psycost. In this place, it has tobe calculated again for the new "bits" with already calculated distortion and psycost for best mode.</div>

<div><div class="h5">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>

<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>
+        }<br>
+        else<br>
+        {<br>
+            outBestCU->m_totalCost = m_rdCost->calcRdCost(outBestCU->m_totalDistortion, outBestCU->m_totalBits);<br>
+        }<br>
     }<br>
<br>
     outTempCU->initEstData(depth);<br>
@@ -648,7 +655,14 @@<br>
             m_entropyCoder->encodeSplitFlag(outTempCU, 0, depth);<br>
             outTempCU->m_totalBits += m_entropyCoder->getNumberOfWrittenBits(); // split bits<br>
         }<br>
-        outTempCU->m_totalCost = m_rdCost->calcRdCost(outTempCU->m_totalDistortion, outTempCU->m_totalBits);<br>
+        if (m_rdCost->psyRdEnabled())<br>
+        {<br>
+            outTempCU->m_totalCost = m_rdCost->calcPsyRdCost(outTempCU->m_totalDistortion, outTempCU->m_totalBits, outTempCU->m_psyCost);<br>
+        }<br>
+        else<br>
+        {<br>
+            outTempCU->m_totalCost = m_rdCost->calcRdCost(outTempCU->m_totalDistortion, outTempCU->m_totalBits);<br>
+        }<br>
<br>
         if ((g_maxCUSize >> depth) == slice->getPPS()->getMinCuDQPSize() && slice->getPPS()->getUseDQP())<br>
         {<br>
@@ -923,7 +937,14 @@<br>
         m_entropyCoder->resetBits();<br>
         m_entropyCoder->encodeSplitFlag(outBestCU, 0, depth);<br>
         outBestCU->m_totalBits += m_entropyCoder->getNumberOfWrittenBits(); // split bits<br>
-        outBestCU->m_totalCost  = m_rdCost->calcRdCost(outBestCU->m_totalDistortion, outBestCU->m_totalBits);<br>
+        if (m_rdCost->psyRdEnabled())<br>
+        {<br>
+             outBestCU->m_totalCost = m_rdCost->calcPsyRdCost(outBestCU->m_totalDistortion, outBestCU->m_totalBits, outBestCU->m_psyCost);<br>
+        }<br>
+        else<br>
+        {<br>
+            outBestCU->m_totalCost = m_rdCost->calcRdCost(outBestCU->m_totalDistortion, outBestCU->m_totalBits);<br>
+        }<br>
<br>
         // Early CU determination<br>
         if (outBestCU->isSkipped(0))<br>
@@ -982,7 +1003,14 @@<br>
             m_entropyCoder->encodeSplitFlag(outTempCU, 0, depth);<br>
             outTempCU->m_totalBits += m_entropyCoder->getNumberOfWrittenBits(); // split bits<br>
         }<br>
-        outTempCU->m_totalCost = m_rdCost->calcRdCost(outTempCU->m_totalDistortion, outTempCU->m_totalBits);<br>
+        if(m_rdCost->psyRdEnabled())<br>
+        {<br>
+            outTempCU->m_totalCost = m_rdCost->calcPsyRdCost(outTempCU->m_totalDistortion, outTempCU->m_totalBits, outTempCU->m_psyCost);<br>
+        }<br>
+        else<br>
+        {<br>
+            outTempCU->m_totalCost = m_rdCost->calcRdCost(outTempCU->m_totalDistortion, outTempCU->m_totalBits);<br>
+        }<br>
<br>
         if ((g_maxCUSize >> depth) == slice->getPPS()->getMinCuDQPSize() && slice->getPPS()->getUseDQP())<br>
         {<br>
@@ -1391,6 +1419,7 @@<br>
         int part = g_convertToBit[outTempCU->getCUSize(0)];<br>
         uint32_t psyRdCost = m_rdCost->psyCost(part, m_origYuv[depth]->getLumaAddr(), m_origYuv[depth]->getStride(),<br>
                                                      m_tmpRecoYuv[depth]->getLumaAddr(), m_tmpRecoYuv[depth]->getStride());<br>
+        outTempCU->m_psyCost = psyRdCost;<br>
         outTempCU->m_totalCost = m_rdCost->calcPsyRdCost(outTempCU->m_totalDistortion, outTempCU->m_totalBits, psyRdCost);<br>
     }<br>
     else<br>
@@ -1438,6 +1467,7 @@<br>
         int part = g_convertToBit[outTempCU->getCUSize(0)];<br>
         uint32_t psyRdCost = m_rdCost->psyCost(part, m_origYuv[depth]->getLumaAddr(), m_origYuv[depth]->getStride(),<br>
                                                      m_tmpRecoYuv[depth]->getLumaAddr(), m_tmpRecoYuv[depth]->getStride());<br>
+        outTempCU->m_psyCost = psyRdCost;<br>
         outTempCU->m_totalCost = m_rdCost->calcPsyRdCost(outTempCU->m_totalDistortion, outTempCU->m_totalBits, psyRdCost);<br>
     }<br>
     else<br>
diff -r 5134e76aa729 -r cbe5cc0e48b4 source/Lib/TLibEncoder/TEncSearch.cpp<br>
--- a/source/Lib/TLibEncoder/TEncSearch.cpp     Thu May 22 21:46:21 2014 -0500<br>
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp     Mon May 26 12:29:25 2014 +0530<br>
@@ -2698,6 +2698,7 @@<br>
             int size = g_convertToBit[cu->getCUSize(0)];<br>
             uint32_t psyRdCost = m_rdCost->psyCost(size, fencYuv->getLumaAddr(), fencYuv->getStride(),<br>
                                                          outReconYuv->getLumaAddr(), outReconYuv->getStride());<br>
+            cu->m_psyCost = psyRdCost;<br>
             cu->m_totalCost = m_rdCost->calcPsyRdCost(cu->m_totalDistortion, cu->m_totalBits, psyRdCost);<br>
         }<br>
         else<br>
@@ -2789,6 +2790,7 @@<br>
         int size = g_convertToBit[cu->getCUSize(0)];<br>
         uint32_t psyRdCost = m_rdCost->psyCost(size, fencYuv->getLumaAddr(), fencYuv->getStride(),<br>
                                                      outReconYuv->getLumaAddr(), outReconYuv->getStride());<br>
+        cu->m_psyCost = psyRdCost;<br>
         bcost = m_rdCost->calcPsyRdCost(bdist, bestBits, psyRdCost);<br>
     }<br>
     else<br></div></div>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">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>
<br>_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">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>
<br></blockquote></div></div></div><br></div></div>
<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>
<br></blockquote></div><br></div>