From 4c66561ebef7768e1bdf91e97bfe6d30758c144f Mon Sep 17 00:00:00 2001 From: Joose Sainio Date: Fri, 13 May 2022 12:05:54 +0300 Subject: [PATCH] [debug] Temporarily move split flag counting --- src/search.c | 28 +++++++++++++++------------- src/search_intra.c | 5 +---- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/search.c b/src/search.c index 895b27e4..945b3219 100644 --- a/src/search.c +++ b/src/search.c @@ -1148,20 +1148,7 @@ static double search_cu(encoder_state_t * const state, int x, int y, int depth, cabac_data_t post_seach_cabac; memcpy(&post_seach_cabac, &state->search_cabac, sizeof(post_seach_cabac)); memcpy(&state->search_cabac, &pre_search_cabac, sizeof(post_seach_cabac)); - state->search_cabac.update = 1; - double split_bits = 0; - - if (depth < MAX_DEPTH) { - // Add cost of cu_split_flag. - uvg_write_split_flag(state, &state->search_cabac, - x > 0 ? LCU_GET_CU_AT_PX(lcu,SUB_SCU(x) -1, SUB_SCU(y)): NULL, - y > 0 ? LCU_GET_CU_AT_PX(lcu, SUB_SCU(x), SUB_SCU(y) - 1) : NULL, - 1, depth, cu_width, x, y, &split_bits); - } - - state->search_cabac.update = 0; - split_cost += split_bits * state->lambda; // If skip mode was selected for the block, skip further search. // Skip mode means there's no coefficients in the block, so splitting @@ -1177,6 +1164,21 @@ static double search_cu(encoder_state_t * const state, int x, int y, int depth, split_cost = INT_MAX; } + state->search_cabac.update = 1; + + double split_bits = 0; + + if (depth < MAX_DEPTH) { + // Add cost of cu_split_flag. + uvg_write_split_flag(state, &state->search_cabac, + x > 0 ? LCU_GET_CU_AT_PX(lcu, SUB_SCU(x) - 1, SUB_SCU(y)) : NULL, + y > 0 ? LCU_GET_CU_AT_PX(lcu, SUB_SCU(x), SUB_SCU(y) - 1) : NULL, + 1, depth, cu_width, x, y, &split_bits); + } + + state->search_cabac.update = 0; + split_cost += split_bits * state->lambda; + // If no search is not performed for this depth, try just the best mode // of the top left CU from the next depth. This should ensure that 64x64 // gets used, at least in the most obvious cases, while avoiding any diff --git a/src/search_intra.c b/src/search_intra.c index aa63dfb6..6a13cd29 100644 --- a/src/search_intra.c +++ b/src/search_intra.c @@ -1250,9 +1250,6 @@ static int8_t search_intra_rdo( const int tr_depth = CLIP(1, MAX_PU_DEPTH, depth + state->encoder_control->cfg.tr_depth_intra); for (int mode = 0; mode < modes_to_check; mode++) { - if(mode == 0) { - printf("%hu %hu %d %d\n", state->search_cabac.ctx.qt_cbf_model_luma[0].state[0], state->search_cabac.ctx.qt_cbf_model_luma[0].state[1], x_px, y_px); - } double rdo_bitcost = uvg_luma_mode_bits(state, &search_data[mode].pred_cu, x_px, y_px, depth, lcu); search_data[mode].pred_cu.tr_idx = MTS_TR_NUM; search_data[mode].bits = rdo_bitcost; @@ -1431,7 +1428,7 @@ int8_t uvg_search_cu_intra_chroma(encoder_state_t * const state, // FIXME: It might make more sense to only disable rough search if // num_modes is 0.is 0. - { + if(state->encoder_control->cfg.cclm){ const int_fast8_t log2_width_c = MAX(LOG2_LCU_WIDTH - depth - 1, 2); const vector2d_t pic_px = { state->tile->frame->width, state->tile->frame->height }; const vector2d_t luma_px = { x_px & ~7, y_px & ~7};