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