If the function is not inlined, this is more efficient. Also it allows calling refill() without the check
Unified · Split
| @@ -112,7 +112,6 @@ static inline void put_rac(RangeCoder *c, uint8_t *const state, int bit) · 111 unmodified lines | ||
| 112 | 112 | |
| 113 | 113 | static inline void refill(RangeCoder *c) |
| 114 | 114 | { |
| 115 | − if (c->range < 0x100) { | |
| 116 | 115 | c->range <<= 8; |
| 117 | 116 | c->low <<= 8; |
| 118 | 117 | if (c->bytestream < c->bytestream_end) { |
| @@ -120,7 +119,6 @@ static inline void refill(RangeCoder *c) · 1 unmodified line | ||
| 120 | 119 | c->bytestream++; |
| 121 | 120 | } else |
| 122 | 121 | c->overread ++; |
| 123 | − } | |
| 124 | 122 | } |
| 125 | 123 | |
| 126 | 124 | static inline int get_rac(RangeCoder *c, uint8_t *const state) |
| @@ -130,13 +128,15 @@ static inline int get_rac(RangeCoder *c, uint8_t *const state) · 3 unmodified lines | ||
| 130 | 128 | c->range -= range1; |
| 131 | 129 | if (c->low < c->range) { |
| 132 | 130 | *state = c->zero_state[*state]; |
| 133 | − refill(c); | |
| 131 | + if (c->range < 0x100) | |
| 132 | + refill(c); | |
| 134 | 133 | return 0; |
| 135 | 134 | } else { |
| 136 | 135 | c->low -= c->range; |
| 137 | 136 | *state = c->one_state[*state]; |
| 138 | 137 | c->range = range1; |
| 139 | − refill(c); | |
| 138 | + if (c->range < 0x100) | |
| 139 | + refill(c); | |
| 140 | 140 | return 1; |
| 141 | 141 | } |
| 142 | 142 | } |