diff options
-rw-r--r-- | libavcodec/put_bits.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h index cd66a82a44..e8bc86a82c 100644 --- a/libavcodec/put_bits.h +++ b/libavcodec/put_bits.h @@ -86,6 +86,26 @@ static inline int put_bits_count(PutBitContext *s) } /** + * @return the number of bytes output so far; may only be called + * when the PutBitContext is freshly initialized or flushed. + */ +static inline int put_bytes_output(const PutBitContext *s) +{ + av_assert2(s->bit_left == BUF_BITS); + return s->buf_ptr - s->buf; +} + +/** + * @param round_up When set, the number of bits written so far will be + * rounded up to the next byte. + * @return the number of bytes output so far. + */ +static inline int put_bytes_count(const PutBitContext *s, int round_up) +{ + return s->buf_ptr - s->buf + ((BUF_BITS - s->bit_left + (round_up ? 7 : 0)) >> 3); +} + +/** * Rebase the bit writer onto a reallocated buffer. * * @param buffer the buffer where to put bits @@ -112,6 +132,16 @@ static inline int put_bits_left(PutBitContext* s) } /** + * @param round_up When set, the number of bits written will be + * rounded up to the next byte. + * @return the number of bytes left. + */ +static inline int put_bytes_left(const PutBitContext *s, int round_up) +{ + return s->buf_end - s->buf_ptr - ((BUF_BITS - s->bit_left + (round_up ? 7 : 0)) >> 3); +} + +/** * Pad the end of the output stream with zeros. */ static inline void flush_put_bits(PutBitContext *s) |