From 52335adda04180f3be95f66a256af4288beb9d2c Mon Sep 17 00:00:00 2001 From: Marko Viitanen Date: Fri, 11 Oct 2013 11:59:10 +0300 Subject: [PATCH] Split merge candidate derivation to its own function --- src/inter.c | 56 ++++++++++++++++++++++++++++++++++------------------- src/inter.h | 2 ++ 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/src/inter.c b/src/inter.c index e2a26b3e..bbdc41a0 100644 --- a/src/inter.c +++ b/src/inter.c @@ -227,18 +227,21 @@ void inter_recon(picture* ref,int32_t xpos, int32_t ypos,int32_t width, const in } /** - * \brief Get MV prediction for current block + * \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 depth current block depth - * \param mv_pred[2][2] 2x motion vector prediction + * \param b0 candidate b0 + * \param b1 candidate b1 + * \param b2 candidate b2 + * \param a0 candidate a0 + * \param a1 candidate a1 */ -void inter_get_mv_cand(encoder_control *encoder, int32_t x_cu, int32_t y_cu, int8_t depth, int16_t mv_cand[2][2]) +void inter_get_spatial_merge_candidates(encoder_control *encoder, int32_t x_cu, int32_t y_cu, int8_t depth, + cu_info **b0, cu_info **b1,cu_info **b2,cu_info **a0,cu_info **a1) { uint8_t cur_block_in_scu = (LCU_WIDTH>>depth) / CU_MIN_SIZE_PIXELS; //!< the width of the current block on SCU - uint8_t candidates = 0; - /* Predictor block locations ____ _______ @@ -248,37 +251,50 @@ void inter_get_mv_cand(encoder_control *encoder, int32_t x_cu, int32_t y_cu, int __| | |A1|_________| |A0| - */ - cu_info *b0, *b1, *b2, *a0, *a1; - - b0 = b1 = b2 = a0 = a1 = NULL; + */ // A0 and A1 availability testing if (x_cu != 0) { - a1 = &encoder->in.cur_pic->cu_array[MAX_DEPTH][x_cu - 1 + (y_cu + cur_block_in_scu - 1) * (encoder->in.width_in_lcu<coded) a1 = NULL; + *a1 = &encoder->in.cur_pic->cu_array[MAX_DEPTH][x_cu - 1 + (y_cu + cur_block_in_scu - 1) * (encoder->in.width_in_lcu<coded) *a1 = NULL; if (y_cu + cur_block_in_scu < encoder->in.height_in_lcu<in.cur_pic->cu_array[MAX_DEPTH][x_cu - 1 + (y_cu + cur_block_in_scu) * (encoder->in.width_in_lcu<coded) a0 = NULL; + *a0 = &encoder->in.cur_pic->cu_array[MAX_DEPTH][x_cu - 1 + (y_cu + cur_block_in_scu) * (encoder->in.width_in_lcu<coded) *a0 = NULL; } } // B0, B1 and B2 availability testing if (y_cu != 0) { - if (x_cu + cur_block_in_scu < encoder->in.width_in_lcu<in.cur_pic->cu_array[MAX_DEPTH][x_cu + cur_block_in_scu + (y_cu - 1) * (encoder->in.width_in_lcu<coded) b0 = NULL; + *b0 = &encoder->in.cur_pic->cu_array[MAX_DEPTH][x_cu + cur_block_in_scu + (y_cu - 1) * (encoder->in.width_in_lcu<coded) *b0 = NULL; } - b1 = &encoder->in.cur_pic->cu_array[MAX_DEPTH][x_cu + cur_block_in_scu - 1 + (y_cu - 1) * (encoder->in.width_in_lcu<coded) b1 = NULL; + *b1 = &encoder->in.cur_pic->cu_array[MAX_DEPTH][x_cu + cur_block_in_scu - 1 + (y_cu - 1) * (encoder->in.width_in_lcu<coded) *b1 = NULL; if (x_cu != 0) { - b2 = &encoder->in.cur_pic->cu_array[MAX_DEPTH][x_cu - 1 + (y_cu - 1) * (encoder->in.width_in_lcu<coded) b2 = NULL; + *b2 = &encoder->in.cur_pic->cu_array[MAX_DEPTH][x_cu - 1 + (y_cu - 1) * (encoder->in.width_in_lcu<coded) *b2 = NULL; } } +} + +/** + * \brief Get MV prediction 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[2][2] 2x motion vector prediction + */ +void inter_get_mv_cand(encoder_control *encoder, int32_t x_cu, int32_t y_cu, int8_t depth, int16_t mv_cand[2][2]) +{ + uint8_t candidates = 0; + + cu_info *b0, *b1, *b2, *a0, *a1; + b0 = b1 = b2 = a0 = a1 = NULL; + inter_get_spatial_merge_candidates(encoder, x_cu, y_cu, depth, &b0, &b1, &b2, &a0, &a1); // Left predictors if (a0 && a0->type == CU_INTER) { diff --git a/src/inter.h b/src/inter.h index 58c35c89..4553f894 100644 --- a/src/inter.h +++ b/src/inter.h @@ -21,6 +21,8 @@ void inter_set_block(picture* pic,uint32_t x_cu, uint32_t y_cu, uint8_t depth, cu_info *cur_cu); void inter_recon(picture *ref,int32_t xpos, int32_t ypos,int32_t width, const int16_t mv[2], picture* dst); +void inter_get_spatial_merge_candidates(encoder_control *encoder, int32_t x_cu, int32_t y_cu, int8_t depth, + cu_info **b0, cu_info **b1,cu_info **b2,cu_info **a0,cu_info **a1); void inter_get_mv_cand(encoder_control *encoder, int32_t x_cu, int32_t y_cu, int8_t depth, int16_t mv_cand[2][2]); #endif