<div dir="ltr">The patch line in the email is not break, but in the Patchwork web page, patch line mangled by the MTU, the next patch is the same.<div><br></div><div>I don't know why this happen. I will try to send a right patch tomorrow. Thanks!</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 9, 2015 at 11:53 PM, Steve Borho <span dir="ltr"><<a href="mailto:steve@borho.org" target="_blank">steve@borho.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 10/09, Ximing Cheng wrote:<br>
> # HG changeset patch<br>
> # User Ximing Cheng <<a href="mailto:ximingcheng@tencent.com">ximingcheng@tencent.com</a>><br>
> # Date 1444372125 -28800<br>
> # Fri Oct 09 14:28:45 2015 +0800<br>
> # Node ID 4176ffb657db00f173ba15a8d54c821f6811f514<br>
> # Parent 55a4a9b920ff0385fd0b65c73c4c3f63b8a8cc65<br>
> Remove new/delete in BitCost, double the size of s_bitsizes to remove the<br>
> abs operation in bitcost<br>
<br>
</span>ah, now I see what you meant<br>
<span class=""><br>
> diff --git a/source/encoder/bitcost.cpp b/source/encoder/bitcost.cpp<br>
> --- a/source/encoder/bitcost.cpp<br>
> +++ b/source/encoder/bitcost.cpp<br>
> @@ -41,7 +41,7 @@<br>
> x265_emms(); // just to be safe<br>
><br>
> CalculateLogs();<br>
> - s_costs[qp] = new uint16_t[4 * BC_MAX_MV + 1] + 2 * BC_MAX_MV;<br>
> + s_costs[qp] = X265_MALLOC(uint16_t, 4 * BC_MAX_MV + 1) + 2 *<br>
> BC_MAX_MV;<br>
> double lambda = x265_lambda_tab[qp];<br>
><br>
> // estimate same cost for negative and positive MVD<br>
> @@ -67,11 +67,11 @@<br>
> {<br>
> if (!s_bitsizes)<br>
> {<br>
> - s_bitsizes = new float[2 * BC_MAX_MV + 1];<br>
> + s_bitsizes = X265_MALLOC(float, 4 * BC_MAX_MV + 1) + 2 * BC_MAX_MV;<br>
<br>
</span>in C++ new can never fail (it can throw an exception but it can't return<br>
NULL) but malloc can, so this becomes a risk. We'll have to check for<br>
malloc failures and abort the encode (and not try to free this pointer).<br>
<span class=""><br>
> s_bitsizes[0] = 0.718f;<br>
> float log2_2 = 2.0f / log(2.0f); // 2 x 1/log(2)<br>
> for (int i = 1; i <= 2 * BC_MAX_MV; i++)<br>
> - s_bitsizes[i] = log((float)(i + 1)) * log2_2 + 1.718f;<br>
> + s_bitsizes[i] = s_bitsizes[-i] = log((float)(i + 1)) * log2_2<br>
> + 1.718f;<br>
<br>
</span>the patch was line mangled by the MTU<br>
<span class=""><br>
> }<br>
> }<br>
><br>
> @@ -81,12 +81,12 @@<br>
> {<br>
> if (s_costs[i])<br>
> {<br>
> - delete [] (s_costs[i] - 2 * BC_MAX_MV);<br>
> + X265_FREE(s_costs[i] - 2 * BC_MAX_MV);<br>
><br>
> s_costs[i] = 0;<br>
> }<br>
> }<br>
><br>
> - delete [] s_bitsizes;<br>
> + X265_FREE(s_bitsizes - 2 * BC_MAX_MV);<br>
> s_bitsizes = 0;<br>
> }<br>
> diff --git a/source/encoder/bitcost.h b/source/encoder/bitcost.h<br>
> --- a/source/encoder/bitcost.h<br>
> +++ b/source/encoder/bitcost.h<br>
> @@ -47,14 +47,14 @@<br>
> // return bit cost of motion vector difference, without lambda<br>
> inline uint32_t bitcost(const MV& mv) const<br>
> {<br>
> - return (uint32_t)(s_bitsizes[abs(mv.x - m_mvp.x)] +<br>
> - s_bitsizes[abs(mv.y - m_mvp.y)] + 0.5f);<br>
> + return (uint32_t)(s_bitsizes[mv.x - m_mvp.x] +<br>
> + s_bitsizes[mv.y - m_mvp.y] + 0.5f);<br>
> }<br>
><br>
> static inline uint32_t bitcost(const MV& mv, const MV& mvp)<br>
> {<br>
> - return (uint32_t)(s_bitsizes[abs(mv.x - mvp.x)] +<br>
> - s_bitsizes[abs(mv.y - mvp.y)] + 0.5f);<br>
> + return (uint32_t)(s_bitsizes[mv.x - mvp.x] +<br>
> + s_bitsizes[mv.y - mvp.y] + 0.5f);<br>
<br>
</span>yeah, this should be a reasonable speedup<br>
<br>
> }<br>
><br>
> static void destroy();<br>
<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" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
Steve Borho<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" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</font></span></blockquote></div><br></div>