summaryrefslogtreecommitdiff
path: root/vp9/common/vp9_entropymv.c
diff options
context:
space:
mode:
authorDmitry Kovalev <dkovalev@google.com>2013-07-24 17:44:04 -0700
committerDmitry Kovalev <dkovalev@google.com>2013-07-24 17:44:04 -0700
commit40358dc406cf9ae46d063b170b6ddf84a754a87d (patch)
treeebc9f5605c66fa17b91b74dbaefbadaee37df8f6 /vp9/common/vp9_entropymv.c
parentfcc34796d2376575ecb34d0d381a84b03bc6ad81 (diff)
downloadlibvpx-40358dc406cf9ae46d063b170b6ddf84a754a87d.tar
libvpx-40358dc406cf9ae46d063b170b6ddf84a754a87d.tar.gz
libvpx-40358dc406cf9ae46d063b170b6ddf84a754a87d.tar.bz2
libvpx-40358dc406cf9ae46d063b170b6ddf84a754a87d.zip
Removing duplicated code for merging two probabilities.
Adding common merge_probs and merge_probs2 functions. Changing ints to usigned ints in some places. Change-Id: Icf088ffdea7cf5b95284a128916409bdd53506b0
Diffstat (limited to 'vp9/common/vp9_entropymv.c')
-rw-r--r--vp9/common/vp9_entropymv.c29
1 files changed, 8 insertions, 21 deletions
diff --git a/vp9/common/vp9_entropymv.c b/vp9/common/vp9_entropymv.c
index 343b6241d..6dac50957 100644
--- a/vp9/common/vp9_entropymv.c
+++ b/vp9/common/vp9_entropymv.c
@@ -175,14 +175,7 @@ void vp9_inc_mv(const MV *mv, nmv_context_counts *mvctx) {
}
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) {
@@ -195,26 +188,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;
}