diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-09-29 05:42:24 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-09-29 15:22:37 +0200 |
commit | cf32181b70116309b3a33c8f6bf017a0d0a33089 (patch) | |
tree | 7bf54abd0ed58c3624c5a19b5dfc8fd53a9f0f5d | |
parent | 8ba694548782c1821ab119c18fe02360a81c6768 (diff) | |
download | ffmpeg-cf32181b70116309b3a33c8f6bf017a0d0a33089.tar.gz |
avcodec/put_bits: Add rebase_put_bits()
Reviewed-by: Benoit Fouet <benoit.fouet@free.fr>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/put_bits.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h index 8081fb9ea5..8858caaacc 100644 --- a/libavcodec/put_bits.h +++ b/libavcodec/put_bits.h @@ -63,6 +63,24 @@ static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, } /** + * Rebase the bit writer onto a reallocated buffer. + * + * @param buffer the buffer where to put bits + * @param buffer_size the size in bytes of buffer, + * must be larger than the previous size + */ +static inline void rebase_put_bits(PutBitContext *s, uint8_t *buffer, + int buffer_size) +{ + av_assert0(8*buffer_size > s->size_in_bits); + + s->buf_end = buffer + buffer_size; + s->buf_ptr = buffer + (s->buf_ptr - s->buf); + s->buf = buffer; + s->size_in_bits = 8 * buffer_size; +} + +/** * @return the total number of bits written to the bitstream. */ static inline int put_bits_count(PutBitContext *s) |