Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.         getbits
  3.  
  4.         copyright ?-2006 by the mpg123 project - free software under the terms of the LGPL 2.1
  5.         see COPYING and AUTHORS files in distribution or http://mpg123.de
  6.         initially written by Michael Hipp
  7. */
  8.  
  9. #ifndef _MPG123_GETBITS_H_
  10. #define _MPG123_GETBITS_H_
  11.  
  12. /* that's the same file as getits.c but with defines to
  13.   force inlining */
  14.  
  15. static unsigned long rval;
  16. static unsigned char rval_uc;
  17.  
  18. #define backbits(nob) ((void)( \
  19.   bsi.bitindex    -= nob, \
  20.   bsi.wordpointer += (bsi.bitindex>>3), \
  21.   bsi.bitindex    &= 0x7 ))
  22.  
  23. #define getbitoffset() ((-bsi.bitindex)&0x7)
  24. #define getbyte()      (*bsi.wordpointer++)
  25.  
  26. #define getbits(nob) ( \
  27.   rval = bsi.wordpointer[0], rval <<= 8, rval |= bsi.wordpointer[1], \
  28.   rval <<= 8, rval |= bsi.wordpointer[2], rval <<= bsi.bitindex, \
  29.   rval &= 0xffffff, bsi.bitindex += nob, \
  30.   rval >>= (24-nob), bsi.wordpointer += (bsi.bitindex>>3), \
  31.   bsi.bitindex &= 7,rval)
  32.  
  33. #define getbits_fast(nob) ( \
  34.   rval = (unsigned char) (bsi.wordpointer[0] << bsi.bitindex), \
  35.   rval |= ((unsigned long) bsi.wordpointer[1]<<bsi.bitindex)>>8, \
  36.   rval <<= nob, rval >>= 8, \
  37.   bsi.bitindex += nob, bsi.wordpointer += (bsi.bitindex>>3), \
  38.   bsi.bitindex &= 7, rval )
  39.  
  40. #define get1bit() ( \
  41.   rval_uc = *bsi.wordpointer << bsi.bitindex, bsi.bitindex++, \
  42.   bsi.wordpointer += (bsi.bitindex>>3), bsi.bitindex &= 7, rval_uc>>7 )
  43.  
  44.  
  45. #endif
  46.