GstBitWriter
GstBitWriter provides a bit writer that can write any number of bits into a memory buffer. It provides functions for writing any number of bits into 8, 16, 32 and 64 bit variables.
Methods
gst_bit_writer_align_bytes
gboolean gst_bit_writer_align_bytes (GstBitWriter * bitwriter, guint8 trailing_bit)
Write trailing bit to align last byte of data. trailing_bit can only be 1 or 0.
gst_bit_writer_free
gst_bit_writer_free (GstBitWriter * bitwriter)
Frees bitwriter and the allocated data inside.
Parameters:
bitwriter
(
[in][transfer: full])
–
GstBitWriter instance
gst_bit_writer_free_and_get_buffer
GstBuffer * gst_bit_writer_free_and_get_buffer (GstBitWriter * bitwriter)
Frees bitwriter without destroying the internal data, which is returned as GstBuffer.
Free-function: gst_buffer_unref
Parameters:
bitwriter
(
[in][transfer: full])
–
GstBitWriter instance
a new allocated GstBuffer wrapping the data inside. gst_buffer_unref after usage.
gst_bit_writer_free_and_get_data
guint8 * gst_bit_writer_free_and_get_data (GstBitWriter * bitwriter)
Frees bitwriter without destroying the internal data, which is returned.
Free-function: g_free
Parameters:
bitwriter
(
[in][transfer: full])
–
GstBitWriter instance
the current data. g_free after usage.
gst_bit_writer_get_data
guint8 * gst_bit_writer_get_data (const GstBitWriter * bitwriter)
Get written data pointer
Parameters:
bitwriter
–
a GstBitWriter instance
data pointer
gst_bit_writer_get_remaining
guint gst_bit_writer_get_remaining (const GstBitWriter * bitwriter)
Parameters:
bitwriter
–
gst_bit_writer_get_size
guint gst_bit_writer_get_size (const GstBitWriter * bitwriter)
Get size of written data
Parameters:
bitwriter
–
a GstBitWriter instance
size of bits written in data
gst_bit_writer_init
gst_bit_writer_init (GstBitWriter * bitwriter)
Initializes bitwriter to an empty instance.
Parameters:
bitwriter
–
GstBitWriter instance
gst_bit_writer_init_with_data
gst_bit_writer_init_with_data (GstBitWriter * bitwriter, guint8 * data, guint size, gboolean initialized)
Initializes bitwriter with the given memory area data. IF initialized is TRUE it is possible to read size bits from the GstBitWriter from the beginning.
Parameters:
bitwriter
–
GstBitWriter instance
data
(
[arraylength=size][transfer: none])
–
Memory area for writing
size
–
Size of data in bytes
initialized
–
If TRUE the complete data can be read from the beginning
gst_bit_writer_init_with_size
gst_bit_writer_init_with_size (GstBitWriter * bitwriter, guint32 size, gboolean fixed)
Initializes a GstBitWriter instance and allocates the given data size.
Parameters:
bitwriter
–
GstBitWriter instance
size
–
the size on bytes to allocate for data
fixed
–
If TRUE the data can't be reallocated
gst_bit_writer_put_bits_uint16
gboolean gst_bit_writer_put_bits_uint16 (GstBitWriter * bitwriter, guint16 value, guint nbits)
Write nbits bits of value to GstBitWriter.
Parameters:
bitwriter
–
a GstBitWriter instance
value
–
value of guint16 to write
nbits
–
number of bits to write
gst_bit_writer_put_bits_uint32
gboolean gst_bit_writer_put_bits_uint32 (GstBitWriter * bitwriter, guint32 value, guint nbits)
Write nbits bits of value to GstBitWriter.
Parameters:
bitwriter
–
a GstBitWriter instance
value
–
value of guint32 to write
nbits
–
number of bits to write
gst_bit_writer_put_bits_uint64
gboolean gst_bit_writer_put_bits_uint64 (GstBitWriter * bitwriter, guint64 value, guint nbits)
Write nbits bits of value to GstBitWriter.
Parameters:
bitwriter
–
a GstBitWriter instance
value
–
value of guint64 to write
nbits
–
number of bits to write
gst_bit_writer_put_bits_uint8
gboolean gst_bit_writer_put_bits_uint8 (GstBitWriter * bitwriter, guint8 value, guint nbits)
Write nbits bits of value to GstBitWriter.
Parameters:
bitwriter
–
a GstBitWriter instance
value
–
value of guint8 to write
nbits
–
number of bits to write
gst_bit_writer_put_bytes
gboolean gst_bit_writer_put_bytes (GstBitWriter * bitwriter, const guint8 * data, guint nbytes)
Write nbytes bytes of data to GstBitWriter.
Parameters:
bitwriter
–
a GstBitWriter instance
data
(
[array])
–
pointer of data to write
nbytes
–
number of bytes to write
gst_bit_writer_reset
gst_bit_writer_reset (GstBitWriter * bitwriter)
Resets bitwriter and frees the data if it's owned by bitwriter.
Parameters:
bitwriter
–
GstBitWriter instance
gst_bit_writer_reset_and_get_buffer
GstBuffer * gst_bit_writer_reset_and_get_buffer (GstBitWriter * bitwriter)
Resets bitwriter and returns the current data as GstBuffer.
Free-function: gst_buffer_unref
Parameters:
bitwriter
–
a GstBitWriter instance
a new allocated GstBuffer wrapping the current data. gst_buffer_unref after usage.
gst_bit_writer_reset_and_get_data
guint8 * gst_bit_writer_reset_and_get_data (GstBitWriter * bitwriter)
Resets bitwriter and returns the current data.
Free-function: g_free
Parameters:
bitwriter
–
a GstBitWriter instance
the current data. g_free after usage.
gst_bit_writer_set_pos
gboolean gst_bit_writer_set_pos (GstBitWriter * bitwriter, guint pos)
Parameters:
bitwriter
–
pos
–
Functions
gst_bit_writer_new
GstBitWriter * gst_bit_writer_new ()
Creates a new, empty GstBitWriter instance.
Free-function: gst_bit_writer_free
a new, empty GstByteWriter instance
gst_bit_writer_new_with_data
GstBitWriter * gst_bit_writer_new_with_data (guint8 * data, guint size, gboolean initialized)
Creates a new GstBitWriter instance with the given memory area. If initialized is TRUE it is possible to read size bits from the GstBitWriter from the beginning.
Free-function: gst_bit_writer_free
Parameters:
data
(
[arraylength=size][transfer: none])
–
Memory area for writing
size
–
Size of data in bytes
initialized
–
if TRUE the complete data can be read from the beginning
a new GstBitWriter instance
gst_bit_writer_new_with_size
GstBitWriter * gst_bit_writer_new_with_size (guint32 size, gboolean fixed)
Creates a GstBitWriter instance with the given initial data size.
Free-function: gst_bit_writer_free
a new GstBitWriter instance
Function Macros
__GST_BIT_WRITER_WRITE_BITS_INLINE
#define __GST_BIT_WRITER_WRITE_BITS_INLINE(bits) \ static inline gboolean \ _gst_bit_writer_put_bits_uint##bits##_inline( \ GstBitWriter *bitwriter, \ guint##bits value, \ guint nbits \ ) \ { \ g_return_val_if_fail(bitwriter != NULL, FALSE); \ g_return_val_if_fail(nbits != 0, FALSE); \ g_return_val_if_fail(nbits <= bits, FALSE); \ \ if (!_gst_bit_writer_check_remaining(bitwriter, nbits)) \ return FALSE; \ gst_bit_writer_put_bits_uint##bits##_unchecked(bitwriter, value, nbits); \ return TRUE; \ }
__GST_BIT_WRITER_WRITE_BITS_UNCHECKED
#define __GST_BIT_WRITER_WRITE_BITS_UNCHECKED(bits) \ static inline void \ gst_bit_writer_put_bits_uint##bits##_unchecked( \ GstBitWriter *bitwriter, \ guint##bits value, \ guint nbits \ ) \ { \ guint byte_pos, bit_offset; \ guint8 *cur_byte; \ guint fill_bits; \ \ byte_pos = (bitwriter->bit_size >> 3); \ bit_offset = (bitwriter->bit_size & 0x07); \ cur_byte = bitwriter->data + byte_pos; \ g_assert (nbits <= bits); \ g_assert( bit_offset < 8 && \ bitwriter->bit_size <= bitwriter->bit_capacity); \ \ while (nbits) { \ fill_bits = ((8 - bit_offset) < nbits ? (8 - bit_offset) : nbits); \ nbits -= fill_bits; \ bitwriter->bit_size += fill_bits; \ \ *cur_byte |= (((value >> nbits) & _gst_bit_writer_bit_filling_mask[fill_bits]) \ << (8 - bit_offset - fill_bits)); \ ++cur_byte; \ bit_offset = 0; \ } \ g_assert(cur_byte <= \ (bitwriter->data + (bitwriter->bit_capacity >> 3))); \ }
Constants
The results of the search are