Lines Matching refs:bitD
96 MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, size_t srcSize);
97 MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, unsigned nbBits);
98 MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD);
99 MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* bitD);
122 MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, unsigned nbBits);
258 MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, size_t srcSize) in BIT_initDStream() argument
260 if (srcSize < 1) { ZSTD_memset(bitD, 0, sizeof(*bitD)); return ERROR(srcSize_wrong); } in BIT_initDStream()
262 bitD->start = (const char*)srcBuffer; in BIT_initDStream()
263 bitD->limitPtr = bitD->start + sizeof(bitD->bitContainer); in BIT_initDStream()
265 if (srcSize >= sizeof(bitD->bitContainer)) { /* normal case */ in BIT_initDStream()
266 bitD->ptr = (const char*)srcBuffer + srcSize - sizeof(bitD->bitContainer); in BIT_initDStream()
267 bitD->bitContainer = MEM_readLEST(bitD->ptr); in BIT_initDStream()
269 …bitD->bitsConsumed = lastByte ? 8 - BIT_highbit32(lastByte) : 0; /* ensures bitsConsumed is alway… in BIT_initDStream()
272 bitD->ptr = bitD->start; in BIT_initDStream()
273 bitD->bitContainer = *(const BYTE*)(bitD->start); in BIT_initDStream()
276 …case 7: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[6]) << (sizeof(bitD->bitContaine… in BIT_initDStream()
279 …case 6: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[5]) << (sizeof(bitD->bitContaine… in BIT_initDStream()
282 …case 5: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[4]) << (sizeof(bitD->bitContaine… in BIT_initDStream()
285 case 4: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[3]) << 24; in BIT_initDStream()
288 case 3: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[2]) << 16; in BIT_initDStream()
291 case 2: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[1]) << 8; in BIT_initDStream()
297 bitD->bitsConsumed = lastByte ? 8 - BIT_highbit32(lastByte) : 0; in BIT_initDStream()
300 bitD->bitsConsumed += (U32)(sizeof(bitD->bitContainer) - srcSize)*8; in BIT_initDStream()
340 MEM_STATIC FORCE_INLINE_ATTR size_t BIT_lookBits(const BIT_DStream_t* bitD, U32 nbBits) in BIT_lookBits() argument
346 …return BIT_getMiddleBits(bitD->bitContainer, (sizeof(bitD->bitContainer)*8) - bitD->bitsConsumed -… in BIT_lookBits()
349 U32 const regMask = sizeof(bitD->bitContainer)*8 - 1; in BIT_lookBits()
350 …return ((bitD->bitContainer << (bitD->bitsConsumed & regMask)) >> 1) >> ((regMask-nbBits) & regMas… in BIT_lookBits()
356 MEM_STATIC size_t BIT_lookBitsFast(const BIT_DStream_t* bitD, U32 nbBits) in BIT_lookBitsFast() argument
358 U32 const regMask = sizeof(bitD->bitContainer)*8 - 1; in BIT_lookBitsFast()
360 … return (bitD->bitContainer << (bitD->bitsConsumed & regMask)) >> (((regMask+1)-nbBits) & regMask); in BIT_lookBitsFast()
363 MEM_STATIC FORCE_INLINE_ATTR void BIT_skipBits(BIT_DStream_t* bitD, U32 nbBits) in BIT_skipBits() argument
365 bitD->bitsConsumed += nbBits; in BIT_skipBits()
372 MEM_STATIC FORCE_INLINE_ATTR size_t BIT_readBits(BIT_DStream_t* bitD, unsigned nbBits) in BIT_readBits() argument
374 size_t const value = BIT_lookBits(bitD, nbBits); in BIT_readBits()
375 BIT_skipBits(bitD, nbBits); in BIT_readBits()
381 MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, unsigned nbBits) in BIT_readBitsFast() argument
383 size_t const value = BIT_lookBitsFast(bitD, nbBits); in BIT_readBitsFast()
385 BIT_skipBits(bitD, nbBits); in BIT_readBitsFast()
395 MEM_STATIC BIT_DStream_status BIT_reloadDStreamFast(BIT_DStream_t* bitD) in BIT_reloadDStreamFast() argument
397 if (UNLIKELY(bitD->ptr < bitD->limitPtr)) in BIT_reloadDStreamFast()
399 assert(bitD->bitsConsumed <= sizeof(bitD->bitContainer)*8); in BIT_reloadDStreamFast()
400 bitD->ptr -= bitD->bitsConsumed >> 3; in BIT_reloadDStreamFast()
401 bitD->bitsConsumed &= 7; in BIT_reloadDStreamFast()
402 bitD->bitContainer = MEM_readLEST(bitD->ptr); in BIT_reloadDStreamFast()
411 MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD) in BIT_reloadDStream() argument
413 …if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* overflow detected, like end of stream… in BIT_reloadDStream()
416 if (bitD->ptr >= bitD->limitPtr) { in BIT_reloadDStream()
417 return BIT_reloadDStreamFast(bitD); in BIT_reloadDStream()
419 if (bitD->ptr == bitD->start) { in BIT_reloadDStream()
420 if (bitD->bitsConsumed < sizeof(bitD->bitContainer)*8) return BIT_DStream_endOfBuffer; in BIT_reloadDStream()
424 { U32 nbBytes = bitD->bitsConsumed >> 3; in BIT_reloadDStream()
426 if (bitD->ptr - nbBytes < bitD->start) { in BIT_reloadDStream()
427 nbBytes = (U32)(bitD->ptr - bitD->start); /* ptr > start */ in BIT_reloadDStream()
430 bitD->ptr -= nbBytes; in BIT_reloadDStream()
431 bitD->bitsConsumed -= nbBytes*8; in BIT_reloadDStream()
432 …bitD->bitContainer = MEM_readLEST(bitD->ptr); /* reminder : srcSize > sizeof(bitD->bitContainer)… in BIT_reloadDStream()