1/*
2 * "$Id: bit-ops.h,v 1.4 2009/05/17 19:25:36 rlk Exp $"
3 *
4 *   Softweave calculator for gimp-print.
5 *
6 *   Copyright 2000 Charles Briscoe-Smith <cpbs@debian.org>
7 *
8 *   This program is free software; you can redistribute it and/or modify it
9 *   under the terms of the GNU General Public License as published by the Free
10 *   Software Foundation; either version 2 of the License, or (at your option)
11 *   any later version.
12 *
13 *   This program is distributed in the hope that it will be useful, but
14 *   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 *   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16 *   for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 */
22
23/**
24 * @file gutenprint/bit-ops.h
25 * @brief Bit operations.
26 */
27
28#ifndef GUTENPRINT_BIT_OPS_H
29#define GUTENPRINT_BIT_OPS_H
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35/**
36 * Interleave a buffer consisting of two bit strings of length single_length
37 * into one string of packed two-bit ints.
38 *
39 * @param line the input bit string
40 * @param single_length the length (in bytes) of the input
41 * @param outbuf the output.
42 */
43extern void	stp_fold(const unsigned char *line, int single_length,
44			 unsigned char *outbuf);
45
46/**
47 * Interleave a buffer consisting of three bit strings of length single_length
48 * into one string of packed three-bit ints.
49 *
50 * @param line the input bit string
51 * @param single_length the length (in bytes) of the input
52 * @param outbuf the output.
53 */
54extern void	stp_fold_3bit(const unsigned char *line, int single_length,
55			 unsigned char *outbuf);
56
57/**
58 * Interleave a buffer consisting of three bit strings of length single_length
59 * into one string of packed three-bit ints.
60 *
61 * @param line the input bit string
62 * @param single_length the length (in bytes) of the input
63 * @param outbuf the output.
64 */
65extern void	stp_fold_3bit_323(const unsigned char *line, int single_length,
66			 unsigned char *outbuf);
67
68/**
69 * Interleave a buffer consisting of four bit strings of length single_length
70 * into one string of packed four-bit ints.
71 *
72 * @param line the input bit string
73 * @param single_length the length (in bytes) of the input
74 * @param outbuf the output.
75 */
76extern void	stp_fold_4bit(const unsigned char *line, int single_length,
77			 unsigned char *outbuf);
78
79/**
80 * Split an input sequence of packed 1 or 2 bit integers into two or more
81 * outputs of equal length, distributing non-zero integers round robin
82 * into each output.  Used in "high quality" modes when extra passes are
83 * made, to ensure that each pass gets an equal number of ink drops.
84 * Each output is as long as the input.
85 *
86 * @param height the number of integers in the input divided by 8
87 * @param bits the bit depth (1 or 2)
88 * @param n the number of outputs into which the input should be distributed
89 * @param in the input bit string
90 * @param stride the stride across the outputs (if it's necessary to
91 * distribute the input over non-contiguous members of the array of outputs)
92 * @param outs the array of output bit strings
93 */
94extern void	stp_split(int height, int bits, int n, const unsigned char *in,
95			  int stride, unsigned char **outs);
96
97/**
98 * Deprecated -- use stp_split
99 */
100extern void	stp_split_2(int height, int bits, const unsigned char *in,
101			    unsigned char *outhi, unsigned char *outlo);
102
103/**
104 * Deprecated -- use stp_split
105 */
106extern void	stp_split_4(int height, int bits, const unsigned char *in,
107			    unsigned char *out0, unsigned char *out1,
108			    unsigned char *out2, unsigned char *out3);
109
110/**
111 * Unpack an input sequence of packed 1 or 2 bit integers into two or more
112 * outputs of equal length.  The input is round robined into the outputs.
113 * Each output is 1/n as long as the input.
114 *
115 * @param height the number of integers in the input divided by 8
116 * @param bits the bit depth (1 or 2)
117 * @param n the number of outputs into which the input should be distributed
118 * @param in the input bit string
119 * @param outs the array of output bit strings
120 *
121 */
122extern void	stp_unpack(int height, int bits, int n, const unsigned char *in,
123			   unsigned char **outs);
124
125/**
126 * Deprecated -- use stp_unpack
127 */
128extern void	stp_unpack_2(int height, int bits, const unsigned char *in,
129			     unsigned char *outlo, unsigned char *outhi);
130
131/**
132 * Deprecated -- use stp_unpack
133 */
134extern void	stp_unpack_4(int height, int bits, const unsigned char *in,
135			     unsigned char *out0, unsigned char *out1,
136			     unsigned char *out2, unsigned char *out3);
137
138/**
139 * Deprecated -- use stp_unpack
140 */
141extern void	stp_unpack_8(int height, int bits, const unsigned char *in,
142			     unsigned char *out0, unsigned char *out1,
143			     unsigned char *out2, unsigned char *out3,
144			     unsigned char *out4, unsigned char *out5,
145			     unsigned char *out6, unsigned char *out7);
146
147/**
148 * Deprecated -- use stp_unpack
149 */
150extern void	stp_unpack_16(int height, int bits, const unsigned char *in,
151			      unsigned char *out0, unsigned char *out1,
152			      unsigned char *out2, unsigned char *out3,
153			      unsigned char *out4, unsigned char *out5,
154			      unsigned char *out6, unsigned char *out7,
155			      unsigned char *out8, unsigned char *out9,
156			      unsigned char *out10, unsigned char *out11,
157			      unsigned char *out12, unsigned char *out13,
158			      unsigned char *out14, unsigned char *out15);
159
160#ifdef __cplusplus
161  }
162#endif
163
164#endif /* GUTENPRINT_BIT_OPS_H */
165