Fixed bipred mv candidate selection

This commit is contained in:
Marko Viitanen 2015-04-23 12:18:05 +03:00
parent 9951810910
commit 3c694a8f6e
3 changed files with 9 additions and 8 deletions

View file

@ -74,7 +74,7 @@ typedef struct
uint32_t bitcost; uint32_t bitcost;
int16_t mv[2][2]; // \brief Motion vectors for L0 and L1 int16_t mv[2][2]; // \brief Motion vectors for L0 and L1
int16_t mvd[2][2]; // \brief Motion vector differences for L0 and L1 int16_t mvd[2][2]; // \brief Motion vector differences for L0 and L1
uint8_t mv_cand; // \brief selected MV candidate uint8_t mv_cand[2]; // \brief selected MV candidate
uint8_t mv_ref[2]; // \brief Index of the encoder_control.ref array. uint8_t mv_ref[2]; // \brief Index of the encoder_control.ref array.
uint8_t mv_ref_coded[2]; // \brief Coded and corrected index of ref picture uint8_t mv_ref_coded[2]; // \brief Coded and corrected index of ref picture
uint8_t mv_dir; // \brief Probably describes if mv_ref is L0, L1 or both (bi-pred) uint8_t mv_dir; // \brief Probably describes if mv_ref is L0, L1 or both (bi-pred)

View file

@ -1428,7 +1428,7 @@ void encode_coding_tree(encoder_state_t * const state,
} }
// Signal which candidate MV to use // Signal which candidate MV to use
cabac_write_unary_max_symbol(cabac, cabac->ctx.mvp_idx_model, cur_cu->inter.mv_cand, 1, cabac_write_unary_max_symbol(cabac, cabac->ctx.mvp_idx_model, cur_cu->inter.mv_cand[ref_list_idx], 1,
AMVP_MAX_NUM_CANDS - 1); AMVP_MAX_NUM_CANDS - 1);
} }
} // for ref_list } // for ref_list

View file

@ -988,8 +988,10 @@ static int search_cu_inter(const encoder_state_t * const state, int x, int y, in
// Get list of candidates // Get list of candidates
int16_t num_cand = inter_get_merge_cand(state, x, y, depth, merge_cand, lcu); int16_t num_cand = inter_get_merge_cand(state, x, y, depth, merge_cand, lcu);
// Select better candidate
cur_cu->inter.mv_cand = 0; // Default to candidate 0 // Default to candidate 0
cur_cu->inter.mv_cand[0] = 0;
cur_cu->inter.mv_cand[1] = 0;
cur_cu->inter.cost = UINT_MAX; cur_cu->inter.cost = UINT_MAX;
@ -1094,7 +1096,7 @@ static int search_cu_inter(const encoder_state_t * const state, int x, int y, in
cur_cu->inter.mvd[ref_list][1] = (int16_t)mvd.y; cur_cu->inter.mvd[ref_list][1] = (int16_t)mvd.y;
cur_cu->inter.cost = temp_cost; cur_cu->inter.cost = temp_cost;
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 = cu_mv_cand; cur_cu->inter.mv_cand[ref_list] = cu_mv_cand;
} }
} }
@ -1176,16 +1178,15 @@ static int search_cu_inter(const encoder_state_t * const state, int x, int y, in
// Select candidate 1 if it has lower cost // Select candidate 1 if it has lower cost
if (cand2_cost < cand1_cost) { if (cand2_cost < cand1_cost) {
//cu_mv_cand = 1; cu_mv_cand = 1;
cu_mv_cand = 0;
} }
} }
cur_cu->inter.mvd[reflist][0] = cur_cu->inter.mv[reflist][0] - mv_cand[cu_mv_cand][0]; cur_cu->inter.mvd[reflist][0] = cur_cu->inter.mv[reflist][0] - mv_cand[cu_mv_cand][0];
cur_cu->inter.mvd[reflist][1] = cur_cu->inter.mv[reflist][1] - mv_cand[cu_mv_cand][1]; cur_cu->inter.mvd[reflist][1] = cur_cu->inter.mv[reflist][1] - mv_cand[cu_mv_cand][1];
cur_cu->inter.mv_cand[reflist] = cu_mv_cand;
} }
cur_cu->inter.cost = cost; cur_cu->inter.cost = cost;
cur_cu->inter.bitcost = bitcost[0] + bitcost[1] + cur_cu->inter.mv_dir - 1 + cur_cu->inter.mv_ref_coded[0] + cur_cu->inter.mv_ref_coded[1]; cur_cu->inter.bitcost = bitcost[0] + bitcost[1] + cur_cu->inter.mv_dir - 1 + cur_cu->inter.mv_ref_coded[0] + cur_cu->inter.mv_ref_coded[1];
cur_cu->inter.mv_cand = cu_mv_cand;
} }
} }
} }