summaryrefslogtreecommitdiff
path: root/libavcodec/put_bits.h
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/put_bits.h')
-rw-r--r--libavcodec/put_bits.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h
index b85e88f28c..1ceb1cc766 100644
--- a/libavcodec/put_bits.h
+++ b/libavcodec/put_bits.h
@@ -119,6 +119,18 @@ static inline void flush_put_bits(PutBitContext *s)
s->bit_buf = 0;
}
+static inline void flush_put_bits_le(PutBitContext *s)
+{
+ while (s->bit_left < 32) {
+ av_assert0(s->buf_ptr < s->buf_end);
+ *s->buf_ptr++ = s->bit_buf;
+ s->bit_buf >>= 8;
+ s->bit_left += 8;
+ }
+ s->bit_left = 32;
+ s->bit_buf = 0;
+}
+
#ifdef BITSTREAM_WRITER_LE
#define avpriv_align_put_bits align_put_bits_unsupported_here
#define avpriv_put_string ff_put_string_unsupported_here
@@ -197,6 +209,34 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value)
s->bit_left = bit_left;
}
+static inline void put_bits_le(PutBitContext *s, int n, unsigned int value)
+{
+ unsigned int bit_buf;
+ int bit_left;
+
+ av_assert2(n <= 31 && value < (1U << n));
+
+ bit_buf = s->bit_buf;
+ bit_left = s->bit_left;
+
+ bit_buf |= value << (32 - bit_left);
+ if (n >= bit_left) {
+ if (3 < s->buf_end - s->buf_ptr) {
+ AV_WL32(s->buf_ptr, bit_buf);
+ s->buf_ptr += 4;
+ } else {
+ av_log(NULL, AV_LOG_ERROR, "Internal error, put_bits buffer too small\n");
+ av_assert2(0);
+ }
+ bit_buf = value >> bit_left;
+ bit_left += 32;
+ }
+ bit_left -= n;
+
+ s->bit_buf = bit_buf;
+ s->bit_left = bit_left;
+}
+
static inline void put_sbits(PutBitContext *pb, int n, int32_t value)
{
av_assert2(n >= 0 && n <= 31);