Fixed using wrong POC in add_temporal_candidate

This commit is contained in:
Miika Metsoila 2017-08-09 11:33:28 +03:00
parent 25e0a954c7
commit 0dd069f8af
4 changed files with 26 additions and 22 deletions

View file

@ -143,6 +143,7 @@ typedef struct
#endif
} intra;
struct {
uint32_t poc[2];
int16_t mv[2][2]; // \brief Motion vectors for L0 and L1
uint8_t mv_ref[2]; // \brief Index of the L0 and L1 array.
uint8_t mv_cand0 : 3; // \brief selected MV candidate

View file

@ -824,7 +824,7 @@ void kvz_encoder_create_ref_lists(const encoder_state_t *const state)
}
}
// Fill the rest of ref_list_poc_out array with -1s.
// Fill the rest with -1s.
for (; j < 16; j++) {
state->frame->ref_LX[0][j] = (uint8_t) -1;
state->frame->ref_LX[1][j] = (uint8_t) -1;

View file

@ -502,6 +502,7 @@ static void inter_clear_cu_unused(cu_info_t* cu)
cu->inter.mv[i][0] = 0;
cu->inter.mv[i][1] = 0;
cu->inter.mv_ref[i] = 255;
cu->inter.poc[i] = (uint32_t) -1;
}
}
@ -956,8 +957,6 @@ static INLINE void apply_mv_scaling(const encoder_state_t *state,
* \param colocated colocated CU
* \param reflist either 0 (for L0) or 1 (for L1)
* \param[out] mv_out Returns the motion vector
* \param[out] ref_out Returns the index of the picture referenced by the
* colocated CU. May be NULL.
*
* \return Whether a temporal candidate was added or not.
*/
@ -965,8 +964,7 @@ static bool add_temporal_candidate(const encoder_state_t *state,
uint8_t current_ref,
const cu_info_t *colocated,
int32_t reflist,
int16_t mv_out[2],
uint8_t *ref_out)
int16_t mv_out[2])
{
if (!colocated) return false;
@ -981,18 +979,13 @@ static bool add_temporal_candidate(const encoder_state_t *state,
int cand_list = colocated->inter.mv_dir & (1 << reflist) ? reflist : !reflist;
// The reference id the colocated block is using
uint32_t colocated_ref_mv_ref = state->frame->ref_LX[cand_list][colocated->inter.mv_ref[cand_list]];
if (ref_out) *ref_out = 0; //colocated_ref;
mv_out[0] = colocated->inter.mv[cand_list][0];
mv_out[1] = colocated->inter.mv[cand_list][1];
apply_mv_scaling_pocs(
state->frame->poc,
state->frame->ref->pocs[current_ref],
state->frame->ref->pocs[colocated_ref],
state->frame->ref->images[colocated_ref]->ref_pocs[colocated_ref_mv_ref],
colocated->inter.poc[cand_list],
mv_out
);
return true;
@ -1112,8 +1105,7 @@ static void get_mv_cand_from_candidates(const encoder_state_t * const state,
state->frame->ref_LX[reflist][cur_cu->inter.mv_ref[reflist]],
(h != NULL) ? h : c3,
reflist,
mv_cand[candidates],
NULL)) {
mv_cand[candidates])) {
candidates++;
}
@ -1298,8 +1290,8 @@ uint8_t kvz_inter_get_merge_cand(const encoder_state_t * const state,
ref_idx,
temporal_cand,
reflist,
mv_cand[candidates].mv[reflist],
&mv_cand[candidates].ref[reflist])) {
mv_cand[candidates].mv[reflist])) {
mv_cand[candidates].ref[reflist] = 0;
mv_cand[candidates].dir |= (1 << reflist);
}
}

View file

@ -1271,12 +1271,19 @@ static void search_pu_inter_ref(encoder_state_t * const state,
// ref_idx has to be found in either L0 or L1
assert(LX_idx < LX_IDX_MAX_PLUS_1);
// store temp values to be stored back later
int8_t temp_ref_idx = cur_cu->inter.mv_ref[ref_list];
int8_t temp_poc = cur_cu->inter.poc[ref_list];
// Get MV candidates
cur_cu->inter.mv_ref[ref_list] = LX_idx;
kvz_inter_get_mv_cand(state, x, y, width, height, mv_cand, cur_cu, lcu, ref_list);
cur_cu->inter.mv_ref[ref_list] = temp_ref_idx;
cur_cu->inter.poc[ref_list] = state->frame->ref->pocs[ref_idx];
kvz_inter_get_mv_cand(state, x, y, width, height, mv_cand, cur_cu, lcu, ref_list);
// store old values back
cur_cu->inter.mv_ref[ref_list] = temp_ref_idx;
cur_cu->inter.poc[ref_list] = temp_poc;
vector2d_t mv = { 0, 0 };
{
@ -1412,11 +1419,12 @@ static void search_pu_inter_ref(encoder_state_t * const state,
cur_cu->inter.mv_dir = ref_list+1;
uint8_t mv_ref_coded = LX_idx;
cur_cu->merged = merged;
cur_cu->merge_idx = merge_idx;
cur_cu->inter.mv_ref[ref_list] = LX_idx;
cur_cu->inter.mv[ref_list][0] = (int16_t)mv.x;
cur_cu->inter.mv[ref_list][1] = (int16_t)mv.y;
cur_cu->merged = merged;
cur_cu->merge_idx = merge_idx;
cur_cu->inter.mv_ref[ref_list] = LX_idx;
cur_cu->inter.poc[ref_list] = state->frame->ref->pocs[ref_idx];
cur_cu->inter.mv[ref_list][0] = (int16_t)mv.x;
cur_cu->inter.mv[ref_list][1] = (int16_t)mv.y;
CU_SET_MV_CAND(cur_cu, ref_list, cu_mv_cand);
*inter_cost = temp_cost;
@ -1608,6 +1616,9 @@ static void search_pu_inter(encoder_state_t * const state,
cur_cu->inter.mv_ref[0] = merge_cand[i].ref[0];
cur_cu->inter.mv_ref[1] = merge_cand[j].ref[1];
cur_cu->inter.poc[0] = state->frame->ref->pocs[mv_ref_coded[0]];
cur_cu->inter.poc[1] = state->frame->ref->pocs[mv_ref_coded[1]];
cur_cu->inter.mv[0][0] = merge_cand[i].mv[0][0];
cur_cu->inter.mv[0][1] = merge_cand[i].mv[0][1];
cur_cu->inter.mv[1][0] = merge_cand[j].mv[1][0];