source: trunk/gsdl/packages/mg/lib/bitio_random.h@ 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: 3.7 KB
Line 
1/**************************************************************************
2 *
3 * bitio_random.h -- Functions for bitio to a file (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_random.h 439 1999-08-10 21:23:37Z sjboddie $
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_RANDOM
35#define H_BITIO_RANDOM
36
37
38
39typedef struct random_bitio_state
40 {
41 FILE *File;
42 unsigned char *Buf;
43 unsigned long Base;
44 unsigned long Used;
45 unsigned long pos;
46 unsigned long len;
47 unsigned long sft;
48 }
49random_bitio_state;
50
51
52/* NOTE : All bytes are filled high bit first */
53
54
55void BIO_Random_Start (FILE * f, unsigned long len,
56 random_bitio_state * bs);
57void BIO_Random_Done (random_bitio_state * bs);
58
59
60
61void BIO_Random_Decode_Start (void *buf, unsigned long pos,
62 random_bitio_state * bs);
63
64void BIO_Random_Encode_Bit (int bit, random_bitio_state * bs);
65
66int BIO_Random_Decode_Bit (random_bitio_state * bs);
67
68
69void BIO_Random_Unary_Encode (unsigned long val, random_bitio_state * bs,
70 unsigned long *bits);
71unsigned long BIO_Random_Unary_Decode (random_bitio_state * bs,
72 unsigned long *bits);
73
74
75
76void BIO_Random_Binary_Encode (unsigned long val, unsigned long b,
77 random_bitio_state * bs, unsigned long *bits);
78unsigned long BIO_Random_Binary_Decode (unsigned long b, random_bitio_state * bs,
79 unsigned long *bits);
80
81
82
83void BIO_Random_Gamma_Encode (unsigned long val, random_bitio_state * bs,
84 unsigned long *bits);
85unsigned long BIO_Random_Gamma_Decode (random_bitio_state * bs,
86 unsigned long *bits);
87
88
89
90void BIO_Random_Delta_Encode (unsigned long val, random_bitio_state * bs,
91 unsigned long *bits);
92unsigned long BIO_Random_Delta_Decode (random_bitio_state * bs,
93 unsigned long *bits);
94
95
96void BIO_Random_Elias_Encode (unsigned long val, unsigned long b, double s,
97 random_bitio_state * bs, unsigned long *bits);
98unsigned long BIO_Random_Elias_Decode (unsigned long b, double s,
99 random_bitio_state * bs,
100 unsigned long *bits);
101
102
103void BIO_Random_Bblock_Encode (unsigned long val, unsigned long b,
104 random_bitio_state * bs, unsigned long *bits);
105unsigned long BIO_Random_Bblock_Decode (unsigned long b,
106 random_bitio_state * bs,
107 unsigned long *bits);
108
109
110void BIO_Random_Seek (unsigned long pos, random_bitio_state * bs);
111
112void BIO_Random_Flush (random_bitio_state * bs);
113
114unsigned long BIO_Random_Tell (random_bitio_state * bs);
115
116
117#endif
Note: See TracBrowser for help on using the repository browser.