Optimize allocation of txb,context_ext buffers
txb and context_ext buffers are not used in the stats generation stage
(firstpass/LAP), however, they are allocated memory for those stages.
Removed unneeded memory allocations to those buffers.
Observed memory footprint reduction in singlepass AOM_Q.
Resolution Memory
Single
Thread
1920x1080 ~6.0%
Memory measuring command:
$ valgrind --tool=massif ./aomenc ...
Change-Id: I0649ebee14ebfde34d689dd8d517a49c6bf5598e
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 55bf534..22b87ee 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -1104,9 +1104,11 @@
ALIGN_POWER_OF_TWO(cm->mi_params.mi_rows, cm->seq_params.mib_size_log2);
int sb_rows = mi_rows_aligned_to_sb >> cm->seq_params.mib_size_log2;
- av1_alloc_txb_buf(cpi);
+ if (!is_stat_generation_stage(cpi)) {
+ av1_alloc_txb_buf(cpi);
- alloc_context_buffers_ext(cpi);
+ alloc_context_buffers_ext(cpi);
+ }
aom_free(cpi->tile_tok[0][0]);
aom_free(cpi->tplist[0][0]);
@@ -1213,7 +1215,7 @@
av1_init_macroblockd(cm, xd, NULL);
- alloc_context_buffers_ext(cpi);
+ if (!is_stat_generation_stage(cpi)) alloc_context_buffers_ext(cpi);
set_tile_info(cpi);
}