Use the same coeff cost calculation for all rd modes.

- It's not worth it to have these faster approximations for coefficient cost.
This commit is contained in:
Ari Koivula 2015-01-20 10:53:03 +02:00
parent 870171e6ad
commit 81ad583e08
3 changed files with 5 additions and 40 deletions

View file

@ -212,19 +212,7 @@ uint32_t rdo_cost_intra(encoder_state * const encoder_state, pixel *pred, pixel
ssd += diff*diff;
}
double coeff_bits = 0;
// Simple RDO
if(encoder->rdo == 1) {
// SSD between reconstruction and original + sum of coeffs
int coeff_abs = 0;
for (i = 0; i < width*width; i++) {
coeff_abs += abs((int)temp_coeff[i]);
}
coeff_bits += 1 + 1.5 * coeff_abs;
// Full RDO
} else if(encoder->rdo >= 2) {
coeff_bits = get_coeff_cost(encoder_state, temp_coeff, width, 0, luma_scan_mode);
}
double coeff_bits = get_coeff_cost(encoder_state, temp_coeff, width, 0, luma_scan_mode);
return (uint32_t)(0.5 + ssd + coeff_bits * encoder_state->global->cur_lambda_cost);
}

View file

@ -989,7 +989,7 @@ static double cu_rd_cost_luma(const encoder_state *const encoder_state,
}
}
if (rdo >= 1) {
{
coefficient coeff_temp[32 * 32];
int8_t luma_scan_mode = get_scan_order(pred_cu->type, pred_cu->intra[PU_INDEX(x_px / 4, y_px / 4)].mode, depth);
@ -1063,7 +1063,7 @@ static double cu_rd_cost_chroma(const encoder_state *const encoder_state,
}
}
if (rdo >= 1) {
{
coefficient coeff_temp[16 * 16];
int8_t scan_order = get_scan_order(pred_cu->type, pred_cu->intra[0].mode_chroma, depth);

View file

@ -460,32 +460,9 @@ int quantize_residual_trskip(
0, in_stride, 4,
ref_in, pred_in, noskip.rec, noskip.coeff);
noskip.cost = pixels_calc_ssd(ref_in, noskip.rec, in_stride, 4, 4);
if (encoder_state->encoder_control->rdo == 1) {
// Estimate bit cost of encoding the coeffs as ~(1.5 * abs_sum).
unsigned abs_coeffs = coefficients_calc_abs(noskip.coeff, 4, 4);
noskip.cost += (abs_coeffs + (abs_coeffs / 2)) * bit_cost;
} else if (encoder_state->encoder_control->rdo >= 2) {
noskip.cost += get_coeff_cost(encoder_state, noskip.coeff, 4, 0, scan_order) * bit_cost;
}
noskip.cost += get_coeff_cost(encoder_state, noskip.coeff, 4, 0, scan_order) * bit_cost;
if (encoder_state->encoder_control->rdo == 0) {
// Evaluating whether to use transform skip or not requires doing the
// transform. So if rdo is off, it's probably better to not use trskip.
skip.cost = UINT32_MAX;
} else {
skip.has_coeffs = quantize_residual(
encoder_state, cur_cu, width, color, scan_order,
1, in_stride, 4,
ref_in, pred_in, skip.rec, skip.coeff);
skip.cost = pixels_calc_ssd(ref_in, skip.rec, in_stride, 4, 4);
if (encoder_state->encoder_control->rdo == 1) {
// Estimate bit cost of encoding the coeffs as ~(1.5 * abs_sum + 1).
unsigned abs_coeffs = coefficients_calc_abs(skip.coeff, 4, 4);
skip.cost += (1 + abs_coeffs + (abs_coeffs / 2)) * bit_cost;
} else if (encoder_state->encoder_control->rdo >= 2) {
skip.cost += get_coeff_cost(encoder_state, skip.coeff, 4, 0, scan_order) * bit_cost;
}
}
skip.cost += get_coeff_cost(encoder_state, skip.coeff, 4, 0, scan_order) * bit_cost;
if (noskip.cost <= skip.cost) {
*trskip_out = 0;