[mtt] Minor fixes

This commit is contained in:
Joose Sainio 2023-02-14 10:36:01 +02:00 committed by Marko Viitanen
parent d69bdf79f4
commit d222718c22
7 changed files with 24 additions and 27 deletions

View file

@ -192,11 +192,11 @@ static const struct option long_options[] = {
{ "dual-tree", no_argument, NULL, 0 }, { "dual-tree", no_argument, NULL, 0 },
{ "no-dual-tree", no_argument, NULL, 0 }, { "no-dual-tree", no_argument, NULL, 0 },
{ "cabac-debug-file", required_argument, NULL, 0 }, { "cabac-debug-file", required_argument, NULL, 0 },
{"mtt-depth-intra", required_argument, NULL, 0 }, { "mtt-depth-intra", required_argument, NULL, 0 },
{"mtt-depth-inter", required_argument, NULL, 0 }, { "mtt-depth-inter", required_argument, NULL, 0 },
{"mtt-depth-intra-chroma", required_argument, NULL, 0 }, { "mtt-depth-intra-chroma", required_argument, NULL, 0 },
{"max_bt_size", required_argument, NULL, 0 }, { "max-bt-size", required_argument, NULL, 0 },
{"max_tt_size", required_argument, NULL, 0 }, { "max-tt-size", required_argument, NULL, 0 },
{ "intra-rough-granularity",required_argument, NULL, 0 }, { "intra-rough-granularity",required_argument, NULL, 0 },
{ "ibc", required_argument, NULL, 0 }, { "ibc", required_argument, NULL, 0 },
{ "dep-quant", no_argument, NULL, 0 }, { "dep-quant", no_argument, NULL, 0 },

View file

@ -373,18 +373,11 @@ int uvg_get_split_locs(
int uvg_get_implicit_split( int uvg_get_implicit_split(
const encoder_state_t* const state, const encoder_state_t* const state,
const cu_loc_t* const cu_loc, const cu_loc_t* const cu_loc,
enum uint8_t max_mtt_depth,
uvg_tree_type tree_type, bool uses_chroma_coordinates)
uint8_t max_mtt_depth)
{ {
// This checking if cabac is in update state is a very dirty way of checking bool right_ok = (state->tile->frame->width >> uses_chroma_coordinates) >= cu_loc->x + cu_loc->width;
// whether we are in the search or writing the bitstream, and unfortunately the bool bottom_ok = (state->tile->frame->height >> uses_chroma_coordinates) >= cu_loc->y + cu_loc->height;
// coordinates are different for chroma tree in those two conditions. It might be
// possible to pass the chroma loc for uvg_get_possible_splits in the search but
// then all of the conditions need to be checked in that function.
// This current solutions *might* not work with alf enabled but I think it should work
bool right_ok = (state->tile->frame->width >> (tree_type == UVG_CHROMA_T && state->cabac.update)) >= cu_loc->x + cu_loc->width;
bool bottom_ok = (state->tile->frame->height >> (tree_type == UVG_CHROMA_T && state->cabac.update)) >= cu_loc->y + cu_loc->height;
if (right_ok && bottom_ok) return NO_SPLIT; if (right_ok && bottom_ok) return NO_SPLIT;
if (right_ok && max_mtt_depth != 0) return BT_HOR_SPLIT; if (right_ok && max_mtt_depth != 0) return BT_HOR_SPLIT;
@ -394,10 +387,11 @@ int uvg_get_implicit_split(
int uvg_get_possible_splits(const encoder_state_t * const state, int uvg_get_possible_splits(const encoder_state_t * const state,
const cu_loc_t * const cu_loc, split_tree_t split_tree, enum uvg_tree_type tree_type, bool splits[6]) const cu_loc_t * const cu_loc, split_tree_t split_tree, enum uvg_tree_type tree_type, bool splits[6], bool
use_chroma_coordinates)
{ {
const int width = tree_type != UVG_CHROMA_T ? cu_loc->width : cu_loc->chroma_width; const unsigned width = tree_type != UVG_CHROMA_T ? cu_loc->width : cu_loc->chroma_width;
const int height = tree_type != UVG_CHROMA_T ? cu_loc->height : cu_loc->chroma_height; const unsigned height = tree_type != UVG_CHROMA_T ? cu_loc->height : cu_loc->chroma_height;
const int slice_type = state->frame->is_irap ? (tree_type == UVG_CHROMA_T ? 2 : 0) : 1; const int slice_type = state->frame->is_irap ? (tree_type == UVG_CHROMA_T ? 2 : 0) : 1;
const unsigned max_btd = const unsigned max_btd =
@ -408,7 +402,7 @@ int uvg_get_possible_splits(const encoder_state_t * const state,
const unsigned min_tt_size = 1 << MIN_SIZE >> (tree_type == UVG_CHROMA_T); const unsigned min_tt_size = 1 << MIN_SIZE >> (tree_type == UVG_CHROMA_T);
const unsigned min_qt_size = state->encoder_control->cfg.min_qt_size[slice_type]; const unsigned min_qt_size = state->encoder_control->cfg.min_qt_size[slice_type];
const enum split_type implicitSplit = uvg_get_implicit_split(state, cu_loc, tree_type, max_btd); const enum split_type implicitSplit = uvg_get_implicit_split(state, cu_loc, max_btd, use_chroma_coordinates);
splits[NO_SPLIT] = splits[QT_SPLIT] = splits[BT_HOR_SPLIT] = splits[TT_HOR_SPLIT] = splits[BT_VER_SPLIT] = splits[TT_VER_SPLIT] = true; splits[NO_SPLIT] = splits[QT_SPLIT] = splits[BT_HOR_SPLIT] = splits[TT_HOR_SPLIT] = splits[BT_VER_SPLIT] = splits[TT_VER_SPLIT] = true;
bool can_btt = split_tree.mtt_depth < max_btd; bool can_btt = split_tree.mtt_depth < max_btd;
@ -426,8 +420,8 @@ int uvg_get_possible_splits(const encoder_state_t * const state,
{ {
splits[NO_SPLIT] = splits[TT_HOR_SPLIT] = splits[TT_VER_SPLIT] = false; splits[NO_SPLIT] = splits[TT_HOR_SPLIT] = splits[TT_VER_SPLIT] = false;
splits[BT_HOR_SPLIT] = implicitSplit == BT_HOR_SPLIT; splits[BT_HOR_SPLIT] = implicitSplit == BT_HOR_SPLIT && height <= max_bt_size;
splits[BT_VER_SPLIT] = implicitSplit == BT_VER_SPLIT; splits[BT_VER_SPLIT] = implicitSplit == BT_VER_SPLIT && width <= max_bt_size;
if (tree_type == UVG_CHROMA_T && width == 4) splits[BT_VER_SPLIT] = false; if (tree_type == UVG_CHROMA_T && width == 4) splits[BT_VER_SPLIT] = false;
if (!splits[BT_HOR_SPLIT] && !splits[BT_VER_SPLIT] && !splits[QT_SPLIT]) splits[QT_SPLIT] = true; if (!splits[BT_HOR_SPLIT] && !splits[BT_VER_SPLIT] && !splits[QT_SPLIT]) splits[QT_SPLIT] = true;
return 1; return 1;

View file

@ -203,7 +203,8 @@ int uvg_get_split_locs(
cu_loc_t out[4], cu_loc_t out[4],
uint8_t* separate_chroma); uint8_t* separate_chroma);
int uvg_get_possible_splits(const encoder_state_t* const state, int uvg_get_possible_splits(const encoder_state_t* const state,
const cu_loc_t* const cu_loc, split_tree_t split_tree, enum uvg_tree_type tree_type, bool splits[6]); const cu_loc_t* const cu_loc, split_tree_t split_tree, enum uvg_tree_type tree_type, bool splits[6], bool
use_chroma_coordinates);
#define CU_GET_MV_CAND(cu_info_ptr, reflist) \ #define CU_GET_MV_CAND(cu_info_ptr, reflist) \

View file

@ -1251,7 +1251,7 @@ uint8_t uvg_write_split_flag(
bool can_split[6]; bool can_split[6];
const bool is_implicit = uvg_get_possible_splits(state, cu_loc, split_tree, tree_type, can_split); const bool is_implicit = uvg_get_possible_splits(state, cu_loc, split_tree, tree_type, can_split, tree_type == UVG_CHROMA_T);
bool allow_split = can_split[1] || can_split[2] || can_split[3] || can_split[4] || can_split[5]; bool allow_split = can_split[1] || can_split[2] || can_split[3] || can_split[4] || can_split[5];

View file

@ -129,7 +129,7 @@ typedef int16_t coeff_t;
typedef int32_t mv_t; typedef int32_t mv_t;
//#define VERBOSE 1 //#define VERBOSE 1
#define UVG_DEBUG_PRINT_CABAC 1 //#define UVG_DEBUG_PRINT_CABAC 1
//#define UVG_DEBUG 1 //#define UVG_DEBUG 1
//#define UVG_DEBUG_PRINT_YUVIEW_CSV 1 //#define UVG_DEBUG_PRINT_YUVIEW_CSV 1

View file

@ -1600,6 +1600,8 @@ static double search_cu(
cu_loc_t separate_tree_chroma_loc = *cu_loc; cu_loc_t separate_tree_chroma_loc = *cu_loc;
separate_tree_chroma_loc.y >>= 1; separate_tree_chroma_loc.y >>= 1;
separate_tree_chroma_loc.x >>= 1; separate_tree_chroma_loc.x >>= 1;
separate_tree_chroma_loc.width >>= 1;
separate_tree_chroma_loc.height >>= 1;
if (cur_cu->type == CU_INTRA || cur_cu->type == CU_INTER) { if (cur_cu->type == CU_INTRA || cur_cu->type == CU_INTER) {
double bits = 0; double bits = 0;
@ -1689,7 +1691,7 @@ static double search_cu(
} }
bool can_split[6]; bool can_split[6];
bool is_implicit = uvg_get_possible_splits(state, cu_loc, split_tree, tree_type, can_split); bool is_implicit = uvg_get_possible_splits(state, cu_loc, split_tree, tree_type, can_split, false);
const int slice_type = state->frame->is_irap ? (tree_type == UVG_CHROMA_T ? 2 : 0) : 1; const int slice_type = state->frame->is_irap ? (tree_type == UVG_CHROMA_T ? 2 : 0) : 1;
const int max_btd = state->encoder_control->cfg.max_btt_depth[slice_type]; const int max_btd = state->encoder_control->cfg.max_btt_depth[slice_type];

View file

@ -417,7 +417,7 @@ static double search_intra_trdepth(
} }
if (pred_cu->intra.isp_mode != ISP_MODE_NO_ISP && search_data->best_isp_cbfs == 0) continue; if (pred_cu->intra.isp_mode != ISP_MODE_NO_ISP && search_data->best_isp_cbfs == 0) continue;
if (trafo != 0 && !cbf_is_set(pred_cu->cbf, COLOR_Y)) continue; if ((trafo != 0 || lfnst_idx != 0) && !cbf_is_set(pred_cu->cbf, COLOR_Y)) continue;
derive_mts_constraints(pred_cu, lcu, width, height, lcu_px); derive_mts_constraints(pred_cu, lcu, width, height, lcu_px);
if (pred_cu->tr_idx > 1) { if (pred_cu->tr_idx > 1) {