Simplify rabs_read()
This is branchless on newer gcc and clang and is about 1% faster overall
at cq-level=16 frame-parallel=1.
Change-Id: I7f5608ab0f0abbc29aa3419a103addf945ea9f0a
diff --git a/aom_dsp/ansreader.h b/aom_dsp/ansreader.h
index fcd9ca9..78db99d 100644
--- a/aom_dsp/ansreader.h
+++ b/aom_dsp/ansreader.h
@@ -73,10 +73,11 @@
const unsigned quotient = state / ANS_P8_PRECISION;
const unsigned remainder = state % ANS_P8_PRECISION;
const int value = remainder >= p0;
+ const unsigned qp0 = quotient * p0;
if (value)
- state = quotient * (ANS_P8_PRECISION - p0) + remainder - p0;
+ state = state - qp0 - p0;
else
- state = quotient * p0 + remainder;
+ state = qp0 + remainder;
ans->state = state;
return value;
}