diff options
Diffstat (limited to 'tiff/libtiff/tif_write.c')
-rw-r--r-- | tiff/libtiff/tif_write.c | 110 |
1 files changed, 55 insertions, 55 deletions
diff --git a/tiff/libtiff/tif_write.c b/tiff/libtiff/tif_write.c index 3af69ab4..b5ef21d0 100644 --- a/tiff/libtiff/tif_write.c +++ b/tiff/libtiff/tif_write.c @@ -40,16 +40,16 @@ ((((tif)->tif_flags & TIFF_BUFFERSETUP) && tif->tif_rawdata) || \ TIFFWriteBufferSetup((tif), NULL, (tmsize_t) -1)) -static int TIFFGrowStrips(TIFF* tif, uint32 delta, const char* module); -static int TIFFAppendToStrip(TIFF* tif, uint32 strip, uint8* data, tmsize_t cc); +static int TIFFGrowStrips(TIFF* tif, uint32_t delta, const char* module); +static int TIFFAppendToStrip(TIFF* tif, uint32_t strip, uint8_t* data, tmsize_t cc); int -TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample) +TIFFWriteScanline(TIFF* tif, void* buf, uint32_t row, uint16_t sample) { static const char module[] = "TIFFWriteScanline"; register TIFFDirectory *td; int status, imagegrew = 0; - uint32 strip; + uint32_t strip; if (!WRITECHECKSTRIPS(tif, module)) return (-1); @@ -166,9 +166,9 @@ TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample) } /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode( tif, (uint8*) buf, tif->tif_scanlinesize ); + tif->tif_postdecode(tif, (uint8_t*) buf, tif->tif_scanlinesize ); - status = (*tif->tif_encoderow)(tif, (uint8*) buf, + status = (*tif->tif_encoderow)(tif, (uint8_t*) buf, tif->tif_scanlinesize, sample); /* we are now poised at the beginning of the next row */ @@ -180,14 +180,14 @@ TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample) /* more bytes available in the output buffer than the previous byte count, */ /* so that TIFFAppendToStrip() will detect the overflow when it is called the first */ /* time if the new compressed tile is bigger than the older one. (GDAL #4771) */ -static int _TIFFReserveLargeEnoughWriteBuffer(TIFF* tif, uint32 strip_or_tile) +static int _TIFFReserveLargeEnoughWriteBuffer(TIFF* tif, uint32_t strip_or_tile) { TIFFDirectory *td = &tif->tif_dir; if( td->td_stripbytecount_p[strip_or_tile] > 0 ) { /* The +1 is to ensure at least one extra bytes */ /* The +4 is because the LZW encoder flushes 4 bytes before the limit */ - uint64 safe_buffer_size = (uint64)(td->td_stripbytecount_p[strip_or_tile] + 1 + 4); + uint64_t safe_buffer_size = (uint64_t)(td->td_stripbytecount_p[strip_or_tile] + 1 + 4); if( tif->tif_rawdatasize <= (tmsize_t)safe_buffer_size ) { if( !(TIFFWriteBufferSetup(tif, NULL, @@ -209,11 +209,11 @@ static int _TIFFReserveLargeEnoughWriteBuffer(TIFF* tif, uint32 strip_or_tile) * NB: Image length must be setup before writing. */ tmsize_t -TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc) +TIFFWriteEncodedStrip(TIFF* tif, uint32_t strip, void* data, tmsize_t cc) { static const char module[] = "TIFFWriteEncodedStrip"; TIFFDirectory *td = &tif->tif_dir; - uint16 sample; + uint16_t sample; if (!WRITECHECKSTRIPS(tif, module)) return ((tmsize_t) -1); @@ -273,26 +273,26 @@ TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc) if( td->td_compression == COMPRESSION_NONE ) { /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode( tif, (uint8*) data, cc ); + tif->tif_postdecode(tif, (uint8_t*) data, cc ); if (!isFillOrder(tif, td->td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits((uint8*) data, cc); + TIFFReverseBits((uint8_t*) data, cc); if (cc > 0 && - !TIFFAppendToStrip(tif, strip, (uint8*) data, cc)) + !TIFFAppendToStrip(tif, strip, (uint8_t*) data, cc)) return ((tmsize_t) -1); return (cc); } - sample = (uint16)(strip / td->td_stripsperimage); + sample = (uint16_t)(strip / td->td_stripsperimage); if (!(*tif->tif_preencode)(tif, sample)) return ((tmsize_t) -1); /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode( tif, (uint8*) data, cc ); + tif->tif_postdecode(tif, (uint8_t*) data, cc ); - if (!(*tif->tif_encodestrip)(tif, (uint8*) data, cc, sample)) + if (!(*tif->tif_encodestrip)(tif, (uint8_t*) data, cc, sample)) return ((tmsize_t) -1); if (!(*tif->tif_postencode)(tif)) return ((tmsize_t) -1); @@ -313,7 +313,7 @@ TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc) * NB: Image length must be setup before writing. */ tmsize_t -TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc) +TIFFWriteRawStrip(TIFF* tif, uint32_t strip, void* data, tmsize_t cc) { static const char module[] = "TIFFWriteRawStrip"; TIFFDirectory *td = &tif->tif_dir; @@ -352,7 +352,7 @@ TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc) return ((tmsize_t) -1); } tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; - return (TIFFAppendToStrip(tif, strip, (uint8*) data, cc) ? + return (TIFFAppendToStrip(tif, strip, (uint8_t*) data, cc) ? cc : (tmsize_t) -1); } @@ -361,7 +361,7 @@ TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc) * tile is selected by the (x,y,z,s) coordinates. */ tmsize_t -TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s) +TIFFWriteTile(TIFF* tif, void* buf, uint32_t x, uint32_t y, uint32_t z, uint16_t s) { if (!TIFFCheckTile(tif, x, y, z, s)) return ((tmsize_t)(-1)); @@ -388,12 +388,12 @@ TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s) * the image on each write (as TIFFWriteScanline does). */ tmsize_t -TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc) +TIFFWriteEncodedTile(TIFF* tif, uint32_t tile, void* data, tmsize_t cc) { static const char module[] = "TIFFWriteEncodedTile"; TIFFDirectory *td; - uint16 sample; - uint32 howmany32; + uint16_t sample; + uint32_t howmany32; if (!WRITECHECKTILES(tif, module)) return ((tmsize_t)(-1)); @@ -457,31 +457,31 @@ TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc) if( td->td_compression == COMPRESSION_NONE ) { /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode( tif, (uint8*) data, cc ); + tif->tif_postdecode(tif, (uint8_t*) data, cc ); if (!isFillOrder(tif, td->td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits((uint8*) data, cc); + TIFFReverseBits((uint8_t*) data, cc); if (cc > 0 && - !TIFFAppendToStrip(tif, tile, (uint8*) data, cc)) + !TIFFAppendToStrip(tif, tile, (uint8_t*) data, cc)) return ((tmsize_t) -1); return (cc); } - sample = (uint16)(tile/td->td_stripsperimage); + sample = (uint16_t)(tile / td->td_stripsperimage); if (!(*tif->tif_preencode)(tif, sample)) return ((tmsize_t)(-1)); /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode( tif, (uint8*) data, cc ); + tif->tif_postdecode(tif, (uint8_t*) data, cc ); - if (!(*tif->tif_encodetile)(tif, (uint8*) data, cc, sample)) + if (!(*tif->tif_encodetile)(tif, (uint8_t*) data, cc, sample)) return ((tmsize_t) -1); if (!(*tif->tif_postencode)(tif)) return ((tmsize_t)(-1)); if (!isFillOrder(tif, td->td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits((uint8*)tif->tif_rawdata, tif->tif_rawcc); + TIFFReverseBits((uint8_t*)tif->tif_rawdata, tif->tif_rawcc); if (tif->tif_rawcc > 0 && !TIFFAppendToStrip(tif, tile, tif->tif_rawdata, tif->tif_rawcc)) return ((tmsize_t)(-1)); @@ -500,7 +500,7 @@ TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc) * the image on each write (as TIFFWriteScanline does). */ tmsize_t -TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc) +TIFFWriteRawTile(TIFF* tif, uint32_t tile, void* data, tmsize_t cc) { static const char module[] = "TIFFWriteRawTile"; @@ -512,7 +512,7 @@ TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc) (unsigned long) tif->tif_dir.td_nstrips); return ((tmsize_t)(-1)); } - return (TIFFAppendToStrip(tif, tile, (uint8*) data, cc) ? + return (TIFFAppendToStrip(tif, tile, (uint8_t*) data, cc) ? cc : (tmsize_t)(-1)); } @@ -542,11 +542,11 @@ TIFFSetupStrips(TIFF* tif) } if (td->td_planarconfig == PLANARCONFIG_SEPARATE) td->td_stripsperimage /= td->td_samplesperpixel; - td->td_stripoffset_p = (uint64 *) - _TIFFCheckMalloc(tif, td->td_nstrips, sizeof (uint64), + td->td_stripoffset_p = (uint64_t *) + _TIFFCheckMalloc(tif, td->td_nstrips, sizeof (uint64_t), "for \"StripOffsets\" array"); - td->td_stripbytecount_p = (uint64 *) - _TIFFCheckMalloc(tif, td->td_nstrips, sizeof (uint64), + td->td_stripbytecount_p = (uint64_t *) + _TIFFCheckMalloc(tif, td->td_nstrips, sizeof (uint64_t), "for \"StripByteCounts\" array"); if (td->td_stripoffset_p == NULL || td->td_stripbytecount_p == NULL) return (0); @@ -554,8 +554,8 @@ TIFFSetupStrips(TIFF* tif) * Place data at the end-of-file * (by setting offsets to zero). */ - _TIFFmemset(td->td_stripoffset_p, 0, td->td_nstrips*sizeof (uint64)); - _TIFFmemset(td->td_stripbytecount_p, 0, td->td_nstrips*sizeof (uint64)); + _TIFFmemset(td->td_stripoffset_p, 0, td->td_nstrips*sizeof (uint64_t)); + _TIFFmemset(td->td_stripbytecount_p, 0, td->td_nstrips*sizeof (uint64_t)); TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS); TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS); return (1); @@ -688,7 +688,7 @@ TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size) tif->tif_flags |= TIFF_MYBUFFER; } else tif->tif_flags &= ~TIFF_MYBUFFER; - tif->tif_rawdata = (uint8*) bp; + tif->tif_rawdata = (uint8_t*) bp; tif->tif_rawdatasize = size; tif->tif_rawcc = 0; tif->tif_rawcp = tif->tif_rawdata; @@ -700,17 +700,17 @@ TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size) * Grow the strip data structures by delta strips. */ static int -TIFFGrowStrips(TIFF* tif, uint32 delta, const char* module) +TIFFGrowStrips(TIFF* tif, uint32_t delta, const char* module) { TIFFDirectory *td = &tif->tif_dir; - uint64* new_stripoffset; - uint64* new_stripbytecount; + uint64_t* new_stripoffset; + uint64_t* new_stripbytecount; assert(td->td_planarconfig == PLANARCONFIG_CONTIG); - new_stripoffset = (uint64*)_TIFFrealloc(td->td_stripoffset_p, - (td->td_nstrips + delta) * sizeof (uint64)); - new_stripbytecount = (uint64*)_TIFFrealloc(td->td_stripbytecount_p, - (td->td_nstrips + delta) * sizeof (uint64)); + new_stripoffset = (uint64_t*)_TIFFrealloc(td->td_stripoffset_p, + (td->td_nstrips + delta) * sizeof (uint64_t)); + new_stripbytecount = (uint64_t*)_TIFFrealloc(td->td_stripbytecount_p, + (td->td_nstrips + delta) * sizeof (uint64_t)); if (new_stripoffset == NULL || new_stripbytecount == NULL) { if (new_stripoffset) _TIFFfree(new_stripoffset); @@ -723,9 +723,9 @@ TIFFGrowStrips(TIFF* tif, uint32 delta, const char* module) td->td_stripoffset_p = new_stripoffset; td->td_stripbytecount_p = new_stripbytecount; _TIFFmemset(td->td_stripoffset_p + td->td_nstrips, - 0, delta*sizeof (uint64)); + 0, delta*sizeof (uint64_t)); _TIFFmemset(td->td_stripbytecount_p + td->td_nstrips, - 0, delta*sizeof (uint64)); + 0, delta*sizeof (uint64_t)); td->td_nstrips += delta; tif->tif_flags |= TIFF_DIRTYDIRECT; @@ -736,19 +736,19 @@ TIFFGrowStrips(TIFF* tif, uint32 delta, const char* module) * Append the data to the specified strip. */ static int -TIFFAppendToStrip(TIFF* tif, uint32 strip, uint8* data, tmsize_t cc) +TIFFAppendToStrip(TIFF* tif, uint32_t strip, uint8_t* data, tmsize_t cc) { static const char module[] = "TIFFAppendToStrip"; TIFFDirectory *td = &tif->tif_dir; - uint64 m; - int64 old_byte_count = -1; + uint64_t m; + int64_t old_byte_count = -1; if (td->td_stripoffset_p[strip] == 0 || tif->tif_curoff == 0) { assert(td->td_nstrips > 0); if( td->td_stripbytecount_p[strip] != 0 && td->td_stripoffset_p[strip] != 0 - && td->td_stripbytecount_p[strip] >= (uint64) cc ) + && td->td_stripbytecount_p[strip] >= (uint64_t) cc ) { /* * There is already tile data on disk, and the new tile @@ -785,8 +785,8 @@ TIFFAppendToStrip(TIFF* tif, uint32 strip, uint8* data, tmsize_t cc) m = tif->tif_curoff+cc; if (!(tif->tif_flags&TIFF_BIGTIFF)) - m = (uint32)m; - if ((m<tif->tif_curoff)||(m<(uint64)cc)) + m = (uint32_t)m; + if ((m<tif->tif_curoff)||(m<(uint64_t)cc)) { TIFFErrorExt(tif->tif_clientdata, module, "Maximum TIFF file size exceeded"); return (0); @@ -799,7 +799,7 @@ TIFFAppendToStrip(TIFF* tif, uint32 strip, uint8* data, tmsize_t cc) tif->tif_curoff = m; td->td_stripbytecount_p[strip] += cc; - if( (int64) td->td_stripbytecount_p[strip] != old_byte_count ) + if((int64_t) td->td_stripbytecount_p[strip] != old_byte_count ) tif->tif_flags |= TIFF_DIRTYSTRIP; return (1); @@ -816,7 +816,7 @@ TIFFFlushData1(TIFF* tif) if (tif->tif_rawcc > 0 && tif->tif_flags & TIFF_BUF4WRITE ) { if (!isFillOrder(tif, tif->tif_dir.td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits((uint8*)tif->tif_rawdata, + TIFFReverseBits((uint8_t*)tif->tif_rawdata, tif->tif_rawcc); if (!TIFFAppendToStrip(tif, isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip, |