daala_ec: Convert the encoder to use iCDFs
This only changes the internal coding engine. We convert CDFs into
iCDFs at the "bool" writer <-> daala_ec boundary.
Encoder output should not change, and all streams should remain
decodable without decoder changes.
Change-Id: Id3ac7352926497bf6f7bc371ab9bc76e9a3569d5
diff --git a/aom_dsp/entcode.h b/aom_dsp/entcode.h
index b88fd9d..534959e 100644
--- a/aom_dsp/entcode.h
+++ b/aom_dsp/entcode.h
@@ -28,6 +28,16 @@
3 => 1/8th bits.*/
#define OD_BITRES (3)
+/*With CONFIG_EC_SMALLMUL, the value stored in a CDF is 32768 minus the actual
+ Q15 cumulative probability (an "inverse" CDF).
+ This function converts from one representation to the other (and is its own
+ inverse).*/
+#if CONFIG_EC_SMALLMUL
+#define OD_ICDF(x) (32768U - (x))
+#else
+#define OD_ICDF(x) (x)
+#endif
+
/*See entcode.c for further documentation.*/
OD_WARN_UNUSED_RESULT uint32_t od_ec_tell_frac(uint32_t nbits_total,