On 1/30/2024 6:53 PM, Andreas Rheinhardt wrote:
James Almer:
Signed-off-by: James Almer <jamr...@gmail.com>
---
  libavcodec/put_bits.h | 16 ++++++++++++++++
  1 file changed, 16 insertions(+)

diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h
index 4561dc131a..04dedd3342 100644
--- a/libavcodec/put_bits.h
+++ b/libavcodec/put_bits.h
@@ -370,6 +370,22 @@ static inline void put_sbits63(PutBitContext *pb, int n, 
int64_t value)
      put_bits64(pb, n, (uint64_t)(value) & (~(UINT64_MAX << n)));
  }
+static inline void put_leb(PutBitContext *s, unsigned value)
+{
+    int len;
+    uint8_t byte;
+
+    len = (av_log2(value) + 7) / 7;
+
+    for (int i = 0; i < len; i++) {
+        byte = value >> (7 * i) & 0x7f;
+        if (i < len - 1)
+            byte |= 0x80;
+
+        put_bits_no_assert(s, 8, byte);
+    }
+}
+
  /**
   * Return the pointer to the byte where the bitstream writer will put
   * the next bit.

This function does use any internals of PutBitContext and should
therefore be in user-code. In fact, get_leb() should not exist in
get_bits.h.

You could say the same about skip_1stop_8data_bits(), decode210(), decode012() and get_vlc_multi().

And the idea is to have these be reusable. leb is evidently going to be used by anything AOMedia will make.
_______________________________________________
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".

Reply via email to