ref: 65df3d138a242e9d668da5d439bb842708ec9f2f
parent: 8d8d7bfde5d311bb7d4ff4e921a9dbaa8f389af5
author: Adrian Grange <[email protected]>
date: Tue Mar 24 05:44:07 EDT 2015
Replace heap with stack memory allocation Replaced the dynamic memory allocation of the second_pred buffer with an allocation on the stack. Change-Id: I2716c46b71e8587714ca5733a99eca2c68419b23
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -1549,13 +1549,6 @@
mbmi->ref_frame[1] < 0 ? 0 : mbmi->ref_frame[1]};
int_mv ref_mv[2];
int ite, ref;
- // Prediction buffer from second frame.
-#if CONFIG_VP9_HIGHBITDEPTH
- uint8_t *second_pred;
- uint8_t *second_pred_alloc;
-#else
- uint8_t *second_pred = vpx_memalign(16, pw * ph * sizeof(uint8_t));
-#endif // CONFIG_VP9_HIGHBITDEPTH
const InterpKernel *kernel = vp9_get_interp_kernel(mbmi->interp_filter);
struct scale_factors sf;
@@ -1566,14 +1559,13 @@
vp9_get_scaled_ref_frame(cpi, mbmi->ref_frame[0]),
vp9_get_scaled_ref_frame(cpi, mbmi->ref_frame[1])
};
+
+ // Prediction buffer from second frame.
#if CONFIG_VP9_HIGHBITDEPTH
- if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
- second_pred_alloc = vpx_memalign(16, pw * ph * sizeof(uint16_t));
- second_pred = CONVERT_TO_BYTEPTR(second_pred_alloc);
- } else {
- second_pred_alloc = vpx_memalign(16, pw * ph * sizeof(uint8_t));
- second_pred = second_pred_alloc;
- }
+ DECLARE_ALIGNED_ARRAY(16, uint16_t, second_pred_alloc_16, 64 * 64);
+ uint8_t *second_pred;
+#else
+ DECLARE_ALIGNED_ARRAY(16, uint8_t, second_pred, 64 * 64);
#endif // CONFIG_VP9_HIGHBITDEPTH
for (ref = 0; ref < 2; ++ref) {
@@ -1628,6 +1620,7 @@
// Get the prediction block from the 'other' reference frame.
#if CONFIG_VP9_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
+ second_pred = CONVERT_TO_BYTEPTR(second_pred_alloc_16);
vp9_highbd_build_inter_predictor(ref_yv12[!id].buf,
ref_yv12[!id].stride,
second_pred, pw,
@@ -1637,6 +1630,7 @@
mi_col * MI_SIZE, mi_row * MI_SIZE,
xd->bd);
} else {
+ second_pred = (uint8_t *)second_pred_alloc_16;
vp9_build_inter_predictor(ref_yv12[!id].buf,
ref_yv12[!id].stride,
second_pred, pw,
@@ -1722,12 +1716,6 @@
&mbmi->ref_mvs[refs[ref]][0].as_mv,
x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
}
-
-#if CONFIG_VP9_HIGHBITDEPTH
- vpx_free(second_pred_alloc);
-#else
- vpx_free(second_pred);
-#endif // CONFIG_VP9_HIGHBITDEPTH
}
static int64_t rd_pick_best_sub8x8_mode(VP9_COMP *cpi, MACROBLOCK *x,