From d69bdf79f452b5ad31191088232434646156b9f4 Mon Sep 17 00:00:00 2001 From: Joose Sainio Date: Wed, 8 Feb 2023 14:39:36 +0200 Subject: [PATCH] [mtt] Fix couple of issues with 64x32 CUs and non square tr skip rdoq --- src/encode_coding_tree.c | 4 ++-- src/global.h | 2 +- src/intra.c | 2 +- src/rdo.c | 3 +++ src/search_intra.c | 2 ++ 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/encode_coding_tree.c b/src/encode_coding_tree.c index 31bbe003..5604aa16 100644 --- a/src/encode_coding_tree.c +++ b/src/encode_coding_tree.c @@ -237,7 +237,7 @@ void uvg_encode_ts_residual(encoder_state_t* const state, const uint32_t log2_block_width = uvg_g_convert_to_log2[width]; const uint32_t log2_block_height = uvg_g_convert_to_log2[height]; // TODO: log2_cg_size is wrong if width != height - const uint32_t log2_cg_size = uvg_g_log2_sbb_size[log2_block_width][log2_block_width][0] + uvg_g_log2_sbb_size[log2_block_width][log2_block_width][1]; + const uint32_t log2_cg_size = uvg_g_log2_sbb_size[log2_block_width][log2_block_width][0] + uvg_g_log2_sbb_size[log2_block_width][log2_block_height][1]; const uint32_t* const scan = uvg_get_scan_order_table(SCAN_GROUP_4X4, scan_mode, log2_block_width, log2_block_height); const uint32_t* const scan_cg = uvg_get_scan_order_table(SCAN_GROUP_UNGROUPED, scan_mode, log2_block_width, log2_block_height); @@ -265,7 +265,7 @@ void uvg_encode_ts_residual(encoder_state_t* const state, bool no_sig_group_before_last = true; for (i = 0; i <= scan_cg_last; i++) { - if (!(width == 4 || (i ==scan_cg_last && no_sig_group_before_last))) { + if (!((width == 4 && height == 4) || (i ==scan_cg_last && no_sig_group_before_last))) { uint32_t cg_blkpos = scan_cg[i]; uint32_t cg_pos_y = cg_blkpos / cg_width; uint32_t cg_pos_x = cg_blkpos - (cg_pos_y * cg_width); diff --git a/src/global.h b/src/global.h index 972b7e82..27058463 100644 --- a/src/global.h +++ b/src/global.h @@ -129,7 +129,7 @@ typedef int16_t coeff_t; typedef int32_t mv_t; //#define VERBOSE 1 -//#define UVG_DEBUG_PRINT_CABAC 1 +#define UVG_DEBUG_PRINT_CABAC 1 //#define UVG_DEBUG 1 //#define UVG_DEBUG_PRINT_YUVIEW_CSV 1 diff --git a/src/intra.c b/src/intra.c index e3b61540..2dae1a6c 100644 --- a/src/intra.c +++ b/src/intra.c @@ -1649,7 +1649,7 @@ void uvg_intra_predict( } else { uvg_pixels_blit(&state->tile->frame->cclm_luma_rec[x / 2 + (y * stride) / 4], dst, width, height, stride / 2, width); - if (!PU_IS_TU(&data->pred_cu) || data->cclm_parameters[color == COLOR_U ? 0 : 1].b <= 0) { + if (width != 1 << data->pred_cu.log2_chroma_width || height != 1 << data->pred_cu.log2_chroma_height || data->cclm_parameters[color == COLOR_U ? 0 : 1].b <= 0) { predict_cclm( state, color, width, height, x, y, stride, intra_mode, lcu, refs, dst, (cclm_parameters_t*)&data->cclm_parameters[color == COLOR_U ? 0 : 1], diff --git a/src/rdo.c b/src/rdo.c index 18f65f12..cfc03c48 100644 --- a/src/rdo.c +++ b/src/rdo.c @@ -1196,8 +1196,11 @@ int uvg_ts_rdoq(encoder_state_t* const state, coeff_t* src_coeff, coeff_t* dest_ switch (cg_num) { case 1: FILL_ARRAY(sig_coeffgroup_flag, 0, 1); FILL_ARRAY(cost_coeffgroup_sig, 0, 1); break; + case 2: FILL_ARRAY(sig_coeffgroup_flag, 0, 2); FILL_ARRAY(cost_coeffgroup_sig, 0, 2); break; case 4: FILL_ARRAY(sig_coeffgroup_flag, 0, 4); FILL_ARRAY(cost_coeffgroup_sig, 0, 4); break; + case 8: FILL_ARRAY(sig_coeffgroup_flag, 0, 8); FILL_ARRAY(cost_coeffgroup_sig, 0, 8); break; case 16: FILL_ARRAY(sig_coeffgroup_flag, 0, 16); FILL_ARRAY(cost_coeffgroup_sig, 0, 16); break; + case 32: FILL_ARRAY(sig_coeffgroup_flag, 0, 32); FILL_ARRAY(cost_coeffgroup_sig, 0, 32); break; case 64: FILL_ARRAY(sig_coeffgroup_flag, 0, 64); FILL_ARRAY(cost_coeffgroup_sig, 0, 64); break; default: assert(0 && "There should be 1, 4, 16 or 64 coefficient groups"); } diff --git a/src/search_intra.c b/src/search_intra.c index 0aee661c..1c911996 100644 --- a/src/search_intra.c +++ b/src/search_intra.c @@ -341,6 +341,7 @@ static double search_intra_trdepth( if (state->encoder_control->cfg.trskip_enable && width <= (1 << state->encoder_control->cfg.trskip_max_size) && height <= (1 << state->encoder_control->cfg.trskip_max_size) + && PU_IS_TU(pred_cu) && pred_cu->intra.isp_mode == ISP_MODE_NO_ISP) { num_transforms = MAX(num_transforms, 2); } @@ -378,6 +379,7 @@ static double search_intra_trdepth( if (trafo == MTS_SKIP && ((width > (1 << state->encoder_control->cfg.trskip_max_size) || (height > (1 << state->encoder_control->cfg.trskip_max_size))) + || !PU_IS_TU(pred_cu) || !state->encoder_control->cfg.trskip_enable)) { continue; }