From a3df13fb99b915df777bd99edc973c7ddfd6a197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arttu=20Yl=C3=A4-Outinen?= Date: Mon, 12 Oct 2015 14:44:03 +0300 Subject: [PATCH] Make kvz_inter_get_merge_cand work with SMP blocks. - Replaces parameter depth with parameters width and height. - Adds parameters use_a1 and use_b1 for disabling the use of merge candidates A1 and B1. --- src/inter.c | 30 +++++++++++++++++++++--------- src/inter.h | 31 ++++++++++++++++++++++++++++--- src/search_inter.c | 8 +++++++- 3 files changed, 56 insertions(+), 13 deletions(-) diff --git a/src/inter.c b/src/inter.c index 64e63485..177a745f 100644 --- a/src/inter.c +++ b/src/inter.c @@ -407,8 +407,8 @@ static void inter_clear_cu_unused(cu_info_t* cu) { /** * \brief Get merge candidates for current block * \param encoder encoder control struct to use - * \param x_cu block x position in SCU - * \param y_cu block y position in SCU + * \param x block x position in SCU + * \param y block y position in SCU * \param width current block width * \param height current block height * \param b0 candidate b0 @@ -694,13 +694,23 @@ void kvz_inter_get_mv_cand(const encoder_state_t * const state, /** * \brief Get merge predictions for current block - * \param encoder encoder control struct to use - * \param x_cu block x position in SCU - * \param y_cu block y position in SCU - * \param depth current block depth - * \param mv_pred[MRG_MAX_NUM_CANDS][2] MRG_MAX_NUM_CANDS motion vector prediction + * \param state the encoder state + * \param x block x position in SCU + * \param y block y position in SCU + * \param width block width + * \param height block height + * \param use_a1 true, if candidate a1 can be used + * \param use_b1 true, if candidate b1 can be used + * \param mv_cand Returns the merge candidates. + * \param lcu lcu containing the block + * \return number of merge candidates */ -uint8_t kvz_inter_get_merge_cand(const encoder_state_t * const state, int32_t x, int32_t y, int8_t depth, inter_merge_cand_t mv_cand[MRG_MAX_NUM_CANDS], lcu_t *lcu) +uint8_t kvz_inter_get_merge_cand(const encoder_state_t * const state, + int32_t x, int32_t y, + int32_t width, int32_t height, + bool use_a1, bool use_b1, + inter_merge_cand_t mv_cand[MRG_MAX_NUM_CANDS], + lcu_t *lcu) { uint8_t candidates = 0; int8_t duplicate = 0; @@ -708,8 +718,10 @@ uint8_t kvz_inter_get_merge_cand(const encoder_state_t * const state, int32_t x, cu_info_t *b0, *b1, *b2, *a0, *a1; int8_t zero_idx = 0; b0 = b1 = b2 = a0 = a1 = NULL; - kvz_inter_get_spatial_merge_candidates(x, y, LCU_WIDTH >> depth, LCU_WIDTH >> depth, &b0, &b1, &b2, &a0, &a1, lcu); + kvz_inter_get_spatial_merge_candidates(x, y, width, height, &b0, &b1, &b2, &a0, &a1, lcu); + if (!use_a1) a1 = NULL; + if (!use_b1) b1 = NULL; #define CHECK_DUPLICATE(CU1,CU2) {duplicate = 0; if ((CU2) && \ (CU1)->inter.mv_dir == (CU2)->inter.mv_dir && \ diff --git a/src/inter.h b/src/inter.h index ec5f271d..b2e85569 100644 --- a/src/inter.h +++ b/src/inter.h @@ -42,7 +42,32 @@ typedef struct { //void kvz_inter_set_block(image* im,uint32_t x_cu, uint32_t y_cu, uint8_t depth, cu_info *cur_cu); void kvz_inter_recon_lcu(const encoder_state_t * const state, const kvz_picture * ref, int32_t xpos, int32_t ypos, int32_t width, const int16_t mv_param[2], lcu_t* lcu, hi_prec_buf_t *hi_prec_out); void kvz_inter_recon_lcu_bipred(const encoder_state_t * const state, const kvz_picture * ref1, const kvz_picture * ref2, int32_t xpos, int32_t ypos, int32_t width, int16_t mv_param[2][2], lcu_t* lcu); -void kvz_inter_get_spatial_merge_candidates(int32_t x, int32_t y, int32_t width, int32_t height, cu_info_t **b0, cu_info_t **b1, cu_info_t **b2, cu_info_t **a0, cu_info_t **a1, lcu_t *lcu); -void kvz_inter_get_mv_cand(const encoder_state_t *state, int32_t x, int32_t y, int32_t width, int32_t height, int16_t mv_cand[2][2], cu_info_t* cur_cu, lcu_t *lcu, int8_t reflist); -uint8_t kvz_inter_get_merge_cand(const encoder_state_t *state, int32_t x, int32_t y, int8_t depth, inter_merge_cand_t mv_cand[MRG_MAX_NUM_CANDS], lcu_t *lcu); + +void kvz_inter_get_spatial_merge_candidates(int32_t x, + int32_t y, + int32_t width, + int32_t height, + cu_info_t **b0, + cu_info_t **b1, + cu_info_t **b2, + cu_info_t **a0, + cu_info_t **a1, + lcu_t *lcu); + +void kvz_inter_get_mv_cand(const encoder_state_t * const state, + int32_t x, + int32_t y, + int32_t width, + int32_t height, + int16_t mv_cand[2][2], + cu_info_t* cur_cu, + lcu_t *lcu, + int8_t reflist); + +uint8_t kvz_inter_get_merge_cand(const encoder_state_t * const state, + int32_t x, int32_t y, + int32_t width, int32_t height, + bool use_a1, bool use_b1, + inter_merge_cand_t mv_cand[MRG_MAX_NUM_CANDS], + lcu_t *lcu); #endif diff --git a/src/search_inter.c b/src/search_inter.c index 989eca7d..17159f6d 100644 --- a/src/search_inter.c +++ b/src/search_inter.c @@ -1104,7 +1104,13 @@ int kvz_search_cu_inter(const encoder_state_t * const state, int x, int y, int d // Search for merge mode candidate inter_merge_cand_t merge_cand[MRG_MAX_NUM_CANDS]; // Get list of candidates - int16_t num_cand = kvz_inter_get_merge_cand(state, x, y, depth, merge_cand, lcu); + int16_t num_cand = kvz_inter_get_merge_cand(state, + x, y, + LCU_WIDTH >> depth, + LCU_WIDTH >> depth, + true, true, + merge_cand, + lcu); uint32_t(*get_mvd_cost)(vector2d_t *, cabac_data_t*) = get_mvd_coding_cost; if (state->encoder_control->cfg->mv_rdo) {