Go to the documentation of this file.
26 #ifndef AVCODEC_PUT_BITS_H
27 #define AVCODEC_PUT_BITS_H
51 if (buffer_size < 0) {
56 s->size_in_bits = 8 * buffer_size;
58 s->buf_end =
s->buf + buffer_size;
76 s->buf_end =
buffer + buffer_size;
77 s->buf_ptr =
buffer + (
s->buf_ptr -
s->buf);
79 s->size_in_bits = 8 * buffer_size;
87 return (
s->buf_ptr -
s->buf) * 8 + 32 -
s->bit_left;
95 return (
s->buf_end -
s->buf_ptr) * 8 - 32 +
s->bit_left;
103 #ifndef BITSTREAM_WRITER_LE
104 if (
s->bit_left < 32)
105 s->bit_buf <<=
s->bit_left;
107 while (
s->bit_left < 32) {
109 #ifdef BITSTREAM_WRITER_LE
110 *
s->buf_ptr++ =
s->bit_buf;
113 *
s->buf_ptr++ =
s->bit_buf >> 24;
124 while (
s->bit_left < 32) {
126 *
s->buf_ptr++ =
s->bit_buf;
134 #ifdef BITSTREAM_WRITER_LE
135 #define avpriv_align_put_bits align_put_bits_unsupported_here
136 #define avpriv_put_string ff_put_string_unsupported_here
137 #define avpriv_copy_bits avpriv_copy_bits_unsupported_here
150 int terminate_string);
166 unsigned int bit_buf;
171 bit_buf =
s->bit_buf;
172 bit_left =
s->bit_left;
175 #ifdef BITSTREAM_WRITER_LE
176 bit_buf |=
value << (32 - bit_left);
178 if (3 <
s->buf_end -
s->buf_ptr) {
185 bit_buf =
value >> bit_left;
191 bit_buf = (bit_buf <<
n) |
value;
194 bit_buf <<= bit_left;
195 bit_buf |=
value >> (
n - bit_left);
196 if (3 <
s->buf_end -
s->buf_ptr) {
208 s->bit_buf = bit_buf;
209 s->bit_left = bit_left;
214 unsigned int bit_buf;
219 bit_buf =
s->bit_buf;
220 bit_left =
s->bit_left;
222 bit_buf |=
value << (32 - bit_left);
224 if (3 <
s->buf_end -
s->buf_ptr) {
231 bit_buf =
value >> bit_left;
236 s->bit_buf = bit_buf;
237 s->bit_left = bit_left;
252 unsigned int bit_buf;
255 bit_buf =
s->bit_buf;
256 bit_left =
s->bit_left;
258 #ifdef BITSTREAM_WRITER_LE
259 bit_buf |=
value << (32 - bit_left);
260 if (3 <
s->buf_end -
s->buf_ptr) {
267 bit_buf = (uint64_t)
value >> bit_left;
269 bit_buf = (uint64_t)bit_buf << bit_left;
270 bit_buf |=
value >> (32 - bit_left);
271 if (3 <
s->buf_end -
s->buf_ptr) {
281 s->bit_buf = bit_buf;
282 s->bit_left = bit_left;
297 uint32_t lo =
value & 0xffffffff;
298 uint32_t hi =
value >> 32;
299 #ifdef BITSTREAM_WRITER_LE
307 uint32_t lo =
value & 0xffffffff;
308 uint32_t hi =
value >> 32;
309 #ifdef BITSTREAM_WRITER_LE
349 s->buf_ptr -= 4 * (
s->bit_left >> 5);
361 s->buf_end =
s->buf +
size;
362 s->size_in_bits = 8*
size;
static void put_bits_le(PutBitContext *s, int n, unsigned int value)
static void av_unused put_bits32(PutBitContext *s, uint32_t value)
Write exactly 32 bits into a bitstream.
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_bits64(PutBitContext *s, int n, uint64_t value)
Write up to 64 bits into a bitstream.
static int put_bits_left(PutBitContext *s)
void avpriv_align_put_bits(PutBitContext *s)
Pad the bitstream with zeros up to the next byte boundary.
static void put_bits(PutBitContext *s, int n, unsigned int value)
Write up to 31 bits into a bitstream.
#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 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)
Copy the content of src to the bitstream.
void avpriv_put_string(PutBitContext *pb, const char *string, int terminate_string)
Put the string string in the bitstream.
#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.