libxcoder  5.2.0
ni_bitstream.h File Reference

Utility definitions to operate on bits in a bitstream. More...

Go to the source code of this file.

Data Structures

struct  ni_data_chunk_t
 
struct  _ni_bitstream_writer_t
 
struct  _ni_bitstream_reader_t
 

Macros

#define NI_DATA_CHUNK_SIZE   4096
 

Typedefs

typedef struct ni_data_chunk_t ni_data_chunk_t
 
typedef struct _ni_bitstream_writer_t ni_bitstream_writer_t
 
typedef struct _ni_bitstream_reader_t ni_bitstream_reader_t
 

Functions

void ni_bitstream_writer_init (ni_bitstream_writer_t *stream)
 init a bitstream writer More...
 
uint64_t ni_bs_writer_tell (const ni_bitstream_writer_t *const stream)
 return the number of bits written to bitstream so far More...
 
void ni_bs_writer_put (ni_bitstream_writer_t *stream, uint32_t data, uint8_t bits)
 write a specified number (<= 32) of bits to bitstream, buffer individual bits until a full byte is made More...
 
void ni_bs_writer_put_ue (ni_bitstream_writer_t *stream, uint32_t data)
 write unsigned Exp-Golomb bit string to bitstream, 2^32-2 at most. More...
 
void ni_bs_writer_put_se (ni_bitstream_writer_t *stream, int32_t data)
 write signed Exp-Golomb bit string to bitstream More...
 
void ni_bs_writer_align_zero (ni_bitstream_writer_t *stream)
 align the bitstream with zero More...
 
void ni_bs_writer_copy (uint8_t *dst, const ni_bitstream_writer_t *stream)
 copy bitstream data to dst Note: caller must ensure sufficient space in dst More...
 
void ni_bs_writer_clear (ni_bitstream_writer_t *stream)
 clear and reset bitstream More...
 
LIB_API_BITSTREAM void ni_bitstream_reader_init (ni_bitstream_reader_t *br, const uint8_t *data, int bit_size)
 init a bitstream reader Note: bitstream_reader takes reading ownership of the data More...
 
LIB_API_BITSTREAM int ni_bs_reader_bits_count (ni_bitstream_reader_t *br)
 return the number of bits already parsed in stream More...
 
LIB_API_BITSTREAM int ni_bs_reader_get_bits_left (ni_bitstream_reader_t *br)
 return the number of bits left to parse in stream More...
 
LIB_API_BITSTREAM void ni_bs_reader_skip_bits (ni_bitstream_reader_t *br, int n)
 skip a number of bits ahead in the bitstream reader More...
 
LIB_API_BITSTREAM uint32_t ni_bs_reader_get_bits (ni_bitstream_reader_t *br, int n)
 read bits (up to 32) from the bitstream reader, after reader init More...
 
LIB_API_BITSTREAM uint32_t ni_bs_reader_get_ue (ni_bitstream_reader_t *br)
 read an unsigned Exp-Golomb code ue(v) More...
 
LIB_API_BITSTREAM int32_t ni_bs_reader_get_se (ni_bitstream_reader_t *br)
 read a signed Exp-Golomb code se(v) More...
 

Detailed Description

Utility definitions to operate on bits in a bitstream.


Definition in file ni_bitstream.h.

Macro Definition Documentation

◆ NI_DATA_CHUNK_SIZE

#define NI_DATA_CHUNK_SIZE   4096

Definition at line 60 of file ni_bitstream.h.

Typedef Documentation

◆ ni_bitstream_reader_t

◆ ni_bitstream_writer_t

◆ ni_data_chunk_t

Function Documentation

◆ ni_bitstream_reader_init()

LIB_API_BITSTREAM void ni_bitstream_reader_init ( ni_bitstream_reader_t br,
const uint8_t *  data,
int  bit_size 
)

init a bitstream reader Note: bitstream_reader takes reading ownership of the data


Parameters
brbitstream reader
datadata to be parsed
bit_sizenumber of bits in the data
Returns
none

Definition at line 317 of file ni_bitstream.c.

◆ ni_bitstream_writer_init()

void ni_bitstream_writer_init ( ni_bitstream_writer_t stream)

init a bitstream writer


Parameters
streambitstream
Returns
none

Definition at line 158 of file ni_bitstream.c.

◆ ni_bs_reader_bits_count()

LIB_API_BITSTREAM int ni_bs_reader_bits_count ( ni_bitstream_reader_t br)

return the number of bits already parsed in stream


Parameters
brbitstream reader
Returns
number of bits parsed

Definition at line 338 of file ni_bitstream.c.

◆ ni_bs_reader_get_bits()

LIB_API_BITSTREAM uint32_t ni_bs_reader_get_bits ( ni_bitstream_reader_t br,
int  n 
)

read bits (up to 32) from the bitstream reader, after reader init


Parameters
brbitstream reader
nnumber of bits to read
Returns
value read

Definition at line 471 of file ni_bitstream.c.

◆ ni_bs_reader_get_bits_left()

LIB_API_BITSTREAM int ni_bs_reader_get_bits_left ( ni_bitstream_reader_t br)

return the number of bits left to parse in stream


Parameters
brbitstream reader
Returns
number of bits left

Definition at line 349 of file ni_bitstream.c.

◆ ni_bs_reader_get_se()

LIB_API_BITSTREAM int32_t ni_bs_reader_get_se ( ni_bitstream_reader_t br)

read a signed Exp-Golomb code se(v)


Parameters
brbitstream reader
Returns
value read

Definition at line 546 of file ni_bitstream.c.

◆ ni_bs_reader_get_ue()

LIB_API_BITSTREAM uint32_t ni_bs_reader_get_ue ( ni_bitstream_reader_t br)

read an unsigned Exp-Golomb code ue(v)


Parameters
brbitstream reader
Returns
value read

Definition at line 522 of file ni_bitstream.c.

◆ ni_bs_reader_skip_bits()

LIB_API_BITSTREAM void ni_bs_reader_skip_bits ( ni_bitstream_reader_t br,
int  n 
)

skip a number of bits ahead in the bitstream reader


Parameters
brbitstream reader
nnumber of bits to skip
Returns
none

Definition at line 361 of file ni_bitstream.c.

◆ ni_bs_writer_align_zero()

void ni_bs_writer_align_zero ( ni_bitstream_writer_t stream)

align the bitstream with zero


Parameters
streambitstream
Returns
none

Definition at line 266 of file ni_bitstream.c.

◆ ni_bs_writer_clear()

void ni_bs_writer_clear ( ni_bitstream_writer_t stream)

clear and reset bitstream


Parameters
streambitstream
Returns
none

Definition at line 300 of file ni_bitstream.c.

◆ ni_bs_writer_copy()

void ni_bs_writer_copy ( uint8_t *  dst,
const ni_bitstream_writer_t stream 
)

copy bitstream data to dst Note: caller must ensure sufficient space in dst


Parameters
dstcopy destination
streambitstream
Returns
none

Definition at line 282 of file ni_bitstream.c.

◆ ni_bs_writer_put()

void ni_bs_writer_put ( ni_bitstream_writer_t stream,
uint32_t  data,
uint8_t  bits 
)

write a specified number (<= 32) of bits to bitstream, buffer individual bits until a full byte is made


Parameters
streambitstream
datainput data
bitsnumber of bits in data to write to stream, max 32
Returns
none

Definition at line 183 of file ni_bitstream.c.

◆ ni_bs_writer_put_se()

void ni_bs_writer_put_se ( ni_bitstream_writer_t stream,
int32_t  data 
)

write signed Exp-Golomb bit string to bitstream


Parameters
streambitstream
datainput data
Returns
none

Definition at line 253 of file ni_bitstream.c.

◆ ni_bs_writer_put_ue()

void ni_bs_writer_put_ue ( ni_bitstream_writer_t stream,
uint32_t  data 
)

write unsigned Exp-Golomb bit string to bitstream, 2^32-2 at most.


Parameters
streambitstream
datainput data
Returns
none

Definition at line 219 of file ni_bitstream.c.

◆ ni_bs_writer_tell()

uint64_t ni_bs_writer_tell ( const ni_bitstream_writer_t *const  stream)

return the number of bits written to bitstream so far


Parameters
streambitstream
Returns
position

Definition at line 169 of file ni_bitstream.c.