[lfnst] handle transform skip correctly during search

This commit is contained in:
Joose Sainio 2022-07-07 17:04:16 +03:00
parent 03fb6ce92e
commit ea32ef33ac
4 changed files with 11 additions and 9 deletions

View file

@ -166,7 +166,8 @@ static bool can_use_lfnst_with_isp(const int width, const int height, const int
const int x,
const int y,
enum uvg_tree_type tree_type,
const color_t color)
const color_t color,
const lcu_t* lcu)
{
if (state->encoder_control->cfg.lfnst && pred_cu->type == CU_INTRA) {
const int isp_mode = 0; // ISP_TODO: assign proper ISP mode when ISP is implemented
@ -204,9 +205,9 @@ static bool can_use_lfnst_with_isp(const int width, const int height, const int
if (color == COLOR_Y) {
for (int i = 0; i < num_transform_units; i++) {
// TODO: this works only for square blocks
const int pu_x = x + ((i % tu_row_length) * tu_width);
const int pu_y = y + ((i / tu_row_length) * tu_height);
const cu_info_t* cur_tu = uvg_cu_array_at_const(frame->cu_array, pu_x, pu_y);
const int tu_x = x + ((i % tu_row_length) * tu_width);
const int tu_y = y + ((i / tu_row_length) * tu_height);
const cu_info_t* cur_tu = lcu ? LCU_GET_CU_AT_PX(lcu, tu_x, tu_y) : uvg_cu_array_at_const(frame->cu_array, tu_x, tu_y);
assert(cur_tu != NULL && "NULL transform unit.");
bool cbf_set = cbf_is_set(cur_tu->cbf, tr_depth, COLOR_Y);
@ -239,7 +240,7 @@ static bool encode_lfnst_idx(
const color_t color)
{
if (uvg_is_lfnst_allowed(state, pred_cu, width, height, x, y, tree_type, color)) {
if (uvg_is_lfnst_allowed(state, pred_cu, width, height, x, y, tree_type, color, NULL)) {
// Getting separate tree bool from block size is a temporary fix until a proper dual tree check is possible (there is no dual tree structure at time of writing this).
// VTM seems to force explicit dual tree structure for small 4x4 blocks
bool is_separate_tree = depth == 4 || tree_type != UVG_BOTH_T;

View file

@ -49,7 +49,8 @@ bool uvg_is_lfnst_allowed(
const int x,
const int y,
enum uvg_tree_type tree_type,
const color_t color);
const color_t color,
const lcu_t* lcu);
void uvg_encode_coding_tree(
encoder_state_t * const state,

View file

@ -572,7 +572,7 @@ static double cu_rd_cost_tr_split_accurate(
}
if(depth == 4 || tree_type == UVG_LUMA_T) {
if (uvg_is_lfnst_allowed(state, tr_cu, width, width, x_px, y_px, tree_type, COLOR_Y)) {
if (uvg_is_lfnst_allowed(state, tr_cu, width, width, x_px, y_px, tree_type, COLOR_Y, lcu)) {
const int lfnst_idx = tr_cu->lfnst_idx;
CABAC_FBITS_UPDATE(
cabac,
@ -639,7 +639,7 @@ static double cu_rd_cost_tr_split_accurate(
}
}
if (uvg_is_lfnst_allowed(state, tr_cu, width, width, x_px, y_px, tree_type, depth == 4 || tree_type == UVG_CHROMA_T ? COLOR_UV : COLOR_Y)) {
if (uvg_is_lfnst_allowed(state, tr_cu, width, width, x_px, y_px, tree_type, depth == 4 || tree_type == UVG_CHROMA_T ? COLOR_UV : COLOR_Y, lcu)) {
const int lfnst_idx = (depth != 4 && tree_type != UVG_CHROMA_T) ? tr_cu->lfnst_idx : tr_cu->cr_lfnst_idx;
CABAC_FBITS_UPDATE(
cabac,

View file

@ -703,7 +703,7 @@ void uvg_chroma_transform_search(
transforms[i] == CHROMA_TS);
}
if((depth == 4 || tree_type == UVG_CHROMA_T) && state->encoder_control->cfg.lfnst && 0) {
if(uvg_is_lfnst_allowed(state, pred_cu, width, height, 0, 0 , UVG_CHROMA_T, COLOR_UV)) {
if(uvg_is_lfnst_allowed(state, pred_cu, width, height, 0, 0 , UVG_CHROMA_T, COLOR_UV, lcu)) {
const int lfnst_idx = pred_cu->cr_lfnst_idx;
CABAC_FBITS_UPDATE(
&state->search_cabac,