source: main/branches/64_bit_Greenstone/greenstone2/common-src/indexers/mg/lib/bitio_mems.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.6 KB
Line 
1/**************************************************************************
2 *
3 * bitio_mems.c -- Functions for bitio to memory (random access)
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_mems.h"
25#include "bitio_m.h"
26
27int fprintf (FILE *, const char *,...);
28
29
30
31void
32BIO_Mems_Encode_Start (unsigned char *buf, mg_u_long pos,
33 mems_bitio_state * bs)
34{
35 ENCODE_START (buf, pos)
36 ENCODE_PAUSE (*bs)
37}
38
39void
40BIO_Mems_Encode_Done (mems_bitio_state * bs)
41{
42 ENCODE_CONTINUE (*bs)
43 ENCODE_DONE
44}
45
46
47void
48BIO_Mems_Decode_Start (unsigned char *buf, mg_u_long pos,
49 mems_bitio_state * bs)
50{
51 DECODE_START (buf, pos)
52 DECODE_PAUSE (*bs)
53}
54
55
56
57
58void
59BIO_Mems_Unary_Encode (mg_u_long val, mems_bitio_state * bs,
60 mg_u_long *bits)
61{
62 ENCODE_CONTINUE (*bs)
63 if (bits)
64 UNARY_ENCODE_L (val, *bits);
65 else
66 UNARY_ENCODE (val);
67 ENCODE_PAUSE (*bs)
68}
69
70
71mg_u_long
72BIO_Mems_Unary_Decode (mems_bitio_state * bs,
73 mg_u_long *bits)
74{
75 register mg_u_long val;
76 DECODE_CONTINUE (*bs)
77 if (bits)
78 UNARY_DECODE_L (val, *bits);
79 else
80 UNARY_DECODE (val);
81 DECODE_PAUSE (*bs)
82 return (val);
83}
84
85
86
87
88
89
90
91void
92BIO_Mems_Binary_Encode (mg_u_long val, mg_u_long b,
93 mems_bitio_state * bs, mg_u_long *bits)
94{
95 ENCODE_CONTINUE (*bs)
96 if (bits)
97 BINARY_ENCODE_L (val, b, *bits);
98 else
99 BINARY_ENCODE (val, b);
100 ENCODE_PAUSE (*bs)
101}
102
103
104mg_u_long
105BIO_Mems_Binary_Decode (mg_u_long b, mems_bitio_state * bs,
106 mg_u_long *bits)
107{
108 register mg_u_long val;
109 DECODE_CONTINUE (*bs)
110 if (bits)
111 BINARY_DECODE_L (val, b, *bits);
112 else
113 BINARY_DECODE (val, b);
114 DECODE_PAUSE (*bs)
115 return (val);
116}
117
118
119
120
121
122
123
124void
125BIO_Mems_Gamma_Encode (mg_u_long val, mems_bitio_state * bs,
126 mg_u_long *bits)
127{
128 ENCODE_CONTINUE (*bs)
129 if (bits)
130 GAMMA_ENCODE_L (val, *bits);
131 else
132 GAMMA_ENCODE (val);
133 ENCODE_PAUSE (*bs)
134}
135
136
137mg_u_long
138BIO_Mems_Gamma_Decode (mems_bitio_state * bs, mg_u_long *bits)
139{
140 register mg_u_long val;
141 DECODE_CONTINUE (*bs)
142 if (bits)
143 GAMMA_DECODE_L (val, *bits);
144 else
145 GAMMA_DECODE (val);
146 DECODE_PAUSE (*bs)
147 return (val);
148}
149
150
151
152
153void
154BIO_Mems_Delta_Encode (mg_u_long val, mems_bitio_state * bs,
155 mg_u_long *bits)
156{
157 ENCODE_CONTINUE (*bs)
158 if (bits)
159 DELTA_ENCODE_L (val, *bits);
160 else
161 DELTA_ENCODE (val);
162 ENCODE_PAUSE (*bs)
163}
164
165
166mg_u_long
167BIO_Mems_Delta_Decode (mems_bitio_state * bs, mg_u_long *bits)
168{
169 register mg_u_long val;
170 DECODE_CONTINUE (*bs)
171 if (bits)
172 DELTA_DECODE_L (val, *bits);
173 else
174 DELTA_DECODE (val);
175 DECODE_PAUSE (*bs)
176 return (val);
177}
178
179void
180BIO_Mems_Elias_Encode (mg_u_long val, mg_u_long b, double s,
181 mems_bitio_state * bs, mg_u_long *bits)
182{
183 ENCODE_CONTINUE (*bs)
184 if (bits)
185 ELIAS_ENCODE_L (val, b, s, *bits);
186 else
187 ELIAS_ENCODE (val, b, s);
188 ENCODE_PAUSE (*bs)
189}
190
191
192mg_u_long
193BIO_Mems_Elias_Decode (mg_u_long b, double s,
194 mems_bitio_state * bs, mg_u_long *bits)
195{
196 register mg_u_long val;
197 DECODE_CONTINUE (*bs)
198 if (bits)
199 ELIAS_DECODE_L (val, b, s, *bits);
200 else
201 ELIAS_DECODE (val, b, s);
202 DECODE_PAUSE (*bs)
203 return (val);
204}
205
206void
207BIO_Mems_Bblock_Encode (mg_u_long val, mg_u_long b,
208 mems_bitio_state * bs, mg_u_long *bits)
209{
210 ENCODE_CONTINUE (*bs)
211 if (bits)
212 BBLOCK_ENCODE_L (val, b, *bits);
213 else
214 BBLOCK_ENCODE (val, b);
215 ENCODE_PAUSE (*bs)
216}
217
218
219mg_u_long
220BIO_Mems_Bblock_Decode (mg_u_long b, mems_bitio_state * bs,
221 mg_u_long *bits)
222{
223 register mg_u_long val;
224 DECODE_CONTINUE (*bs)
225 if (bits)
226 BBLOCK_DECODE_L (val, b, *bits);
227 else
228 BBLOCK_DECODE (val, b);
229 DECODE_PAUSE (*bs)
230 return (val);
231}
232
233void
234BIO_Mems_Decode_Seek (mg_u_long pos, mems_bitio_state * bs)
235{
236 DECODE_CONTINUE (*bs)
237 DECODE_SEEK (pos);
238 DECODE_PAUSE (*bs)
239}
240
241void
242BIO_Mems_Encode_Seek (mg_u_long pos, mems_bitio_state * bs)
243{
244 ENCODE_CONTINUE (*bs)
245 ENCODE_SEEK (pos);
246 ENCODE_PAUSE (*bs)
247}
Note: See TracBrowser for help on using the repository browser.