Disable bit calculations that always degrade quality

This commit is contained in:
Joose Sainio 2022-03-16 09:14:08 +02:00
parent 352d6750f5
commit e39fbb11a7
2 changed files with 10 additions and 0 deletions

View file

@ -775,12 +775,16 @@ static double search_cu(encoder_state_t * const state, int x, int y, int depth,
double intra_cost; double intra_cost;
kvz_search_cu_intra(state, x, y, depth, lcu, kvz_search_cu_intra(state, x, y, depth, lcu,
&intra_mode, &intra_cost); &intra_mode, &intra_cost);
#ifdef COMPLETE_PRED_MODE_BITS
// Technically counting these bits would be correct, however counting
// them universally degrades quality so this block is disabled by default
if(state->frame->slicetype != KVZ_SLICE_I) { if(state->frame->slicetype != KVZ_SLICE_I) {
double pred_mode_type_bits = 0; double pred_mode_type_bits = 0;
CABAC_FBITS_UPDATE(&state->search_cabac, &state->search_cabac.ctx.cu_pred_mode_model, 1, pred_mode_type_bits, "pred_mode_flag"); CABAC_FBITS_UPDATE(&state->search_cabac, &state->search_cabac.ctx.cu_pred_mode_model, 1, pred_mode_type_bits, "pred_mode_flag");
CABAC_FBITS_UPDATE(&state->search_cabac, &state->search_cabac.ctx.cu_skip_flag_model[kvz_get_skip_context(x, y, lcu, NULL)], 0, pred_mode_type_bits, "skip_flag"); CABAC_FBITS_UPDATE(&state->search_cabac, &state->search_cabac.ctx.cu_skip_flag_model[kvz_get_skip_context(x, y, lcu, NULL)], 0, pred_mode_type_bits, "skip_flag");
intra_cost += pred_mode_type_bits * state->lambda; intra_cost += pred_mode_type_bits * state->lambda;
} }
#endif
if (intra_cost < cost) { if (intra_cost < cost) {
cost = intra_cost; cost = intra_cost;
cur_cu->type = CU_INTRA; cur_cu->type = CU_INTRA;

View file

@ -1666,7 +1666,13 @@ static void search_pu_inter(encoder_state_t * const state,
} }
const double merge_flag_cost = CTX_ENTROPY_FBITS(&state->search_cabac.ctx.cu_merge_flag_ext_model, 1); const double merge_flag_cost = CTX_ENTROPY_FBITS(&state->search_cabac.ctx.cu_merge_flag_ext_model, 1);
#ifdef COMPLETE_PRED_MODE_BITS
// Technically counting these bits would be correct, however counting
// them universally degrades quality so this block is disabled by default
const double no_skip_flag = CTX_ENTROPY_FBITS(&state->search_cabac.ctx.cu_skip_flag_model[kvz_get_skip_context(x, y, lcu, NULL)], 0); const double no_skip_flag = CTX_ENTROPY_FBITS(&state->search_cabac.ctx.cu_skip_flag_model[kvz_get_skip_context(x, y, lcu, NULL)], 0);
#else
const double no_skip_flag = 0;
#endif
// Check motion vector constraints and perform rough search // Check motion vector constraints and perform rough search
for (int merge_idx = 0; merge_idx < info->num_merge_cand; ++merge_idx) { for (int merge_idx = 0; merge_idx < info->num_merge_cand; ++merge_idx) {