From e779b2f3812954516c780e0ce4f182d581ad6d92 Mon Sep 17 00:00:00 2001 From: sdeng Date: Mon, 29 Apr 2019 09:31:13 -0700 Subject: Refactor the SSIM based rdmult update function Change-Id: I335103689659d9a2b291c4da54f07cdd9c2b1a6d --- vp9/encoder/vp9_encodeframe.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'vp9') diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index a5d59b69b..0e3737f37 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -257,8 +257,8 @@ static INLINE void set_mode_info_offsets(VP9_COMMON *const cm, 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 @@ static double get_ssim_rdmult_scaling_factor(VP9_COMP *const cpi, int mi_row, 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 @@ static void set_offsets(VP9_COMP *cpi, const TileInfo *const tile, 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 @@ static void set_segment_rdmult(VP9_COMP *const cpi, MACROBLOCK *const x, } 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 @@ static void encode_b(VP9_COMP *cpi, const TileInfo *const tile, ThreadData *td, 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 @@ static void rd_pick_partition(VP9_COMP *cpi, ThreadData *td, 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; -- cgit v1.2.3