paraslash Paraslash Audio Streaming
About   News   Download   Documentation   Development

Data Structures | Functions
bitstream.h File Reference

Bitstream structures and inline functions. More...

Data Structures

struct  getbit_context
 Structure for bistream I/O. More...
 
struct  vlc
 A variable length code table. More...
 

Functions

void init_vlc (struct vlc *vlc, int nb_bits, int nb_codes, const void *bits, const void *codes, int codes_size)
 Build VLC decoding tables suitable for use with get_vlc(). More...
 
void free_vlc (struct vlc *vlc)
 Deallocate all resources of a VLC table. More...
 
int get_vlc (struct getbit_context *gbc, const struct vlc *vlc)
 Parse a vlc code. More...
 

Detailed Description

Bitstream structures and inline functions.

Function Documentation

◆ init_vlc()

void init_vlc ( struct vlc vlc,
int  nb_bits,
int  nb_codes,
const void *  bits,
const void *  codes,
int  codes_size 
)

Build VLC decoding tables suitable for use with get_vlc().

Parameters
vlcThe structure to be initialized.
nb_bitsSet the decoding table size (2^nb_bits) entries.
nb_codesNumber of vlc codes.
bitsTable which gives the size (in bits) of each vlc code.
codesTable which gives the bit pattern of of each vlc code.
codes_sizeThe number of bytes of each entry of the codes tables.

The bigger nb_bits is, the faster is the decoding. But it should not be too big to save memory and L1 cache. '9' is a good compromise.

The wrap and size parameters allow to use any memory configuration and types (byte/word/long) to store the bits and codes tables.

References vlc::bits, PARA_INFO_LOG, vlc::table, vlc::table_allocated, and vlc::table_size.

◆ free_vlc()

void free_vlc ( struct vlc vlc)

Deallocate all resources of a VLC table.

Parameters
vlcPointer to an initialized vlc structure.

The table given by vlc must have been initialized earlier via init_vlc().

References freep(), and vlc::table.

◆ get_vlc()

int get_vlc ( struct getbit_context gbc,
const struct vlc vlc 
)

Parse a vlc code.

Parameters
gbcThe getbit context structure.
vlcThe vlc tables to use.
Returns
The vlc code.