ec_multisymbol: Add defines CDF_PROB_BITS, CDF_PROB_TOP Change-Id: I6c1717ad82d05ebe22327aec6989af2c0db336e3
diff --git a/aom_dsp/prob.c b/aom_dsp/prob.c index a98a4bc..7d51dbb 100644 --- a/aom_dsp/prob.c +++ b/aom_dsp/prob.c
@@ -198,7 +198,7 @@ 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 */
diff --git a/aom_dsp/prob.h b/aom_dsp/prob.h index 782e4b3..86ed3d3 100644 --- a/aom_dsp/prob.h +++ b/aom_dsp/prob.h
@@ -27,6 +27,9 @@ // 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 @@ #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 @@ 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;
diff --git a/av1/common/entropy.c b/av1/common/entropy.c index a3cc11c..ae7b449 100644 --- a/av1/common/entropy.c +++ b/av1/common/entropy.c
@@ -4405,11 +4405,14 @@ 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;