mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 19:24:06 +00:00
Merge branch 'early-skip-fixes'
This commit is contained in:
commit
ab872c0432
11
src/intra.c
11
src/intra.c
|
@ -665,7 +665,18 @@ void kvz_intra_recon_cu(
|
|||
cur_cu = LCU_GET_CU_AT_PX(lcu, lcu_px.x, lcu_px.y);
|
||||
}
|
||||
|
||||
// Reset CBFs because CBFs might have been set
|
||||
// for depth earlier
|
||||
if (mode_luma >= 0) {
|
||||
cbf_clear(&cur_cu->cbf, depth, COLOR_Y);
|
||||
}
|
||||
if (mode_chroma >= 0) {
|
||||
cbf_clear(&cur_cu->cbf, depth, COLOR_U);
|
||||
cbf_clear(&cur_cu->cbf, depth, COLOR_V);
|
||||
}
|
||||
|
||||
if (depth == 0 || cur_cu->tr_depth > depth) {
|
||||
|
||||
const int offset = width / 2;
|
||||
const int32_t x2 = x + offset;
|
||||
const int32_t y2 = y + offset;
|
||||
|
|
|
@ -1441,6 +1441,46 @@ static void search_pu_inter_bipred(inter_search_info_t *info,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check if an identical merge candidate exists in a list
|
||||
*
|
||||
* \param all_cand Full list of available merge candidates
|
||||
* \param cand_to_add Merge candidate to be checked for duplicates
|
||||
* \param added_idx_list List of indices of unique merge candidates
|
||||
* \param list_size Size of the list
|
||||
*
|
||||
* \return Does an identical candidate exist in list
|
||||
*/
|
||||
static bool merge_candidate_in_list(inter_merge_cand_t * all_cands,
|
||||
inter_merge_cand_t * cand_to_add,
|
||||
int8_t * added_idx_list,
|
||||
int list_size)
|
||||
{
|
||||
bool found = false;
|
||||
for (int i = 0; i < list_size && !found; ++i) {
|
||||
inter_merge_cand_t * list_cand = &all_cands[added_idx_list[i]];
|
||||
|
||||
// Check only the specified dir(s) in case
|
||||
// something unused is left uninitialized
|
||||
found = cand_to_add->dir == list_cand->dir;
|
||||
if (cand_to_add->dir & 1) {
|
||||
found = found &&
|
||||
cand_to_add->ref[0] == list_cand->ref[0] &&
|
||||
cand_to_add->mv[0][0] == list_cand->mv[0][0] &&
|
||||
cand_to_add->mv[0][1] == list_cand->mv[0][1];
|
||||
}
|
||||
|
||||
if (cand_to_add->dir & 2) {
|
||||
found = found &&
|
||||
cand_to_add->ref[1] == list_cand->ref[1] &&
|
||||
cand_to_add->mv[1][0] == list_cand->mv[1][0] &&
|
||||
cand_to_add->mv[1][1] == list_cand->mv[1][1];
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Update PU to have best modes at this depth.
|
||||
*
|
||||
|
@ -1514,36 +1554,47 @@ static void search_pu_inter(encoder_state_t * const state,
|
|||
if (cfg->early_skip && cur_cu->part_size == SIZE_2Nx2N) {
|
||||
|
||||
int num_rdo_cands = 0;
|
||||
int8_t mrg_cands[MRG_MAX_NUM_CANDS] = { 0, 1, 2, 3, 4 };
|
||||
double mrg_costs[MRG_MAX_NUM_CANDS] = { MAX_DOUBLE };
|
||||
int8_t mrg_cands[MRG_MAX_NUM_CANDS];
|
||||
double mrg_costs[MRG_MAX_NUM_CANDS];
|
||||
for (int i = 0; i < MRG_MAX_NUM_CANDS; ++i) {
|
||||
mrg_cands[i] = -1;
|
||||
mrg_costs[i] = MAX_DOUBLE;
|
||||
}
|
||||
|
||||
// Check motion vector constraints and perform rough search
|
||||
for (int merge_idx = 0; merge_idx < info.num_merge_cand; ++merge_idx) {
|
||||
|
||||
cur_cu->inter.mv_dir = info.merge_cand[merge_idx].dir;
|
||||
cur_cu->inter.mv_ref[0] = info.merge_cand[merge_idx].ref[0];
|
||||
cur_cu->inter.mv_ref[1] = info.merge_cand[merge_idx].ref[1];
|
||||
cur_cu->inter.mv[0][0] = info.merge_cand[merge_idx].mv[0][0];
|
||||
cur_cu->inter.mv[0][1] = info.merge_cand[merge_idx].mv[0][1];
|
||||
cur_cu->inter.mv[1][0] = info.merge_cand[merge_idx].mv[1][0];
|
||||
cur_cu->inter.mv[1][1] = info.merge_cand[merge_idx].mv[1][1];
|
||||
inter_merge_cand_t *cur_cand = &info.merge_cand[merge_idx];
|
||||
cur_cu->inter.mv_dir = cur_cand->dir;
|
||||
cur_cu->inter.mv_ref[0] = cur_cand->ref[0];
|
||||
cur_cu->inter.mv_ref[1] = cur_cand->ref[1];
|
||||
cur_cu->inter.mv[0][0] = cur_cand->mv[0][0];
|
||||
cur_cu->inter.mv[0][1] = cur_cand->mv[0][1];
|
||||
cur_cu->inter.mv[1][0] = cur_cand->mv[1][0];
|
||||
cur_cu->inter.mv[1][1] = cur_cand->mv[1][1];
|
||||
|
||||
bool is_duplicate = merge_candidate_in_list(info.merge_cand, cur_cand,
|
||||
mrg_cands,
|
||||
num_rdo_cands);
|
||||
|
||||
// Don't try merge candidates that don't satisfy mv constraints.
|
||||
// Don't add duplicates to list
|
||||
if (!fracmv_within_tile(&info, cur_cu->inter.mv[0][0], cur_cu->inter.mv[0][1]) ||
|
||||
!fracmv_within_tile(&info, cur_cu->inter.mv[1][0], cur_cu->inter.mv[1][1]))
|
||||
!fracmv_within_tile(&info, cur_cu->inter.mv[1][0], cur_cu->inter.mv[1][1]) ||
|
||||
is_duplicate)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cfg->rdo >= 2) {
|
||||
|
||||
kvz_lcu_fill_trdepth(lcu, x, y, depth, depth);
|
||||
kvz_inter_recon_cu(state, lcu, x, y, width);
|
||||
mrg_costs[merge_idx] = kvz_satd_any_size(width, height,
|
||||
lcu->rec.y + y_local * LCU_WIDTH + x_local, LCU_WIDTH,
|
||||
lcu->ref.y + y_local * LCU_WIDTH + x_local, LCU_WIDTH);
|
||||
}
|
||||
|
||||
mrg_cands[num_rdo_cands] = merge_idx;
|
||||
num_rdo_cands++;
|
||||
}
|
||||
|
||||
|
|
|
@ -445,7 +445,18 @@ void kvz_quantize_lcu_residual(encoder_state_t * const state,
|
|||
width == 32 ||
|
||||
width == 64);
|
||||
|
||||
// Reset CBFs because CBFs might have been set
|
||||
// for depth earlier
|
||||
if (luma) {
|
||||
cbf_clear(&cur_pu->cbf, depth, COLOR_Y);
|
||||
}
|
||||
if (chroma) {
|
||||
cbf_clear(&cur_pu->cbf, depth, COLOR_U);
|
||||
cbf_clear(&cur_pu->cbf, depth, COLOR_V);
|
||||
}
|
||||
|
||||
if (depth == 0 || cur_pu->tr_depth > depth) {
|
||||
|
||||
// Split transform and increase depth
|
||||
const int offset = width / 2;
|
||||
const int32_t x2 = x + offset;
|
||||
|
|
Loading…
Reference in a new issue