Consistently use get_prob(), clip_prob() and newly added clip_pixel().

Add a function clip_pixel() to clip a pixel value to the [0,255] range
of allowed values, and use this where-ever appropriate (e.g. prediction,
reconstruction). Likewise, consistently use the recently added function
clip_prob(), which calculates a binary probability in the [1,255] range.
If possible, try to use get_prob() or its sister get_binary_prob() to
calculate binary probabilities, for consistency.

Since in some places, this means that binary probability calculations
are changed (we use {255,256}*count0/(total) in a range of places,
and all of these are now changed to use 256*count0+(total>>1)/total),
this changes the encoding result, so this patch warrants some extensive
testing.

Change-Id: Ibeeff8d886496839b8e0c0ace9ccc552351f7628
This commit is contained in:
Ronald S. Bultje
2012-12-10 12:09:07 -08:00
parent d124465975
commit 4d0ec7aacd
20 changed files with 236 additions and 565 deletions

View File

@@ -11,6 +11,7 @@
#include "vp9/common/vp9_pred_common.h"
#include "vp9/common/vp9_seg_common.h"
#include "vp9/common/vp9_treecoder.h"
// TBD prediction functions for various bitstream signals
@@ -383,26 +384,13 @@ void vp9_calc_ref_probs(int *count, vp9_prob *probs) {
int tot_count;
tot_count = count[0] + count[1] + count[2] + count[3];
if (tot_count) {
probs[0] = (vp9_prob)((count[0] * 255 + (tot_count >> 1)) / tot_count);
probs[0] += !probs[0];
} else
probs[0] = 128;
probs[0] = get_prob(count[0], tot_count);
tot_count -= count[0];
if (tot_count) {
probs[1] = (vp9_prob)((count[1] * 255 + (tot_count >> 1)) / tot_count);
probs[1] += !probs[1];
} else
probs[1] = 128;
probs[1] = get_prob(count[1], tot_count);
tot_count -= count[1];
if (tot_count) {
probs[2] = (vp9_prob)((count[2] * 255 + (tot_count >> 1)) / tot_count);
probs[2] += !probs[2];
} else
probs[2] = 128;
probs[2] = get_prob(count[2], tot_count);
}
// Computes a set of modified conditional probabilities for the reference frame