Commit 2ce4bd42 authored by Alex Converse's avatar Alex Converse Committed by Thomas Davies

ec_multisymbol: Add defines CDF_PROB_BITS, CDF_PROB_TOP

Change-Id: I6c1717ad82d05ebe22327aec6989af2c0db336e3
parent 8e0b8697
......@@ -198,7 +198,7 @@ int tree_to_cdf(const aom_tree_index *tree, const aom_prob *probs,
nsymbs++;
}
/* Compute the probabilities of each symbol in Q15 */
tree_node_compute_probs(symb, 0, 32768);
tree_node_compute_probs(symb, 0, CDF_PROB_TOP);
/* Extract the cdf, index, path and length */
tree_node_extract(symb, 0, 0, cdf, index, path, len);
/* Convert to CDF */
......
......@@ -27,6 +27,9 @@ typedef uint8_t aom_prob;
// TODO(negge): Rename this aom_prob once we remove vpxbool.
typedef uint16_t aom_cdf_prob;
#define CDF_PROB_BITS 15
#define CDF_PROB_TOP (1 << CDF_PROB_BITS)
#define MAX_PROB 255
#define aom_prob_half ((aom_prob)128)
......@@ -144,7 +147,7 @@ static INLINE void update_cdf(aom_cdf_prob *cdf, int val, int nsymbs) {
#if 1
const int tmp0 = 1 << rate2;
tmp = tmp0;
diff = ((32768 - (nsymbs << rate2)) >> rate) << rate;
diff = ((CDF_PROB_TOP - (nsymbs << rate2)) >> rate) << rate;
// Single loop (faster)
for (i = 0; i < nsymbs - 1; ++i, tmp += tmp0) {
tmp += (i == val ? diff : 0);
......@@ -155,7 +158,7 @@ static INLINE void update_cdf(aom_cdf_prob *cdf, int val, int nsymbs) {
tmp = (i + 1) << rate2;
cdf[i] -= ((cdf[i] - tmp) >> rate);
}
diff = 32768 - cdf[nsymbs - 1];
diff = CDF_PROB_TOP - cdf[nsymbs - 1];
for (i = val; i < nsymbs; ++i) {
cdf[i] += diff;
......
......@@ -4405,11 +4405,14 @@ static void build_token_cdfs(const aom_prob *pdf_model,
assert(pdf_model[2] != 0);
// Do the head (ZERO, ONE, TWO or more)
cdf_head[ZERO_TOKEN] = sum = (pdf_model[1] << 7);
scale = (1 << 15) - cdf_head[ZERO_TOKEN];
p = AOMMAX(1, (scale * 128 * pdf_model[2] + (1 << 14)) >> 15);
cdf_head[ONE_TOKEN] = cdf_head[ZERO_TOKEN] + p;
cdf_head[TWO_TOKEN] = (1 << 15);
cdf_head[ZERO_TOKEN] = sum = (pdf_model[1] << (CDF_PROB_BITS - 8));
assert(cdf_head[ZERO_TOKEN] < CDF_PROB_TOP);
scale = CDF_PROB_TOP - cdf_head[ZERO_TOKEN];
p = ROUND_POWER_OF_TWO(scale * (pdf_model[2] << (CDF_PROB_BITS - 8)),
CDF_PROB_BITS);
cdf_head[ONE_TOKEN] = cdf_head[ZERO_TOKEN] + AOMMAX(1, p);
assert(cdf_head[ONE_TOKEN] < CDF_PROB_TOP);
cdf_head[TWO_TOKEN] = CDF_PROB_TOP;
// Do the tail
sum = 0;
......
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