summaryrefslogtreecommitdiff
path: root/libtiff/tif_read.c
diff options
context:
space:
mode:
authorRoger Leigh <rleigh@codelibre.net>2021-01-01 20:14:07 +0000
committerRoger Leigh <rleigh@codelibre.net>2021-01-21 23:14:13 +0000
commit39a74eede0455ec8ee334dcddf71f5354d508d8b (patch)
tree3f6515dfaa192da54d5dd731b9f90d32908b3cd5 /libtiff/tif_read.c
parentaf604f119a7b23d0b14dc5940fc84e45616dee69 (diff)
downloadlibtiff-git-39a74eede0455ec8ee334dcddf71f5354d508d8b.tar.gz
Use standard C99 integer types
Diffstat (limited to 'libtiff/tif_read.c')
-rw-r--r--libtiff/tif_read.c212
1 files changed, 106 insertions, 106 deletions
diff --git a/libtiff/tif_read.c b/libtiff/tif_read.c
index c4c868b1..748fb2d5 100644
--- a/libtiff/tif_read.c
+++ b/libtiff/tif_read.c
@@ -29,31 +29,31 @@
#include "tiffiop.h"
#include <stdio.h>
-int TIFFFillStrip(TIFF* tif, uint32 strip);
-int TIFFFillTile(TIFF* tif, uint32 tile);
-static int TIFFStartStrip(TIFF* tif, uint32 strip);
-static int TIFFStartTile(TIFF* tif, uint32 tile);
+int TIFFFillStrip(TIFF* tif, uint32_t strip);
+int TIFFFillTile(TIFF* tif, uint32_t tile);
+static int TIFFStartStrip(TIFF* tif, uint32_t strip);
+static int TIFFStartTile(TIFF* tif, uint32_t tile);
static int TIFFCheckRead(TIFF*, int);
static tmsize_t
-TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size,const char* module);
+TIFFReadRawStrip1(TIFF* tif, uint32_t strip, void* buf, tmsize_t size, const char* module);
static tmsize_t
-TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* module);
+TIFFReadRawTile1(TIFF* tif, uint32_t tile, void* buf, tmsize_t size, const char* module);
-#define NOSTRIP ((uint32)(-1)) /* undefined state */
-#define NOTILE ((uint32)(-1)) /* undefined state */
+#define NOSTRIP ((uint32_t)(-1)) /* undefined state */
+#define NOTILE ((uint32_t)(-1)) /* undefined state */
#define INITIAL_THRESHOLD (1024 * 1024)
#define THRESHOLD_MULTIPLIER 10
#define MAX_THRESHOLD (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * INITIAL_THRESHOLD)
-#define TIFF_INT64_MAX ((((int64)0x7FFFFFFF) << 32) | 0xFFFFFFFF)
+#define TIFF_INT64_MAX ((((int64_t)0x7FFFFFFF) << 32) | 0xFFFFFFFF)
/* Read 'size' bytes in tif_rawdata buffer starting at offset 'rawdata_offset'
* Returns 1 in case of success, 0 otherwise. */
-static int TIFFReadAndRealloc( TIFF* tif, tmsize_t size,
- tmsize_t rawdata_offset,
- int is_strip, uint32 strip_or_tile,
- const char* module )
+static int TIFFReadAndRealloc(TIFF* tif, tmsize_t size,
+ tmsize_t rawdata_offset,
+ int is_strip, uint32_t strip_or_tile,
+ const char* module )
{
#if SIZEOF_SIZE_T == 8
tmsize_t threshold = INITIAL_THRESHOLD;
@@ -66,8 +66,8 @@ static int TIFFReadAndRealloc( TIFF* tif, tmsize_t size,
/* file size */
if( size > 1000 * 1000 * 1000 )
{
- uint64 filesize = TIFFGetFileSize(tif);
- if( (uint64)size >= filesize )
+ uint64_t filesize = TIFFGetFileSize(tif);
+ if((uint64_t)size >= filesize )
{
TIFFErrorExt(tif->tif_clientdata, module,
"Chunk size requested is larger than file size.");
@@ -95,16 +95,16 @@ static int TIFFReadAndRealloc( TIFF* tif, tmsize_t size,
}
#endif
if (already_read + to_read + rawdata_offset > tif->tif_rawdatasize) {
- uint8* new_rawdata;
+ uint8_t* new_rawdata;
assert((tif->tif_flags & TIFF_MYBUFFER) != 0);
tif->tif_rawdatasize = (tmsize_t)TIFFroundup_64(
- (uint64)already_read + to_read + rawdata_offset, 1024);
+ (uint64_t)already_read + to_read + rawdata_offset, 1024);
if (tif->tif_rawdatasize==0) {
TIFFErrorExt(tif->tif_clientdata, module,
"Invalid buffer size");
return 0;
}
- new_rawdata = (uint8*) _TIFFrealloc(
+ new_rawdata = (uint8_t*) _TIFFrealloc(
tif->tif_rawdata, tif->tif_rawdatasize);
if( new_rawdata == 0 )
{
@@ -186,7 +186,7 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart )
static const char module[] = "TIFFFillStripPartial";
register TIFFDirectory *td = &tif->tif_dir;
tmsize_t unused_data;
- uint64 read_offset;
+ uint64_t read_offset;
tmsize_t to_read;
tmsize_t read_ahead_mod;
/* tmsize_t bytecountm; */
@@ -258,8 +258,8 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart )
to_read = read_ahead_mod - unused_data;
else
to_read = tif->tif_rawdatasize - unused_data;
- if( (uint64) to_read > TIFFGetStrileByteCount(tif, strip)
- - tif->tif_rawdataoff - tif->tif_rawdataloaded )
+ if((uint64_t) to_read > TIFFGetStrileByteCount(tif, strip)
+ - tif->tif_rawdataoff - tif->tif_rawdataloaded )
{
to_read = (tmsize_t) TIFFGetStrileByteCount(tif, strip)
- tif->tif_rawdataoff - tif->tif_rawdataloaded;
@@ -300,7 +300,7 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart )
/* For JPEG, if there are multiple scans (can generally be known */
/* with the read_ahead used), we need to read the whole strip */
if( tif->tif_dir.td_compression==COMPRESSION_JPEG &&
- (uint64)tif->tif_rawcc < TIFFGetStrileByteCount(tif, strip) )
+ (uint64_t)tif->tif_rawcc < TIFFGetStrileByteCount(tif, strip) )
{
if( TIFFJPEGIsFullStripRequired(tif) )
{
@@ -326,10 +326,10 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart )
* strips.
*/
static int
-TIFFSeek(TIFF* tif, uint32 row, uint16 sample )
+TIFFSeek(TIFF* tif, uint32_t row, uint16_t sample )
{
register TIFFDirectory *td = &tif->tif_dir;
- uint32 strip;
+ uint32_t strip;
int whole_strip;
tmsize_t read_ahead = 0;
@@ -350,7 +350,7 @@ TIFFSeek(TIFF* tif, uint32 row, uint16 sample )
(unsigned long) sample, (unsigned long) td->td_samplesperpixel);
return (0);
}
- strip = (uint32)sample*td->td_stripsperimage + row/td->td_rowsperstrip;
+ strip = (uint32_t)sample * td->td_stripsperimage + row / td->td_rowsperstrip;
} else
strip = row / td->td_rowsperstrip;
@@ -412,7 +412,7 @@ TIFFSeek(TIFF* tif, uint32 row, uint16 sample )
else if( !whole_strip )
{
if( ((tif->tif_rawdata + tif->tif_rawdataloaded) - tif->tif_rawcp) < read_ahead
- && (uint64) tif->tif_rawdataoff+tif->tif_rawdataloaded < TIFFGetStrileByteCount(tif, strip) )
+ && (uint64_t) tif->tif_rawdataoff + tif->tif_rawdataloaded < TIFFGetStrileByteCount(tif, strip) )
{
if( !TIFFFillStripPartial(tif,strip,read_ahead,0) )
return 0;
@@ -457,7 +457,7 @@ TIFFSeek(TIFF* tif, uint32 row, uint16 sample )
}
int
-TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample)
+TIFFReadScanline(TIFF* tif, void* buf, uint32_t row, uint16_t sample)
{
int e;
@@ -468,13 +468,13 @@ TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample)
* Decompress desired row into user buffer.
*/
e = (*tif->tif_decoderow)
- (tif, (uint8*) buf, tif->tif_scanlinesize, sample);
+ (tif, (uint8_t*) buf, tif->tif_scanlinesize, sample);
/* we are now poised at the beginning of the next row */
tif->tif_row = row + 1;
if (e)
- (*tif->tif_postdecode)(tif, (uint8*) buf,
+ (*tif->tif_postdecode)(tif, (uint8_t*) buf,
tif->tif_scanlinesize);
}
return (e > 0 ? 1 : -1);
@@ -485,14 +485,14 @@ TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample)
* rows in the strip (check for truncated last strip on any
* of the separations).
*/
-static tmsize_t TIFFReadEncodedStripGetStripSize(TIFF* tif, uint32 strip, uint16* pplane)
+static tmsize_t TIFFReadEncodedStripGetStripSize(TIFF* tif, uint32_t strip, uint16_t* pplane)
{
static const char module[] = "TIFFReadEncodedStrip";
TIFFDirectory *td = &tif->tif_dir;
- uint32 rowsperstrip;
- uint32 stripsperplane;
- uint32 stripinplane;
- uint32 rows;
+ uint32_t rowsperstrip;
+ uint32_t stripsperplane;
+ uint32_t stripinplane;
+ uint32_t rows;
tmsize_t stripsize;
if (!TIFFCheckRead(tif,0))
return((tmsize_t)(-1));
@@ -509,7 +509,7 @@ static tmsize_t TIFFReadEncodedStripGetStripSize(TIFF* tif, uint32 strip, uint16
rowsperstrip=td->td_imagelength;
stripsperplane= TIFFhowmany_32_maxuint_compat(td->td_imagelength, rowsperstrip);
stripinplane=(strip%stripsperplane);
- if( pplane ) *pplane=(uint16)(strip/stripsperplane);
+ if( pplane ) *pplane=(uint16_t)(strip / stripsperplane);
rows=td->td_imagelength-stripinplane*rowsperstrip;
if (rows>rowsperstrip)
rows=rowsperstrip;
@@ -524,12 +524,12 @@ static tmsize_t TIFFReadEncodedStripGetStripSize(TIFF* tif, uint32 strip, uint16
* amount into the user-supplied buffer.
*/
tmsize_t
-TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size)
+TIFFReadEncodedStrip(TIFF* tif, uint32_t strip, void* buf, tmsize_t size)
{
static const char module[] = "TIFFReadEncodedStrip";
TIFFDirectory *td = &tif->tif_dir;
tmsize_t stripsize;
- uint16 plane;
+ uint16_t plane;
stripsize=TIFFReadEncodedStripGetStripSize(tif, strip, &plane);
if (stripsize==((tmsize_t)(-1)))
@@ -569,12 +569,12 @@ TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size)
* * calls regular TIFFReadEncodedStrip() if *buf != NULL
*/
tmsize_t
-_TIFFReadEncodedStripAndAllocBuffer(TIFF* tif, uint32 strip,
+_TIFFReadEncodedStripAndAllocBuffer(TIFF* tif, uint32_t strip,
void **buf, tmsize_t bufsizetoalloc,
tmsize_t size_to_read)
{
tmsize_t this_stripsize;
- uint16 plane;
+ uint16_t plane;
if( *buf != NULL )
{
@@ -606,8 +606,8 @@ _TIFFReadEncodedStripAndAllocBuffer(TIFF* tif, uint32 strip,
}
static tmsize_t
-TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size,
- const char* module)
+TIFFReadRawStrip1(TIFF* tif, uint32_t strip, void* buf, tmsize_t size,
+ const char* module)
{
assert((tif->tif_flags&TIFF_NOREADRAW)==0);
if (!isMapped(tif)) {
@@ -639,8 +639,8 @@ TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size,
} else {
tmsize_t ma = 0;
tmsize_t n;
- if ((TIFFGetStrileOffset(tif, strip) > (uint64)TIFF_TMSIZE_T_MAX)||
- ((ma=(tmsize_t)TIFFGetStrileOffset(tif, strip))>tif->tif_size))
+ if ((TIFFGetStrileOffset(tif, strip) > (uint64_t)TIFF_TMSIZE_T_MAX) ||
+ ((ma=(tmsize_t)TIFFGetStrileOffset(tif, strip))>tif->tif_size))
{
n=0;
}
@@ -681,7 +681,7 @@ TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size,
}
static tmsize_t
-TIFFReadRawStripOrTile2(TIFF* tif, uint32 strip_or_tile, int is_strip,
+TIFFReadRawStripOrTile2(TIFF* tif, uint32_t strip_or_tile, int is_strip,
tmsize_t size, const char* module)
{
assert( !isMapped(tif) );
@@ -719,11 +719,11 @@ TIFFReadRawStripOrTile2(TIFF* tif, uint32 strip_or_tile, int is_strip,
* Read a strip of data from the file.
*/
tmsize_t
-TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size)
+TIFFReadRawStrip(TIFF* tif, uint32_t strip, void* buf, tmsize_t size)
{
static const char module[] = "TIFFReadRawStrip";
TIFFDirectory *td = &tif->tif_dir;
- uint64 bytecount64;
+ uint64_t bytecount64;
tmsize_t bytecountm;
if (!TIFFCheckRead(tif, 0))
@@ -742,7 +742,7 @@ TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size)
return ((tmsize_t)(-1));
}
bytecount64 = TIFFGetStrileByteCount(tif, strip);
- if (size != (tmsize_t)(-1) && (uint64)size <= bytecount64)
+ if (size != (tmsize_t)(-1) && (uint64_t)size <= bytecount64)
bytecountm = size;
else
bytecountm = _TIFFCastUInt64ToSSize(tif, bytecount64, module);
@@ -753,7 +753,7 @@ TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size)
}
TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
-static uint64 NoSanitizeSubUInt64(uint64 a, uint64 b)
+static uint64_t NoSanitizeSubUInt64(uint64_t a, uint64_t b)
{
return a - b;
}
@@ -763,15 +763,15 @@ static uint64 NoSanitizeSubUInt64(uint64 a, uint64 b)
* expanded, as necessary, to hold the strip's data.
*/
int
-TIFFFillStrip(TIFF* tif, uint32 strip)
+TIFFFillStrip(TIFF* tif, uint32_t strip)
{
static const char module[] = "TIFFFillStrip";
TIFFDirectory *td = &tif->tif_dir;
if ((tif->tif_flags&TIFF_NOREADRAW)==0)
{
- uint64 bytecount = TIFFGetStrileByteCount(tif, strip);
- if( bytecount == 0 || bytecount > (uint64)TIFF_INT64_MAX ) {
+ uint64_t bytecount = TIFFGetStrileByteCount(tif, strip);
+ if( bytecount == 0 || bytecount > (uint64_t)TIFF_INT64_MAX ) {
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
TIFFErrorExt(tif->tif_clientdata, module,
"Invalid strip byte count %I64u, strip %lu",
@@ -795,10 +795,10 @@ TIFFFillStrip(TIFF* tif, uint32 strip)
/* Hopefully they are safe enough for all codecs */
tmsize_t stripsize = TIFFStripSize(tif);
if( stripsize != 0 &&
- (bytecount - 4096) / 10 > (uint64)stripsize )
+ (bytecount - 4096) / 10 > (uint64_t)stripsize )
{
- uint64 newbytecount = (uint64)stripsize * 10 + 4096;
- if( newbytecount == 0 || newbytecount > (uint64)TIFF_INT64_MAX )
+ uint64_t newbytecount = (uint64_t)stripsize * 10 + 4096;
+ if( newbytecount == 0 || newbytecount > (uint64_t)TIFF_INT64_MAX )
{
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
TIFFWarningExt(tif->tif_clientdata, module,
@@ -828,8 +828,8 @@ TIFFFillStrip(TIFF* tif, uint32 strip)
* comparison (which can overflow) we do the following
* two comparisons:
*/
- if (bytecount > (uint64)tif->tif_size ||
- TIFFGetStrileOffset(tif, strip) > (uint64)tif->tif_size - bytecount) {
+ if (bytecount > (uint64_t)tif->tif_size ||
+ TIFFGetStrileOffset(tif, strip) > (uint64_t)tif->tif_size - bytecount) {
/*
* This error message might seem strange, but
* it's what would happen if a read were done
@@ -897,7 +897,7 @@ TIFFFillStrip(TIFF* tif, uint32 strip)
*/
tmsize_t bytecountm;
bytecountm=(tmsize_t)bytecount;
- if ((uint64)bytecountm!=bytecount)
+ if ((uint64_t)bytecountm != bytecount)
{
TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
return(0);
@@ -962,7 +962,7 @@ TIFFFillStrip(TIFF* tif, uint32 strip)
* tile is selected by the (x,y,z,s) coordinates.
*/
tmsize_t
-TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s)
+TIFFReadTile(TIFF* tif, void* buf, uint32_t x, uint32_t y, uint32_t z, uint16_t s)
{
if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s))
return ((tmsize_t)(-1));
@@ -975,7 +975,7 @@ TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s)
* amount into the user-supplied buffer.
*/
tmsize_t
-TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size)
+TIFFReadEncodedTile(TIFF* tif, uint32_t tile, void* buf, tmsize_t size)
{
static const char module[] = "TIFFReadEncodedTile";
TIFFDirectory *td = &tif->tif_dir;
@@ -1012,8 +1012,8 @@ TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size)
else if (size > tilesize)
size = tilesize;
if (TIFFFillTile(tif, tile) && (*tif->tif_decodetile)(tif,
- (uint8*) buf, size, (uint16)(tile/td->td_stripsperimage))) {
- (*tif->tif_postdecode)(tif, (uint8*) buf, size);
+ (uint8_t*) buf, size, (uint16_t)(tile / td->td_stripsperimage))) {
+ (*tif->tif_postdecode)(tif, (uint8_t*) buf, size);
return (size);
} else
return ((tmsize_t)(-1));
@@ -1028,7 +1028,7 @@ TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size)
tmsize_t
_TIFFReadTileAndAllocBuffer(TIFF* tif,
void **buf, tmsize_t bufsizetoalloc,
- uint32 x, uint32 y, uint32 z, uint16 s)
+ uint32_t x, uint32_t y, uint32_t z, uint16_t s)
{
if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s))
return ((tmsize_t)(-1));
@@ -1045,9 +1045,9 @@ _TIFFReadTileAndAllocBuffer(TIFF* tif,
* * calls regular TIFFReadEncodedTile() if *buf != NULL
*/
tmsize_t
-_TIFFReadEncodedTileAndAllocBuffer(TIFF* tif, uint32 tile,
- void **buf, tmsize_t bufsizetoalloc,
- tmsize_t size_to_read)
+_TIFFReadEncodedTileAndAllocBuffer(TIFF* tif, uint32_t tile,
+ void **buf, tmsize_t bufsizetoalloc,
+ tmsize_t size_to_read)
{
static const char module[] = "_TIFFReadEncodedTileAndAllocBuffer";
TIFFDirectory *td = &tif->tif_dir;
@@ -1083,15 +1083,15 @@ _TIFFReadEncodedTileAndAllocBuffer(TIFF* tif, uint32 tile,
else if (size_to_read > tilesize)
size_to_read = tilesize;
if( (*tif->tif_decodetile)(tif,
- (uint8*) *buf, size_to_read, (uint16)(tile/td->td_stripsperimage))) {
- (*tif->tif_postdecode)(tif, (uint8*) *buf, size_to_read);
+ (uint8_t*) *buf, size_to_read, (uint16_t)(tile / td->td_stripsperimage))) {
+ (*tif->tif_postdecode)(tif, (uint8_t*) *buf, size_to_read);
return (size_to_read);
} else
return ((tmsize_t)(-1));
}
static tmsize_t
-TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* module)
+TIFFReadRawTile1(TIFF* tif, uint32_t tile, void* buf, tmsize_t size, const char* module)
{
assert((tif->tif_flags&TIFF_NOREADRAW)==0);
if (!isMapped(tif)) {
@@ -1129,7 +1129,7 @@ TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* m
tmsize_t n;
ma=(tmsize_t)TIFFGetStrileOffset(tif, tile);
mb=ma+size;
- if ((TIFFGetStrileOffset(tif, tile) > (uint64)TIFF_TMSIZE_T_MAX)||(ma>tif->tif_size))
+ if ((TIFFGetStrileOffset(tif, tile) > (uint64_t)TIFF_TMSIZE_T_MAX) || (ma > tif->tif_size))
n=0;
else if ((mb<ma)||(mb<size)||(mb>tif->tif_size))
n=tif->tif_size-ma;
@@ -1164,11 +1164,11 @@ TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* m
* Read a tile of data from the file.
*/
tmsize_t
-TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size)
+TIFFReadRawTile(TIFF* tif, uint32_t tile, void* buf, tmsize_t size)
{
static const char module[] = "TIFFReadRawTile";
TIFFDirectory *td = &tif->tif_dir;
- uint64 bytecount64;
+ uint64_t bytecount64;
tmsize_t bytecountm;
if (!TIFFCheckRead(tif, 1))
@@ -1186,7 +1186,7 @@ TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size)
return ((tmsize_t)(-1));
}
bytecount64 = TIFFGetStrileByteCount(tif, tile);
- if (size != (tmsize_t)(-1) && (uint64)size <= bytecount64)
+ if (size != (tmsize_t)(-1) && (uint64_t)size <= bytecount64)
bytecountm = size;
else
bytecountm = _TIFFCastUInt64ToSSize(tif, bytecount64, module);
@@ -1201,15 +1201,15 @@ TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size)
* expanded, as necessary, to hold the tile's data.
*/
int
-TIFFFillTile(TIFF* tif, uint32 tile)
+TIFFFillTile(TIFF* tif, uint32_t tile)
{
static const char module[] = "TIFFFillTile";
TIFFDirectory *td = &tif->tif_dir;
if ((tif->tif_flags&TIFF_NOREADRAW)==0)
{
- uint64 bytecount = TIFFGetStrileByteCount(tif, tile);
- if( bytecount == 0 || bytecount > (uint64)TIFF_INT64_MAX ) {
+ uint64_t bytecount = TIFFGetStrileByteCount(tif, tile);
+ if( bytecount == 0 || bytecount > (uint64_t)TIFF_INT64_MAX ) {
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
TIFFErrorExt(tif->tif_clientdata, module,
"%I64u: Invalid tile byte count, tile %lu",
@@ -1233,10 +1233,10 @@ TIFFFillTile(TIFF* tif, uint32 tile)
/* Hopefully they are safe enough for all codecs */
tmsize_t stripsize = TIFFTileSize(tif);
if( stripsize != 0 &&
- (bytecount - 4096) / 10 > (uint64)stripsize )
+ (bytecount - 4096) / 10 > (uint64_t)stripsize )
{
- uint64 newbytecount = (uint64)stripsize * 10 + 4096;
- if( newbytecount == 0 || newbytecount > (uint64)TIFF_INT64_MAX )
+ uint64_t newbytecount = (uint64_t)stripsize * 10 + 4096;
+ if( newbytecount == 0 || newbytecount > (uint64_t)TIFF_INT64_MAX )
{
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
TIFFWarningExt(tif->tif_clientdata, module,
@@ -1266,8 +1266,8 @@ TIFFFillTile(TIFF* tif, uint32 tile)
* comparison (which can overflow) we do the following
* two comparisons:
*/
- if (bytecount > (uint64)tif->tif_size ||
- TIFFGetStrileOffset(tif, tile) > (uint64)tif->tif_size - bytecount) {
+ if (bytecount > (uint64_t)tif->tif_size ||
+ TIFFGetStrileOffset(tif, tile) > (uint64_t)tif->tif_size - bytecount) {
tif->tif_curtile = NOTILE;
return (0);
}
@@ -1308,7 +1308,7 @@ TIFFFillTile(TIFF* tif, uint32 tile)
*/
tmsize_t bytecountm;
bytecountm=(tmsize_t)bytecount;
- if ((uint64)bytecountm!=bytecount)
+ if ((uint64_t)bytecountm != bytecount)
{
TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
return(0);
@@ -1390,10 +1390,10 @@ TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size)
}
if (bp) {
tif->tif_rawdatasize = size;
- tif->tif_rawdata = (uint8*) bp;
+ tif->tif_rawdata = (uint8_t*) bp;
tif->tif_flags &= ~TIFF_MYBUFFER;
} else {
- tif->tif_rawdatasize = (tmsize_t)TIFFroundup_64((uint64)size, 1024);
+ tif->tif_rawdatasize = (tmsize_t)TIFFroundup_64((uint64_t)size, 1024);
if (tif->tif_rawdatasize==0) {
TIFFErrorExt(tif->tif_clientdata, module,
"Invalid buffer size");
@@ -1401,7 +1401,7 @@ TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size)
}
/* Initialize to zero to avoid uninitialized buffers in case of */
/* short reads (http://bugzilla.maptools.org/show_bug.cgi?id=2651) */
- tif->tif_rawdata = (uint8*) _TIFFcalloc(1, tif->tif_rawdatasize);
+ tif->tif_rawdata = (uint8_t*) _TIFFcalloc(1, tif->tif_rawdatasize);
tif->tif_flags |= TIFF_MYBUFFER;
}
if (tif->tif_rawdata == NULL) {
@@ -1419,7 +1419,7 @@ TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size)
* strip has just been read in.
*/
static int
-TIFFStartStrip(TIFF* tif, uint32 strip)
+TIFFStartStrip(TIFF* tif, uint32_t strip)
{
TIFFDirectory *td = &tif->tif_dir;
@@ -1446,7 +1446,7 @@ TIFFStartStrip(TIFF* tif, uint32 strip)
tif->tif_rawcc = (tmsize_t)TIFFGetStrileByteCount(tif, strip);
}
if ((*tif->tif_predecode)(tif,
- (uint16)(strip / td->td_stripsperimage)) == 0 ) {
+ (uint16_t)(strip / td->td_stripsperimage)) == 0 ) {
/* Needed for example for scanline access, if tif_predecode */
/* fails, and we try to read the same strip again. Without invalidating */
/* tif_curstrip, we'd call tif_decoderow() on a possibly invalid */
@@ -1462,11 +1462,11 @@ TIFFStartStrip(TIFF* tif, uint32 strip)
* tile has just been read in.
*/
static int
-TIFFStartTile(TIFF* tif, uint32 tile)
+TIFFStartTile(TIFF* tif, uint32_t tile)
{
static const char module[] = "TIFFStartTile";
TIFFDirectory *td = &tif->tif_dir;
- uint32 howmany32;
+ uint32_t howmany32;
if ((tif->tif_flags & TIFF_CODERSETUP) == 0) {
if (!(*tif->tif_setupdecode)(tif))
@@ -1501,7 +1501,7 @@ TIFFStartTile(TIFF* tif, uint32 tile)
tif->tif_rawcc = (tmsize_t)TIFFGetStrileByteCount(tif, tile);
}
return ((*tif->tif_predecode)(tif,
- (uint16)(tile/td->td_stripsperimage)));
+ (uint16_t)(tile / td->td_stripsperimage)));
}
static int
@@ -1529,14 +1529,14 @@ TIFFCheckRead(TIFF* tif, int tiles)
* inbuf content must be writable (if bit reversal is needed)
* Returns 1 in case of success, 0 otherwise.
*/
-int TIFFReadFromUserBuffer(TIFF* tif, uint32 strile,
+int TIFFReadFromUserBuffer(TIFF* tif, uint32_t strile,
void* inbuf, tmsize_t insize,
void* outbuf, tmsize_t outsize)
{
static const char module[] = "TIFFReadFromUserBuffer";
TIFFDirectory *td = &tif->tif_dir;
int ret = 1;
- uint32 old_tif_flags = tif->tif_flags;
+ uint32_t old_tif_flags = tif->tif_flags;
tmsize_t old_rawdatasize = tif->tif_rawdatasize;
void* old_rawdata = tif->tif_rawdata;
@@ -1567,29 +1567,29 @@ int TIFFReadFromUserBuffer(TIFF* tif, uint32 strile,
if( TIFFIsTiled(tif) )
{
if( !TIFFStartTile(tif, strile) ||
- !(*tif->tif_decodetile)(tif, (uint8*) outbuf, outsize,
- (uint16)(strile/td->td_stripsperimage)) )
+ !(*tif->tif_decodetile)(tif, (uint8_t*) outbuf, outsize,
+ (uint16_t)(strile / td->td_stripsperimage)) )
{
ret = 0;
}
}
else
{
- uint32 rowsperstrip=td->td_rowsperstrip;
- uint32 stripsperplane;
+ uint32_t rowsperstrip=td->td_rowsperstrip;
+ uint32_t stripsperplane;
if (rowsperstrip>td->td_imagelength)
rowsperstrip=td->td_imagelength;
stripsperplane= TIFFhowmany_32_maxuint_compat(td->td_imagelength, rowsperstrip);
if( !TIFFStartStrip(tif, strile) ||
- !(*tif->tif_decodestrip)(tif, (uint8*) outbuf, outsize,
- (uint16)(strile/stripsperplane)) )
+ !(*tif->tif_decodestrip)(tif, (uint8_t*) outbuf, outsize,
+ (uint16_t)(strile / stripsperplane)) )
{
ret = 0;
}
}
if( ret )
{
- (*tif->tif_postdecode)(tif, (uint8*) outbuf, outsize);
+ (*tif->tif_postdecode)(tif, (uint8_t*) outbuf, outsize);
}
if (!isFillOrder(tif, td->td_fillorder) &&
@@ -1608,37 +1608,37 @@ int TIFFReadFromUserBuffer(TIFF* tif, uint32 strile,
}
void
-_TIFFNoPostDecode(TIFF* tif, uint8* buf, tmsize_t cc)
+_TIFFNoPostDecode(TIFF* tif, uint8_t* buf, tmsize_t cc)
{
(void) tif; (void) buf; (void) cc;
}
void
-_TIFFSwab16BitData(TIFF* tif, uint8* buf, tmsize_t cc)
+_TIFFSwab16BitData(TIFF* tif, uint8_t* buf, tmsize_t cc)
{
(void) tif;
assert((cc & 1) == 0);
- TIFFSwabArrayOfShort((uint16*) buf, cc/2);
+ TIFFSwabArrayOfShort((uint16_t*) buf, cc / 2);
}
void
-_TIFFSwab24BitData(TIFF* tif, uint8* buf, tmsize_t cc)
+_TIFFSwab24BitData(TIFF* tif, uint8_t* buf, tmsize_t cc)
{
(void) tif;
assert((cc % 3) == 0);
- TIFFSwabArrayOfTriples((uint8*) buf, cc/3);
+ TIFFSwabArrayOfTriples((uint8_t*) buf, cc / 3);
}
void
-_TIFFSwab32BitData(TIFF* tif, uint8* buf, tmsize_t cc)
+_TIFFSwab32BitData(TIFF* tif, uint8_t* buf, tmsize_t cc)
{
(void) tif;
assert((cc & 3) == 0);
- TIFFSwabArrayOfLong((uint32*) buf, cc/4);
+ TIFFSwabArrayOfLong((uint32_t*) buf, cc / 4);
}
void
-_TIFFSwab64BitData(TIFF* tif, uint8* buf, tmsize_t cc)
+_TIFFSwab64BitData(TIFF* tif, uint8_t* buf, tmsize_t cc)
{
(void) tif;
assert((cc & 7) == 0);