2 |
- |
1 |
/* Copyright (C) 1995, 1996, 1997, 1998 Aladdin Enterprises. All rights reserved.
|
|
|
2 |
|
|
|
3 |
This software is provided AS-IS with no warranty, either express or
|
|
|
4 |
implied.
|
|
|
5 |
|
|
|
6 |
This software is distributed under license and may not be copied,
|
|
|
7 |
modified or distributed except as expressly authorized under the terms
|
|
|
8 |
of the license contained in the file LICENSE in this distribution.
|
|
|
9 |
|
|
|
10 |
For more information about licensing, please refer to
|
|
|
11 |
http://www.ghostscript.com/licensing/. For information on
|
|
|
12 |
commercial licensing, go to http://www.artifex.com/licensing/ or
|
|
|
13 |
contact Artifex Software, Inc., 101 Lucas Valley Road #110,
|
|
|
14 |
San Rafael, CA 94903, U.S.A., +1(415)492-9861.
|
|
|
15 |
*/
|
|
|
16 |
|
|
|
17 |
/* $Id: gsbittab.h,v 1.4 2002/02/21 22:24:52 giles Exp $ */
|
|
|
18 |
/* Interface to tables for bit operations */
|
|
|
19 |
|
|
|
20 |
#ifndef gsbittab_INCLUDED
|
|
|
21 |
# define gsbittab_INCLUDED
|
|
|
22 |
|
|
|
23 |
/*
|
|
|
24 |
* Generate tables for transforming 2, 4, 6, or 8 bits.
|
|
|
25 |
*/
|
|
|
26 |
#define btab2_(v0,v2,v1)\
|
|
|
27 |
v0,v1+v0,v2+v0,v2+v1+v0
|
|
|
28 |
#define bit_table_2(v0,v2,v1) btab2_(v0,v2,v1)
|
|
|
29 |
#define btab4_(v0,v8,v4,v2,v1)\
|
|
|
30 |
btab2_(v0,v2,v1), btab2_(v4+v0,v2,v1),\
|
|
|
31 |
btab2_(v8+v0,v2,v1), btab2_(v8+v4+v0,v2,v1)
|
|
|
32 |
#define bit_table_4(v0,v8,v4,v2,v1) btab4_(v0,v8,v4,v2,v1)
|
|
|
33 |
#define btab6_(v0,v20,v10,v8,v4,v2,v1)\
|
|
|
34 |
btab4_(v0,v8,v4,v2,v1), btab4_(v10+v0,v8,v4,v2,v1),\
|
|
|
35 |
btab4_(v20+v0,v8,v4,v2,v1), btab4_(v20+v10+v0,v8,v4,v2,v1)
|
|
|
36 |
#define bit_table_6(v0,v20,v10,v8,v4,v2,v1) btab6_(v0,v20,v10,v8,v4,v2,v1)
|
|
|
37 |
#define bit_table_8(v0,v80,v40,v20,v10,v8,v4,v2,v1)\
|
|
|
38 |
btab6_(v0,v20,v10,v8,v4,v2,v1), btab6_(v40+v0,v20,v10,v8,v4,v2,v1),\
|
|
|
39 |
btab6_(v80+v0,v20,v10,v8,v4,v2,v1), btab6_(v80+v40+v0,v20,v10,v8,v4,v2,v1)
|
|
|
40 |
|
|
|
41 |
/*
|
|
|
42 |
* byte_reverse_bits[B] = the byte B with the order of bits reversed.
|
|
|
43 |
*/
|
|
|
44 |
extern const byte byte_reverse_bits[256];
|
|
|
45 |
|
|
|
46 |
/*
|
|
|
47 |
* byte_right_mask[N] = a byte with N trailing 1s, 0 <= N <= 8.
|
|
|
48 |
*/
|
|
|
49 |
extern const byte byte_right_mask[9];
|
|
|
50 |
|
|
|
51 |
/*
|
|
|
52 |
* byte_count_bits[B] = the number of 1-bits in a byte with value B.
|
|
|
53 |
*/
|
|
|
54 |
extern const byte byte_count_bits[256];
|
|
|
55 |
|
|
|
56 |
/*
|
|
|
57 |
* byte_bit_run_length_N[B], for 0 <= N <= 7, gives the length of the
|
|
|
58 |
* run of 1-bits starting at bit N in a byte with value B,
|
|
|
59 |
* numbering the bits in the byte as 01234567. If the run includes
|
|
|
60 |
* the low-order bit (i.e., might be continued into a following byte),
|
|
|
61 |
* the run length is increased by 8.
|
|
|
62 |
*/
|
|
|
63 |
extern const byte
|
|
|
64 |
byte_bit_run_length_0[256], byte_bit_run_length_1[256],
|
|
|
65 |
byte_bit_run_length_2[256], byte_bit_run_length_3[256],
|
|
|
66 |
byte_bit_run_length_4[256], byte_bit_run_length_5[256],
|
|
|
67 |
byte_bit_run_length_6[256], byte_bit_run_length_7[256];
|
|
|
68 |
|
|
|
69 |
/*
|
|
|
70 |
* byte_bit_run_length[N] points to byte_bit_run_length_N.
|
|
|
71 |
* byte_bit_run_length_neg[N] = byte_bit_run_length[-N & 7].
|
|
|
72 |
*/
|
|
|
73 |
extern const byte *const byte_bit_run_length[8];
|
|
|
74 |
extern const byte *const byte_bit_run_length_neg[8];
|
|
|
75 |
|
|
|
76 |
/*
|
|
|
77 |
* byte_acegbdfh_to_abcdefgh[acegbdfh] = abcdefgh, where the letters
|
|
|
78 |
* denote the individual bits of the byte.
|
|
|
79 |
*/
|
|
|
80 |
extern const byte byte_acegbdfh_to_abcdefgh[256];
|
|
|
81 |
|
|
|
82 |
#endif /* gsbittab_INCLUDED */
|