Setup block level rd mult in more places
This is a preparation to enable tune=ssim.
Change-Id: Ifbc9b70465ab4df8fc14bd9eb809974ba3b2cdd7
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index e1d0ba0..d9f8292 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -256,8 +256,9 @@
const AV1_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &x->e_mbd;
x->rdmult = cpi->rd.RDMULT;
- if (cm->delta_q_info.delta_q_present_flag)
+ if (cm->delta_q_info.delta_q_present_flag) {
x->rdmult = set_deltaq_rdmult(cpi, xd);
+ }
if (cpi->oxcf.tuning == AOM_TUNE_SSIM) {
set_ssim_rdmult(cpi, x, bsize, mi_row, mi_col, &x->rdmult);
}
@@ -663,7 +664,7 @@
// Save rdmult before it might be changed, so it can be restored later.
const int orig_rdmult = x->rdmult;
- setup_block_rdmult(cpi, x, mi_row, mi_col, bsize);
+ x->rdmult = cpi->rd.RDMULT;
if (aq_mode == VARIANCE_AQ) {
if (cpi->vaq_refresh) {
@@ -681,8 +682,9 @@
x->rdmult = av1_cyclic_refresh_get_rdmult(cpi->cyclic_refresh);
}
- if (cm->delta_q_info.delta_q_present_flag)
+ if (cm->delta_q_info.delta_q_present_flag) {
x->rdmult = set_deltaq_rdmult(cpi, xd);
+ }
// Set error per bit for current rdmult
set_error_per_bit(x, x->rdmult);
@@ -1544,6 +1546,8 @@
MACROBLOCKD *xd = &x->e_mbd;
set_offsets_without_segment_id(cpi, tile, x, mi_row, mi_col, bsize);
+ const int origin_mult = x->rdmult;
+ setup_block_rdmult(cpi, x, mi_row, mi_col, bsize);
MB_MODE_INFO *mbmi = xd->mi[0];
mbmi->partition = partition;
update_state(cpi, tile_data, td, ctx, mi_row, mi_col, bsize, dry_run);
@@ -1577,6 +1581,7 @@
}
update_stats(&cpi->common, tile_data, td, mi_row, mi_col);
}
+ x->rdmult = origin_mult;
}
#if !CONFIG_REALTIME_ONLY
@@ -2214,6 +2219,8 @@
PICK_MODE_CONTEXT *prev_ctx,
PICK_MODE_CONTEXT *this_ctx) {
MACROBLOCK *const x = &td->mb;
+ const int orig_mult = x->rdmult;
+ setup_block_rdmult(cpi, x, mi_row, mi_col, subsize);
av1_rd_cost_update(x->rdmult, &best_rdcost);
if (cpi->sf.adaptive_motion_search) load_pred_mv(x, prev_ctx);
@@ -2232,7 +2239,10 @@
av1_rd_cost_update(x->rdmult, sum_rdc);
}
- if (sum_rdc->rdcost >= best_rdcost.rdcost) return 0;
+ if (sum_rdc->rdcost >= best_rdcost.rdcost) {
+ x->rdmult = orig_mult;
+ return 0;
+ }
if (!is_last) {
update_state(cpi, tile_data, td, this_ctx, mi_row, mi_col, subsize, 1);
@@ -2240,6 +2250,7 @@
subsize, NULL);
}
+ x->rdmult = orig_mult;
return 1;
}
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 6ce45b5..52958d5 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -12528,7 +12528,7 @@
void av1_rd_pick_inter_mode_sb(AV1_COMP *cpi, TileDataEnc *tile_data,
MACROBLOCK *x, int mi_row, int mi_col,
- RD_STATS *rd_cost, BLOCK_SIZE bsize,
+ RD_STATS *rd_cost, const BLOCK_SIZE bsize,
PICK_MODE_CONTEXT *ctx, int64_t best_rd_so_far) {
AV1_COMMON *const cm = &cpi->common;
const int num_planes = av1_num_planes(cm);