ReactOS  0.4.14-dev-998-g623dd26
bitstream.h File Reference
#include "mem.h"
#include "debug.h"
#include "error_private.h"
Include dependency graph for bitstream.h:
This graph shows which files directly or indirectly include this file:

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]))
 

Enumerations

enum  BIT_DStream_status { BIT_DStream_unfinished = 0, BIT_DStream_endOfBuffer = 1, BIT_DStream_completed = 2, BIT_DStream_overflow = 3 }
 

Functions

MEM_STATIC size_t BIT_initCStream (BIT_CStream_t *bitC, void *dstBuffer, size_t dstCapacity)
 
MEM_STATIC void BIT_addBits (BIT_CStream_t *bitC, size_t value, unsigned nbBits)
 
MEM_STATIC void BIT_flushBits (BIT_CStream_t *bitC)
 
MEM_STATIC size_t BIT_closeCStream (BIT_CStream_t *bitC)
 
MEM_STATIC size_t BIT_initDStream (BIT_DStream_t *bitD, const void *srcBuffer, size_t srcSize)
 
MEM_STATIC size_t BIT_readBits (BIT_DStream_t *bitD, unsigned nbBits)
 
MEM_STATIC BIT_DStream_status BIT_reloadDStream (BIT_DStream_t *bitD)
 
MEM_STATIC unsigned BIT_endOfDStream (const BIT_DStream_t *bitD)
 
MEM_STATIC void BIT_addBitsFast (BIT_CStream_t *bitC, size_t value, unsigned nbBits)
 
MEM_STATIC void BIT_flushBitsFast (BIT_CStream_t *bitC)
 
MEM_STATIC size_t BIT_readBitsFast (BIT_DStream_t *bitD, unsigned nbBits)
 
MEM_STATIC unsigned BIT_highbit32 (U32 val)
 
MEM_STATIC size_t BIT_getUpperBits (size_t bitContainer, U32 const start)
 
MEM_STATIC size_t BIT_getMiddleBits (size_t bitContainer, U32 const start, U32 const nbBits)
 
MEM_STATIC size_t BIT_getLowerBits (size_t bitContainer, U32 const nbBits)
 
MEM_STATIC size_t BIT_lookBits (const BIT_DStream_t *bitD, U32 nbBits)
 
MEM_STATIC size_t BIT_lookBitsFast (const BIT_DStream_t *bitD, U32 nbBits)
 
MEM_STATIC void BIT_skipBits (BIT_DStream_t *bitD, U32 nbBits)
 
MEM_STATIC size_t BIT_readBits (BIT_DStream_t *bitD, U32 nbBits)
 
MEM_STATIC size_t BIT_readBitsFast (BIT_DStream_t *bitD, U32 nbBits)
 

Variables

static const unsigned BIT_mask []
 

Macro Definition Documentation

◆ BIT_MASK_SIZE

#define BIT_MASK_SIZE   (sizeof(BIT_mask) / sizeof(BIT_mask[0]))

Definition at line 190 of file bitstream.h.

◆ STREAM_ACCUMULATOR_MIN

#define STREAM_ACCUMULATOR_MIN   ((U32)(MEM_32bits() ? STREAM_ACCUMULATOR_MIN_32 : STREAM_ACCUMULATOR_MIN_64))

Definition at line 64 of file bitstream.h.

◆ STREAM_ACCUMULATOR_MIN_32

#define STREAM_ACCUMULATOR_MIN_32   25

Definition at line 62 of file bitstream.h.

◆ STREAM_ACCUMULATOR_MIN_64

#define STREAM_ACCUMULATOR_MIN_64   57

Definition at line 63 of file bitstream.h.

Enumeration Type Documentation

◆ BIT_DStream_status

Enumerator
BIT_DStream_unfinished 
BIT_DStream_endOfBuffer 
BIT_DStream_completed 
BIT_DStream_overflow 

Definition at line 116 of file bitstream.h.

Function Documentation

◆ BIT_addBits()

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 214 of file bitstream.h.

216 {
218  assert(nbBits < BIT_MASK_SIZE);
219  assert(nbBits + bitC->bitPos < sizeof(bitC->bitContainer) * 8);
220  bitC->bitContainer |= (value & BIT_mask[nbBits]) << bitC->bitPos;
221  bitC->bitPos += nbBits;
222 }
#define assert(x)
Definition: debug.h:53
#define BIT_MASK_SIZE
Definition: bitstream.h:190
static const unsigned BIT_mask[]
Definition: bitstream.h:183
size_t bitContainer
Definition: bitstream.h:75
#define MEM_STATIC_ASSERT(c)
Definition: mem.h:47
unsigned bitPos
Definition: bitstream.h:76

Referenced by ZSTD_encodeSequences_body().

◆ BIT_addBitsFast()

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 227 of file bitstream.h.

229 {
230  assert((value>>nbBits) == 0);
231  assert(nbBits + bitC->bitPos < sizeof(bitC->bitContainer) * 8);
232  bitC->bitContainer |= value << bitC->bitPos;
233  bitC->bitPos += nbBits;
234 }
#define assert(x)
Definition: debug.h:53
size_t bitContainer
Definition: bitstream.h:75
unsigned bitPos
Definition: bitstream.h:76

Referenced by BIT_closeCStream(), and HUF_encodeSymbol().

◆ BIT_closeCStream()

MEM_STATIC size_t BIT_closeCStream ( BIT_CStream_t bitC)

BIT_closeCStream() :

Returns
: size of CStream, in bytes, or 0 if it could not fit into dstBuffer

Definition at line 269 of file bitstream.h.

270 {
271  BIT_addBitsFast(bitC, 1, 1); /* endMark */
272  BIT_flushBits(bitC);
273  if (bitC->ptr >= bitC->endPtr) return 0; /* overflow detected */
274  return (bitC->ptr - bitC->startPtr) + (bitC->bitPos > 0);
275 }
MEM_STATIC void BIT_flushBits(BIT_CStream_t *bitC)
Definition: bitstream.h:255
unsigned bitPos
Definition: bitstream.h:76
char * ptr
Definition: bitstream.h:78
char * endPtr
Definition: bitstream.h:79
char * startPtr
Definition: bitstream.h:77
MEM_STATIC void BIT_addBitsFast(BIT_CStream_t *bitC, size_t value, unsigned nbBits)
Definition: bitstream.h:227

Referenced by FSE_compress_usingCTable_generic(), HUF_compress1X_usingCTable_internal_body(), and ZSTD_encodeSequences_body().

◆ BIT_endOfDStream()

MEM_STATIC unsigned BIT_endOfDStream ( const BIT_DStream_t DStream)

BIT_endOfDStream() :

Returns
: 1 if DStream has exactly reached its end (all bits consumed).

Definition at line 446 of file bitstream.h.

447 {
448  return ((DStream->ptr == DStream->start) && (DStream->bitsConsumed == sizeof(DStream->bitContainer)*8));
449 }
const char * start
Definition: bitstream.h:112
const char * ptr
Definition: bitstream.h:111
size_t bitContainer
Definition: bitstream.h:109
unsigned bitsConsumed
Definition: bitstream.h:110

Referenced by HUF_decompress1X1_usingDTable_internal_body(), HUF_decompress1X2_usingDTable_internal_body(), HUF_decompress4X1_usingDTable_internal_body(), and HUF_decompress4X2_usingDTable_internal_body().

◆ BIT_flushBits()

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 255 of file bitstream.h.

256 {
257  size_t const nbBytes = bitC->bitPos >> 3;
258  assert(bitC->bitPos < sizeof(bitC->bitContainer) * 8);
259  MEM_writeLEST(bitC->ptr, bitC->bitContainer);
260  bitC->ptr += nbBytes;
261  if (bitC->ptr > bitC->endPtr) bitC->ptr = bitC->endPtr;
262  bitC->bitPos &= 7;
263  bitC->bitContainer >>= nbBytes*8;
264 }
#define assert(x)
Definition: debug.h:53
size_t bitContainer
Definition: bitstream.h:75
MEM_STATIC void MEM_writeLEST(void *memPtr, size_t val)
Definition: mem.h:313
unsigned bitPos
Definition: bitstream.h:76
char * ptr
Definition: bitstream.h:78
char * endPtr
Definition: bitstream.h:79

Referenced by BIT_closeCStream(), and ZSTD_encodeSequences_body().

◆ BIT_flushBitsFast()

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 239 of file bitstream.h.

240 {
241  size_t const nbBytes = bitC->bitPos >> 3;
242  assert(bitC->bitPos < sizeof(bitC->bitContainer) * 8);
243  MEM_writeLEST(bitC->ptr, bitC->bitContainer);
244  bitC->ptr += nbBytes;
245  assert(bitC->ptr <= bitC->endPtr);
246  bitC->bitPos &= 7;
247  bitC->bitContainer >>= nbBytes*8;
248 }
#define assert(x)
Definition: debug.h:53
size_t bitContainer
Definition: bitstream.h:75
MEM_STATIC void MEM_writeLEST(void *memPtr, size_t val)
Definition: mem.h:313
unsigned bitPos
Definition: bitstream.h:76
char * ptr
Definition: bitstream.h:78
char * endPtr
Definition: bitstream.h:79

◆ BIT_getLowerBits()

MEM_STATIC size_t BIT_getLowerBits ( size_t  bitContainer,
U32 const  nbBits 
)

Definition at line 348 of file bitstream.h.

349 {
350  assert(nbBits < BIT_MASK_SIZE);
351  return bitContainer & BIT_mask[nbBits];
352 }
#define assert(x)
Definition: debug.h:53
#define BIT_MASK_SIZE
Definition: bitstream.h:190
static const unsigned BIT_mask[]
Definition: bitstream.h:183

◆ BIT_getMiddleBits()

MEM_STATIC size_t BIT_getMiddleBits ( size_t  bitContainer,
U32 const  start,
U32 const  nbBits 
)

Definition at line 340 of file bitstream.h.

341 {
342  U32 const regMask = sizeof(bitContainer)*8 - 1;
343  /* if start > regMask, bitstream is corrupted, and result is undefined */
344  assert(nbBits < BIT_MASK_SIZE);
345  return (bitContainer >> (start & regMask)) & BIT_mask[nbBits];
346 }
unsigned int U32
Definition: mem.h:77
#define assert(x)
Definition: debug.h:53
#define BIT_MASK_SIZE
Definition: bitstream.h:190
static const unsigned BIT_mask[]
Definition: bitstream.h:183
GLuint start
Definition: gl.h:1545

Referenced by BIT_lookBits().

◆ BIT_getUpperBits()

MEM_STATIC size_t BIT_getUpperBits ( size_t  bitContainer,
U32 const  start 
)

Definition at line 335 of file bitstream.h.

336 {
337  return bitContainer >> start;
338 }
GLuint start
Definition: gl.h:1545

◆ BIT_highbit32()

MEM_STATIC unsigned BIT_highbit32 ( U32  val)

Definition at line 156 of file bitstream.h.

157 {
158  assert(val != 0);
159  {
160 # if defined(_MSC_VER) /* Visual */
161  unsigned long r=0;
162  _BitScanReverse ( &r, val );
163  return (unsigned) r;
164 # elif defined(__GNUC__) && (__GNUC__ >= 3) /* Use GCC Intrinsic */
165  return 31 - __builtin_clz (val);
166 # else /* Software version */
167  static const unsigned DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29,
168  11, 14, 16, 18, 22, 25, 3, 30,
169  8, 12, 20, 28, 15, 17, 24, 7,
170  19, 27, 23, 6, 26, 5, 4, 31 };
171  U32 v = val;
172  v |= v >> 1;
173  v |= v >> 2;
174  v |= v >> 4;
175  v |= v >> 8;
176  v |= v >> 16;
177  return DeBruijnClz[ (U32) (v * 0x07C4ACDDU) >> 27];
178 # endif
179  }
180 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
unsigned int U32
Definition: mem.h:77
#define assert(x)
Definition: debug.h:53
GLuint GLfloat * val
Definition: glext.h:7180
const GLdouble * v
Definition: gl.h:2040
unsigned char _BitScanReverse(unsigned long *_Index, unsigned long _Mask)
Definition: intrin_arm.h:180

Referenced by BIT_initDStream(), FSE_buildCTable_wksp(), FSE_buildDTable(), FSE_minTableLog(), FSE_optimalTableLog_internal(), HUF_readStats(), HUF_setMaxHeight(), HUF_sort(), and ZSTD_buildFSETable().

◆ BIT_initCStream()

MEM_STATIC size_t BIT_initCStream ( BIT_CStream_t bitC,
void startPtr,
size_t  dstCapacity 
)

BIT_initCStream() : dstCapacity must be > sizeof(size_t)

Returns
: 0 if success, otherwise an error code (can be tested using ERR_isError())

Definition at line 199 of file bitstream.h.

201 {
202  bitC->bitContainer = 0;
203  bitC->bitPos = 0;
204  bitC->startPtr = (char*)startPtr;
205  bitC->ptr = bitC->startPtr;
206  bitC->endPtr = bitC->startPtr + dstCapacity - sizeof(bitC->bitContainer);
207  if (dstCapacity <= sizeof(bitC->bitContainer)) return ERROR(dstSize_tooSmall);
208  return 0;
209 }
#define ERROR(name)
Definition: error_private.h:53
size_t bitContainer
Definition: bitstream.h:75
unsigned bitPos
Definition: bitstream.h:76
char * ptr
Definition: bitstream.h:78
char * endPtr
Definition: bitstream.h:79
char * startPtr
Definition: bitstream.h:77

Referenced by FSE_compress_usingCTable_generic(), HUF_compress1X_usingCTable_internal_body(), and ZSTD_encodeSequences_body().

◆ BIT_initDStream()

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.

Returns
: size of stream (== srcSize), or an errorCode if a problem is detected

Definition at line 287 of file bitstream.h.

288 {
289  if (srcSize < 1) { memset(bitD, 0, sizeof(*bitD)); return ERROR(srcSize_wrong); }
290 
291  bitD->start = (const char*)srcBuffer;
292  bitD->limitPtr = bitD->start + sizeof(bitD->bitContainer);
293 
294  if (srcSize >= sizeof(bitD->bitContainer)) { /* normal case */
295  bitD->ptr = (const char*)srcBuffer + srcSize - sizeof(bitD->bitContainer);
296  bitD->bitContainer = MEM_readLEST(bitD->ptr);
297  { BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1];
298  bitD->bitsConsumed = lastByte ? 8 - BIT_highbit32(lastByte) : 0; /* ensures bitsConsumed is always set */
299  if (lastByte == 0) return ERROR(GENERIC); /* endMark not present */ }
300  } else {
301  bitD->ptr = bitD->start;
302  bitD->bitContainer = *(const BYTE*)(bitD->start);
303  switch(srcSize)
304  {
305  case 7: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[6]) << (sizeof(bitD->bitContainer)*8 - 16);
306  /* fall-through */
307 
308  case 6: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[5]) << (sizeof(bitD->bitContainer)*8 - 24);
309  /* fall-through */
310 
311  case 5: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[4]) << (sizeof(bitD->bitContainer)*8 - 32);
312  /* fall-through */
313 
314  case 4: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[3]) << 24;
315  /* fall-through */
316 
317  case 3: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[2]) << 16;
318  /* fall-through */
319 
320  case 2: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[1]) << 8;
321  /* fall-through */
322 
323  default: break;
324  }
325  { BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1];
326  bitD->bitsConsumed = lastByte ? 8 - BIT_highbit32(lastByte) : 0;
327  if (lastByte == 0) return ERROR(corruption_detected); /* endMark not present */
328  }
329  bitD->bitsConsumed += (U32)(sizeof(bitD->bitContainer) - srcSize)*8;
330  }
331 
332  return srcSize;
333 }
#define ERROR(name)
Definition: error_private.h:53
unsigned int U32
Definition: mem.h:77
MEM_STATIC size_t MEM_readLEST(const void *memPtr)
Definition: mem.h:305
const char * start
Definition: bitstream.h:112
MEM_STATIC unsigned BIT_highbit32(U32 val)
Definition: bitstream.h:156
const char * ptr
Definition: bitstream.h:111
__kernel_size_t size_t
Definition: linux.h:237
size_t bitContainer
Definition: bitstream.h:109
unsigned bitsConsumed
Definition: bitstream.h:110
const char * limitPtr
Definition: bitstream.h:113
unsigned char BYTE
Definition: mem.h:68
#define memset(x, y, z)
Definition: compat.h:39

Referenced by FSE_decompress_usingDTable_generic(), HUF_decompress1X1_usingDTable_internal_body(), HUF_decompress1X2_usingDTable_internal_body(), HUF_decompress4X1_usingDTable_internal_body(), HUF_decompress4X2_usingDTable_internal_body(), ZSTD_decompressSequences_body(), and ZSTD_decompressSequencesLong_body().

◆ BIT_lookBits()

MEM_STATIC 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.

Returns
: value extracted

Definition at line 360 of file bitstream.h.

361 {
362  /* arbitrate between double-shift and shift+mask */
363 #if 1
364  /* if bitD->bitsConsumed + nbBits > sizeof(bitD->bitContainer)*8,
365  * bitstream is likely corrupted, and result is undefined */
366  return BIT_getMiddleBits(bitD->bitContainer, (sizeof(bitD->bitContainer)*8) - bitD->bitsConsumed - nbBits, nbBits);
367 #else
368  /* this code path is slower on my os-x laptop */
369  U32 const regMask = sizeof(bitD->bitContainer)*8 - 1;
370  return ((bitD->bitContainer << (bitD->bitsConsumed & regMask)) >> 1) >> ((regMask-nbBits) & regMask);
371 #endif
372 }
unsigned int U32
Definition: mem.h:77
MEM_STATIC size_t BIT_getMiddleBits(size_t bitContainer, U32 const start, U32 const nbBits)
Definition: bitstream.h:340
size_t bitContainer
Definition: bitstream.h:109
unsigned bitsConsumed
Definition: bitstream.h:110

Referenced by BIT_readBits().

◆ BIT_lookBitsFast()

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 376 of file bitstream.h.

377 {
378  U32 const regMask = sizeof(bitD->bitContainer)*8 - 1;
379  assert(nbBits >= 1);
380  return (bitD->bitContainer << (bitD->bitsConsumed & regMask)) >> (((regMask+1)-nbBits) & regMask);
381 }
unsigned int U32
Definition: mem.h:77
#define assert(x)
Definition: debug.h:53
size_t bitContainer
Definition: bitstream.h:109
unsigned bitsConsumed
Definition: bitstream.h:110

Referenced by BIT_readBitsFast(), HUF_decodeLastSymbolX2(), HUF_decodeSymbolX1(), and HUF_decodeSymbolX2().

◆ BIT_readBits() [1/2]

MEM_STATIC size_t BIT_readBits ( BIT_DStream_t bitD,
unsigned  nbBits 
)

◆ BIT_readBits() [2/2]

MEM_STATIC size_t BIT_readBits ( BIT_DStream_t bitD,
U32  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.

Returns
: extracted value.

Definition at line 392 of file bitstream.h.

393 {
394  size_t const value = BIT_lookBits(bitD, nbBits);
395  BIT_skipBits(bitD, nbBits);
396  return value;
397 }
MEM_STATIC void BIT_skipBits(BIT_DStream_t *bitD, U32 nbBits)
Definition: bitstream.h:383
MEM_STATIC size_t BIT_lookBits(const BIT_DStream_t *bitD, U32 nbBits)
Definition: bitstream.h:360
GLsizei const GLfloat * value
Definition: glext.h:6069

◆ BIT_readBitsFast() [1/2]

MEM_STATIC size_t BIT_readBitsFast ( BIT_DStream_t bitD,
unsigned  nbBits 
)

◆ BIT_readBitsFast() [2/2]

MEM_STATIC size_t BIT_readBitsFast ( BIT_DStream_t bitD,
U32  nbBits 
)

BIT_readBitsFast() : unsafe version; only works only if nbBits >= 1

Definition at line 401 of file bitstream.h.

402 {
403  size_t const value = BIT_lookBitsFast(bitD, nbBits);
404  assert(nbBits >= 1);
405  BIT_skipBits(bitD, nbBits);
406  return value;
407 }
#define assert(x)
Definition: debug.h:53
MEM_STATIC size_t BIT_lookBitsFast(const BIT_DStream_t *bitD, U32 nbBits)
Definition: bitstream.h:376
MEM_STATIC void BIT_skipBits(BIT_DStream_t *bitD, U32 nbBits)
Definition: bitstream.h:383
GLsizei const GLfloat * value
Definition: glext.h:6069

◆ BIT_reloadDStream()

MEM_STATIC 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 read beyond src buffer.

Returns
: status of BIT_DStream_t internal register. when status == BIT_DStream_unfinished, internal register is filled with at least 25 or 57 bits

Definition at line 414 of file bitstream.h.

415 {
416  if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* overflow detected, like end of stream */
417  return BIT_DStream_overflow;
418 
419  if (bitD->ptr >= bitD->limitPtr) {
420  bitD->ptr -= bitD->bitsConsumed >> 3;
421  bitD->bitsConsumed &= 7;
422  bitD->bitContainer = MEM_readLEST(bitD->ptr);
423  return BIT_DStream_unfinished;
424  }
425  if (bitD->ptr == bitD->start) {
426  if (bitD->bitsConsumed < sizeof(bitD->bitContainer)*8) return BIT_DStream_endOfBuffer;
427  return BIT_DStream_completed;
428  }
429  /* start < ptr < limitPtr */
430  { U32 nbBytes = bitD->bitsConsumed >> 3;
432  if (bitD->ptr - nbBytes < bitD->start) {
433  nbBytes = (U32)(bitD->ptr - bitD->start); /* ptr > start */
435  }
436  bitD->ptr -= nbBytes;
437  bitD->bitsConsumed -= nbBytes*8;
438  bitD->bitContainer = MEM_readLEST(bitD->ptr); /* reminder : srcSize > sizeof(bitD->bitContainer), otherwise bitD->ptr == bitD->start */
439  return result;
440  }
441 }
unsigned int U32
Definition: mem.h:77
MEM_STATIC size_t MEM_readLEST(const void *memPtr)
Definition: mem.h:305
const char * start
Definition: bitstream.h:112
const char * ptr
Definition: bitstream.h:111
BIT_DStream_status
Definition: bitstream.h:116
size_t bitContainer
Definition: bitstream.h:109
unsigned bitsConsumed
Definition: bitstream.h:110
const char * limitPtr
Definition: bitstream.h:113
GLuint start
Definition: gl.h:1545
GLuint64EXT * result
Definition: glext.h:11304

Referenced by FSE_decompress_usingDTable_generic(), HUF_decodeStreamX1(), HUF_decodeStreamX2(), HUF_decompress4X1_usingDTable_internal_body(), HUF_decompress4X2_usingDTable_internal_body(), ZSTD_decodeSequence(), ZSTD_decodeSequenceLong(), ZSTD_decompressSequences_body(), ZSTD_decompressSequencesLong_body(), and ZSTD_initFseState().

◆ BIT_skipBits()

MEM_STATIC void BIT_skipBits ( BIT_DStream_t bitD,
U32  nbBits 
)

Definition at line 383 of file bitstream.h.

384 {
385  bitD->bitsConsumed += nbBits;
386 }
unsigned bitsConsumed
Definition: bitstream.h:110

Referenced by BIT_readBits(), BIT_readBitsFast(), HUF_decodeLastSymbolX2(), HUF_decodeSymbolX1(), and HUF_decodeSymbolX2().

Variable Documentation

◆ BIT_mask

const unsigned BIT_mask[]
static
Initial value:
= {
0, 1, 3, 7, 0xF, 0x1F,
0x3F, 0x7F, 0xFF, 0x1FF, 0x3FF, 0x7FF,
0xFFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF, 0x1FFFF,
0x3FFFF, 0x7FFFF, 0xFFFFF, 0x1FFFFF, 0x3FFFFF, 0x7FFFFF,
0xFFFFFF, 0x1FFFFFF, 0x3FFFFFF, 0x7FFFFFF, 0xFFFFFFF, 0x1FFFFFFF,
0x3FFFFFFF, 0x7FFFFFFF}

Definition at line 183 of file bitstream.h.

Referenced by BIT_addBits(), BIT_getLowerBits(), and BIT_getMiddleBits().