<div dir="ltr"><div># HG changeset patch</div><div># User Kavitha Sampath <<a href="mailto:kavitha@multicorewareinc.com">kavitha@multicorewareinc.com</a>></div><div># Date 1390879943 -19800</div><div>#      Tue Jan 28 09:02:23 2014 +0530</div>
<div># Node ID 32a73eb61f9a33103e07173a35c7f723c23a2bd0</div><div># Parent  b59b1e579f78b4c29c0c1491e6198a63ba1d597f</div><div>WeightPrediction: Avoid motion compensation when difPoc is large</div><div><br></div><div>diff -r b59b1e579f78 -r 32a73eb61f9a source/encoder/frameencoder.cpp</div>
<div>--- a/source/encoder/frameencoder.cpp<span class="" style="white-space:pre">       </span>Mon Jan 27 00:10:56 2014 -0600</div><div>+++ b/source/encoder/frameencoder.cpp<span class="" style="white-space:pre">        </span>Tue Jan 28 09:02:23 2014 +0530</div>
<div>@@ -465,7 +465,7 @@</div><div>         //------------------------------------------------------------------------------</div><div>         //  Weighted Prediction implemented at Slice level. SliceMode=2 is not supported yet.</div>
<div>         //------------------------------------------------------------------------------</div><div>-        WeightPrediction wp(slice);</div><div>+        WeightPrediction wp(slice, m_cfg->param);</div><div>         wp.weightAnalyseEnc();</div>
<div>     }</div><div> </div><div>diff -r b59b1e579f78 -r 32a73eb61f9a source/encoder/weightPrediction.cpp</div><div>--- a/source/encoder/weightPrediction.cpp<span class="" style="white-space:pre">       </span>Mon Jan 27 00:10:56 2014 -0600</div>
<div>+++ b/source/encoder/weightPrediction.cpp<span class="" style="white-space:pre">   </span>Tue Jan 28 09:02:23 2014 +0530</div><div>@@ -188,18 +188,20 @@</div><div>     {</div><div>         for (int refIdxTemp = 0; (refIdxTemp < m_slice->getNumRefIdx(list)) && (numWeighted < 8); refIdxTemp++)</div>
<div>         {</div><div>+            bool mcFlag = false;</div><div>             check = 0;</div><div>             fw = m_wp[list][refIdxTemp];</div><div>             ref  = &m_slice->getRefPic(list, refIdxTemp)->m_lowres;</div>
<div>             refPoc = m_slice->getRefPic(list, refIdxTemp)->getPOC();</div><div>             difPoc = abs(curPoc - refPoc);</div><div>-            m_mvs = fenc->lowresMvs[list][difPoc - 1];</div><div>-            if (m_mvs)</div>
<div>+            if (difPoc <= m_bframes + 1)</div><div>             {</div><div>-                if (m_mvs[0].x == 0x7FFF)</div><div>-                    continue;</div><div>-                else</div><div>+                m_mvs = fenc->lowresMvs[list][difPoc - 1];</div>
<div>+                if (m_mvs[0].x != 0x7FFF)</div><div>+                {</div><div>                     m_mvCost = fenc->lowresMvCosts[0][difPoc - 1];</div><div>+                    mcFlag = true;</div><div>+                }</div>
<div>             }</div><div>             const float epsilon = 1.f / 128.f;</div><div>             float guessScale[3], fencMean[3], refMean[3];</div><div>@@ -246,7 +248,7 @@</div><div> </div><div>                     m_mcbuf = ref->fpelPlane;</div>
<div>                     m_inbuf = fenc->lowresPlane[0];</div><div>-                    if (m_mvs)</div><div>+                    if (mcFlag)</div><div>                     {</div><div>                         pixel *tempm_buf;</div>
<div>                         pixel m_buf8[8 * 8];</div><div>@@ -256,7 +258,7 @@</div><div>                         {</div><div>                             for (int x = 0; x < m_frmWidth; x += 8, pixoff += 8, cu++)</div>
<div>                             {</div><div>-                                if (fenc->lowresMvCosts[0][difPoc - 1][cu] > fenc->intraCost[cu])</div><div>+                                if (m_mvCost[cu] > fenc->intraCost[cu])</div>
<div>                                 {</div><div>                                     strd = m_refStride;</div><div>                                     tempm_buf = m_inbuf + pixoff;</div><div>@@ -280,7 +282,7 @@</div><div>
                     m_mcbuf = m_slice->getRefPic(list, refIdxTemp)->getPicYuvOrg()->getCbAddr();</div><div>                     m_inbuf = m_slice->getPic()->getPicYuvOrg()->getCbAddr();</div><div>                     m_blockSize = 8;</div>
<div>-                    if (m_mvs) mcChroma();</div><div>+                    if (mcFlag) mcChroma();</div><div>                     break;</div><div> </div><div>                 case 2:</div><div>@@ -288,7 +290,7 @@</div>
<div>                     m_mcbuf = m_slice->getRefPic(list, refIdxTemp)->getPicYuvOrg()->getCrAddr();</div><div>                     m_inbuf = m_slice->getPic()->getPicYuvOrg()->getCrAddr();</div><div>                     m_blockSize = 8;</div>
<div>-                    if (m_mvs) mcChroma();</div><div>+                    if (mcFlag) mcChroma();</div><div>                     break;</div><div>                 }</div><div> </div><div>diff -r b59b1e579f78 -r 32a73eb61f9a source/encoder/weightPrediction.h</div>
<div>--- a/source/encoder/weightPrediction.h<span class="" style="white-space:pre">     </span>Mon Jan 27 00:10:56 2014 -0600</div><div>+++ b/source/encoder/weightPrediction.h<span class="" style="white-space:pre">      </span>Tue Jan 28 09:02:23 2014 +0530</div>
<div>@@ -42,10 +42,9 @@</div><div>     pixel *m_mcbuf, *m_inbuf, *m_buf;</div><div>     int32_t *m_intraCost;</div><div>     MV *m_mvs;</div><div>-</div><div>+    int m_bframes;</div><div> public:</div><div>-</div><div>-    WeightPrediction(TComSlice *slice)</div>
<div>+    WeightPrediction(TComSlice *slice, x265_param param)</div><div>     {</div><div>         this->m_slice = slice;</div><div>         m_csp = m_slice->getPic()->getPicYuvOrg()->m_picCsp;</div><div>@@ -56,7 +55,7 @@</div>
<div>         m_dstStride = m_frmWidth;</div><div>         m_refStride = m_slice->getPic()->m_lowres.lumaStride;</div><div>         m_intraCost = m_slice->getPic()->m_lowres.intraCost;</div><div>-</div><div>+        m_bframes = param.bframes;</div>
<div>         m_mcbuf = NULL;</div><div>         m_inbuf = NULL;</div><div>         m_buf = (pixel*)X265_MALLOC(pixel, m_frmHeight * m_refStride);</div></div>