ref: dff4d376eaff3460e930711807ce865ff76aff3a
parent: 2a26032bd2250407dbdc6447a82a7c1ff964d84b
parent: e779b2f3812954516c780e0ce4f182d581ad6d92
author: Sai Deng <sdeng@google.com>
date: Mon Apr 29 14:35:59 EDT 2019
Merge "Refactor the SSIM based rdmult update function"
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -257,8 +257,8 @@
x->mbmi_ext = x->mbmi_ext_base + (mi_row * cm->mi_cols + mi_col);
}
-static double get_ssim_rdmult_scaling_factor(VP9_COMP *const cpi, int mi_row,
- int mi_col) {
+static void set_ssim_rdmult(VP9_COMP *const cpi, int mi_row, int mi_col,
+ int *rdmult) {
const VP9_COMMON *const cm = &cpi->common;
// SSIM rdmult scaling factors are currently 64x64 based.
@@ -270,8 +270,10 @@
const int index = row * num_cols + col;
assert(cpi->oxcf.tuning == VP8_TUNE_SSIM);
+ *rdmult =
+ (int)((double)(*rdmult) * cpi->mi_ssim_rdmult_scaling_factors[index]);
+ *rdmult = VPXMAX(*rdmult, 1);
vpx_clear_system_state();
- return cpi->mi_ssim_rdmult_scaling_factors[index];
}
static void set_offsets(VP9_COMP *cpi, const TileInfo *const tile,
@@ -310,10 +312,7 @@
x->rddiv = cpi->rd.RDDIV;
x->rdmult = cpi->rd.RDMULT;
if (oxcf->tuning == VP8_TUNE_SSIM) {
- const double ssim_factor =
- get_ssim_rdmult_scaling_factor(cpi, mi_row, mi_col);
- x->rdmult = (int)(ssim_factor * x->rdmult);
- vpx_clear_system_state();
+ set_ssim_rdmult(cpi, mi_row, mi_col, &x->rdmult);
}
// required by vp9_append_sub8x8_mvs_for_idx() and vp9_find_best_ref_mvs()
@@ -1962,10 +1961,7 @@
}
if (oxcf->tuning == VP8_TUNE_SSIM) {
- const double ssim_factor =
- get_ssim_rdmult_scaling_factor(cpi, mi_row, mi_col);
- x->rdmult = (int)(ssim_factor * x->rdmult);
- vpx_clear_system_state();
+ set_ssim_rdmult(cpi, mi_row, mi_col, &x->rdmult);
}
}
@@ -2208,10 +2204,7 @@
const VP9EncoderConfig *const oxcf = &cpi->oxcf;
x->rdmult = x->cb_rdmult;
if (oxcf->tuning == VP8_TUNE_SSIM) {
- const double ssim_factor =
- get_ssim_rdmult_scaling_factor(cpi, mi_row, mi_col);
- x->rdmult = (int)(ssim_factor * x->rdmult);
- vpx_clear_system_state();
+ set_ssim_rdmult(cpi, mi_row, mi_col, &x->rdmult);
}
}
@@ -3824,10 +3817,7 @@
int partition_mul = x->cb_rdmult;
if (oxcf->tuning == VP8_TUNE_SSIM) {
- const double ssim_factor =
- get_ssim_rdmult_scaling_factor(cpi, mi_row, mi_col);
- partition_mul = (int)(ssim_factor * partition_mul);
- vpx_clear_system_state();
+ set_ssim_rdmult(cpi, mi_row, mi_col, &partition_mul);
}
(void)*tp_orig;