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