source: trunk/gsdl/packages/mg-1.3d/lib/bitio_mem.c@ 13

Last change on this file since 13 was 13, checked in by rjmcnab, 26 years ago

* empty log message *

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