Lines Matching refs:hBitStream
133 HANDLE_FDK_BITSTREAM hBitStream = (HANDLE_FDK_BITSTREAM) FDKcalloc(1, sizeof(FDK_BITSTREAM)); variable
134 FDK_InitBitBuffer(&hBitStream->hBitBuf, pBuffer, bufSize, 0) ;
137 hBitStream->CacheWord = hBitStream->BitsInCache = 0 ;
138 hBitStream->ConfigCache = config ;
140 return hBitStream ;
155 void FDKinitBitStream (HANDLE_FDK_BITSTREAM hBitStream,
161 FDK_InitBitBuffer(&hBitStream->hBitBuf, pBuffer, bufSize, validBits) ;
164 hBitStream->CacheWord = hBitStream->BitsInCache = 0 ;
165 hBitStream->ConfigCache = config ;
176 FDK_INLINE void FDKresetBitbuffer( HANDLE_FDK_BITSTREAM hBitStream, FDK_BS_CFG config = BS_READER)
178 FDK_ResetBitBuffer( &hBitStream->hBitBuf ) ;
181 hBitStream->CacheWord = hBitStream->BitsInCache = 0 ;
182 hBitStream->ConfigCache = config ;
190 FDK_INLINE void FDKdeleteBitStream (HANDLE_FDK_BITSTREAM hBitStream) in FDKdeleteBitStream() argument
192 FDK_DeleteBitBuffer(&hBitStream->hBitBuf) ; in FDKdeleteBitStream()
193 FDKfree(hBitStream) ; in FDKdeleteBitStream()
208 FDK_INLINE UINT FDKreadBits(HANDLE_FDK_BITSTREAM hBitStream, in FDKreadBits() argument
212 INT missingBits = numberOfBits - hBitStream->BitsInCache; in FDKreadBits()
215 UINT bits = hBitStream->CacheWord << missingBits; in FDKreadBits()
216 hBitStream->CacheWord = FDK_get32 (&hBitStream->hBitBuf) ; in FDKreadBits()
217 hBitStream->BitsInCache = CACHE_BITS - missingBits; in FDKreadBits()
218 return ( bits | (hBitStream->CacheWord >> hBitStream->BitsInCache)) & BitMask[numberOfBits]; in FDKreadBits()
221 hBitStream->BitsInCache -= numberOfBits; in FDKreadBits()
222 return ( hBitStream->CacheWord >> hBitStream->BitsInCache) & BitMask[numberOfBits]; in FDKreadBits()
227 if (hBitStream->BitsInCache <= numberOfBits) in FDKreadBits()
229 const INT freeBits = (CACHE_BITS-1) - hBitStream->BitsInCache ; in FDKreadBits()
231 …hBitStream->CacheWord = (hBitStream->CacheWord << freeBits) | FDK_get (&hBitStream->hBitBuf,freeBi… in FDKreadBits()
232 hBitStream->BitsInCache += freeBits ; in FDKreadBits()
235 hBitStream->BitsInCache -= numberOfBits ; in FDKreadBits()
237 return (hBitStream->CacheWord >> hBitStream->BitsInCache) & validMask ; in FDKreadBits()
241 FDK_INLINE UINT FDKreadBit(HANDLE_FDK_BITSTREAM hBitStream) in FDKreadBit() argument
244 if (!hBitStream->BitsInCache) in FDKreadBit()
246 hBitStream->CacheWord = FDK_get32 (&hBitStream->hBitBuf); in FDKreadBit()
247 hBitStream->BitsInCache = CACHE_BITS; in FDKreadBit()
249 hBitStream->BitsInCache--; in FDKreadBit()
251 return (hBitStream->CacheWord >> hBitStream->BitsInCache) & 1; in FDKreadBit()
253 return FDKreadBits(hBitStream,1); in FDKreadBit()
266 inline UINT FDKread2Bits(HANDLE_FDK_BITSTREAM hBitStream) in FDKread2Bits() argument
268 UINT BitsInCache = hBitStream->BitsInCache; in FDKread2Bits()
273 …hBitStream->CacheWord = (hBitStream->CacheWord << freeBits) | FDK_get (&hBitStream->hBitBuf,freeBi… in FDKread2Bits()
276 hBitStream->BitsInCache = BitsInCache - 2; in FDKread2Bits()
277 return (hBitStream->CacheWord >> hBitStream->BitsInCache) & 0x3; in FDKread2Bits()
288 FDK_INLINE UINT FDKreadBitsBwd(HANDLE_FDK_BITSTREAM hBitStream, in FDKreadBitsBwd() argument
293 if (hBitStream->BitsInCache <= numberOfBits) in FDKreadBitsBwd()
295 const INT freeBits = (CACHE_BITS-1) - hBitStream->BitsInCache ; in FDKreadBitsBwd()
297 …hBitStream->CacheWord = (hBitStream->CacheWord << freeBits) | FDK_getBwd (&hBitStream->hBitBuf,fre… in FDKreadBitsBwd()
298 hBitStream->BitsInCache += freeBits ; in FDKreadBitsBwd()
301 hBitStream->BitsInCache -= numberOfBits ; in FDKreadBitsBwd()
303 return (hBitStream->CacheWord >> hBitStream->BitsInCache) & validMask ; in FDKreadBitsBwd()
316 FDK_INLINE UINT FDKgetBits (HANDLE_FDK_BITSTREAM hBitStream, UINT numBits) in FDKgetBits() argument
318 return FDK_get (&hBitStream->hBitBuf, numBits) ; in FDKgetBits()
330 FDK_INLINE UCHAR FDKwriteBits(HANDLE_FDK_BITSTREAM hBitStream, UINT value, in FDKwriteBits() argument
335 if ((hBitStream->BitsInCache+numberOfBits) < CACHE_BITS) in FDKwriteBits()
337 hBitStream->BitsInCache += numberOfBits ; in FDKwriteBits()
338 hBitStream->CacheWord = (hBitStream->CacheWord << numberOfBits) | (value & validMask); in FDKwriteBits()
342 FDK_put(&hBitStream->hBitBuf, hBitStream->CacheWord, hBitStream->BitsInCache) ; in FDKwriteBits()
343 hBitStream->BitsInCache = numberOfBits ; in FDKwriteBits()
344 hBitStream->CacheWord = (value & validMask) ; in FDKwriteBits()
359 FDK_INLINE UCHAR FDKwriteBitsBwd(HANDLE_FDK_BITSTREAM hBitStream, UINT value, in FDKwriteBitsBwd() argument
364 if ((hBitStream->BitsInCache+numberOfBits) <= CACHE_BITS) in FDKwriteBitsBwd()
366 hBitStream->BitsInCache += numberOfBits ; in FDKwriteBitsBwd()
367 hBitStream->CacheWord = (hBitStream->CacheWord << numberOfBits) | (value & validMask); in FDKwriteBitsBwd()
371 FDK_putBwd(&hBitStream->hBitBuf, hBitStream->CacheWord, hBitStream->BitsInCache) ; in FDKwriteBitsBwd()
372 hBitStream->BitsInCache = numberOfBits ; in FDKwriteBitsBwd()
373 hBitStream->CacheWord = (value & validMask) ; in FDKwriteBitsBwd()
386 FDK_INLINE void FDKsyncCache (HANDLE_FDK_BITSTREAM hBitStream) in FDKsyncCache() argument
388 if (hBitStream->ConfigCache == BS_READER) in FDKsyncCache()
389 FDK_pushBack (&hBitStream->hBitBuf,hBitStream->BitsInCache,hBitStream->ConfigCache) ; in FDKsyncCache()
391 FDK_put(&hBitStream->hBitBuf, hBitStream->CacheWord, hBitStream->BitsInCache) ; in FDKsyncCache()
393 hBitStream->BitsInCache = 0 ; in FDKsyncCache()
394 hBitStream->CacheWord = 0 ; in FDKsyncCache()
404 FDK_INLINE void FDKsyncCacheBwd (HANDLE_FDK_BITSTREAM hBitStream) in FDKsyncCacheBwd() argument
406 if (hBitStream->ConfigCache == BS_READER) { in FDKsyncCacheBwd()
407 FDK_pushForward (&hBitStream->hBitBuf,hBitStream->BitsInCache,hBitStream->ConfigCache) ; in FDKsyncCacheBwd()
409 FDK_putBwd (&hBitStream->hBitBuf, hBitStream->CacheWord, hBitStream->BitsInCache) ; in FDKsyncCacheBwd()
412 hBitStream->BitsInCache = 0 ; in FDKsyncCacheBwd()
413 hBitStream->CacheWord = 0 ; in FDKsyncCacheBwd()
426 FDK_INLINE void FDKbyteAlign (HANDLE_FDK_BITSTREAM hBitStream) in FDKbyteAlign() argument
428 FDKsyncCache (hBitStream) ; in FDKbyteAlign()
429 FDK_byteAlign (&hBitStream->hBitBuf, (UCHAR)hBitStream->ConfigCache) ; in FDKbyteAlign()
443 FDK_INLINE void FDKbyteAlign (HANDLE_FDK_BITSTREAM hBitStream, UINT alignmentAnchor) in FDKbyteAlign() argument
445 FDKsyncCache (hBitStream) ; in FDKbyteAlign()
446 if (hBitStream->ConfigCache == BS_READER) { in FDKbyteAlign()
447 FDK_pushForward (&hBitStream->hBitBuf, in FDKbyteAlign()
448 … (8 - ((alignmentAnchor - FDK_getValidBits(&hBitStream->hBitBuf)) & 0x07)) & 0x07, in FDKbyteAlign()
449 hBitStream->ConfigCache) ; in FDKbyteAlign()
452 FDK_put (&hBitStream->hBitBuf, in FDKbyteAlign()
454 (8 - ((FDK_getValidBits(&hBitStream->hBitBuf)-alignmentAnchor) & 0x07)) & 0x07 ); in FDKbyteAlign()
475 FDK_INLINE void FDKpushBackCache (HANDLE_FDK_BITSTREAM hBitStream, const UINT numberOfBits) in FDKpushBackCache() argument
477 FDK_ASSERT ((hBitStream->BitsInCache+numberOfBits)<=CACHE_BITS); in FDKpushBackCache()
478 hBitStream->BitsInCache += numberOfBits ; in FDKpushBackCache()
481 FDK_INLINE void FDKpushBack (HANDLE_FDK_BITSTREAM hBitStream, const UINT numberOfBits) in FDKpushBack() argument
483 …if ((hBitStream->BitsInCache+numberOfBits)<CACHE_BITS && (hBitStream->ConfigCache == BS_READER) ) { in FDKpushBack()
484 hBitStream->BitsInCache += numberOfBits ; in FDKpushBack()
485 FDKsyncCache(hBitStream) ; /* sync cache to avoid invalid cache */ in FDKpushBack()
488 FDKsyncCache(hBitStream) ; in FDKpushBack()
489 FDK_pushBack(&hBitStream->hBitBuf,numberOfBits,hBitStream->ConfigCache); in FDKpushBack()
493 FDK_INLINE void FDKpushFor (HANDLE_FDK_BITSTREAM hBitStream, const UINT numberOfBits) in FDKpushFor() argument
495 if ( (hBitStream->BitsInCache>numberOfBits) && (hBitStream->ConfigCache == BS_READER) ) { in FDKpushFor()
496 hBitStream->BitsInCache -= numberOfBits; in FDKpushFor()
499 FDKsyncCache(hBitStream) ; in FDKpushFor()
500 FDK_pushForward(&hBitStream->hBitBuf,numberOfBits,hBitStream->ConfigCache); in FDKpushFor()
504 FDK_INLINE void FDKpushBiDirectional (HANDLE_FDK_BITSTREAM hBitStream, const INT numberOfBits) in FDKpushBiDirectional() argument
506 if(numberOfBits>=0) FDKpushFor(hBitStream, numberOfBits) ; in FDKpushBiDirectional()
507 else FDKpushBack(hBitStream, -numberOfBits) ; in FDKpushBiDirectional()
517 FDK_INLINE UINT FDKgetValidBits (HANDLE_FDK_BITSTREAM hBitStream) in FDKgetValidBits() argument
519 FDKsyncCache(hBitStream) ; in FDKgetValidBits()
520 return FDK_getValidBits(&hBitStream->hBitBuf) ; in FDKgetValidBits()
529 FDK_INLINE INT FDKgetFreeBits (HANDLE_FDK_BITSTREAM hBitStream) in FDKgetFreeBits() argument
531 return FDK_getFreeBits (&hBitStream->hBitBuf) ; in FDKgetFreeBits()
539 FDK_INLINE void FDKresetBitCnt (HANDLE_FDK_BITSTREAM hBitStream) in FDKresetBitCnt() argument
541 FDKsyncCache (hBitStream) ; in FDKresetBitCnt()
542 FDK_setBitCnt (&hBitStream->hBitBuf, 0) ; in FDKresetBitCnt()
551 FDK_INLINE void FDKsetBitCnt (HANDLE_FDK_BITSTREAM hBitStream, UINT value) in FDKsetBitCnt() argument
553 FDKsyncCache (hBitStream) ; in FDKsetBitCnt()
554 FDK_setBitCnt (&hBitStream->hBitBuf, value) ; in FDKsetBitCnt()
562 FDK_INLINE INT FDKgetBitCnt (HANDLE_FDK_BITSTREAM hBitStream) in FDKgetBitCnt() argument
564 FDKsyncCache(hBitStream) ; in FDKgetBitCnt()
565 return FDK_getBitCnt(&hBitStream->hBitBuf) ; in FDKgetBitCnt()
579 FDK_INLINE void FDKfeedBuffer (HANDLE_FDK_BITSTREAM hBitStream, const UCHAR inputBuffer [], const U… in FDKfeedBuffer() argument
581 FDKsyncCache (hBitStream) ; in FDKfeedBuffer()
582 FDK_Feed(&hBitStream->hBitBuf, (UCHAR*)inputBuffer, bufferSize, bytesValid ) ; in FDKfeedBuffer()
611 FDK_INLINE void FDKfetchBuffer(HANDLE_FDK_BITSTREAM hBitStream, UCHAR *outputBuffer, UINT *writeByt… in FDKfetchBuffer() argument
613 FDKsyncCache (hBitStream) ; in FDKfetchBuffer()
614 FDK_Fetch(&hBitStream->hBitBuf, outputBuffer, writeBytes); in FDKfetchBuffer()