File Coverage

xs/filter.xs
Criterion Covered Total %
statement 96 96 100.0
branch 33 62 53.2
condition n/a
subroutine n/a
pod n/a
total 129 158 81.6


line stmt bran cond sub pod time code
1             MODULE = PDF::Make PACKAGE = PDF::Make::Filter
2             PROTOTYPES: ENABLE
3              
4             SV *
5             _ascii85_encode(in_sv)
6             SV *in_sv
7             PREINIT:
8             STRLEN in_len;
9             const uint8_t *in;
10             pdfmake_buf_t out;
11             pdfmake_err_t err;
12             CODE:
13 12           in = (const uint8_t *)SvPVbyte(in_sv, in_len);
14 12 50         if (pdfmake_buf_init(&out) != PDFMAKE_OK) croak("buf_init failed");
15 12           err = pdfmake_ascii85_encode(in, in_len, &out);
16 12 50         if (err != PDFMAKE_OK) { pdfmake_buf_free(&out); croak("ascii85_encode: err=%d", err); }
17 12           RETVAL = newSVpvn((char *)out.data, out.len);
18 12           pdfmake_buf_free(&out);
19             OUTPUT:
20             RETVAL
21              
22             SV *
23             _ascii85_decode(in_sv)
24             SV *in_sv
25             PREINIT:
26             STRLEN in_len;
27             const uint8_t *in;
28             pdfmake_buf_t out;
29             pdfmake_err_t err;
30             CODE:
31 15           in = (const uint8_t *)SvPVbyte(in_sv, in_len);
32 15 50         if (pdfmake_buf_init(&out) != PDFMAKE_OK) croak("buf_init failed");
33 15           err = pdfmake_ascii85_decode(in, in_len, &out);
34 15 50         if (err != PDFMAKE_OK) { pdfmake_buf_free(&out); croak("ascii85_decode: err=%d", err); }
35 15           RETVAL = newSVpvn((char *)out.data, out.len);
36 15           pdfmake_buf_free(&out);
37             OUTPUT:
38             RETVAL
39              
40             SV *
41             _asciihex_encode(in_sv)
42             SV *in_sv
43             PREINIT:
44             STRLEN in_len;
45             const uint8_t *in;
46             pdfmake_buf_t out;
47             pdfmake_err_t err;
48             CODE:
49 3           in = (const uint8_t *)SvPVbyte(in_sv, in_len);
50 3 50         if (pdfmake_buf_init(&out) != PDFMAKE_OK) croak("buf_init failed");
51 3           err = pdfmake_asciihex_encode(in, in_len, &out);
52 3 50         if (err != PDFMAKE_OK) { pdfmake_buf_free(&out); croak("asciihex_encode: err=%d", err); }
53 3           RETVAL = newSVpvn((char *)out.data, out.len);
54 3           pdfmake_buf_free(&out);
55             OUTPUT:
56             RETVAL
57              
58             SV *
59             _asciihex_decode(in_sv)
60             SV *in_sv
61             PREINIT:
62             STRLEN in_len;
63             const uint8_t *in;
64             pdfmake_buf_t out;
65             pdfmake_err_t err;
66             CODE:
67 8           in = (const uint8_t *)SvPVbyte(in_sv, in_len);
68 8 50         if (pdfmake_buf_init(&out) != PDFMAKE_OK) croak("buf_init failed");
69 8           err = pdfmake_asciihex_decode(in, in_len, &out);
70 8 50         if (err != PDFMAKE_OK) { pdfmake_buf_free(&out); croak("asciihex_decode: err=%d", err); }
71 8           RETVAL = newSVpvn((char *)out.data, out.len);
72 8           pdfmake_buf_free(&out);
73             OUTPUT:
74             RETVAL
75              
76             SV *
77             _rle_encode(in_sv)
78             SV *in_sv
79             PREINIT:
80             STRLEN in_len;
81             const uint8_t *in;
82             pdfmake_buf_t out;
83             pdfmake_err_t err;
84             CODE:
85 6           in = (const uint8_t *)SvPVbyte(in_sv, in_len);
86 6 50         if (pdfmake_buf_init(&out) != PDFMAKE_OK) croak("buf_init failed");
87 6           err = pdfmake_rle_encode(in, in_len, &out);
88 6 50         if (err != PDFMAKE_OK) { pdfmake_buf_free(&out); croak("rle_encode: err=%d", err); }
89 6           RETVAL = newSVpvn((char *)out.data, out.len);
90 6           pdfmake_buf_free(&out);
91             OUTPUT:
92             RETVAL
93              
94             SV *
95             _rle_decode(in_sv)
96             SV *in_sv
97             PREINIT:
98             STRLEN in_len;
99             const uint8_t *in;
100             pdfmake_buf_t out;
101             pdfmake_err_t err;
102             CODE:
103 13           in = (const uint8_t *)SvPVbyte(in_sv, in_len);
104 13 50         if (pdfmake_buf_init(&out) != PDFMAKE_OK) croak("buf_init failed");
105 13           err = pdfmake_rle_decode(in, in_len, &out);
106 13 50         if (err != PDFMAKE_OK) { pdfmake_buf_free(&out); croak("rle_decode: err=%d", err); }
107 13           RETVAL = newSVpvn((char *)out.data, out.len);
108 13           pdfmake_buf_free(&out);
109             OUTPUT:
110             RETVAL
111              
112             SV *
113             _flate_encode(in_sv)
114             SV *in_sv
115             PREINIT:
116             STRLEN in_len;
117             const uint8_t *in;
118             pdfmake_buf_t out;
119             pdfmake_flate_params_t params;
120             pdfmake_err_t err;
121             CODE:
122 8           in = (const uint8_t *)SvPVbyte(in_sv, in_len);
123 8 50         if (pdfmake_buf_init(&out) != PDFMAKE_OK) croak("buf_init failed");
124 8           pdfmake_flate_params_init(¶ms);
125 8           err = pdfmake_flate_encode(in, in_len, ¶ms, &out);
126 8 50         if (err != PDFMAKE_OK) { pdfmake_buf_free(&out); croak("flate_encode: err=%d", err); }
127 8           RETVAL = newSVpvn((char *)out.data, out.len);
128 8           pdfmake_buf_free(&out);
129             OUTPUT:
130             RETVAL
131              
132             SV *
133             _flate_decode(in_sv)
134             SV *in_sv
135             PREINIT:
136             STRLEN in_len;
137             const uint8_t *in;
138             pdfmake_buf_t out;
139             pdfmake_flate_params_t params;
140             pdfmake_err_t err;
141             CODE:
142 8           in = (const uint8_t *)SvPVbyte(in_sv, in_len);
143 8 50         if (pdfmake_buf_init(&out) != PDFMAKE_OK) croak("buf_init failed");
144 8           pdfmake_flate_params_init(¶ms);
145 8           err = pdfmake_flate_decode(in, in_len, ¶ms, &out);
146 8 100         if (err != PDFMAKE_OK) { pdfmake_buf_free(&out); croak("flate_decode: err=%d", err); }
147 7           RETVAL = newSVpvn((char *)out.data, out.len);
148 7           pdfmake_buf_free(&out);
149             OUTPUT:
150             RETVAL
151              
152             SV *
153             _deflate_encode(in_sv, level)
154             SV *in_sv
155             int level
156             PREINIT:
157             STRLEN in_len;
158             const uint8_t *in;
159             pdfmake_buf_t out;
160             pdfmake_err_t err;
161             CODE:
162 5           in = (const uint8_t *)SvPVbyte(in_sv, in_len);
163 5 50         if (pdfmake_buf_init(&out) != PDFMAKE_OK) croak("buf_init failed");
164 5           err = pdfmake_deflate_encode(in, in_len, level, &out);
165 5 50         if (err != PDFMAKE_OK) { pdfmake_buf_free(&out); croak("deflate_encode: err=%d", err); }
166 5           RETVAL = newSVpvn((char *)out.data, out.len);
167 5           pdfmake_buf_free(&out);
168             OUTPUT:
169             RETVAL
170              
171             SV *
172             _deflate_decode(in_sv)
173             SV *in_sv
174             PREINIT:
175             STRLEN in_len;
176             const uint8_t *in;
177             pdfmake_buf_t out;
178             pdfmake_err_t err;
179             CODE:
180 5           in = (const uint8_t *)SvPVbyte(in_sv, in_len);
181 5 50         if (pdfmake_buf_init(&out) != PDFMAKE_OK) croak("buf_init failed");
182 5           err = pdfmake_deflate_decode(in, in_len, &out);
183 5 50         if (err != PDFMAKE_OK) { pdfmake_buf_free(&out); croak("deflate_decode: err=%d", err); }
184 5           RETVAL = newSVpvn((char *)out.data, out.len);
185 5           pdfmake_buf_free(&out);
186             OUTPUT:
187             RETVAL
188              
189             UV
190             _adler32(in_sv)
191             SV *in_sv
192             PREINIT:
193             STRLEN in_len;
194             const uint8_t *in;
195             CODE:
196 4           in = (const uint8_t *)SvPVbyte(in_sv, in_len);
197 4 100         RETVAL = (UV)pdfmake_adler32(in, in_len);
198             OUTPUT:
199             RETVAL
200              
201             SV *
202             _lzw_decode(in_sv, early_change = 1)
203             SV *in_sv
204             int early_change
205             PREINIT:
206             STRLEN in_len;
207             const uint8_t *in;
208             pdfmake_buf_t out;
209             pdfmake_flate_params_t params;
210             pdfmake_err_t err;
211             CODE:
212 4           in = (const uint8_t *)SvPVbyte(in_sv, in_len);
213 4 50         if (pdfmake_buf_init(&out) != PDFMAKE_OK) croak("buf_init failed");
214 4           pdfmake_flate_params_init(¶ms);
215 4           params.early_change = early_change;
216 4           err = pdfmake_lzw_decode(in, in_len, ¶ms, &out);
217 4 50         if (err != PDFMAKE_OK) { pdfmake_buf_free(&out); croak("lzw_decode: err=%d", err); }
218 4           RETVAL = newSVpvn((char *)out.data, out.len);
219 4           pdfmake_buf_free(&out);
220             OUTPUT:
221             RETVAL
222              
223             SV *
224             _predictor_encode(predictor, colors, bits, columns, in_sv)
225             int predictor
226             int colors
227             int bits
228             int columns
229             SV *in_sv
230             PREINIT:
231             STRLEN in_len;
232             const uint8_t *in;
233             pdfmake_buf_t out;
234             pdfmake_err_t err;
235             CODE:
236 7           in = (const uint8_t *)SvPVbyte(in_sv, in_len);
237 7 50         if (pdfmake_buf_init(&out) != PDFMAKE_OK) croak("buf_init failed");
238 7           err = pdfmake_predictor_encode(predictor, colors, bits, columns, in, in_len, &out);
239 7 50         if (err != PDFMAKE_OK) { pdfmake_buf_free(&out); croak("predictor_encode: err=%d", err); }
240 7           RETVAL = newSVpvn((char *)out.data, out.len);
241 7           pdfmake_buf_free(&out);
242             OUTPUT:
243             RETVAL
244              
245             SV *
246             _predictor_decode(predictor, colors, bits, columns, in_sv)
247             int predictor
248             int colors
249             int bits
250             int columns
251             SV *in_sv
252             PREINIT:
253             STRLEN in_len;
254             const uint8_t *in;
255             pdfmake_buf_t out;
256             pdfmake_err_t err;
257             CODE:
258 7           in = (const uint8_t *)SvPVbyte(in_sv, in_len);
259 7 50         if (pdfmake_buf_init(&out) != PDFMAKE_OK) croak("buf_init failed");
260 7           err = pdfmake_predictor_decode(predictor, colors, bits, columns, in, in_len, &out);
261 7 50         if (err != PDFMAKE_OK) { pdfmake_buf_free(&out); croak("predictor_decode: err=%d", err); }
262 7           RETVAL = newSVpvn((char *)out.data, out.len);
263 7           pdfmake_buf_free(&out);
264             OUTPUT:
265             RETVAL
266              
267             SV *
268             _tiff_predictor_encode(colors, bits, columns, in_sv)
269             int colors
270             int bits
271             int columns
272             SV *in_sv
273             PREINIT:
274             STRLEN in_len;
275             const uint8_t *in;
276             pdfmake_buf_t out;
277             pdfmake_err_t err;
278             CODE:
279 1           in = (const uint8_t *)SvPVbyte(in_sv, in_len);
280 1 50         if (pdfmake_buf_init(&out) != PDFMAKE_OK) croak("buf_init failed");
281 1           err = pdfmake_tiff_predictor_encode(colors, bits, columns, in, in_len, &out);
282 1 50         if (err != PDFMAKE_OK) { pdfmake_buf_free(&out); croak("tiff_predictor_encode: err=%d", err); }
283 1           RETVAL = newSVpvn((char *)out.data, out.len);
284 1           pdfmake_buf_free(&out);
285             OUTPUT:
286             RETVAL
287              
288             SV *
289             _tiff_predictor_decode(colors, bits, columns, in_sv)
290             int colors
291             int bits
292             int columns
293             SV *in_sv
294             PREINIT:
295             STRLEN in_len;
296             const uint8_t *in;
297             pdfmake_buf_t out;
298             pdfmake_err_t err;
299             CODE:
300 1           in = (const uint8_t *)SvPVbyte(in_sv, in_len);
301 1 50         if (pdfmake_buf_init(&out) != PDFMAKE_OK) croak("buf_init failed");
302 1           err = pdfmake_tiff_predictor_decode(colors, bits, columns, in, in_len, &out);
303 1 50         if (err != PDFMAKE_OK) { pdfmake_buf_free(&out); croak("tiff_predictor_decode: err=%d", err); }
304 1           RETVAL = newSVpvn((char *)out.data, out.len);
305 1           pdfmake_buf_free(&out);
306             OUTPUT:
307             RETVAL