diff mbox series

[FFmpeg-devel,4/8] avcodec/rangecoder: Avoid checking for the first byte on every renormalization

Message ID 20241016194955.3627687-4-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/8] avcodec/rangecoder: only perform renorm check/loop for callers that need it | expand

Commit Message

Michael Niedermayer Oct. 16, 2024, 7:49 p.m. UTC
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/rangecoder.h | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/rangecoder.h b/libavcodec/rangecoder.h
index da13c453edd..944ad492fda 100644
--- a/libavcodec/rangecoder.h
+++ b/libavcodec/rangecoder.h
@@ -62,10 +62,9 @@  void ff_build_rac_states(RangeCoder *c, int factor, int max_p);
 static inline void renorm_encoder(RangeCoder *c)
 {
     // FIXME: optimize
-        if (c->outstanding_byte < 0) {
-            c->outstanding_byte = c->low >> 8;
-        } else if (c->low <= 0xFF00) {
-            *c->bytestream++ = c->outstanding_byte;
+        if (c->low <= 0xFF00) {
+            *c->bytestream = c->outstanding_byte;
+            c->bytestream += c->outstanding_byte >= 0;
             for (; c->outstanding_count; c->outstanding_count--)
                 *c->bytestream++ = 0xFF;
             c->outstanding_byte = c->low >> 8;