1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
/* Copyright (C) 1995, 2000 Aladdin Enterprises. All rights reserved.
This software is provided AS-IS with no warranty, either express or
implied.
This software is distributed under license and may not be copied,
modified or distributed except as expressly authorized under the terms
of the license contained in the file LICENSE in this distribution.
For more information about licensing, please refer to
http://www.ghostscript.com/licensing/. For information on
commercial licensing, go to http://www.artifex.com/licensing/ or
contact Artifex Software, Inc., 101 Lucas Valley Road #110,
San Rafael, CA 94903, U.S.A., +1(415)492-9861.
*/
/*$RCSfile$ $Revision$ */
/* zlib and Flate filter creation */
#include "ghost.h"
#include "oper.h"
#include "idict.h"
#include "strimpl.h"
#include "spdiffx.h"
#include "spngpx.h"
#include "szlibx.h"
#include "idparam.h"
#include "ifilter.h"
#include "ifrpred.h"
#include "ifwpred.h"
/* Common setup for zlib (Flate) filter */
private int
filter_zlib(i_ctx_t *i_ctx_p, stream_zlib_state *pzls)
{
os_ptr op = osp;
int code = 0;
(*s_zlibE_template.set_defaults)((stream_state *)pzls);
if (r_has_type(op, t_dictionary))
code = dict_int_param(op, "Effort", -1, 9, -1, &pzls->level);
return code;
}
/* <source> zlibEncode/filter <file> */
/* <source> <dict> zlibEncode/filter <file> */
private int
zzlibE(i_ctx_t *i_ctx_p)
{
stream_zlib_state zls;
int code = filter_zlib(i_ctx_p, &zls);
if (code < 0)
return code;
return filter_write(i_ctx_p, 0, &s_zlibE_template, (stream_state *)&zls, 0);
}
/* <target> zlibDecode/filter <file> */
/* <target> <dict> zlibDecode/filter <file> */
private int
zzlibD(i_ctx_t *i_ctx_p)
{
stream_zlib_state zls;
(*s_zlibD_template.set_defaults)((stream_state *)&zls);
return filter_read(i_ctx_p, 0, &s_zlibD_template, (stream_state *)&zls, 0);
}
/* <source> FlateEncode/filter <file> */
/* <source> <dict> FlateEncode/filter <file> */
private int
zFlateE(i_ctx_t *i_ctx_p)
{
stream_zlib_state zls;
int code = filter_zlib(i_ctx_p, &zls);
if (code < 0)
return code;
return filter_write_predictor(i_ctx_p, 0, &s_zlibE_template,
(stream_state *)&zls);
}
/* <target> FlateDecode/filter <file> */
/* <target> <dict> FlateDecode/filter <file> */
private int
zFlateD(i_ctx_t *i_ctx_p)
{
stream_zlib_state zls;
(*s_zlibD_template.set_defaults)((stream_state *)&zls);
return filter_read_predictor(i_ctx_p, 0, &s_zlibD_template,
(stream_state *)&zls);
}
/* ------ Initialization procedure ------ */
const op_def zfzlib_op_defs[] =
{
op_def_begin_filter(),
{"1zlibEncode", zzlibE},
{"1zlibDecode", zzlibD},
{"1FlateEncode", zFlateE},
{"1FlateDecode", zFlateD},
op_def_end(0)
};
|