From b9822398a005072546718c695d9c15ce144e9506 Mon Sep 17 00:00:00 2001 From: siivonek Date: Fri, 23 Sep 2022 15:41:50 +0300 Subject: [PATCH] [isp] Fix lfnst constraint checks when ISP is in use. Add some asserts. --- src/encode_coding_tree.c | 27 ++++++++++++++++++++++++++- src/intra.c | 3 +++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/encode_coding_tree.c b/src/encode_coding_tree.c index d0dab272..c2be1395 100644 --- a/src/encode_coding_tree.c +++ b/src/encode_coding_tree.c @@ -133,10 +133,35 @@ bool uvg_is_lfnst_allowed( } bool luma_flag = (depth == 4 && color == COLOR_Y) || (tree_type != UVG_CHROMA_T && depth != 4); bool chroma_flag = (depth == 4 && color != COLOR_Y) || tree_type != UVG_LUMA_T; - bool non_zero_coeff_non_ts_corner_8x8 = (luma_flag && pred_cu->violates_lfnst_constrained_luma) || (chroma_flag && pred_cu->violates_lfnst_constrained_chroma); + bool non_zero_coeff_non_ts_corner_8x8 = false; + bool last_scan_pos = false; bool is_tr_skip = false; + int split_num = color == COLOR_Y && isp_mode ? uvg_get_isp_split_num(width, height, isp_mode, false) : 0; const videoframe_t* const frame = state->tile->frame; + + if (split_num) { + // Constraints for ISP split blocks + for (int i = 0; i < split_num; ++i) { + cu_loc_t split_loc; + uvg_get_isp_split_loc(&split_loc, x, y, width, height, i, isp_mode, false); + int local_split_x = split_loc.x; + int local_split_y = split_loc.y; + uvg_get_isp_cu_arr_coords(&local_split_x, &local_split_y); + cu_info_t* split_cu = lcu ? LCU_GET_CU_AT_PX(lcu, local_split_x, local_split_y) : + uvg_cu_array_at_const(frame->cu_array, local_split_x, local_split_y); + + if (cbf_is_set(split_cu->cbf, depth, COLOR_Y)) { + non_zero_coeff_non_ts_corner_8x8 |= (luma_flag && split_cu->violates_lfnst_constrained_luma) || (chroma_flag && split_cu->violates_lfnst_constrained_chroma); + //last_scan_pos |= split_cu->lfnst_last_scan_pos; + last_scan_pos |= true; + } + } + } else { + non_zero_coeff_non_ts_corner_8x8 |= (luma_flag && pred_cu->violates_lfnst_constrained_luma) || (chroma_flag && pred_cu->violates_lfnst_constrained_chroma); + last_scan_pos |= pred_cu->lfnst_last_scan_pos; + } + //const int num_pred_units = kvz_part_mode_num_parts[pred_cu->part_size]; const int tr_depth = pred_cu->tr_depth; assert(depth <= tr_depth && "Depth greater than transform depth. This should never trigger."); diff --git a/src/intra.c b/src/intra.c index 7eb07911..a831f768 100644 --- a/src/intra.c +++ b/src/intra.c @@ -1619,6 +1619,9 @@ int uvg_get_isp_split_num(const int width, const int height, const int split_typ void uvg_get_isp_split_loc(cu_loc_t *loc, const int x, const int y, const int block_w, const int block_h, int split_idx, const int split_type, const bool is_transform_split) { + // Check for illegal splits + assert(!(block_w == 4 && block_h == 4) || split_idx == 0 && "Trying to get ISP split CU when split is not allowed."); + assert(!((block_w * block_h) <= 16) || split_idx < 2 && "Split index for small blocks must be in [0, 1]"); assert((split_idx >= 0 && split_idx <= 3) && "ISP split index must be in [0, 3]."); assert((split_type != ISP_MODE_NO_ISP || split_idx == 0) && "Trying to ISP split when split type = NO_ISP."); int part_dim = block_w;