26#ifndef AVCODEC_PUT_BITS_H
27#define AVCODEC_PUT_BITS_H
40#define AV_WBBUF AV_WB64
41#define AV_WLBUF AV_WL64
45#define AV_WBBUF AV_WB32
46#define AV_WLBUF AV_WL32
65 if (buffer_size < 0) {
71 s->buf_end =
s->buf + buffer_size;
92 return (
s->buf_ptr -
s->buf) * 8 +
BUF_BITS -
s->bit_left;
102 return s->buf_ptr -
s->buf;
112 return s->buf_ptr -
s->buf + ((
BUF_BITS -
s->bit_left + (round_up ? 7 : 0)) >> 3);
127 s->buf_end =
buffer + buffer_size;
128 s->buf_ptr =
buffer + (
s->buf_ptr -
s->buf);
137 return (
s->buf_end -
s->buf_ptr) * 8 -
BUF_BITS +
s->bit_left;
147 return s->buf_end -
s->buf_ptr - ((
BUF_BITS -
s->bit_left + (round_up ? 7 : 0)) >> 3);
155#ifndef BITSTREAM_WRITER_LE
157 s->bit_buf <<=
s->bit_left;
161#ifdef BITSTREAM_WRITER_LE
162 *
s->buf_ptr++ =
s->bit_buf;
178 *
s->buf_ptr++ =
s->bit_buf;
186#ifdef BITSTREAM_WRITER_LE
187#define ff_put_string ff_put_string_unsupported_here
188#define ff_copy_bits ff_copy_bits_unsupported_here
197 int terminate_string);
212 bit_buf =
s->bit_buf;
213 bit_left =
s->bit_left;
216#ifdef BITSTREAM_WRITER_LE
219 if (
s->buf_end -
s->buf_ptr >=
sizeof(
BitBuf)) {
226 bit_buf =
value >> bit_left;
232 bit_buf = (bit_buf << n) |
value;
235 bit_buf <<= bit_left;
236 bit_buf |=
value >> (n - bit_left);
237 if (
s->buf_end -
s->buf_ptr >=
sizeof(
BitBuf)) {
249 s->bit_buf = bit_buf;
250 s->bit_left = bit_left;
270 bit_buf =
s->bit_buf;
271 bit_left =
s->bit_left;
275 if (
s->buf_end -
s->buf_ptr >=
sizeof(
BitBuf)) {
282 bit_buf =
value >> bit_left;
287 s->bit_buf = bit_buf;
288 s->bit_left = bit_left;
311 bit_buf =
s->bit_buf;
312 bit_left =
s->bit_left;
314#ifdef BITSTREAM_WRITER_LE
316 if (
s->buf_end -
s->buf_ptr >=
sizeof(
BitBuf)) {
323 bit_buf = (uint64_t)
value >> bit_left;
325 bit_buf = (uint64_t)bit_buf << bit_left;
327 if (
s->buf_end -
s->buf_ptr >=
sizeof(
BitBuf)) {
337 s->bit_buf = bit_buf;
338 s->bit_left = bit_left;
356 uint32_t lo =
value & 0xffffffff;
357 uint32_t hi =
value >> 32;
358#ifdef BITSTREAM_WRITER_LE
379 uint32_t lo =
value & 0xffffffff;
380 uint32_t hi =
value >> 32;
381#ifdef BITSTREAM_WRITER_LE
439 s->buf_end =
s->buf +
size;
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
common internal and external API header
static const uint8_t bits[8]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static void put_sbits(PutBitContext *pb, int n, int32_t value)
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static void put_bits_le(PutBitContext *s, int n, BitBuf value)
static void rebase_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Rebase the bit writer onto a reallocated buffer.
static void flush_put_bits_le(PutBitContext *s)
static void set_put_bits_buffer_size(PutBitContext *s, int size)
Change the end of the buffer.
static void put_bits64(PutBitContext *s, int n, uint64_t value)
Write up to 64 bits into a bitstream.
static void skip_put_bits(PutBitContext *s, int n)
Skip the given number of bits.
static int put_bits_count(PutBitContext *s)
static void put_bits_no_assert(PutBitContext *s, int n, BitBuf value)
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
static int put_bytes_count(const PutBitContext *s, int round_up)
static int put_bits_left(PutBitContext *s)
static void put_sbits63(PutBitContext *pb, int n, int64_t value)
static int put_bytes_left(const PutBitContext *s, int round_up)
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static void put_bits63(PutBitContext *s, int n, uint64_t value)
Write up to 63 bits into a bitstream.
static int put_bytes_output(const PutBitContext *s)
void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length)
Copy the content of src to the bitstream.
static void skip_put_bytes(PutBitContext *s, int n)
Skip the given number of bytes.
static av_unused void put_bits32(PutBitContext *s, uint32_t value)
Write exactly 32 bits into a bitstream.
static void align_put_bits(PutBitContext *s)
Pad the bitstream with zeros up to the next byte boundary.
static void put_bits(PutBitContext *s, int n, BitBuf value)
Write up to 31 bits into a bitstream.
static void put_bits_assume_flushed(const PutBitContext *s)
Inform the compiler that a PutBitContext is flushed (i.e.
void ff_put_string(PutBitContext *pb, const char *string, int terminate_string)
Put the string string in the bitstream.