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()
262 …case 6: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[5]) << (sizeof(bitD->bitContain… in BIT_initDStream()
263 …case 5: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[4]) << (sizeof(bitD->bitContain… in BIT_initDStream()
264 case 4: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[3]) << 24; in BIT_initDStream()
265 case 3: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[2]) << 16; in BIT_initDStream()
266 case 2: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[1]) << 8; in BIT_initDStream()
271 bitD->bitsConsumed = lastByte ? 8 - BIT_highbit32(lastByte) : 0; in BIT_initDStream()
275 bitD->bitsConsumed += (U32)(sizeof(bitD->bitContainer) - srcSize) * 8; in BIT_initDStream()
294 ZSTD_STATIC size_t BIT_lookBits(const BIT_DStream_t *bitD, U32 nbBits) in BIT_lookBits() argument
296 U32 const bitMask = sizeof(bitD->bitContainer) * 8 - 1; in BIT_lookBits()
297 …return ((bitD->bitContainer << (bitD->bitsConsumed & bitMask)) >> 1) >> ((bitMask - nbBits) & bitM… in BIT_lookBits()
302 ZSTD_STATIC size_t BIT_lookBitsFast(const BIT_DStream_t *bitD, U32 nbBits) in BIT_lookBitsFast() argument
304 U32 const bitMask = sizeof(bitD->bitContainer) * 8 - 1; in BIT_lookBitsFast()
305 …return (bitD->bitContainer << (bitD->bitsConsumed & bitMask)) >> (((bitMask + 1) - nbBits) & bitMa… in BIT_lookBitsFast()
308 ZSTD_STATIC void BIT_skipBits(BIT_DStream_t *bitD, U32 nbBits) { bitD->bitsConsumed += nbBits; } in BIT_skipBits() argument
315 ZSTD_STATIC size_t BIT_readBits(BIT_DStream_t *bitD, U32 nbBits) in BIT_readBits() argument
317 size_t const value = BIT_lookBits(bitD, nbBits); in BIT_readBits()
318 BIT_skipBits(bitD, nbBits); in BIT_readBits()
324 ZSTD_STATIC size_t BIT_readBitsFast(BIT_DStream_t *bitD, U32 nbBits) in BIT_readBitsFast() argument
326 size_t const value = BIT_lookBitsFast(bitD, nbBits); in BIT_readBitsFast()
327 BIT_skipBits(bitD, nbBits); in BIT_readBitsFast()
336 ZSTD_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t *bitD) in BIT_reloadDStream() argument
338 …if (bitD->bitsConsumed > (sizeof(bitD->bitContainer) * 8)) /* should not happen => corruption dete… in BIT_reloadDStream()
341 if (bitD->ptr >= bitD->start + sizeof(bitD->bitContainer)) { in BIT_reloadDStream()
342 bitD->ptr -= bitD->bitsConsumed >> 3; in BIT_reloadDStream()
343 bitD->bitsConsumed &= 7; in BIT_reloadDStream()
344 bitD->bitContainer = ZSTD_readLEST(bitD->ptr); in BIT_reloadDStream()
347 if (bitD->ptr == bitD->start) { in BIT_reloadDStream()
348 if (bitD->bitsConsumed < sizeof(bitD->bitContainer) * 8) in BIT_reloadDStream()
353 U32 nbBytes = bitD->bitsConsumed >> 3; in BIT_reloadDStream()
355 if (bitD->ptr - nbBytes < bitD->start) { in BIT_reloadDStream()
356 nbBytes = (U32)(bitD->ptr - bitD->start); /* ptr > start */ in BIT_reloadDStream()
359 bitD->ptr -= nbBytes; in BIT_reloadDStream()
360 bitD->bitsConsumed -= nbBytes * 8; in BIT_reloadDStream()
361 bitD->bitContainer = ZSTD_readLEST(bitD->ptr); /* reminder : srcSize > sizeof(bitD) */ in BIT_reloadDStream()