From cbb2aa75b74c910e170283234a072f9a1dce8872 Mon Sep 17 00:00:00 2001 From: Ari Koivula Date: Mon, 6 Oct 2014 21:46:12 +0300 Subject: [PATCH] Add macros for adjusting weight of distortion between luma and chroma. - Everything needs to have a short name because windows has a maximum path length limitation that is breaking my testing framework. --- src/encoderstate.c | 5 +++++ src/search.c | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/encoderstate.c b/src/encoderstate.c index 2faf81ea..0a348bd6 100644 --- a/src/encoderstate.c +++ b/src/encoderstate.c @@ -43,6 +43,9 @@ #include "sao.h" #include "rdo.h" +#ifndef LMBD +# define LMBD 1.0 +#endif /*! \brief Initializes lambda-value for current QP @@ -70,6 +73,8 @@ void encoder_state_init_lambda(encoder_state * const encoder_state) lambda *= 0.95; } + lambda *= LMBD; + encoder_state->global->cur_lambda_cost = lambda; encoder_state->global->cur_lambda_cost_sqrt = sqrt(lambda); } diff --git a/src/search.c b/src/search.c index 822b1563..4ee39d43 100644 --- a/src/search.c +++ b/src/search.c @@ -47,13 +47,20 @@ && (x) + (block_width) <= (width) \ && (y) + (block_height) <= (height)) -#ifndef CU_SPLIT_COST -# define CU_SPLIT_COST 9 +#ifndef CUSPL +# define CUSPL 9 #endif #ifndef FULL_CU_SPLIT_SEARCH # define FULL_CU_SPLIT_SEARCH false #endif +#ifndef LMUL +# define LMUL 1.0 +#endif +#ifndef CMUL +# define CMUL 1.0 +#endif + /** * This is used in the hexagon_search to select 3 points to search. * @@ -831,7 +838,7 @@ static double cu_rd_cost_luma(const encoder_state *const encoder_state, } double bits = tr_tree_bits + coeff_bits; - return ssd + bits * encoder_state->global->cur_lambda_cost; + return (double)ssd * LMUL + bits * encoder_state->global->cur_lambda_cost; } @@ -921,7 +928,7 @@ static double cu_rd_cost_chroma(const encoder_state *const encoder_state, } double bits = tr_tree_bits + coeff_bits; - return ssd + bits * encoder_state->global->cur_lambda_cost; + return (double)ssd * CMUL + bits * encoder_state->global->cur_lambda_cost; } @@ -1507,7 +1514,7 @@ static double search_cu(encoder_state * const encoder_state, int x, int y, int d if (depth < MAX_INTRA_SEARCH_DEPTH || (depth < MAX_INTER_SEARCH_DEPTH && encoder_state->global->slicetype != SLICE_I)) { int half_cu = cu_width / 2; // Using Cost = lambda * 9 to compensate on the price of the split - double split_cost = encoder_state->global->cur_lambda_cost * CU_SPLIT_COST; + double split_cost = encoder_state->global->cur_lambda_cost * CUSPL; int cbf = cbf_is_set(cur_cu->cbf.y, depth) || cbf_is_set(cur_cu->cbf.u, depth) || cbf_is_set(cur_cu->cbf.v, depth); if (depth < MAX_DEPTH) {