Allow CDF precision to be configured with CDF_PROB_BITS.
This does not change the precision used for od_ec_enc_bool_q15
(used by aom_write and aom_write_bit), which means these two
paths will use different CDF precision for now.
The test that verifies that q15's code identically to CDFs
is disabled.
Change-Id: I4cd40a60d472eb58f37ac4fda1056b5dfe8b39a5
diff --git a/aom_dsp/entdec.c b/aom_dsp/entdec.c
index 569cef0..0e94804 100644
--- a/aom_dsp/entdec.c
+++ b/aom_dsp/entdec.c
@@ -14,6 +14,7 @@
#endif
#include "aom_dsp/entdec.h"
+#include "aom_dsp/prob.h"
/*A range decoder.
This is an entropy decoder based upon \cite{Mar79}, which is itself a
@@ -171,8 +172,8 @@
/*Decodes a symbol given an inverse cumulative distribution function (CDF)
table in Q15.
- icdf: 32768 minus the CDF, such that symbol s falls in the range
- [s > 0 ? (32768 - icdf[s - 1]) : 0, 32768 - icdf[s]).
+ icdf: CDF_PROB_TOP minus the CDF, such that symbol s falls in the range
+ [s > 0 ? (CDF_PROB_TOP - icdf[s - 1]) : 0, CDF_PROB_TOP - icdf[s]).
The values must be monotonically non-increasing, and icdf[nsyms - 1]
must be 0.
nsyms: The number of symbols in the alphabet.
@@ -191,15 +192,16 @@
const int N = nsyms - 1;
OD_ASSERT(dif >> (OD_EC_WINDOW_SIZE - 16) < r);
- OD_ASSERT(icdf[nsyms - 1] == OD_ICDF(32768U));
+ OD_ASSERT(icdf[nsyms - 1] == OD_ICDF(CDF_PROB_TOP));
OD_ASSERT(32768U <= r);
+ OD_ASSERT(7 - EC_PROB_SHIFT - CDF_SHIFT >= 0);
c = (unsigned)(dif >> (OD_EC_WINDOW_SIZE - 16));
v = r;
ret = -1;
do {
u = v;
v = ((r >> 8) * (uint32_t)(icdf[++ret] >> EC_PROB_SHIFT) >>
- (7 - EC_PROB_SHIFT));
+ (7 - EC_PROB_SHIFT - CDF_SHIFT));
v += EC_MIN_PROB * (N - ret);
} while (c < v);
OD_ASSERT(v < u);