[FFmpeg-devel] [PATCH 2/3] avcodec/put_bits: Add rebase_put_bits()

Michael Niedermayer michaelni at gmx.at
Mon Sep 29 05:56:00 CEST 2014


Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavcodec/put_bits.h |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h
index 8081fb9..f16d04a 100644
--- a/libavcodec/put_bits.h
+++ b/libavcodec/put_bits.h
@@ -63,6 +63,23 @@ static inline void init_put_bits(PutBitContext *s, uint8_t *buffer,
 }
 
 /**
+ * Rebase the bit writer onto a reallocted buffer.
+ *
+ * @param buffer the buffer where to put bits
+ * @param buffer_size the size in bytes of buffer
+ */
+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)
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list