source: main/branches/64_bit_Greenstone/greenstone2/common-src/indexers/mg/lib/bitio_mem.c@ 23508

Last change on this file since 23508 was 23508, checked in by sjm84, 13 years ago

Committing 64 bit changes into the branch

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1/**************************************************************************
2 *
3 * bitio_mem.c -- Functions for bitio to memory
4 * Copyright (C) 1994 Neil Sharman
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 **************************************************************************/
21
22#include "sysfuncs.h"
23
24#include "bitio_m_mem.h"
25#include "bitio_m.h"
26
27int fprintf (FILE *, const char *,...);
28
29
30
31void
32BIO_Mem_Encode_Start (void *buf, int rem, mem_bitio_state * bs)
33{
34 ENCODE_START (buf, rem)
35 ENCODE_PAUSE (*bs)
36}
37
38void
39BIO_Mem_Encode_Done (mem_bitio_state * bs)
40{
41 ENCODE_CONTINUE (*bs)
42 ENCODE_DONE
43}
44
45
46void
47BIO_Mem_Decode_Start (void *buf, int rem, mem_bitio_state * bs)
48{
49 DECODE_START (buf, rem)
50 DECODE_PAUSE (*bs)
51}
52
53
54
55
56void
57BIO_Mem_Unary_Encode (mg_u_long val, mem_bitio_state * bs,
58 mg_u_long *bits)
59{
60 ENCODE_CONTINUE (*bs)
61 if (bits)
62 UNARY_ENCODE_L (val, *bits);
63 else
64 UNARY_ENCODE (val);
65 ENCODE_PAUSE (*bs)
66}
67
68
69mg_u_long
70BIO_Mem_Unary_Decode (mem_bitio_state * bs,
71 mg_u_long *bits)
72{
73 register mg_u_long val;
74 DECODE_CONTINUE (*bs)
75 if (bits)
76 UNARY_DECODE_L (val, *bits);
77 else
78 UNARY_DECODE (val);
79 DECODE_PAUSE (*bs)
80 return (val);
81}
82
83
84
85
86
87
88
89void
90BIO_Mem_Binary_Encode (mg_u_long val, mg_u_long b,
91 mem_bitio_state * bs, mg_u_long *bits)
92{
93 ENCODE_CONTINUE (*bs)
94 if (bits)
95 BINARY_ENCODE_L (val, b, *bits);
96 else
97 BINARY_ENCODE (val, b);
98 ENCODE_PAUSE (*bs)
99}
100
101
102mg_u_long
103BIO_Mem_Binary_Decode (mg_u_long b, mem_bitio_state * bs,
104 mg_u_long *bits)
105{
106 register mg_u_long val;
107 DECODE_CONTINUE (*bs)
108 if (bits)
109 BINARY_DECODE_L (val, b, *bits);
110 else
111 BINARY_DECODE (val, b);
112 DECODE_PAUSE (*bs)
113 return (val);
114}
115
116
117
118
119
120
121
122void
123BIO_Mem_Gamma_Encode (mg_u_long val, mem_bitio_state * bs,
124 mg_u_long *bits)
125{
126 ENCODE_CONTINUE (*bs)
127 if (bits)
128 GAMMA_ENCODE_L (val, *bits);
129 else
130 GAMMA_ENCODE (val);
131 ENCODE_PAUSE (*bs)
132}
133
134
135mg_u_long
136BIO_Mem_Gamma_Decode (mem_bitio_state * bs, mg_u_long *bits)
137{
138 register mg_u_long val;
139 DECODE_CONTINUE (*bs)
140 if (bits)
141 GAMMA_DECODE_L (val, *bits);
142 else
143 GAMMA_DECODE (val);
144 DECODE_PAUSE (*bs)
145 return (val);
146}
147
148
149
150
151void
152BIO_Mem_Delta_Encode (mg_u_long val, mem_bitio_state * bs,
153 mg_u_long *bits)
154{
155 ENCODE_CONTINUE (*bs)
156 if (bits)
157 DELTA_ENCODE_L (val, *bits);
158 else
159 DELTA_ENCODE (val);
160 ENCODE_PAUSE (*bs)
161}
162
163
164mg_u_long
165BIO_Mem_Delta_Decode (mem_bitio_state * bs, mg_u_long *bits)
166{
167 register mg_u_long val;
168 DECODE_CONTINUE (*bs)
169 if (bits)
170 DELTA_DECODE_L (val, *bits);
171 else
172 DELTA_DECODE (val);
173 DECODE_PAUSE (*bs)
174 return (val);
175}
176
177void
178BIO_Mem_Elias_Encode (mg_u_long val, mg_u_long b, double s,
179 mem_bitio_state * bs, mg_u_long *bits)
180{
181 ENCODE_CONTINUE (*bs)
182 if (bits)
183 ELIAS_ENCODE_L (val, b, s, *bits);
184 else
185 ELIAS_ENCODE (val, b, s);
186 ENCODE_PAUSE (*bs)
187}
188
189
190mg_u_long
191BIO_Mem_Elias_Decode (mg_u_long b, double s,
192 mem_bitio_state * bs, mg_u_long *bits)
193{
194 register mg_u_long val;
195 DECODE_CONTINUE (*bs)
196 if (bits)
197 ELIAS_DECODE_L (val, b, s, *bits);
198 else
199 ELIAS_DECODE (val, b, s);
200 DECODE_PAUSE (*bs)
201 return (val);
202}
203
204void
205BIO_Mem_Bblock_Encode (mg_u_long val, mg_u_long b,
206 mem_bitio_state * bs, mg_u_long *bits)
207{
208 ENCODE_CONTINUE (*bs)
209 if (bits)
210 BBLOCK_ENCODE_L (val, b, *bits);
211 else
212 BBLOCK_ENCODE (val, b);
213 ENCODE_PAUSE (*bs)
214}
215
216
217mg_u_long
218BIO_Mem_Bblock_Decode (mg_u_long b, mem_bitio_state * bs,
219 mg_u_long *bits)
220{
221 register mg_u_long val;
222 DECODE_CONTINUE (*bs)
223 if (bits)
224 BBLOCK_DECODE_L (val, b, *bits);
225 else
226 BBLOCK_DECODE (val, b);
227 DECODE_PAUSE (*bs)
228 return (val);
229}
230
231void
232BIO_Mem_Decode_Seek (mg_u_long pos, mem_bitio_state * bs)
233{
234 DECODE_CONTINUE (*bs)
235 DECODE_SEEK (pos);
236 DECODE_PAUSE (*bs)
237}
Note: See TracBrowser for help on using the repository browser.