Commit e4bf50b9 authored by Debargha Mukherjee's avatar Debargha Mukherjee

Make the backward updates work with bitshifts

Removes integer divides from backward updates for VP10.
Currently this is put in as part of the entropy experiment.
Coding efficiency change is in the noise level.

Change-Id: I5b3c0ab6169ee6d82d0ca1778e264fd4577cdd32
parent 3f7a7096
......@@ -2840,13 +2840,6 @@ void vp10_default_coef_probs(VP10_COMMON *cm) {
#endif // CONFIG_ANS
}
#define COEF_COUNT_SAT 24
#define COEF_MAX_UPDATE_FACTOR 112
#define COEF_COUNT_SAT_KEY 24
#define COEF_MAX_UPDATE_FACTOR_KEY 112
#define COEF_COUNT_SAT_AFTER_KEY 24
#define COEF_MAX_UPDATE_FACTOR_AFTER_KEY 128
static void adapt_coef_probs(VP10_COMMON *cm, TX_SIZE tx_size,
unsigned int count_sat,
unsigned int update_factor) {
......@@ -2880,9 +2873,9 @@ static void adapt_coef_probs(VP10_COMMON *cm, TX_SIZE tx_size,
{ n1, n2 }
};
for (m = 0; m < UNCONSTRAINED_NODES; ++m)
probs[i][j][k][l][m] = merge_probs(pre_probs[i][j][k][l][m],
branch_ct[m],
count_sat, update_factor);
probs[i][j][k][l][m] = vp10_merge_probs(pre_probs[i][j][k][l][m],
branch_ct[m],
count_sat, update_factor);
}
}
......@@ -2890,20 +2883,25 @@ void vp10_adapt_coef_probs(VP10_COMMON *cm) {
TX_SIZE t;
unsigned int count_sat, update_factor;
if (frame_is_intra_only(cm)) {
update_factor = COEF_MAX_UPDATE_FACTOR_KEY;
count_sat = COEF_COUNT_SAT_KEY;
} else if (cm->last_frame_type == KEY_FRAME) {
#if CONFIG_ENTROPY
if (cm->last_frame_type == KEY_FRAME) {
update_factor = COEF_MAX_UPDATE_FACTOR_AFTER_KEY_BITS; /* adapt quickly */
count_sat = COEF_COUNT_SAT_AFTER_KEY_BITS;
} else {
update_factor = COEF_MAX_UPDATE_FACTOR_BITS;
count_sat = COEF_COUNT_SAT_BITS;
}
if (cm->partial_prob_update == 1) {
update_factor = COEF_MAX_UPDATE_FACTOR_BITS;
}
#else
if (cm->last_frame_type == KEY_FRAME) {
update_factor = COEF_MAX_UPDATE_FACTOR_AFTER_KEY; /* adapt quickly */
count_sat = COEF_COUNT_SAT_AFTER_KEY;
} else {
update_factor = COEF_MAX_UPDATE_FACTOR;
count_sat = COEF_COUNT_SAT;
}
#if CONFIG_ENTROPY
if (cm->partial_prob_update == 1) {
update_factor = COEF_MAX_UPDATE_FACTOR;
}
#endif // CONFIG_ENTROPY
for (t = TX_4X4; t <= TX_32X32; t++)
adapt_coef_probs(cm, t, count_sat, update_factor);
......
......@@ -231,6 +231,51 @@ static INLINE int get_entropy_context(TX_SIZE tx_size, const ENTROPY_CONTEXT *a,
struct frame_contexts;
void vp10_coef_pareto_cdfs(struct frame_contexts *fc);
#endif // CONFIG_ANS
#if CONFIG_ENTROPY
#define COEF_COUNT_SAT_BITS 5
#define COEF_MAX_UPDATE_FACTOR_BITS 7
#define COEF_COUNT_SAT_AFTER_KEY_BITS 5
#define COEF_MAX_UPDATE_FACTOR_AFTER_KEY_BITS 7
#define MODE_MV_COUNT_SAT_BITS 5
#define MODE_MV_MAX_UPDATE_FACTOR_BITS 7
#else
#define COEF_COUNT_SAT 24
#define COEF_MAX_UPDATE_FACTOR 112
#define COEF_COUNT_SAT_AFTER_KEY 24
#define COEF_MAX_UPDATE_FACTOR_AFTER_KEY 128
#endif // CONFIG_ENTROPY
static INLINE vpx_prob vp10_merge_probs(vpx_prob pre_prob,
const unsigned int ct[2],
unsigned int count_sat,
unsigned int max_update_factor) {
#if CONFIG_ENTROPY
const vpx_prob prob = get_binary_prob(ct[0], ct[1]);
const unsigned int count =
VPXMIN(ct[0] + ct[1], (unsigned int)(1 << count_sat));
const unsigned int factor =
count << (max_update_factor - count_sat);
return weighted_prob(pre_prob, prob, factor);
#else
return merge_probs(pre_prob, ct, count_sat, max_update_factor);
#endif // CONFIG_ENTROPY
}
static INLINE vpx_prob vp10_mode_mv_merge_probs(vpx_prob pre_prob,
const unsigned int ct[2]) {
#if CONFIG_ENTROPY
return vp10_merge_probs(pre_prob, ct,
MODE_MV_COUNT_SAT_BITS,
MODE_MV_MAX_UPDATE_FACTOR_BITS);
#else
return mode_mv_merge_probs(pre_prob, ct);
#endif // CONFIG_ENTROPY
}
#ifdef __cplusplus
} // extern "C"
#endif
......
......@@ -1270,37 +1270,37 @@ void vp10_adapt_inter_frame_probs(VP10_COMMON *cm) {
const FRAME_COUNTS *counts = &cm->counts;
for (i = 0; i < INTRA_INTER_CONTEXTS; i++)
fc->intra_inter_prob[i] = mode_mv_merge_probs(pre_fc->intra_inter_prob[i],
counts->intra_inter[i]);
fc->intra_inter_prob[i] = vp10_mode_mv_merge_probs(
pre_fc->intra_inter_prob[i], counts->intra_inter[i]);
for (i = 0; i < COMP_INTER_CONTEXTS; i++)
fc->comp_inter_prob[i] = mode_mv_merge_probs(pre_fc->comp_inter_prob[i],
counts->comp_inter[i]);
fc->comp_inter_prob[i] = vp10_mode_mv_merge_probs(
pre_fc->comp_inter_prob[i], counts->comp_inter[i]);
for (i = 0; i < REF_CONTEXTS; i++)
for (j = 0; j < (COMP_REFS - 1); j++)
fc->comp_ref_prob[i][j] = mode_mv_merge_probs(pre_fc->comp_ref_prob[i][j],
counts->comp_ref[i][j]);
fc->comp_ref_prob[i][j] = vp10_mode_mv_merge_probs(
pre_fc->comp_ref_prob[i][j], counts->comp_ref[i][j]);
for (i = 0; i < REF_CONTEXTS; i++)
for (j = 0; j < (SINGLE_REFS - 1); j++)
fc->single_ref_prob[i][j] = mode_mv_merge_probs(
fc->single_ref_prob[i][j] = vp10_mode_mv_merge_probs(
pre_fc->single_ref_prob[i][j], counts->single_ref[i][j]);
#if CONFIG_REF_MV
for (i = 0; i < NEWMV_MODE_CONTEXTS; ++i)
fc->newmv_prob[i] = mode_mv_merge_probs(pre_fc->newmv_prob[i],
counts->newmv_mode[i]);
fc->newmv_prob[i] = vp10_mode_mv_merge_probs(pre_fc->newmv_prob[i],
counts->newmv_mode[i]);
for (i = 0; i < ZEROMV_MODE_CONTEXTS; ++i)
fc->zeromv_prob[i] = mode_mv_merge_probs(pre_fc->zeromv_prob[i],
counts->zeromv_mode[i]);
fc->zeromv_prob[i] = vp10_mode_mv_merge_probs(pre_fc->zeromv_prob[i],
counts->zeromv_mode[i]);
for (i = 0; i < REFMV_MODE_CONTEXTS; ++i)
fc->refmv_prob[i] = mode_mv_merge_probs(pre_fc->refmv_prob[i],
counts->refmv_mode[i]);
fc->refmv_prob[i] = vp10_mode_mv_merge_probs(pre_fc->refmv_prob[i],
counts->refmv_mode[i]);
for (i = 0; i < DRL_MODE_CONTEXTS; ++i)
fc->drl_prob[i] = mode_mv_merge_probs(pre_fc->drl_prob[i],
counts->drl_mode[i]);
fc->drl_prob[i] = vp10_mode_mv_merge_probs(pre_fc->drl_prob[i],
counts->drl_mode[i]);
#if CONFIG_EXT_INTER
fc->new2mv_prob = mode_mv_merge_probs(pre_fc->new2mv_prob,
counts->new2mv_mode);
fc->new2mv_prob = vp10_mode_mv_merge_probs(pre_fc->new2mv_prob,
counts->new2mv_mode);
#endif // CONFIG_EXT_INTER
#else
for (i = 0; i < INTER_MODE_CONTEXTS; i++)
......@@ -1310,16 +1310,16 @@ void vp10_adapt_inter_frame_probs(VP10_COMMON *cm) {
#if CONFIG_OBMC
for (i = BLOCK_8X8; i < BLOCK_SIZES; ++i)
fc->obmc_prob[i] = mode_mv_merge_probs(pre_fc->obmc_prob[i],
counts->obmc[i]);
fc->obmc_prob[i] = vp10_mode_mv_merge_probs(pre_fc->obmc_prob[i],
counts->obmc[i]);
#endif // CONFIG_OBMC
#if CONFIG_SUPERTX
for (i = 0; i < PARTITION_SUPERTX_CONTEXTS; ++i) {
int j;
for (j = 1; j < TX_SIZES; ++j) {
fc->supertx_prob[i][j] = mode_mv_merge_probs(pre_fc->supertx_prob[i][j],
counts->supertx[i][j]);
fc->supertx_prob[i][j] = vp10_mode_mv_merge_probs(
pre_fc->supertx_prob[i][j], counts->supertx[i][j]);
}
}
#endif // CONFIG_SUPERTX
......@@ -1332,8 +1332,8 @@ void vp10_adapt_inter_frame_probs(VP10_COMMON *cm) {
fc->inter_compound_mode_probs[i]);
for (i = 0; i < BLOCK_SIZE_GROUPS; ++i) {
if (is_interintra_allowed_bsize_group(i))
fc->interintra_prob[i] = mode_mv_merge_probs(pre_fc->interintra_prob[i],
counts->interintra[i]);
fc->interintra_prob[i] = vp10_mode_mv_merge_probs(
pre_fc->interintra_prob[i], counts->interintra[i]);
}
for (i = 0; i < BLOCK_SIZE_GROUPS; i++) {
vpx_tree_merge_probs(
......@@ -1342,12 +1342,12 @@ void vp10_adapt_inter_frame_probs(VP10_COMMON *cm) {
}
for (i = 0; i < BLOCK_SIZES; ++i) {
if (is_interintra_allowed_bsize(i) && is_interintra_wedge_used(i))
fc->wedge_interintra_prob[i] = mode_mv_merge_probs(
fc->wedge_interintra_prob[i] = vp10_mode_mv_merge_probs(
pre_fc->wedge_interintra_prob[i], counts->wedge_interintra[i]);
}
for (i = 0; i < BLOCK_SIZES; ++i) {
if (is_interinter_wedge_used(i))
fc->wedge_interinter_prob[i] = mode_mv_merge_probs(
fc->wedge_interinter_prob[i] = vp10_mode_mv_merge_probs(
pre_fc->wedge_interinter_prob[i], counts->wedge_interinter[i]);
}
#endif // CONFIG_EXT_INTER
......@@ -1385,12 +1385,12 @@ void vp10_adapt_intra_frame_probs(VP10_COMMON *cm) {
if (cm->tx_mode == TX_MODE_SELECT)
for (i = 0; i < TXFM_PARTITION_CONTEXTS; ++i)
fc->txfm_partition_prob[i] =
mode_mv_merge_probs(pre_fc->txfm_partition_prob[i],
vp10_mode_mv_merge_probs(pre_fc->txfm_partition_prob[i],
counts->txfm_partition[i]);
#endif
for (i = 0; i < SKIP_CONTEXTS; ++i)
fc->skip_probs[i] = mode_mv_merge_probs(
fc->skip_probs[i] = vp10_mode_mv_merge_probs(
pre_fc->skip_probs[i], counts->skip[i]);
#if CONFIG_EXT_TX
......@@ -1433,8 +1433,8 @@ void vp10_adapt_intra_frame_probs(VP10_COMMON *cm) {
if (cm->seg.temporal_update) {
for (i = 0; i < PREDICTION_PROBS; i++)
fc->seg.pred_probs[i] = mode_mv_merge_probs(pre_fc->seg.pred_probs[i],
counts->seg.pred[i]);
fc->seg.pred_probs[i] = vp10_mode_mv_merge_probs(
pre_fc->seg.pred_probs[i], counts->seg.pred[i]);
vpx_tree_merge_probs(vp10_segment_tree, pre_fc->seg.tree_probs,
counts->seg.tree_mispred, fc->seg.tree_probs);
......@@ -1461,7 +1461,7 @@ void vp10_adapt_intra_frame_probs(VP10_COMMON *cm) {
#if CONFIG_EXT_INTRA
for (i = 0; i < PLANE_TYPES; ++i) {
fc->ext_intra_probs[i] = mode_mv_merge_probs(
fc->ext_intra_probs[i] = vp10_mode_mv_merge_probs(
pre_fc->ext_intra_probs[i], counts->ext_intra[i]);
}
......
......@@ -207,7 +207,7 @@ void vp10_adapt_mv_probs(VP10_COMMON *cm, int allow_hp) {
vpx_tree_merge_probs(vp10_mv_joint_tree, pre_fc->joints, counts->joints,
fc->joints);
#if CONFIG_REF_MV
fc->zero_rmv = mode_mv_merge_probs(pre_fc->zero_rmv, counts->zero_rmv);
fc->zero_rmv = vp10_mode_mv_merge_probs(pre_fc->zero_rmv, counts->zero_rmv);
#endif
for (i = 0; i < 2; ++i) {
......@@ -215,14 +215,14 @@ void vp10_adapt_mv_probs(VP10_COMMON *cm, int allow_hp) {
const nmv_component *pre_comp = &pre_fc->comps[i];
const nmv_component_counts *c = &counts->comps[i];
comp->sign = mode_mv_merge_probs(pre_comp->sign, c->sign);
comp->sign = vp10_mode_mv_merge_probs(pre_comp->sign, c->sign);
vpx_tree_merge_probs(vp10_mv_class_tree, pre_comp->classes, c->classes,
comp->classes);
vpx_tree_merge_probs(vp10_mv_class0_tree, pre_comp->class0, c->class0,
comp->class0);
for (j = 0; j < MV_OFFSET_BITS; ++j)
comp->bits[j] = mode_mv_merge_probs(pre_comp->bits[j], c->bits[j]);
comp->bits[j] = vp10_mode_mv_merge_probs(pre_comp->bits[j], c->bits[j]);
for (j = 0; j < CLASS0_SIZE; ++j)
vpx_tree_merge_probs(vp10_mv_fp_tree, pre_comp->class0_fp[j],
......@@ -231,9 +231,9 @@ void vp10_adapt_mv_probs(VP10_COMMON *cm, int allow_hp) {
vpx_tree_merge_probs(vp10_mv_fp_tree, pre_comp->fp, c->fp, comp->fp);
if (allow_hp) {
comp->class0_hp = mode_mv_merge_probs(pre_comp->class0_hp,
c->class0_hp);
comp->hp = mode_mv_merge_probs(pre_comp->hp, c->hp);
comp->class0_hp = vp10_mode_mv_merge_probs(pre_comp->class0_hp,
c->class0_hp);
comp->hp = vp10_mode_mv_merge_probs(pre_comp->hp, c->hp);
}
}
}
......@@ -250,14 +250,14 @@ void vp10_adapt_mv_probs(VP10_COMMON *cm, int allow_hp) {
const nmv_component *pre_comp = &pre_fc->comps[i];
const nmv_component_counts *c = &counts->comps[i];
comp->sign = mode_mv_merge_probs(pre_comp->sign, c->sign);
comp->sign = vp10_mode_mv_merge_probs(pre_comp->sign, c->sign);
vpx_tree_merge_probs(vp10_mv_class_tree, pre_comp->classes, c->classes,
comp->classes);
vpx_tree_merge_probs(vp10_mv_class0_tree, pre_comp->class0, c->class0,
comp->class0);
for (j = 0; j < MV_OFFSET_BITS; ++j)
comp->bits[j] = mode_mv_merge_probs(pre_comp->bits[j], c->bits[j]);
comp->bits[j] = vp10_mode_mv_merge_probs(pre_comp->bits[j], c->bits[j]);
for (j = 0; j < CLASS0_SIZE; ++j)
vpx_tree_merge_probs(vp10_mv_fp_tree, pre_comp->class0_fp[j],
......@@ -266,8 +266,9 @@ void vp10_adapt_mv_probs(VP10_COMMON *cm, int allow_hp) {
vpx_tree_merge_probs(vp10_mv_fp_tree, pre_comp->fp, c->fp, comp->fp);
if (allow_hp) {
comp->class0_hp = mode_mv_merge_probs(pre_comp->class0_hp, c->class0_hp);
comp->hp = mode_mv_merge_probs(pre_comp->hp, c->hp);
comp->class0_hp = vp10_mode_mv_merge_probs(
pre_comp->class0_hp, c->class0_hp);
comp->hp = vp10_mode_mv_merge_probs(pre_comp->hp, c->hp);
}
}
#endif
......
......@@ -191,9 +191,9 @@ static int get_cost(unsigned int ct[][2], vpx_prob p, int n) {
total_ct[0] += ct[i][0];
total_ct[1] += ct[i][1];
if (i < n)
p = merge_probs(p0, total_ct, 24, 112);
p = vp10_merge_probs(p0, total_ct,
COEF_COUNT_SAT_BITS, COEF_MAX_UPDATE_FACTOR_BITS);
}
return cost;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment