source: trunk/gsdl/packages/mg/lib/bitio_mems.c@ 1153

Last change on this file since 1153 was 439, checked in by sjboddie, 25 years ago

renamed mg-1.3d directory mg

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