<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 1390911442 -19800</div><div>#      Tue Jan 28 17:47:22 2014 +0530</div>
<div># Node ID 50916775f873c07477da1c3b0dfaef0c19c0d564</div><div># Parent  3568c1b19947f8641504c69bca6ab859ed11825e</div><div>default weightP: fix crash due to access of lowres array of references with invalid mvs in weightCost</div>
<div><br></div><div>diff -r 3568c1b19947 -r 50916775f873 source/encoder/weightPrediction.cpp</div><div>--- a/source/encoder/weightPrediction.cpp<span class="" style="white-space:pre">   </span>Tue Jan 28 01:49:03 2014 -0600</div>
<div>+++ b/source/encoder/weightPrediction.cpp<span class="" style="white-space:pre">   </span>Tue Jan 28 17:47:22 2014 +0530</div><div>@@ -119,7 +119,7 @@</div><div>             nonBorderCU = (x > 0) && (x < m_frmWidth - 8 - 1) && (y > 0) && (y < m_frmHeight - 8 - 1);</div>
<div>             if (nonBorderCU)</div><div>             {</div><div>-                if (m_mvs)</div><div>+                if (m_mcFlag)</div><div>                 {</div><div>                     if (m_mvCost[mb] < m_intraCost[mb])</div>
<div>                     {</div><div>@@ -188,7 +188,7 @@</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>+            m_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>@@ -200,7 +200,7 @@</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>+                    m_mcFlag = true;</div><div>                 }</div><div>             }</div><div>             const float epsilon = 1.f / 128.f;</div><div>@@ -220,7 +220,6 @@</div><div>                     log2denom[1] = X265_MIN(log2denom[1], (int)fw[yuv].log2WeightDenom);</div>
<div>                 }</div><div>             }</div><div>-</div><div>             log2denom[2] = log2denom[1];</div><div>             for (int yuv = 0; yuv < 3; yuv++)</div><div>             {</div><div>@@ -247,7 +246,7 @@</div>
<div>                 case 0:</div><div>                     m_mcbuf = ref->fpelPlane;</div><div>                     m_inbuf = fenc->lowresPlane[0];</div><div>-                    if(mcFlag)</div><div>+                    if(m_mcFlag)</div>
<div>                     {</div><div>                         pixel *tempm_buf;</div><div>                         pixel m_buf8[8 * 8];</div><div>@@ -271,7 +270,7 @@</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>+                        m_mcbuf = m_buf;</div><div>                     }</div>
<div>                     break;</div><div>                 case 1:</div><div>@@ -279,7 +278,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(mcFlag) mcChroma();</div><div>+                    if(m_mcFlag) mcChroma();</div>
<div>                     break;</div><div> </div><div>                 case 2:</div><div>@@ -287,7 +286,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(mcFlag) mcChroma();</div><div>+                    if(m_mcFlag) mcChroma();</div>
<div>                     break;</div><div>                 }</div><div> </div><div>diff -r 3568c1b19947 -r 50916775f873 source/encoder/weightPrediction.h</div><div>--- a/source/encoder/weightPrediction.h<span class="" style="white-space:pre">     </span>Tue Jan 28 01:49:03 2014 -0600</div>
<div>+++ b/source/encoder/weightPrediction.h<span class="" style="white-space:pre">     </span>Tue Jan 28 17:47:22 2014 +0530</div><div>@@ -43,6 +43,7 @@</div><div>     int32_t *m_intraCost;</div><div>     MV *m_mvs;</div><div>
     int m_bframes;</div><div>+    bool m_mcFlag;</div><div> </div><div> public:</div><div> </div><div>@@ -58,6 +59,7 @@</div><div>         m_refStride = m_slice->getPic()->m_lowres.lumaStride;</div><div>         m_intraCost = m_slice->getPic()->m_lowres.intraCost;</div>
<div>         m_bframes = param.bframes;</div><div>+        m_mcFlag = false;</div><div> </div><div>         m_mcbuf = NULL;</div><div>         m_inbuf = NULL;</div></div>