diff options
author | Tor Andersson <tor@ghostscript.com> | 2008-10-16 16:28:29 +0200 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2008-10-16 16:28:29 +0200 |
commit | 538ceb14d0144fa44241bebcc512b9c7810ef82d (patch) | |
tree | 965817e0bda1c434150ba0c1295d13f35cd9b0f5 | |
parent | 9555d31fb7f2b98e795e747c26a5ce4617f8d711 (diff) | |
download | mupdf-538ceb14d0144fa44241bebcc512b9c7810ef82d.tar.xz |
Put buffer->eof handling in filter struct, not in individual process functions.
-rw-r--r-- | include/fitz/stm_filter.h | 3 | ||||
-rw-r--r-- | stream/filt_a85d.c | 1 | ||||
-rw-r--r-- | stream/filt_a85e.c | 2 | ||||
-rw-r--r-- | stream/filt_ahxd.c | 1 | ||||
-rw-r--r-- | stream/filt_ahxe.c | 1 | ||||
-rw-r--r-- | stream/filt_dctd.c | 1 | ||||
-rw-r--r-- | stream/filt_dcte.c | 1 | ||||
-rw-r--r-- | stream/filt_faxd.c | 1 | ||||
-rw-r--r-- | stream/filt_faxe.c | 1 | ||||
-rw-r--r-- | stream/filt_flate.c | 2 | ||||
-rw-r--r-- | stream/filt_jbig2d.c | 1 | ||||
-rw-r--r-- | stream/filt_jpxd.c | 1 | ||||
-rw-r--r-- | stream/filt_lzwd.c | 3 | ||||
-rw-r--r-- | stream/filt_lzwe.c | 1 | ||||
-rw-r--r-- | stream/filt_rld.c | 5 | ||||
-rw-r--r-- | stream/filt_rle.c | 4 | ||||
-rw-r--r-- | stream/stm_filter.c | 5 |
17 files changed, 12 insertions, 22 deletions
diff --git a/include/fitz/stm_filter.h b/include/fitz/stm_filter.h index b707838f..1ef52658 100644 --- a/include/fitz/stm_filter.h +++ b/include/fitz/stm_filter.h @@ -14,6 +14,7 @@ * produced -- if we actually produced any new data * consumed -- like above * count -- number of bytes produced in total since the beginning + * done -- remember if we've ever returned fz_iodone * * Most filters take fz_obj as a way to specify parameters. * In most cases, this is a dictionary that contains the same keys @@ -49,6 +50,7 @@ extern fz_error fz_kiodone; (*fp)->consumed = 0; \ (*fp)->produced = 0; \ (*fp)->count = 0; \ + (*fp)->done = 0; \ VAR = (TYPE*) *fp struct fz_filter_s @@ -59,6 +61,7 @@ struct fz_filter_s int consumed; int produced; int count; + int done; }; fz_error *fz_process(fz_filter *f, fz_buffer *in, fz_buffer *out); diff --git a/stream/filt_a85d.c b/stream/filt_a85d.c index 5bbe68cb..19ba9e9a 100644 --- a/stream/filt_a85d.c +++ b/stream/filt_a85d.c @@ -117,7 +117,6 @@ o1: *(out->wp+0) = f->word >> 24; out->wp += f->count - 1; break; } - out->eof = 1; return fz_iodone; } diff --git a/stream/filt_a85e.c b/stream/filt_a85e.c index a33ee7c5..386d8bb3 100644 --- a/stream/filt_a85e.c +++ b/stream/filt_a85e.c @@ -105,7 +105,6 @@ fz_processa85e(fz_filter *filter, fz_buffer *in, fz_buffer *out) *out->wp++ = '~'; *out->wp++ = '>'; - out->eof = 1; return fz_iodone; } @@ -120,7 +119,6 @@ needinput: return fz_ioneedout; *out->wp++ = '~'; *out->wp++ = '>'; - out->eof = 1; return fz_iodone; } return fz_ioneedin; diff --git a/stream/filt_ahxd.c b/stream/filt_ahxd.c index d670a8d9..0feb10c2 100644 --- a/stream/filt_ahxd.c +++ b/stream/filt_ahxd.c @@ -83,7 +83,6 @@ fz_processahxd(fz_filter *filter, fz_buffer *in, fz_buffer *out) else if (c == '>') { if (f->odd) *out->wp++ = (f->a << 4); - out->eof = 1; return fz_iodone; } diff --git a/stream/filt_ahxe.c b/stream/filt_ahxe.c index 8a2e271b..0fc727c3 100644 --- a/stream/filt_ahxe.c +++ b/stream/filt_ahxe.c @@ -57,7 +57,6 @@ needinput: if (out->wp == out->ep) return fz_ioneedout; *out->wp++ = '>'; - out->eof = 1; return fz_iodone; } return fz_ioneedin; diff --git a/stream/filt_dctd.c b/stream/filt_dctd.c index 5a49759c..3425b8e5 100644 --- a/stream/filt_dctd.c +++ b/stream/filt_dctd.c @@ -217,7 +217,6 @@ fz_processdctd(fz_filter *filter, fz_buffer *in, fz_buffer *out) if (b == FALSE) goto needinput; d->stage = 4; - out->eof = 1; in->rp = in->wp - d->src.super.bytes_in_buffer; return fz_iodone; } diff --git a/stream/filt_dcte.c b/stream/filt_dcte.c index 3ce0f21d..5380c6b1 100644 --- a/stream/filt_dcte.c +++ b/stream/filt_dcte.c @@ -239,7 +239,6 @@ fz_processdcte(fz_filter *filter, fz_buffer *in, fz_buffer *out) jpeg_finish_compress(&e->cinfo); e->stage = 3; - out->eof = 1; out->wp = out->ep - e->dst.super.free_in_buffer; return fz_iodone; } diff --git a/stream/filt_faxd.c b/stream/filt_faxd.c index fca7114f..3eaf5f3b 100644 --- a/stream/filt_faxd.c +++ b/stream/filt_faxd.c @@ -465,7 +465,6 @@ rtc: while (i-- && in->rp > in->bp) in->rp --; - out->eof = 1; return fz_iodone; } diff --git a/stream/filt_faxe.c b/stream/filt_faxe.c index 39d46a8c..7551fb80 100644 --- a/stream/filt_faxe.c +++ b/stream/filt_faxe.c @@ -384,7 +384,6 @@ rtc: if (fax->bidx) out->wp ++; - out->eof = 1; return fz_iodone; } diff --git a/stream/filt_flate.c b/stream/filt_flate.c index 0929b558..6a86da3a 100644 --- a/stream/filt_flate.c +++ b/stream/filt_flate.c @@ -94,7 +94,6 @@ fz_processflated(fz_filter *f, fz_buffer *in, fz_buffer *out) if (err == Z_STREAM_END || err == Z_BUF_ERROR) { - out->eof = 1; return fz_iodone; } else if (err == Z_OK) @@ -191,7 +190,6 @@ fz_processflatee(fz_filter *f, fz_buffer *in, fz_buffer *out) if (err == Z_STREAM_END) { - out->eof = 1; return fz_iodone; } else if (err == Z_OK) diff --git a/stream/filt_jbig2d.c b/stream/filt_jbig2d.c index 9f877d37..3569d3eb 100644 --- a/stream/filt_jbig2d.c +++ b/stream/filt_jbig2d.c @@ -106,7 +106,6 @@ fz_processjbig2d(fz_filter *filter, fz_buffer *in, fz_buffer *out) if (d->idx == d->page->height * d->page->stride) { jbig2_release_page(d->ctx, d->page); - out->eof = 1; return fz_iodone; } } diff --git a/stream/filt_jpxd.c b/stream/filt_jpxd.c index a8e14d0d..28dc87de 100644 --- a/stream/filt_jpxd.c +++ b/stream/filt_jpxd.c @@ -141,7 +141,6 @@ output: d->offset ++; } - out->eof = 1; return fz_iodone; } diff --git a/stream/filt_lzwd.c b/stream/filt_lzwd.c index 76ebe92a..c4aed45b 100644 --- a/stream/filt_lzwd.c +++ b/stream/filt_lzwd.c @@ -138,7 +138,6 @@ fz_processlzwd(fz_filter *filter, fz_buffer *in, fz_buffer *out) { if (lzw->bidx > 32 - lzw->codebits) { - out->eof = 1; unstuff(lzw, in); return fz_iodone; } @@ -154,7 +153,6 @@ fz_processlzwd(fz_filter *filter, fz_buffer *in, fz_buffer *out) if (lzw->code == LZW_EOD) { eatbits(lzw, lzw->codebits); - out->eof = 1; unstuff(lzw, in); return fz_iodone; } @@ -171,7 +169,6 @@ fz_processlzwd(fz_filter *filter, fz_buffer *in, fz_buffer *out) if (lzw->code == LZW_EOD) { eatbits(lzw, oldcodebits + MINBITS); - out->eof = 1; unstuff(lzw, in); return fz_iodone; } diff --git a/stream/filt_lzwe.c b/stream/filt_lzwe.c index ec6f5f7a..5a221f9f 100644 --- a/stream/filt_lzwe.c +++ b/stream/filt_lzwe.c @@ -239,7 +239,6 @@ eof: putcode(lzw, out, lzw->oldcode); putcode(lzw, out, LZW_EOD); - out->eof = 1; return fz_iodone; } diff --git a/stream/filt_rld.c b/stream/filt_rld.c index 74499a57..9b0ed75f 100644 --- a/stream/filt_rld.c +++ b/stream/filt_rld.c @@ -25,7 +25,6 @@ fz_processrld(fz_filter *filter, fz_buffer *in, fz_buffer *out) { if (in->eof) { - out->eof = 1; return fz_iodone; } return fz_ioneedin; @@ -36,8 +35,8 @@ fz_processrld(fz_filter *filter, fz_buffer *in, fz_buffer *out) run = *in->rp++; - if (run == 128) { - out->eof = 1; + if (run == 128) + { return fz_iodone; } diff --git a/stream/filt_rle.c b/stream/filt_rle.c index 021c3ecf..65c2a7a4 100644 --- a/stream/filt_rle.c +++ b/stream/filt_rle.c @@ -223,9 +223,9 @@ fprintf(stderr, "--record--\n"); case END: error = puteod(enc, in, out); - if (error) return error; + if (error) + return error; - out->eof = 1; return fz_iodone; } diff --git a/stream/stm_filter.c b/stream/stm_filter.c index 4260158e..450433d4 100644 --- a/stream/stm_filter.c +++ b/stream/stm_filter.c @@ -17,6 +17,9 @@ fz_process(fz_filter *f, fz_buffer *in, fz_buffer *out) oldrp = in->rp; oldwp = out->wp; + if (f->done) + return fz_iodone; + reason = f->process(f, in, out); assert(in->rp <= in->wp); @@ -26,11 +29,13 @@ fz_process(fz_filter *f, fz_buffer *in, fz_buffer *out) f->produced = out->wp > oldwp; f->count += out->wp - oldwp; + /* iodone or error */ if (reason != fz_ioneedin && reason != fz_ioneedout) { if (reason != fz_iodone) reason = fz_rethrow(reason, "cannot process filter"); out->eof = 1; + f->done = 1; } return reason; |