Reduce the tpl model memory usage
Reduce the tpl model memory usage to 35 frames. The memory footprint
before enabling 32 max gop length was 36 frames. The net change is
hence 1 frame less.
Change-Id: I847d6c7b16d0e3c166b44ee47fd9e2ee087a7932
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index a4675ef..751e0dd 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -3162,6 +3162,7 @@
#endif
set_tpl_stats_block_size(cpi);
+
for (int frame = 0; frame < MAX_LENGTH_TPL_FRAME_STATS; ++frame) {
const int mi_cols = ALIGN_POWER_OF_TWO(cm->mi_cols, MAX_MIB_SIZE_LOG2);
const int mi_rows = ALIGN_POWER_OF_TWO(cm->mi_rows, MAX_MIB_SIZE_LOG2);
@@ -3174,21 +3175,23 @@
cpi->tpl_stats_buffer[frame].stride = cpi->tpl_stats_buffer[frame].width;
cpi->tpl_stats_buffer[frame].mi_rows = cm->mi_rows;
cpi->tpl_stats_buffer[frame].mi_cols = cm->mi_cols;
+ }
+ for (int frame = 0; frame < MAX_LAG_BUFFERS; ++frame) {
CHECK_MEM_ERROR(
- cm, cpi->tpl_stats_buffer[frame].tpl_stats_ptr,
+ cm, cpi->tpl_stats_pool[frame],
aom_calloc(cpi->tpl_stats_buffer[frame].width *
cpi->tpl_stats_buffer[frame].height,
sizeof(*cpi->tpl_stats_buffer[frame].tpl_stats_ptr)));
-
- if (aom_alloc_frame_buffer(
- &cpi->tpl_stats_buffer[frame].rec_picture_buf, cm->width,
- cm->height, cm->seq_params.subsampling_x,
- cm->seq_params.subsampling_y, cm->seq_params.use_highbitdepth,
- AOM_ENC_NO_SCALE_BORDER, cm->byte_alignment))
+ if (aom_alloc_frame_buffer(&cpi->tpl_rec_pool[frame], cm->width, cm->height,
+ cm->seq_params.subsampling_x,
+ cm->seq_params.subsampling_y,
+ cm->seq_params.use_highbitdepth,
+ AOM_ENC_NO_SCALE_BORDER, cm->byte_alignment))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate frame buffer");
}
+
cpi->tpl_frame = &cpi->tpl_stats_buffer[REF_FRAMES + 1];
#if CONFIG_COLLECT_PARTITION_STATS == 2
@@ -3530,12 +3533,9 @@
#endif
}
- for (int frame = 0; frame < MAX_LENGTH_TPL_FRAME_STATS; ++frame) {
- aom_free(cpi->tpl_stats_buffer[frame].tpl_stats_ptr);
- cpi->tpl_stats_buffer[frame].is_valid = 0;
-
- aom_free_frame_buffer(&cpi->tpl_stats_buffer[frame].rec_picture_buf);
- cpi->tpl_stats_buffer[frame].rec_picture = NULL;
+ for (int frame = 0; frame < MAX_LAG_BUFFERS; ++frame) {
+ aom_free(cpi->tpl_stats_pool[frame]);
+ aom_free_frame_buffer(&cpi->tpl_rec_pool[frame]);
}
for (t = cpi->num_workers - 1; t >= 0; --t) {