From 812377db45d66857d218d3b29a1170305afee0a4 Mon Sep 17 00:00:00 2001 From: Joose Sainio Date: Mon, 19 Dec 2022 10:24:00 +0200 Subject: [PATCH] [mtt] Set cus outside of the frame to zero for initializing partial worktree --- src/search.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/search.c b/src/search.c index c0dc0700..10b2ae35 100644 --- a/src/search.c +++ b/src/search.c @@ -77,12 +77,17 @@ static INLINE void copy_cu_info(lcu_t *from, lcu_t *to, const cu_loc_t* const cu } -static INLINE void initialize_partial_work_tree(lcu_t* from, lcu_t *to, const cu_loc_t * const cu_loc, const cu_loc_t* const - chroma_loc, - const enum uvg_tree_type tree_type) { +static INLINE void initialize_partial_work_tree( + const encoder_state_t* const state, + lcu_t* from, + lcu_t *to, + const cu_loc_t * const cu_loc, + const cu_loc_t* const + chroma_loc, + const enum uvg_tree_type tree_type) { - const int y_limit = LCU_WIDTH >> (tree_type == UVG_CHROMA_T); - const int x_limit = LCU_WIDTH >> (tree_type == UVG_CHROMA_T); + const int y_limit = MIN(LCU_WIDTH, state->tile->frame->height - cu_loc->y / 64 * 64) >> (tree_type == UVG_CHROMA_T); + const int x_limit = MIN(LCU_WIDTH, state->tile->frame->width - cu_loc->x / 64 * 64) >> (tree_type == UVG_CHROMA_T); if (cu_loc->local_x == 0) { to->left_ref = from->left_ref; @@ -186,6 +191,16 @@ static INLINE void initialize_partial_work_tree(lcu_t* from, lcu_t *to, const cu *LCU_GET_TOP_RIGHT_CU(to) = *LCU_GET_TOP_RIGHT_CU(from); } } + if (x_limit != LCU_WIDTH >> (tree_type == UVG_CHROMA_T)) { + for (int y = y_start; y < y_limit; y += SCU_WIDTH) { + memset(LCU_GET_CU_AT_PX(to, x_limit, y), 0, sizeof(cu_info_t)); + } + } + if (y_limit != LCU_WIDTH >> (tree_type == UVG_CHROMA_T)) { + for (int x = x_start; x < x_limit; x += SCU_WIDTH) { + memset(LCU_GET_CU_AT_PX(to, x, y_limit), 0, sizeof(cu_info_t)); + } + } } static INLINE void copy_cu_pixels( @@ -1694,7 +1709,7 @@ static double search_cu( uint8_t separate_chroma = 0; const int splits = uvg_get_split_locs(cu_loc, split_type, new_cu_loc, &separate_chroma); separate_chroma |= !has_chroma; - initialize_partial_work_tree(lcu, &split_lcu[split_type - 1], cu_loc, separate_chroma ? chroma_loc : cu_loc , tree_type); + initialize_partial_work_tree(state, lcu, &split_lcu[split_type - 1], cu_loc , separate_chroma ? chroma_loc : cu_loc, tree_type); for (int split = 0; split < splits; ++split) { new_split.part_index = split; split_cost += search_cu(state,