Remove consts and fix wrong types

This commit is contained in:
Joose Sainio 2021-12-16 11:48:59 +02:00
parent 64b2806cc8
commit 951a845f08
3 changed files with 15 additions and 16 deletions

View file

@ -271,8 +271,7 @@ static INLINE uint32_t get_coeff_cabac_cost(
scan_mode, scan_mode,
0); 0);
if(cabac_copy.update) { if(cabac_copy.update) {
memcpy((cabac_data_t *)&state->search_cabac, &cabac_copy, sizeof(cabac_copy));
memcpy(&state->search_cabac, &cabac_copy, sizeof(cabac_copy));
} }
return (bits_left - cabac_copy.bits_left) + ((cabac_copy.num_buffered_bytes - num_buffered_bytes) << 3); return (bits_left - cabac_copy.bits_left) + ((cabac_copy.num_buffered_bytes - num_buffered_bytes) << 3);
} }
@ -1036,7 +1035,7 @@ double kvz_calc_mvd_cost_cabac(const encoder_state_t * state,
inter_merge_cand_t merge_cand[MRG_MAX_NUM_CANDS], inter_merge_cand_t merge_cand[MRG_MAX_NUM_CANDS],
int16_t num_cand, int16_t num_cand,
int32_t ref_idx, int32_t ref_idx,
uint32_t *bitcost) double* bitcost)
{ {
cabac_data_t state_cabac_copy; cabac_data_t state_cabac_copy;
cabac_data_t* cabac; cabac_data_t* cabac;

View file

@ -53,7 +53,7 @@ static double sao_mode_bits_none(const encoder_state_t * const state, sao_info_t
{ {
double mode_bits = 0.0; double mode_bits = 0.0;
cabac_data_t * cabac = (cabac_data_t*)&state->search_cabac; cabac_data_t * cabac = (cabac_data_t*)&state->search_cabac;
const cabac_ctx_t *ctx = NULL; cabac_ctx_t *ctx = NULL;
// FL coded merges. // FL coded merges.
if (sao_left != NULL) { if (sao_left != NULL) {
ctx = &(cabac->ctx.sao_merge_flag_model); ctx = &(cabac->ctx.sao_merge_flag_model);
@ -74,8 +74,8 @@ static double sao_mode_bits_none(const encoder_state_t * const state, sao_info_t
static double sao_mode_bits_merge(const encoder_state_t * const state, static double sao_mode_bits_merge(const encoder_state_t * const state,
int8_t merge_cand) { int8_t merge_cand) {
double mode_bits = 0.0; double mode_bits = 0.0;
cabac_data_t * const cabac = (cabac_data_t*)&state->search_cabac; cabac_data_t * cabac = (cabac_data_t*)&state->search_cabac;
const cabac_ctx_t *ctx = NULL; cabac_ctx_t *ctx = NULL;
// FL coded merges. // FL coded merges.
ctx = &(cabac->ctx.sao_merge_flag_model); ctx = &(cabac->ctx.sao_merge_flag_model);
@ -91,8 +91,8 @@ static double sao_mode_bits_edge(const encoder_state_t * const state,
sao_info_t *sao_top, sao_info_t *sao_left, unsigned buf_cnt) sao_info_t *sao_top, sao_info_t *sao_left, unsigned buf_cnt)
{ {
double mode_bits = 0.0; double mode_bits = 0.0;
cabac_data_t * const cabac = (cabac_data_t*)&state->search_cabac; cabac_data_t * cabac = (cabac_data_t*)&state->search_cabac;
const cabac_ctx_t *ctx = NULL; cabac_ctx_t *ctx = NULL;
// FL coded merges. // FL coded merges.
if (sao_left != NULL) { if (sao_left != NULL) {
ctx = &(cabac->ctx.sao_merge_flag_model); ctx = &(cabac->ctx.sao_merge_flag_model);
@ -132,8 +132,8 @@ static double sao_mode_bits_band(const encoder_state_t * const state,
sao_info_t *sao_top, sao_info_t *sao_left, unsigned buf_cnt) sao_info_t *sao_top, sao_info_t *sao_left, unsigned buf_cnt)
{ {
double mode_bits = 0.0; double mode_bits = 0.0;
cabac_data_t * const cabac = (cabac_data_t*)&state->search_cabac; cabac_data_t * cabac = (cabac_data_t*)&state->search_cabac;
const cabac_ctx_t *ctx = NULL; cabac_ctx_t *ctx = NULL;
// FL coded merges. // FL coded merges.
if (sao_left != NULL) { if (sao_left != NULL) {
ctx = &(cabac->ctx.sao_merge_flag_model); ctx = &(cabac->ctx.sao_merge_flag_model);

View file

@ -269,7 +269,7 @@ static double search_intra_trdepth(encoder_state_t * const state,
// Add bits for split_transform_flag = 1, because transform depth search bypasses // Add bits for split_transform_flag = 1, because transform depth search bypasses
// the normal recursion in the cost functions. // the normal recursion in the cost functions.
if (depth >= 1 && depth <= 3) { if (depth >= 1 && depth <= 3) {
const cabac_ctx_t *ctx = &(state->search_cabac.ctx.trans_subdiv_model[5 - (6 - depth)]); cabac_ctx_t *ctx = &(state->search_cabac.ctx.trans_subdiv_model[5 - (6 - depth)]);
CABAC_FBITS_UPDATE(&state->search_cabac, ctx, 1, tr_split_bit, "tr_split"); CABAC_FBITS_UPDATE(&state->search_cabac, ctx, 1, tr_split_bit, "tr_split");
*bit_cost += tr_split_bit; *bit_cost += tr_split_bit;
} }
@ -283,7 +283,7 @@ static double search_intra_trdepth(encoder_state_t * const state,
if (state->encoder_control->chroma_format != KVZ_CSP_400) { if (state->encoder_control->chroma_format != KVZ_CSP_400) {
const uint8_t tr_depth = depth - pred_cu->depth; const uint8_t tr_depth = depth - pred_cu->depth;
const cabac_ctx_t *ctx = &(state->search_cabac.ctx.qt_cbf_model_chroma[tr_depth]); cabac_ctx_t *ctx = &(state->search_cabac.ctx.qt_cbf_model_chroma[tr_depth]);
if (tr_depth == 0 || cbf_is_set(pred_cu->cbf, depth - 1, COLOR_U)) { if (tr_depth == 0 || cbf_is_set(pred_cu->cbf, depth - 1, COLOR_U)) {
CABAC_FBITS_UPDATE(&state->search_cabac, ctx, cbf_is_set(pred_cu->cbf, depth, COLOR_U), cbf_bits, "cbf_cb"); CABAC_FBITS_UPDATE(&state->search_cabac, ctx, cbf_is_set(pred_cu->cbf, depth, COLOR_U), cbf_bits, "cbf_cb");
} }
@ -647,9 +647,9 @@ static int8_t search_intra_rdo(encoder_state_t * const state,
} }
double kvz_luma_mode_bits(encoder_state_t *state, int8_t luma_mode, const int8_t *intra_preds) double kvz_luma_mode_bits(const encoder_state_t *state, int8_t luma_mode, const int8_t *intra_preds)
{ {
cabac_data_t* cabac = &state->search_cabac; cabac_data_t* cabac = (cabac_data_t *)&state->search_cabac;
double mode_bits = 0; double mode_bits = 0;
bool mode_in_preds = false; bool mode_in_preds = false;
@ -659,7 +659,7 @@ double kvz_luma_mode_bits(encoder_state_t *state, int8_t luma_mode, const int8_t
} }
} }
const cabac_ctx_t *ctx = &(cabac->ctx.intra_mode_model); cabac_ctx_t *ctx = &(cabac->ctx.intra_mode_model);
CABAC_FBITS_UPDATE(cabac, ctx, mode_in_preds, mode_bits, "prev_intra_luma_pred_flag_search"); CABAC_FBITS_UPDATE(cabac, ctx, mode_in_preds, mode_bits, "prev_intra_luma_pred_flag_search");
if (state->search_cabac.update) { if (state->search_cabac.update) {
if(mode_in_preds) { if(mode_in_preds) {
@ -688,7 +688,7 @@ double kvz_luma_mode_bits(encoder_state_t *state, int8_t luma_mode, const int8_t
double kvz_chroma_mode_bits(const encoder_state_t *state, int8_t chroma_mode, int8_t luma_mode) double kvz_chroma_mode_bits(const encoder_state_t *state, int8_t chroma_mode, int8_t luma_mode)
{ {
cabac_data_t* cabac = (cabac_data_t*)&state->search_cabac; cabac_data_t* cabac = (cabac_data_t*)&state->search_cabac;
const cabac_ctx_t *ctx = &(cabac->ctx.chroma_pred_model[0]); cabac_ctx_t *ctx = &(cabac->ctx.chroma_pred_model[0]);
double mode_bits = 0; double mode_bits = 0;
CABAC_FBITS_UPDATE(cabac, ctx, chroma_mode != luma_mode, mode_bits, "intra_chroma_pred_mode"); CABAC_FBITS_UPDATE(cabac, ctx, chroma_mode != luma_mode, mode_bits, "intra_chroma_pred_mode");