[mtt] 64x32 and 32x64

This commit is contained in:
Joose Sainio 2022-11-21 13:45:36 +02:00
parent baa7a3bb70
commit 69f66626ed
5 changed files with 69 additions and 71 deletions

View file

@ -372,10 +372,10 @@ int uvg_count_available_edge_cus(const cu_loc_t* const cu_loc, const lcu_t* cons
while (LCU_GET_CU_AT_PX(lcu, cu_loc->local_x - TR_MIN_WIDTH, cu_loc->local_y + amount)->type != CU_NOTSET && (cu_loc->local_y + amount) < LCU_WIDTH) { while (LCU_GET_CU_AT_PX(lcu, cu_loc->local_x - TR_MIN_WIDTH, cu_loc->local_y + amount)->type != CU_NOTSET && (cu_loc->local_y + amount) < LCU_WIDTH) {
amount += TR_MIN_WIDTH; amount += TR_MIN_WIDTH;
} }
return amount / TR_MIN_WIDTH; return MAX(amount / TR_MIN_WIDTH, cu_loc->height / TR_MIN_WIDTH);
} }
while (LCU_GET_CU_AT_PX(lcu, cu_loc->local_x + amount, cu_loc->local_y - TR_MIN_WIDTH)->type != CU_NOTSET && cu_loc->local_x + amount < LCU_WIDTH) { while (LCU_GET_CU_AT_PX(lcu, cu_loc->local_x + amount, cu_loc->local_y - TR_MIN_WIDTH)->type != CU_NOTSET && cu_loc->local_x + amount < LCU_WIDTH) {
amount += TR_MIN_WIDTH; amount += TR_MIN_WIDTH;
} }
return amount / TR_MIN_WIDTH; return MAX(amount / TR_MIN_WIDTH, cu_loc->width / TR_MIN_WIDTH);
} }

View file

@ -625,25 +625,31 @@ static void encode_transform_coeff(
const int x_cu = 8 * (x / 8); const int x_cu = 8 * (x / 8);
const int y_cu = 8 * (y / 8); const int y_cu = 8 * (y / 8);
const cu_info_t *cur_cu = uvg_cu_array_at_const(used_array, x, y); // TODO: very suspect, chroma cbfs stored in upper left corner, everything else in bottom right for depth 4 const cu_info_t *cur_cu = uvg_cu_array_at_const(used_array, x, y); // TODO: very suspect, chroma cbfs stored in upper left corner, everything else in bottom right for depth 4
int8_t split = (cu_loc->width > TR_MAX_WIDTH || cu_loc->height > TR_MAX_WIDTH); const bool ver_split = cu_loc->height > TR_MAX_WIDTH;
const bool hor_split = cu_loc->width > TR_MAX_WIDTH;
const int cb_flag_y = tree_type != UVG_CHROMA_T ? cbf_is_set(cur_pu->cbf, COLOR_Y) : 0; const int cb_flag_y = tree_type != UVG_CHROMA_T ? cbf_is_set(cur_pu->cbf, COLOR_Y) : 0;
const int cb_flag_u = tree_type != UVG_LUMA_T ?( cur_pu->joint_cb_cr ? (cur_pu->joint_cb_cr >> 1) & 1 : cbf_is_set(cur_cu->cbf, COLOR_U)) : 0; const int cb_flag_u = tree_type != UVG_LUMA_T ?( cur_pu->joint_cb_cr ? (cur_pu->joint_cb_cr >> 1) & 1 : cbf_is_set(cur_cu->cbf, COLOR_U)) : 0;
const int cb_flag_v = tree_type != UVG_LUMA_T ? (cur_pu->joint_cb_cr ? cur_pu->joint_cb_cr & 1 : cbf_is_set(cur_cu->cbf, COLOR_V)) : 0; const int cb_flag_v = tree_type != UVG_LUMA_T ? (cur_pu->joint_cb_cr ? cur_pu->joint_cb_cr & 1 : cbf_is_set(cur_cu->cbf, COLOR_V)) : 0;
if (split) { if (hor_split || ver_split) {
int split_width = width >> 1; enum split_type split;
int split_height = height >> 1; if (cu_loc->width > TR_MAX_WIDTH && cu_loc->height > TR_MAX_WIDTH) {
split = QT_SPLIT;
}
else if (cu_loc->width > TR_MAX_WIDTH) {
split = BT_VER_SPLIT;
}
else {
split = BT_HOR_SPLIT;
}
for (int j = 0; j < 2; j++) { cu_loc_t split_cu_loc[4];
for (int i = 0; i < 2; i++) { const int split_count = uvg_get_split_locs(cu_loc, split, split_cu_loc);
cu_loc_t loc; for (int i = 0; i < split_count; ++i) {
uvg_cu_loc_ctor(&loc, (x + i * split_width), (y + j * split_height), width >> 1, height >> 1); encode_transform_coeff(state, &split_cu_loc[i], only_chroma, coeff, tree_type, true, luma_cbf_ctx, &split_cu_loc[i]);
encode_transform_coeff(state, &loc, only_chroma, coeff, tree_type, true, luma_cbf_ctx, &loc);
}
} }
return; return;
} }

View file

@ -565,7 +565,7 @@ static void predict_cclm(
y_extension >>= tree_type == UVG_CHROMA_T; y_extension >>= tree_type == UVG_CHROMA_T;
const cu_info_t* pu = LCU_GET_CU_AT_PX(lcu, (x_scu >> (tree_type == UVG_CHROMA_T)) - 4, y_extension); const cu_info_t* pu = LCU_GET_CU_AT_PX(lcu, (x_scu >> (tree_type == UVG_CHROMA_T)) - 4, y_extension);
if (y_extension >= ctu_size || pu->type == CU_NOTSET || (pu->type == CU_INTRA && pu->intra.mode_chroma == -1)) break; if (y_extension >= ctu_size || pu->type == CU_NOTSET || (pu->type == CU_INTRA && pu->intra.mode_chroma == -1)) break;
if(x_scu == 32 && y_scu == 0 && pu->log2_width == 6) break; if(x_scu == 32 && y_scu == 0 && pu->log2_height == 6 && pu->log2_width == 6 ) break;
} }
for(int i = 0; i < height + available_left_below * 2; i++) { for(int i = 0; i < height + available_left_below * 2; i++) {
sampled_luma_ref.left[i] = state->tile->frame->cclm_luma_rec[(y0/2 + i) * (stride2/2) + x0 / 2 - 1]; sampled_luma_ref.left[i] = state->tile->frame->cclm_luma_rec[(y0/2 + i) * (stride2/2) + x0 / 2 - 1];
@ -1783,6 +1783,7 @@ static void intra_recon_tb_leaf(
} }
} }
/** /**
* \brief Reconstruct an intra CU * \brief Reconstruct an intra CU
* *
@ -1833,33 +1834,23 @@ void uvg_intra_recon_cu(
} }
if (width > TR_MAX_WIDTH || height > TR_MAX_WIDTH) { if (width > TR_MAX_WIDTH || height > TR_MAX_WIDTH) {
cu_loc_t split_cu_loc; enum split_type split;
if (cu_loc->width > TR_MAX_WIDTH && cu_loc->height > TR_MAX_WIDTH) {
split = QT_SPLIT;
}
else if (cu_loc->width > TR_MAX_WIDTH) {
split = BT_VER_SPLIT;
}
else {
split = BT_HOR_SPLIT;
}
const int half_width = width / 2; cu_loc_t split_cu_loc[4];
const int half_height = height / 2; const int split_count = uvg_get_split_locs(cu_loc, split, split_cu_loc);
uvg_cu_loc_ctor(&split_cu_loc, cu_loc->x, cu_loc->y, half_width, half_height); for (int i = 0; i < split_count; ++i) {
uvg_intra_recon_cu(state, search_data, &split_cu_loc, NULL, lcu, tree_type, recon_luma, recon_chroma); uvg_intra_recon_cu(state, search_data, &split_cu_loc[i], NULL, lcu, tree_type, recon_luma, recon_chroma);
uvg_cu_loc_ctor(&split_cu_loc, cu_loc->x + half_width, cu_loc->y, half_width, half_height); }
uvg_intra_recon_cu(state, search_data, &split_cu_loc, NULL, lcu, tree_type, recon_luma, recon_chroma);
uvg_cu_loc_ctor(&split_cu_loc, cu_loc->x, cu_loc->y + half_height, half_width, half_height);
uvg_intra_recon_cu(state, search_data, &split_cu_loc, NULL, lcu, tree_type, recon_luma, recon_chroma);
uvg_cu_loc_ctor(&split_cu_loc, cu_loc->x + half_width, cu_loc->y + half_height, half_width, half_height);
uvg_intra_recon_cu(state, search_data, &split_cu_loc, NULL, lcu, tree_type, recon_luma, recon_chroma);
// Propagate coded block flags from child CUs to parent CU.
uint16_t child_cbfs[3] = {
LCU_GET_CU_AT_PX(lcu, (lcu_px.x + half_width) >> (tree_type == UVG_CHROMA_T), lcu_px.y >> (tree_type == UVG_CHROMA_T))->cbf,
LCU_GET_CU_AT_PX(lcu, lcu_px.x >> (tree_type == UVG_CHROMA_T), (lcu_px.y + half_height) >> (tree_type == UVG_CHROMA_T))->cbf,
LCU_GET_CU_AT_PX(lcu, (lcu_px.x + half_width) >> (tree_type == UVG_CHROMA_T), (lcu_px.y + half_height) >> (tree_type == UVG_CHROMA_T))->cbf,
};
//if (recon_luma && depth <= MAX_DEPTH) {
// cbf_set_conditionally(&cur_cu->cbf, child_cbfs, depth, COLOR_Y);
//}
//if (recon_chroma && depth <= MAX_DEPTH) {
// cbf_set_conditionally(&cur_cu->cbf, child_cbfs, depth, COLOR_U);
// cbf_set_conditionally(&cur_cu->cbf, child_cbfs, depth, COLOR_V);
//}
return; return;
} }
if (search_data->pred_cu.intra.isp_mode != ISP_MODE_NO_ISP && recon_luma ) { if (search_data->pred_cu.intra.isp_mode != ISP_MODE_NO_ISP && recon_luma ) {

View file

@ -575,25 +575,24 @@ static double search_intra_trdepth(
// max_depth. // max_depth.
// - Min transform size hasn't been reached (MAX_PU_DEPTH). // - Min transform size hasn't been reached (MAX_PU_DEPTH).
else { else {
cu_loc_t split_cu_loc;
const int half_width = width / 2;
const int half_height = height / 2;
split_cost = 0; split_cost = 0;
uvg_cu_loc_ctor(&split_cu_loc, cu_loc->x, cu_loc->y, half_width, half_height);
split_cost += search_intra_trdepth(state, &split_cu_loc, nosplit_cost, search_data, lcu, tree_type); enum split_type split;
if (split_cost < nosplit_cost) { if (cu_loc->width > TR_MAX_WIDTH && cu_loc->height > TR_MAX_WIDTH) {
uvg_cu_loc_ctor(&split_cu_loc, cu_loc->x + half_width, cu_loc->y, half_width, half_height); split = QT_SPLIT;
split_cost += search_intra_trdepth(state, &split_cu_loc, nosplit_cost, search_data, lcu, tree_type);
} }
if (split_cost < nosplit_cost) { else if (cu_loc->width > TR_MAX_WIDTH) {
uvg_cu_loc_ctor(&split_cu_loc, cu_loc->x, cu_loc->y + half_height, half_width, half_height); split = BT_VER_SPLIT;
split_cost += search_intra_trdepth(state, &split_cu_loc, nosplit_cost, search_data, lcu, tree_type);
} }
if (split_cost < nosplit_cost) { else {
uvg_cu_loc_ctor(&split_cu_loc, cu_loc->x + half_width, cu_loc->y + half_height, half_width, half_height); split = BT_HOR_SPLIT;
split_cost += search_intra_trdepth(state, &split_cu_loc, nosplit_cost, search_data, lcu, tree_type); }
cu_loc_t split_cu_loc[4];
const int split_count = uvg_get_split_locs(cu_loc, split, split_cu_loc);
for (int i = 0; i < split_count; ++i) {
split_cost += search_intra_trdepth(state, &split_cu_loc[i], nosplit_cost, search_data, lcu, tree_type);
} }
} }
@ -1821,7 +1820,7 @@ void uvg_search_cu_intra(
} }
uint8_t num_mrl_modes = 0; uint8_t num_mrl_modes = 0;
for(int line = 1; line < lines; ++line) { for(int line = 1; line < lines && !is_large; ++line) {
uvg_pixel extra_refs[128 * MAX_REF_LINE_IDX] = { 0 }; uvg_pixel extra_refs[128 * MAX_REF_LINE_IDX] = { 0 };
if (luma_px.x > 0 && lcu_px.x == 0 && lcu_px.y > 0) { if (luma_px.x > 0 && lcu_px.x == 0 && lcu_px.y > 0) {

View file

@ -1400,25 +1400,27 @@ void uvg_quantize_lcu_residual(
} }
if (cu_loc->width > TR_MAX_WIDTH || cu_loc->height > TR_MAX_WIDTH) { if (cu_loc->width > TR_MAX_WIDTH || cu_loc->height > TR_MAX_WIDTH) {
enum split_type split;
if (cu_loc->width > TR_MAX_WIDTH && cu_loc->height > TR_MAX_WIDTH) {
split = QT_SPLIT;
}
else if (cu_loc->width > TR_MAX_WIDTH) {
split = BT_VER_SPLIT;
}
else {
split = BT_HOR_SPLIT;
}
// Split transform and increase depth cu_loc_t split_cu_loc[4];
const int offset = width / 2; uint16_t child_cbfs[3];
for (int j = 0; j < 2; ++j) { const int split_count = uvg_get_split_locs(cu_loc, split, split_cu_loc);
for (int i = 0; i < 2; ++i) { for (int i = 0; i < split_count; ++i) {
cu_loc_t loc; uvg_quantize_lcu_residual(state, luma, chroma, 0, &split_cu_loc[i], NULL, lcu, early_skip, tree_type);
uvg_cu_loc_ctor(&loc, (x + i * offset), (y + j * offset), width >> 1, height >> 1); if(i != 0) {
// jccr is currently not supported if transform is split child_cbfs[i - 1] = LCU_GET_CU_AT_PX(lcu, split_cu_loc[i].local_x, split_cu_loc[i].local_y)->cbf;
uvg_quantize_lcu_residual(state, luma, chroma, 0, &loc, NULL, lcu, early_skip, tree_type);
} }
} }
// Propagate coded block flags from child CUs to parent CU.
uint16_t child_cbfs[3] = {
LCU_GET_CU_AT_PX(lcu, lcu_px.x + offset, lcu_px.y )->cbf,
LCU_GET_CU_AT_PX(lcu, lcu_px.x, lcu_px.y + offset)->cbf,
LCU_GET_CU_AT_PX(lcu, lcu_px.x + offset, lcu_px.y + offset)->cbf,
};
cur_pu->root_cbf = cbf_is_set_any(cur_pu->cbf) cur_pu->root_cbf = cbf_is_set_any(cur_pu->cbf)
|| cbf_is_set_any(child_cbfs[0]) || cbf_is_set_any(child_cbfs[0])