Commit 70006e46 authored by Urvang Joshi's avatar Urvang Joshi
Browse files

Remove 'rddiv' member from various structs.

This was initialized from a const and never modified. But was still
passed around and stored in multiple structs.

Removed these 'rddiv' member variables and now RDOPT() and RDOPT_DBL()
always use the const RDDIV_BITS directly.

Change-Id: I1a8dfd2c8fa857d466ad1207b4f0dd6ec07eafb8
parent 0b993846
......@@ -116,7 +116,6 @@ struct macroblock {
// The equivalend SAD error of one (whole) bit at the current quantizer
// for sub-8x8 blocks.
int sadperbit4;
int rddiv;
int rdmult;
int mb_energy;
int *m_search_count_ptr;
......
......@@ -308,7 +308,6 @@ static void set_offsets_without_segment_id(const AV1_COMP *const cpi,
av1_setup_src_planes(x, cpi->source, mi_row, mi_col);
// R/D setup.
x->rddiv = cpi->rd.RDDIV;
x->rdmult = cpi->rd.RDMULT;
// required by av1_append_sub8x8_mvs_for_idx() and av1_find_best_ref_mvs()
......@@ -413,7 +412,6 @@ static void set_offsets_extend(const AV1_COMP *const cpi, ThreadData *td,
xd->left_available = (mi_col_ori > tile->mi_col_start);
// R/D setup.
x->rddiv = cpi->rd.RDDIV;
x->rdmult = cpi->rd.RDMULT;
}
......@@ -2353,8 +2351,7 @@ static void rd_use_partition(AV1_COMP *cpi, ThreadData *td,
if (none_rdc.rate < INT_MAX) {
none_rdc.rate += cpi->partition_cost[pl][PARTITION_NONE];
none_rdc.rdcost =
RDCOST(x->rdmult, x->rddiv, none_rdc.rate, none_rdc.dist);
none_rdc.rdcost = RDCOST(x->rdmult, none_rdc.rate, none_rdc.dist);
#if CONFIG_SUPERTX
none_rate_nocoef += cpi->partition_cost[pl][PARTITION_NONE];
#endif
......@@ -2532,7 +2529,7 @@ static void rd_use_partition(AV1_COMP *cpi, ThreadData *td,
if (last_part_rdc.rate < INT_MAX) {
last_part_rdc.rate += cpi->partition_cost[pl][partition];
last_part_rdc.rdcost =
RDCOST(x->rdmult, x->rddiv, last_part_rdc.rate, last_part_rdc.dist);
RDCOST(x->rdmult, last_part_rdc.rate, last_part_rdc.dist);
#if CONFIG_SUPERTX
last_part_rate_nocoef += cpi->partition_cost[pl][partition];
#endif
......@@ -2616,8 +2613,7 @@ static void rd_use_partition(AV1_COMP *cpi, ThreadData *td,
}
if (chosen_rdc.rate < INT_MAX) {
chosen_rdc.rate += cpi->partition_cost[pl][PARTITION_SPLIT];
chosen_rdc.rdcost =
RDCOST(x->rdmult, x->rddiv, chosen_rdc.rate, chosen_rdc.dist);
chosen_rdc.rdcost = RDCOST(x->rdmult, chosen_rdc.rate, chosen_rdc.dist);
#if CONFIG_SUPERTX
chosen_rate_nocoef += cpi->partition_cost[pl][PARTITION_NONE];
#endif
......@@ -3106,8 +3102,7 @@ static void rd_test_partition3(
cm->fc->supertx_prob[partition_supertx_context_lookup[partition]]
[supertx_size],
0);
sum_rdc.rdcost =
RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
if (!check_intra_sb(cpi, tile_info, mi_row, mi_col, bsize, pc_tree)) {
TX_TYPE best_tx = DCT_DCT;
......@@ -3122,8 +3117,7 @@ static void rd_test_partition3(
cm->fc->supertx_prob[partition_supertx_context_lookup[partition]]
[supertx_size],
1);
tmp_rdc.rdcost =
RDCOST(x->rdmult, x->rddiv, tmp_rdc.rate, tmp_rdc.dist);
tmp_rdc.rdcost = RDCOST(x->rdmult, tmp_rdc.rate, tmp_rdc.dist);
if (tmp_rdc.rdcost < sum_rdc.rdcost) {
sum_rdc = tmp_rdc;
update_supertx_param_sb(cpi, td, mi_row, mi_col, bsize, best_tx,
......@@ -3142,8 +3136,7 @@ static void rd_test_partition3(
#endif
bsize);
sum_rdc.rate += cpi->partition_cost[pl][partition];
sum_rdc.rdcost =
RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
#if CONFIG_SUPERTX
sum_rate_nocoef += cpi->partition_cost[pl][partition];
#endif
......@@ -3416,8 +3409,7 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
if (this_rdc.rate != INT_MAX) {
if (bsize_at_least_8x8) {
this_rdc.rate += partition_cost[PARTITION_NONE];
this_rdc.rdcost =
RDCOST(x->rdmult, x->rddiv, this_rdc.rate, this_rdc.dist);
this_rdc.rdcost = RDCOST(x->rdmult, this_rdc.rate, this_rdc.dist);
#if CONFIG_SUPERTX
this_rate_nocoef += partition_cost[PARTITION_NONE];
#endif
......@@ -3556,8 +3548,7 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
cm->fc->supertx_prob[partition_supertx_context_lookup
[PARTITION_SPLIT]][supertx_size],
0);
sum_rdc.rdcost =
RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
if (is_inter_mode(pc_tree->leaf_split[0]->mic.mbmi.mode)) {
TX_TYPE best_tx = DCT_DCT;
......@@ -3574,8 +3565,7 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
cm->fc->supertx_prob[partition_supertx_context_lookup
[PARTITION_SPLIT]][supertx_size],
1);
tmp_rdc.rdcost =
RDCOST(x->rdmult, x->rddiv, tmp_rdc.rate, tmp_rdc.dist);
tmp_rdc.rdcost = RDCOST(x->rdmult, tmp_rdc.rate, tmp_rdc.dist);
if (tmp_rdc.rdcost < sum_rdc.rdcost) {
sum_rdc = tmp_rdc;
update_supertx_param_sb(cpi, td, mi_row, mi_col, bsize, best_tx,
......@@ -3653,8 +3643,7 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
<< 4;
assert(sum_rdc.dist_y < INT64_MAX);
sum_rdc.dist = sum_rdc.dist - sum_rdc.dist_y + daala_dist;
sum_rdc.rdcost =
RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
}
#endif // CONFIG_DAALA_DIST && CONFIG_CB4X4
......@@ -3669,8 +3658,7 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
cm->fc->supertx_prob[partition_supertx_context_lookup
[PARTITION_SPLIT]][supertx_size],
0);
sum_rdc.rdcost =
RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
if (!check_intra_sb(cpi, tile_info, mi_row, mi_col, bsize, pc_tree)) {
TX_TYPE best_tx = DCT_DCT;
......@@ -3687,8 +3675,7 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
cm->fc->supertx_prob[partition_supertx_context_lookup
[PARTITION_SPLIT]][supertx_size],
1);
tmp_rdc.rdcost =
RDCOST(x->rdmult, x->rddiv, tmp_rdc.rate, tmp_rdc.dist);
tmp_rdc.rdcost = RDCOST(x->rdmult, tmp_rdc.rate, tmp_rdc.dist);
if (tmp_rdc.rdcost < sum_rdc.rdcost) {
sum_rdc = tmp_rdc;
update_supertx_param_sb(cpi, td, mi_row, mi_col, bsize, best_tx,
......@@ -3703,7 +3690,7 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
if (reached_last_index && sum_rdc.rdcost < best_rdc.rdcost) {
sum_rdc.rate += partition_cost[PARTITION_SPLIT];
sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
#if CONFIG_SUPERTX
sum_rate_nocoef += partition_cost[PARTITION_SPLIT];
#endif // CONFIG_SUPERTX
......@@ -3831,8 +3818,7 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
use_activity_masking, x->qindex)
<< 4;
sum_rdc.dist = sum_rdc.dist - sum_rdc.dist_y + daala_dist;
sum_rdc.rdcost =
RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
}
#endif // CONFIG_DAALA_DIST && CONFIG_CB4X4
}
......@@ -3848,7 +3834,7 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
cm->fc->supertx_prob[partition_supertx_context_lookup[PARTITION_HORZ]]
[supertx_size],
0);
sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
if (!check_intra_sb(cpi, tile_info, mi_row, mi_col, bsize, pc_tree)) {
TX_TYPE best_tx = DCT_DCT;
......@@ -3866,8 +3852,7 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
->supertx_prob[partition_supertx_context_lookup[PARTITION_HORZ]]
[supertx_size],
1);
tmp_rdc.rdcost =
RDCOST(x->rdmult, x->rddiv, tmp_rdc.rate, tmp_rdc.dist);
tmp_rdc.rdcost = RDCOST(x->rdmult, tmp_rdc.rate, tmp_rdc.dist);
if (tmp_rdc.rdcost < sum_rdc.rdcost) {
sum_rdc = tmp_rdc;
update_supertx_param_sb(cpi, td, mi_row, mi_col, bsize, best_tx,
......@@ -3881,7 +3866,7 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
if (sum_rdc.rdcost < best_rdc.rdcost) {
sum_rdc.rate += partition_cost[PARTITION_HORZ];
sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
#if CONFIG_SUPERTX
sum_rate_nocoef += partition_cost[PARTITION_HORZ];
#endif // CONFIG_SUPERTX
......@@ -4005,8 +3990,7 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
8, 8, 8, 1, use_activity_masking, x->qindex)
<< 4;
sum_rdc.dist = sum_rdc.dist - sum_rdc.dist_y + daala_dist;
sum_rdc.rdcost =
RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
}
#endif // CONFIG_DAALA_DIST && CONFIG_CB4X4
}
......@@ -4021,7 +4005,7 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
cm->fc->supertx_prob[partition_supertx_context_lookup[PARTITION_VERT]]
[supertx_size],
0);
sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
if (!check_intra_sb(cpi, tile_info, mi_row, mi_col, bsize, pc_tree)) {
TX_TYPE best_tx = DCT_DCT;
......@@ -4039,8 +4023,7 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
->supertx_prob[partition_supertx_context_lookup[PARTITION_VERT]]
[supertx_size],
1);
tmp_rdc.rdcost =
RDCOST(x->rdmult, x->rddiv, tmp_rdc.rate, tmp_rdc.dist);
tmp_rdc.rdcost = RDCOST(x->rdmult, tmp_rdc.rate, tmp_rdc.dist);
if (tmp_rdc.rdcost < sum_rdc.rdcost) {
sum_rdc = tmp_rdc;
update_supertx_param_sb(cpi, td, mi_row, mi_col, bsize, best_tx,
......@@ -4054,7 +4037,7 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
if (sum_rdc.rdcost < best_rdc.rdcost) {
sum_rdc.rate += partition_cost[PARTITION_VERT];
sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
#if CONFIG_SUPERTX
sum_rate_nocoef += partition_cost[PARTITION_VERT];
#endif // CONFIG_SUPERTX
......@@ -6915,8 +6898,7 @@ static void rd_supertx_sb(const AV1_COMP *const cpi, ThreadData *td,
*tmp_rate = av1_cost_bit(av1_get_skip_prob(cm, xd), 1);
x->skip = 1;
} else {
if (RDCOST(x->rdmult, x->rddiv, *tmp_rate, *tmp_dist) <
RDCOST(x->rdmult, x->rddiv, 0, sse)) {
if (RDCOST(x->rdmult, *tmp_rate, *tmp_dist) < RDCOST(x->rdmult, 0, sse)) {
*tmp_rate += av1_cost_bit(av1_get_skip_prob(cm, xd), 0);
x->skip = 0;
} else {
......@@ -6926,7 +6908,7 @@ static void rd_supertx_sb(const AV1_COMP *const cpi, ThreadData *td,
}
}
*tmp_rate += base_rate;
rd_tx = RDCOST(x->rdmult, x->rddiv, *tmp_rate, *tmp_dist);
rd_tx = RDCOST(x->rdmult, *tmp_rate, *tmp_dist);
if (rd_tx < bestrd_tx * 0.99 || tx_type == DCT_DCT) {
*best_tx = tx_type;
bestrd_tx = rd_tx;
......
......@@ -119,10 +119,10 @@ static const int plane_rd_mult[REF_TYPES][PLANE_TYPES] = {
#endif
};
#define UPDATE_RD_COST() \
{ \
rd_cost0 = RDCOST(rdmult, rddiv, rate0, error0); \
rd_cost1 = RDCOST(rdmult, rddiv, rate1, error1); \
#define UPDATE_RD_COST() \
{ \
rd_cost0 = RDCOST(rdmult, rate0, error0); \
rd_cost1 = RDCOST(rdmult, rate1, error1); \
}
static INLINE unsigned int get_token_bit_costs(
......@@ -175,7 +175,6 @@ static int optimize_b_greedy(const AV1_COMMON *cm, MACROBLOCK *mb, int plane,
const dequant_val_type_nuq *dequant_val = pd->dequant_val_nuq[dq];
#endif // CONFIG_NEW_QUANT
int sz = 0;
const int64_t rddiv = mb->rddiv;
int64_t rd_cost0, rd_cost1;
int16_t t0, t1;
int i, final_eob;
......@@ -224,7 +223,7 @@ static int optimize_b_greedy(const AV1_COMMON *cm, MACROBLOCK *mb, int plane,
rate0 = get_token_bit_costs(*(token_costs_ptr + band_translate[0]), 0, ctx0,
EOB_TOKEN);
int64_t best_block_rd_cost = RDCOST(rdmult, rddiv, rate0, accu_error);
int64_t best_block_rd_cost = RDCOST(rdmult, rate0, accu_error);
// int64_t best_block_rd_cost_all0 = best_block_rd_cost;
......@@ -361,16 +360,16 @@ static int optimize_b_greedy(const AV1_COMMON *cm, MACROBLOCK *mb, int plane,
}
}
rd_cost0 = RDCOST(rdmult, rddiv, (rate0 + next_bits0), d2);
rd_cost1 = RDCOST(rdmult, rddiv, (rate1 + next_bits1), d2_a);
rd_cost0 = RDCOST(rdmult, (rate0 + next_bits0), d2);
rd_cost1 = RDCOST(rdmult, (rate1 + next_bits1), d2_a);
best_x = (rd_cost1 < rd_cost0);
eob_cost0 = RDCOST(rdmult, rddiv, (accu_rate + rate0 + next_eob_bits0),
eob_cost0 = RDCOST(rdmult, (accu_rate + rate0 + next_eob_bits0),
(accu_error + d2 - d0));
eob_cost1 = eob_cost0;
if (x_a != 0) {
eob_cost1 = RDCOST(rdmult, rddiv, (accu_rate + rate1 + next_eob_bits1),
eob_cost1 = RDCOST(rdmult, (accu_rate + rate1 + next_eob_bits1),
(accu_error + d2_a - d0));
best_eob_x = (eob_cost1 < eob_cost0);
} else {
......@@ -1587,7 +1586,7 @@ static int cfl_compute_alpha_ind(MACROBLOCK *const x, const CFL_CTX *const cfl,
dist = sse[CFL_PRED_U][0] + sse[CFL_PRED_V][0];
dist *= 16;
best_cost = RDCOST(x->rdmult, x->rddiv, cfl->costs[0], dist);
best_cost = RDCOST(x->rdmult, cfl->costs[0], dist);
for (int c = 1; c < CFL_ALPHABET_SIZE; c++) {
const int idx_u = cfl_alpha_codes[c][CFL_PRED_U];
......@@ -1597,7 +1596,7 @@ static int cfl_compute_alpha_ind(MACROBLOCK *const x, const CFL_CTX *const cfl,
dist = sse[CFL_PRED_U][idx_u + (sign_u == CFL_SIGN_NEG)] +
sse[CFL_PRED_V][idx_v + (sign_v == CFL_SIGN_NEG)];
dist *= 16;
cost = RDCOST(x->rdmult, x->rddiv, cfl->costs[c], dist);
cost = RDCOST(x->rdmult, cfl->costs[c], dist);
if (cost < best_cost) {
best_cost = cost;
ind = c;
......
......@@ -1360,8 +1360,7 @@ void try_level_down_facade(LevelDownStats *stats, int scan_idx,
test_level_down(coeff_idx, txb_cache, txb_probs, txb_info);
#endif
}
stats->rd_diff = RDCOST(txb_info->rdmult, txb_info->rddiv, stats->cost_diff,
stats->dist_diff);
stats->rd_diff = RDCOST(txb_info->rdmult, stats->cost_diff, stats->dist_diff);
if (stats->rd_diff < 0) stats->update = 1;
return;
}
......@@ -1507,11 +1506,11 @@ int av1_optimize_txb(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block,
const int shift = av1_get_tx_scale(tx_size);
const int64_t rdmult =
(x->rdmult * plane_rd_mult[is_inter][plane_type] + 2) >> 2;
const int64_t rddiv = x->rddiv;
TxbInfo txb_info = { qcoeff, dqcoeff, tcoeff, dequant, shift, tx_size,
txs_ctx, bwl, stride, height, eob, seg_eob,
scan_order, txb_ctx, rdmult, rddiv };
TxbInfo txb_info = { qcoeff, dqcoeff, tcoeff, dequant, shift,
tx_size, txs_ctx, bwl, stride, height,
eob, seg_eob, scan_order, txb_ctx, rdmult };
TxbCache txb_cache;
gen_txb_cache(&txb_cache, &txb_info);
......@@ -1900,8 +1899,7 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane,
get_scan(cm, tx_size, tx_type, is_inter_block(mbmi));
this_rd_stats.rate = av1_cost_coeffs(
cpi, x, plane, block, tx_size, scan_order, a, l, use_fast_coef_costing);
int rd =
RDCOST(x->rdmult, x->rddiv, this_rd_stats.rate, this_rd_stats.dist);
int rd = RDCOST(x->rdmult, this_rd_stats.rate, this_rd_stats.dist);
if (rd < best_rd) {
best_rd = rd;
*rd_stats = this_rd_stats;
......
......@@ -39,7 +39,6 @@ typedef struct TxbInfo {
const SCAN_ORDER *scan_order;
TXB_CTX *txb_ctx;
int64_t rdmult;
int64_t rddiv;
} TxbInfo;
typedef struct TxbCache {
......
......@@ -154,8 +154,7 @@ int av1_search_filter_level(const YV12_BUFFER_CONFIG *sd, AV1_COMP *cpi,
// Update best error
best_err = ss_err[filt_best];
if (best_cost_ret)
*best_cost_ret = RDCOST_DBL(x->rdmult, x->rddiv, 0, best_err);
if (best_cost_ret) *best_cost_ret = RDCOST_DBL(x->rdmult, 0, best_err);
return filt_best;
}
......
......@@ -478,7 +478,7 @@ static double search_sgrproj(const YV12_BUFFER_CONFIG *src, AV1_COMP *cpi,
(1 << plane));
// #bits when a tile is not restored
bits = av1_cost_bit(RESTORE_NONE_SGRPROJ_PROB, 0);
cost_norestore = RDCOST_DBL(x->rdmult, x->rddiv, (bits >> 4), err);
cost_norestore = RDCOST_DBL(x->rdmult, (bits >> 4), err);
best_tile_cost[tile_idx] = DBL_MAX;
search_selfguided_restoration(
dgd_buffer + v_start * dgd_stride + h_start, h_end - h_start,
......@@ -498,7 +498,7 @@ static double search_sgrproj(const YV12_BUFFER_CONFIG *src, AV1_COMP *cpi,
&ref_sgrproj_info)
<< AV1_PROB_COST_SHIFT;
bits += av1_cost_bit(RESTORE_NONE_SGRPROJ_PROB, 1);
cost_sgrproj = RDCOST_DBL(x->rdmult, x->rddiv, (bits >> 4), err);
cost_sgrproj = RDCOST_DBL(x->rdmult, (bits >> 4), err);
if (cost_sgrproj >= cost_norestore) {
type[tile_idx] = RESTORE_NONE;
} else {
......@@ -531,7 +531,7 @@ static double search_sgrproj(const YV12_BUFFER_CONFIG *src, AV1_COMP *cpi,
}
err = try_restoration_frame(src, cpi, rsi, (1 << plane), partial_frame,
dst_frame);
cost_sgrproj = RDCOST_DBL(x->rdmult, x->rddiv, (bits >> 4), err);
cost_sgrproj = RDCOST_DBL(x->rdmult, (bits >> 4), err);
return cost_sgrproj;
}
......@@ -1039,7 +1039,7 @@ static double search_wiener(const YV12_BUFFER_CONFIG *src, AV1_COMP *cpi,
(1 << plane));
// #bits when a tile is not restored
bits = av1_cost_bit(RESTORE_NONE_WIENER_PROB, 0);
cost_norestore = RDCOST_DBL(x->rdmult, x->rddiv, (bits >> 4), err);
cost_norestore = RDCOST_DBL(x->rdmult, (bits >> 4), err);
best_tile_cost[tile_idx] = DBL_MAX;
av1_get_rest_tile_limits(tile_idx, 0, 0, nhtiles, nvtiles, tile_width,
......@@ -1081,7 +1081,7 @@ static double search_wiener(const YV12_BUFFER_CONFIG *src, AV1_COMP *cpi,
count_wiener_bits(&rsi[plane].wiener_info[tile_idx], &ref_wiener_info)
<< AV1_PROB_COST_SHIFT;
bits += av1_cost_bit(RESTORE_NONE_WIENER_PROB, 1);
cost_wiener = RDCOST_DBL(x->rdmult, x->rddiv, (bits >> 4), err);
cost_wiener = RDCOST_DBL(x->rdmult, (bits >> 4), err);
if (cost_wiener >= cost_norestore) {
type[tile_idx] = RESTORE_NONE;
} else {
......@@ -1114,7 +1114,7 @@ static double search_wiener(const YV12_BUFFER_CONFIG *src, AV1_COMP *cpi,
}
err = try_restoration_frame(src, cpi, rsi, 1 << plane, partial_frame,
dst_frame);
cost_wiener = RDCOST_DBL(x->rdmult, x->rddiv, (bits >> 4), err);
cost_wiener = RDCOST_DBL(x->rdmult, (bits >> 4), err);
return cost_wiener;
}
......@@ -1160,7 +1160,7 @@ static double search_norestore(const YV12_BUFFER_CONFIG *src, AV1_COMP *cpi,
// RD cost associated with no restoration
err = sse_restoration_frame(cm, src, cm->frame_to_show, (1 << plane));
bits = frame_level_restore_bits[RESTORE_NONE] << AV1_PROB_COST_SHIFT;
cost_norestore = RDCOST_DBL(x->rdmult, x->rddiv, (bits >> 4), err);
cost_norestore = RDCOST_DBL(x->rdmult, (bits >> 4), err);
return cost_norestore;
}
......@@ -1192,11 +1192,11 @@ static double search_switchable_restoration(
rsi->frame_restoration_type = RESTORE_SWITCHABLE;
bits = frame_level_restore_bits[rsi->frame_restoration_type]
<< AV1_PROB_COST_SHIFT;
cost_switchable = RDCOST_DBL(x->rdmult, x->rddiv, bits >> 4, 0);
cost_switchable = RDCOST_DBL(x->rdmult, bits >> 4, 0);
for (tile_idx = 0; tile_idx < ntiles; ++tile_idx) {
double best_cost = RDCOST_DBL(
x->rdmult, x->rddiv, (cpi->switchable_restore_cost[RESTORE_NONE] >> 4),
tile_cost[RESTORE_NONE][tile_idx]);
double best_cost =
RDCOST_DBL(x->rdmult, (cpi->switchable_restore_cost[RESTORE_NONE] >> 4),
tile_cost[RESTORE_NONE][tile_idx]);
rsi->restoration_type[tile_idx] = RESTORE_NONE;
for (r = 1; r < RESTORE_SWITCHABLE_TYPES; r++) {
if (force_restore_type != 0)
......@@ -1210,8 +1210,8 @@ static double search_switchable_restoration(
count_sgrproj_bits(&rsi->sgrproj_info[tile_idx], &ref_sgrproj_info);
tilebits <<= AV1_PROB_COST_SHIFT;
tilebits += cpi->switchable_restore_cost[r];
double cost = RDCOST_DBL(x->rdmult, x->rddiv, tilebits >> 4,
tile_cost[r][tile_idx]);
double cost =
RDCOST_DBL(x->rdmult, tilebits >> 4, tile_cost[r][tile_idx]);
if (cost < best_cost) {
rsi->restoration_type[tile_idx] = r;
......
......@@ -351,7 +351,6 @@ void av1_initialize_rd_consts(AV1_COMP *cpi) {
aom_clear_system_state();
rd->RDDIV = RDDIV_BITS; // In bits (to multiply D by 128).
rd->RDMULT = av1_compute_rd_mult(cpi, cm->base_qindex + cm->y_dc_delta_q);
set_error_per_bit(x, rd->RDMULT);
......
......@@ -30,12 +30,13 @@ extern "C" {
#define RDDIV_BITS 7
#define RD_EPB_SHIFT 6
#define RDCOST(RM, DM, R, D) \
(ROUND_POWER_OF_TWO(((int64_t)R) * (RM), AV1_PROB_COST_SHIFT) + (D << DM))
#define RDCOST(RM, R, D) \
(ROUND_POWER_OF_TWO(((int64_t)R) * (RM), AV1_PROB_COST_SHIFT) + \
(D << RDDIV_BITS))
#define RDCOST_DBL(RM, DM, R, D) \
#define RDCOST_DBL(RM, R, D) \
(((((double)(R)) * (RM)) / (double)(1 << AV1_PROB_COST_SHIFT)) + \
((double)(D) * (1 << (DM))))
((double)(D) * (1 << RDDIV_BITS)))
#define QIDX_SKIP_THRESH 115
......@@ -381,7 +382,6 @@ typedef struct RD_OPT {
int64_t prediction_type_threshes[TOTAL_REFS_PER_FRAME][REFERENCE_MODES];
int RDMULT;
int RDDIV;
} RD_OPT;
static INLINE void av1_init_rd_stats(RD_STATS *rd_stats) {
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment