}
#endif // !CONFIG_REALTIME_ONLY
+ cpi->mb_wiener_var_cols = 0;
+ cpi->mb_wiener_var_rows = 0;
+ cpi->mb_wiener_variance = NULL;
+
vp9_set_speed_features_framesize_independent(cpi, oxcf->speed);
vp9_set_speed_features_framesize_dependent(cpi, oxcf->speed);
- // TODO(jingning): The buffer allocation will be refactored next.
- CHECK_MEM_ERROR(
- cm, cpi->mb_wiener_variance,
- vpx_calloc(cm->mb_rows * cm->mb_cols, sizeof(*cpi->mb_wiener_variance)));
-
{
const int bsize = BLOCK_64X64;
const int w = num_8x8_blocks_wide_lookup[bsize];
return 0;
}
+static void init_mb_wiener_var_buffer(VP9_COMP *cpi) {
+ VP9_COMMON *cm = &cpi->common;
+
+ if (cpi->mb_wiener_variance && cpi->mb_wiener_var_rows >= cm->mb_rows &&
+ cpi->mb_wiener_var_cols >= cm->mb_cols)
+ return;
+
+ vpx_free(cpi->mb_wiener_variance);
+ cpi->mb_wiener_variance = NULL;
+
+ CHECK_MEM_ERROR(
+ cm, cpi->mb_wiener_variance,
+ vpx_calloc(cm->mb_rows * cm->mb_cols, sizeof(*cpi->mb_wiener_variance)));
+ cpi->mb_wiener_var_rows = cm->mb_rows;
+ cpi->mb_wiener_var_cols = cm->mb_cols;
+}
+
static void set_mb_wiener_variance(VP9_COMP *cpi) {
VP9_COMMON *cm = &cpi->common;
uint8_t *buffer = cpi->Source->y_buffer;
if (oxcf->tuning == VP8_TUNE_SSIM) set_mb_ssim_rdmult_scaling(cpi);
- if (oxcf->aq_mode == PERCEPTUAL_AQ) set_mb_wiener_variance(cpi);
+ if (oxcf->aq_mode == PERCEPTUAL_AQ) {
+ init_mb_wiener_var_buffer(cpi);
+ set_mb_wiener_variance(cpi);
+ }
vpx_clear_system_state();