aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/rangecoder.h
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2024-10-16 14:39:20 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2024-10-24 23:01:14 +0200
commitd147b3d7ecba2bd40cb45284f920238da97a95ee (patch)
treeeedd9175c08795404d561cfb1d8c2d9f271c94b2 /libavcodec/rangecoder.h
parent67adb303228a5d8e2abe860b7748004cc83ca65f (diff)
downloadffmpeg-d147b3d7ecba2bd40cb45284f920238da97a95ee.tar.gz
avcodec/rangecoder: only perform renorm check/loop for callers that need it
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/rangecoder.h')
-rw-r--r--libavcodec/rangecoder.h5
1 files changed, 2 insertions, 3 deletions
diff --git a/libavcodec/rangecoder.h b/libavcodec/rangecoder.h
index 89d178ac31..110908d6bd 100644
--- a/libavcodec/rangecoder.h
+++ b/libavcodec/rangecoder.h
@@ -62,7 +62,6 @@ void ff_build_rac_states(RangeCoder *c, int factor, int max_p);
static inline void renorm_encoder(RangeCoder *c)
{
// FIXME: optimize
- while (c->range < 0x100) {
if (c->outstanding_byte < 0) {
c->outstanding_byte = c->low >> 8;
} else if (c->low <= 0xFF00) {
@@ -81,7 +80,6 @@ static inline void renorm_encoder(RangeCoder *c)
c->low = (c->low & 0xFF) << 8;
c->range <<= 8;
- }
}
static inline int get_rac_count(RangeCoder *c)
@@ -108,7 +106,8 @@ static inline void put_rac(RangeCoder *c, uint8_t *const state, int bit)
*state = c->one_state[*state];
}
- renorm_encoder(c);
+ while (c->range < 0x100)
+ renorm_encoder(c);
}
static inline void refill(RangeCoder *c)