Remove g_lambda_cost

This commit is contained in:
Laurent Fasnacht 2014-04-17 11:49:27 +02:00
parent 83360918ba
commit 534013be77
4 changed files with 14 additions and 17 deletions

View file

@ -43,7 +43,6 @@
#include "sao.h" #include "sao.h"
#include "rdo.h" #include "rdo.h"
double g_lambda_cost[55];
double g_cur_lambda_cost; double g_cur_lambda_cost;
/* Local functions. */ /* Local functions. */
@ -81,7 +80,6 @@ void init_lambda(const encoder_control * const encoder)
lambda *= 0.95; lambda *= 0.95;
} }
g_lambda_cost[encoder->QP] = lambda;
g_cur_lambda_cost = lambda; g_cur_lambda_cost = lambda;
} }

View file

@ -128,7 +128,6 @@ void encode_transform_coeff(const encoder_control * const encoder, cabac_data *c
void encode_block_residual(const encoder_control * const encoder, void encode_block_residual(const encoder_control * const encoder,
uint16_t x_ctb, uint16_t y_ctb, uint8_t depth); uint16_t x_ctb, uint16_t y_ctb, uint8_t depth);
extern double g_lambda_cost[55];
extern double g_cur_lambda_cost; extern double g_cur_lambda_cost;
static const uint8_t g_group_idx[32] = { static const uint8_t g_group_idx[32] = {

View file

@ -298,7 +298,7 @@ uint32_t get_coded_level ( const encoder_control * const encoder, cabac_data *ca
cabac_ctx* base_sig_model = type?(cabac->ctx_cu_sig_model_chroma):(cabac->ctx_cu_sig_model_luma); cabac_ctx* base_sig_model = type?(cabac->ctx_cu_sig_model_chroma):(cabac->ctx_cu_sig_model_luma);
if( !last && max_abs_level < 3 ) { if( !last && max_abs_level < 3 ) {
*coded_cost_sig = g_lambda_cost[encoder->QP] * CTX_ENTROPY_BITS(&base_sig_model[ctx_num_sig], 0); *coded_cost_sig = g_cur_lambda_cost * CTX_ENTROPY_BITS(&base_sig_model[ctx_num_sig], 0);
*coded_cost = *coded_cost0 + *coded_cost_sig; *coded_cost = *coded_cost0 + *coded_cost_sig;
if (max_abs_level == 0) return best_abs_level; if (max_abs_level == 0) return best_abs_level;
} else { } else {
@ -306,13 +306,13 @@ uint32_t get_coded_level ( const encoder_control * const encoder, cabac_data *ca
} }
if( !last ) { if( !last ) {
cur_cost_sig = g_lambda_cost[encoder->QP] * CTX_ENTROPY_BITS(&base_sig_model[ctx_num_sig], 1); cur_cost_sig = g_cur_lambda_cost * CTX_ENTROPY_BITS(&base_sig_model[ctx_num_sig], 1);
} }
min_abs_level = ( max_abs_level > 1 ? max_abs_level - 1 : 1 ); min_abs_level = ( max_abs_level > 1 ? max_abs_level - 1 : 1 );
for (abs_level = max_abs_level; abs_level >= min_abs_level ; abs_level-- ) { for (abs_level = max_abs_level; abs_level >= min_abs_level ; abs_level-- ) {
double err = (double)(level_double - ( abs_level << q_bits ) ); double err = (double)(level_double - ( abs_level << q_bits ) );
double cur_cost = err * err * temp + g_lambda_cost[encoder->QP] * double cur_cost = err * err * temp + g_cur_lambda_cost *
get_ic_rate_cost( cabac, abs_level, ctx_num_one, ctx_num_abs, get_ic_rate_cost( cabac, abs_level, ctx_num_one, ctx_num_abs,
abs_go_rice, c1_idx, c2_idx, type); abs_go_rice, c1_idx, c2_idx, type);
cur_cost += cur_cost_sig; cur_cost += cur_cost_sig;
@ -349,7 +349,7 @@ static double get_rate_last(const encoder_control * const encoder,
if( ctx_y > 3 ) { if( ctx_y > 3 ) {
uiCost += 32768.0 * ((ctx_y-2)>>1); uiCost += 32768.0 * ((ctx_y-2)>>1);
} }
return g_lambda_cost[encoder->QP]*uiCost; return g_cur_lambda_cost*uiCost;
} }
static void calc_last_bits(cabac_data *cabac, int32_t width, int32_t height, int8_t type, static void calc_last_bits(cabac_data *cabac, int32_t width, int32_t height, int8_t type,
@ -587,7 +587,7 @@ void rdoq(const encoder_control * const encoder, cabac_data *cabac, coefficient
if (sig_coeffgroup_flag[ cg_blkpos ] == 0) { if (sig_coeffgroup_flag[ cg_blkpos ] == 0) {
uint32_t ctx_sig = context_get_sig_coeff_group(sig_coeffgroup_flag, cg_pos_x, uint32_t ctx_sig = context_get_sig_coeff_group(sig_coeffgroup_flag, cg_pos_x,
cg_pos_y, width); cg_pos_y, width);
cost_coeffgroup_sig[ cg_scanpos ] = g_lambda_cost[encoder->QP]*CTX_ENTROPY_BITS(&base_coeff_group_ctx[ctx_sig],0); cost_coeffgroup_sig[ cg_scanpos ] = g_cur_lambda_cost*CTX_ENTROPY_BITS(&base_coeff_group_ctx[ctx_sig],0);
base_cost += cost_coeffgroup_sig[ cg_scanpos ] - rd_stats.sig_cost; base_cost += cost_coeffgroup_sig[ cg_scanpos ] - rd_stats.sig_cost;
} else { } else {
if (cg_scanpos < cg_last_scanpos) {//skip the last coefficient group, which will be handled together with last position below. if (cg_scanpos < cg_last_scanpos) {//skip the last coefficient group, which will be handled together with last position below.
@ -604,9 +604,9 @@ void rdoq(const encoder_control * const encoder, cabac_data *cabac, coefficient
ctx_sig = context_get_sig_coeff_group(sig_coeffgroup_flag, cg_pos_x, ctx_sig = context_get_sig_coeff_group(sig_coeffgroup_flag, cg_pos_x,
cg_pos_y, width); cg_pos_y, width);
if (cg_scanpos < cg_last_scanpos) { if (cg_scanpos < cg_last_scanpos) {
cost_coeffgroup_sig[cg_scanpos] = g_lambda_cost[encoder->QP]*CTX_ENTROPY_BITS(&base_coeff_group_ctx[ctx_sig],1); cost_coeffgroup_sig[cg_scanpos] = g_cur_lambda_cost*CTX_ENTROPY_BITS(&base_coeff_group_ctx[ctx_sig],1);
base_cost += cost_coeffgroup_sig[cg_scanpos]; base_cost += cost_coeffgroup_sig[cg_scanpos];
cost_zero_cg += g_lambda_cost[encoder->QP]*CTX_ENTROPY_BITS(&base_coeff_group_ctx[ctx_sig],0); cost_zero_cg += g_cur_lambda_cost*CTX_ENTROPY_BITS(&base_coeff_group_ctx[ctx_sig],0);
} }
// try to convert the current coeff group from non-zero to all-zero // try to convert the current coeff group from non-zero to all-zero
@ -620,7 +620,7 @@ void rdoq(const encoder_control * const encoder, cabac_data *cabac, coefficient
sig_coeffgroup_flag[ cg_blkpos ] = 0; sig_coeffgroup_flag[ cg_blkpos ] = 0;
base_cost = cost_zero_cg; base_cost = cost_zero_cg;
if (cg_scanpos < cg_last_scanpos) { if (cg_scanpos < cg_last_scanpos) {
cost_coeffgroup_sig[ cg_scanpos ] = g_lambda_cost[encoder->QP]*CTX_ENTROPY_BITS(&base_coeff_group_ctx[ctx_sig],0); cost_coeffgroup_sig[ cg_scanpos ] = g_cur_lambda_cost*CTX_ENTROPY_BITS(&base_coeff_group_ctx[ctx_sig],0);
} }
// reset coeffs to 0 in this block // reset coeffs to 0 in this block
for (scanpos_in_cg = cg_size-1; scanpos_in_cg >= 0; scanpos_in_cg--) { for (scanpos_in_cg = cg_size-1; scanpos_in_cg >= 0; scanpos_in_cg--) {
@ -648,13 +648,13 @@ void rdoq(const encoder_control * const encoder, cabac_data *cabac, coefficient
if( block_type != CU_INTRA && !type/* && pcCU->getTransformIdx( uiAbsPartIdx ) == 0*/ ) { if( block_type != CU_INTRA && !type/* && pcCU->getTransformIdx( uiAbsPartIdx ) == 0*/ ) {
best_cost = block_uncoded_cost + g_lambda_cost[encoder->QP]*CTX_ENTROPY_BITS(&(cabac->ctx_cu_qt_root_cbf_model),0); best_cost = block_uncoded_cost + g_cur_lambda_cost*CTX_ENTROPY_BITS(&(cabac->ctx_cu_qt_root_cbf_model),0);
base_cost += g_lambda_cost[encoder->QP]*CTX_ENTROPY_BITS(&(cabac->ctx_cu_qt_root_cbf_model),1); base_cost += g_cur_lambda_cost*CTX_ENTROPY_BITS(&(cabac->ctx_cu_qt_root_cbf_model),1);
} else { } else {
cabac_ctx* base_cbf_model = type?(cabac->ctx_qt_cbf_model_chroma):(cabac->ctx_qt_cbf_model_luma); cabac_ctx* base_cbf_model = type?(cabac->ctx_qt_cbf_model_chroma):(cabac->ctx_qt_cbf_model_luma);
ctx_cbf = ( type ? tr_depth : !tr_depth); ctx_cbf = ( type ? tr_depth : !tr_depth);
best_cost = block_uncoded_cost + g_lambda_cost[encoder->QP]*CTX_ENTROPY_BITS(&base_cbf_model[ctx_cbf],0); best_cost = block_uncoded_cost + g_cur_lambda_cost*CTX_ENTROPY_BITS(&base_cbf_model[ctx_cbf],0);
base_cost += g_lambda_cost[encoder->QP]*CTX_ENTROPY_BITS(&base_cbf_model[ctx_cbf],1); base_cost += g_cur_lambda_cost*CTX_ENTROPY_BITS(&base_cbf_model[ctx_cbf],1);
} }
for (cg_scanpos = cg_last_scanpos; cg_scanpos >= 0; cg_scanpos--) { for (cg_scanpos = cg_last_scanpos; cg_scanpos >= 0; cg_scanpos--) {
@ -708,7 +708,7 @@ void rdoq(const encoder_control * const encoder, cabac_data *cabac, coefficient
if(*abs_sum >= 2) { if(*abs_sum >= 2) {
int64_t rd_factor = (int64_t) ( int64_t rd_factor = (int64_t) (
g_inv_quant_scales[qp_scaled%6] * g_inv_quant_scales[qp_scaled%6] * (1<<(2*(qp_scaled/6))) g_inv_quant_scales[qp_scaled%6] * g_inv_quant_scales[qp_scaled%6] * (1<<(2*(qp_scaled/6)))
/ g_lambda_cost[encoder->QP] / 16 / (1<<(2*(encoder->bitdepth-8))) / g_cur_lambda_cost / 16 / (1<<(2*(encoder->bitdepth-8)))
+ 0.5); + 0.5);
int32_t lastCG = -1; int32_t lastCG = -1;
int32_t absSum = 0; int32_t absSum = 0;

View file

@ -928,7 +928,7 @@ static int search_cu(const encoder_control * const encoder, cabac_data *cabac, i
// Recursively split all the way to max search depth. // Recursively split all the way to max search depth.
if (depth < MAX_INTRA_SEARCH_DEPTH || depth < MAX_INTER_SEARCH_DEPTH) { if (depth < MAX_INTRA_SEARCH_DEPTH || depth < MAX_INTER_SEARCH_DEPTH) {
int half_cu = cu_width / 2; int half_cu = cu_width / 2;
int split_cost = (int)(4.5 * g_lambda_cost[encoder->QP]); int split_cost = (int)(4.5 * g_cur_lambda_cost);
// If skip mode was selected for the block, skip further search. // If skip mode was selected for the block, skip further search.
// Skip mode means there's no coefficients in the block, so splitting // Skip mode means there's no coefficients in the block, so splitting