source: trunk/gsdl3/src/packages/mg/lib/bitio_mems.c@ 3745

Last change on this file since 3745 was 3745, checked in by mdewsnip, 21 years ago

Addition of MG package for search and retrieval

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 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 * $Id: bitio_mems.c 3745 2003-02-20 21:20:24Z mdewsnip $
21 *
22 **************************************************************************/
23
24/*
25 $Log$
26 Revision 1.1 2003/02/20 21:14:16 mdewsnip
27 Addition of MG package for search and retrieval
28
29 Revision 1.1 1999/08/10 21:16:45 sjboddie
30 renamed mg-1.3d directory mg
31
32 Revision 1.1 1998/11/17 09:31:48 rjmcnab
33 *** empty log message ***
34
35 * Revision 1.1 1994/08/22 00:24:39 tes
36 * Initial placement under CVS.
37 *
38 */
39
40static char *RCSID = "$Id: bitio_mems.c 3745 2003-02-20 21:20:24Z mdewsnip $";
41
42
43#include "sysfuncs.h"
44
45#include "bitio_m_mems.h"
46#include "bitio_m.h"
47
48int fprintf (FILE *, const char *,...);
49
50
51
52void
53BIO_Mems_Encode_Start (unsigned char *buf, unsigned long pos,
54 mems_bitio_state * bs)
55{
56 ENCODE_START (buf, pos)
57 ENCODE_PAUSE (*bs)
58}
59
60void
61BIO_Mems_Encode_Done (mems_bitio_state * bs)
62{
63 ENCODE_CONTINUE (*bs)
64 ENCODE_DONE
65}
66
67
68void
69BIO_Mems_Decode_Start (unsigned char *buf, unsigned long pos,
70 mems_bitio_state * bs)
71{
72 DECODE_START (buf, pos)
73 DECODE_PAUSE (*bs)
74}
75
76
77
78
79void
80BIO_Mems_Unary_Encode (unsigned long val, mems_bitio_state * bs,
81 unsigned long *bits)
82{
83 ENCODE_CONTINUE (*bs)
84 if (bits)
85 UNARY_ENCODE_L (val, *bits);
86 else
87 UNARY_ENCODE (val);
88 ENCODE_PAUSE (*bs)
89}
90
91
92unsigned long
93BIO_Mems_Unary_Decode (mems_bitio_state * bs,
94 unsigned long *bits)
95{
96 register unsigned long val;
97 DECODE_CONTINUE (*bs)
98 if (bits)
99 UNARY_DECODE_L (val, *bits);
100 else
101 UNARY_DECODE (val);
102 DECODE_PAUSE (*bs)
103 return (val);
104}
105
106
107
108
109
110
111
112void
113BIO_Mems_Binary_Encode (unsigned long val, unsigned long b,
114 mems_bitio_state * bs, unsigned long *bits)
115{
116 ENCODE_CONTINUE (*bs)
117 if (bits)
118 BINARY_ENCODE_L (val, b, *bits);
119 else
120 BINARY_ENCODE (val, b);
121 ENCODE_PAUSE (*bs)
122}
123
124
125unsigned long
126BIO_Mems_Binary_Decode (unsigned long b, mems_bitio_state * bs,
127 unsigned long *bits)
128{
129 register unsigned long val;
130 DECODE_CONTINUE (*bs)
131 if (bits)
132 BINARY_DECODE_L (val, b, *bits);
133 else
134 BINARY_DECODE (val, b);
135 DECODE_PAUSE (*bs)
136 return (val);
137}
138
139
140
141
142
143
144
145void
146BIO_Mems_Gamma_Encode (unsigned long val, mems_bitio_state * bs,
147 unsigned long *bits)
148{
149 ENCODE_CONTINUE (*bs)
150 if (bits)
151 GAMMA_ENCODE_L (val, *bits);
152 else
153 GAMMA_ENCODE (val);
154 ENCODE_PAUSE (*bs)
155}
156
157
158unsigned long
159BIO_Mems_Gamma_Decode (mems_bitio_state * bs, unsigned long *bits)
160{
161 register unsigned long val;
162 DECODE_CONTINUE (*bs)
163 if (bits)
164 GAMMA_DECODE_L (val, *bits);
165 else
166 GAMMA_DECODE (val);
167 DECODE_PAUSE (*bs)
168 return (val);
169}
170
171
172
173
174void
175BIO_Mems_Delta_Encode (unsigned long val, mems_bitio_state * bs,
176 unsigned long *bits)
177{
178 ENCODE_CONTINUE (*bs)
179 if (bits)
180 DELTA_ENCODE_L (val, *bits);
181 else
182 DELTA_ENCODE (val);
183 ENCODE_PAUSE (*bs)
184}
185
186
187unsigned long
188BIO_Mems_Delta_Decode (mems_bitio_state * bs, unsigned long *bits)
189{
190 register unsigned long val;
191 DECODE_CONTINUE (*bs)
192 if (bits)
193 DELTA_DECODE_L (val, *bits);
194 else
195 DELTA_DECODE (val);
196 DECODE_PAUSE (*bs)
197 return (val);
198}
199
200void
201BIO_Mems_Elias_Encode (unsigned long val, unsigned long b, double s,
202 mems_bitio_state * bs, unsigned long *bits)
203{
204 ENCODE_CONTINUE (*bs)
205 if (bits)
206 ELIAS_ENCODE_L (val, b, s, *bits);
207 else
208 ELIAS_ENCODE (val, b, s);
209 ENCODE_PAUSE (*bs)
210}
211
212
213unsigned long
214BIO_Mems_Elias_Decode (unsigned long b, double s,
215 mems_bitio_state * bs, unsigned long *bits)
216{
217 register unsigned long val;
218 DECODE_CONTINUE (*bs)
219 if (bits)
220 ELIAS_DECODE_L (val, b, s, *bits);
221 else
222 ELIAS_DECODE (val, b, s);
223 DECODE_PAUSE (*bs)
224 return (val);
225}
226
227void
228BIO_Mems_Bblock_Encode (unsigned long val, unsigned long b,
229 mems_bitio_state * bs, unsigned long *bits)
230{
231 ENCODE_CONTINUE (*bs)
232 if (bits)
233 BBLOCK_ENCODE_L (val, b, *bits);
234 else
235 BBLOCK_ENCODE (val, b);
236 ENCODE_PAUSE (*bs)
237}
238
239
240unsigned long
241BIO_Mems_Bblock_Decode (unsigned long b, mems_bitio_state * bs,
242 unsigned long *bits)
243{
244 register unsigned long val;
245 DECODE_CONTINUE (*bs)
246 if (bits)
247 BBLOCK_DECODE_L (val, b, *bits);
248 else
249 BBLOCK_DECODE (val, b);
250 DECODE_PAUSE (*bs)
251 return (val);
252}
253
254void
255BIO_Mems_Decode_Seek (unsigned long pos, mems_bitio_state * bs)
256{
257 DECODE_CONTINUE (*bs)
258 DECODE_SEEK (pos);
259 DECODE_PAUSE (*bs)
260}
261
262void
263BIO_Mems_Encode_Seek (unsigned long pos, mems_bitio_state * bs)
264{
265 ENCODE_CONTINUE (*bs)
266 ENCODE_SEEK (pos);
267 ENCODE_PAUSE (*bs)
268}
Note: See TracBrowser for help on using the repository browser.