libgpac
Documentation of the core library of GPAC
bitstream.c File Reference
#include <gpac/bitstream.h>
+ Include dependency graph for bitstream.c:

Data Structures

struct  GF_BitStream
 

Macros

#define BS_MEM_BLOCK_ALLOC_SIZE   512
 
#define NO_OPTS
 

Enumerations

enum  { GF_BITSTREAM_FILE_READ = GF_BITSTREAM_WRITE_DYN + 1 , GF_BITSTREAM_FILE_WRITE }
 

Functions

GF_Err gf_bs_reassign_buffer (GF_BitStream *bs, const u8 *buffer, u64 BufferSize)
 bitstream reassignment More...
 
GF_EXPORT GF_BitStream * gf_bs_new (const u8 *buffer, u64 BufferSize, u32 mode)
 bitstream constructor More...
 
GF_EXPORT GF_BitStream * gf_bs_from_file (FILE *f, u32 mode)
 bitstream constructor from file handle More...
 
GF_EXPORT GF_BitStream * gf_bs_from_fd (int fd, u32 mode)
 
GF_BitStream * gf_bs_new_cbk_buffer (GF_Err(*on_block_out)(void *cbk, u8 *data, u32 block_size), void *usr_data, u8 *buffer, u32 buffer_size)
 bitstream constructor from callback output and preallocated buffer More...
 
GF_BitStream * gf_bs_new_cbk (GF_Err(*on_block_out)(void *cbk, u8 *data, u32 block_size), void *usr_data, u32 block_size)
 bitstream constructor from callback output More...
 
void gf_bs_prevent_dispatch (GF_BitStream *bs, Bool prevent_dispatch)
 prevents block dispatch Prevents byte dispatching in callback mode. This is used when seek operations are used. More...
 
static Bool bs_flush_write_cache (GF_BitStream *bs)
 
GF_EXPORT void gf_bs_del (GF_BitStream *bs)
 bitstream destructor from file handle More...
 
GF_EXPORT void gf_bs_enable_emulation_byte_removal (GF_BitStream *bs, Bool do_remove)
 NALU-based Annex B mode, only used for read mode. More...
 
GF_EXPORT u32 gf_bs_get_emulation_byte_removed (GF_BitStream *bs)
 NALU-based Annex B mode, only used for read mode. More...
 
Bool gf_bs_is_align (GF_BitStream *bs)
 bitstream alignment checking More...
 
static GFINLINE u8 gf_bs_load_byte (GF_BitStream *bs, Bool *is_eos)
 
static u8 BS_ReadByte (GF_BitStream *bs)
 
GF_EXPORT u8 gf_bs_read_bit (GF_BitStream *bs)
 
GF_EXPORT u32 gf_bs_read_int (GF_BitStream *bs, u32 nBits)
 integer reading More...
 
GF_EXPORT u32 gf_bs_read_u8 (GF_BitStream *bs)
 align char reading More...
 
GF_EXPORT u32 gf_bs_read_u16 (GF_BitStream *bs)
 align short reading More...
 
GF_EXPORT u32 gf_bs_read_u24 (GF_BitStream *bs)
 align 24-bit integer reading More...
 
GF_EXPORT u32 gf_bs_read_u32 (GF_BitStream *bs)
 align integer reading More...
 
GF_EXPORT u64 gf_bs_read_u64 (GF_BitStream *bs)
 align large integer reading More...
 
GF_EXPORT u64 gf_bs_read_long_int (GF_BitStream *bs, u32 nBits)
 large integer reading More...
 
GF_EXPORT Float gf_bs_read_float (GF_BitStream *bs)
 float reading More...
 
GF_EXPORT Double gf_bs_read_double (GF_BitStream *bs)
 double reading More...
 
GF_EXPORT u32 gf_bs_read_data (GF_BitStream *bs, u8 *data, u32 nbBytes)
 data reading More...
 
static void BS_WriteByte (GF_BitStream *bs, u8 val)
 
static void BS_WriteBit (GF_BitStream *bs, u32 bit)
 
static s32 bs_handle_nbits_overflow (GF_BitStream *bs, s32 nBits, s32 max_shift)
 
GF_EXPORT void gf_bs_write_int (GF_BitStream *bs, s32 _value, s32 nBits)
 integer writing More...
 
GF_EXPORT void gf_bs_write_long_int (GF_BitStream *bs, s64 _value, s32 nBits)
 large integer writing More...
 
GF_EXPORT void gf_bs_write_u8 (GF_BitStream *bs, u32 value)
 align char writing More...
 
GF_EXPORT void gf_bs_write_u16 (GF_BitStream *bs, u32 value)
 align short writing More...
 
GF_EXPORT void gf_bs_write_u24 (GF_BitStream *bs, u32 value)
 align 24-bits integer writing More...
 
GF_EXPORT void gf_bs_write_u32 (GF_BitStream *bs, u32 value)
 align integer writing More...
 
GF_EXPORT void gf_bs_write_u64 (GF_BitStream *bs, u64 value)
 align large integer writing More...
 
GF_EXPORT u32 gf_bs_write_byte (GF_BitStream *bs, u8 byte, u32 repeat_count)
 write byte multiple times More...
 
GF_EXPORT void gf_bs_write_float (GF_BitStream *bs, Float value)
 float writing More...
 
GF_EXPORT void gf_bs_write_double (GF_BitStream *bs, Double value)
 double writing More...
 
GF_EXPORT u32 gf_bs_write_data (GF_BitStream *bs, const u8 *data, u32 nbBytes)
 data writing More...
 
GF_EXPORT u8 gf_bs_align (GF_BitStream *bs)
 bitstream alignment More...
 
GF_EXPORT u64 gf_bs_available (GF_BitStream *bs)
 capacity query More...
 
static s32 BS_CutBuffer (GF_BitStream *bs)
 
GF_EXPORT void gf_bs_get_content_no_truncate (GF_BitStream *bs, u8 **output, u32 *outSize, u32 *alloc_size)
 buffer fetching More...
 
GF_EXPORT void gf_bs_get_content (GF_BitStream *bs, u8 **output, u32 *outSize)
 buffer fetching More...
 
GF_Err gf_bs_grow (GF_BitStream *bs, u32 addSize)
 
GF_EXPORT void gf_bs_skip_bytes (GF_BitStream *bs, u64 nbBytes)
 byte skipping More...
 
static GF_Err BS_SeekIntern (GF_BitStream *bs, u64 offset)
 
GF_EXPORT GF_Err gf_bs_seek (GF_BitStream *bs, u64 offset)
 bitstream seeking More...
 
GF_EXPORT u32 gf_bs_peek_bits (GF_BitStream *bs, u32 numBits, u64 byte_offset)
 bit peeking More...
 
GF_EXPORT u64 gf_bs_get_refreshed_size (GF_BitStream *bs)
 file-based size query More...
 
GF_EXPORT u64 gf_bs_get_size (GF_BitStream *bs)
 size query More...
 
GF_EXPORT u64 gf_bs_get_position (GF_BitStream *bs)
 position query More...
 
GF_EXPORT u8 gf_bs_bits_available (GF_BitStream *bs)
 bit reservoir query More...
 
GF_EXPORT void gf_bs_set_eos_callback (GF_BitStream *bs, void(*EndOfStream)(void *par), void *par)
 end of bitstream management More...
 
GF_EXPORT u64 gf_bs_read_u64_le (GF_BitStream *bs)
 little endian integer reading More...
 
GF_EXPORT u32 gf_bs_read_u32_le (GF_BitStream *bs)
 little endian integer reading More...
 
GF_EXPORT u16 gf_bs_read_u16_le (GF_BitStream *bs)
 little endian integer reading More...
 
GF_EXPORT void gf_bs_write_u64_le (GF_BitStream *bs, u64 val)
 little endian large integer writing More...
 
GF_EXPORT void gf_bs_write_u32_le (GF_BitStream *bs, u32 val)
 little endian integer writing More...
 
GF_EXPORT void gf_bs_write_u16_le (GF_BitStream *bs, u32 val)
 little endian short writing More...
 
GF_EXPORT u32 gf_bs_get_bit_offset (GF_BitStream *bs)
 bit position More...
 
GF_EXPORT u32 gf_bs_get_bit_position (GF_BitStream *bs)
 current bit position More...
 
GF_EXPORT u32 gf_bs_read_vluimsbf5 (GF_BitStream *bs)
 variable length integer reading More...
 
GF_EXPORT void gf_bs_truncate (GF_BitStream *bs)
 bitstream truncation More...
 
void gf_bs_untruncate (GF_BitStream *bs)
 
GF_EXPORT GF_Err gf_bs_transfer (GF_BitStream *dst, GF_BitStream *src, Bool keep_src)
 transfer content from source bitstream to destination bitstream More...
 
GF_EXPORT void gf_bs_flush (GF_BitStream *bs)
 Flushes bitstream content to disk. More...
 
u64 gf_bs_set_cookie (GF_BitStream *bs, u64 cookie)
 Sets cookie. More...
 
u64 gf_bs_get_cookie (GF_BitStream *bs)
 Gets cookie. More...
 
GF_EXPORT GF_Err gf_bs_insert_data (GF_BitStream *bs, u8 *data, u32 size, u64 offset)
 Inserts a data block, moving bytes to the end. More...
 
GF_Err gf_bs_set_logger (GF_BitStream *bs, void(*on_bs_log)(void *udta, const char *field_name, u32 nb_bits, u64 field_val, s32 idx1, s32 idx2, s32 idx3), void *udta)
 
void gf_bs_log_idx (GF_BitStream *bs, u32 nBits, const char *fname, s64 val, s32 idx1, s32 idx2, s32 idx3)
 
void gf_bs_mark_overflow (GF_BitStream *bs, Bool reset)
 Marks overflow access. More...
 
u32 gf_bs_is_overflow (GF_BitStream *bs)
 Gets overflow state. More...
 
GF_EXPORT char * gf_bs_read_utf8 (GF_BitStream *bs)
 Reads string. More...
 
GF_EXPORT GF_Err gf_bs_write_utf8 (GF_BitStream *bs, const char *str)
 Writes string. More...
 

Macro Definition Documentation

◆ BS_MEM_BLOCK_ALLOC_SIZE

#define BS_MEM_BLOCK_ALLOC_SIZE   512

◆ NO_OPTS

#define NO_OPTS

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
GF_BITSTREAM_FILE_READ 
GF_BITSTREAM_FILE_WRITE 

Function Documentation

◆ gf_bs_from_fd()

GF_EXPORT GF_BitStream* gf_bs_from_fd ( int  fd,
u32  mode 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bs_flush_write_cache()

static Bool bs_flush_write_cache ( GF_BitStream *  bs)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_bs_load_byte()

static GFINLINE u8 gf_bs_load_byte ( GF_BitStream *  bs,
Bool is_eos 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BS_ReadByte()

static u8 BS_ReadByte ( GF_BitStream *  bs)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_bs_read_bit()

GF_EXPORT u8 gf_bs_read_bit ( GF_BitStream *  bs)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BS_WriteByte()

static void BS_WriteByte ( GF_BitStream *  bs,
u8  val 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BS_WriteBit()

static void BS_WriteBit ( GF_BitStream *  bs,
u32  bit 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bs_handle_nbits_overflow()

static s32 bs_handle_nbits_overflow ( GF_BitStream *  bs,
s32  nBits,
s32  max_shift 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BS_CutBuffer()

static s32 BS_CutBuffer ( GF_BitStream *  bs)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_bs_grow()

GF_Err gf_bs_grow ( GF_BitStream *  bs,
u32  addSize 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BS_SeekIntern()

static GF_Err BS_SeekIntern ( GF_BitStream *  bs,
u64  offset 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_bs_untruncate()

void gf_bs_untruncate ( GF_BitStream *  bs)
+ Here is the caller graph for this function:

◆ gf_bs_set_logger()

GF_Err gf_bs_set_logger ( GF_BitStream *  bs,
void(*)(void *udta, const char *field_name, u32 nb_bits, u64 field_val, s32 idx1, s32 idx2, s32 idx3)  on_bs_log,
void *  udta 
)
+ Here is the caller graph for this function:

◆ gf_bs_log_idx()

void gf_bs_log_idx ( GF_BitStream *  bs,
u32  nBits,
const char *  fname,
s64  val,
s32  idx1,
s32  idx2,
s32  idx3 
)
+ Here is the caller graph for this function: