Lines Matching refs:bitC
56 MEM_STATIC size_t BIT_initCStream(BIT_CStream_t* bitC, void* dstBuffer, size_t dstCapacity);
57 MEM_STATIC void BIT_addBits(BIT_CStream_t* bitC, size_t value, unsigned nbBits);
58 MEM_STATIC void BIT_flushBits(BIT_CStream_t* bitC);
59 MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC);
116 MEM_STATIC void BIT_addBitsFast(BIT_CStream_t* bitC, size_t value, unsigned nbBits);
119 MEM_STATIC void BIT_flushBitsFast(BIT_CStream_t* bitC);
169 MEM_STATIC size_t BIT_initCStream(BIT_CStream_t* bitC, in BIT_initCStream() argument
172 bitC->bitContainer = 0; in BIT_initCStream()
173 bitC->bitPos = 0; in BIT_initCStream()
174 bitC->startPtr = (char*)startPtr; in BIT_initCStream()
175 bitC->ptr = bitC->startPtr; in BIT_initCStream()
176 bitC->endPtr = bitC->startPtr + dstCapacity - sizeof(bitC->bitContainer); in BIT_initCStream()
177 if (dstCapacity <= sizeof(bitC->bitContainer)) return ERROR(dstSize_tooSmall); in BIT_initCStream()
184 MEM_STATIC void BIT_addBits(BIT_CStream_t* bitC, in BIT_addBits() argument
189 assert(nbBits + bitC->bitPos < sizeof(bitC->bitContainer) * 8); in BIT_addBits()
190 bitC->bitContainer |= (value & BIT_mask[nbBits]) << bitC->bitPos; in BIT_addBits()
191 bitC->bitPos += nbBits; in BIT_addBits()
197 MEM_STATIC void BIT_addBitsFast(BIT_CStream_t* bitC, in BIT_addBitsFast() argument
201 assert(nbBits + bitC->bitPos < sizeof(bitC->bitContainer) * 8); in BIT_addBitsFast()
202 bitC->bitContainer |= value << bitC->bitPos; in BIT_addBitsFast()
203 bitC->bitPos += nbBits; in BIT_addBitsFast()
209 MEM_STATIC void BIT_flushBitsFast(BIT_CStream_t* bitC) in BIT_flushBitsFast() argument
211 size_t const nbBytes = bitC->bitPos >> 3; in BIT_flushBitsFast()
212 assert(bitC->bitPos < sizeof(bitC->bitContainer) * 8); in BIT_flushBitsFast()
213 assert(bitC->ptr <= bitC->endPtr); in BIT_flushBitsFast()
214 MEM_writeLEST(bitC->ptr, bitC->bitContainer); in BIT_flushBitsFast()
215 bitC->ptr += nbBytes; in BIT_flushBitsFast()
216 bitC->bitPos &= 7; in BIT_flushBitsFast()
217 bitC->bitContainer >>= nbBytes*8; in BIT_flushBitsFast()
225 MEM_STATIC void BIT_flushBits(BIT_CStream_t* bitC) in BIT_flushBits() argument
227 size_t const nbBytes = bitC->bitPos >> 3; in BIT_flushBits()
228 assert(bitC->bitPos < sizeof(bitC->bitContainer) * 8); in BIT_flushBits()
229 assert(bitC->ptr <= bitC->endPtr); in BIT_flushBits()
230 MEM_writeLEST(bitC->ptr, bitC->bitContainer); in BIT_flushBits()
231 bitC->ptr += nbBytes; in BIT_flushBits()
232 if (bitC->ptr > bitC->endPtr) bitC->ptr = bitC->endPtr; in BIT_flushBits()
233 bitC->bitPos &= 7; in BIT_flushBits()
234 bitC->bitContainer >>= nbBytes*8; in BIT_flushBits()
240 MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC) in BIT_closeCStream() argument
242 BIT_addBitsFast(bitC, 1, 1); /* endMark */ in BIT_closeCStream()
243 BIT_flushBits(bitC); in BIT_closeCStream()
244 if (bitC->ptr >= bitC->endPtr) return 0; /* overflow detected */ in BIT_closeCStream()
245 return (bitC->ptr - bitC->startPtr) + (bitC->bitPos > 0); in BIT_closeCStream()