diff options
author | Andrey Kiselev <dron@ak4719.spb.edu> | 2004-09-26 09:49:53 +0000 |
---|---|---|
committer | Andrey Kiselev <dron@ak4719.spb.edu> | 2004-09-26 09:49:53 +0000 |
commit | 4a880ff13af2100fd6f4b57db9711a64b6f7cadf (patch) | |
tree | c2384c1e88f78ed4a9883ef9c1d4add949353009 /libtiff/tif_write.c | |
parent | cb0a22a9889a23756caf0678dbb322d4f2ff022b (diff) | |
download | libtiff-git-4a880ff13af2100fd6f4b57db9711a64b6f7cadf.tar.gz |
Optimize checking for the strip bounds.
Diffstat (limited to 'libtiff/tif_write.c')
-rw-r--r-- | libtiff/tif_write.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/libtiff/tif_write.c b/libtiff/tif_write.c index e08ab867..c8ffdf25 100644 --- a/libtiff/tif_write.c +++ b/libtiff/tif_write.c @@ -1,4 +1,4 @@ -/* $Id: tif_write.c,v 1.13 2004-09-25 11:07:11 dron Exp $ */ +/* $Id: tif_write.c,v 1.14 2004-09-26 09:49:53 dron Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -621,7 +621,7 @@ TIFFAppendToStrip(TIFF* tif, tstrip_t strip, tidata_t data, tsize_t cc) /* * No current offset, set the current strip. */ - if (td->td_stripoffset[strip] != 0) { + if (td->td_nstrips || td->td_stripoffset[strip] != 0) { /* * Prevent overlapping of the data chunks. We need * this to enable in place updating of the compressed @@ -629,22 +629,34 @@ TIFFAppendToStrip(TIFF* tif, tstrip_t strip, tidata_t data, tsize_t cc) * the file without any optimization of the spare * space, so such scheme is not too much effective. */ - tstrip_t i; - for (i = 0; i < td->td_stripsperimage; i++) { - if (td->td_stripoffset[i] > - td->td_stripoffset[strip] - && td->td_stripoffset[i] < + if (td->td_stripbytecountsorted) { + if (strip == td->td_nstrips - 1 + || td->td_stripoffset[strip + 1] < td->td_stripoffset[strip] + cc) { td->td_stripoffset[strip] = - TIFFSeekFile(tif, (toff_t) 0, + TIFFSeekFile(tif, (toff_t)0, SEEK_END); } + } else { + tstrip_t i; + for (i = 0; i < td->td_nstrips; i++) { + if (td->td_stripoffset[i] > + td->td_stripoffset[strip] + && td->td_stripoffset[i] < + td->td_stripoffset[strip] + cc) { + td->td_stripoffset[strip] = + TIFFSeekFile(tif, + (toff_t)0, + SEEK_END); + } + } } if (!SeekOK(tif, td->td_stripoffset[strip])) { TIFFError(module, "%s: Seek error at scanline %lu", - tif->tif_name, (unsigned long)tif->tif_row); + tif->tif_name, + (unsigned long)tif->tif_row); return (0); } } else |