BVarStream

Functions

BVarStream

~BVarStream

void

InitWrite

void

InitRead

int

Put

int

Get

Detailed Description

class BVarStream

BVarStream encodes/decodes samples of variable length. Given an integer sample value and a cascading sequence of bit lengths to try, it will write escape sequences until it encounters a bit length long enough to encapsulate the value.

It was ported to C because it was a step along the way in the implementation of class BPack. It was put into this file in case it ever became useful. Buyer beware, however, since it has been neither used nor tested since the port to C++.

Public Functions

inline BVarStream()
inline ~BVarStream()
inline void InitWrite(int size, void *pointer)

We already have a buffer that we would like to use varstream to fill w/ data. matching this call with a vsfree is unnecessary (but would do no harm). pointer must be 4-byte aligned.

inline void InitRead(int size, void const *pointer)

We have a buffer that we would like to use varstream to read from. matching this call with a vsfree is unnecessary (but would do no harm). pointer must be 4-byte aligned.

inline int Put(int *numbits_array, int val)

The numbits_array is an array of bit lengths which should be attempted, in order. It is assumed that at least one of the lengths is sufficient for the given val. For EdgeBreaker, we used {2,6,10,14,18,22,26,31}

inline int Get(int *numbits_array)

Decode a sample based on a given sequence of bit lengths. For each bit length, a value equal to the mask (all 1’s) is interpreted as an escape sequence. Every time an escape sequence encountered, we jump to the next value in numbits_array to try to interpret the value. This sequence of bit lengths must match what was used on the write side.