From 04334c84b883840ec8bbe62d48e57df5f6408ca7 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 24 May 2005 06:19:10 +0200 Subject: tiff and stream cleanups --- Jamfile | 3 +-- samus/sa_tiff.c | 15 ++++----------- stream/filt_process.c | 51 --------------------------------------------------- stream/stm_filter.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 64 deletions(-) delete mode 100644 stream/filt_process.c create mode 100644 stream/stm_filter.c diff --git a/Jamfile b/Jamfile index a48860e8..f50ad08a 100644 --- a/Jamfile +++ b/Jamfile @@ -134,14 +134,13 @@ Library libstream : obj_print.c obj_simple.c + stm_filter.c stm_buffer.c stm_filec.c stm_filer.c stm_filew.c - filt_process.c filt_pipeline.c - filt_a85d.c filt_a85e.c filt_ahxd.c diff --git a/samus/sa_tiff.c b/samus/sa_tiff.c index 232da32f..3530f944 100644 --- a/samus/sa_tiff.c +++ b/samus/sa_tiff.c @@ -1,6 +1,6 @@ /* - * Minimal TIFF image loader. Baseline TIFF 6.0 with a few extensions, - * as specified in the Metro specification. + * Minimal TIFF image loader. Baseline TIFF 6.0 with CMYK support. + * Limited bit depth and extra samples support, as per Metro. */ #include "fitz.h" @@ -101,7 +101,6 @@ static const unsigned char bitrev[256] = 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff }; - static inline unsigned readshort(sa_tiff *tiff) { unsigned a = fz_readbyte(tiff->file); @@ -234,15 +233,8 @@ printf("w=%d h=%d n=%d bpc=%d ", case 2: printf("CCITT "); - if (tiff->photometric != 0 && tiff->photometric != 1) - return fz_throw("ioerror: ccitt encoding on color TIFF"); - if (tiff->samplesperpixel != 1) - return fz_throw("ioerror: ccitt encoding on multi-component TIFF"); - if (tiff->bitspersample != 1) - return fz_throw("ioerror: ccitt encoding on multi-bit TIFF"); - error = fz_packobj(¶ms, "<<" - "/K 1 /EncodedByteAlign true /EndOfLine false /EndOfBlock false" + "/K 0 /EncodedByteAlign true /EndOfLine false /EndOfBlock false" "/Columns %i /Rows %i /BlackIs1 %b" ">>", tiff->imagewidth, @@ -270,6 +262,7 @@ printf("w=%d h=%d n=%d bpc=%d ", printf("\n"); + /* TODO: scrap write-file and decode with filter directly to final destination */ error = fz_newbuffer(&buf, 4096); error = fz_openbuffer(&file, buf, FZ_WRITE); diff --git a/stream/filt_process.c b/stream/filt_process.c deleted file mode 100644 index afe4feed..00000000 --- a/stream/filt_process.c +++ /dev/null @@ -1,51 +0,0 @@ -#include - -fz_error fz_kioneedin = { -1, "", "", "filter.c", 0 }; -fz_error fz_kioneedout = { -1, "", "", "filter.c", 0 }; -fz_error fz_kiodone = { -1, "", "", "filter.c", 0 }; - -fz_error * -fz_process(fz_filter *f, fz_buffer *in, fz_buffer *out) -{ - fz_error *reason; - unsigned char *oldrp; - unsigned char *oldwp; - - assert(!out->eof); - - oldrp = in->rp; - oldwp = out->wp; - - reason = f->process(f, in, out); - - assert(in->rp <= in->wp); - assert(out->wp <= out->ep); - - f->consumed = in->rp > oldrp; - f->produced = out->wp > oldwp; - f->count += out->wp - oldwp; - - if (reason != fz_ioneedin && reason != fz_ioneedout) - out->eof = 1; - - return reason; -} - -fz_filter * -fz_keepfilter(fz_filter *f) -{ - f->refs ++; - return f; -} - -void -fz_dropfilter(fz_filter *f) -{ - if (--f->refs == 0) - { - if (f->drop) - f->drop(f); - fz_free(f); - } -} - diff --git a/stream/stm_filter.c b/stream/stm_filter.c new file mode 100644 index 00000000..afe4feed --- /dev/null +++ b/stream/stm_filter.c @@ -0,0 +1,51 @@ +#include + +fz_error fz_kioneedin = { -1, "", "", "filter.c", 0 }; +fz_error fz_kioneedout = { -1, "", "", "filter.c", 0 }; +fz_error fz_kiodone = { -1, "", "", "filter.c", 0 }; + +fz_error * +fz_process(fz_filter *f, fz_buffer *in, fz_buffer *out) +{ + fz_error *reason; + unsigned char *oldrp; + unsigned char *oldwp; + + assert(!out->eof); + + oldrp = in->rp; + oldwp = out->wp; + + reason = f->process(f, in, out); + + assert(in->rp <= in->wp); + assert(out->wp <= out->ep); + + f->consumed = in->rp > oldrp; + f->produced = out->wp > oldwp; + f->count += out->wp - oldwp; + + if (reason != fz_ioneedin && reason != fz_ioneedout) + out->eof = 1; + + return reason; +} + +fz_filter * +fz_keepfilter(fz_filter *f) +{ + f->refs ++; + return f; +} + +void +fz_dropfilter(fz_filter *f) +{ + if (--f->refs == 0) + { + if (f->drop) + f->drop(f); + fz_free(f); + } +} + -- cgit v1.2.3