mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 19:24:06 +00:00
Make mvd_coding_cost functions take const cabac
This commit is contained in:
parent
11defe1595
commit
d31be8eb27
10
src/rdo.c
10
src/rdo.c
|
@ -840,7 +840,8 @@ void kvz_rdoq(encoder_state_t * const state, coeff_t *coef, coeff_t *dest_coeff
|
|||
* \returns int
|
||||
* Calculates cost of actual motion vectors using CABAC coding
|
||||
*/
|
||||
uint32_t kvz_get_mvd_coding_cost_cabac(encoder_state_t * const state, vector2d_t *mvd, cabac_data_t* cabac) {
|
||||
uint32_t kvz_get_mvd_coding_cost_cabac(encoder_state_t * const state, vector2d_t *mvd, const cabac_data_t* real_cabac)
|
||||
{
|
||||
uint32_t bitcost = 0;
|
||||
const int32_t mvd_hor = mvd->x;
|
||||
const int32_t mvd_ver = mvd->y;
|
||||
|
@ -850,7 +851,8 @@ uint32_t kvz_get_mvd_coding_cost_cabac(encoder_state_t * const state, vector2d_t
|
|||
const uint32_t mvd_ver_abs = abs(mvd_ver);
|
||||
|
||||
cabac_data_t cabac_copy;
|
||||
memcpy(&cabac_copy, cabac, sizeof(cabac_data_t));
|
||||
memcpy(&cabac_copy, real_cabac, sizeof(cabac_data_t));
|
||||
cabac_data_t *cabac = &cabac_copy;
|
||||
cabac->only_count = 1;
|
||||
|
||||
cabac->cur_ctx = &(cabac->ctx.cu_mvd_model[0]);
|
||||
|
@ -875,9 +877,7 @@ uint32_t kvz_get_mvd_coding_cost_cabac(encoder_state_t * const state, vector2d_t
|
|||
}
|
||||
CABAC_BIN_EP(cabac, (mvd_ver > 0) ? 0 : 1, "mvd_sign_flag_ver");
|
||||
}
|
||||
bitcost = ((23 - cabac->bits_left) + (cabac->num_buffered_bytes << 3)) - ((23 - cabac_copy.bits_left) + (cabac_copy.num_buffered_bytes << 3));
|
||||
|
||||
memcpy(cabac, &cabac_copy, sizeof(cabac_data_t));
|
||||
bitcost = ((23 - cabac->bits_left) + (cabac->num_buffered_bytes << 3)) - ((23 - real_cabac->bits_left) + (real_cabac->num_buffered_bytes << 3));
|
||||
|
||||
return bitcost;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ uint32_t kvz_get_coded_level(encoder_state_t * state, double* coded_cost, double
|
|||
|
||||
kvz_mvd_cost_func kvz_calc_mvd_cost_cabac;
|
||||
|
||||
uint32_t kvz_get_mvd_coding_cost_cabac(encoder_state_t * const state, vector2d_t *mvd, cabac_data_t* cabac);
|
||||
uint32_t kvz_get_mvd_coding_cost_cabac(encoder_state_t * const state, vector2d_t *mvd, const cabac_data_t* cabac);
|
||||
|
||||
uint8_t kvz_skip_unnecessary_rdoq(encoder_state_t * const state, coeff_t *coef, coeff_t *dest_coeff, int32_t width,
|
||||
int32_t height, int8_t type, int8_t scan_mode, int8_t block_type);
|
||||
|
|
|
@ -175,7 +175,7 @@ static unsigned select_starting_point(int16_t num_cand, inter_merge_cand_t *merg
|
|||
}
|
||||
|
||||
|
||||
static uint32_t get_mvd_coding_cost(encoder_state_t * const state, vector2d_t *mvd, cabac_data_t* cabac)
|
||||
static uint32_t get_mvd_coding_cost(encoder_state_t * const state, vector2d_t *mvd, const cabac_data_t* cabac)
|
||||
{
|
||||
uint32_t bitcost = 0;
|
||||
const int32_t mvd_hor = mvd->x;
|
||||
|
@ -1223,7 +1223,7 @@ static void search_pu_inter_ref(encoder_state_t * const state,
|
|||
inter_merge_cand_t merge_cand[MRG_MAX_NUM_CANDS],
|
||||
int16_t num_cand,
|
||||
unsigned ref_idx,
|
||||
uint32_t(*get_mvd_cost)(encoder_state_t * const, vector2d_t *, cabac_data_t*),
|
||||
uint32_t(*get_mvd_cost)(encoder_state_t * const, vector2d_t *, const cabac_data_t*),
|
||||
double *inter_cost,
|
||||
uint32_t *inter_bitcost)
|
||||
{
|
||||
|
@ -1363,11 +1363,11 @@ static void search_pu_inter_ref(encoder_state_t * const state,
|
|||
|
||||
mvd_temp1.x = mv.x - mv_cand[0][0];
|
||||
mvd_temp1.y = mv.y - mv_cand[0][1];
|
||||
cand1_cost = get_mvd_cost(state, &mvd_temp1, (cabac_data_t*)&state->cabac);
|
||||
cand1_cost = get_mvd_cost(state, &mvd_temp1, &state->cabac);
|
||||
|
||||
mvd_temp2.x = mv.x - mv_cand[1][0];
|
||||
mvd_temp2.y = mv.y - mv_cand[1][1];
|
||||
cand2_cost = get_mvd_cost(state, &mvd_temp2, (cabac_data_t*)&state->cabac);
|
||||
cand2_cost = get_mvd_cost(state, &mvd_temp2, &state->cabac);
|
||||
|
||||
// Select candidate 1 if it has lower cost
|
||||
if (cand2_cost < cand1_cost) {
|
||||
|
@ -1448,7 +1448,7 @@ static void search_pu_inter(encoder_state_t * const state,
|
|||
merge_cand,
|
||||
lcu);
|
||||
|
||||
uint32_t(*get_mvd_cost)(encoder_state_t * const state, vector2d_t *, cabac_data_t*) = get_mvd_coding_cost;
|
||||
uint32_t(*get_mvd_cost)(encoder_state_t * const state, vector2d_t *, const cabac_data_t*) = get_mvd_coding_cost;
|
||||
if (state->encoder_control->cfg->mv_rdo) {
|
||||
get_mvd_cost = kvz_get_mvd_coding_cost_cabac;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue