mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 19:24:06 +00:00
Extract inter search in a single ref frame.
Moves code for doing inter search in a single reference frame from function kvz_search_cu_inter to a new function search_cu_inter_ref.
This commit is contained in:
parent
f9f3d5929e
commit
21e19067fe
|
@ -952,44 +952,20 @@ static unsigned search_frac(const encoder_state_t * const state,
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update lcu to have best modes at this depth.
|
* \brief Perform inter search for a single reference frame.
|
||||||
* \return Cost of best mode.
|
|
||||||
*/
|
*/
|
||||||
int kvz_search_cu_inter(const encoder_state_t * const state, int x, int y, int depth, lcu_t *lcu)
|
static void search_cu_inter_ref(const encoder_state_t * const state,
|
||||||
|
int x, int y, int depth,
|
||||||
|
lcu_t *lcu, cu_info_t *cur_cu,
|
||||||
|
int16_t mv_cand[2][2],
|
||||||
|
inter_merge_cand_t merge_cand[MRG_MAX_NUM_CANDS],
|
||||||
|
int16_t num_cand,
|
||||||
|
unsigned ref_idx,
|
||||||
|
uint32_t(*get_mvd_cost)(vector2d_t *, cabac_data_t*))
|
||||||
{
|
{
|
||||||
|
const int x_cu = x >> 3;
|
||||||
|
const int y_cu = y >> 3;
|
||||||
const videoframe_t * const frame = state->tile->frame;
|
const videoframe_t * const frame = state->tile->frame;
|
||||||
uint32_t ref_idx = 0;
|
|
||||||
int x_local = SUB_SCU(x);
|
|
||||||
int y_local = SUB_SCU(y);
|
|
||||||
int x_cu = x>>3;
|
|
||||||
int y_cu = y>>3;
|
|
||||||
cu_info_t *cur_cu = LCU_GET_CU(lcu, x_local >> 3, y_local >> 3);
|
|
||||||
|
|
||||||
int16_t mv_cand[2][2];
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
uint32_t(*get_mvd_cost)(vector2d_t *, cabac_data_t*) = get_mvd_coding_cost;
|
|
||||||
if (state->encoder_control->cfg->mv_rdo) {
|
|
||||||
get_mvd_cost = kvz_get_mvd_coding_cost_cabac;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int max_lcu_below = -1;
|
|
||||||
|
|
||||||
if (state->encoder_control->owf) {
|
|
||||||
max_lcu_below = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default to candidate 0
|
|
||||||
cur_cu->inter.mv_cand[0] = 0;
|
|
||||||
cur_cu->inter.mv_cand[1] = 0;
|
|
||||||
|
|
||||||
cur_cu->inter.cost = UINT_MAX;
|
|
||||||
|
|
||||||
for (ref_idx = 0; ref_idx < state->global->ref->used_size; ref_idx++) {
|
|
||||||
kvz_picture *ref_image = state->global->ref->images[ref_idx];
|
kvz_picture *ref_image = state->global->ref->images[ref_idx];
|
||||||
uint32_t temp_bitcost = 0;
|
uint32_t temp_bitcost = 0;
|
||||||
uint32_t temp_cost = 0;
|
uint32_t temp_cost = 0;
|
||||||
|
@ -1006,6 +982,7 @@ int kvz_search_cu_inter(const encoder_state_t * const state, int x, int y, int d
|
||||||
kvz_inter_get_mv_cand(state, x, y, depth, mv_cand, cur_cu, lcu, ref_list);
|
kvz_inter_get_mv_cand(state, x, y, depth, mv_cand, cur_cu, lcu, ref_list);
|
||||||
cur_cu->inter.mv_ref[ref_list] = temp_ref_idx;
|
cur_cu->inter.mv_ref[ref_list] = temp_ref_idx;
|
||||||
|
|
||||||
|
|
||||||
vector2d_t mv = { 0, 0 };
|
vector2d_t mv = { 0, 0 };
|
||||||
{
|
{
|
||||||
// Take starting point for MV search from previous frame.
|
// Take starting point for MV search from previous frame.
|
||||||
|
@ -1092,6 +1069,52 @@ int kvz_search_cu_inter(const encoder_state_t * const state, int x, int y, int d
|
||||||
cur_cu->inter.bitcost = temp_bitcost + cur_cu->inter.mv_dir - 1 + cur_cu->inter.mv_ref_coded[ref_list];
|
cur_cu->inter.bitcost = temp_bitcost + cur_cu->inter.mv_dir - 1 + cur_cu->inter.mv_ref_coded[ref_list];
|
||||||
cur_cu->inter.mv_cand[ref_list] = cu_mv_cand;
|
cur_cu->inter.mv_cand[ref_list] = cu_mv_cand;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update lcu to have best modes at this depth.
|
||||||
|
* \return Cost of best mode.
|
||||||
|
*/
|
||||||
|
int kvz_search_cu_inter(const encoder_state_t * const state, int x, int y, int depth, lcu_t *lcu)
|
||||||
|
{
|
||||||
|
const videoframe_t * const frame = state->tile->frame;
|
||||||
|
uint32_t ref_idx = 0;
|
||||||
|
int x_local = SUB_SCU(x);
|
||||||
|
int y_local = SUB_SCU(y);
|
||||||
|
cu_info_t *cur_cu = LCU_GET_CU(lcu, x_local >> 3, y_local >> 3);
|
||||||
|
|
||||||
|
int16_t mv_cand[2][2];
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
uint32_t(*get_mvd_cost)(vector2d_t *, cabac_data_t*) = get_mvd_coding_cost;
|
||||||
|
if (state->encoder_control->cfg->mv_rdo) {
|
||||||
|
get_mvd_cost = kvz_get_mvd_coding_cost_cabac;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int max_lcu_below = -1;
|
||||||
|
|
||||||
|
if (state->encoder_control->owf) {
|
||||||
|
max_lcu_below = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default to candidate 0
|
||||||
|
cur_cu->inter.mv_cand[0] = 0;
|
||||||
|
cur_cu->inter.mv_cand[1] = 0;
|
||||||
|
|
||||||
|
cur_cu->inter.cost = UINT_MAX;
|
||||||
|
|
||||||
|
for (ref_idx = 0; ref_idx < state->global->ref->used_size; ref_idx++) {
|
||||||
|
search_cu_inter_ref(state,
|
||||||
|
x, y, depth,
|
||||||
|
lcu, cur_cu,
|
||||||
|
mv_cand, merge_cand, num_cand,
|
||||||
|
ref_idx,
|
||||||
|
get_mvd_cost);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search bi-pred positions
|
// Search bi-pred positions
|
||||||
|
|
Loading…
Reference in a new issue