mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 19:24:06 +00:00
Split merge candidate derivation to its own function
This commit is contained in:
parent
96a0f03298
commit
52335adda0
54
src/inter.c
54
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
|
||||
____ _______
|
||||
|
@ -249,36 +252,49 @@ 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<<MAX_DEPTH)];
|
||||
if (!a1->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<<MAX_DEPTH)];
|
||||
if (!(*a1)->coded) *a1 = NULL;
|
||||
|
||||
if (y_cu + cur_block_in_scu < encoder->in.height_in_lcu<<MAX_DEPTH) {
|
||||
a0 = &encoder->in.cur_pic->cu_array[MAX_DEPTH][x_cu - 1 + (y_cu + cur_block_in_scu) * (encoder->in.width_in_lcu<<MAX_DEPTH)];
|
||||
if (!a0->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<<MAX_DEPTH)];
|
||||
if (!(*a0)->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<<MAX_DEPTH) {
|
||||
b0 = &encoder->in.cur_pic->cu_array[MAX_DEPTH][x_cu + cur_block_in_scu + (y_cu - 1) * (encoder->in.width_in_lcu<<MAX_DEPTH)];
|
||||
if (!b0->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<<MAX_DEPTH)];
|
||||
if (!(*b0)->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<<MAX_DEPTH)];
|
||||
if (!b1->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<<MAX_DEPTH)];
|
||||
if (!(*b1)->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<<MAX_DEPTH)];
|
||||
if(!b2->coded) b2 = NULL;
|
||||
*b2 = &encoder->in.cur_pic->cu_array[MAX_DEPTH][x_cu - 1 + (y_cu - 1) * (encoder->in.width_in_lcu<<MAX_DEPTH)];
|
||||
if(!(*b2)->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) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue