Go to the documentation of this file.
26 #ifndef AVCODEC_PUT_BITS_H
27 #define AVCODEC_PUT_BITS_H
39 #define AV_WBBUF AV_WB32
40 #define AV_WLBUF AV_WL32
60 if (buffer_size < 0) {
65 s->size_in_bits = 8 * buffer_size;
67 s->buf_end =
s->buf + buffer_size;
78 return (
s->buf_ptr -
s->buf) * 8 +
BUF_BITS -
s->bit_left;
93 s->buf_end =
buffer + buffer_size;
94 s->buf_ptr =
buffer + (
s->buf_ptr -
s->buf);
96 s->size_in_bits = 8 * buffer_size;
104 return (
s->buf_end -
s->buf_ptr) * 8 -
BUF_BITS +
s->bit_left;
112 #ifndef BITSTREAM_WRITER_LE
114 s->bit_buf <<=
s->bit_left;
118 #ifdef BITSTREAM_WRITER_LE
119 *
s->buf_ptr++ =
s->bit_buf;
135 *
s->buf_ptr++ =
s->bit_buf;
143 #if FF_API_AVPRIV_PUT_BITS
148 #ifdef BITSTREAM_WRITER_LE
149 #define ff_put_string ff_put_string_unsupported_here
150 #define ff_copy_bits ff_copy_bits_unsupported_here
159 int terminate_string);
174 bit_buf =
s->bit_buf;
175 bit_left =
s->bit_left;
178 #ifdef BITSTREAM_WRITER_LE
181 if (
s->buf_end -
s->buf_ptr >=
sizeof(
BitBuf)) {
188 bit_buf =
value >> bit_left;
194 bit_buf = (bit_buf << n) |
value;
197 bit_buf <<= bit_left;
198 bit_buf |=
value >> (n - bit_left);
199 if (
s->buf_end -
s->buf_ptr >=
sizeof(
BitBuf)) {
211 s->bit_buf = bit_buf;
212 s->bit_left = bit_left;
232 bit_buf =
s->bit_buf;
233 bit_left =
s->bit_left;
237 if (
s->buf_end -
s->buf_ptr >=
sizeof(
BitBuf)) {
244 bit_buf =
value >> bit_left;
249 s->bit_buf = bit_buf;
250 s->bit_left = bit_left;
273 bit_buf =
s->bit_buf;
274 bit_left =
s->bit_left;
276 #ifdef BITSTREAM_WRITER_LE
278 if (
s->buf_end -
s->buf_ptr >=
sizeof(
BitBuf)) {
285 bit_buf = (uint64_t)
value >> bit_left;
287 bit_buf = (uint64_t)bit_buf << bit_left;
289 if (
s->buf_end -
s->buf_ptr >=
sizeof(
BitBuf)) {
299 s->bit_buf = bit_buf;
300 s->bit_left = bit_left;
315 uint32_t lo =
value & 0xffffffff;
316 uint32_t hi =
value >> 32;
317 #ifdef BITSTREAM_WRITER_LE
325 uint32_t lo =
value & 0xffffffff;
326 uint32_t hi =
value >> 32;
327 #ifdef BITSTREAM_WRITER_LE
379 s->buf_end =
s->buf +
size;
380 s->size_in_bits = 8*
size;
static void av_unused 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_sbits(PutBitContext *pb, int n, int32_t value)
void ff_put_string(PutBitContext *pb, const char *string, int terminate_string)
Put the string string in the bitstream.
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static const int BUF_BITS
static void put_bits64(PutBitContext *s, int n, uint64_t value)
Write up to 64 bits into a bitstream.
void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length)
Copy the content of src to the bitstream.
static int put_bits_left(PutBitContext *s)
void avpriv_align_put_bits(PutBitContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static void rebase_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Rebase the bit writer onto a reallocated buffer.
static void skip_put_bits(PutBitContext *s, int n)
Skip the given number of bits.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static void flush_put_bits_le(PutBitContext *s)
static void put_bits(PutBitContext *s, int n, BitBuf value)
Write up to 31 bits into a bitstream.
static void set_put_bits_buffer_size(PutBitContext *s, int size)
Change the end of the buffer.
void avpriv_copy_bits(PutBitContext *pb, const uint8_t *src, int length)
static void put_bits_no_assert(PutBitContext *s, int n, BitBuf value)
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
static int put_bits_count(PutBitContext *s)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
static void skip_put_bytes(PutBitContext *s, int n)
Skip the given number of bytes.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static void put_bits_le(PutBitContext *s, int n, BitBuf value)