summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vp9/common/vp9_entropy.c30
-rw-r--r--vp9/common/vp9_entropymode.c9
-rw-r--r--vp9/common/vp9_entropymv.c29
-rw-r--r--vp9/common/vp9_treecoder.h18
4 files changed, 41 insertions, 45 deletions
diff --git a/vp9/common/vp9_entropy.c b/vp9/common/vp9_entropy.c
index 0ad0dbccd..6c2b6e5cf 100644
--- a/vp9/common/vp9_entropy.c
+++ b/vp9/common/vp9_entropy.c
@@ -614,7 +614,8 @@ void vp9_coef_tree_initialize() {
#define COEF_MAX_UPDATE_FACTOR_AFTER_KEY 128
static void adapt_coef_probs(VP9_COMMON *cm, TX_SIZE txfm_size,
- int count_sat, int update_factor) {
+ unsigned int count_sat,
+ unsigned int update_factor) {
FRAME_CONTEXT *pre_fc = &cm->frame_contexts[cm->frame_context_idx];
vp9_coeff_probs_model *dst_coef_probs = cm->fc.coef_probs[txfm_size];
@@ -622,8 +623,7 @@ static void adapt_coef_probs(VP9_COMMON *cm, TX_SIZE 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->counts.eob_branch[txfm_size];
- int t, i, j, k, l, count;
- int factor;
+ int t, i, j, k, l;
unsigned int branch_ct[UNCONSTRAINED_NODES][2];
vp9_prob coef_probs[UNCONSTRAINED_NODES];
int entropy_nodes_adapt = UNCONSTRAINED_NODES;
@@ -634,29 +634,23 @@ static void adapt_coef_probs(VP9_COMMON *cm, TX_SIZE txfm_size,
for (l = 0; l < PREV_COEF_CONTEXTS; ++l) {
if (l >= 3 && k == 0)
continue;
- vp9_tree_probs_from_distribution(
- vp9_coefmodel_tree,
- coef_probs, branch_ct,
- coef_counts[i][j][k][l], 0);
+ vp9_tree_probs_from_distribution(vp9_coefmodel_tree, coef_probs,
+ branch_ct, coef_counts[i][j][k][l],
+ 0);
branch_ct[0][1] = eob_branch_count[i][j][k][l] - branch_ct[0][0];
coef_probs[0] = get_binary_prob(branch_ct[0][0], branch_ct[0][1]);
- for (t = 0; t < entropy_nodes_adapt; ++t) {
- count = branch_ct[t][0] + branch_ct[t][1];
- count = count > count_sat ? count_sat : count;
- factor = (update_factor * count / count_sat);
- dst_coef_probs[i][j][k][l][t] =
- weighted_prob(pre_coef_probs[i][j][k][l][t],
- coef_probs[t], factor);
- }
+ for (t = 0; t < entropy_nodes_adapt; ++t)
+ dst_coef_probs[i][j][k][l][t] = merge_probs(
+ pre_coef_probs[i][j][k][l][t], coef_probs[t],
+ branch_ct[t], count_sat, update_factor);
}
}
void vp9_adapt_coef_probs(VP9_COMMON *cm) {
TX_SIZE t;
- int count_sat;
- int update_factor; /* denominator 256 */
+ unsigned int count_sat, update_factor;
- if ((cm->frame_type == KEY_FRAME) || cm->intra_only) {
+ if (cm->frame_type == KEY_FRAME || cm->intra_only) {
update_factor = COEF_MAX_UPDATE_FACTOR_KEY;
count_sat = COEF_COUNT_SAT_KEY;
} else if (cm->last_frame_type == KEY_FRAME) {
diff --git a/vp9/common/vp9_entropymode.c b/vp9/common/vp9_entropymode.c
index cd864cf07..faaa1c2fa 100644
--- a/vp9/common/vp9_entropymode.c
+++ b/vp9/common/vp9_entropymode.c
@@ -382,15 +382,12 @@ void vp9_accum_mv_refs(VP9_COMMON *pc,
#define COUNT_SAT 20
#define MAX_UPDATE_FACTOR 128
-static int update_ct(vp9_prob pre_prob, vp9_prob prob,
- unsigned int ct[2]) {
- const int count = MIN(ct[0] + ct[1], COUNT_SAT);
- const int factor = MAX_UPDATE_FACTOR * count / COUNT_SAT;
- return weighted_prob(pre_prob, prob, factor);
+static int update_ct(vp9_prob pre_prob, vp9_prob prob, unsigned int ct[2]) {
+ return merge_probs(pre_prob, prob, ct, COUNT_SAT, MAX_UPDATE_FACTOR);
}
static int update_ct2(vp9_prob pre_prob, unsigned int ct[2]) {
- return update_ct(pre_prob, get_binary_prob(ct[0], ct[1]), ct);
+ return merge_probs2(pre_prob, ct, COUNT_SAT, MAX_UPDATE_FACTOR);
}
static void update_mode_probs(int n_modes,
diff --git a/vp9/common/vp9_entropymv.c b/vp9/common/vp9_entropymv.c
index 5ceec0d6b..f819d6839 100644
--- a/vp9/common/vp9_entropymv.c
+++ b/vp9/common/vp9_entropymv.c
@@ -170,14 +170,7 @@ void vp9_inc_mv(const MV *mv, nmv_context_counts *counts) {
}
static void adapt_prob(vp9_prob *dest, vp9_prob prep, unsigned int ct[2]) {
- const int count = MIN(ct[0] + ct[1], MV_COUNT_SAT);
- if (count) {
- const vp9_prob newp = get_binary_prob(ct[0], ct[1]);
- const int factor = MV_MAX_UPDATE_FACTOR * count / MV_COUNT_SAT;
- *dest = weighted_prob(prep, newp, factor);
- } else {
- *dest = prep;
- }
+ *dest = merge_probs2(prep, ct, MV_COUNT_SAT, MV_MAX_UPDATE_FACTOR);
}
void vp9_counts_process(nmv_context_counts *nmv_count, int usehp) {
@@ -190,26 +183,20 @@ static unsigned int adapt_probs(unsigned int i,
vp9_prob this_probs[],
const vp9_prob last_probs[],
const unsigned int num_events[]) {
- vp9_prob this_prob;
- const uint32_t left = tree[i] <= 0
+
+ const unsigned int left = tree[i] <= 0
? num_events[-tree[i]]
: adapt_probs(tree[i], tree, this_probs, last_probs, num_events);
- const uint32_t right = tree[i + 1] <= 0
+ const unsigned int right = tree[i + 1] <= 0
? num_events[-tree[i + 1]]
: adapt_probs(tree[i + 1], tree, this_probs, last_probs, num_events);
- uint32_t weight = left + right;
- if (weight) {
- this_prob = get_binary_prob(left, right);
- weight = weight > MV_COUNT_SAT ? MV_COUNT_SAT : weight;
- this_prob = weighted_prob(last_probs[i >> 1], this_prob,
- MV_MAX_UPDATE_FACTOR * weight / MV_COUNT_SAT);
- } else {
- this_prob = last_probs[i >> 1];
- }
- this_probs[i >> 1] = this_prob;
+ const unsigned int ct[2] = { left, right };
+
+ this_probs[i >> 1] = merge_probs2(last_probs[i >> 1], ct,
+ MV_COUNT_SAT, MV_MAX_UPDATE_FACTOR);
return left + right;
}
diff --git a/vp9/common/vp9_treecoder.h b/vp9/common/vp9_treecoder.h
index ebcd4116f..31182c35c 100644
--- a/vp9/common/vp9_treecoder.h
+++ b/vp9/common/vp9_treecoder.h
@@ -79,4 +79,22 @@ static INLINE vp9_prob weighted_prob(int prob1, int prob2, int factor) {
return ROUND_POWER_OF_TWO(prob1 * (256 - factor) + prob2 * factor, 8);
}
+static INLINE vp9_prob merge_probs(vp9_prob pre_prob, vp9_prob prob,
+ const unsigned int ct[2],
+ unsigned int count_sat,
+ unsigned int max_update_factor) {
+ const unsigned int count = MIN(ct[0] + ct[1], count_sat);
+ const unsigned int factor = max_update_factor * count / count_sat;
+ return weighted_prob(pre_prob, prob, factor);
+}
+
+static INLINE vp9_prob merge_probs2(vp9_prob pre_prob,
+ const unsigned int ct[2],
+ unsigned int count_sat,
+ unsigned int max_update_factor) {
+ return merge_probs(pre_prob, get_binary_prob(ct[0], ct[1]), ct, count_sat,
+ max_update_factor);
+}
+
+
#endif // VP9_COMMON_VP9_TREECODER_H_