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:
Arttu Ylä-Outinen 2015-10-07 13:44:19 +03:00
parent f9f3d5929e
commit 21e19067fe

View file

@ -952,44 +952,20 @@ static unsigned search_frac(const encoder_state_t * const state,
/**
* Update lcu to have best modes at this depth.
* \return Cost of best mode.
* \brief Perform inter search for a single reference frame.
*/
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;
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];
uint32_t temp_bitcost = 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);
cur_cu->inter.mv_ref[ref_list] = temp_ref_idx;
vector2d_t mv = { 0, 0 };
{
// Take starting point for MV search from previous frame.
@ -1094,6 +1071,52 @@ int kvz_search_cu_inter(const encoder_state_t * const state, int x, int y, int d
}
}
/**
* 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
if (state->global->slicetype == KVZ_SLICE_B && state->encoder_control->cfg->bipred) {
lcu_t *templcu = MALLOC(lcu_t, 1);