From 81ad583e082065010b630fb3308a75f1be4dc94b Mon Sep 17 00:00:00 2001 From: Ari Koivula Date: Tue, 20 Jan 2015 10:53:03 +0200 Subject: [PATCH] Use the same coeff cost calculation for all rd modes. - It's not worth it to have these faster approximations for coefficient cost. --- src/rdo.c | 14 +------------- src/search.c | 4 ++-- src/transform.c | 27 ++------------------------- 3 files changed, 5 insertions(+), 40 deletions(-) diff --git a/src/rdo.c b/src/rdo.c index ef54d22c..19034ad9 100644 --- a/src/rdo.c +++ b/src/rdo.c @@ -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); } diff --git a/src/search.c b/src/search.c index ea8a29cc..f0ef5184 100644 --- a/src/search.c +++ b/src/search.c @@ -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); diff --git a/src/transform.c b/src/transform.c index 5c10e401..47422d39 100644 --- a/src/transform.c +++ b/src/transform.c @@ -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;