Conditionally allocate frame mv buffer
Frame level motion vector and reference frame
buffer is allocated only when temporal mv prediction
is enabled.
Peak Memory Reduction (%)
Resolution single thread (rt speed 10)
320x180 0.79
320x240 0.92
640x360 1.48
640x480 1.64
1280x720 2.03
HEAP memory reduction was measured using the following command.
$valgrind --tool=massif ./aomenc ...
Change-Id: I2498ceb45486cf7cab6311159b3e2675580a2faf
diff --git a/av1/common/av1_common_int.h b/av1/common/av1_common_int.h
index fd2ec06..a7c20f5 100644
--- a/av1/common/av1_common_int.h
+++ b/av1/common/av1_common_int.h
@@ -1219,21 +1219,26 @@
const int buf_cols = buf->mi_cols;
const CommonModeInfoParams *const mi_params = &cm->mi_params;
- if (buf->mvs == NULL || buf_rows != mi_params->mi_rows ||
+ if (buf->seg_map == NULL || buf_rows != mi_params->mi_rows ||
buf_cols != mi_params->mi_cols) {
- aom_free(buf->mvs);
buf->mi_rows = mi_params->mi_rows;
buf->mi_cols = mi_params->mi_cols;
- CHECK_MEM_ERROR(cm, buf->mvs,
- (MV_REF *)aom_calloc(((mi_params->mi_rows + 1) >> 1) *
- ((mi_params->mi_cols + 1) >> 1),
- sizeof(*buf->mvs)));
aom_free(buf->seg_map);
CHECK_MEM_ERROR(
cm, buf->seg_map,
(uint8_t *)aom_calloc(mi_params->mi_rows * mi_params->mi_cols,
sizeof(*buf->seg_map)));
}
+ if (buf->mvs == NULL || buf_rows != mi_params->mi_rows ||
+ buf_cols != mi_params->mi_cols) {
+ if (cm->seq_params->order_hint_info.enable_ref_frame_mvs) {
+ aom_free(buf->mvs);
+ CHECK_MEM_ERROR(cm, buf->mvs,
+ (MV_REF *)aom_calloc(((mi_params->mi_rows + 1) >> 1) *
+ ((mi_params->mi_cols + 1) >> 1),
+ sizeof(*buf->mvs)));
+ }
+ }
const int mem_size =
((mi_params->mi_rows + MAX_MIB_SIZE) >> 1) * (mi_params->mi_stride >> 1);