diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2024-05-24 16:33:47 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2025-05-21 12:02:25 +0200 |
commit | 4484e9b37307116647a2bd5b202cbff90c8e3cfc (patch) | |
tree | f03620c9e990d7d1b27a28f08ab36744d91f44b9 | |
parent | 988e319b406be8d91a9097b141ef5fc30dc69d01 (diff) | |
download | ffmpeg-4484e9b37307116647a2bd5b202cbff90c8e3cfc.tar.gz |
avcodec/put_bits: Allow to mark places where PutBitContext is flushed
This will allow the compiler to optimize the "is the cache full?"
branches away from some put_bits().
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r-- | libavcodec/put_bits.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h index 56c3f4cc6d..c3eee622d4 100644 --- a/libavcodec/put_bits.h +++ b/libavcodec/put_bits.h @@ -75,6 +75,16 @@ static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, } /** + * Inform the compiler that a PutBitContext is flushed (i.e. if it has just + * been initialized or flushed). Undefined behaviour occurs if this is used + * with a PutBitContext for which this is not true. + */ +static inline void put_bits_assume_flushed(const PutBitContext *s) +{ + av_assume(s->bit_left == BUF_BITS); +} + +/** * @return the total number of bits written to the bitstream. */ static inline int put_bits_count(PutBitContext *s) |