ref: 775706c4534475ace8c3b68516e40628ee03808f
parent: ea78306257fa185255ef922541306d2a9ab1b744
author: Jingning Han <jingning@google.com>
date: Mon May 21 06:13:53 EDT 2018
Allocate tpl_dep_stats frame buffer Allocate buffers to support gather temporal dependency statistics at the encoder. Change-Id: I97d4594913a2423e8a916f20caf82ab0f5836961
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -2085,7 +2085,7 @@
VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf,
BufferPool *const pool) {
- unsigned int i;
+ unsigned int i, frame;
VP9_COMP *volatile const cpi = vpx_memalign(32, sizeof(VP9_COMP));
VP9_COMMON *volatile const cm = cpi != NULL ? &cpi->common : NULL;
@@ -2333,6 +2333,16 @@
}
#endif // !CONFIG_REALTIME_ONLY
+ for (frame = 0; frame < MAX_LAG_BUFFERS; ++frame) {
+ CHECK_MEM_ERROR(cm, cpi->tpl_stats[frame].tpl_stats_ptr,
+ vpx_calloc(cm->mi_rows * cm->mi_cols,
+ sizeof(*cpi->tpl_stats[frame].tpl_stats_ptr)));
+ cpi->tpl_stats[frame].is_valid = 1;
+ cpi->tpl_stats[frame].width = cm->mi_cols;
+ cpi->tpl_stats[frame].height = cm->mi_rows;
+ cpi->tpl_stats[frame].stride = cm->mi_cols;
+ }
+
vp9_set_speed_features_framesize_independent(cpi);
vp9_set_speed_features_framesize_dependent(cpi);
@@ -2424,7 +2434,7 @@
void vp9_remove_compressor(VP9_COMP *cpi) {
VP9_COMMON *cm;
- unsigned int i;
+ unsigned int i, frame;
int t;
if (!cpi) return;
@@ -2518,6 +2528,12 @@
#if CONFIG_VP9_TEMPORAL_DENOISING
vp9_denoiser_free(&(cpi->denoiser));
#endif
+
+ for (frame = 0; frame < MAX_LAG_BUFFERS; ++frame) {
+ if (cpi->tpl_stats[frame].is_valid)
+ vpx_free(cpi->tpl_stats[frame].tpl_stats_ptr);
+ cpi->tpl_stats[frame].is_valid = 0;
+ }
for (t = 0; t < cpi->num_workers; ++t) {
VPxWorker *const worker = &cpi->workers[t];