<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 12, 2015 at 7:56 AM, Ximing Cheng <span dir="ltr"><<a href="mailto:chengximing1989@foxmail.com" target="_blank">chengximing1989@foxmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Ximing Cheng <<a href="mailto:ximingcheng@tencent.com">ximingcheng@tencent.com</a>><br>
# Date 1444616335 -28800<br>
# Mon Oct 12 10:18:55 2015 +0800<br>
# Node ID 667253981f61f18c36bf5c7f607fbf6ea8cc6474<br>
# Parent b6156a08b1def3584647f26096866c1a0c11e54a<br>
BitCost: Remove the abs and new/delete operation in BitCost<br>
<br>
diff -r b6156a08b1de -r 667253981f61 source/encoder/bitcost.cpp<br>
--- a/source/encoder/bitcost.cpp Fri Oct 09 20:45:59 2015 +0530<br>
+++ b/source/encoder/bitcost.cpp Mon Oct 12 10:18:55 2015 +0800<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 * BC_MAX_MV;<br></blockquote><div><br></div><div>Thanks, mostly good - can you replace X265_MALLOC with CHECKED_MALLOC? <br><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
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;</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
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 + 1.718f;<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 -r b6156a08b1de -r 667253981f61 source/encoder/bitcost.h<br>
--- a/source/encoder/bitcost.h Fri Oct 09 20:45:59 2015 +0530<br>
+++ b/source/encoder/bitcost.h Mon Oct 12 10:18:55 2015 +0800<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>
<br>
static void destroy();<br>
<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>
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr"><div><div>Deepthi Nandakumar<br></div>Engineering Manager, x265<br></div>Multicoreware, Inc<br></div></div>
</div></div>