BitWriter#

Added in version 1.16.

class BitWriter(*args, **kwargs)#

BitWriter 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#

class BitWriter
align_bytes(trailing_bit: int) bool#

Write trailing bit to align last byte of data. trailing_bit can only be 1 or 0.

Parameters:

trailing_bit – trailing bits of last byte, 0 or 1

free() None#

Frees bitwriter and the allocated data inside.

free_and_get_buffer() Buffer#

Frees bitwriter without destroying the internal data, which is returned as Buffer.

Free-function: gst_buffer_unref

free_and_get_data() list[int]#

Frees bitwriter without destroying the internal data, which is returned.

Free-function: g_free

get_data() list[int]#

Get written data pointer

get_remaining() int#
get_size() int#

Get size of written data

put_bits_uint16(value: int, nbits: int) bool#

Write nbits bits of value to BitWriter.

Parameters:
  • value – value of int to write

  • nbits – number of bits to write

put_bits_uint32(value: int, nbits: int) bool#

Write nbits bits of value to BitWriter.

Parameters:
  • value – value of int to write

  • nbits – number of bits to write

put_bits_uint64(value: int, nbits: int) bool#

Write nbits bits of value to BitWriter.

Parameters:
  • value – value of int to write

  • nbits – number of bits to write

put_bits_uint8(value: int, nbits: int) bool#

Write nbits bits of value to BitWriter.

Parameters:
  • value – value of int to write

  • nbits – number of bits to write

put_bytes(data: list[int], nbytes: int) bool#

Write nbytes bytes of data to BitWriter.

Parameters:
  • data – pointer of data to write

  • nbytes – number of bytes to write

reset() None#

Resets bitwriter and frees the data if it’s owned by bitwriter.

reset_and_get_buffer() Buffer#

Resets bitwriter and returns the current data as Buffer.

Free-function: gst_buffer_unref

reset_and_get_data() list[int]#

Resets bitwriter and returns the current data.

Free-function: g_free

set_pos(pos: int) bool#
Parameters:

pos

Fields#

class BitWriter
auto_grow#
bit_capacity#
bit_size#

Size of written data in bits

data#

Allocated data for bit writer to write

owned#