Project Alice
|
#include "mem.h"
#include "compiler.h"
#include "debug.h"
#include "error_private.h"
#include "bits.h"
Go to the source code of this file.
Classes | |
struct | BIT_CStream_t |
struct | BIT_DStream_t |
Macros | |
#define | STREAM_ACCUMULATOR_MIN_32 25 |
#define | STREAM_ACCUMULATOR_MIN_64 57 |
#define | STREAM_ACCUMULATOR_MIN ((U32)(MEM_32bits() ? STREAM_ACCUMULATOR_MIN_32 : STREAM_ACCUMULATOR_MIN_64)) |
#define | BIT_MASK_SIZE (sizeof(BIT_mask) / sizeof(BIT_mask[0])) |
Typedefs | |
typedef size_t | BitContainerType |
Enumerations | |
enum | BIT_DStream_status { BIT_DStream_unfinished = 0 , BIT_DStream_endOfBuffer = 1 , BIT_DStream_completed = 2 , BIT_DStream_overflow = 3 } |
#define BIT_MASK_SIZE (sizeof(BIT_mask) / sizeof(BIT_mask[0])) |
Definition at line 145 of file bitstream.h.
#define STREAM_ACCUMULATOR_MIN ((U32)(MEM_32bits() ? STREAM_ACCUMULATOR_MIN_32 : STREAM_ACCUMULATOR_MIN_64)) |
Definition at line 49 of file bitstream.h.
#define STREAM_ACCUMULATOR_MIN_32 25 |
Definition at line 47 of file bitstream.h.
#define STREAM_ACCUMULATOR_MIN_64 57 |
Definition at line 48 of file bitstream.h.
typedef size_t BitContainerType |
Definition at line 93 of file bitstream.h.
enum BIT_DStream_status |
Enumerator | |
---|---|
BIT_DStream_unfinished | |
BIT_DStream_endOfBuffer | |
BIT_DStream_completed | |
BIT_DStream_overflow |
Definition at line 102 of file bitstream.h.
MEM_STATIC void BIT_addBits | ( | BIT_CStream_t * | bitC, |
size_t | value, | ||
unsigned | nbBits | ||
) |
BIT_addBits() : can add up to 31 bits into bitC
. Note : does not check for register overflow !
Definition at line 179 of file bitstream.h.
MEM_STATIC void BIT_addBitsFast | ( | BIT_CStream_t * | bitC, |
size_t | value, | ||
unsigned | nbBits | ||
) |
BIT_addBitsFast() : works only if value
is clean, meaning all high bits above nbBits are 0
Definition at line 192 of file bitstream.h.
MEM_STATIC size_t BIT_closeCStream | ( | BIT_CStream_t * | bitC | ) |
Definition at line 235 of file bitstream.h.
MEM_STATIC unsigned BIT_endOfDStream | ( | const BIT_DStream_t * | DStream | ) |
Definition at line 448 of file bitstream.h.
MEM_STATIC void BIT_flushBits | ( | BIT_CStream_t * | bitC | ) |
BIT_flushBits() : assumption : bitContainer has not overflowed safe version; check for buffer overflow, and prevents it. note : does not signal buffer overflow. overflow will be revealed later on using BIT_closeCStream()
Definition at line 220 of file bitstream.h.
MEM_STATIC void BIT_flushBitsFast | ( | BIT_CStream_t * | bitC | ) |
BIT_flushBitsFast() : assumption : bitContainer has not overflowed unsafe version; does not check buffer overflow
Definition at line 204 of file bitstream.h.
FORCE_INLINE_TEMPLATE size_t BIT_getLowerBits | ( | size_t | bitContainer, |
U32 const | nbBits | ||
) |
FORCE_INLINE_TEMPLATE size_t BIT_getMiddleBits | ( | BitContainerType | bitContainer, |
U32 const | start, | ||
U32 const | nbBits | ||
) |
FORCE_INLINE_TEMPLATE size_t BIT_getUpperBits | ( | BitContainerType | bitContainer, |
U32 const | start | ||
) |
Definition at line 301 of file bitstream.h.
MEM_STATIC size_t BIT_initCStream | ( | BIT_CStream_t * | bitC, |
void * | startPtr, | ||
size_t | dstCapacity | ||
) |
BIT_initCStream() : dstCapacity
must be > sizeof(size_t)
Definition at line 154 of file bitstream.h.
MEM_STATIC size_t BIT_initDStream | ( | BIT_DStream_t * | bitD, |
const void * | srcBuffer, | ||
size_t | srcSize | ||
) |
BIT_initDStream() : Initialize a BIT_DStream_t. bitD
: a pointer to an already allocated BIT_DStream_t structure. srcSize
must be the exact size of the bitStream, in bytes.
Definition at line 253 of file bitstream.h.
FORCE_INLINE_TEMPLATE size_t BIT_lookBits | ( | const BIT_DStream_t * | bitD, |
U32 | nbBits | ||
) |
BIT_lookBits() : Provides next n bits from local register. local register is not modified. On 32-bits, maxNbBits==24. On 64-bits, maxNbBits==56.
Definition at line 329 of file bitstream.h.
MEM_STATIC size_t BIT_lookBitsFast | ( | const BIT_DStream_t * | bitD, |
U32 | nbBits | ||
) |
BIT_lookBitsFast() : unsafe version; only works if nbBits >= 1
Definition at line 345 of file bitstream.h.
FORCE_INLINE_TEMPLATE size_t BIT_readBits | ( | BIT_DStream_t * | bitD, |
unsigned | nbBits | ||
) |
BIT_readBits() : Read (consume) next n bits from local register and update. Pay attention to not read more than nbBits contained into local register.
Definition at line 361 of file bitstream.h.
MEM_STATIC size_t BIT_readBitsFast | ( | BIT_DStream_t * | bitD, |
unsigned | nbBits | ||
) |
BIT_readBitsFast() : unsafe version; only works if nbBits >= 1
Definition at line 370 of file bitstream.h.
FORCE_INLINE_TEMPLATE BIT_DStream_status BIT_reloadDStream | ( | BIT_DStream_t * | bitD | ) |
BIT_reloadDStream() : Refill bitD
from buffer previously set in BIT_initDStream() . This function is safe, it guarantees it will not never beyond src buffer.
BIT_DStream_t
internal register. when status == BIT_DStream_unfinished, internal register is filled with at least 25 or 57 bits Definition at line 411 of file bitstream.h.
MEM_STATIC BIT_DStream_status BIT_reloadDStream_internal | ( | BIT_DStream_t * | bitD | ) |
BIT_reloadDStream_internal() : Simple variant of BIT_reloadDStream(), with two conditions:
Definition at line 383 of file bitstream.h.
MEM_STATIC BIT_DStream_status BIT_reloadDStreamFast | ( | BIT_DStream_t * | bitD | ) |
BIT_reloadDStreamFast() : Similar to BIT_reloadDStream(), but with two differences:
Definition at line 399 of file bitstream.h.
FORCE_INLINE_TEMPLATE void BIT_skipBits | ( | BIT_DStream_t * | bitD, |
U32 | nbBits | ||
) |