[x265] [PATCH 1 of 2] BitCost: Remove the abs and new/delete operation in BitCost

Deepthi Nandakumar deepthi at multicorewareinc.com
Mon Oct 12 11:12:43 CEST 2015


On Mon, Oct 12, 2015 at 7:56 AM, Ximing Cheng <chengximing1989 at foxmail.com>
wrote:

> # HG changeset patch
> # User Ximing Cheng <ximingcheng at tencent.com>
> # Date 1444616335 -28800
> #      Mon Oct 12 10:18:55 2015 +0800
> # Node ID 667253981f61f18c36bf5c7f607fbf6ea8cc6474
> # Parent  b6156a08b1def3584647f26096866c1a0c11e54a
> BitCost: Remove the abs and new/delete operation in BitCost
>
> diff -r b6156a08b1de -r 667253981f61 source/encoder/bitcost.cpp
> --- a/source/encoder/bitcost.cpp        Fri Oct 09 20:45:59 2015 +0530
> +++ b/source/encoder/bitcost.cpp        Mon Oct 12 10:18:55 2015 +0800
> @@ -41,7 +41,7 @@
>              x265_emms(); // just to be safe
>
>              CalculateLogs();
> -            s_costs[qp] = new uint16_t[4 * BC_MAX_MV + 1] + 2 * BC_MAX_MV;
> +            s_costs[qp] = X265_MALLOC(uint16_t, 4 * BC_MAX_MV + 1) + 2 *
> BC_MAX_MV;
>

Thanks, mostly good - can you replace X265_MALLOC with CHECKED_MALLOC?

             double lambda = x265_lambda_tab[qp];
>
>              // estimate same cost for negative and positive MVD
> @@ -67,11 +67,11 @@
>  {
>      if (!s_bitsizes)
>      {
> -        s_bitsizes = new float[2 * BC_MAX_MV + 1];
> +        s_bitsizes = X265_MALLOC(float, 4 * BC_MAX_MV + 1) + 2 *
> BC_MAX_MV;

         s_bitsizes[0] = 0.718f;
>          float log2_2 = 2.0f / log(2.0f);  // 2 x 1/log(2)
>          for (int i = 1; i <= 2 * BC_MAX_MV; i++)
> -            s_bitsizes[i] = log((float)(i + 1)) * log2_2 + 1.718f;
> +            s_bitsizes[i] = s_bitsizes[-i] = log((float)(i + 1)) * log2_2
> + 1.718f;
>      }
>  }
>
> @@ -81,12 +81,12 @@
>      {
>          if (s_costs[i])
>          {
> -            delete [] (s_costs[i] - 2 * BC_MAX_MV);
> +            X265_FREE(s_costs[i] - 2 * BC_MAX_MV);
>
>              s_costs[i] = 0;
>          }
>      }
>
> -    delete [] s_bitsizes;
> +    X265_FREE(s_bitsizes - 2 * BC_MAX_MV);
>      s_bitsizes = 0;
>  }
> diff -r b6156a08b1de -r 667253981f61 source/encoder/bitcost.h
> --- a/source/encoder/bitcost.h  Fri Oct 09 20:45:59 2015 +0530
> +++ b/source/encoder/bitcost.h  Mon Oct 12 10:18:55 2015 +0800
> @@ -47,14 +47,14 @@
>      // return bit cost of motion vector difference, without lambda
>      inline uint32_t bitcost(const MV& mv) const
>      {
> -        return (uint32_t)(s_bitsizes[abs(mv.x - m_mvp.x)] +
> -                          s_bitsizes[abs(mv.y - m_mvp.y)] + 0.5f);
> +        return (uint32_t)(s_bitsizes[mv.x - m_mvp.x] +
> +                          s_bitsizes[mv.y - m_mvp.y] + 0.5f);
>      }
>
>      static inline uint32_t bitcost(const MV& mv, const MV& mvp)
>      {
> -        return (uint32_t)(s_bitsizes[abs(mv.x - mvp.x)] +
> -                          s_bitsizes[abs(mv.y - mvp.y)] + 0.5f);
> +        return (uint32_t)(s_bitsizes[mv.x - mvp.x] +
> +                          s_bitsizes[mv.y - mvp.y] + 0.5f);
>      }
>
>      static void destroy();
>
>
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>



-- 
Deepthi Nandakumar
Engineering Manager, x265
Multicoreware, Inc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20151012/fe22d63e/attachment.html>


More information about the x265-devel mailing list