Pre-release checkin
This commit is contained in:
parent
a02f97a5d4
commit
177452c8c9
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
2000-12-19 Mike Welles <mike@bangsate.com> *** 3.5.6 release ***
|
||||
|
||||
* Took out LZW Encoding from tif_lzw.c
|
||||
|
||||
* Created HOWTO-RELEASE
|
||||
|
||||
* Created html/v3.5.6.html
|
||||
|
||||
* updated index.html
|
||||
|
||||
2000-12-01 Frank Warmerdam <warmerdam@pobox.com>
|
||||
|
||||
* Added patches for EOFB support in tif_fax3.c and tif_fax3.h.
|
||||
|
74
HOWTO-RELEASE
Normal file
74
HOWTO-RELEASE
Normal file
@ -0,0 +1,74 @@
|
||||
HOWTO-RELEASE:
|
||||
Notes on releasing. <mike@bangstate.com>
|
||||
|
||||
1.
|
||||
|
||||
Commit any unsaved changes.
|
||||
|
||||
2.
|
||||
|
||||
"make clean"
|
||||
|
||||
3.
|
||||
|
||||
Create html/vX.X.html. Take ChangeLog entries and html-ify in
|
||||
there. Easist thing to do is take html/vX.(X-1).html and use
|
||||
it as a template.
|
||||
|
||||
4.
|
||||
|
||||
Add any new files that have been created that should be part
|
||||
of the distrubituion (like the html file in step 2), to
|
||||
TIFFFILES in Makefile.in
|
||||
|
||||
5.
|
||||
|
||||
Make sure tif_dir.c in lzw-compression-kit is in sync with the
|
||||
main tree.
|
||||
|
||||
6.
|
||||
|
||||
Increment version in file "VERSION"
|
||||
|
||||
|
||||
7.
|
||||
|
||||
sh configure; make; make install (to test).
|
||||
|
||||
|
||||
8.
|
||||
|
||||
make release.
|
||||
|
||||
9.
|
||||
|
||||
make distclean
|
||||
|
||||
10.
|
||||
|
||||
cvs commit
|
||||
|
||||
11.
|
||||
|
||||
ftp ftp.onshore.com;
|
||||
cd /home/ftp/pub/libtiff
|
||||
put ../tiff-vn-n-n.zip .
|
||||
put ../tiff-vn-n-n.tar.gz .
|
||||
|
||||
12
|
||||
|
||||
ftp ftp.libtiff.org
|
||||
lcd html
|
||||
mput *.html
|
||||
put ../tiff-vn-n-n.zip .
|
||||
put ../tiff-vn-n-n.tar.gz .
|
||||
|
||||
13.
|
||||
|
||||
Announce to list, tiff@olympiakos.com
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1 +1 @@
|
||||
04/12/2000
|
||||
12/19/2000
|
||||
|
2
dist/tiff.version
vendored
2
dist/tiff.version
vendored
@ -1 +1 @@
|
||||
define TIFF_VNUM "3.5.5 (release)"
|
||||
define TIFF_VNUM "3.5.6 (release)"
|
||||
|
@ -14,11 +14,11 @@ TIFF Software
|
||||
<B>Home Page</B>: <A HREF="http://www.libtiff.org/">
|
||||
http://www.libtiff.org</A> <BR>
|
||||
<B>FAQ Page</B>: <I>forthcoming</I><BR>
|
||||
<B>Latest Release</B>: <A HREF="v3.5.5.html">v3.5.5</A><BR>
|
||||
<B>Latest Software</B>: <A HREF="v3.5.5.html">v3.5.5</A><BR>
|
||||
<B>Latest Release</B>: <A HREF="v3.5.6.html">v3.5.6</A><BR>
|
||||
<B>Latest Software</B>: <A HREF="v3.5.6.html">v3.5.6</A><BR>
|
||||
<B>Master FTP Site</B>: <A HREF="ftp://ftp.onshore.com/pub/libtiff">ftp.onshore.com</A> , directory pub/libtiff (Active mode FTP only!)<BR>
|
||||
<B>HTTP Download</B>: <A HREF=http://www.libtiff.org/tiff-v3.5.5.tar.gz>http://www.libtiff.org/tiff-v3.5.5.tar.gz</a>, <A HREF=http://www.libtiff.org/tiff-v3.5.5.zip>http://www.libtiff.org/tiff-v3.5.5.zip</a><BR>
|
||||
<B>LZW Compression Kit:</B> <A HREF="libtiff-lzw-compression-kit-1.1.tar.gz">libtiff-lzw-compression-kit-1.1.tar.gz</A><BR>
|
||||
<B>HTTP Download</B>: <A HREF=http://www.libtiff.org/tiff-v3.5.6.tar.gz>http://www.libtiff.org/tiff-v3.5.6.tar.gz</a>, <A HREF=http://www.libtiff.org/tiff-v3.5.6.zip>http://www.libtiff.org/tiff-v3.5.6.zip</a><BR>
|
||||
<B>LZW Compression Kit:</B> <A HREF="libtiff-lzw-compression-kit-1.2.tar.gz">libtiff-lzw-compression-kit-1.1.tar.gz</A><BR>
|
||||
<B>Mailing List</B>: <a href=mailto:tiff@olympiakos.com>tiff@olympiakos.com</a> <BR>
|
||||
<B>Mailing List Subscription</b>: <a href=mailto:tiff-request@olympiakos.com>tiff-request@olympiakos.com</a> ("subscribe tiff" in body of message). <BR>
|
||||
<B>Mailing List Archive</b>: <A HREF= http://www.remotesensing.org/lists/libtiff_archive/maillist.html>http://www.remotesensing.org/lists/libtiff_archive/maillist.html</A> <BR>
|
||||
@ -84,7 +84,7 @@ The following sections are included in this documentation:
|
||||
<P>
|
||||
<HR>
|
||||
<em>
|
||||
$Id: index.html,v 1.28 2000-07-13 14:58:16 mwelles Exp $
|
||||
$Id: index.html,v 1.29 2000-12-19 20:12:53 mwelles Exp $
|
||||
</em>
|
||||
|
||||
</BODY>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>
|
||||
Changes in TIFF v3.5.4
|
||||
Changes in TIFF v3.5.5
|
||||
</TITLE>
|
||||
</HEAD>
|
||||
|
||||
@ -149,7 +149,7 @@ The following information is located here:
|
||||
|
||||
<HR>
|
||||
|
||||
Last updated $Date: 2000-03-29 04:35:28 $.
|
||||
Last updated $Date: 2000-12-19 20:12:53 $.
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
180
html/v3.5.6.html
Normal file
180
html/v3.5.6.html
Normal file
@ -0,0 +1,180 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>
|
||||
Changes in TIFF v3.5.6
|
||||
</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<BODY BGCOLOR=white>
|
||||
<FONT FACE="Helvetica, Arial, Sans">
|
||||
<FONT FACE="Helvetica, Arial, Sans">
|
||||
|
||||
<BASEFONT SIZE=4>
|
||||
<B><FONT SIZE=+3>T</FONT>IFF <FONT SIZE=+2>C</FONT>HANGE <FONT SIZE=+2>I</FONT>NFORMATION</B>
|
||||
<BASEFONT SIZE=3>
|
||||
|
||||
<UL>
|
||||
<HR SIZE=4 WIDTH=65% ALIGN=left>
|
||||
<B>Current Version</B>: v3.5.6<BR>
|
||||
<B>Previous Version</B>: <A HREF=v3.5.5.html>v3.5.5</a><BR>
|
||||
<B>Master FTP Site</B>: <A HREF="ftp://ftp.onshore.com/pub/libtiff">ftp.onshore.com</a>, directory pub/libtiff</A><BR>
|
||||
<B>Master HTTP Site</B>: <A HREF="http://www.libtiff.org/">http://www.libtiff.org</a>
|
||||
<HR SIZE=4 WIDTH=65% ALIGN=left>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
This document describes the changes made to the software between the
|
||||
<I>previous</I> and <I>current</I> versions (see above).
|
||||
If you don't find something listed here, then it was not done in this
|
||||
timeframe, or it was not considered important enough to be mentioned.
|
||||
The following information is located here:
|
||||
<UL>
|
||||
<LI><A HREF="#configure">Changes in the software configuration</A>
|
||||
<LI><A HREF="#libtiff">Changes in libtiff</A>
|
||||
<LI><A HREF="#tools">Changes in the tools</A>
|
||||
<LI><A HREF="#lzwkit">Changes in the LZW compression kit</A>
|
||||
</UL>
|
||||
<p>
|
||||
<P><HR WIDTH=65% ALIGN=left>
|
||||
|
||||
<A NAME="configure"><B><FONT SIZE=+3>C</FONT>HANGES IN THE SOFTWARE CONFIGURATION:</B></A>
|
||||
|
||||
<UL>
|
||||
|
||||
<LI> Added GNULDdso target an`d switched linux and freebsd to use it.
|
||||
<LI> tools/Makefile.in: Modified to install properly on SGI.
|
||||
<LI> configure: Fixed stupid mistake in libc6 test on Linux
|
||||
</UL>
|
||||
|
||||
<P><HR WIDTH=65% ALIGN=left>
|
||||
|
||||
<A NAME="libtiff"><B><FONT SIZE=+3>C</FONT>HANGES IN LIBTIFF:</B></A>
|
||||
|
||||
|
||||
<UL>
|
||||
|
||||
<LI> tools/rgb2ycbcr.c: fixed output strip size to account for vertical
|
||||
roundup if rows_per_strip not a multiple of vertical sample size.
|
||||
|
||||
<LI> tif_dir.c: Clear TIFF_ISTILED flag in TIFFDefaultDirectory
|
||||
as per http://bugzilla.remotesensing.org/show_bug.cgi?id=18
|
||||
from vandrove@vc.cvut.cz.
|
||||
|
||||
<LI> Modified tif_packbits.c decoding to avoid overrunning the
|
||||
output buffer, and to issue a warning if data needs to be
|
||||
discarded. See http://bugzilla.remotesensing.org/show_bug.cgi?id=18
|
||||
|
||||
<LI> Modified TIFFClientOpen() to emit an error on an attempt to
|
||||
open a comperessed file for update (O_RDWR/r+) access. This is
|
||||
because the compressor/decompressor code gets very confused when
|
||||
the mode is O_RDWR, assuming this means writing only. See
|
||||
bug http://bugzilla.remotesensing.org/show_bug.cgi?id=13
|
||||
|
||||
<LI> Applied patch for 0x0000 sequences in tif_fax3.h's definition
|
||||
of EXPAND1D() as per bug 11 (from Roman).
|
||||
|
||||
<LI> Fixed tiffcomp.h to avoid win32 stuff if unix #defined, to improve
|
||||
cygwin compatibility.
|
||||
|
||||
<LI> Applied patch from Roman Shpount to tif_fax3.c. This seems to
|
||||
be a proper fix to the buffer sizing problem. See
|
||||
http://bugzilla.remotesensing.org/show_bug.cgi?id=11
|
||||
|
||||
<LI> Fixed tif_getimage.c to fix overrun bug with YCbCr images without
|
||||
downsampling. http://bugzilla.remotesensing.org/show_bug.cgi?id=10
|
||||
Thanks to Nick Lamb <njl98r@ecs.soton.ac.uk> for reporting the
|
||||
bug and proving the patch.
|
||||
|
||||
<LI> Fixed tif_jpeg.c so avoid destroying the decompressor before
|
||||
we are done access data thanks to bug report from:
|
||||
Michael Eckstein <eckstein@gepro.cz>.
|
||||
|
||||
<LI> tif_flush.c: Changed so that TIFFFlushData() doesn't return an
|
||||
error when TIFF_BEENWRITING is not set. This ensures that the
|
||||
directory contents can still be flushed by TIFFFlush().
|
||||
|
||||
<LI> Reverted tif_flush change.
|
||||
|
||||
<LI> tif_open.c: Don't set MMAP for O_RDWR files.
|
||||
|
||||
<LI> tif_open.c: Set STRIPCHOP_DEFAULT for O_RDWR as well as O_RDONLY
|
||||
so that files opened for update can be strip chopped too.
|
||||
|
||||
<LI> tif_read.c: fixed up bug with files missing rowsperstrip and
|
||||
the strips per separation fix done a few weeks ago.
|
||||
|
||||
<LI> Tentatively added support for SAMPLEFORMAT_COMPLEXIEEEFP, and
|
||||
SAMPLEFORMAT_COMPLEXINT.
|
||||
|
||||
<LI> index.html, bugs.html: added bugzilla info.
|
||||
|
||||
<LI> tif_read.c: fix subtle bug with determining the number of
|
||||
rows for strips that are the last strip in a separation but
|
||||
not the last strip of all in TIFFReadEncodedStrip().
|
||||
|
||||
<LI> Applied 16/32 bit fix to tif_fax3.c. Fix supplied by
|
||||
Peter Skarpetis <peters@serendipity-software.com.au>
|
||||
|
||||
<LI> Modified tiffio.h logic with regard to including windows.h. It
|
||||
won't include it when building with __CYGWIN__.
|
||||
|
||||
<LI> README: update to mention www.libtiff.org, don't list Sam's old
|
||||
email address.
|
||||
|
||||
<LI> configure: Fixed DSO test for Linux as per patch from
|
||||
Jan Van Buggenhout <chipzz@Ace.ULYSSIS.Student.KULeuven.Ac.Be>.
|
||||
|
||||
<LI> libtiff/tif_dirread.c: Don't use estimate strip byte count for
|
||||
one tile/strip images with an offset, and byte count of zero. These
|
||||
could be "unpopulated" images.
|
||||
|
||||
<LI> contrib/addtiffo: Added "averaging" resampling option.
|
||||
|
||||
<LI> tools/tiffsplit.c: Copy TIFFTAG_SAMPLEFORMAT.
|
||||
|
||||
<LI> tif_win32.c: Applied patch to fix overreads and ovverwrites
|
||||
caught by BoundsChecker. From Arvan Pritchard
|
||||
<arvan.pritchard@infomatix.co.uk> (untested).
|
||||
|
||||
<LI> tif_getimage.c: Applied patch to silence VC6 warnings. From
|
||||
Arvan Pritchard <arvan.pritchard@informatix.co.uk>
|
||||
|
||||
<LI> tif_lzw.c: Applied patch to silence VC6 warnings. From
|
||||
Arvan Pritchard <arvan.pritchard@informatix.co.uk>
|
||||
|
||||
|
||||
|
||||
</UL>
|
||||
|
||||
<P><HR WIDTH=65% ALIGN=left>
|
||||
|
||||
<A NAME="tools"><B><FONT SIZE=+3>C</FONT>HANGES IN THE TOOLS:</B></A>
|
||||
|
||||
<UL>
|
||||
|
||||
<LI> Modified tiff2bw to ensure portions add to 100%, and that
|
||||
white is properly recovered. See bug
|
||||
http://bugzilla.remotesensing.org/show_bug.cgi?id=15 Patch
|
||||
c/o Stanislav Brabec <utx@penguin.cz>
|
||||
|
||||
<LI> Added contrib/stream (stream io) code submitted by Avi Bleiweiss.
|
||||
|
||||
</UL>
|
||||
|
||||
<P><HR WIDTH=65% ALIGN=left>
|
||||
|
||||
<A NAME="lzwkit"><B><FONT SIZE=+3>C</FONT>HANGES IN THE LZW COMPRESSION KIT</B></A>
|
||||
<UL>
|
||||
|
||||
<LI> updated tif_dir.c to reflect changes to no-lzw tif_dir.c
|
||||
|
||||
</UL>
|
||||
|
||||
<A HREF="index.html"><IMG SRC="images/back.gif"></A> TIFF home page.<BR>
|
||||
|
||||
<HR>
|
||||
|
||||
Last updated $Date: 2000-12-19 20:12:53 $.
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
@ -1,4 +1,4 @@
|
||||
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_lzw.c,v 1.6 2000-04-04 14:43:35 mwelles Exp $ */
|
||||
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_lzw.c,v 1.7 2000-12-19 20:12:53 mwelles Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@ -636,299 +636,7 @@ LZWDecodeCompat(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s)
|
||||
}
|
||||
#endif /* LZW_COMPAT */
|
||||
|
||||
/*
|
||||
* LZW Encoding.
|
||||
*/
|
||||
|
||||
static int
|
||||
LZWSetupEncode(TIFF* tif)
|
||||
{
|
||||
LZWEncodeState* sp = EncoderState(tif);
|
||||
static const char module[] = "LZWSetupEncode";
|
||||
|
||||
assert(sp != NULL);
|
||||
sp->enc_hashtab = (hash_t*) _TIFFmalloc(HSIZE*sizeof (hash_t));
|
||||
if (sp->enc_hashtab == NULL) {
|
||||
TIFFError(module, "No space for LZW hash table");
|
||||
return (0);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset encoding state at the start of a strip.
|
||||
*/
|
||||
static int
|
||||
LZWPreEncode(TIFF* tif, tsample_t s)
|
||||
{
|
||||
LZWEncodeState *sp = EncoderState(tif);
|
||||
|
||||
(void) s;
|
||||
assert(sp != NULL);
|
||||
sp->lzw_nbits = BITS_MIN;
|
||||
sp->lzw_maxcode = MAXCODE(BITS_MIN);
|
||||
sp->lzw_free_ent = CODE_FIRST;
|
||||
sp->lzw_nextbits = 0;
|
||||
sp->lzw_nextdata = 0;
|
||||
sp->enc_checkpoint = CHECK_GAP;
|
||||
sp->enc_ratio = 0;
|
||||
sp->enc_incount = 0;
|
||||
sp->enc_outcount = 0;
|
||||
/*
|
||||
* The 4 here insures there is space for 2 max-sized
|
||||
* codes in LZWEncode and LZWPostDecode.
|
||||
*/
|
||||
sp->enc_rawlimit = tif->tif_rawdata + tif->tif_rawdatasize-1 - 4;
|
||||
cl_hash(sp); /* clear hash table */
|
||||
sp->enc_oldcode = (hcode_t) -1; /* generates CODE_CLEAR in LZWEncode */
|
||||
return (1);
|
||||
}
|
||||
|
||||
#define CALCRATIO(sp, rat) { \
|
||||
if (incount > 0x007fffff) { /* NB: shift will overflow */\
|
||||
rat = outcount >> 8; \
|
||||
rat = (rat == 0 ? 0x7fffffff : incount/rat); \
|
||||
} else \
|
||||
rat = (incount<<8) / outcount; \
|
||||
}
|
||||
#define PutNextCode(op, c) { \
|
||||
nextdata = (nextdata << nbits) | c; \
|
||||
nextbits += nbits; \
|
||||
*op++ = (u_char)(nextdata >> (nextbits-8)); \
|
||||
nextbits -= 8; \
|
||||
if (nextbits >= 8) { \
|
||||
*op++ = (u_char)(nextdata >> (nextbits-8)); \
|
||||
nextbits -= 8; \
|
||||
} \
|
||||
outcount += nbits; \
|
||||
}
|
||||
|
||||
/*
|
||||
* Encode a chunk of pixels.
|
||||
*
|
||||
* Uses an open addressing double hashing (no chaining) on the
|
||||
* prefix code/next character combination. We do a variant of
|
||||
* Knuth's algorithm D (vol. 3, sec. 6.4) along with G. Knott's
|
||||
* relatively-prime secondary probe. Here, the modular division
|
||||
* first probe is gives way to a faster exclusive-or manipulation.
|
||||
* Also do block compression with an adaptive reset, whereby the
|
||||
* code table is cleared when the compression ratio decreases,
|
||||
* but after the table fills. The variable-length output codes
|
||||
* are re-sized at this point, and a CODE_CLEAR is generated
|
||||
* for the decoder.
|
||||
*/
|
||||
static int
|
||||
LZWEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
|
||||
{
|
||||
register LZWEncodeState *sp = EncoderState(tif);
|
||||
register long fcode;
|
||||
register hash_t *hp;
|
||||
register int h, c;
|
||||
hcode_t ent;
|
||||
long disp;
|
||||
long incount, outcount, checkpoint;
|
||||
long nextdata, nextbits;
|
||||
int free_ent, maxcode, nbits;
|
||||
tidata_t op, limit;
|
||||
|
||||
(void) s;
|
||||
if (sp == NULL)
|
||||
return (0);
|
||||
/*
|
||||
* Load local state.
|
||||
*/
|
||||
incount = sp->enc_incount;
|
||||
outcount = sp->enc_outcount;
|
||||
checkpoint = sp->enc_checkpoint;
|
||||
nextdata = sp->lzw_nextdata;
|
||||
nextbits = sp->lzw_nextbits;
|
||||
free_ent = sp->lzw_free_ent;
|
||||
maxcode = sp->lzw_maxcode;
|
||||
nbits = sp->lzw_nbits;
|
||||
op = tif->tif_rawcp;
|
||||
limit = sp->enc_rawlimit;
|
||||
ent = sp->enc_oldcode;
|
||||
|
||||
if (ent == (hcode_t) -1 && cc > 0) {
|
||||
/*
|
||||
* NB: This is safe because it can only happen
|
||||
* at the start of a strip where we know there
|
||||
* is space in the data buffer.
|
||||
*/
|
||||
PutNextCode(op, CODE_CLEAR);
|
||||
ent = *bp++; cc--; incount++;
|
||||
}
|
||||
while (cc > 0) {
|
||||
c = *bp++; cc--; incount++;
|
||||
fcode = ((long)c << BITS_MAX) + ent;
|
||||
h = (c << HSHIFT) ^ ent; /* xor hashing */
|
||||
#ifdef _WINDOWS
|
||||
/*
|
||||
* Check hash index for an overflow.
|
||||
*/
|
||||
if (h >= HSIZE)
|
||||
h -= HSIZE;
|
||||
#endif
|
||||
hp = &sp->enc_hashtab[h];
|
||||
if (hp->hash == fcode) {
|
||||
ent = hp->code;
|
||||
continue;
|
||||
}
|
||||
if (hp->hash >= 0) {
|
||||
/*
|
||||
* Primary hash failed, check secondary hash.
|
||||
*/
|
||||
disp = HSIZE - h;
|
||||
if (h == 0)
|
||||
disp = 1;
|
||||
do {
|
||||
/*
|
||||
* Avoid pointer arithmetic 'cuz of
|
||||
* wraparound problems with segments.
|
||||
*/
|
||||
if ((h -= disp) < 0)
|
||||
h += HSIZE;
|
||||
hp = &sp->enc_hashtab[h];
|
||||
if (hp->hash == fcode) {
|
||||
ent = hp->code;
|
||||
goto hit;
|
||||
}
|
||||
} while (hp->hash >= 0);
|
||||
}
|
||||
/*
|
||||
* New entry, emit code and add to table.
|
||||
*/
|
||||
/*
|
||||
* Verify there is space in the buffer for the code
|
||||
* and any potential Clear code that might be emitted
|
||||
* below. The value of limit is setup so that there
|
||||
* are at least 4 bytes free--room for 2 codes.
|
||||
*/
|
||||
if (op > limit) {
|
||||
tif->tif_rawcc = (tsize_t)(op - tif->tif_rawdata);
|
||||
TIFFFlushData1(tif);
|
||||
op = tif->tif_rawdata;
|
||||
}
|
||||
PutNextCode(op, ent);
|
||||
ent = c;
|
||||
hp->code = free_ent++;
|
||||
hp->hash = fcode;
|
||||
if (free_ent == CODE_MAX-1) {
|
||||
/* table is full, emit clear code and reset */
|
||||
cl_hash(sp);
|
||||
sp->enc_ratio = 0;
|
||||
incount = 0;
|
||||
outcount = 0;
|
||||
free_ent = CODE_FIRST;
|
||||
PutNextCode(op, CODE_CLEAR);
|
||||
nbits = BITS_MIN;
|
||||
maxcode = MAXCODE(BITS_MIN);
|
||||
} else {
|
||||
/*
|
||||
* If the next entry is going to be too big for
|
||||
* the code size, then increase it, if possible.
|
||||
*/
|
||||
if (free_ent > maxcode) {
|
||||
nbits++;
|
||||
assert(nbits <= BITS_MAX);
|
||||
maxcode = (int) MAXCODE(nbits);
|
||||
} else if (incount >= checkpoint) {
|
||||
long rat;
|
||||
/*
|
||||
* Check compression ratio and, if things seem
|
||||
* to be slipping, clear the hash table and
|
||||
* reset state. The compression ratio is a
|
||||
* 24+8-bit fractional number.
|
||||
*/
|
||||
checkpoint = incount+CHECK_GAP;
|
||||
CALCRATIO(sp, rat);
|
||||
if (rat <= sp->enc_ratio) {
|
||||
cl_hash(sp);
|
||||
sp->enc_ratio = 0;
|
||||
incount = 0;
|
||||
outcount = 0;
|
||||
free_ent = CODE_FIRST;
|
||||
PutNextCode(op, CODE_CLEAR);
|
||||
nbits = BITS_MIN;
|
||||
maxcode = MAXCODE(BITS_MIN);
|
||||
} else
|
||||
sp->enc_ratio = rat;
|
||||
}
|
||||
}
|
||||
hit:
|
||||
;
|
||||
}
|
||||
|
||||
/*
|
||||
* Restore global state.
|
||||
*/
|
||||
sp->enc_incount = incount;
|
||||
sp->enc_outcount = outcount;
|
||||
sp->enc_checkpoint = checkpoint;
|
||||
sp->enc_oldcode = ent;
|
||||
sp->lzw_nextdata = nextdata;
|
||||
sp->lzw_nextbits = nextbits;
|
||||
sp->lzw_free_ent = free_ent;
|
||||
sp->lzw_maxcode = maxcode;
|
||||
sp->lzw_nbits = nbits;
|
||||
tif->tif_rawcp = op;
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Finish off an encoded strip by flushing the last
|
||||
* string and tacking on an End Of Information code.
|
||||
*/
|
||||
static int
|
||||
LZWPostEncode(TIFF* tif)
|
||||
{
|
||||
register LZWEncodeState *sp = EncoderState(tif);
|
||||
tidata_t op = tif->tif_rawcp;
|
||||
long nextbits = sp->lzw_nextbits;
|
||||
long nextdata = sp->lzw_nextdata;
|
||||
long outcount = sp->enc_outcount;
|
||||
int nbits = sp->lzw_nbits;
|
||||
|
||||
if (op > sp->enc_rawlimit) {
|
||||
tif->tif_rawcc = (tsize_t)(op - tif->tif_rawdata);
|
||||
TIFFFlushData1(tif);
|
||||
op = tif->tif_rawdata;
|
||||
}
|
||||
if (sp->enc_oldcode != (hcode_t) -1) {
|
||||
PutNextCode(op, sp->enc_oldcode);
|
||||
sp->enc_oldcode = (hcode_t) -1;
|
||||
}
|
||||
PutNextCode(op, CODE_EOI);
|
||||
if (nextbits > 0)
|
||||
*op++ = (u_char)(nextdata << (8-nextbits));
|
||||
tif->tif_rawcc = (tsize_t)(op - tif->tif_rawdata);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset encoding hash table.
|
||||
*/
|
||||
static void
|
||||
cl_hash(LZWEncodeState* sp)
|
||||
{
|
||||
register hash_t *hp = &sp->enc_hashtab[HSIZE-1];
|
||||
register long i = HSIZE-8;
|
||||
|
||||
do {
|
||||
i -= 8;
|
||||
hp[-7].hash = -1;
|
||||
hp[-6].hash = -1;
|
||||
hp[-5].hash = -1;
|
||||
hp[-4].hash = -1;
|
||||
hp[-3].hash = -1;
|
||||
hp[-2].hash = -1;
|
||||
hp[-1].hash = -1;
|
||||
hp[ 0].hash = -1;
|
||||
hp -= 8;
|
||||
} while (i >= 0);
|
||||
for (i += 8; i > 0; i--, hp--)
|
||||
hp->hash = -1;
|
||||
}
|
||||
|
||||
static void
|
||||
LZWCleanup(TIFF* tif)
|
||||
@ -937,9 +645,6 @@ LZWCleanup(TIFF* tif)
|
||||
if (tif->tif_mode == O_RDONLY) {
|
||||
if (DecoderState(tif)->dec_codetab)
|
||||
_TIFFfree(DecoderState(tif)->dec_codetab);
|
||||
} else {
|
||||
if (EncoderState(tif)->enc_hashtab)
|
||||
_TIFFfree(EncoderState(tif)->enc_hashtab);
|
||||
}
|
||||
_TIFFfree(tif->tif_data);
|
||||
tif->tif_data = NULL;
|
||||
@ -959,12 +664,8 @@ TIFFInitLZW(TIFF* tif, int scheme)
|
||||
goto bad;
|
||||
DecoderState(tif)->dec_codetab = NULL;
|
||||
DecoderState(tif)->dec_decode = NULL;
|
||||
} else {
|
||||
tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (LZWEncodeState));
|
||||
if (tif->tif_data == NULL)
|
||||
goto bad;
|
||||
EncoderState(tif)->enc_hashtab = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Install codec methods.
|
||||
*/
|
||||
@ -973,12 +674,6 @@ TIFFInitLZW(TIFF* tif, int scheme)
|
||||
tif->tif_decoderow = LZWDecode;
|
||||
tif->tif_decodestrip = LZWDecode;
|
||||
tif->tif_decodetile = LZWDecode;
|
||||
tif->tif_setupencode = LZWSetupEncode;
|
||||
tif->tif_preencode = LZWPreEncode;
|
||||
tif->tif_postencode = LZWPostEncode;
|
||||
tif->tif_encoderow = LZWEncode;
|
||||
tif->tif_encodestrip = LZWEncode;
|
||||
tif->tif_encodetile = LZWEncode;
|
||||
tif->tif_cleanup = LZWCleanup;
|
||||
/*
|
||||
* Setup predictor setup.
|
||||
|
Loading…
Reference in New Issue
Block a user