blob: bcad4323373ab7c31529a89c798444c363fea490 (
plain)
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
|
#include <fitz.h>
fz_error *
fz_newrld(fz_filter **fp, fz_obj *params)
{
FZ_NEWFILTER(fz_filter, f, rld);
return nil;
}
void
fz_droprld(fz_filter *rld)
{
}
fz_error *
fz_processrld(fz_filter *filter, fz_buffer *in, fz_buffer *out)
{
int run, i;
unsigned char c;
while (1)
{
if (in->rp == in->wp)
return fz_ioneedin;
if (out->wp == out->ep)
return fz_ioneedout;
run = *in->rp++;
if (run == 128) {
out->eof = 1;
return fz_iodone;
}
else if (run < 128) {
run = run + 1;
if (in->rp + run > in->wp) {
in->rp --;
return fz_ioneedin;
}
if (out->wp + run > out->ep) {
in->rp --;
return fz_ioneedout;
}
for (i = 0; i < run; i++)
*out->wp++ = *in->rp++;
}
else if (run > 128) {
run = 257 - run;
if (in->rp + 1 > in->wp) {
in->rp --;
return fz_ioneedin;
}
if (out->wp + run > out->ep) {
in->rp --;
return fz_ioneedout;
}
c = *in->rp++;
for (i = 0; i < run; i++)
*out->wp++ = c;
}
}
}
|