source: gsdl/trunk/trunk/mg/lib/bitio_mem.h@ 16583

Last change on this file since 16583 was 16583, checked in by davidb, 16 years ago

Undoing change commited in r16582

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
Line 
1/**************************************************************************
2 *
3 * bitio_mem.h -- 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 * This file contains function definitions for doing bitwise input and output
23 * of numbers on an array of chars. These routines are faster than the ones
24 * in "mems" files. But with these routines you cannot mix reads and writes
25 * on the array of chars, or multiple write, at the same time and guarantee
26 * them to work, also you cannot seek to a point and do a write. The decode
27 * routine can detect when you run off the end of the array and will produce
28 * an approate error message, and the encode routine will stop when it gets
29 * to the end of the character array.
30 *
31 *
32 **************************************************************************/
33
34
35#ifndef H_BITIO_MEM
36#define H_BITIO_MEM
37
38
39
40typedef struct mem_bitio_state
41 {
42 unsigned char *Base;
43 unsigned char *Pos;
44 int Remaining;
45 unsigned char Buff;
46 unsigned char Btg;
47 }
48mem_bitio_state;
49
50
51/* NOTE : All bytes are filled high bit first */
52
53
54void BIO_Mem_Encode_Start (void *buf, int rem, mem_bitio_state * bs);
55void BIO_Mem_Encode_Done (mem_bitio_state * bs);
56
57
58
59void BIO_Mem_Decode_Start (void *buf, int rem, mem_bitio_state * bs);
60
61
62
63void BIO_Mem_Unary_Encode (unsigned long val, mem_bitio_state * bs,
64 unsigned long *bits);
65unsigned long BIO_Mem_Unary_Decode (mem_bitio_state * bs,
66 unsigned long *bits);
67
68
69
70void BIO_Mem_Binary_Encode (unsigned long val, unsigned long b,
71 mem_bitio_state * bs, unsigned long *bits);
72unsigned long BIO_Mem_Binary_Decode (unsigned long b, mem_bitio_state * bs,
73 unsigned long *bits);
74
75
76
77void BIO_Mem_Gamma_Encode (unsigned long val, mem_bitio_state * bs,
78 unsigned long *bits);
79unsigned long BIO_Mem_Gamma_Decode (mem_bitio_state * bs, unsigned long *bits);
80
81
82
83void BIO_Mem_Delta_Encode (unsigned long val, mem_bitio_state * bs,
84 unsigned long *bits);
85unsigned long BIO_Mem_Delta_Decode (mem_bitio_state * bs, unsigned long *bits);
86
87
88void BIO_Mem_Elias_Encode (unsigned long val, unsigned long b, double s,
89 mem_bitio_state * bs, unsigned long *bits);
90unsigned long BIO_Mem_Elias_Decode (unsigned long b, double s,
91 mem_bitio_state * bs, unsigned long *bits);
92
93
94void BIO_Mem_Bblock_Encode (unsigned long val, unsigned long b,
95 mem_bitio_state * bs, unsigned long *bits);
96unsigned long BIO_Mem_Bblock_Decode (unsigned long b, mem_bitio_state * bs,
97 unsigned long *bits);
98
99
100void BIO_Mem_Decode_Seek (unsigned long pos, mem_bitio_state * bs);
101
102
103#endif
Note: See TracBrowser for help on using the repository browser.