Lines Matching refs:hBitBuf
117 void FDK_CreateBitBuffer(HANDLE_FDK_BITBUF *hBitBuf, UCHAR *pBuffer, in FDK_CreateBitBuffer() argument
119 FDK_InitBitBuffer(*hBitBuf, pBuffer, bufSize, 0); in FDK_CreateBitBuffer()
121 FDKmemclear((*hBitBuf)->Buffer, bufSize * sizeof(UCHAR)); in FDK_CreateBitBuffer()
124 void FDK_DeleteBitBuffer(HANDLE_FDK_BITBUF hBitBuf) { ; } in FDK_DeleteBitBuffer() argument
126 void FDK_InitBitBuffer(HANDLE_FDK_BITBUF hBitBuf, UCHAR *pBuffer, UINT bufSize, in FDK_InitBitBuffer() argument
128 hBitBuf->ValidBits = validBits; in FDK_InitBitBuffer()
129 hBitBuf->ReadOffset = 0; in FDK_InitBitBuffer()
130 hBitBuf->WriteOffset = 0; in FDK_InitBitBuffer()
131 hBitBuf->BitNdx = 0; in FDK_InitBitBuffer()
133 hBitBuf->Buffer = pBuffer; in FDK_InitBitBuffer()
134 hBitBuf->bufSize = bufSize; in FDK_InitBitBuffer()
135 hBitBuf->bufBits = (bufSize << 3); in FDK_InitBitBuffer()
137 FDK_ASSERT(hBitBuf->ValidBits <= hBitBuf->bufBits); in FDK_InitBitBuffer()
149 void FDK_ResetBitBuffer(HANDLE_FDK_BITBUF hBitBuf) { in FDK_ResetBitBuffer() argument
150 hBitBuf->ValidBits = 0; in FDK_ResetBitBuffer()
151 hBitBuf->ReadOffset = 0; in FDK_ResetBitBuffer()
152 hBitBuf->WriteOffset = 0; in FDK_ResetBitBuffer()
153 hBitBuf->BitNdx = 0; in FDK_ResetBitBuffer()
157 INT FDK_get(HANDLE_FDK_BITBUF hBitBuf, const UINT numberOfBits) { in FDK_get() argument
158 UINT byteOffset = hBitBuf->BitNdx >> 3; in FDK_get()
159 UINT bitOffset = hBitBuf->BitNdx & 0x07; in FDK_get()
161 hBitBuf->BitNdx = (hBitBuf->BitNdx + numberOfBits) & (hBitBuf->bufBits - 1); in FDK_get()
162 hBitBuf->ValidBits -= numberOfBits; in FDK_get()
164 UINT byteMask = hBitBuf->bufSize - 1; in FDK_get()
166 UINT tx = (hBitBuf->Buffer[byteOffset & byteMask] << 24) | in FDK_get()
167 (hBitBuf->Buffer[(byteOffset + 1) & byteMask] << 16) | in FDK_get()
168 (hBitBuf->Buffer[(byteOffset + 2) & byteMask] << 8) | in FDK_get()
169 hBitBuf->Buffer[(byteOffset + 3) & byteMask]; in FDK_get()
173 tx |= hBitBuf->Buffer[(byteOffset + 4) & byteMask] >> (8 - bitOffset); in FDK_get()
181 INT FDK_get32(HANDLE_FDK_BITBUF hBitBuf) { in FDK_get32() argument
182 UINT BitNdx = hBitBuf->BitNdx + 32; in FDK_get32()
183 hBitBuf->BitNdx = BitNdx & (hBitBuf->bufBits - 1); in FDK_get32()
184 hBitBuf->ValidBits = (UINT)((INT)hBitBuf->ValidBits - (INT)32); in FDK_get32()
187 if (BitNdx <= hBitBuf->bufBits) { in FDK_get32()
188 UINT cache = (hBitBuf->Buffer[(byteOffset - 3)] << 24) | in FDK_get32()
189 (hBitBuf->Buffer[(byteOffset - 2)] << 16) | in FDK_get32()
190 (hBitBuf->Buffer[(byteOffset - 1)] << 8) | in FDK_get32()
191 hBitBuf->Buffer[(byteOffset - 0)]; in FDK_get32()
195 ((UINT)hBitBuf->Buffer[byteOffset - 4] << (24 + BitNdx)); in FDK_get32()
199 UINT byte_mask = hBitBuf->bufSize - 1; in FDK_get32()
200 UINT cache = (hBitBuf->Buffer[(byteOffset - 3) & byte_mask] << 24) | in FDK_get32()
201 (hBitBuf->Buffer[(byteOffset - 2) & byte_mask] << 16) | in FDK_get32()
202 (hBitBuf->Buffer[(byteOffset - 1) & byte_mask] << 8) | in FDK_get32()
203 hBitBuf->Buffer[(byteOffset - 0) & byte_mask]; in FDK_get32()
207 ((UINT)hBitBuf->Buffer[(byteOffset - 4) & byte_mask] in FDK_get32()
215 INT FDK_getBwd(HANDLE_FDK_BITBUF hBitBuf, const UINT numberOfBits) { in FDK_getBwd() argument
216 UINT byteOffset = hBitBuf->BitNdx >> 3; in FDK_getBwd()
217 UINT bitOffset = hBitBuf->BitNdx & 0x07; in FDK_getBwd()
218 UINT byteMask = hBitBuf->bufSize - 1; in FDK_getBwd()
221 hBitBuf->BitNdx = (hBitBuf->BitNdx - numberOfBits) & (hBitBuf->bufBits - 1); in FDK_getBwd()
222 hBitBuf->ValidBits += numberOfBits; in FDK_getBwd()
224 UINT tx = hBitBuf->Buffer[(byteOffset - 3) & byteMask] << 24 | in FDK_getBwd()
225 hBitBuf->Buffer[(byteOffset - 2) & byteMask] << 16 | in FDK_getBwd()
226 hBitBuf->Buffer[(byteOffset - 1) & byteMask] << 8 | in FDK_getBwd()
227 hBitBuf->Buffer[byteOffset & byteMask]; in FDK_getBwd()
233 tx |= hBitBuf->Buffer[(byteOffset - 4) & byteMask] << (24 + bitOffset); in FDK_getBwd()
248 void FDK_put(HANDLE_FDK_BITBUF hBitBuf, UINT value, const UINT numberOfBits) { in FDK_put() argument
250 UINT byteOffset0 = hBitBuf->BitNdx >> 3; in FDK_put()
251 UINT bitOffset = hBitBuf->BitNdx & 0x7; in FDK_put()
253 hBitBuf->BitNdx = (hBitBuf->BitNdx + numberOfBits) & (hBitBuf->bufBits - 1); in FDK_put()
254 hBitBuf->ValidBits += numberOfBits; in FDK_put()
256 UINT byteMask = hBitBuf->bufSize - 1; in FDK_put()
269 UINT cache = (((UINT)hBitBuf->Buffer[byteOffset0]) << 24) | in FDK_put()
270 (((UINT)hBitBuf->Buffer[byteOffset1]) << 16) | in FDK_put()
271 (((UINT)hBitBuf->Buffer[byteOffset2]) << 8) | in FDK_put()
272 (((UINT)hBitBuf->Buffer[byteOffset3]) << 0); in FDK_put()
275 hBitBuf->Buffer[byteOffset0] = (UCHAR)(cache >> 24); in FDK_put()
276 hBitBuf->Buffer[byteOffset1] = (UCHAR)(cache >> 16); in FDK_put()
277 hBitBuf->Buffer[byteOffset2] = (UCHAR)(cache >> 8); in FDK_put()
278 hBitBuf->Buffer[byteOffset3] = (UCHAR)(cache >> 0); in FDK_put()
286 (UINT)hBitBuf->Buffer[byteOffset4] & (~(BitMask[bits] << (8 - bits))); in FDK_put()
288 hBitBuf->Buffer[byteOffset4] = (UCHAR)cache; in FDK_put()
293 void FDK_putBwd(HANDLE_FDK_BITBUF hBitBuf, UINT value, in FDK_putBwd() argument
295 UINT byteOffset = hBitBuf->BitNdx >> 3; in FDK_putBwd()
296 UINT bitOffset = 7 - (hBitBuf->BitNdx & 0x07); in FDK_putBwd()
297 UINT byteMask = hBitBuf->bufSize - 1; in FDK_putBwd()
303 hBitBuf->BitNdx = (hBitBuf->BitNdx - numberOfBits) & (hBitBuf->bufBits - 1); in FDK_putBwd()
304 hBitBuf->ValidBits -= numberOfBits; in FDK_putBwd()
317 hBitBuf->Buffer[byteOffset & byteMask] = in FDK_putBwd()
318 (hBitBuf->Buffer[byteOffset & byteMask] & (mask)) | (UCHAR)(tmp); in FDK_putBwd()
319 hBitBuf->Buffer[(byteOffset - 1) & byteMask] = in FDK_putBwd()
320 (hBitBuf->Buffer[(byteOffset - 1) & byteMask] & (mask >> 8)) | in FDK_putBwd()
322 hBitBuf->Buffer[(byteOffset - 2) & byteMask] = in FDK_putBwd()
323 (hBitBuf->Buffer[(byteOffset - 2) & byteMask] & (mask >> 16)) | in FDK_putBwd()
325 hBitBuf->Buffer[(byteOffset - 3) & byteMask] = in FDK_putBwd()
326 (hBitBuf->Buffer[(byteOffset - 3) & byteMask] & (mask >> 24)) | in FDK_putBwd()
330 hBitBuf->Buffer[(byteOffset - 4) & byteMask] = in FDK_putBwd()
332 (hBitBuf->Buffer[(byteOffset - 4) & byteMask] & in FDK_putBwd()
338 void FDK_pushBack(HANDLE_FDK_BITBUF hBitBuf, const UINT numberOfBits, in FDK_pushBack() argument
340 hBitBuf->ValidBits = in FDK_pushBack()
341 (config == 0) ? (UINT)((INT)hBitBuf->ValidBits + (INT)numberOfBits) in FDK_pushBack()
342 : ((UINT)((INT)hBitBuf->ValidBits - (INT)numberOfBits)); in FDK_pushBack()
343 hBitBuf->BitNdx = ((UINT)((INT)hBitBuf->BitNdx - (INT)numberOfBits)) & in FDK_pushBack()
344 (hBitBuf->bufBits - 1); in FDK_pushBack()
348 void FDK_pushForward(HANDLE_FDK_BITBUF hBitBuf, const UINT numberOfBits, in FDK_pushForward() argument
350 hBitBuf->ValidBits = in FDK_pushForward()
351 (config == 0) ? ((UINT)((INT)hBitBuf->ValidBits - (INT)numberOfBits)) in FDK_pushForward()
352 : (UINT)((INT)hBitBuf->ValidBits + (INT)numberOfBits); in FDK_pushForward()
353 hBitBuf->BitNdx = in FDK_pushForward()
354 (UINT)((INT)hBitBuf->BitNdx + (INT)numberOfBits) & (hBitBuf->bufBits - 1); in FDK_pushForward()
358 UINT FDK_getValidBits(HANDLE_FDK_BITBUF hBitBuf) { return hBitBuf->ValidBits; } in FDK_getValidBits() argument
361 INT FDK_getFreeBits(HANDLE_FDK_BITBUF hBitBuf) { in FDK_getFreeBits() argument
362 return (hBitBuf->bufBits - hBitBuf->ValidBits); in FDK_getFreeBits()
365 void FDK_Feed(HANDLE_FDK_BITBUF hBitBuf, const UCHAR *RESTRICT inputBuffer, in FDK_Feed() argument
372 fMin(hBitBuf->bufBits, in FDK_Feed()
373 (UINT)fMax(0, ((INT)hBitBuf->bufBits - (INT)hBitBuf->ValidBits))) >> in FDK_Feed()
381 bToRead = hBitBuf->bufSize - hBitBuf->ReadOffset; in FDK_Feed()
386 FDKmemcpy(&hBitBuf->Buffer[hBitBuf->ReadOffset], inputBuffer, in FDK_Feed()
390 hBitBuf->ValidBits = (UINT)((INT)hBitBuf->ValidBits + (INT)(bToRead << 3)); in FDK_Feed()
394 hBitBuf->ReadOffset = in FDK_Feed()
395 (hBitBuf->ReadOffset + bToRead) & (hBitBuf->bufSize - 1); in FDK_Feed()
462 void FDK_Fetch(HANDLE_FDK_BITBUF hBitBuf, UCHAR *outBuf, UINT *writeBytes) { in FDK_Fetch() argument
466 UINT bToWrite = (hBitBuf->ValidBits) >> 3; in FDK_Fetch()
473 bToWrite = hBitBuf->bufSize - hBitBuf->WriteOffset; in FDK_Fetch()
478 FDKmemcpy(outputBuffer, &hBitBuf->Buffer[hBitBuf->WriteOffset], in FDK_Fetch()
482 hBitBuf->ValidBits -= bToWrite << 3; in FDK_Fetch()
486 hBitBuf->WriteOffset = in FDK_Fetch()
487 (hBitBuf->WriteOffset + bToWrite) & (hBitBuf->bufSize - 1); in FDK_Fetch()