Lines Matching refs:hBitStream
139 HANDLE_FDK_BITSTREAM hBitStream = variable
141 if (hBitStream == NULL) return NULL;
142 FDK_InitBitBuffer(&hBitStream->hBitBuf, pBuffer, bufSize, 0);
145 hBitStream->CacheWord = hBitStream->BitsInCache = 0;
146 hBitStream->ConfigCache = config;
148 return hBitStream;
164 void FDKinitBitStream(HANDLE_FDK_BITSTREAM hBitStream, UCHAR *pBuffer,
167 FDK_InitBitBuffer(&hBitStream->hBitBuf, pBuffer, bufSize, validBits);
170 hBitStream->CacheWord = hBitStream->BitsInCache = 0;
171 hBitStream->ConfigCache = config;
181 FDK_INLINE void FDKresetBitbuffer(HANDLE_FDK_BITSTREAM hBitStream,
183 FDK_ResetBitBuffer(&hBitStream->hBitBuf);
186 hBitStream->CacheWord = hBitStream->BitsInCache = 0;
187 hBitStream->ConfigCache = config;
194 FDK_INLINE void FDKdeleteBitStream(HANDLE_FDK_BITSTREAM hBitStream) { in FDKdeleteBitStream() argument
195 FDK_DeleteBitBuffer(&hBitStream->hBitBuf); in FDKdeleteBitStream()
196 FDKfree(hBitStream); in FDKdeleteBitStream()
210 FDK_INLINE UINT FDKreadBits(HANDLE_FDK_BITSTREAM hBitStream, in FDKreadBits() argument
213 INT missingBits = (INT)numberOfBits - (INT)hBitStream->BitsInCache; in FDKreadBits()
217 if (missingBits != 32) bits = hBitStream->CacheWord << missingBits; in FDKreadBits()
218 hBitStream->CacheWord = FDK_get32(&hBitStream->hBitBuf); in FDKreadBits()
219 hBitStream->BitsInCache += CACHE_BITS; in FDKreadBits()
222 hBitStream->BitsInCache -= numberOfBits; in FDKreadBits()
224 return (bits | (hBitStream->CacheWord >> hBitStream->BitsInCache)) & in FDKreadBits()
228 FDK_INLINE UINT FDKreadBit(HANDLE_FDK_BITSTREAM hBitStream) { in FDKreadBit() argument
229 if (!hBitStream->BitsInCache) { in FDKreadBit()
230 hBitStream->CacheWord = FDK_get32(&hBitStream->hBitBuf); in FDKreadBit()
231 hBitStream->BitsInCache = CACHE_BITS - 1; in FDKreadBit()
232 return hBitStream->CacheWord >> 31; in FDKreadBit()
234 hBitStream->BitsInCache--; in FDKreadBit()
236 return (hBitStream->CacheWord >> hBitStream->BitsInCache) & 1; in FDKreadBit()
248 FDK_INLINE UINT FDKread2Bits(HANDLE_FDK_BITSTREAM hBitStream) { in FDKread2Bits() argument
254 INT missingBits = 2 - (INT)hBitStream->BitsInCache; in FDKread2Bits()
256 bits = hBitStream->CacheWord << missingBits; in FDKread2Bits()
257 hBitStream->CacheWord = FDK_get32(&hBitStream->hBitBuf); in FDKread2Bits()
258 hBitStream->BitsInCache += CACHE_BITS; in FDKread2Bits()
261 hBitStream->BitsInCache -= 2; in FDKread2Bits()
263 return (bits | (hBitStream->CacheWord >> hBitStream->BitsInCache)) & 0x3; in FDKread2Bits()
274 FDK_INLINE UINT FDKreadBitsBwd(HANDLE_FDK_BITSTREAM hBitStream, in FDKreadBitsBwd() argument
278 if (hBitStream->BitsInCache <= numberOfBits) { in FDKreadBitsBwd()
279 const INT freeBits = (CACHE_BITS - 1) - hBitStream->BitsInCache; in FDKreadBitsBwd()
281 hBitStream->CacheWord = (hBitStream->CacheWord << freeBits) | in FDKreadBitsBwd()
282 FDK_getBwd(&hBitStream->hBitBuf, freeBits); in FDKreadBitsBwd()
283 hBitStream->BitsInCache += freeBits; in FDKreadBitsBwd()
286 hBitStream->BitsInCache -= numberOfBits; in FDKreadBitsBwd()
288 return (hBitStream->CacheWord >> hBitStream->BitsInCache) & validMask; in FDKreadBitsBwd()
305 FDK_INLINE UINT escapedValue(HANDLE_FDK_BITSTREAM hBitStream, int nBits1, in escapedValue() argument
307 UINT value = FDKreadBits(hBitStream, nBits1); in escapedValue()
310 UINT valueAdd = FDKreadBits(hBitStream, nBits2); in escapedValue()
313 value += FDKreadBits(hBitStream, nBits3); in escapedValue()
329 FDK_INLINE UINT FDKgetBits(HANDLE_FDK_BITSTREAM hBitStream, UINT numBits) { in FDKgetBits() argument
330 return FDK_get(&hBitStream->hBitBuf, numBits); in FDKgetBits()
342 FDK_INLINE UCHAR FDKwriteBits(HANDLE_FDK_BITSTREAM hBitStream, UINT value, in FDKwriteBits() argument
346 if (hBitStream == NULL) { in FDKwriteBits()
350 if ((hBitStream->BitsInCache + numberOfBits) < CACHE_BITS) { in FDKwriteBits()
351 hBitStream->BitsInCache += numberOfBits; in FDKwriteBits()
352 hBitStream->CacheWord = in FDKwriteBits()
353 (hBitStream->CacheWord << numberOfBits) | (value & validMask); in FDKwriteBits()
362 int missing_bits = CACHE_BITS - hBitStream->BitsInCache; in FDKwriteBits()
367 (missing_bits == 32) ? 0 : (hBitStream->CacheWord << missing_bits); in FDKwriteBits()
369 FDK_put(&hBitStream->hBitBuf, CacheWord, 32); in FDKwriteBits()
371 hBitStream->CacheWord = value; in FDKwriteBits()
372 hBitStream->BitsInCache = remaining_bits; in FDKwriteBits()
387 FDK_INLINE UCHAR FDKwriteBitsBwd(HANDLE_FDK_BITSTREAM hBitStream, UINT value, in FDKwriteBitsBwd() argument
391 if ((hBitStream->BitsInCache + numberOfBits) <= CACHE_BITS) { in FDKwriteBitsBwd()
392 hBitStream->BitsInCache += numberOfBits; in FDKwriteBitsBwd()
393 hBitStream->CacheWord = in FDKwriteBitsBwd()
394 (hBitStream->CacheWord << numberOfBits) | (value & validMask); in FDKwriteBitsBwd()
396 FDK_putBwd(&hBitStream->hBitBuf, hBitStream->CacheWord, in FDKwriteBitsBwd()
397 hBitStream->BitsInCache); in FDKwriteBitsBwd()
398 hBitStream->BitsInCache = numberOfBits; in FDKwriteBitsBwd()
399 hBitStream->CacheWord = (value & validMask); in FDKwriteBitsBwd()
420 FDK_INLINE UCHAR FDKwriteEscapedValue(HANDLE_FDK_BITSTREAM hBitStream, in FDKwriteEscapedValue() argument
427 nbits += FDKwriteBits(hBitStream, value, nBits1); in FDKwriteEscapedValue()
429 nbits += FDKwriteBits(hBitStream, tmp, nBits1); in FDKwriteEscapedValue()
434 nbits += FDKwriteBits(hBitStream, value, nBits2); in FDKwriteEscapedValue()
436 nbits += FDKwriteBits(hBitStream, tmp, nBits2); in FDKwriteEscapedValue()
439 nbits += FDKwriteBits(hBitStream, value, nBits3); in FDKwriteEscapedValue()
452 FDK_INLINE void FDKsyncCache(HANDLE_FDK_BITSTREAM hBitStream) { in FDKsyncCache() argument
453 if (hBitStream->ConfigCache == BS_READER) in FDKsyncCache()
454 FDK_pushBack(&hBitStream->hBitBuf, hBitStream->BitsInCache, in FDKsyncCache()
455 hBitStream->ConfigCache); in FDKsyncCache()
456 else if (hBitStream->BitsInCache) /* BS_WRITER */ in FDKsyncCache()
457 FDK_put(&hBitStream->hBitBuf, hBitStream->CacheWord, in FDKsyncCache()
458 hBitStream->BitsInCache); in FDKsyncCache()
460 hBitStream->BitsInCache = 0; in FDKsyncCache()
461 hBitStream->CacheWord = 0; in FDKsyncCache()
470 FDK_INLINE void FDKsyncCacheBwd(HANDLE_FDK_BITSTREAM hBitStream) { in FDKsyncCacheBwd() argument
471 if (hBitStream->ConfigCache == BS_READER) { in FDKsyncCacheBwd()
472 FDK_pushForward(&hBitStream->hBitBuf, hBitStream->BitsInCache, in FDKsyncCacheBwd()
473 hBitStream->ConfigCache); in FDKsyncCacheBwd()
475 FDK_putBwd(&hBitStream->hBitBuf, hBitStream->CacheWord, in FDKsyncCacheBwd()
476 hBitStream->BitsInCache); in FDKsyncCacheBwd()
479 hBitStream->BitsInCache = 0; in FDKsyncCacheBwd()
480 hBitStream->CacheWord = 0; in FDKsyncCacheBwd()
495 FDK_INLINE void FDKbyteAlign(HANDLE_FDK_BITSTREAM hBitStream, in FDKbyteAlign() argument
497 FDKsyncCache(hBitStream); in FDKbyteAlign()
498 if (hBitStream->ConfigCache == BS_READER) { in FDKbyteAlign()
500 &hBitStream->hBitBuf, in FDKbyteAlign()
502 (INT)FDK_getValidBits(&hBitStream->hBitBuf)) & in FDKbyteAlign()
505 hBitStream->ConfigCache); in FDKbyteAlign()
507 FDK_put(&hBitStream->hBitBuf, 0, in FDKbyteAlign()
508 (8 - ((FDK_getValidBits(&hBitStream->hBitBuf) - alignmentAnchor) & in FDKbyteAlign()
532 FDK_INLINE void FDKpushBackCache(HANDLE_FDK_BITSTREAM hBitStream, in FDKpushBackCache() argument
534 FDK_ASSERT((hBitStream->BitsInCache + numberOfBits) <= CACHE_BITS); in FDKpushBackCache()
535 hBitStream->BitsInCache += numberOfBits; in FDKpushBackCache()
538 FDK_INLINE void FDKpushBack(HANDLE_FDK_BITSTREAM hBitStream, in FDKpushBack() argument
540 if ((hBitStream->BitsInCache + numberOfBits) < CACHE_BITS && in FDKpushBack()
541 (hBitStream->ConfigCache == BS_READER)) { in FDKpushBack()
542 hBitStream->BitsInCache += numberOfBits; in FDKpushBack()
543 FDKsyncCache(hBitStream); /* sync cache to avoid invalid cache */ in FDKpushBack()
545 FDKsyncCache(hBitStream); in FDKpushBack()
546 FDK_pushBack(&hBitStream->hBitBuf, numberOfBits, hBitStream->ConfigCache); in FDKpushBack()
550 FDK_INLINE void FDKpushFor(HANDLE_FDK_BITSTREAM hBitStream, in FDKpushFor() argument
552 if ((hBitStream->BitsInCache > numberOfBits) && in FDKpushFor()
553 (hBitStream->ConfigCache == BS_READER)) { in FDKpushFor()
554 hBitStream->BitsInCache -= numberOfBits; in FDKpushFor()
556 FDKsyncCache(hBitStream); in FDKpushFor()
557 FDK_pushForward(&hBitStream->hBitBuf, numberOfBits, in FDKpushFor()
558 hBitStream->ConfigCache); in FDKpushFor()
562 FDK_INLINE void FDKpushBiDirectional(HANDLE_FDK_BITSTREAM hBitStream, in FDKpushBiDirectional() argument
565 FDKpushFor(hBitStream, numberOfBits); in FDKpushBiDirectional()
567 FDKpushBack(hBitStream, -numberOfBits); in FDKpushBiDirectional()
577 FDK_INLINE UINT FDKgetValidBits(HANDLE_FDK_BITSTREAM hBitStream) { in FDKgetValidBits() argument
578 FDKsyncCache(hBitStream); in FDKgetValidBits()
579 return FDK_getValidBits(&hBitStream->hBitBuf); in FDKgetValidBits()
587 FDK_INLINE INT FDKgetFreeBits(HANDLE_FDK_BITSTREAM hBitStream) { in FDKgetFreeBits() argument
588 return FDK_getFreeBits(&hBitStream->hBitBuf); in FDKgetFreeBits()
603 FDK_INLINE void FDKfeedBuffer(HANDLE_FDK_BITSTREAM hBitStream, in FDKfeedBuffer() argument
606 FDKsyncCache(hBitStream); in FDKfeedBuffer()
607 FDK_Feed(&hBitStream->hBitBuf, inputBuffer, bufferSize, bytesValid); in FDKfeedBuffer()
636 FDK_INLINE void FDKfetchBuffer(HANDLE_FDK_BITSTREAM hBitStream, in FDKfetchBuffer() argument
638 FDKsyncCache(hBitStream); in FDKfetchBuffer()
639 FDK_Fetch(&hBitStream->hBitBuf, outputBuffer, writeBytes); in FDKfetchBuffer()