aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/put_bits.h
diff options
context:
space:
mode:
authorCarl Eugen Hoyos <ceffmpeg@gmail.com>2017-08-18 20:57:54 +0200
committerCarl Eugen Hoyos <ceffmpeg@gmail.com>2017-08-21 16:19:58 +0200
commit898ea658c8a46a105bcf831691a9aad3bb0f606d (patch)
treedb51f0d1344923d97683ad12f75b29a2ef6fd9e3 /libavcodec/put_bits.h
parent8754ccd3b319fdf4e2beed5657a3e327999c64ce (diff)
downloadffmpeg-898ea658c8a46a105bcf831691a9aad3bb0f606d.tar.gz
lavc/g726: Add a little-endian G.726 encoder.
Fixes ticket #6596.
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);