ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

getbits.h
Go to the documentation of this file.
00001 /*
00002     getbits
00003 
00004     copyright ?-2009 by the mpg123 project - free software under the terms of the LGPL 2.1
00005     see COPYING and AUTHORS files in distribution or http://mpg123.org
00006     initially written by Michael Hipp
00007 
00008     All code is in the header to suggest/force inlining of these small often-used functions.
00009     This indeed has some impact on performance.
00010 */
00011 
00012 #ifndef _MPG123_GETBITS_H_
00013 #define _MPG123_GETBITS_H_
00014 
00015 #include "mpg123lib_intern.h"
00016 
00017 #define backbits(fr,nob) ((void)( \
00018   fr->bitindex    -= nob, \
00019   fr->wordpointer += (fr->bitindex>>3), \
00020   fr->bitindex    &= 0x7 ))
00021 
00022 #define getbitoffset(fr) ((-fr->bitindex)&0x7)
00023 #define getbyte(fr)      (*fr->wordpointer++)
00024 
00025 /* There is something wrong with that macro... the function below works also for the layer1 test case. */
00026 #define macro_getbits(fr, nob) ( \
00027   fr->ultmp = fr->wordpointer[0],\
00028   fr->ultmp <<= 8, \
00029   fr->ultmp |= fr->wordpointer[1], \
00030   fr->ultmp <<= 8, \
00031   fr->ultmp |= fr->wordpointer[2], \
00032   fr->ultmp <<= fr->bitindex, \
00033   fr->ultmp &= 0xffffff, \
00034   fr->bitindex += nob, \
00035   fr->ultmp >>= (24-nob), \
00036   fr->wordpointer += (fr->bitindex>>3), \
00037   fr->bitindex &= 7, \
00038   fr->ultmp)
00039 
00040 static unsigned int getbits(mpg123_handle *fr, int number_of_bits)
00041 {
00042   unsigned long rval;
00043 
00044 #ifdef DEBUG_GETBITS
00045 fprintf(stderr,"g%d",number_of_bits);
00046 #endif
00047 
00048 /*  This is actually slow: if(!number_of_bits)
00049     return 0; */
00050 
00051 #if 0
00052    check_buffer_range(number_of_bits+fr->bitindex);
00053 #endif
00054 
00055   {
00056     rval = fr->wordpointer[0];
00057     rval <<= 8;
00058     rval |= fr->wordpointer[1];
00059     rval <<= 8;
00060     rval |= fr->wordpointer[2];
00061 
00062     rval <<= fr->bitindex;
00063     rval &= 0xffffff;
00064 
00065     fr->bitindex += number_of_bits;
00066 
00067     rval >>= (24-number_of_bits);
00068 
00069     fr->wordpointer += (fr->bitindex>>3);
00070     fr->bitindex &= 7;
00071   }
00072 
00073 #ifdef DEBUG_GETBITS
00074 fprintf(stderr,":%lx\n",rval);
00075 #endif
00076 
00077   return rval;
00078 }
00079 
00080 
00081 #define skipbits(fr, nob) fr->ultmp = ( \
00082   fr->ultmp = fr->wordpointer[0], fr->ultmp <<= 8, fr->ultmp |= fr->wordpointer[1], \
00083   fr->ultmp <<= 8, fr->ultmp |= fr->wordpointer[2], fr->ultmp <<= fr->bitindex, \
00084   fr->ultmp &= 0xffffff, fr->bitindex += nob, \
00085   fr->ultmp >>= (24-nob), fr->wordpointer += (fr->bitindex>>3), \
00086   fr->bitindex &= 7 )
00087 
00088 #define getbits_fast(fr, nob) ( \
00089   fr->ultmp = (unsigned char) (fr->wordpointer[0] << fr->bitindex), \
00090   fr->ultmp |= ((unsigned long) fr->wordpointer[1]<<fr->bitindex)>>8, \
00091   fr->ultmp <<= nob, fr->ultmp >>= 8, \
00092   fr->bitindex += nob, fr->wordpointer += (fr->bitindex>>3), \
00093   fr->bitindex &= 7, fr->ultmp )
00094 
00095 #define get1bit(fr) ( \
00096   fr->uctmp = *fr->wordpointer << fr->bitindex, fr->bitindex++, \
00097   fr->wordpointer += (fr->bitindex>>3), fr->bitindex &= 7, fr->uctmp>>7 )
00098 
00099 
00100 #endif

Generated on Mon May 28 2012 04:32:58 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.