Re: [FFmpeg-devel] [PATCH 1/3] avcodec/put_bits: Relax requirements to rebase PutBitContext

2019-11-16 Thread Michael Niedermayer
On Sat, Nov 16, 2019 at 06:24:29AM +0100, Andreas Rheinhardt wrote:
> 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 
> ---
>  libavcodec/put_bits.h | 20 ++--
>  1 file changed, 10 insertions(+), 10 deletions(-)

will apply

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
then the original author, trying to rewrite it will not make it better.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/3] avcodec/put_bits: Relax requirements to rebase PutBitContext

2019-11-15 Thread Andreas Rheinhardt
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 
---
 libavcodec/put_bits.h | 20 ++--
 1 file 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
@@ -61,17 +61,25 @@ static inline void init_put_bits(PutBitContext *s, uint8_t 
*buffer,
 s->bit_buf  = 0;
 }
 
+/**
+ * @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);
@@ -79,14 +87,6 @@ static inline void rebase_put_bits(PutBitContext *s, uint8_t 
*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)
-{
-return (s->buf_ptr - s->buf) * 8 + 32 - s->bit_left;
-}
-
 /**
  * @return the number of bits available in the bitstream.
  */
-- 
2.20.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".