Commit bff32ac0 authored by Alex Converse's avatar Alex Converse

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
parent 3e42acd4
......@@ -73,10 +73,11 @@ static INLINE int rabs_read(struct AnsDecoder *ans, AnsP8 p0) {
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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment