2 |
- |
1 |
/* Copyright (C) 1993, 1995, 1996, 1997, 1998, 1999 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: scfx.h,v 1.6 2005/06/03 20:03:54 ray Exp $ */
|
|
|
18 |
/* CCITTFax filter state definition */
|
|
|
19 |
/* Requires strimpl.h */
|
|
|
20 |
|
|
|
21 |
#ifndef scfx_INCLUDED
|
|
|
22 |
# define scfx_INCLUDED
|
|
|
23 |
|
|
|
24 |
#include "shc.h"
|
|
|
25 |
|
|
|
26 |
/* Common state */
|
|
|
27 |
#define stream_CF_state_common\
|
|
|
28 |
stream_hc_state_common;\
|
|
|
29 |
/* The client sets the following before initialization. */\
|
|
|
30 |
bool Uncompressed;\
|
|
|
31 |
int K;\
|
|
|
32 |
bool EndOfLine;\
|
|
|
33 |
bool EncodedByteAlign;\
|
|
|
34 |
int Columns;\
|
|
|
35 |
int Rows;\
|
|
|
36 |
bool EndOfBlock;\
|
|
|
37 |
bool BlackIs1;\
|
|
|
38 |
int DamagedRowsBeforeError; /* (Decode only) */\
|
|
|
39 |
/*bool FirstBitLowOrder;*/ /* in stream_hc_state_common */\
|
|
|
40 |
int DecodedByteAlign;\
|
|
|
41 |
/* The init procedure sets the following. */\
|
|
|
42 |
uint raster;\
|
|
|
43 |
byte *lbuf; /* current scan line buffer */\
|
|
|
44 |
/* (only if decoding or 2-D encoding) */\
|
|
|
45 |
byte *lprev; /* previous scan line buffer (only if 2-D) */\
|
|
|
46 |
/* The following are updated dynamically. */\
|
|
|
47 |
int k_left /* number of next rows to encode in 2-D */\
|
|
|
48 |
/* (only if K > 0) */
|
|
|
49 |
typedef struct stream_CF_state_s {
|
|
|
50 |
stream_CF_state_common;
|
|
|
51 |
} stream_CF_state;
|
|
|
52 |
|
|
|
53 |
/* Define common default parameter setting. */
|
|
|
54 |
#define s_CF_set_defaults_inline(ss)\
|
|
|
55 |
((ss)->Uncompressed = false,\
|
|
|
56 |
(ss)->K = 0,\
|
|
|
57 |
(ss)->EndOfLine = false,\
|
|
|
58 |
(ss)->EncodedByteAlign = false,\
|
|
|
59 |
(ss)->Columns = 1728,\
|
|
|
60 |
(ss)->Rows = 0,\
|
|
|
61 |
(ss)->EndOfBlock = true,\
|
|
|
62 |
(ss)->BlackIs1 = false,\
|
|
|
63 |
/* Added by Adobe since the Red Book */\
|
|
|
64 |
(ss)->DamagedRowsBeforeError = 0, /* always set, for s_CF_get_params */\
|
|
|
65 |
(ss)->FirstBitLowOrder = false,\
|
|
|
66 |
/* Added by us */\
|
|
|
67 |
(ss)->DecodedByteAlign = 1,\
|
|
|
68 |
/* Clear pointers */\
|
|
|
69 |
(ss)->lbuf = 0, (ss)->lprev = 0)
|
|
|
70 |
|
|
|
71 |
/* CCITTFaxEncode */
|
|
|
72 |
typedef struct stream_CFE_state_s {
|
|
|
73 |
stream_CF_state_common;
|
|
|
74 |
/* The init procedure sets the following. */
|
|
|
75 |
int max_code_bytes; /* max # of bytes for an encoded line */
|
|
|
76 |
byte *lcode; /* buffer for encoded output line */
|
|
|
77 |
/* The following change dynamically. */
|
|
|
78 |
int read_count; /* # of bytes to copy into lbuf */
|
|
|
79 |
int write_count; /* # of bytes to copy out of lcode */
|
|
|
80 |
int code_bytes; /* # of occupied bytes in lcode */
|
|
|
81 |
} stream_CFE_state;
|
|
|
82 |
|
|
|
83 |
#define private_st_CFE_state() /* in scfe.c */\
|
|
|
84 |
gs_private_st_ptrs3(st_CFE_state, stream_CFE_state, "CCITTFaxEncode state",\
|
|
|
85 |
cfe_enum_ptrs, cfe_reloc_ptrs, lbuf, lprev, lcode)
|
|
|
86 |
#define s_CFE_set_defaults_inline(ss)\
|
|
|
87 |
(s_CF_set_defaults_inline(ss), (ss)->lcode = 0)
|
|
|
88 |
extern const stream_template s_CFE_template;
|
|
|
89 |
|
|
|
90 |
/* CCITTFaxDecode */
|
|
|
91 |
typedef struct stream_CFD_state_s {
|
|
|
92 |
stream_CF_state_common;
|
|
|
93 |
int cbit; /* bits left to fill in current decoded */
|
|
|
94 |
/* byte at lbuf[wpos] (0..7) */
|
|
|
95 |
int rows_left; /* number of rows left */
|
|
|
96 |
int row; /* current row, first is 0 */
|
|
|
97 |
int rpos; /* rptr for copying lbuf to client */
|
|
|
98 |
int wpos; /* rlimit/wptr for filling lbuf or */
|
|
|
99 |
/* copying to client */
|
|
|
100 |
int eol_count; /* number of EOLs seen so far */
|
|
|
101 |
byte invert; /* current value of 'white' */
|
|
|
102 |
/* for 2-D decoding */
|
|
|
103 |
int run_color; /* -1 if processing white run, */
|
|
|
104 |
/* 0 if between runs but white is next, */
|
|
|
105 |
/* 1 if between runs and black is next, */
|
|
|
106 |
/* 2 if processing black run */
|
|
|
107 |
int damaged_rows; /* # of consecutive damaged rows preceding */
|
|
|
108 |
/* the current row */
|
|
|
109 |
bool skipping_damage; /* true if skipping a damaged row looking */
|
|
|
110 |
/* for EOL */
|
|
|
111 |
/* The following are not used yet. */
|
|
|
112 |
int uncomp_run; /* non-0 iff we are in an uncompressed */
|
|
|
113 |
/* run straddling a scan line (-1 if white, */
|
|
|
114 |
/* 1 if black) */
|
|
|
115 |
int uncomp_left; /* # of bits left in the run */
|
|
|
116 |
int uncomp_exit; /* non-0 iff this is an exit run */
|
|
|
117 |
/* (-1 if next run white, 1 if black) */
|
|
|
118 |
} stream_CFD_state;
|
|
|
119 |
|
|
|
120 |
#define private_st_CFD_state() /* in scfd.c */\
|
|
|
121 |
gs_private_st_ptrs2(st_CFD_state, stream_CFD_state, "CCITTFaxDecode state",\
|
|
|
122 |
cfd_enum_ptrs, cfd_reloc_ptrs, lbuf, lprev)
|
|
|
123 |
#define s_CFD_set_defaults_inline(ss)\
|
|
|
124 |
s_CF_set_defaults_inline(ss)
|
|
|
125 |
extern const stream_template s_CFD_template;
|
|
|
126 |
|
|
|
127 |
#endif /* scfx_INCLUDED */
|