From 0b1b04cbeacead2c3a2448558f4e04e46a4d07c1 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 00ef167f..9041dcdc 100644 --- a/src/search.c +++ b/src/search.c @@ -76,12 +76,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; @@ -185,6 +190,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( @@ -1662,7 +1677,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,