Rename struct cabac_ctx to cabac_ctx_t.

This commit is contained in:
Ari Koivula 2015-03-04 13:26:48 +02:00
parent 4bc0308b7e
commit 727fefacc4
8 changed files with 65 additions and 65 deletions

View file

@ -299,7 +299,7 @@ void cabac_write_coeff_remain(cabac_data * const cabac, const uint32_t symbol, c
/**
* \brief
*/
void cabac_write_unary_max_symbol(cabac_data * const data, cabac_ctx * const ctx, uint32_t symbol, const int32_t offset, const uint32_t max_symbol)
void cabac_write_unary_max_symbol(cabac_data * const data, cabac_ctx_t * const ctx, uint32_t symbol, const int32_t offset, const uint32_t max_symbol)
{
int8_t code_last = max_symbol > symbol;

View file

@ -34,11 +34,11 @@
typedef struct
{
uint8_t uc_state;
} cabac_ctx;
} cabac_ctx_t;
typedef struct
{
cabac_ctx *cur_ctx;
cabac_ctx_t *cur_ctx;
uint32_t low;
uint32_t range;
uint32_t buffered_byte;
@ -49,36 +49,36 @@ typedef struct
// CONTEXTS
struct {
cabac_ctx sao_merge_flag_model;
cabac_ctx sao_type_idx_model;
cabac_ctx split_flag_model[3]; //!< \brief split flag context models
cabac_ctx intra_mode_model; //!< \brief intra mode context models
cabac_ctx chroma_pred_model[2];
cabac_ctx trans_subdiv_model[3]; //!< \brief intra mode context models
cabac_ctx qt_cbf_model_luma[4];
cabac_ctx qt_cbf_model_chroma[4];
cabac_ctx part_size_model[4];
cabac_ctx cu_sig_coeff_group_model[4];
cabac_ctx cu_sig_model_luma[27];
cabac_ctx cu_sig_model_chroma[15];
cabac_ctx cu_ctx_last_y_luma[15];
cabac_ctx cu_ctx_last_y_chroma[15];
cabac_ctx cu_ctx_last_x_luma[15];
cabac_ctx cu_ctx_last_x_chroma[15];
cabac_ctx cu_one_model_luma[16];
cabac_ctx cu_one_model_chroma[8];
cabac_ctx cu_abs_model_luma[4];
cabac_ctx cu_abs_model_chroma[2];
cabac_ctx cu_pred_mode_model;
cabac_ctx cu_skip_flag_model[3];
cabac_ctx cu_merge_idx_ext_model;
cabac_ctx cu_merge_flag_ext_model;
cabac_ctx cu_mvd_model[2];
cabac_ctx cu_ref_pic_model[2];
cabac_ctx mvp_idx_model[2];
cabac_ctx cu_qt_root_cbf_model;
cabac_ctx transform_skip_model_luma;
cabac_ctx transform_skip_model_chroma;
cabac_ctx_t sao_merge_flag_model;
cabac_ctx_t sao_type_idx_model;
cabac_ctx_t split_flag_model[3]; //!< \brief split flag context models
cabac_ctx_t intra_mode_model; //!< \brief intra mode context models
cabac_ctx_t chroma_pred_model[2];
cabac_ctx_t trans_subdiv_model[3]; //!< \brief intra mode context models
cabac_ctx_t qt_cbf_model_luma[4];
cabac_ctx_t qt_cbf_model_chroma[4];
cabac_ctx_t part_size_model[4];
cabac_ctx_t cu_sig_coeff_group_model[4];
cabac_ctx_t cu_sig_model_luma[27];
cabac_ctx_t cu_sig_model_chroma[15];
cabac_ctx_t cu_ctx_last_y_luma[15];
cabac_ctx_t cu_ctx_last_y_chroma[15];
cabac_ctx_t cu_ctx_last_x_luma[15];
cabac_ctx_t cu_ctx_last_x_chroma[15];
cabac_ctx_t cu_one_model_luma[16];
cabac_ctx_t cu_one_model_chroma[8];
cabac_ctx_t cu_abs_model_luma[4];
cabac_ctx_t cu_abs_model_chroma[2];
cabac_ctx_t cu_pred_mode_model;
cabac_ctx_t cu_skip_flag_model[3];
cabac_ctx_t cu_merge_idx_ext_model;
cabac_ctx_t cu_merge_flag_ext_model;
cabac_ctx_t cu_mvd_model[2];
cabac_ctx_t cu_ref_pic_model[2];
cabac_ctx_t mvp_idx_model[2];
cabac_ctx_t cu_qt_root_cbf_model;
cabac_ctx_t transform_skip_model_luma;
cabac_ctx_t transform_skip_model_chroma;
} ctx;
} cabac_data;
@ -103,7 +103,7 @@ void cabac_write_coeff_remain(cabac_data *cabac, uint32_t symbol,
uint32_t r_param);
void cabac_write_ep_ex_golomb(cabac_data *data, uint32_t symbol,
uint32_t count);
void cabac_write_unary_max_symbol(cabac_data *data, cabac_ctx *ctx,
void cabac_write_unary_max_symbol(cabac_data *data, cabac_ctx_t *ctx,
uint32_t symbol, int32_t offset,
uint32_t max_symbol);
void cabac_write_unary_max_symbol_ep(cabac_data *data, unsigned int symbol, unsigned int max_symbol);

View file

@ -181,7 +181,7 @@ static const uint8_t INIT_TRANSFORMSKIP_FLAG[3][2] =
/**
* \brief Initialize struct cabac_ctx.
*/
void ctx_init(cabac_ctx *ctx, uint32_t qp, uint32_t init_value)
void ctx_init(cabac_ctx_t *ctx, uint32_t qp, uint32_t init_value)
{
int slope = (init_value >> 4) * 5 - 45;
int offset = ((init_value & 15) << 3) - 16;

View file

@ -33,7 +33,7 @@
// Functions
void ctx_init(cabac_ctx* ctx, uint32_t qp, uint32_t init_value);
void ctx_init(cabac_ctx_t* ctx, uint32_t qp, uint32_t init_value);
void init_contexts(encoder_state_t *encoder_state, int8_t QP, int8_t slice);
void context_copy(encoder_state_t * target_encoder_state, const encoder_state_t * source_encoder_state);

View file

@ -1587,8 +1587,8 @@ void encode_coeff_nxn(encoder_state_t * const encoder_state, coefficient *coeff,
const uint32_t *scan_cg = g_sig_last_scan_cg[log2_block_size - 2][scan_mode];
// Init base contexts according to block type
cabac_ctx *base_coeff_group_ctx = &(cabac->ctx.cu_sig_coeff_group_model[type]);
cabac_ctx *baseCtx = (type == 0) ? &(cabac->ctx.cu_sig_model_luma[0]) :
cabac_ctx_t *base_coeff_group_ctx = &(cabac->ctx.cu_sig_coeff_group_model[type]);
cabac_ctx_t *baseCtx = (type == 0) ? &(cabac->ctx.cu_sig_model_luma[0]) :
&(cabac->ctx.cu_sig_model_chroma[0]);
FILL(sig_coeffgroup_flag, 0);
@ -1705,7 +1705,7 @@ void encode_coeff_nxn(encoder_state_t * const encoder_state, coefficient *coeff,
int8_t sign_hidden = (last_nz_pos_in_cg - first_nz_pos_in_cg >=
4 /*SBH_THRESHOLD*/) ? 1 : 0;
uint32_t ctx_set = (i > 0 && type == 0) ? 2 : 0;
cabac_ctx *base_ctx_mod;
cabac_ctx_t *base_ctx_mod;
int32_t num_c1_flag, first_c2_flag_idx, idx, first_coeff2;
if (c1 == 0) {
@ -1797,8 +1797,8 @@ void encode_last_significant_xy(encoder_state_t * const encoder_state,
int group_idx_x;
int group_idx_y;
int last_x,last_y,i;
cabac_ctx *base_ctx_x = (type ? cabac->ctx.cu_ctx_last_x_chroma : cabac->ctx.cu_ctx_last_x_luma);
cabac_ctx *base_ctx_y = (type ? cabac->ctx.cu_ctx_last_y_chroma : cabac->ctx.cu_ctx_last_y_luma);
cabac_ctx_t *base_ctx_x = (type ? cabac->ctx.cu_ctx_last_x_chroma : cabac->ctx.cu_ctx_last_x_luma);
cabac_ctx_t *base_ctx_y = (type ? cabac->ctx.cu_ctx_last_y_chroma : cabac->ctx.cu_ctx_last_y_luma);
if (scan == SCAN_VER) {
SWAP( lastpos_x, lastpos_y,uint8_t );

View file

@ -283,8 +283,8 @@ int32_t get_ic_rate (encoder_state_t * const encoder_state,
cabac_data * const cabac = &encoder_state->cabac;
int32_t rate = 32768;
uint32_t base_level = (c1_idx < C1FLAG_NUMBER)? (2 + (c2_idx < C2FLAG_NUMBER)) : 1;
cabac_ctx *base_one_ctx = (type == 0) ? &(cabac->ctx.cu_one_model_luma[0]) : &(cabac->ctx.cu_one_model_chroma[0]);
cabac_ctx *base_abs_ctx = (type == 0) ? &(cabac->ctx.cu_abs_model_luma[0]) : &(cabac->ctx.cu_abs_model_chroma[0]);
cabac_ctx_t *base_one_ctx = (type == 0) ? &(cabac->ctx.cu_one_model_luma[0]) : &(cabac->ctx.cu_one_model_chroma[0]);
cabac_ctx_t *base_abs_ctx = (type == 0) ? &(cabac->ctx.cu_abs_model_luma[0]) : &(cabac->ctx.cu_abs_model_chroma[0]);
if ( abs_level >= base_level ) {
int32_t symbol = abs_level - base_level;
@ -347,7 +347,7 @@ uint32_t get_coded_level ( encoder_state_t * const encoder_state, double *coded_
uint32_t best_abs_level = 0;
int32_t abs_level;
int32_t min_abs_level;
cabac_ctx* base_sig_model = type?(cabac->ctx.cu_sig_model_chroma):(cabac->ctx.cu_sig_model_luma);
cabac_ctx_t* base_sig_model = type?(cabac->ctx.cu_sig_model_chroma):(cabac->ctx.cu_sig_model_luma);
if( !last && max_abs_level < 3 ) {
*coded_cost_sig = encoder_state->global->cur_lambda_cost * CTX_ENTROPY_BITS(&base_sig_model[ctx_num_sig], 0);
@ -412,8 +412,8 @@ static void calc_last_bits(encoder_state_t * const encoder_state, int32_t width,
int32_t blk_size_offset_x, blk_size_offset_y, shiftX, shiftY;
int32_t ctx;
cabac_ctx *base_ctx_x = (type ? cabac->ctx.cu_ctx_last_x_chroma : cabac->ctx.cu_ctx_last_x_luma);
cabac_ctx *base_ctx_y = (type ? cabac->ctx.cu_ctx_last_y_chroma : cabac->ctx.cu_ctx_last_y_luma);
cabac_ctx_t *base_ctx_x = (type ? cabac->ctx.cu_ctx_last_x_chroma : cabac->ctx.cu_ctx_last_x_luma);
cabac_ctx_t *base_ctx_y = (type ? cabac->ctx.cu_ctx_last_y_chroma : cabac->ctx.cu_ctx_last_y_luma);
blk_size_offset_x = type ? 0: (g_convert_to_bit[ width ] *3 + ((g_convert_to_bit[ width ] +1)>>2));
blk_size_offset_y = type ? 0: (g_convert_to_bit[ height ]*3 + ((g_convert_to_bit[ height ]+1)>>2));
@ -606,9 +606,9 @@ void rdoq(encoder_state_t * const encoder_state, coefficient *coef, coefficient
uint32_t cg_num = width * height >> 4;
int32_t scanpos;
cabac_ctx *base_coeff_group_ctx = &(cabac->ctx.cu_sig_coeff_group_model[type]);
cabac_ctx *baseCtx = (type == 0) ? &(cabac->ctx.cu_sig_model_luma[0]) : &(cabac->ctx.cu_sig_model_chroma[0]);
cabac_ctx *base_one_ctx = (type == 0) ? &(cabac->ctx.cu_one_model_luma[0]) : &(cabac->ctx.cu_one_model_chroma[0]);
cabac_ctx_t *base_coeff_group_ctx = &(cabac->ctx.cu_sig_coeff_group_model[type]);
cabac_ctx_t *baseCtx = (type == 0) ? &(cabac->ctx.cu_sig_model_luma[0]) : &(cabac->ctx.cu_sig_model_chroma[0]);
cabac_ctx_t *base_one_ctx = (type == 0) ? &(cabac->ctx.cu_one_model_luma[0]) : &(cabac->ctx.cu_one_model_chroma[0]);
double best_cost = 0;
int32_t ctx_cbf = 0;
@ -824,7 +824,7 @@ void rdoq(encoder_state_t * const encoder_state, coefficient *coef, coefficient
best_cost = block_uncoded_cost + encoder_state->global->cur_lambda_cost*CTX_ENTROPY_BITS(&(cabac->ctx.cu_qt_root_cbf_model),0);
base_cost += encoder_state->global->cur_lambda_cost*CTX_ENTROPY_BITS(&(cabac->ctx.cu_qt_root_cbf_model),1);
} else {
cabac_ctx* base_cbf_model = type?(cabac->ctx.qt_cbf_model_chroma):(cabac->ctx.qt_cbf_model_luma);
cabac_ctx_t* base_cbf_model = type?(cabac->ctx.qt_cbf_model_chroma):(cabac->ctx.qt_cbf_model_luma);
ctx_cbf = ( type ? tr_depth : !tr_depth);
best_cost = block_uncoded_cost + encoder_state->global->cur_lambda_cost*CTX_ENTROPY_BITS(&base_cbf_model[ctx_cbf],0);
base_cost += encoder_state->global->cur_lambda_cost*CTX_ENTROPY_BITS(&base_cbf_model[ctx_cbf],1);

View file

@ -123,7 +123,7 @@ static float sao_mode_bits_none(const encoder_state_t * const encoder_state, sao
{
float mode_bits = 0.0;
const cabac_data * const cabac = &encoder_state->cabac;
const cabac_ctx *ctx = NULL;
const cabac_ctx_t *ctx = NULL;
// FL coded merges.
if (sao_left != NULL) {
ctx = &(cabac->ctx.sao_merge_flag_model);
@ -145,7 +145,7 @@ static float sao_mode_bits_merge(const encoder_state_t * const encoder_state,
int8_t merge_cand) {
float mode_bits = 0.0;
const cabac_data * const cabac = &encoder_state->cabac;
const cabac_ctx *ctx = NULL;
const cabac_ctx_t *ctx = NULL;
// FL coded merges.
ctx = &(cabac->ctx.sao_merge_flag_model);
@ -162,7 +162,7 @@ static float sao_mode_bits_edge(const encoder_state_t * const encoder_state,
{
float mode_bits = 0.0;
const cabac_data * const cabac = &encoder_state->cabac;
const cabac_ctx *ctx = NULL;
const cabac_ctx_t *ctx = NULL;
// FL coded merges.
if (sao_left != NULL) {
ctx = &(cabac->ctx.sao_merge_flag_model);
@ -202,7 +202,7 @@ static float sao_mode_bits_band(const encoder_state_t * const encoder_state,
{
float mode_bits = 0.0;
const cabac_data * const cabac = &encoder_state->cabac;
const cabac_ctx *ctx = NULL;
const cabac_ctx_t *ctx = NULL;
// FL coded merges.
if (sao_left != NULL) {
ctx = &(cabac->ctx.sao_merge_flag_model);

View file

@ -958,7 +958,7 @@ static double cu_rd_cost_luma(const encoder_state_t *const encoder_state,
&& width > TR_MIN_WIDTH
&& !intra_split_flag)
{
const cabac_ctx *ctx = &(encoder_state->cabac.ctx.trans_subdiv_model[5 - (6 - depth)]);
const cabac_ctx_t *ctx = &(encoder_state->cabac.ctx.trans_subdiv_model[5 - (6 - depth)]);
tr_tree_bits += CTX_ENTROPY_FBITS(ctx, tr_depth > 0);
}
@ -980,7 +980,7 @@ static double cu_rd_cost_luma(const encoder_state_t *const encoder_state,
cbf_is_set(tr_cu->cbf.u, depth) ||
cbf_is_set(tr_cu->cbf.v, depth))
{
const cabac_ctx *ctx = &(encoder_state->cabac.ctx.qt_cbf_model_luma[!tr_depth]);
const cabac_ctx_t *ctx = &(encoder_state->cabac.ctx.qt_cbf_model_luma[!tr_depth]);
tr_tree_bits += CTX_ENTROPY_FBITS(ctx, cbf_is_set(pred_cu->cbf.y, depth + pu_index));
}
@ -1030,7 +1030,7 @@ static double cu_rd_cost_chroma(const encoder_state_t *const encoder_state,
if (depth < MAX_PU_DEPTH) {
const int tr_depth = depth - pred_cu->depth;
const cabac_ctx *ctx = &(encoder_state->cabac.ctx.qt_cbf_model_chroma[tr_depth]);
const cabac_ctx_t *ctx = &(encoder_state->cabac.ctx.qt_cbf_model_chroma[tr_depth]);
if (tr_depth == 0 || cbf_is_set(pred_cu->cbf.u, depth - 1)) {
tr_tree_bits += CTX_ENTROPY_FBITS(ctx, cbf_is_set(pred_cu->cbf.u, depth));
}
@ -1183,7 +1183,7 @@ static double search_intra_trdepth(encoder_state_t * const encoder_state,
// Add bits for split_transform_flag = 1, because transform depth search bypasses
// the normal recursion in the cost functions.
if (depth >= 1 && depth <= 3) {
const cabac_ctx *ctx = &(encoder_state->cabac.ctx.trans_subdiv_model[5 - (6 - depth)]);
const cabac_ctx_t *ctx = &(encoder_state->cabac.ctx.trans_subdiv_model[5 - (6 - depth)]);
tr_split_bit += CTX_ENTROPY_FBITS(ctx, 1);
}
@ -1196,7 +1196,7 @@ static double search_intra_trdepth(encoder_state_t * const encoder_state,
{
const uint8_t tr_depth = depth - pred_cu->depth;
const cabac_ctx *ctx = &(encoder_state->cabac.ctx.qt_cbf_model_chroma[tr_depth]);
const cabac_ctx_t *ctx = &(encoder_state->cabac.ctx.qt_cbf_model_chroma[tr_depth]);
if (tr_depth == 0 || cbf_is_set(pred_cu->cbf.u, depth - 1)) {
cbf_bits += CTX_ENTROPY_FBITS(ctx, cbf_is_set(pred_cu->cbf.u, depth));
}
@ -1242,7 +1242,7 @@ static double luma_mode_bits(const encoder_state_t *encoder_state, int8_t luma_m
}
}
const cabac_ctx *ctx = &(encoder_state->cabac.ctx.intra_mode_model);
const cabac_ctx_t *ctx = &(encoder_state->cabac.ctx.intra_mode_model);
mode_bits = CTX_ENTROPY_FBITS(ctx, mode_in_preds);
if (mode_in_preds) {
@ -1257,7 +1257,7 @@ static double luma_mode_bits(const encoder_state_t *encoder_state, int8_t luma_m
static double chroma_mode_bits(const encoder_state_t *encoder_state, int8_t chroma_mode, int8_t luma_mode)
{
const cabac_ctx *ctx = &(encoder_state->cabac.ctx.chroma_pred_model[0]);
const cabac_ctx_t *ctx = &(encoder_state->cabac.ctx.chroma_pred_model[0]);
double mode_bits;
if (chroma_mode == luma_mode) {
mode_bits = CTX_ENTROPY_FBITS(ctx, 0);
@ -1376,7 +1376,7 @@ static double get_cost(encoder_state_t * const encoder_state,
// Add the offset bit costs of signaling 'luma and chroma use trskip',
// versus signaling 'luma and chroma don't use trskip' to the SAD cost.
const cabac_ctx *ctx = &encoder_state->cabac.ctx.transform_skip_model_luma;
const cabac_ctx_t *ctx = &encoder_state->cabac.ctx.transform_skip_model_luma;
double trskip_bits = CTX_ENTROPY_FBITS(ctx, 1) - CTX_ENTROPY_FBITS(ctx, 0);
ctx = &encoder_state->cabac.ctx.transform_skip_model_chroma;
trskip_bits += 2.0 * (CTX_ENTROPY_FBITS(ctx, 1) - CTX_ENTROPY_FBITS(ctx, 0));
@ -2057,13 +2057,13 @@ static double search_cu(encoder_state_t * const encoder_state, int x, int y, int
if (depth < MAX_DEPTH) {
uint8_t split_model = get_ctx_cu_split_model(lcu, x, y, depth);
const cabac_ctx *ctx = &(encoder_state->cabac.ctx.split_flag_model[split_model]);
const cabac_ctx_t *ctx = &(encoder_state->cabac.ctx.split_flag_model[split_model]);
cost += CTX_ENTROPY_FBITS(ctx, 0);
split_cost += CTX_ENTROPY_FBITS(ctx, 1);
}
if (cur_cu->type == CU_INTRA && depth == MAX_DEPTH) {
const cabac_ctx *ctx = &(encoder_state->cabac.ctx.part_size_model[0]);
const cabac_ctx_t *ctx = &(encoder_state->cabac.ctx.part_size_model[0]);
cost += CTX_ENTROPY_FBITS(ctx, 1); // 2Nx2N
split_cost += CTX_ENTROPY_FBITS(ctx, 0); // NxN
}
@ -2108,7 +2108,7 @@ static double search_cu(encoder_state_t * const encoder_state, int x, int y, int
cost += cu_rd_cost_chroma(encoder_state, x_local, y_local, depth, cur_cu, &work_tree[depth]);
uint8_t split_model = get_ctx_cu_split_model(lcu, x, y, depth);
const cabac_ctx *ctx = &(encoder_state->cabac.ctx.split_flag_model[split_model]);
const cabac_ctx_t *ctx = &(encoder_state->cabac.ctx.split_flag_model[split_model]);
cost += CTX_ENTROPY_FBITS(ctx, 0);
double mode_bits = calc_mode_bits(encoder_state, cur_cu, x, y);