<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 1390891330 -19800</div><div>#      Tue Jan 28 12:12:10 2014 +0530</div>
<div># Node ID 7abfa3ed39001e591c2def68eb05e4282f7e9414</div><div># Parent  3c2441447f2a26fbe087ed9b420fc3fd087163c3</div><div>WeightPrediction: Avoid motion compensation when difPoc is large</div><div><br></div><div>diff -r 3c2441447f2a -r 7abfa3ed3900 source/encoder/frameencoder.cpp</div>
<div>--- a/source/encoder/frameencoder.cpp<span class="" style="white-space:pre">       </span>Mon Jan 27 14:17:25 2014 -0600</div><div>+++ b/source/encoder/frameencoder.cpp<span class="" style="white-space:pre">        </span>Tue Jan 28 12:12:10 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 3c2441447f2a -r 7abfa3ed3900 source/encoder/weightPrediction.cpp</div><div>--- a/source/encoder/weightPrediction.cpp<span class="" style="white-space:pre">       </span>Mon Jan 27 14:17:25 2014 -0600</div>
<div>+++ b/source/encoder/weightPrediction.cpp<span class="" style="white-space:pre">   </span>Tue Jan 28 12:12:10 2014 +0530</div><div>@@ -188,20 +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>-            if (difPoc > m_bframes + 1)</div><div>-                continue;</div>
<div>-            else</div><div>+            if (difPoc <= m_bframes + 1)</div><div>             {</div><div>                 m_mvs = fenc->lowresMvs[list][difPoc - 1];</div><div>-                if (m_mvs[0].x == 0x7FFF)</div>
<div>-                    continue;</div><div>-                else</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>@@ -245,42 +245,44 @@</div><div>                 switch (yuv)</div><div>                 {</div><div>                 case 0:</div><div>-                {</div><div>+</div><div>                     m_mcbuf = ref->fpelPlane;</div>
<div>                     m_inbuf = fenc->lowresPlane[0];</div><div>-                    pixel *tempm_buf;</div><div>-                    pixel m_buf8[8 * 8];</div><div>-                    int pixoff = 0, cu = 0;</div>
<div>-                    intptr_t strd;</div><div>-                    for (int y = 0; y < m_frmHeight; y += 8, pixoff = y * m_refStride)</div><div>+                    if (mcFlag)</div><div>                     {</div>
<div>-                        for (int x = 0; x < m_frmWidth; x += 8, pixoff += 8, cu++)</div><div>+                        pixel *tempm_buf;</div><div>+                        pixel m_buf8[8 * 8];</div><div>+                        int pixoff = 0, cu = 0;</div>
<div>+                        intptr_t strd;</div><div>+                        for (int y = 0; y < m_frmHeight; y += 8, pixoff = y * m_refStride)</div><div>                         {</div><div>-                            if (m_mvCost[cu] > fenc->intraCost[cu])</div>
<div>+                            for (int x = 0; x < m_frmWidth; x += 8, pixoff += 8, cu++)</div><div>                             {</div><div>-                                strd = m_refStride;</div><div>-                                tempm_buf = m_inbuf + pixoff;</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>+                                }</div><div>+                                else</div><div>+                                {</div><div>+                                    strd = 8;</div><div>+                                    tempm_buf = ref->lowresMC(pixoff, m_mvs[cu], m_buf8, strd);</div>
<div>+                                    ic++;</div><div>+                                }</div><div>+                                primitives.blockcpy_pp(8, 8, m_buf + (y * m_refStride) + x, m_refStride, tempm_buf, strd);</div>
<div>                             }</div><div>-                            else</div><div>-                            {</div><div>-                                strd = 8;</div><div>-                                tempm_buf = ref->lowresMC(pixoff, m_mvs[cu], m_buf8, strd);</div>
<div>-                                ic++;</div><div>-                            }</div><div>-                            primitives.blockcpy_pp(8, 8, m_buf + (y * m_refStride) + x, m_refStride, tempm_buf, strd);</div><div>
                         }</div><div>+</div><div>+                        m_mcbuf = m_buf;</div><div>                     }</div><div>-</div><div>-                    m_mcbuf = m_buf;</div><div>                     break;</div>
<div>-                }</div><div> </div><div>                 case 1:</div><div> </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>-                    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>-                    mcChroma();</div><div>+                    if (mcFlag) mcChroma();</div><div>                     break;</div><div>                 }</div></div>