[3745] | 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 |
|
---|
| 40 | typedef 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 | }
|
---|
| 48 | mem_bitio_state;
|
---|
| 49 |
|
---|
| 50 |
|
---|
| 51 | /* NOTE : All bytes are filled high bit first */
|
---|
| 52 |
|
---|
| 53 |
|
---|
| 54 | void BIO_Mem_Encode_Start (void *buf, int rem, mem_bitio_state * bs);
|
---|
| 55 | void BIO_Mem_Encode_Done (mem_bitio_state * bs);
|
---|
| 56 |
|
---|
| 57 |
|
---|
| 58 |
|
---|
| 59 | void BIO_Mem_Decode_Start (void *buf, int rem, mem_bitio_state * bs);
|
---|
| 60 |
|
---|
| 61 |
|
---|
| 62 |
|
---|
[23508] | 63 | void BIO_Mem_Unary_Encode (mg_u_long val, mem_bitio_state * bs,
|
---|
| 64 | mg_u_long *bits);
|
---|
| 65 | mg_u_long BIO_Mem_Unary_Decode (mem_bitio_state * bs,
|
---|
| 66 | mg_u_long *bits);
|
---|
[3745] | 67 |
|
---|
| 68 |
|
---|
| 69 |
|
---|
[23508] | 70 | void BIO_Mem_Binary_Encode (mg_u_long val, mg_u_long b,
|
---|
| 71 | mem_bitio_state * bs, mg_u_long *bits);
|
---|
| 72 | mg_u_long BIO_Mem_Binary_Decode (mg_u_long b, mem_bitio_state * bs,
|
---|
| 73 | mg_u_long *bits);
|
---|
[3745] | 74 |
|
---|
| 75 |
|
---|
| 76 |
|
---|
[23508] | 77 | void BIO_Mem_Gamma_Encode (mg_u_long val, mem_bitio_state * bs,
|
---|
| 78 | mg_u_long *bits);
|
---|
| 79 | mg_u_long BIO_Mem_Gamma_Decode (mem_bitio_state * bs, mg_u_long *bits);
|
---|
[3745] | 80 |
|
---|
| 81 |
|
---|
| 82 |
|
---|
[23508] | 83 | void BIO_Mem_Delta_Encode (mg_u_long val, mem_bitio_state * bs,
|
---|
| 84 | mg_u_long *bits);
|
---|
| 85 | mg_u_long BIO_Mem_Delta_Decode (mem_bitio_state * bs, mg_u_long *bits);
|
---|
[3745] | 86 |
|
---|
| 87 |
|
---|
[23508] | 88 | void BIO_Mem_Elias_Encode (mg_u_long val, mg_u_long b, double s,
|
---|
| 89 | mem_bitio_state * bs, mg_u_long *bits);
|
---|
| 90 | mg_u_long BIO_Mem_Elias_Decode (mg_u_long b, double s,
|
---|
| 91 | mem_bitio_state * bs, mg_u_long *bits);
|
---|
[3745] | 92 |
|
---|
| 93 |
|
---|
[23508] | 94 | void BIO_Mem_Bblock_Encode (mg_u_long val, mg_u_long b,
|
---|
| 95 | mem_bitio_state * bs, mg_u_long *bits);
|
---|
| 96 | mg_u_long BIO_Mem_Bblock_Decode (mg_u_long b, mem_bitio_state * bs,
|
---|
| 97 | mg_u_long *bits);
|
---|
[3745] | 98 |
|
---|
| 99 |
|
---|
[23508] | 100 | void BIO_Mem_Decode_Seek (mg_u_long pos, mem_bitio_state * bs);
|
---|
[3745] | 101 |
|
---|
| 102 |
|
---|
| 103 | #endif
|
---|