ReactOS
0.4.16-dev-297-gc569aee
Toggle main menu visibility
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
Functions
_
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
w
Variables
_
c
d
e
f
g
h
i
l
n
o
p
s
t
u
x
Typedefs
_
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
w
x
Enumerations
_
c
d
f
i
l
m
o
p
s
t
w
x
Enumerator
a
b
c
d
e
f
g
h
i
m
n
o
p
r
s
t
u
v
w
x
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
_
a
b
c
d
e
f
h
i
k
l
m
n
o
p
r
s
t
u
v
w
z
Enumerator
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Properties
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Related Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
v
x
Files
File List
File Members
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Examples
getbits.h
Go to the documentation of this file.
1
/*
2
getbits
3
4
copyright ?-2009 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
All code is in the header to suggest/force inlining of these small often-used functions.
9
This indeed has some impact on performance.
10
*/
11
12
#ifndef _MPG123_GETBITS_H_
13
#define _MPG123_GETBITS_H_
14
15
#include "
mpg123lib_intern.h
"
16
#include "
debug.h
"
17
18
#define backbits(fr,nob) ((void)( \
19
fr->bits_avail += nob, \
20
fr->bitindex -= nob, \
21
fr->wordpointer += (fr->bitindex>>3), \
22
fr->bitindex &= 0x7 ))
23
24
#define getbitoffset(fr) ((-fr->bitindex)&0x7)
25
/* Precomputing the bytes to be read is error-prone, and some over-read
26
is even expected for Huffman. Just play safe and return zeros in case
27
of overflow. This assumes you made bitindex zero already! */
28
#define getbyte(fr) ( (fr)->bits_avail-=8, (fr)->bits_avail >= 0 \
29
? *((fr)->wordpointer++) \
30
: 0 )
31
32
static
unsigned
int
getbits
(
mpg123_handle
*fr,
int
number_of_bits)
33
{
34
unsigned
long
rval
;
35
36
#ifdef DEBUG_GETBITS
37
fprintf
(
stderr
,
"g%d"
,number_of_bits);
38
#endif
39
fr->
bits_avail
-= number_of_bits;
40
/* Safety catch until we got the nasty code fully figured out. */
41
/* No, that catch stays here, even if we think we got it figured out! */
42
if
(fr->
bits_avail
< 0)
43
{
44
if
(
NOQUIET
)
45
error2
(
"Tried to read %i bits with %li available."
46
, number_of_bits, fr->
bits_avail
);
47
return
0;
48
}
49
/* This is actually slow: if(!number_of_bits)
50
return 0; */
51
52
#if 0
53
check_buffer_range(number_of_bits+fr->
bitindex
);
54
#endif
55
56
{
57
rval
= fr->
wordpointer
[0];
58
rval
<<= 8;
59
rval
|= fr->
wordpointer
[1];
60
rval
<<= 8;
61
rval
|= fr->
wordpointer
[2];
62
63
rval
<<= fr->
bitindex
;
64
rval
&= 0xffffff;
65
66
fr->
bitindex
+= number_of_bits;
67
68
rval
>>= (24-number_of_bits);
69
70
fr->
wordpointer
+= (fr->
bitindex
>>3);
71
fr->
bitindex
&= 7;
72
}
73
74
#ifdef DEBUG_GETBITS
75
fprintf
(
stderr
,
":%lx\n"
,
rval
);
76
#endif
77
78
return
rval
;
79
}
80
81
82
#define skipbits(fr, nob) fr->ultmp = ( \
83
fr->ultmp = fr->wordpointer[0], fr->ultmp <<= 8, fr->ultmp |= fr->wordpointer[1], \
84
fr->ultmp <<= 8, fr->ultmp |= fr->wordpointer[2], fr->ultmp <<= fr->bitindex, \
85
fr->ultmp &= 0xffffff, fr->bitindex += nob, fr->bits_avail -= nob, \
86
fr->ultmp >>= (24-nob), fr->wordpointer += (fr->bitindex>>3), \
87
fr->bitindex &= 7 )
88
89
#define getbits_fast(fr, nob) ( \
90
fr->ultmp = (unsigned char) (fr->wordpointer[0] << fr->bitindex), \
91
fr->ultmp |= ((unsigned long) fr->wordpointer[1]<<fr->bitindex)>>8, \
92
fr->ultmp <<= nob, fr->ultmp >>= 8, \
93
fr->bitindex += nob, fr->bits_avail -= nob, \
94
fr->wordpointer += (fr->bitindex>>3), \
95
fr->bitindex &= 7, fr->ultmp )
96
97
#define get1bit(fr) ( \
98
fr->uctmp = *fr->wordpointer << fr->bitindex, \
99
++fr->bitindex, --fr->bits_avail, \
100
fr->wordpointer += (fr->bitindex>>3), fr->bitindex &= 7, fr->uctmp>>7 )
101
102
103
#endif
rval
float rval
Definition:
cylfrac.c:48
getbits
static unsigned int getbits(mpg123_handle *fr, int number_of_bits)
Definition:
getbits.h:32
stderr
#define stderr
Definition:
stdio.h:100
fprintf
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
mpg123lib_intern.h
NOQUIET
#define NOQUIET
Definition:
mpg123lib_intern.h:290
error2
#define error2(s, a, b)
Definition:
debug.h:126
mpg123_handle_struct
Definition:
frame.h:99
mpg123_handle_struct::bitindex
int bitindex
Definition:
frame.h:227
mpg123_handle_struct::bits_avail
long bits_avail
Definition:
frame.h:228
mpg123_handle_struct::wordpointer
unsigned char * wordpointer
Definition:
frame.h:229
debug.h
sdk
include
reactos
libs
libmpg123
getbits.h
Generated on Wed Nov 27 2024 06:12:42 for ReactOS by
1.9.6