aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2024-10-16 21:20:42 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2024-12-02 03:14:47 +0100
commitb2da4c33e31f85b9c755f2cdb08f5db694e90ca9 (patch)
tree97345a451afaa61741362ad93dc89dd865f11c41
parent18922f4ae3d45ee1dd51abc2832cca1c8ad5c2f9 (diff)
downloadffmpeg-b2da4c33e31f85b9c755f2cdb08f5db694e90ca9.tar.gz
avcodec/rangecoder: eliminate main branch from renorm_encoder()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/rangecoder.h13
1 files changed, 4 insertions, 9 deletions
diff --git a/libavcodec/rangecoder.h b/libavcodec/rangecoder.h
index cdd99eff56..15217a99a3 100644
--- a/libavcodec/rangecoder.h
+++ b/libavcodec/rangecoder.h
@@ -61,17 +61,12 @@ void ff_build_rac_states(RangeCoder *c, int factor, int max_p);
static inline void renorm_encoder(RangeCoder *c)
{
- // FIXME: optimize
- if (c->low <= 0xFF00) {
- *c->bytestream = c->outstanding_byte;
+ if (c->low - 0xFF01 >= 0x10000 - 0xFF01U) {
+ int mask = c->low - 0xFF01 >> 31;
+ *c->bytestream = c->outstanding_byte + 1 + mask;
c->bytestream += c->outstanding_byte >= 0;
for (; c->outstanding_count; c->outstanding_count--)
- *c->bytestream++ = 0xFF;
- c->outstanding_byte = c->low >> 8;
- } else if (c->low >= 0x10000) {
- *c->bytestream++ = c->outstanding_byte + 1;
- for (; c->outstanding_count; c->outstanding_count--)
- *c->bytestream++ = 0x00;
+ *c->bytestream++ = mask;
c->outstanding_byte = c->low >> 8;
} else {
c->outstanding_count++;