41#define FAILED_FII ((uint32) -1)
46#define TIFF_INT64_MAX ((int64)(TIFF_UINT64_MAX >> 1))
49# define TIFFCvtIEEEFloatToNative(tif, n, fp)
50# define TIFFCvtIEEEDoubleToNative(tif, n, dp)
594#if defined(__WIN32__) && (_MSC_VER < 1500)
707#if defined(__WIN32__) && (_MSC_VER < 1500)
774#define INITIAL_THRESHOLD (1024 * 1024)
775#define THRESHOLD_MULTIPLIER 10
776#define MAX_THRESHOLD (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * INITIAL_THRESHOLD)
781#if SIZEOF_SIZE_T == 8
797 while( already_read <
size )
802#if SIZEOF_SIZE_T == 8
811 *pdest, already_read +
to_read);
812 if( new_dest ==
NULL )
815 "Failed to allocate memory for %s "
816 "(%ld elements of %ld bytes each)",
817 "TIFFReadDirEntryArray",
818 (
long) 1, (
long) (already_read +
to_read));
824 (
char*)*pdest + already_read,
to_read);
825 already_read += bytes_read;
843 target_count64 = (direntry->
tdir_count > maxcount) ?
846 if ((target_count64==0)||(typesize==0))
858 if ((
uint64)(2147483647/typesize)<target_count64)
860 if ((
uint64)(2147483647/desttypesize)<target_count64)
1010 *mb++=(
uint8)(*ma++);
1019 ma=(
int16*)origdata;
1028 *mb++=(
uint8)(*ma++);
1046 *mb++=(
uint8)(*ma++);
1055 ma=(
int32*)origdata;
1064 *mb++=(
uint8)(*ma++);
1082 *mb++=(
uint8)(*ma++);
1091 ma=(
int64*)origdata;
1100 *mb++=(
uint8)(*ma++);
1189 *mb++=(
int8)(*ma++);
1198 ma=(
int16*)origdata;
1207 *mb++=(
int8)(*ma++);
1225 *mb++=(
int8)(*ma++);
1234 ma=(
int32*)origdata;
1243 *mb++=(
int8)(*ma++);
1261 *mb++=(
int8)(*ma++);
1270 ma=(
int64*)origdata;
1279 *mb++=(
int8)(*ma++);
1361 ma=(
uint8*)origdata;
1406 ma=(
int32*)origdata;
1442 ma=(
int64*)origdata;
1533 ma=(
uint8*)origdata;
1536 *mb++=(
int16)(*ma++);
1547 *mb++=(
int16)(*ma++);
1564 *mb++=(
int16)(*ma++);
1573 ma=(
int32*)origdata;
1582 *mb++=(
int16)(*ma++);
1600 *mb++=(
int16)(*ma++);
1609 ma=(
int64*)origdata;
1618 *mb++=(
int16)(*ma++);
1700 ma=(
uint8*)origdata;
1742 ma=(
int16*)origdata;
1778 ma=(
int64*)origdata;
1869 ma=(
uint8*)origdata;
1872 *mb++=(
int32)(*ma++);
1883 *mb++=(
int32)(*ma++);
1897 *mb++=(
int32)(*ma++);
1906 ma=(
int16*)origdata;
1912 *mb++=(
int32)(*ma++);
1930 *mb++=(
int32)(*ma++);
1939 ma=(
int64*)origdata;
1948 *mb++=(
int32)(*ma++);
2031 ma=(
uint8*)origdata;
2073 ma=(
int16*)origdata;
2106 ma=(
int32*)origdata;
2202 ma=(
uint8*)origdata;
2205 *mb++=(
int64)(*ma++);
2216 *mb++=(
int64)(*ma++);
2230 *mb++=(
int64)(*ma++);
2239 ma=(
int16*)origdata;
2245 *mb++=(
int64)(*ma++);
2260 *mb++=(
int64)(*ma++);
2269 ma=(
int32*)origdata;
2275 *mb++=(
int64)(*ma++);
2321 *
value=(
float*)origdata;
2337 ma=(
uint8*)origdata;
2340 *mb++=(
float)(*ma++);
2351 *mb++=(
float)(*ma++);
2365 *mb++=(
float)(*ma++);
2374 ma=(
int16*)origdata;
2380 *mb++=(
float)(*ma++);
2395 *mb++=(
float)(*ma++);
2404 ma=(
int32*)origdata;
2410 *mb++=(
float)(*ma++);
2425#if defined(__WIN32__) && (_MSC_VER < 1500)
2433 *mb++ = (
float)(*ma++);
2443 ma=(
int64*)origdata;
2449 *mb++=(
float)(*ma++);
2473 *mb++=(
float)maa/(
float)mab;
2498 *mb++=(
float)maa/(
float)mab;
2510 ma=(
double*)origdata;
2566 *
value=(
double*)origdata;
2582 ma=(
uint8*)origdata;
2585 *mb++=(
double)(*ma++);
2596 *mb++=(
double)(*ma++);
2619 ma=(
int16*)origdata;
2649 ma=(
int32*)origdata;
2670#if defined(__WIN32__) && (_MSC_VER < 1500)
2688 ma=(
int64*)origdata;
2718 *mb++=(
double)maa/(
double)mab;
2743 *mb++=(
double)maa/(
double)mab;
2755 ma=(
float*)origdata;
2758 *mb++=(
double)(*ma++);
2969 assert(
sizeof(
double)==8);
2989 if (
m.i[0]==0 ||
m.i[1]==0)
2999 assert(
sizeof(
double)==8);
3020 if ((
int32)
m.i[0]==0 ||
m.i[1]==0)
3034 assert(
sizeof(
float)==4);
3036 assert(
sizeof(float_union)==4);
3038 *
value=float_union.f;
3045 assert(
sizeof(
double)==8);
3314 if (
value > 0x7FFFFFFFUL)
3324 if (
value > 0x7FFFFFFF)
3416 "Incorrect count for \"%s\"",
3421 "Incompatible type for \"%s\"",
3426 "IO error during reading of \"%s\"",
3431 "Incorrect value for \"%s\"",
3436 "Cannot handle different values per sample for \"%s\"",
3441 "Sanity check on size of \"%s\" value failed",
3446 "Out of memory reading of \"%s\"",
3457 "Incorrect count for \"%s\"; tag ignored",
3462 "Incompatible type for \"%s\"; tag ignored",
3467 "IO error during reading of \"%s\"; tag ignored",
3472 "Incorrect value for \"%s\"; tag ignored",
3477 "Cannot handle different values per sample for \"%s\"; tag ignored",
3482 "Sanity check on size of \"%s\" value failed; tag ignored",
3487 "Out of memory reading of \"%s\"; tag ignored",
3504 switch (photometric) {
3552 if( offset <= filesize && bytecount > filesize -
offset )
3562 if( bytecount < scanlinesize * tif->tif_dir.td_imagelength)
3576 static const char module[] =
"TIFFReadDirectory";
3584 int bitspersample_read =
FALSE;
3609 for (ma=
dir, mb=0; mb<dircount; ma++, mb++)
3613 for (na=ma+1, nb=mb+1; nb<dircount; na++, nb++)
3624 tif->
tif_flags &= ~TIFF_CHOPPEDUPARRAYS;
3691 for (di=0, dp=
dir; di<dircount; di++, dp++)
3699 "Unknown field with tag %d (0x%x) encountered",
3710 "Registering anonymous field with tag %d (0x%x) failed",
3778 "Planarconfig tag value assumed incorrect, "
3779 "assuming data is contig instead of chunky");
3806 "Cannot handle zero number of %s",
3807 isTiled(tif) ?
"tiles" :
"strips");
3831 isTiled(tif) ?
"TileOffsets" :
"StripOffsets");
3838 for (di=0, dp=
dir; di<dircount; di++, dp++)
3873 bitspersample_read =
TRUE;