<div dir="ltr"><div><div># HG changeset patch</div><div># User Deepthi Devaki <<a href="mailto:deepthidevaki@multicorewareinc.com">deepthidevaki@multicorewareinc.com</a>></div><div># Date 1379582068 -19800</div><div>
# Node ID d52de033d7dde002bbbb55e9d55ece138c33fd61</div><div># Parent 26d6f155f8df69147f40f4945d99c29a52988c56</div><div>lookahead: fix crash for I frame cost estimation</div><div><br></div><div>diff -r 26d6f155f8df -r d52de033d7dd source/encoder/slicetype.cpp</div>
<div>--- a/source/encoder/slicetype.cpp<span class="" style="white-space:pre"> </span>Wed Sep 18 16:13:33 2013 -0500</div><div>+++ b/source/encoder/slicetype.cpp<span class="" style="white-space:pre"> </span>Thu Sep 19 14:44:28 2013 +0530</div>
<div>@@ -360,44 +360,46 @@</div><div> mvmax.x = (uint16_t)((widthInCU - cux - 1) * cuSize + 8);</div><div> mvmax.y = (uint16_t)((heightInCU - cuy - 1) * cuSize + 8);</div><div> </div><div>- for (int i = 0; i < 1 + bBidir; i++)</div>
<div>+ if (p0 != p1)</div><div> {</div><div>- if (!bDoSearch[i])</div><div>+ for (int i = 0; i < 1 + bBidir; i++)</div><div> {</div><div>- /* Use previously calculated cost */</div>
<div>+ if (!bDoSearch[i])</div><div>+ {</div><div>+ /* Use previously calculated cost */</div><div>+ COPY2_IF_LT(bcost, *fenc_costs[i], listused, i + 1);</div><div>+ continue;</div>
<div>+ }</div><div>+ int numc = 0;</div><div>+ MV mvc[4], mvp;</div><div>+ MV *fenc_mv = fenc_mvs[i];</div><div>+</div><div>+ /* Reverse-order MV prediction. */</div>
<div>+ mvc[0] = 0;</div><div>+ mvc[2] = 0;</div><div>+#define MVC(mv) mvc[numc++] = mv;</div><div>+ if (cux < widthInCU - 1)</div><div>+ MVC(fenc_mv[1]);</div><div>+ if (cuy < heightInCU - 1)</div>
<div>+ {</div><div>+ MVC(fenc_mv[widthInCU]);</div><div>+ if (cux > 0)</div><div>+ MVC(fenc_mv[widthInCU - 1]);</div><div>+ if (cux < widthInCU - 1)</div>
<div>+ MVC(fenc_mv[widthInCU + 1]);</div><div>+ }</div><div>+#undef MVC</div><div>+ if (numc <= 1)</div><div>+ mvp = mvc[0];</div><div>+ else</div><div>
+ {</div><div>+ x265_median_mv(mvp, mvc[0], mvc[1], mvc[2]);</div><div>+ }</div><div>+</div><div>+ *fenc_costs[i] = me.motionEstimate(i ? fref1 : fref0, mvmin, mvmax, mvp, numc, mvc, merange, *fenc_mvs[i]);</div>
<div> COPY2_IF_LT(bcost, *fenc_costs[i], listused, i + 1);</div><div>- continue;</div><div> }</div><div>- int numc = 0;</div><div>- MV mvc[4], mvp;</div><div>- MV *fenc_mv = fenc_mvs[i];</div>
<div>-</div><div>- /* Reverse-order MV prediction. */</div><div>- mvc[0] = 0;</div><div>- mvc[2] = 0;</div><div>-#define MVC(mv) mvc[numc++] = mv;</div><div>- if (cux < widthInCU - 1)</div><div>
- MVC(fenc_mv[1]);</div><div>- if (cuy < heightInCU - 1)</div><div>- {</div><div>- MVC(fenc_mv[widthInCU]);</div><div>- if (cux > 0)</div><div>- MVC(fenc_mv[widthInCU - 1]);</div>
<div>- if (cux < widthInCU - 1)</div><div>- MVC(fenc_mv[widthInCU + 1]);</div><div>- }</div><div>-#undef MVC</div><div>- if (numc <= 1)</div><div>- mvp = mvc[0];</div>
<div>- else</div><div>- {</div><div>- x265_median_mv(mvp, mvc[0], mvc[1], mvc[2]);</div><div>- }</div><div>-</div><div>- *fenc_costs[i] = me.motionEstimate(i ? fref1 : fref0, mvmin, mvmax, mvp, numc, mvc, merange, *fenc_mvs[i]);</div>
<div>- COPY2_IF_LT(bcost, *fenc_costs[i], listused, i + 1);</div><div> }</div><div>-</div><div> if (!fenc->bIntraCalculated)</div><div> {</div><div> int nLog2SizeMinus2 = g_convertToBit[cuSize]; // partition size</div>
</div><div><br></div></div>