[dual-tree] Remove the limitation of not allowing 2 height chroma blocks in dual tree

This commit is contained in:
Joose Sainio 2023-02-23 08:48:08 +02:00 committed by Marko Viitanen
parent 146e1cb85e
commit 91591c7e7c
5 changed files with 12 additions and 59 deletions

View file

@ -502,25 +502,3 @@ int uvg_count_available_edge_cus(const cu_loc_t* const cu_loc, const lcu_t* cons
} }
return MAX(amount / TR_MIN_WIDTH, cu_loc->width / TR_MIN_WIDTH); return MAX(amount / TR_MIN_WIDTH, cu_loc->width / TR_MIN_WIDTH);
} }
int uvg_count_chroma_tree_available_edge_cus(int x, int y, int width, int height, const lcu_t* const lcu, bool left)
{
if (left && x == 0 || !left && y == 0) return 0;
const int local_x = x % LCU_WIDTH_C;
const int local_y = y % LCU_WIDTH_C;
if (left && local_x == 0) return (LCU_WIDTH_C - local_y) / 4;
if (!left && local_y == 0) return width / 2;
int amount = 0;
if(left) {
while (local_y + amount < LCU_WIDTH_C && LCU_GET_CU_AT_PX(lcu, local_x - TR_MIN_WIDTH, local_y + amount)->type != CU_NOTSET) {
amount += TR_MIN_WIDTH;
}
return MAX(amount / TR_MIN_WIDTH, height / TR_MIN_WIDTH);
}
while (local_x + amount < LCU_WIDTH_C && LCU_GET_CU_AT_PX(lcu, local_x + amount, local_y - TR_MIN_WIDTH)->type != CU_NOTSET) {
amount += TR_MIN_WIDTH;
}
return MAX(amount / TR_MIN_WIDTH, width / TR_MIN_WIDTH);
}

View file

@ -385,7 +385,6 @@ typedef struct {
void uvg_cu_array_copy_from_lcu(cu_array_t* dst, int dst_x, int dst_y, const lcu_t *src); void uvg_cu_array_copy_from_lcu(cu_array_t* dst, int dst_x, int dst_y, const lcu_t *src);
int uvg_count_available_edge_cus(const cu_loc_t* const cu_loc, const lcu_t* const lcu, bool left); int uvg_count_available_edge_cus(const cu_loc_t* const cu_loc, const lcu_t* const lcu, bool left);
int uvg_count_chroma_tree_available_edge_cus(int x, int y, int width, int height, const lcu_t* const lcu, bool left);
/** /**
* \brief Return pointer to the top right reference CU. * \brief Return pointer to the top right reference CU.

View file

@ -1083,12 +1083,12 @@ static void filter_deblock_edge_chroma(encoder_state_t * const state,
int32_t y_coord = y << 1; int32_t y_coord = y << 1;
cu_array_t* cua = tree_type != UVG_CHROMA_T ? frame->cu_array : frame->chroma_cu_array; cu_array_t* cua = tree_type != UVG_CHROMA_T ? frame->cu_array : frame->chroma_cu_array;
if (dir == EDGE_VER) { if (dir == EDGE_VER) {
y_coord = (y + min_chroma_length * blk_idx) << (tree_type != UVG_CHROMA_T); y_coord = (y + min_chroma_length * blk_idx) << (1);
cu_p = uvg_cu_array_at(cua, x_coord - 1, y_coord); cu_p = uvg_cu_array_at(cua, x_coord - 1, y_coord);
cu_q = uvg_cu_array_at(cua, x_coord , y_coord); cu_q = uvg_cu_array_at(cua, x_coord , y_coord);
} else { } else {
x_coord = (x + min_chroma_length * blk_idx) << (tree_type != UVG_CHROMA_T); x_coord = (x + min_chroma_length * blk_idx) << (1);
cu_p = uvg_cu_array_at(cua, x_coord, y_coord - 1); cu_p = uvg_cu_array_at(cua, x_coord, y_coord - 1);
cu_q = uvg_cu_array_at(cua, x_coord, y_coord ); cu_q = uvg_cu_array_at(cua, x_coord, y_coord );
} }
@ -1116,7 +1116,7 @@ static void filter_deblock_edge_chroma(encoder_state_t * const state,
const bool large_boundary = (max_filter_length_P >= 3 && max_filter_length_Q >= 3); const bool large_boundary = (max_filter_length_P >= 3 && max_filter_length_Q >= 3);
const bool is_chroma_hor_CTB_boundary = (dir == EDGE_HOR && y_coord % (LCU_WIDTH >> (tree_type == UVG_CHROMA_T)) == 0); const bool is_chroma_hor_CTB_boundary = (dir == EDGE_HOR && y_coord % LCU_WIDTH == 0);
uint8_t c_strength[2] = { 0, 0 }; uint8_t c_strength[2] = { 0, 0 };

View file

@ -1153,14 +1153,8 @@ void uvg_intra_build_reference_any(
} }
} }
else { else {
if (!is_dual_tree) {
const int num_cus = uvg_count_available_edge_cus(cu_loc, lcu, true); const int num_cus = uvg_count_available_edge_cus(cu_loc, lcu, true);
px_available_left = is_dual_tree || !is_chroma ? num_cus * 4 : num_cus * 2; px_available_left = !is_chroma ? num_cus * 4 : num_cus * 2;
}
else {
const int num_cus = uvg_count_chroma_tree_available_edge_cus(cu_loc->x >> 1, cu_loc->y >> 1, width, height, lcu, true);
px_available_left = num_cus * 4;
}
} }
// Limit the number of available pixels based on block size and dimensions // Limit the number of available pixels based on block size and dimensions
@ -1282,14 +1276,8 @@ void uvg_intra_build_reference_any(
} }
} }
else { else {
if (!is_dual_tree) {
const int num_cus = uvg_count_available_edge_cus(cu_loc, lcu, false); const int num_cus = uvg_count_available_edge_cus(cu_loc, lcu, false);
px_available_top = is_dual_tree || !is_chroma ? num_cus * 4 : num_cus * 2; px_available_top = !is_chroma ? num_cus * 4 : num_cus * 2;
}
else {
const int num_cus = uvg_count_chroma_tree_available_edge_cus(cu_loc->x >> 1, cu_loc->y >> 1, width, height, lcu, false);
px_available_top = num_cus * 4;
}
} }
// Limit the number of available pixels based on block size and dimensions // Limit the number of available pixels based on block size and dimensions
@ -1475,8 +1463,8 @@ void uvg_intra_build_reference_inner(
const int num_cus = uvg_count_available_edge_cus(cu_loc, lcu, true); const int num_cus = uvg_count_available_edge_cus(cu_loc, lcu, true);
px_available_left = is_dual_tree || !is_chroma ? num_cus * 4 : num_cus * 2; px_available_left = is_dual_tree || !is_chroma ? num_cus * 4 : num_cus * 2;
} else { } else {
const int num_cus = uvg_count_chroma_tree_available_edge_cus(cu_loc->x >> 1, cu_loc->y >> 1, width, height, lcu, true); const int num_cus = uvg_count_available_edge_cus(cu_loc, lcu, true);
px_available_left = num_cus * 4; px_available_left = !is_chroma ? num_cus * 4 : num_cus * 2;
} }
} }
@ -1538,14 +1526,8 @@ void uvg_intra_build_reference_inner(
} }
} }
else { else {
if (!is_dual_tree) {
const int num_cus = uvg_count_available_edge_cus(cu_loc, lcu, false); const int num_cus = uvg_count_available_edge_cus(cu_loc, lcu, false);
px_available_top = is_dual_tree || !is_chroma ? num_cus * 4 : num_cus * 2; px_available_top = !is_chroma ? num_cus * 4 : num_cus * 2;
}
else {
const int num_cus = uvg_count_chroma_tree_available_edge_cus(cu_loc->x >> 1, cu_loc->y >> 1, width, height, lcu, false);
px_available_top = num_cus * 4;
}
} }
// Limit the number of available pixels based on block size and dimensions // Limit the number of available pixels based on block size and dimensions

View file

@ -1274,10 +1274,7 @@ static double search_cu(
pu_depth_intra.min = ctrl->cfg.pu_depth_intra.min[gop_layer] >= 0 ? ctrl->cfg.pu_depth_intra.min[gop_layer] : ctrl->cfg.pu_depth_intra.min[0]; pu_depth_intra.min = ctrl->cfg.pu_depth_intra.min[gop_layer] >= 0 ? ctrl->cfg.pu_depth_intra.min[gop_layer] : ctrl->cfg.pu_depth_intra.min[0];
pu_depth_intra.max = ctrl->cfg.pu_depth_intra.max[gop_layer] >= 0 ? ctrl->cfg.pu_depth_intra.max[gop_layer] : ctrl->cfg.pu_depth_intra.max[0]; pu_depth_intra.max = ctrl->cfg.pu_depth_intra.max[gop_layer] >= 0 ? ctrl->cfg.pu_depth_intra.max[gop_layer] : ctrl->cfg.pu_depth_intra.max[0];
} }
if(tree_type == UVG_CHROMA_T) {
pu_depth_intra.max = CLIP(1, 3, pu_depth_intra.max);
pu_depth_intra.min = CLIP(1, 3, pu_depth_intra.min);
}
pu_depth_inter.min = ctrl->cfg.pu_depth_inter.min[gop_layer] >= 0 ? ctrl->cfg.pu_depth_inter.min[gop_layer] : ctrl->cfg.pu_depth_inter.min[0]; pu_depth_inter.min = ctrl->cfg.pu_depth_inter.min[gop_layer] >= 0 ? ctrl->cfg.pu_depth_inter.min[gop_layer] : ctrl->cfg.pu_depth_inter.min[0];
pu_depth_inter.max = ctrl->cfg.pu_depth_inter.max[gop_layer] >= 0 ? ctrl->cfg.pu_depth_inter.max[gop_layer] : ctrl->cfg.pu_depth_inter.max[0]; pu_depth_inter.max = ctrl->cfg.pu_depth_inter.max[gop_layer] >= 0 ? ctrl->cfg.pu_depth_inter.max[gop_layer] : ctrl->cfg.pu_depth_inter.max[0];
@ -1734,10 +1731,7 @@ static double search_cu(
memcpy(&post_seach_cabac, &state->search_cabac, sizeof(post_seach_cabac)); memcpy(&post_seach_cabac, &state->search_cabac, sizeof(post_seach_cabac));
// Recursively split all the way to max search depth. // Recursively split all the way to max search depth.
for (int split_type = QT_SPLIT; split_type <= TT_VER_SPLIT; ++split_type) { for (int split_type = QT_SPLIT; split_type <= TT_VER_SPLIT; ++split_type) {
if (!can_split[split_type] if (!can_split[split_type])
|| (tree_type == UVG_CHROMA_T && split_type == TT_HOR_SPLIT && cu_loc->chroma_height == 8)
|| (tree_type == UVG_CHROMA_T && split_type == BT_HOR_SPLIT && cu_loc->chroma_height == 4)
)
continue; continue;
if (completely_inside && check_for_early_termission( if (completely_inside && check_for_early_termission(