ec_smallmul: Simplify binary read/write.
This should be the same number of operations as the non-ec_smallmul
version (though ideally we'd use the real 15-bit probability
natively).
Encoder output should not change, and all streams should remain
decodable without decoder changes.
Change-Id: I2998a77a02f566cd0c82c415395637acf49b5a97
diff --git a/aom_dsp/daalaboolreader.h b/aom_dsp/daalaboolreader.h
index 29eae48..9ce03c7 100644
--- a/aom_dsp/daalaboolreader.h
+++ b/aom_dsp/daalaboolreader.h
@@ -45,7 +45,11 @@
static INLINE int aom_daala_read(daala_reader *r, int prob) {
int bit;
- int p = ((prob << 15) + (256 - prob)) >> 8;
+#if CONFIG_EC_SMALLMUL
+ int p = (0x7FFFFF - (prob << 15) + prob) >> 8;
+#else
+ int p = ((prob << 15) + 256 - prob) >> 8;
+#endif
#if CONFIG_BITSTREAM_DEBUG
/*{
const int queue_r = bitstream_queue_get_read();
@@ -57,7 +61,7 @@
}*/
#endif
- bit = od_ec_decode_bool_q15(&r->ec, OD_ICDF(p));
+ bit = od_ec_decode_bool_q15(&r->ec, p);
#if CONFIG_BITSTREAM_DEBUG
{
diff --git a/aom_dsp/daalaboolwriter.h b/aom_dsp/daalaboolwriter.h
index c4466fc..00da5a0 100644
--- a/aom_dsp/daalaboolwriter.h
+++ b/aom_dsp/daalaboolwriter.h
@@ -36,7 +36,11 @@
void aom_daala_stop_encode(daala_writer *w);
static INLINE void aom_daala_write(daala_writer *w, int bit, int prob) {
- int p = ((prob << 15) + (256 - prob)) >> 8;
+#if CONFIG_EC_SMALLMUL
+ int p = (0x7FFFFF - (prob << 15) + prob) >> 8;
+#else
+ int p = ((prob << 15) + 256 - prob) >> 8;
+#endif
#if CONFIG_BITSTREAM_DEBUG
aom_cdf_prob cdf[2] = { (aom_cdf_prob)p, 32767 };
/*int queue_r = 0;
@@ -50,7 +54,7 @@
bitstream_queue_push(bit, cdf, 2);
#endif
- od_ec_encode_bool_q15(&w->ec, bit, OD_ICDF(p));
+ od_ec_encode_bool_q15(&w->ec, bit, p);
}
#if CONFIG_RAWBITS