aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2019-11-16 06:24:29 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2019-11-16 20:57:45 +0100
commit27522fb64c43e06486261ca9359a1de929b7d2f3 (patch)
tree0a3c2c381325246df5fc948fa3f5e3352ff5eced
parent57db9f488f73fa58512101f0d5399de79a60b984 (diff)
downloadffmpeg-27522fb64c43e06486261ca9359a1de929b7d2f3.tar.gz
avcodec/put_bits: Relax requirements to rebase PutBitContext
The earlier requirement was for the new buffer to be bigger than the old one. This has been relaxed to only demand that the new buffer can hold all the data written so far. This is in preparation for further commits. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/put_bits.h20
1 files changed, 10 insertions, 10 deletions
diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h
index 1ceb1cc766..7d11a3576a 100644
--- a/libavcodec/put_bits.h
+++ b/libavcodec/put_bits.h
@@ -62,16 +62,24 @@ static inline void init_put_bits(PutBitContext *s, uint8_t *buffer,
}
/**
+ * @return the total number of bits written to the bitstream.
+ */
+static inline int put_bits_count(PutBitContext *s)
+{
+ return (s->buf_ptr - s->buf) * 8 + 32 - s->bit_left;
+}
+
+/**
* 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
+ * must be large enough to hold everything written so far
*/
static inline void rebase_put_bits(PutBitContext *s, uint8_t *buffer,
int buffer_size)
{
- av_assert0(8*buffer_size > s->size_in_bits);
+ av_assert0(8*buffer_size >= put_bits_count(s));
s->buf_end = buffer + buffer_size;
s->buf_ptr = buffer + (s->buf_ptr - s->buf);
@@ -80,14 +88,6 @@ static inline void rebase_put_bits(PutBitContext *s, uint8_t *buffer,
}
/**
- * @return the total number of bits written to the bitstream.
- */
-static inline int put_bits_count(PutBitContext *s)
-{
- return (s->buf_ptr - s->buf) * 8 + 32 - s->bit_left;
-}
-
-/**
* @return the number of bits available in the bitstream.
*/
static inline int put_bits_left(PutBitContext* s)