Lines Matching refs:bitD
88 ZSTD_STATIC size_t BIT_initDStream(BIT_DStream_t *bitD, const void *srcBuffer, size_t srcSize);
89 ZSTD_STATIC size_t BIT_readBits(BIT_DStream_t *bitD, unsigned nbBits);
90 ZSTD_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t *bitD);
91 ZSTD_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t *bitD);
112 ZSTD_STATIC size_t BIT_readBitsFast(BIT_DStream_t *bitD, unsigned nbBits);
209 ZSTD_STATIC size_t BIT_initDStream(BIT_DStream_t *bitD, const void *srcBuffer, size_t srcSize) in BIT_initDStream() argument
212 memset(bitD, 0, sizeof(*bitD)); in BIT_initDStream()
216 if (srcSize >= sizeof(bitD->bitContainer)) { /* normal case */ in BIT_initDStream()
217 bitD->start = (const char *)srcBuffer; in BIT_initDStream()
218 bitD->ptr = (const char *)srcBuffer + srcSize - sizeof(bitD->bitContainer); in BIT_initDStream()
219 bitD->bitContainer = ZSTD_readLEST(bitD->ptr); in BIT_initDStream()
222 …bitD->bitsConsumed = lastByte ? 8 - BIT_highbit32(lastByte) : 0; /* ensures bitsConsumed is always… in BIT_initDStream()
227 bitD->start = (const char *)srcBuffer; in BIT_initDStream()
228 bitD->ptr = bitD->start; in BIT_initDStream()
229 bitD->bitContainer = *(const BYTE *)(bitD->start); in BIT_initDStream()
231 …case 7: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[6]) << (sizeof(bitD->bitContain… in BIT_initDStream()
232 …case 6: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[5]) << (sizeof(bitD->bitContain… in BIT_initDStream()
233 …case 5: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[4]) << (sizeof(bitD->bitContain… in BIT_initDStream()
234 case 4: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[3]) << 24; in BIT_initDStream()
235 case 3: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[2]) << 16; in BIT_initDStream()
236 case 2: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[1]) << 8; in BIT_initDStream()
241 bitD->bitsConsumed = lastByte ? 8 - BIT_highbit32(lastByte) : 0; in BIT_initDStream()
245 bitD->bitsConsumed += (U32)(sizeof(bitD->bitContainer) - srcSize) * 8; in BIT_initDStream()
264 ZSTD_STATIC size_t BIT_lookBits(const BIT_DStream_t *bitD, U32 nbBits) in BIT_lookBits() argument
266 U32 const bitMask = sizeof(bitD->bitContainer) * 8 - 1; in BIT_lookBits()
267 …return ((bitD->bitContainer << (bitD->bitsConsumed & bitMask)) >> 1) >> ((bitMask - nbBits) & bitM… in BIT_lookBits()
272 ZSTD_STATIC size_t BIT_lookBitsFast(const BIT_DStream_t *bitD, U32 nbBits) in BIT_lookBitsFast() argument
274 U32 const bitMask = sizeof(bitD->bitContainer) * 8 - 1; in BIT_lookBitsFast()
275 …return (bitD->bitContainer << (bitD->bitsConsumed & bitMask)) >> (((bitMask + 1) - nbBits) & bitMa… in BIT_lookBitsFast()
278 ZSTD_STATIC void BIT_skipBits(BIT_DStream_t *bitD, U32 nbBits) { bitD->bitsConsumed += nbBits; } in BIT_skipBits() argument
285 ZSTD_STATIC size_t BIT_readBits(BIT_DStream_t *bitD, U32 nbBits) in BIT_readBits() argument
287 size_t const value = BIT_lookBits(bitD, nbBits); in BIT_readBits()
288 BIT_skipBits(bitD, nbBits); in BIT_readBits()
294 ZSTD_STATIC size_t BIT_readBitsFast(BIT_DStream_t *bitD, U32 nbBits) in BIT_readBitsFast() argument
296 size_t const value = BIT_lookBitsFast(bitD, nbBits); in BIT_readBitsFast()
297 BIT_skipBits(bitD, nbBits); in BIT_readBitsFast()
306 ZSTD_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t *bitD) in BIT_reloadDStream() argument
308 …if (bitD->bitsConsumed > (sizeof(bitD->bitContainer) * 8)) /* should not happen => corruption dete… in BIT_reloadDStream()
311 if (bitD->ptr >= bitD->start + sizeof(bitD->bitContainer)) { in BIT_reloadDStream()
312 bitD->ptr -= bitD->bitsConsumed >> 3; in BIT_reloadDStream()
313 bitD->bitsConsumed &= 7; in BIT_reloadDStream()
314 bitD->bitContainer = ZSTD_readLEST(bitD->ptr); in BIT_reloadDStream()
317 if (bitD->ptr == bitD->start) { in BIT_reloadDStream()
318 if (bitD->bitsConsumed < sizeof(bitD->bitContainer) * 8) in BIT_reloadDStream()
323 U32 nbBytes = bitD->bitsConsumed >> 3; in BIT_reloadDStream()
325 if (bitD->ptr - nbBytes < bitD->start) { in BIT_reloadDStream()
326 nbBytes = (U32)(bitD->ptr - bitD->start); /* ptr > start */ in BIT_reloadDStream()
329 bitD->ptr -= nbBytes; in BIT_reloadDStream()
330 bitD->bitsConsumed -= nbBytes * 8; in BIT_reloadDStream()
331 bitD->bitContainer = ZSTD_readLEST(bitD->ptr); /* reminder : srcSize > sizeof(bitD) */ in BIT_reloadDStream()