diff mbox series

[FFmpeg-devel,3/8] avcodec/rangecoder: Move refill check out of refill() function

Message ID 20241016194955.3627687-3-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
If the function is not inlined, this is more efficient. Also
it allows calling refill() without the check

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/rangecoder.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/rangecoder.h b/libavcodec/rangecoder.h
index 2248161bca1..da13c453edd 100644
--- a/libavcodec/rangecoder.h
+++ b/libavcodec/rangecoder.h
@@ -112,7 +112,6 @@  static inline void put_rac(RangeCoder *c, uint8_t *const state, int bit)
 
 static inline void refill(RangeCoder *c)
 {
-    if (c->range < 0x100) {
         c->range <<= 8;
         c->low   <<= 8;
         if (c->bytestream < c->bytestream_end) {
@@ -120,7 +119,6 @@  static inline void refill(RangeCoder *c)
             c->bytestream++;
         } else
             c->overread ++;
-    }
 }
 
 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)
     c->range -= range1;
     if (c->low < c->range) {
         *state = c->zero_state[*state];
-        refill(c);
+        if (c->range < 0x100)
+            refill(c);
         return 0;
     } else {
         c->low  -= c->range;
         *state   = c->one_state[*state];
         c->range = range1;
-        refill(c);
+        if (c->range < 0x100)
+            refill(c);
         return 1;
     }
 }