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: zfilter2.c 8250 2007-09-25 13:31:24Z giles $ */
15
/* Additional filter creation */
34
/* ------ CCITTFaxEncode filter ------ */
36
/* <target> <dict> CCITTFaxEncode/filter <file> */
38
zCFE(i_ctx_t *i_ctx_p)
44
check_type(*op, t_dictionary);
46
code = zcf_setup(op, (stream_CF_state *)&cfs, iimemory);
49
return filter_write(i_ctx_p, 0, &s_CFE_template, (stream_state *)&cfs, 0);
52
/* ------ Common setup for possibly pixel-oriented encoding filters ------ */
55
filter_write_predictor(i_ctx_t *i_ctx_p, int npop,
56
const stream_template * template, stream_state * st)
60
stream_PDiff_state pds;
61
stream_PNGP_state pps;
63
if (r_has_type(op, t_dictionary)) {
64
if ((code = dict_int_param(op, "Predictor", 0, 15, 1, &predictor)) < 0)
67
case 0: /* identity */
69
case 1: /* identity */
71
case 2: /* componentwise horizontal differencing */
72
code = zpd_setup(op, &pds);
81
code = zpp_setup(op, &pps);
84
return_error(e_rangecheck);
91
return filter_write(i_ctx_p, npop, template, st, 0);
93
/* We need to cascade filters. */
97
/* Save the operands, just in case. */
98
ref_assign(&rtarget, op - 1);
99
ref_assign(&rdict, op);
100
code = filter_write(i_ctx_p, npop, template, st, 0);
103
/* filter_write changed osp.... */
107
filter_write(i_ctx_p, 0, &s_PDiffE_template, (stream_state *)&pds, 0) :
108
filter_write(i_ctx_p, 0, &s_PNGPE_template, (stream_state *)&pps, 0));
110
/* Restore the operands. Don't bother trying to clean up */
111
/* the first stream. */
113
ref_assign(op - 1, &rtarget);
114
ref_assign(op, &rdict);
118
* Mark the compression stream as temporary, and propagate
119
* CloseTarget from it to the predictor stream.
121
filter_mark_strm_temp(op, 2);
126
/* ------ LZW encoding filter ------ */
128
/* <target> LZWEncode/filter <file> */
129
/* <target> <dict> LZWEncode/filter <file> */
131
zLZWE(i_ctx_t *i_ctx_p)
134
stream_LZW_state lzs;
135
int code = zlz_setup(op, &lzs);
139
return filter_write_predictor(i_ctx_p, 0, &s_LZWE_template,
140
(stream_state *) & lzs);
143
/* ================ Initialization procedure ================ */
145
const op_def zfilter2_op_defs[] =
147
op_def_begin_filter(),
148
{"2CCITTFaxEncode", zCFE},
149
{"1LZWEncode", zLZWE},