mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 19:24:06 +00:00
Put inter search parameters in a single struct
Adds struct inter_search_info_t for holding the parameters that are used by most function related to inter search. Passing the parameters in a single struct greatly reduces the number of parameters for many functions.
This commit is contained in:
parent
d20c9ab30f
commit
328f051d7f
|
@ -532,7 +532,10 @@ void kvz_cabac_write_unary_max_symbol_ep(cabac_data_t * const data, unsigned int
|
|||
/**
|
||||
* \brief
|
||||
*/
|
||||
void kvz_cabac_write_ep_ex_golomb(struct encoder_state_t * const state, cabac_data_t * const data, uint32_t symbol, uint32_t count)
|
||||
void kvz_cabac_write_ep_ex_golomb(encoder_state_t * const state,
|
||||
cabac_data_t * const data,
|
||||
uint32_t symbol,
|
||||
uint32_t count)
|
||||
{
|
||||
uint32_t bins = 0;
|
||||
int32_t num_bins = 0;
|
||||
|
@ -548,7 +551,7 @@ void kvz_cabac_write_ep_ex_golomb(struct encoder_state_t * const state, cabac_da
|
|||
|
||||
bins = (bins << count) | symbol;
|
||||
num_bins += count;
|
||||
if (!state->cabac.only_count) {
|
||||
if (!data->only_count) {
|
||||
if (state->encoder_control->cfg.crypto_features & KVZ_CRYPTO_MVs) {
|
||||
uint32_t key, mask;
|
||||
key = kvz_crypto_get_key(state->crypto_hdl, num_bins>>1);
|
||||
|
|
32
src/rdo.c
32
src/rdo.c
|
@ -883,7 +883,9 @@ 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, const cabac_data_t* real_cabac)
|
||||
uint32_t kvz_get_mvd_coding_cost_cabac(const encoder_state_t *state,
|
||||
vector2d_t *mvd,
|
||||
const cabac_data_t* real_cabac)
|
||||
{
|
||||
uint32_t bitcost = 0;
|
||||
const int32_t mvd_hor = mvd->x;
|
||||
|
@ -910,13 +912,15 @@ uint32_t kvz_get_mvd_coding_cost_cabac(encoder_state_t * const state, vector2d_t
|
|||
}
|
||||
if (hor_abs_gr0) {
|
||||
if (mvd_hor_abs > 1) {
|
||||
kvz_cabac_write_ep_ex_golomb(state, cabac, mvd_hor_abs - 2, 1);
|
||||
// It is safe to drop const here because cabac->only_count is set.
|
||||
kvz_cabac_write_ep_ex_golomb((encoder_state_t*)state, cabac, mvd_hor_abs - 2, 1);
|
||||
}
|
||||
CABAC_BIN_EP(cabac, (mvd_hor > 0) ? 0 : 1, "mvd_sign_flag_hor");
|
||||
}
|
||||
if (ver_abs_gr0) {
|
||||
if (mvd_ver_abs > 1) {
|
||||
kvz_cabac_write_ep_ex_golomb(state, cabac, mvd_ver_abs - 2, 1);
|
||||
// It is safe to drop const here because cabac->only_count is set.
|
||||
kvz_cabac_write_ep_ex_golomb((encoder_state_t*)state, cabac, mvd_ver_abs - 2, 1);
|
||||
}
|
||||
CABAC_BIN_EP(cabac, (mvd_ver > 0) ? 0 : 1, "mvd_sign_flag_ver");
|
||||
}
|
||||
|
@ -929,10 +933,16 @@ uint32_t kvz_get_mvd_coding_cost_cabac(encoder_state_t * const state, vector2d_t
|
|||
* \returns int
|
||||
* Calculates Motion Vector cost and related costs using CABAC coding
|
||||
*/
|
||||
int kvz_calc_mvd_cost_cabac(encoder_state_t * const state, int x, int y, int mv_shift,
|
||||
int16_t mv_cand[2][2], inter_merge_cand_t merge_cand[MRG_MAX_NUM_CANDS],
|
||||
int16_t num_cand, int32_t ref_idx, uint32_t *bitcost) {
|
||||
|
||||
uint32_t kvz_calc_mvd_cost_cabac(const encoder_state_t * state,
|
||||
int x,
|
||||
int y,
|
||||
int mv_shift,
|
||||
int16_t mv_cand[2][2],
|
||||
inter_merge_cand_t merge_cand[MRG_MAX_NUM_CANDS],
|
||||
int16_t num_cand,
|
||||
int32_t ref_idx,
|
||||
uint32_t *bitcost)
|
||||
{
|
||||
cabac_data_t state_cabac_copy;
|
||||
cabac_data_t* cabac;
|
||||
uint32_t merge_idx;
|
||||
|
@ -1068,7 +1078,8 @@ int kvz_calc_mvd_cost_cabac(encoder_state_t * const state, int x, int y, int mv_
|
|||
|
||||
if (hor_abs_gr0) {
|
||||
if (mvd_hor_abs > 1) {
|
||||
kvz_cabac_write_ep_ex_golomb(state, cabac, mvd_hor_abs - 2, 1);
|
||||
// It is safe to drop const because cabac->only_count is set.
|
||||
kvz_cabac_write_ep_ex_golomb((encoder_state_t*)state, cabac, mvd_hor_abs - 2, 1);
|
||||
}
|
||||
|
||||
CABAC_BIN_EP(cabac, (mvd_hor > 0) ? 0 : 1, "mvd_sign_flag_hor");
|
||||
|
@ -1076,7 +1087,8 @@ int kvz_calc_mvd_cost_cabac(encoder_state_t * const state, int x, int y, int mv_
|
|||
|
||||
if (ver_abs_gr0) {
|
||||
if (mvd_ver_abs > 1) {
|
||||
kvz_cabac_write_ep_ex_golomb(state, cabac, mvd_ver_abs - 2, 1);
|
||||
// It is safe to drop const because cabac->only_count is set.
|
||||
kvz_cabac_write_ep_ex_golomb((encoder_state_t*)state, cabac, mvd_ver_abs - 2, 1);
|
||||
}
|
||||
|
||||
CABAC_BIN_EP(cabac, (mvd_ver > 0) ? 0 : 1, "mvd_sign_flag_ver");
|
||||
|
@ -1094,5 +1106,5 @@ int kvz_calc_mvd_cost_cabac(encoder_state_t * const state, int x, int y, int mv_
|
|||
*bitcost = (23 - state_cabac_copy.bits_left) + (state_cabac_copy.num_buffered_bytes << 3);
|
||||
|
||||
// Store bitcost before restoring cabac
|
||||
return *bitcost * (int32_t)(state->lambda_sqrt + 0.5);
|
||||
return *bitcost * (uint32_t)(state->lambda_sqrt + 0.5);
|
||||
}
|
||||
|
|
|
@ -56,7 +56,9 @@ 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, const cabac_data_t* cabac);
|
||||
uint32_t kvz_get_mvd_coding_cost_cabac(const encoder_state_t *state,
|
||||
vector2d_t *mvd,
|
||||
const cabac_data_t* cabac);
|
||||
|
||||
// Number of fixed point fractional bits used in the fractional bit table.
|
||||
#define CTX_FRAC_BITS 15
|
||||
|
|
1035
src/search_inter.c
1035
src/search_inter.c
File diff suppressed because it is too large
Load diff
|
@ -50,14 +50,14 @@ enum hpel_position {
|
|||
HPEL_POS_DIA = 2
|
||||
};
|
||||
|
||||
typedef int kvz_mvd_cost_func(encoder_state_t * const state,
|
||||
int x, int y,
|
||||
int mv_shift,
|
||||
int16_t mv_cand[2][2],
|
||||
inter_merge_cand_t merge_cand[MRG_MAX_NUM_CANDS],
|
||||
int16_t num_cand,
|
||||
int32_t ref_idx,
|
||||
uint32_t *bitcost);
|
||||
typedef uint32_t kvz_mvd_cost_func(const encoder_state_t *state,
|
||||
int x, int y,
|
||||
int mv_shift,
|
||||
int16_t mv_cand[2][2],
|
||||
inter_merge_cand_t merge_cand[MRG_MAX_NUM_CANDS],
|
||||
int16_t num_cand,
|
||||
int32_t ref_idx,
|
||||
uint32_t *bitcost);
|
||||
|
||||
void kvz_search_cu_inter(encoder_state_t * const state,
|
||||
int x, int y, int depth,
|
||||
|
|
Loading…
Reference in a new issue