refine memory in av1_rd_pick_inter_mode_sb()
tmp_buf_orig in av1_rd_pick_inter_mode_sb() is allocated and freed repeatly,
and its usage is not overlapped with tmp_obmc_bufs, so use tmp_obmc_bufs[0] instead.
Change-Id: Ieb74cb58958cd69cd182fb9f8902b79a89564379
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index ee8ba12..f393728 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -2435,7 +2435,7 @@
for (int i = 0; i < 2; ++i) {
if (x->tmp_obmc_bufs[i] == NULL) {
CHECK_MEM_ERROR(cm, x->tmp_obmc_bufs[i],
- aom_memalign(16, 2 * MAX_MB_PLANE * MAX_SB_SQUARE *
+ aom_memalign(32, 2 * MAX_MB_PLANE * MAX_SB_SQUARE *
sizeof(*x->tmp_obmc_bufs[i])));
x->e_mbd.tmp_obmc_bufs[i] = x->tmp_obmc_bufs[i];
}
@@ -3043,6 +3043,7 @@
aom_free(thread_data->td->above_pred_buf);
aom_free(thread_data->td->left_pred_buf);
aom_free(thread_data->td->wsrc_buf);
+
#if CONFIG_COLLECT_INTER_MODE_RD_STATS
aom_free(thread_data->td->inter_modes_info);
#endif
diff --git a/av1/encoder/ethread.c b/av1/encoder/ethread.c
index 13f5b8a..96afa36 100644
--- a/av1/encoder/ethread.c
+++ b/av1/encoder/ethread.c
@@ -416,7 +416,7 @@
for (int j = 0; j < 2; ++j) {
CHECK_MEM_ERROR(
cm, thread_data->td->tmp_obmc_bufs[j],
- aom_memalign(16, 2 * MAX_MB_PLANE * MAX_SB_SQUARE *
+ aom_memalign(32, 2 * MAX_MB_PLANE * MAX_SB_SQUARE *
sizeof(*thread_data->td->tmp_obmc_bufs[j])));
}
@@ -494,6 +494,7 @@
thread_data->td->mb.above_pred_buf = thread_data->td->above_pred_buf;
thread_data->td->mb.left_pred_buf = thread_data->td->left_pred_buf;
thread_data->td->mb.wsrc_buf = thread_data->td->wsrc_buf;
+
#if CONFIG_COLLECT_INTER_MODE_RD_STATS
thread_data->td->mb.inter_modes_info = thread_data->td->inter_modes_info;
#endif
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 812438c..44ac7be 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -11573,13 +11573,7 @@
int reach_first_comp_mode = 0;
// Temporary buffers used by handle_inter_mode().
- // We allocate them once and reuse it in every call to that function.
- // Note: Must be allocated on the heap due to large size of the arrays.
- uint8_t *tmp_buf_orig;
- CHECK_MEM_ERROR(
- cm, tmp_buf_orig,
- (uint8_t *)aom_memalign(32, 2 * MAX_MB_PLANE * MAX_SB_SQUARE));
- uint8_t *const tmp_buf = get_buf_by_bd(xd, tmp_buf_orig);
+ uint8_t *const tmp_buf = get_buf_by_bd(xd, x->tmp_obmc_bufs[0]);
CompoundTypeRdBuffers rd_buffers;
alloc_compound_type_rd_buffers(cm, &rd_buffers);
@@ -11836,8 +11830,6 @@
if (x->skip && !comp_pred) break;
}
- aom_free(tmp_buf_orig);
- tmp_buf_orig = NULL;
release_compound_type_rd_buffers(&rd_buffers);
#if CONFIG_COLLECT_INTER_MODE_RD_STATS