Lines Matching refs:bitD
118 ZSTD_STATIC size_t BIT_initDStream(BIT_DStream_t *bitD, const void *srcBuffer, size_t srcSize);
119 ZSTD_STATIC size_t BIT_readBits(BIT_DStream_t *bitD, unsigned nbBits);
120 ZSTD_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t *bitD);
121 ZSTD_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t *bitD);
142 ZSTD_STATIC size_t BIT_readBitsFast(BIT_DStream_t *bitD, unsigned nbBits);
239 ZSTD_STATIC size_t BIT_initDStream(BIT_DStream_t *bitD, const void *srcBuffer, size_t srcSize) in BIT_initDStream() argument
242 memset(bitD, 0, sizeof(*bitD)); in BIT_initDStream()
246 if (srcSize >= sizeof(bitD->bitContainer)) { /* normal case */ in BIT_initDStream()
247 bitD->start = (const char *)srcBuffer; in BIT_initDStream()
248 bitD->ptr = (const char *)srcBuffer + srcSize - sizeof(bitD->bitContainer); in BIT_initDStream()
249 bitD->bitContainer = ZSTD_readLEST(bitD->ptr); in BIT_initDStream()
252 …bitD->bitsConsumed = lastByte ? 8 - BIT_highbit32(lastByte) : 0; /* ensures bitsConsumed is always… in BIT_initDStream()
257 bitD->start = (const char *)srcBuffer; in BIT_initDStream()
258 bitD->ptr = bitD->start; in BIT_initDStream()
259 bitD->bitContainer = *(const BYTE *)(bitD->start); in BIT_initDStream()
261 …case 7: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[6]) << (sizeof(bitD->bitContain… in BIT_initDStream()
263 …case 6: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[5]) << (sizeof(bitD->bitContain… in BIT_initDStream()
265 …case 5: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[4]) << (sizeof(bitD->bitContain… in BIT_initDStream()
267 case 4: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[3]) << 24; in BIT_initDStream()
269 case 3: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[2]) << 16; in BIT_initDStream()
271 case 2: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[1]) << 8; in BIT_initDStream()
276 bitD->bitsConsumed = lastByte ? 8 - BIT_highbit32(lastByte) : 0; in BIT_initDStream()
280 bitD->bitsConsumed += (U32)(sizeof(bitD->bitContainer) - srcSize) * 8; in BIT_initDStream()
299 ZSTD_STATIC size_t BIT_lookBits(const BIT_DStream_t *bitD, U32 nbBits) in BIT_lookBits() argument
301 U32 const bitMask = sizeof(bitD->bitContainer) * 8 - 1; in BIT_lookBits()
302 …return ((bitD->bitContainer << (bitD->bitsConsumed & bitMask)) >> 1) >> ((bitMask - nbBits) & bitM… in BIT_lookBits()
307 ZSTD_STATIC size_t BIT_lookBitsFast(const BIT_DStream_t *bitD, U32 nbBits) in BIT_lookBitsFast() argument
309 U32 const bitMask = sizeof(bitD->bitContainer) * 8 - 1; in BIT_lookBitsFast()
310 …return (bitD->bitContainer << (bitD->bitsConsumed & bitMask)) >> (((bitMask + 1) - nbBits) & bitMa… in BIT_lookBitsFast()
313 ZSTD_STATIC void BIT_skipBits(BIT_DStream_t *bitD, U32 nbBits) { bitD->bitsConsumed += nbBits; } in BIT_skipBits() argument
320 ZSTD_STATIC size_t BIT_readBits(BIT_DStream_t *bitD, U32 nbBits) in BIT_readBits() argument
322 size_t const value = BIT_lookBits(bitD, nbBits); in BIT_readBits()
323 BIT_skipBits(bitD, nbBits); in BIT_readBits()
329 ZSTD_STATIC size_t BIT_readBitsFast(BIT_DStream_t *bitD, U32 nbBits) in BIT_readBitsFast() argument
331 size_t const value = BIT_lookBitsFast(bitD, nbBits); in BIT_readBitsFast()
332 BIT_skipBits(bitD, nbBits); in BIT_readBitsFast()
341 ZSTD_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t *bitD) in BIT_reloadDStream() argument
343 …if (bitD->bitsConsumed > (sizeof(bitD->bitContainer) * 8)) /* should not happen => corruption dete… in BIT_reloadDStream()
346 if (bitD->ptr >= bitD->start + sizeof(bitD->bitContainer)) { in BIT_reloadDStream()
347 bitD->ptr -= bitD->bitsConsumed >> 3; in BIT_reloadDStream()
348 bitD->bitsConsumed &= 7; in BIT_reloadDStream()
349 bitD->bitContainer = ZSTD_readLEST(bitD->ptr); in BIT_reloadDStream()
352 if (bitD->ptr == bitD->start) { in BIT_reloadDStream()
353 if (bitD->bitsConsumed < sizeof(bitD->bitContainer) * 8) in BIT_reloadDStream()
358 U32 nbBytes = bitD->bitsConsumed >> 3; in BIT_reloadDStream()
360 if (bitD->ptr - nbBytes < bitD->start) { in BIT_reloadDStream()
361 nbBytes = (U32)(bitD->ptr - bitD->start); /* ptr > start */ in BIT_reloadDStream()
364 bitD->ptr -= nbBytes; in BIT_reloadDStream()
365 bitD->bitsConsumed -= nbBytes * 8; in BIT_reloadDStream()
366 bitD->bitContainer = ZSTD_readLEST(bitD->ptr); /* reminder : srcSize > sizeof(bitD) */ in BIT_reloadDStream()