summaryrefslogtreecommitdiff
path: root/vp9/encoder/vp9_encoder.c
diff options
context:
space:
mode:
Diffstat (limited to 'vp9/encoder/vp9_encoder.c')
-rw-r--r--vp9/encoder/vp9_encoder.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
index fb462c0cb..5bf0d9610 100644
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -2388,6 +2388,7 @@ VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf,
sizeof(*cpi->mb_wiener_variance)));
}
+ cpi->kmeans_data_arr_alloc = 0;
#if CONFIG_NON_GREEDY_MV
cpi->feature_score_loc_alloc = 0;
cpi->tpl_ready = 0;
@@ -2591,6 +2592,10 @@ void vp9_remove_compressor(VP9_COMP *cpi) {
vp9_denoiser_free(&(cpi->denoiser));
#endif
+ if (cpi->kmeans_data_arr_alloc) {
+ vpx_free(cpi->kmeans_data_arr);
+ }
+
#if CONFIG_NON_GREEDY_MV
vpx_free(cpi->feature_score_loc_arr);
vpx_free(cpi->feature_score_loc_sort);
@@ -7254,6 +7259,16 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags,
for (i = 0; i < REFS_PER_FRAME; ++i) cpi->scaled_ref_idx[i] = INVALID_IDX;
}
+ if (cpi->kmeans_data_arr_alloc == 0) {
+ const int mi_cols = mi_cols_aligned_to_sb(cm->mi_cols);
+ const int mi_rows = mi_cols_aligned_to_sb(cm->mi_rows);
+ CHECK_MEM_ERROR(
+ cm, cpi->kmeans_data_arr,
+ vpx_calloc(mi_rows * mi_cols, sizeof(*cpi->kmeans_data_arr)));
+ cpi->kmeans_data_stride = mi_cols;
+ cpi->kmeans_data_arr_alloc = 1;
+ }
+
if (gf_group_index == 1 &&
cpi->twopass.gf_group.update_type[gf_group_index] == ARF_UPDATE &&
cpi->sf.enable_tpl_model) {