Commit 1099a436 authored by Dmitry Kovalev's avatar Dmitry Kovalev
Browse files

Moving counts from FRAME_CONTEXT to new struct FRAME_COUNTS.

Counts are separate from frame context. We have several frame contexts but
need only one copy of all counts.

Change-Id: I5279b0321cb450bbea7049adaa9275306a7cef7d
parent 8d13b0d1
......@@ -629,9 +629,9 @@ static void adapt_coef_probs(VP9_COMMON *cm, TX_SIZE txfm_size,
vp9_coeff_probs_model *dst_coef_probs = cm->fc.coef_probs[txfm_size];
vp9_coeff_probs_model *pre_coef_probs = pre_fc->coef_probs[txfm_size];
vp9_coeff_count_model *coef_counts = cm->fc.coef_counts[txfm_size];
vp9_coeff_count_model *coef_counts = cm->counts.coef[txfm_size];
unsigned int (*eob_branch_count)[REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS] =
cm->fc.eob_branch_counts[txfm_size];
cm->counts.eob_branch[txfm_size];
int t, i, j, k, l, count;
int factor;
unsigned int branch_ct[UNCONSTRAINED_NODES][2];
......
......@@ -357,7 +357,7 @@ void vp9_entropy_mode_init() {
}
void vp9_init_mode_contexts(VP9_COMMON *pc) {
vp9_zero(pc->fc.inter_mode_counts);
vp9_zero(pc->counts.inter_mode);
vp9_copy(pc->fc.inter_mode_probs, default_inter_mode_probs);
}
......@@ -365,7 +365,7 @@ void vp9_accum_mv_refs(VP9_COMMON *pc,
MB_PREDICTION_MODE m,
const int context) {
unsigned int (*inter_mode_counts)[VP9_INTER_MODES - 1][2] =
pc->fc.inter_mode_counts;
pc->counts.inter_mode;
if (m == ZEROMV) {
++inter_mode_counts[context][0][0];
......@@ -402,11 +402,12 @@ void vp9_adapt_mode_context(VP9_COMMON *pc) {
int i, j;
FRAME_CONTEXT *const fc = &pc->fc;
FRAME_CONTEXT *const pre_fc = &pc->frame_contexts[pc->frame_context_idx];
FRAME_COUNTS *const counts = &pc->counts;
for (j = 0; j < INTER_MODE_CONTEXTS; j++)
for (i = 0; i < VP9_INTER_MODES - 1; i++)
fc->inter_mode_probs[j][i] = update_ct2(pre_fc->inter_mode_probs[j][i],
fc->inter_mode_counts[j][i]);
counts->inter_mode[j][i]);
}
static void update_mode_probs(int n_modes,
......@@ -428,41 +429,42 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) {
int i, j;
FRAME_CONTEXT *fc = &cm->fc;
FRAME_CONTEXT *pre_fc = &cm->frame_contexts[cm->frame_context_idx];
FRAME_COUNTS *counts = &cm->counts;
for (i = 0; i < INTRA_INTER_CONTEXTS; i++)
fc->intra_inter_prob[i] = update_ct2(pre_fc->intra_inter_prob[i],
fc->intra_inter_count[i]);
counts->intra_inter[i]);
for (i = 0; i < COMP_INTER_CONTEXTS; i++)
fc->comp_inter_prob[i] = update_ct2(pre_fc->comp_inter_prob[i],
fc->comp_inter_count[i]);
counts->comp_inter[i]);
for (i = 0; i < REF_CONTEXTS; i++)
fc->comp_ref_prob[i] = update_ct2(pre_fc->comp_ref_prob[i],
fc->comp_ref_count[i]);
counts->comp_ref[i]);
for (i = 0; i < REF_CONTEXTS; i++)
for (j = 0; j < 2; j++)
fc->single_ref_prob[i][j] = update_ct2(pre_fc->single_ref_prob[i][j],
fc->single_ref_count[i][j]);
counts->single_ref[i][j]);
for (i = 0; i < BLOCK_SIZE_GROUPS; i++)
update_mode_probs(VP9_INTRA_MODES, vp9_intra_mode_tree,
fc->y_mode_counts[i], pre_fc->y_mode_prob[i],
counts->y_mode[i], pre_fc->y_mode_prob[i],
fc->y_mode_prob[i], 0);
for (i = 0; i < VP9_INTRA_MODES; ++i)
update_mode_probs(VP9_INTRA_MODES, vp9_intra_mode_tree,
fc->uv_mode_counts[i], pre_fc->uv_mode_prob[i],
counts->uv_mode[i], pre_fc->uv_mode_prob[i],
fc->uv_mode_prob[i], 0);
for (i = 0; i < NUM_PARTITION_CONTEXTS; i++)
update_mode_probs(PARTITION_TYPES, vp9_partition_tree,
fc->partition_counts[i],
counts->partition[i],
pre_fc->partition_prob[INTER_FRAME][i],
fc->partition_prob[INTER_FRAME][i], 0);
if (cm->mcomp_filter_type == SWITCHABLE) {
for (i = 0; i <= VP9_SWITCHABLE_FILTERS; i++)
update_mode_probs(VP9_SWITCHABLE_FILTERS, vp9_switchable_interp_tree,
fc->switchable_interp_count[i],
counts->switchable_interp[i],
pre_fc->switchable_interp_prob[i],
fc->switchable_interp_prob[i], 0);
}
......@@ -474,18 +476,18 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) {
unsigned int branch_ct_32x32p[TX_SIZE_MAX_SB - 1][2];
for (i = 0; i < TX_SIZE_CONTEXTS; ++i) {
tx_counts_to_branch_counts_8x8(fc->tx_counts.p8x8[i], branch_ct_8x8p);
tx_counts_to_branch_counts_8x8(counts->tx.p8x8[i], branch_ct_8x8p);
for (j = 0; j < TX_SIZE_MAX_SB - 3; ++j)
fc->tx_probs.p8x8[i][j] = update_ct2(pre_fc->tx_probs.p8x8[i][j],
branch_ct_8x8p[j]);
tx_counts_to_branch_counts_16x16(fc->tx_counts.p16x16[i],
tx_counts_to_branch_counts_16x16(counts->tx.p16x16[i],
branch_ct_16x16p);
for (j = 0; j < TX_SIZE_MAX_SB - 2; ++j)
fc->tx_probs.p16x16[i][j] = update_ct2(pre_fc->tx_probs.p16x16[i][j],
branch_ct_16x16p[j]);
tx_counts_to_branch_counts_32x32(fc->tx_counts.p32x32[i],
tx_counts_to_branch_counts_32x32(counts->tx.p32x32[i],
branch_ct_32x32p);
for (j = 0; j < TX_SIZE_MAX_SB - 1; ++j)
fc->tx_probs.p32x32[i][j] = update_ct2(pre_fc->tx_probs.p32x32[i][j],
......@@ -495,7 +497,7 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) {
for (i = 0; i < MBSKIP_CONTEXTS; ++i)
fc->mbskip_probs[i] = update_ct2(pre_fc->mbskip_probs[i],
fc->mbskip_count[i]);
counts->mbskip[i]);
}
static void set_default_lf_deltas(MACROBLOCKD *xd) {
......
......@@ -226,7 +226,7 @@ void vp9_adapt_mv_probs(VP9_COMMON *cm, int usehp) {
nmv_context *ctx = &cm->fc.nmvc;
nmv_context *pre_ctx = &pre_fc->nmvc;
nmv_context_counts *cts = &cm->fc.NMVcount;
nmv_context_counts *cts = &cm->counts.mv;
vp9_counts_process(cts, usehp);
......
......@@ -38,55 +38,43 @@
#define NUM_FRAME_CONTEXTS (1 << NUM_FRAME_CONTEXTS_LOG2)
typedef struct frame_contexts {
// y_mode, uv_mode, partition
vp9_prob y_mode_prob[BLOCK_SIZE_GROUPS][VP9_INTRA_MODES - 1];
vp9_prob uv_mode_prob[VP9_INTRA_MODES][VP9_INTRA_MODES - 1];
vp9_prob partition_prob[NUM_FRAME_TYPES][NUM_PARTITION_CONTEXTS]
[PARTITION_TYPES - 1];
unsigned int y_mode_counts[BLOCK_SIZE_GROUPS][VP9_INTRA_MODES];
unsigned int uv_mode_counts[VP9_INTRA_MODES][VP9_INTRA_MODES];
unsigned int partition_counts[NUM_PARTITION_CONTEXTS][PARTITION_TYPES];
// coeff
vp9_coeff_probs_model coef_probs[TX_SIZE_MAX_SB][BLOCK_TYPES];
vp9_coeff_count_model coef_counts[TX_SIZE_MAX_SB][BLOCK_TYPES];
unsigned int eob_branch_counts[TX_SIZE_MAX_SB][BLOCK_TYPES][REF_TYPES]
[COEF_BANDS][PREV_COEF_CONTEXTS];
// switchable_interp
vp9_prob switchable_interp_prob[VP9_SWITCHABLE_FILTERS + 1]
[VP9_SWITCHABLE_FILTERS - 1];
unsigned int switchable_interp_count[VP9_SWITCHABLE_FILTERS + 1]
[VP9_SWITCHABLE_FILTERS];
// inter_mode
vp9_prob inter_mode_probs[INTER_MODE_CONTEXTS][VP9_INTER_MODES - 1];
unsigned int inter_mode_counts[INTER_MODE_CONTEXTS][VP9_INTER_MODES - 1][2];
// intra_inter, comp_inter, single_ref, comp_ref
vp9_prob intra_inter_prob[INTRA_INTER_CONTEXTS];
vp9_prob comp_inter_prob[COMP_INTER_CONTEXTS];
vp9_prob single_ref_prob[REF_CONTEXTS][2];
vp9_prob comp_ref_prob[REF_CONTEXTS];
unsigned int intra_inter_count[INTRA_INTER_CONTEXTS][2];
unsigned int comp_inter_count[COMP_INTER_CONTEXTS][2];
unsigned int single_ref_count[REF_CONTEXTS][2][2];
unsigned int comp_ref_count[REF_CONTEXTS][2];
// tx_probs
struct tx_probs tx_probs;
struct tx_counts tx_counts;
// mbskip
vp9_prob mbskip_probs[MBSKIP_CONTEXTS];
unsigned int mbskip_count[MBSKIP_CONTEXTS][2];
// mv
nmv_context nmvc;
nmv_context_counts NMVcount;
} FRAME_CONTEXT;
typedef struct {
unsigned int y_mode[BLOCK_SIZE_GROUPS][VP9_INTRA_MODES];
unsigned int uv_mode[VP9_INTRA_MODES][VP9_INTRA_MODES];
unsigned int partition[NUM_PARTITION_CONTEXTS][PARTITION_TYPES];
vp9_coeff_count_model coef[TX_SIZE_MAX_SB][BLOCK_TYPES];
unsigned int eob_branch[TX_SIZE_MAX_SB][BLOCK_TYPES][REF_TYPES]
[COEF_BANDS][PREV_COEF_CONTEXTS];
unsigned int switchable_interp[VP9_SWITCHABLE_FILTERS + 1]
[VP9_SWITCHABLE_FILTERS];
unsigned int inter_mode[INTER_MODE_CONTEXTS][VP9_INTER_MODES - 1][2];
unsigned int intra_inter[INTRA_INTER_CONTEXTS][2];
unsigned int comp_inter[COMP_INTER_CONTEXTS][2];
unsigned int single_ref[REF_CONTEXTS][2][2];
unsigned int comp_ref[REF_CONTEXTS][2];
struct tx_counts tx;
unsigned int mbskip[MBSKIP_CONTEXTS][2];
nmv_context_counts mv;
} FRAME_COUNTS;
typedef enum {
SINGLE_PREDICTION_ONLY = 0,
COMP_PREDICTION_ONLY = 1,
......@@ -205,6 +193,7 @@ typedef struct VP9Common {
FRAME_CONTEXT fc; /* this frame entropy */
FRAME_CONTEXT frame_contexts[NUM_FRAME_CONTEXTS];
unsigned int frame_context_idx; /* Context to use/update */
FRAME_COUNTS counts;
unsigned int current_video_frame;
int version;
......
......@@ -49,7 +49,7 @@ static TX_SIZE read_selected_tx_size(VP9_COMMON *cm, MACROBLOCKD *xd,
tx_size += vp9_read(r, tx_probs[2]);
}
update_tx_counts(bsize, context, tx_size, &cm->fc.tx_counts);
update_tx_counts(bsize, context, tx_size, &cm->counts.tx);
return tx_size;
}
......@@ -141,7 +141,7 @@ static uint8_t read_skip_coeff(VP9D_COMP *pbi, int segment_id, vp9_reader *r) {
if (!skip_coeff) {
const int ctx = vp9_get_pred_context_mbskip(xd);
skip_coeff = vp9_read(r, vp9_get_pred_prob_mbskip(cm, xd));
cm->fc.mbskip_count[ctx][skip_coeff]++;
cm->counts.mbskip[ctx][skip_coeff]++;
}
return skip_coeff;
}
......@@ -295,6 +295,7 @@ static void read_ref_frame(VP9D_COMP *pbi, vp9_reader *r,
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
FRAME_CONTEXT *const fc = &cm->fc;
FRAME_COUNTS *const counts = &cm->counts;
if (vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_REF_FRAME)) {
ref_frame[0] = vp9_get_segdata(&xd->seg, segment_id, SEG_LVL_REF_FRAME);
......@@ -305,7 +306,7 @@ static void read_ref_frame(VP9D_COMP *pbi, vp9_reader *r,
if (cm->comp_pred_mode == HYBRID_PREDICTION) {
is_comp = vp9_read(r, fc->comp_inter_prob[comp_ctx]);
fc->comp_inter_count[comp_ctx][is_comp]++;
counts->comp_inter[comp_ctx][is_comp]++;
} else {
is_comp = cm->comp_pred_mode == COMP_PREDICTION_ONLY;
}
......@@ -315,7 +316,7 @@ static void read_ref_frame(VP9D_COMP *pbi, vp9_reader *r,
const int fix_ref_idx = cm->ref_frame_sign_bias[cm->comp_fixed_ref];
const int ref_ctx = vp9_get_pred_context_comp_ref_p(cm, xd);
const int b = vp9_read(r, fc->comp_ref_prob[ref_ctx]);
fc->comp_ref_count[ref_ctx][b]++;
counts->comp_ref[ref_ctx][b]++;
ref_frame[fix_ref_idx] = cm->comp_fixed_ref;
ref_frame[!fix_ref_idx] = cm->comp_var_ref[b];
} else {
......@@ -325,11 +326,11 @@ static void read_ref_frame(VP9D_COMP *pbi, vp9_reader *r,
const int ref2_ctx = vp9_get_pred_context_single_ref_p2(xd);
const int b = vp9_read(r, fc->single_ref_prob[ref2_ctx][1]);
ref_frame[0] = b ? ALTREF_FRAME : GOLDEN_FRAME;
fc->single_ref_count[ref1_ctx][0][1]++;
fc->single_ref_count[ref2_ctx][1][b]++;
counts->single_ref[ref1_ctx][0][1]++;
counts->single_ref[ref2_ctx][1][b]++;
} else {
ref_frame[0] = LAST_FRAME;
fc->single_ref_count[ref1_ctx][0][0]++;
counts->single_ref[ref1_ctx][0][0]++;
}
}
}
......@@ -375,7 +376,7 @@ static INLINE INTERPOLATIONFILTERTYPE read_switchable_filter_type(
const vp9_prob *probs = vp9_get_pred_probs_switchable_interp(cm, xd);
const int index = treed_read(r, vp9_switchable_interp_tree, probs);
const int ctx = vp9_get_pred_context_switchable_interp(xd);
++cm->fc.switchable_interp_count[ctx][index];
++cm->counts.switchable_interp[ctx][index];
return vp9_switchable_interp[index];
}
......@@ -389,7 +390,7 @@ static void read_intra_block_modes(VP9D_COMP *pbi, MODE_INFO *mi,
if (bsize >= BLOCK_SIZE_SB8X8) {
const int size_group = MIN(3, MIN(bwl, bhl));
mbmi->mode = read_intra_mode(r, cm->fc.y_mode_prob[size_group]);
cm->fc.y_mode_counts[size_group][mbmi->mode]++;
cm->counts.y_mode[size_group][mbmi->mode]++;
} else {
// Only 4x4, 4x8, 8x4 blocks
const int bw = 1 << bwl, bh = 1 << bhl;
......@@ -400,7 +401,7 @@ static void read_intra_block_modes(VP9D_COMP *pbi, MODE_INFO *mi,
const int ib = idy * 2 + idx;
const int b_mode = read_intra_mode(r, cm->fc.y_mode_prob[0]);
mi->bmi[ib].as_mode = b_mode;
cm->fc.y_mode_counts[0][b_mode]++;
cm->counts.y_mode[0][b_mode]++;
if (bh == 2)
mi->bmi[ib + 2].as_mode = b_mode;
......@@ -412,7 +413,7 @@ static void read_intra_block_modes(VP9D_COMP *pbi, MODE_INFO *mi,
}
mbmi->uv_mode = read_intra_mode(r, cm->fc.uv_mode_prob[mbmi->mode]);
cm->fc.uv_mode_counts[mbmi->mode][mbmi->uv_mode]++;
cm->counts.uv_mode[mbmi->mode][mbmi->uv_mode]++;
}
static MV_REFERENCE_FRAME read_reference_frame(VP9D_COMP *pbi, int segment_id,
......@@ -425,7 +426,7 @@ static MV_REFERENCE_FRAME read_reference_frame(VP9D_COMP *pbi, int segment_id,
const int ctx = vp9_get_pred_context_intra_inter(xd);
ref = (MV_REFERENCE_FRAME)
vp9_read(r, vp9_get_pred_prob_intra_inter(cm, xd));
cm->fc.intra_inter_count[ctx][ref != INTRA_FRAME]++;
cm->counts.intra_inter[ctx][ref != INTRA_FRAME]++;
} else {
ref = (MV_REFERENCE_FRAME) vp9_get_segdata(&xd->seg, segment_id,
SEG_LVL_REF_FRAME) != INTRA_FRAME;
......@@ -518,11 +519,11 @@ static void read_inter_mode_info(VP9D_COMP *pbi, MODE_INFO *mi,
switch (blockmode) {
case NEWMV:
read_mv(r, &blockmv.as_mv, &best_mv.as_mv, nmvc,
&cm->fc.NMVcount, xd->allow_high_precision_mv);
&cm->counts.mv, xd->allow_high_precision_mv);
if (ref1 > 0)
read_mv(r, &secondmv.as_mv, &best_mv_second.as_mv, nmvc,
&cm->fc.NMVcount, xd->allow_high_precision_mv);
&cm->counts.mv, xd->allow_high_precision_mv);
break;
case NEARESTMV:
blockmv.as_int = nearest.as_int;
......@@ -596,11 +597,11 @@ static void read_inter_mode_info(VP9D_COMP *pbi, MODE_INFO *mi,
break;
case NEWMV:
read_mv(r, &mv0->as_mv, &best_mv.as_mv, nmvc, &cm->fc.NMVcount,
read_mv(r, &mv0->as_mv, &best_mv.as_mv, nmvc, &cm->counts.mv,
xd->allow_high_precision_mv);
if (ref1 > 0)
read_mv(r, &mv1->as_mv, &best_mv_second.as_mv, nmvc,
&cm->fc.NMVcount, xd->allow_high_precision_mv);
&cm->counts.mv, xd->allow_high_precision_mv);
break;
default:
assert(!"Invalid inter mode value");
......
......@@ -298,7 +298,7 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col,
else
partition = PARTITION_SPLIT;
pc->fc.partition_counts[pl][partition]++;
pc->counts.partition[pl][partition]++;
}
subsize = get_subsize(bsize, partition);
......@@ -582,23 +582,6 @@ static void setup_frame_size_with_refs(VP9D_COMP *pbi,
apply_frame_size(pbi, width, height);
}
static void zero_counts(FRAME_CONTEXT *fc) {
vp9_zero(fc->coef_counts);
vp9_zero(fc->eob_branch_counts);
vp9_zero(fc->y_mode_counts);
vp9_zero(fc->uv_mode_counts);
vp9_zero(fc->NMVcount);
vp9_zero(fc->inter_mode_counts);
vp9_zero(fc->partition_counts);
vp9_zero(fc->switchable_interp_count);
vp9_zero(fc->intra_inter_count);
vp9_zero(fc->comp_inter_count);
vp9_zero(fc->single_ref_count);
vp9_zero(fc->comp_ref_count);
vp9_zero(fc->tx_counts);
vp9_zero(fc->mbskip_count);
}
static void decode_tile(VP9D_COMP *pbi, vp9_reader *r) {
VP9_COMMON *const pc = &pbi->common;
int mi_row, mi_col;
......@@ -970,7 +953,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
pc->fc = pc->frame_contexts[pc->frame_context_idx];
zero_counts(&pc->fc);
vp9_zero(pc->counts);
// Initialize xd pointers. Any reference should do for xd->pre, so use 0.
setup_pre_planes(xd, 0, &pc->yv12_fb[pc->active_ref_idx[0]], 0, 0, NULL);
......
......@@ -91,11 +91,13 @@ DECLARE_ALIGNED(16, extern const uint8_t,
val += 1 << bits_count; \
} while (0);
static int decode_coefs(FRAME_CONTEXT *fc, const MACROBLOCKD *xd,
static int decode_coefs(VP9_COMMON *cm, const MACROBLOCKD *xd,
vp9_reader *r, int block_idx,
PLANE_TYPE type, int seg_eob, int16_t *qcoeff_ptr,
TX_SIZE txfm_size, const int16_t *dq,
ENTROPY_CONTEXT *A, ENTROPY_CONTEXT *L) {
FRAME_CONTEXT *const fc = &cm->fc;
FRAME_COUNTS *const counts = &cm->counts;
ENTROPY_CONTEXT above_ec, left_ec;
int pt, c = 0;
int band;
......@@ -121,7 +123,7 @@ static int decode_coefs(FRAME_CONTEXT *fc, const MACROBLOCKD *xd,
#endif
coef_probs = fc->coef_probs[txfm_size][type][ref];
coef_counts = fc->coef_counts[txfm_size];
coef_counts = counts->coef[txfm_size];
switch (txfm_size) {
default:
case TX_4X4: {
......@@ -172,7 +174,7 @@ static int decode_coefs(FRAME_CONTEXT *fc, const MACROBLOCKD *xd,
band = get_coef_band(band_translate, c);
prob = coef_probs[band][pt];
#if !CONFIG_BALANCED_COEFTREE
fc->eob_branch_counts[txfm_size][type][ref][band][pt]++;
counts->eob_branch[txfm_size][type][ref][band][pt]++;
if (!vp9_read(r, prob[EOB_CONTEXT_NODE]))
break;
......@@ -308,7 +310,7 @@ static void decode_block(int plane, int block,
ENTROPY_CONTEXT *A = pd->above_context + aoff;
ENTROPY_CONTEXT *L = pd->left_context + loff;
const int eob = decode_coefs(&arg->pbi->common.fc, xd, arg->r, block,
const int eob = decode_coefs(&arg->pbi->common, xd, arg->r, block,
pd->plane_type, seg_eob,
BLOCK_OFFSET(pd->qcoeff, block, 16),
ss_tx_size, pd->dequant, A, L);
......
......@@ -225,12 +225,12 @@ static int write_skip_coeff(const VP9_COMP *cpi, int segment_id, MODE_INFO *m,
}
void vp9_update_skip_probs(VP9_COMP *cpi, vp9_writer *w) {
FRAME_CONTEXT *const fc = &cpi->common.fc;
VP9_COMMON *cm = &cpi->common;
int k;
for (k = 0; k < MBSKIP_CONTEXTS; ++k)
vp9_cond_prob_diff_update(w, &fc->mbskip_probs[k],
VP9_MODE_UPDATE_PROB, fc->mbskip_count[k]);
vp9_cond_prob_diff_update(w, &cm->fc.mbskip_probs[k],
VP9_MODE_UPDATE_PROB, cm->counts.mbskip[k]);
}
static void write_intra_mode(vp9_writer *bc, int m, const vp9_prob *p) {
......@@ -248,7 +248,7 @@ static void update_switchable_interp_probs(VP9_COMP *const cpi,
vp9_tree_probs_from_distribution(
vp9_switchable_interp_tree,
new_prob[j], branch_ct[j],
pc->fc.switchable_interp_count[j], 0);
pc->counts.switchable_interp[j], 0);
}
for (j = 0; j <= VP9_SWITCHABLE_FILTERS; ++j) {
for (i = 0; i < VP9_SWITCHABLE_FILTERS - 1; ++i) {
......@@ -269,7 +269,7 @@ static void update_inter_mode_probs(VP9_COMMON *pc, vp9_writer* const bc) {
for (j = 0; j < VP9_INTER_MODES - 1; j++) {
vp9_cond_prob_diff_update(bc, &pc->fc.inter_mode_probs[i][j],
VP9_MODE_UPDATE_PROB,
pc->fc.inter_mode_counts[i][j]);
pc->counts.inter_mode[i][j]);
}
}
}
......@@ -740,7 +740,7 @@ static void build_tree_distribution(VP9_COMP *cpi, TX_SIZE txfm_size) {
vp9_coeff_probs_model *coef_probs = cpi->frame_coef_probs[txfm_size];
vp9_coeff_count *coef_counts = cpi->coef_counts[txfm_size];
unsigned int (*eob_branch_ct)[REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS] =
cpi->common.fc.eob_branch_counts[txfm_size];
cpi->common.counts.eob_branch[txfm_size];
vp9_coeff_stats *coef_branch_ct = cpi->frame_branch_ct[txfm_size];
vp9_prob full_probs[ENTROPY_NODES];
int i, j, k, l;
......@@ -1060,7 +1060,7 @@ static void encode_txfm_probs(VP9_COMP *cpi, vp9_writer *w) {
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
tx_counts_to_branch_counts_8x8(cm->fc.tx_counts.p8x8[i],
tx_counts_to_branch_counts_8x8(cm->counts.tx.p8x8[i],
ct_8x8p);
for (j = 0; j < TX_SIZE_MAX_SB - 3; j++)
vp9_cond_prob_diff_update(w, &cm->fc.tx_probs.p8x8[i][j],
......@@ -1068,7 +1068,7 @@ static void encode_txfm_probs(VP9_COMP *cpi, vp9_writer *w) {
}
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
tx_counts_to_branch_counts_16x16(cm->fc.tx_counts.p16x16[i],
tx_counts_to_branch_counts_16x16(cm->counts.tx.p16x16[i],
ct_16x16p);
for (j = 0; j < TX_SIZE_MAX_SB - 2; j++)
vp9_cond_prob_diff_update(w, &cm->fc.tx_probs.p16x16[i][j],
......@@ -1076,7 +1076,7 @@ static void encode_txfm_probs(VP9_COMP *cpi, vp9_writer *w) {
}
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
tx_counts_to_branch_counts_32x32(cm->fc.tx_counts.p32x32[i], ct_32x32p);
tx_counts_to_branch_counts_32x32(cm->counts.tx.p32x32[i], ct_32x32p);
for (j = 0; j < TX_SIZE_MAX_SB - 1; j++)
vp9_cond_prob_diff_update(w, &cm->fc.tx_probs.p32x32[i][j],
VP9_MODE_UPDATE_PROB, ct_32x32p[j]);
......@@ -1105,7 +1105,7 @@ static void fix_mcomp_filter_type(VP9_COMP *cpi) {
for (i = 0; i < VP9_SWITCHABLE_FILTERS; ++i) {
count[i] = 0;
for (j = 0; j <= VP9_SWITCHABLE_FILTERS; ++j)
count[i] += cm->fc.switchable_interp_count[j][i];
count[i] += cm->counts.switchable_interp[j][i];
c += (count[i] > 0);
}
if (c == 1) {
......@@ -1392,7 +1392,7 @@ static size_t write_compressed_header(VP9_COMP *cpi, uint8_t *data) {
#endif
update_inter_mode_probs(cm, &header_bc);
vp9_zero(fc->inter_mode_counts);
vp9_zero(cm->counts.inter_mode);
if (cm->mcomp_filter_type == SWITCHABLE)
update_switchable_interp_probs(cpi, &header_bc);
......
......@@ -422,7 +422,7 @@ static void update_state(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx,
if (cpi->common.mcomp_filter_type == SWITCHABLE
&& is_inter_mode(mbmi->mode)) {
++cpi->common.fc.switchable_interp_count[
++cpi->common.counts.switchable_interp[
vp9_get_pred_context_switchable_interp(xd)]
[vp9_switchable_interp_map[mbmi->interp_filter]];
}
......@@ -1949,14 +1949,14 @@ static void init_encode_frame_mb_context(VP9_COMP *cpi) {
vp9_zero(cpi->y_mode_count)
vp9_zero(cpi->y_uv_mode_count)
vp9_zero(cm->fc.inter_mode_counts)
vp9_zero(cm->counts.inter_mode)
vp9_zero(cpi->partition_count);
vp9_zero(cpi->intra_inter_count);
vp9_zero(cpi->comp_inter_count);
vp9_zero(cpi->single_ref_count);
vp9_zero(cpi->comp_ref_count);
vp9_zero(cm->fc.tx_counts);
vp9_zero(cm->fc.mbskip_count);
vp9_zero(cm->counts.tx);
vp9_zero(cm->counts.mbskip);
// Note: this memset assumes above_context[0], [1] and [2]
// are allocated as part of the same buffer.
......@@ -2018,7 +2018,7 @@ static void encode_frame_internal(VP9_COMP *cpi) {
// Reset frame count of inter 0,0 motion vector usage.
cpi->inter_zz_count = 0;
vp9_zero(cm->fc.switchable_interp_count);
vp9_zero(cm->counts.switchable_interp);
vp9_zero(cpi->txfm_stepdown_count);
xd->mode_info_context = cm->mi;
......@@ -2026,7 +2026,7 @@ static void encode_frame_internal(VP9_COMP *cpi) {
vp9_zero(cpi->NMVcount);
vp9_zero(cpi->coef_counts);
vp9_zero(cm->fc.eob_branch_counts);
vp9_zero(cm->counts.eob_branch);
cpi->mb.e_mbd.lossless = cm->base_qindex == 0 && cm->y_dc_delta_q == 0
&& cm->uv_dc_delta_q == 0 && cm->uv_ac_delta_q == 0;
......@@ -2412,17 +2412,17 @@ void vp9_encode_frame(VP9_COMP *cpi) {
int count32x32 = 0;
for (i = 0; i < TX_SIZE_CONTEXTS; ++i) {
count4x4 += cm->fc.tx_counts.p32x32[i][TX_4X4];
count4x4 += cm->fc.tx_counts.p16x16[i][TX_4X4];
count4x4 += cm->fc.tx_counts.p8x8[i][TX_4X4];
count4x4 += cm->counts.tx.p32x32[i][TX_4X4];
count4x4 += cm->counts.tx.p16x16[i][TX_4X4];
count4x4 += cm->counts.tx.p8x8[i][TX_4X4];
count8x8_lp += cm->fc.tx_counts.p32x32[i][TX_8X8];
count8x8_lp += cm->fc.tx_counts.p16x16[i][TX_8X8];
count8x8_8x8p += cm->fc.tx_counts.p8x8[i][TX_8X8];
count8x8_lp += cm->counts.tx.p32x32[i][TX_8X8];
count8x8_lp += cm->counts.tx.p16x16[i][TX_8X8];
count8x8_8x8p += cm->counts.tx.p8x8[i][TX_8X8];
count16x16_16x16p += cm->fc.tx_counts.p16x16[i][TX_16X16];
count16x16_lp += cm->fc.tx_counts.p32x32[i][TX_16X16];
count32x32 += cm->fc.tx_counts.p32x32[i][TX_32X32];
count16x16_16x16p += cm->counts.tx.p16x16[i][TX_16X16];
count16x16_lp += cm->counts.tx.p32x32[i][TX_16X16];
count32x32 += cm->counts.tx.p32x32[i][TX_32X32];
}
if (count4x4 == 0 && count16x16_lp == 0 && count16x16_16x16p == 0
......@@ -2588,7 +2588,7 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t, int output_enabled,
mbmi->mb_skip_coeff = 1;
if (output_enabled)
cm->fc.mbskip_count[mb_skip_context][1]++;
cm->counts.mbskip[mb_skip_context][1]++;
vp9_reset_sb_tokens_context(
xd, (bsize < BLOCK_SIZE_SB8X8)