1 | /**************************************************************************
|
---|
2 | *
|
---|
3 | * bitio_mems.h -- 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.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 slower than the ones
|
---|
26 | * in "mem" files. but with these routines you can mix reads and writes, or
|
---|
27 | * multiple writes, on the array of chars at the same time and guarantee
|
---|
28 | * them to work, also you can seek to a point and do a write. The decode and
|
---|
29 | * encode functions cannot detect when the end off the character is reached
|
---|
30 | * and just continue processing.
|
---|
31 | *
|
---|
32 | **************************************************************************/
|
---|
33 |
|
---|
34 | #ifndef H_BITIO_MEMS
|
---|
35 | #define H_BITIO_MEMS
|
---|
36 |
|
---|
37 |
|
---|
38 |
|
---|
39 | typedef struct mems_bitio_state
|
---|
40 | {
|
---|
41 | unsigned char *Base;
|
---|
42 | unsigned long pos;
|
---|
43 | }
|
---|
44 | mems_bitio_state;
|
---|
45 |
|
---|
46 |
|
---|
47 | /* NOTE : All bytes are filled high bit first */
|
---|
48 |
|
---|
49 |
|
---|
50 | void BIO_Mems_Encode_Start (char *buf, unsigned long pos, mems_bitio_state * bs);
|
---|
51 | void BIO_Mems_Encode_Done (mems_bitio_state * bs);
|
---|
52 |
|
---|
53 |
|
---|
54 |
|
---|
55 | void BIO_Mems_Decode_Start (void *buf, unsigned long pos, mems_bitio_state * bs);
|
---|
56 |
|
---|
57 |
|
---|
58 |
|
---|
59 | void BIO_Mems_Unary_Encode (unsigned long val, mems_bitio_state * bs,
|
---|
60 | unsigned long *bits);
|
---|
61 | unsigned long BIO_Mems_Unary_Decode (mems_bitio_state * bs,
|
---|
62 | unsigned long *bits);
|
---|
63 |
|
---|
64 |
|
---|
65 |
|
---|
66 | void BIO_Mems_Binary_Encode (unsigned long val, unsigned long b,
|
---|
67 | mems_bitio_state * bs, unsigned long *bits);
|
---|
68 | unsigned long BIO_Mems_Binary_Decode (unsigned long b, mems_bitio_state * bs,
|
---|
69 | unsigned long *bits);
|
---|
70 |
|
---|
71 |
|
---|
72 |
|
---|
73 | void BIO_Mems_Gamma_Encode (unsigned long val, mems_bitio_state * bs,
|
---|
74 | unsigned long *bits);
|
---|
75 | unsigned long BIO_Mems_Gamma_Decode (mems_bitio_state * bs, unsigned long *bits);
|
---|
76 |
|
---|
77 |
|
---|
78 |
|
---|
79 | void BIO_Mems_Delta_Encode (unsigned long val, mems_bitio_state * bs,
|
---|
80 | unsigned long *bits);
|
---|
81 | unsigned long BIO_Mems_Delta_Decode (mems_bitio_state * bs, unsigned long *bits);
|
---|
82 |
|
---|
83 |
|
---|
84 | void BIO_Mems_Elias_Encode (unsigned long val, unsigned long b, double s,
|
---|
85 | mems_bitio_state * bs, unsigned long *bits);
|
---|
86 | unsigned long BIO_Mems_Elias_Decode (unsigned long b, double s,
|
---|
87 | mems_bitio_state * bs, unsigned long *bits);
|
---|
88 |
|
---|
89 |
|
---|
90 | void BIO_Mems_Bblock_Encode (unsigned long val, unsigned long b,
|
---|
91 | mems_bitio_state * bs, unsigned long *bits);
|
---|
92 | unsigned long BIO_Mems_Bblock_Decode (unsigned long b, mems_bitio_state * bs,
|
---|
93 | unsigned long *bits);
|
---|
94 |
|
---|
95 |
|
---|
96 | void BIO_Mems_Decode_Seek (unsigned long pos, mems_bitio_state * bs);
|
---|
97 |
|
---|
98 |
|
---|
99 | #endif
|
---|