diff options
author | Sam Leffler <sam@engr.sgi.com> | 1996-02-09 22:51:07 +0000 |
---|---|---|
committer | Roger Leigh <rleigh@codelibre.net> | 2022-06-22 18:37:14 +0100 |
commit | 963e9c6bc0b30048052bf076e0c8b62ea2f9e90f (patch) | |
tree | cfbc5c90031d152c07ec8b2169c4ed0e67578491 /libtiff | |
parent | 98ce01d4275de67a73e57548172d9a35caa84b92 (diff) | |
download | libtiff-git-963e9c6bc0b30048052bf076e0c8b62ea2f9e90f.tar.gz |
v3.4beta029 releasev3.4beta029
Diffstat (limited to 'libtiff')
-rw-r--r-- | libtiff/Makefile.in | 8 | ||||
-rw-r--r-- | libtiff/tif_apple.c | 4 | ||||
-rw-r--r-- | libtiff/tif_fax3.c | 101 | ||||
-rw-r--r-- | libtiff/tif_fax3.h | 42 | ||||
-rw-r--r-- | libtiff/tiffcomp.h | 4 |
5 files changed, 99 insertions, 60 deletions
diff --git a/libtiff/Makefile.in b/libtiff/Makefile.in index c7b9491f..d29af81b 100644 --- a/libtiff/Makefile.in +++ b/libtiff/Makefile.in @@ -1,4 +1,4 @@ -# $Header: /usr/people/sam/tiff/libtiff/RCS/Makefile.in,v 1.27 1996/01/10 19:35:01 sam Exp $ +# $Header: /usr/people/sam/tiff/libtiff/RCS/Makefile.in,v 1.28 1996/02/09 05:55:00 sam Exp $ # # Tag Image File Format Library # @@ -33,7 +33,7 @@ SRCDIR = @LIBSRCDIR@ # TARGET: @TARGET@ # CCOMPILER: @CCOMPILER@ # -SHELL = /bin/sh +SHELL = @SCRIPT_SH@ NULL = CC = @CCOMPILER@ AR = @AR@ @@ -136,6 +136,8 @@ TARGETS = libtiff.a all: ${TARGETS} if [ @DSO@dso != nodso ]; then \ ${MAKE} @DSO@dso; \ + else \ + true; \ fi libtiff.a: ${OBJS} @@ -261,6 +263,8 @@ install: all installHdrs ${INSTALL} -idb tiff.sw.dev -m 444 -F @DIR_LIB@ -O libtiff.a if [ @DSO@dso != nodso ]; then \ ${MAKE} installDSO; \ + else \ + true; \ fi clean: diff --git a/libtiff/tif_apple.c b/libtiff/tif_apple.c index 519b876f..81f87724 100644 --- a/libtiff/tif_apple.c +++ b/libtiff/tif_apple.c @@ -1,4 +1,4 @@ -/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_apple.c,v 1.21 1996/01/10 19:32:54 sam Exp $ */ +/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_apple.c,v 1.22 1996/02/06 23:50:58 sam Exp $ */ /* * Copyright (c) 1988-1996 Sam Leffler @@ -46,7 +46,7 @@ #include <Files.h> #include <Memory.h> -#if defined(__PPCC__) || defined(__SC__) || defined(__MRC__) +#if defined(__PPCC__) || defined(__SC__) || defined(__MRC__) || defined(applec) #define CtoPstr c2pstr #endif diff --git a/libtiff/tif_fax3.c b/libtiff/tif_fax3.c index ea32a3bc..2d5df7f0 100644 --- a/libtiff/tif_fax3.c +++ b/libtiff/tif_fax3.c @@ -1,4 +1,4 @@ -/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_fax3.c,v 1.133 1996/01/10 19:33:02 sam Exp $ */ +/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_fax3.c,v 1.135 1996/02/08 20:21:27 sam Exp $ */ /* * Copyright (c) 1990-1996 Sam Leffler @@ -592,6 +592,17 @@ Fax3PutBits(TIFF* tif, u_int bits, u_int length) */ #define putcode(tif, te) Fax3PutBits(tif, (te)->code, (te)->length) +#ifdef FAX3_DEBUG +#define DEBUG_COLOR(w) (tab == TIFFFaxWhiteCodes ? w "W" : w "B") +#define DEBUG_PRINT(what,len) { \ + int t; \ + printf("%08X/%-2d: %s%5d\t", data, bit, DEBUG_COLOR(what), len); \ + for (t = length-1; t >= 0; t--) \ + putchar(code & (1<<t) ? '1' : '0'); \ + putchar('\n'); \ +} +#endif + /* * Write the sequence of codes that describes * the specified span of zero's or one's. The @@ -609,6 +620,9 @@ putspan(TIFF* tif, int32 span, const tableentry* tab) while (span >= 2624) { const tableentry* te = &tab[63 + (2560>>6)]; code = te->code, length = te->length; +#ifdef FAX3_DEBUG + DEBUG_PRINT("MakeUp", te->runlen); +#endif _PutBits(tif, code, length); span -= te->runlen; } @@ -616,10 +630,16 @@ putspan(TIFF* tif, int32 span, const tableentry* tab) const tableentry* te = &tab[63 + (span>>6)]; assert(te->runlen == 64*(span>>6)); code = te->code, length = te->length; +#ifdef FAX3_DEBUG + DEBUG_PRINT("MakeUp", te->runlen); +#endif _PutBits(tif, code, length); span -= te->runlen; } code = tab[span].code, length = tab[span].length; +#ifdef FAX3_DEBUG + DEBUG_PRINT(" Term", tab[span].runlen); +#endif _PutBits(tif, code, length); sp->data = data; @@ -1070,21 +1090,20 @@ Fax3Cleanup(TIFF* tif) } } -#define FIELD_OPTIONS (FIELD_CODEC+0) -#define FIELD_BADFAXLINES (FIELD_CODEC+1) -#define FIELD_CLEANFAXDATA (FIELD_CODEC+2) -#define FIELD_BADFAXRUN (FIELD_CODEC+3) -#define FIELD_RECVPARAMS (FIELD_CODEC+4) -#define FIELD_SUBADDRESS (FIELD_CODEC+5) -#define FIELD_RECVTIME (FIELD_CODEC+6) +#define FIELD_BADFAXLINES (FIELD_CODEC+0) +#define FIELD_CLEANFAXDATA (FIELD_CODEC+1) +#define FIELD_BADFAXRUN (FIELD_CODEC+2) +#define FIELD_RECVPARAMS (FIELD_CODEC+3) +#define FIELD_SUBADDRESS (FIELD_CODEC+4) +#define FIELD_RECVTIME (FIELD_CODEC+5) -static const TIFFFieldInfo fax3FieldInfo[] = { +#define FIELD_OPTIONS (FIELD_CODEC+6) + +static const TIFFFieldInfo faxFieldInfo[] = { { TIFFTAG_FAXMODE, 0, 0, TIFF_ANY, FIELD_PSEUDO, FALSE, FALSE, "FaxMode" }, { TIFFTAG_FAXFILLFUNC, 0, 0, TIFF_ANY, FIELD_PSEUDO, FALSE, FALSE, "FaxFillFunc" }, - { TIFFTAG_GROUP3OPTIONS, 1, 1, TIFF_LONG, FIELD_OPTIONS, - FALSE, FALSE, "Group3Options" }, { TIFFTAG_BADFAXLINES, 1, 1, TIFF_LONG, FIELD_BADFAXLINES, TRUE, FALSE, "BadFaxLines" }, { TIFFTAG_BADFAXLINES, 1, 1, TIFF_SHORT, FIELD_BADFAXLINES, @@ -1102,29 +1121,13 @@ static const TIFFFieldInfo fax3FieldInfo[] = { { TIFFTAG_FAXRECVTIME, 1, 1, TIFF_LONG, FIELD_RECVTIME, TRUE, FALSE, "FaxRecvTime" }, }; +static const TIFFFieldInfo fax3FieldInfo[] = { + { TIFFTAG_GROUP3OPTIONS, 1, 1, TIFF_LONG, FIELD_OPTIONS, + FALSE, FALSE, "Group3Options" }, +}; static const TIFFFieldInfo fax4FieldInfo[] = { - { TIFFTAG_FAXMODE, 0, 0, TIFF_ANY, FIELD_PSEUDO, - FALSE, FALSE, "FaxMode" }, - { TIFFTAG_FAXFILLFUNC, 0, 0, TIFF_ANY, FIELD_PSEUDO, - FALSE, FALSE, "FaxFillFunc" }, { TIFFTAG_GROUP4OPTIONS, 1, 1, TIFF_LONG, FIELD_OPTIONS, FALSE, FALSE, "Group4Options" }, - { TIFFTAG_BADFAXLINES, 1, 1, TIFF_LONG, FIELD_BADFAXLINES, - TRUE, FALSE, "BadFaxLines" }, - { TIFFTAG_BADFAXLINES, 1, 1, TIFF_SHORT, FIELD_BADFAXLINES, - TRUE, FALSE, "BadFaxLines" }, - { TIFFTAG_CLEANFAXDATA, 1, 1, TIFF_SHORT, FIELD_CLEANFAXDATA, - TRUE, FALSE, "CleanFaxData" }, - { TIFFTAG_CONSECUTIVEBADFAXLINES,1,1, TIFF_LONG, FIELD_BADFAXRUN, - TRUE, FALSE, "ConsecutiveBadFaxLines" }, - { TIFFTAG_CONSECUTIVEBADFAXLINES,1,1, TIFF_SHORT, FIELD_BADFAXRUN, - TRUE, FALSE, "ConsecutiveBadFaxLines" }, - { TIFFTAG_FAXRECVPARAMS, 1, 1, TIFF_LONG, FIELD_RECVPARAMS, - TRUE, FALSE, "FaxRecvParams" }, - { TIFFTAG_FAXSUBADDRESS, -1,-1, TIFF_ASCII, FIELD_SUBADDRESS, - TRUE, FALSE, "FaxSubAddress" }, - { TIFFTAG_FAXRECVTIME, 1, 1, TIFF_LONG, FIELD_RECVTIME, - TRUE, FALSE, "FaxRecvTime" }, }; #define N(a) (sizeof (a) / sizeof (a[0])) @@ -1268,8 +1271,8 @@ Fax3PrintDir(TIFF* tif, FILE* fd, long flags) (u_long) sp->recvtime); } -int -TIFFInitCCITTFax3(TIFF* tif, int scheme) +static int +InitCCITTFax3(TIFF* tif) { Fax3BaseState* sp; @@ -1291,14 +1294,7 @@ TIFFInitCCITTFax3(TIFF* tif, int scheme) * Merge codec-specific tag information and * override parent get/set field methods. */ - switch (scheme) { - case COMPRESSION_CCITTFAX3: - _TIFFMergeFieldInfo(tif, fax3FieldInfo, N(fax3FieldInfo)); - break; - case COMPRESSION_CCITTFAX4: - _TIFFMergeFieldInfo(tif, fax4FieldInfo, N(fax4FieldInfo)); - break; - } + _TIFFMergeFieldInfo(tif, faxFieldInfo, N(faxFieldInfo)); sp->vgetparent = tif->tif_vgetfield; tif->tif_vgetfield = Fax3VGetField; /* hook for codec tags */ sp->vsetparent = tif->tif_vsetfield; @@ -1308,7 +1304,6 @@ TIFFInitCCITTFax3(TIFF* tif, int scheme) sp->recvparams = 0; sp->subaddress = NULL; - TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_CLASSF); if (tif->tif_mode == O_RDONLY) { tif->tif_flags |= TIFF_NOBITREV;/* decoder does bit reversal */ DecoderState(tif)->runs = NULL; @@ -1336,6 +1331,20 @@ TIFFInitCCITTFax3(TIFF* tif, int scheme) return (1); } +int +TIFFInitCCITTFax3(TIFF* tif, int scheme) +{ + if (InitCCITTFax3(tif)) { + _TIFFMergeFieldInfo(tif, fax3FieldInfo, N(fax3FieldInfo)); + + /* + * The default format is Class/F-style w/o RTC. + */ + return TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_CLASSF); + } else + return (0); +} + /* * CCITT Group 4 (T.6) Facsimile-compatible * Compression Scheme Support. @@ -1419,7 +1428,9 @@ Fax4PostEncode(TIFF* tif) int TIFFInitCCITTFax4(TIFF* tif, int scheme) { - if (TIFFInitCCITTFax3(tif, scheme)) { /* reuse G3 logic */ + if (InitCCITTFax3(tif)) { /* reuse G3 support */ + _TIFFMergeFieldInfo(tif, fax4FieldInfo, N(fax4FieldInfo)); + tif->tif_decoderow = Fax4Decode; tif->tif_decodestrip = Fax4Decode; tif->tif_decodetile = Fax4Decode; @@ -1492,7 +1503,7 @@ Fax3DecodeRLE(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) int TIFFInitCCITTRLE(TIFF* tif, int scheme) { - if (TIFFInitCCITTFax3(tif, scheme)) { /* reuse G3 compression */ + if (InitCCITTFax3(tif)) { /* reuse G3 support */ tif->tif_decoderow = Fax3DecodeRLE; tif->tif_decodestrip = Fax3DecodeRLE; tif->tif_decodetile = Fax3DecodeRLE; @@ -1508,7 +1519,7 @@ TIFFInitCCITTRLE(TIFF* tif, int scheme) int TIFFInitCCITTRLEW(TIFF* tif, int scheme) { - if (TIFFInitCCITTFax3(tif, scheme)) { /* reuse G3 compression */ + if (InitCCITTFax3(tif)) { /* reuse G3 support */ tif->tif_decoderow = Fax3DecodeRLE; tif->tif_decodestrip = Fax3DecodeRLE; tif->tif_decodetile = Fax3DecodeRLE; diff --git a/libtiff/tif_fax3.h b/libtiff/tif_fax3.h index d4ed4a21..224d5e2c 100644 --- a/libtiff/tif_fax3.h +++ b/libtiff/tif_fax3.h @@ -1,4 +1,4 @@ -/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_fax3.h,v 1.27 1996/01/10 19:33:22 sam Exp $ */ +/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_fax3.h,v 1.29 1996/02/09 22:51:07 sam Exp $ */ /* * Copyright (c) 1990-1996 Sam Leffler @@ -122,25 +122,49 @@ extern const TIFFFaxTabEnt TIFFFaxBlackTable[]; * data. In any event, we don't prescan and must watch for * running out of data since we can't permit the library to * scan past the end of the input data buffer. + * + * Finally, note that we must handle remaindered data at the end + * of a strip specially. The coder asks for a fixed number of + * bits when scanning for the next code. This may be more bits + * than are actually present in the data stream. If we appear + * to run out of data but still have some number of valid bits + * remaining then we makeup the requested amount with zeros and + * return successfully. If the returned data is incorrect then + * we should be called again and get a premature EOF error; + * otherwise we should get the right answer. */ #ifndef NeedBits8 #define NeedBits8(n,eoflab) do { \ if (BitsAvail < (n)) { \ - if (EndOfData()) goto eoflab; \ - BitAcc |= bitmap[*cp++]<<BitsAvail; \ - BitsAvail += 8; \ + if (EndOfData()) { \ + if (BitsAvail == 0) /* no valid bits */ \ + goto eoflab; \ + BitsAvail = (n); /* pad with zeros */ \ + } else { \ + BitAcc |= bitmap[*cp++]<<BitsAvail; \ + BitsAvail += 8; \ + } \ } \ } while (0) #endif #ifndef NeedBits16 #define NeedBits16(n,eoflab) do { \ if (BitsAvail < (n)) { \ - if (EndOfData()) goto eoflab; \ - BitAcc |= bitmap[*cp++]<<BitsAvail; \ - if ((BitsAvail += 8) < (n)) { \ - if (EndOfData()) goto eoflab; \ + if (EndOfData()) { \ + if (BitsAvail == 0) /* no valid bits */ \ + goto eoflab; \ + BitsAvail = (n); /* pad with zeros */ \ + } else { \ BitAcc |= bitmap[*cp++]<<BitsAvail; \ - BitsAvail += 8; \ + if ((BitsAvail += 8) < (n)) { \ + if (EndOfData()) { \ + /* NB: we know BitsAvail is non-zero here */ \ + BitsAvail = (n); /* pad with zeros */ \ + } else { \ + BitAcc |= bitmap[*cp++]<<BitsAvail; \ + BitsAvail += 8; \ + } \ + } \ } \ } \ } while (0) diff --git a/libtiff/tiffcomp.h b/libtiff/tiffcomp.h index bbdd9b20..c208c9ac 100644 --- a/libtiff/tiffcomp.h +++ b/libtiff/tiffcomp.h @@ -1,4 +1,4 @@ -/* $Header: /usr/people/sam/tiff/libtiff/RCS/tiffcomp.h,v 1.47 1996/01/10 19:33:24 sam Exp $ */ +/* $Header: /usr/people/sam/tiff/libtiff/RCS/tiffcomp.h,v 1.48 1996/02/06 23:50:58 sam Exp $ */ /* * Copyright (c) 1990-1996 Sam Leffler @@ -60,7 +60,7 @@ #if defined(__PPCC__) || defined(__SC__) || defined(__MRC__) #include <types.h> -#elif !defined(__MWERKS__) && !defined(THINK_C) && !defined(__acornriscos) +#elif !defined(__MWERKS__) && !defined(THINK_C) && !defined(__acornriscos) && !defined(applec) #include <sys/types.h> #endif |