shithub: libvpx

Download patch

ref: 4dc70fa7f9a47096b5062f7d0600aafe4878dec4
parent: 93f88ab55abfe0262789d6312f549d3adc484c58
author: Ronald S. Bultje <[email protected]>
date: Fri Jun 21 13:19:36 EDT 2013

Don't re-allocate comp_pred buffers for each call to comp motion search.

Instead, just allocate a few bytes on the stack, this is 4k, which isn't
all that much.

Change-Id: I82af6ee89e6ed01faaa23ff891ee7ced76df8c16

--- a/vp9/encoder/vp9_mcomp.c
+++ b/vp9/encoder/vp9_mcomp.c
@@ -447,7 +447,7 @@
   int offset;
   int usehp = xd->allow_high_precision_mv;
 
-  uint8_t *comp_pred = vpx_memalign(16, w * h * sizeof(uint8_t));
+  DECLARE_ALIGNED_ARRAY(16, uint8_t, comp_pred, 64 * 64);
   uint8_t *y = xd->plane[0].pre[0].buf +
                (bestmv->as_mv.row) * xd->plane[0].pre[0].stride +
                bestmv->as_mv.col;
@@ -597,8 +597,6 @@
   bestmv->as_mv.row = br;
   bestmv->as_mv.col = bc;
 
-  vpx_free(comp_pred);
-
   if ((abs(bestmv->as_mv.col - ref_mv->as_mv.col) > (MAX_FULL_PEL_VAL << 3)) ||
       (abs(bestmv->as_mv.row - ref_mv->as_mv.row) > (MAX_FULL_PEL_VAL << 3)))
     return INT_MAX;
@@ -2356,7 +2354,7 @@
   int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]};
 
   /* Compound pred buffer */
-  uint8_t *comp_pred = vpx_memalign(16, w * h * sizeof(uint8_t));
+  DECLARE_ALIGNED_ARRAY(16, uint8_t, comp_pred, 64 * 64);
 
   fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
   fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
@@ -2420,10 +2418,8 @@
         (unsigned int *)(&thissad)) +
         mv_err_cost(&this_mv, center_mv, mvjcost, mvcost, x->errorperbit,
                     xd->allow_high_precision_mv);
-    vpx_free(comp_pred);
     return besterr;
   } else {
-    vpx_free(comp_pred);
     return INT_MAX;
   }
 }