562
|
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.org
|
|
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 #define backbits(fr,nob) ((void)( \
|
|
16 fr->bitindex -= nob, \
|
|
17 fr->wordpointer += (fr->bitindex>>3), \
|
|
18 fr->bitindex &= 0x7 ))
|
|
19
|
|
20 #define getbitoffset(fr) ((-fr->bitindex)&0x7)
|
|
21 #define getbyte(fr) (*fr->wordpointer++)
|
|
22
|
|
23 #define getbits(fr, nob) ( \
|
|
24 fr->ultmp = fr->wordpointer[0], fr->ultmp <<= 8, fr->ultmp |= fr->wordpointer[1], \
|
|
25 fr->ultmp <<= 8, fr->ultmp |= fr->wordpointer[2], fr->ultmp <<= fr->bitindex, \
|
|
26 fr->ultmp &= 0xffffff, fr->bitindex += nob, \
|
|
27 fr->ultmp >>= (24-nob), fr->wordpointer += (fr->bitindex>>3), \
|
|
28 fr->bitindex &= 7,fr->ultmp)
|
|
29
|
|
30 #define skipbits(fr, nob) fr->ultmp = ( \
|
|
31 fr->ultmp = fr->wordpointer[0], fr->ultmp <<= 8, fr->ultmp |= fr->wordpointer[1], \
|
|
32 fr->ultmp <<= 8, fr->ultmp |= fr->wordpointer[2], fr->ultmp <<= fr->bitindex, \
|
|
33 fr->ultmp &= 0xffffff, fr->bitindex += nob, \
|
|
34 fr->ultmp >>= (24-nob), fr->wordpointer += (fr->bitindex>>3), \
|
|
35 fr->bitindex &= 7 )
|
|
36
|
|
37 #define getbits_fast(fr, nob) ( \
|
|
38 fr->ultmp = (unsigned char) (fr->wordpointer[0] << fr->bitindex), \
|
|
39 fr->ultmp |= ((unsigned long) fr->wordpointer[1]<<fr->bitindex)>>8, \
|
|
40 fr->ultmp <<= nob, fr->ultmp >>= 8, \
|
|
41 fr->bitindex += nob, fr->wordpointer += (fr->bitindex>>3), \
|
|
42 fr->bitindex &= 7, fr->ultmp )
|
|
43
|
|
44 #define get1bit(fr) ( \
|
|
45 fr->uctmp = *fr->wordpointer << fr->bitindex, fr->bitindex++, \
|
|
46 fr->wordpointer += (fr->bitindex>>3), fr->bitindex &= 7, fr->uctmp>>7 )
|
|
47
|
|
48
|
|
49 #endif
|