1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
4
This software is provided AS-IS with no warranty, either express or
7
This software is distributed under license and may not be copied, modified
8
or distributed except as expressly authorized under the terms of that
9
license. Refer to licensing information at http://www.artifex.com/
10
or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
11
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
14
/* $Id: scfparam.c 8250 2007-09-25 13:31:24Z giles $ */
15
/* CCITTFax filter parameter setting and reading */
23
#include "scf.h" /* for cfe_max_width */
26
/* Define the CCITTFax parameters. */
27
static const gs_param_item_t s_CF_param_items[] =
29
#define cfp(key, type, memb) { key, type, offset_of(stream_CF_state, memb) }
30
cfp("Uncompressed", gs_param_type_bool, Uncompressed),
31
cfp("K", gs_param_type_int, K),
32
cfp("EndOfLine", gs_param_type_bool, EndOfLine),
33
cfp("EncodedByteAlign", gs_param_type_bool, EncodedByteAlign),
34
cfp("Columns", gs_param_type_int, Columns),
35
cfp("Rows", gs_param_type_int, Rows),
36
cfp("EndOfBlock", gs_param_type_bool, EndOfBlock),
37
cfp("BlackIs1", gs_param_type_bool, BlackIs1),
38
cfp("DamagedRowsBeforeError", gs_param_type_int, DamagedRowsBeforeError),
39
cfp("FirstBitLowOrder", gs_param_type_bool, FirstBitLowOrder),
40
cfp("DecodedByteAlign", gs_param_type_int, DecodedByteAlign),
45
/* Define a limit on the Rows parameter, was too low at 32000 */
46
#define cf_max_height 1000000
48
/* Get non-default CCITTFax filter parameters. */
49
stream_state_proc_get_params(s_CF_get_params, stream_CF_state); /* check */
51
s_CF_get_params(gs_param_list * plist, const stream_CF_state * ss, bool all)
53
stream_CF_state cfs_defaults;
54
const stream_CF_state *defaults;
59
s_CF_set_defaults_inline(&cfs_defaults);
60
defaults = &cfs_defaults;
62
return gs_param_write_items(plist, ss, defaults, s_CF_param_items);
65
/* Put CCITTFax filter parameters. */
66
stream_state_proc_put_params(s_CF_put_params, stream_CF_state); /* check */
68
s_CF_put_params(gs_param_list * plist, stream_CF_state * ss)
70
stream_CF_state state;
74
code = gs_param_read_items(plist, (void *)&state, s_CF_param_items);
76
(state.K < -cf_max_height || state.K > cf_max_height ||
77
state.Columns < 0 || state.Columns > cfe_max_width ||
78
state.Rows < 0 || state.Rows > cf_max_height ||
79
state.DamagedRowsBeforeError < 0 ||
80
state.DamagedRowsBeforeError > cf_max_height ||
81
state.DecodedByteAlign < 1 || state.DecodedByteAlign > 16 ||
82
(state.DecodedByteAlign & (state.DecodedByteAlign - 1)) != 0)
84
code = gs_note_error(gs_error_rangecheck);