54#define FAILED_FII ((uint32_t)-1)
70#define TIFFCvtIEEEFloatToNative(tif, n, fp)
84#define TIFFCvtIEEEDoubleToNative(tif, n, dp)
144 uint32_t desttypesize,
void **value);
289 const char *module,
const char *
tagname,
357 result.
c[0] = value[0];
358 result.
c[1] = value[1];
359 result.
c[2] = value[2];
360 result.
c[3] = value[3];
361 result.
c[4] = value[4];
362 result.
c[5] = value[5];
363 result.
c[6] = value[6];
364 result.
c[7] = value[7];
639 *value = (uint16_t)m;
649 *value = (uint16_t)m;
662 *value = (uint16_t)m;
672 *value = (uint16_t)m;
682 *value = (uint16_t)m;
694 *value = (uint16_t)m;
706 *value = (uint16_t)m;
859 *value = (uint32_t)m;
869 *value = (uint32_t)m;
876 *value = (uint32_t)m;
886 *value = (uint32_t)m;
900 *value = (uint32_t)m;
913 *value = (uint32_t)m;
925 *value = (uint32_t)m;
1000 *value = (int32_t)m;
1015 *value = (int32_t)m;
1027 *value = (int32_t)m;
1072 *value = (uint64_t)m;
1082 *value = (uint64_t)m;
1089 *value = (uint64_t)m;
1099 *value = (uint64_t)m;
1107 *value = (uint64_t)m;
1117 *value = (uint64_t)m;
1133 *value = (uint64_t)m;
1177 *value = (int64_t)m;
1184 *value = (int64_t)m;
1191 *value = (int64_t)m;
1198 *value = (int64_t)m;
1205 *value = (int64_t)m;
1212 *value = (int64_t)m;
1224 *value = (int64_t)m;
1358 if ((m > (
double)FLT_MAX) || (m < -(
double)FLT_MAX))
1521 *value = (uint64_t)m;
1537#define INITIAL_THRESHOLD (1024 * 1024)
1542#define THRESHOLD_MULTIPLIER 10
1550#define MAX_THRESHOLD \
1551 (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * \
1582#if SIZEOF_SIZE_T == 8
1591 if (!
SeekOK(tif, offset))
1600 while (already_read < size)
1604 tmsize_t to_read = size - already_read;
1605#if SIZEOF_SIZE_T == 8
1608 to_read = threshold;
1615 if (new_dest == NULL)
1618 "Failed to allocate memory for %s "
1621 "TIFFReadDirEntryArray", (
tmsize_t)1,
1622 already_read + to_read);
1627 bytes_read =
TIFFReadFile(tif, (
char *)*pdest + already_read, to_read);
1630 already_read += bytes_read;
1631 if (bytes_read != to_read)
1645#define MAX_SIZE_TAG_DATA 2147483647U
1679 uint32_t *count, uint32_t desttypesize,
1680 void **value, uint64_t maxcount)
1685 uint64_t target_count64;
1686 int original_datasize_clamped;
1692 if ((target_count64 == 0) || (typesize == 0))
1702 original_datasize_clamped =
1716 *count = (uint32_t)target_count64;
1717 datasize = (uint32_t)(*count) * (
unsigned int)typesize;
1720 if (datasize > 100 * 1024 * 1024)
1726 if (datasize > filesize)
1729 "Requested memory size for tag %d (0x%x) %" PRIu32
1730 " is greater than filesize %" PRIu64
1731 ". Memory not allocated, tag not read",
1756 if (original_datasize_clamped <= 4 && datasize <= 4)
1780 if (original_datasize_clamped <= 8 && datasize <= 8)
1836 uint32_t desttypesize,
void **value)
1839 value, ~((uint64_t)0));
1903 *value = (uint8_t *)origdata;
1909 m = (int8_t *)origdata;
1910 for (n = 0; n < count; n++)
1920 *value = (uint8_t *)origdata;
1939 ma = (uint16_t *)origdata;
1941 for (n = 0; n < count; n++)
1948 *mb++ = (uint8_t)(*ma++);
1957 ma = (int16_t *)origdata;
1959 for (n = 0; n < count; n++)
1966 *mb++ = (uint8_t)(*ma++);
1975 ma = (uint32_t *)origdata;
1977 for (n = 0; n < count; n++)
1984 *mb++ = (uint8_t)(*ma++);
1993 ma = (int32_t *)origdata;
1995 for (n = 0; n < count; n++)
2002 *mb++ = (uint8_t)(*ma++);
2011 ma = (uint64_t *)origdata;
2013 for (n = 0; n < count; n++)
2020 *mb++ = (uint8_t)(*ma++);
2029 ma = (int64_t *)origdata;
2031 for (n = 0; n < count; n++)
2038 *mb++ = (uint8_t)(*ma++);
2117 m = (uint8_t *)origdata;
2118 for (n = 0; n < count; n++)
2128 *value = (int8_t *)origdata;
2132 *value = (int8_t *)origdata;
2150 ma = (uint16_t *)origdata;
2152 for (n = 0; n < count; n++)
2159 *mb++ = (int8_t)(*ma++);
2168 ma = (int16_t *)origdata;
2170 for (n = 0; n < count; n++)
2177 *mb++ = (int8_t)(*ma++);
2186 ma = (uint32_t *)origdata;
2188 for (n = 0; n < count; n++)
2195 *mb++ = (int8_t)(*ma++);
2204 ma = (int32_t *)origdata;
2206 for (n = 0; n < count; n++)
2213 *mb++ = (int8_t)(*ma++);
2222 ma = (uint64_t *)origdata;
2224 for (n = 0; n < count; n++)
2231 *mb++ = (int8_t)(*ma++);
2240 ma = (int64_t *)origdata;
2242 for (n = 0; n < count; n++)
2249 *mb++ = (int8_t)(*ma++);
2323 *value = (uint16_t *)origdata;
2331 m = (int16_t *)origdata;
2332 for (n = 0; n < count; n++)
2344 *value = (uint16_t *)origdata;
2351 "TIFFReadDirEntryShortArray");
2364 ma = (uint8_t *)origdata;
2366 for (n = 0; n < count; n++)
2367 *mb++ = (uint16_t)(*ma++);
2375 ma = (int8_t *)origdata;
2377 for (n = 0; n < count; n++)
2382 *mb++ = (uint16_t)(*ma++);
2391 ma = (uint32_t *)origdata;
2393 for (n = 0; n < count; n++)
2400 *mb++ = (uint16_t)(*ma++);
2409 ma = (int32_t *)origdata;
2411 for (n = 0; n < count; n++)
2418 *mb++ = (uint16_t)(*ma++);
2427 ma = (uint64_t *)origdata;
2429 for (n = 0; n < count; n++)
2436 *mb++ = (uint16_t)(*ma++);
2445 ma = (int64_t *)origdata;
2447 for (n = 0; n < count; n++)
2454 *mb++ = (uint16_t)(*ma++);
2532 m = (uint16_t *)origdata;
2533 for (n = 0; n < count; n++)
2545 *value = (int16_t *)origdata;
2549 *value = (int16_t *)origdata;
2557 "TIFFReadDirEntrySshortArray");
2570 ma = (uint8_t *)origdata;
2572 for (n = 0; n < count; n++)
2573 *mb++ = (int16_t)(*ma++);
2581 ma = (int8_t *)origdata;
2583 for (n = 0; n < count; n++)
2584 *mb++ = (int16_t)(*ma++);
2592 ma = (uint32_t *)origdata;
2594 for (n = 0; n < count; n++)
2601 *mb++ = (int16_t)(*ma++);
2610 ma = (int32_t *)origdata;
2612 for (n = 0; n < count; n++)
2619 *mb++ = (int16_t)(*ma++);
2628 ma = (uint64_t *)origdata;
2630 for (n = 0; n < count; n++)
2637 *mb++ = (int16_t)(*ma++);
2646 ma = (int64_t *)origdata;
2648 for (n = 0; n < count; n++)
2655 *mb++ = (int16_t)(*ma++);
2733 *value = (uint32_t *)origdata;
2741 m = (int32_t *)origdata;
2742 for (n = 0; n < count; n++)
2754 *value = (uint32_t *)origdata;
2761 "TIFFReadDirEntryLongArray");
2774 ma = (uint8_t *)origdata;
2776 for (n = 0; n < count; n++)
2777 *mb++ = (uint32_t)(*ma++);
2785 ma = (int8_t *)origdata;
2787 for (n = 0; n < count; n++)
2792 *mb++ = (uint32_t)(*ma++);
2801 ma = (uint16_t *)origdata;
2803 for (n = 0; n < count; n++)
2807 *mb++ = (uint32_t)(*ma++);
2816 ma = (int16_t *)origdata;
2818 for (n = 0; n < count; n++)
2825 *mb++ = (uint32_t)(*ma++);
2835 ma = (uint64_t *)origdata;
2837 for (n = 0; n < count; n++)
2844 *mb++ = (uint32_t)(*ma++);
2853 ma = (int64_t *)origdata;
2855 for (n = 0; n < count; n++)
2862 *mb++ = (uint32_t)(*ma++);
2940 m = (uint32_t *)origdata;
2941 for (n = 0; n < count; n++)
2953 *value = (int32_t *)origdata;
2957 *value = (int32_t *)origdata;
2965 "TIFFReadDirEntrySlongArray");
2978 ma = (uint8_t *)origdata;
2980 for (n = 0; n < count; n++)
2981 *mb++ = (int32_t)(*ma++);
2989 ma = (int8_t *)origdata;
2991 for (n = 0; n < count; n++)
2992 *mb++ = (int32_t)(*ma++);
3000 ma = (uint16_t *)origdata;
3002 for (n = 0; n < count; n++)
3006 *mb++ = (int32_t)(*ma++);
3015 ma = (int16_t *)origdata;
3017 for (n = 0; n < count; n++)
3021 *mb++ = (int32_t)(*ma++);
3030 ma = (uint64_t *)origdata;
3032 for (n = 0; n < count; n++)
3039 *mb++ = (int32_t)(*ma++);
3048 ma = (int64_t *)origdata;
3050 for (n = 0; n < count; n++)
3057 *mb++ = (int32_t)(*ma++);
3107 uint64_t **value, uint64_t maxcount)
3140 *value = (uint64_t *)origdata;
3148 m = (int64_t *)origdata;
3149 for (n = 0; n < count; n++)
3161 *value = (uint64_t *)origdata;
3168 "TIFFReadDirEntryLong8ArrayWithLimit");
3181 ma = (uint8_t *)origdata;
3183 for (n = 0; n < count; n++)
3184 *mb++ = (uint64_t)(*ma++);
3192 ma = (int8_t *)origdata;
3194 for (n = 0; n < count; n++)
3199 *mb++ = (uint64_t)(*ma++);
3208 ma = (uint16_t *)origdata;
3210 for (n = 0; n < count; n++)
3214 *mb++ = (uint64_t)(*ma++);
3223 ma = (int16_t *)origdata;
3225 for (n = 0; n < count; n++)
3232 *mb++ = (uint64_t)(*ma++);
3242 ma = (uint32_t *)origdata;
3244 for (n = 0; n < count; n++)
3248 *mb++ = (uint64_t)(*ma++);
3257 ma = (int32_t *)origdata;
3259 for (n = 0; n < count; n++)
3266 *mb++ = (uint64_t)(*ma++);
3369 m = (uint64_t *)origdata;
3370 for (n = 0; n < count; n++)
3382 *value = (int64_t *)origdata;
3386 *value = (int64_t *)origdata;
3394 "TIFFReadDirEntrySlong8Array");
3407 ma = (uint8_t *)origdata;
3409 for (n = 0; n < count; n++)
3410 *mb++ = (int64_t)(*ma++);
3418 ma = (int8_t *)origdata;
3420 for (n = 0; n < count; n++)
3421 *mb++ = (int64_t)(*ma++);
3429 ma = (uint16_t *)origdata;
3431 for (n = 0; n < count; n++)
3435 *mb++ = (int64_t)(*ma++);
3444 ma = (int16_t *)origdata;
3446 for (n = 0; n < count; n++)
3450 *mb++ = (int64_t)(*ma++);
3459 ma = (uint32_t *)origdata;
3461 for (n = 0; n < count; n++)
3465 *mb++ = (int64_t)(*ma++);
3474 ma = (int32_t *)origdata;
3476 for (n = 0; n < count; n++)
3480 *mb++ = (int64_t)(*ma++);
3561 *value = (
float *)origdata;
3567 "TIFFReadDirEntryFloatArray");
3580 ma = (uint8_t *)origdata;
3582 for (n = 0; n < count; n++)
3583 *mb++ = (
float)(*ma++);
3591 ma = (int8_t *)origdata;
3593 for (n = 0; n < count; n++)
3594 *mb++ = (
float)(*ma++);
3602 ma = (uint16_t *)origdata;
3604 for (n = 0; n < count; n++)
3608 *mb++ = (float)(*ma++);
3617 ma = (int16_t *)origdata;
3619 for (n = 0; n < count; n++)
3623 *mb++ = (float)(*ma++);
3632 ma = (uint32_t *)origdata;
3634 for (n = 0; n < count; n++)
3638 *mb++ = (float)(*ma++);
3647 ma = (int32_t *)origdata;
3649 for (n = 0; n < count; n++)
3653 *mb++ = (float)(*ma++);
3662 ma = (uint64_t *)origdata;
3664 for (n = 0; n < count; n++)
3668 *mb++ = (float)(*ma++);
3677 ma = (int64_t *)origdata;
3679 for (n = 0; n < count; n++)
3683 *mb++ = (float)(*ma++);
3694 ma = (uint32_t *)origdata;
3696 for (n = 0; n < count; n++)
3707 *mb++ = (float)maa / (
float)mab;
3718 ma = (uint32_t *)origdata;
3720 for (n = 0; n < count; n++)
3724 maa = *(int32_t *)ma;
3732 *mb++ = (float)maa / (
float)mab;
3744 ma = (
double *)origdata;
3746 for (n = 0; n < count; n++)
3749 if (val > (
double)FLT_MAX)
3750 val = (
double)FLT_MAX;
3751 else if (val < -(
double)FLT_MAX)
3752 val = -(
double)FLT_MAX;
3832 *value = (
double *)origdata;
3838 (
tmsize_t)((size_t)count *
sizeof(
double)));
3851 ma = (uint8_t *)origdata;
3853 for (n = 0; n < count; n++)
3854 *mb++ = (
double)(*ma++);
3862 ma = (int8_t *)origdata;
3864 for (n = 0; n < count; n++)
3865 *mb++ = (
double)(*ma++);
3873 ma = (uint16_t *)origdata;
3875 for (n = 0; n < count; n++)
3879 *mb++ = (double)(*ma++);
3888 ma = (int16_t *)origdata;
3890 for (n = 0; n < count; n++)
3894 *mb++ = (double)(*ma++);
3903 ma = (uint32_t *)origdata;
3905 for (n = 0; n < count; n++)
3909 *mb++ = (double)(*ma++);
3918 ma = (int32_t *)origdata;
3920 for (n = 0; n < count; n++)
3924 *mb++ = (double)(*ma++);
3933 ma = (uint64_t *)origdata;
3935 for (n = 0; n < count; n++)
3939 *mb++ = (double)(*ma++);
3948 ma = (int64_t *)origdata;
3950 for (n = 0; n < count; n++)
3954 *mb++ = (double)(*ma++);
3965 ma = (uint32_t *)origdata;
3967 for (n = 0; n < count; n++)
3978 *mb++ = (double)maa / (
double)mab;
3989 ma = (uint32_t *)origdata;
3991 for (n = 0; n < count; n++)
3995 maa = *(int32_t *)ma;
4003 *mb++ = (double)maa / (
double)mab;
4015 ma = (
float *)origdata;
4017 for (n = 0; n < count; n++)
4018 *mb++ = (
double)(*ma++);
4081 *value = (uint64_t *)origdata;
4089 "TIFFReadDirEntryIfd8Array");
4103 ma = (uint32_t *)origdata;
4105 for (n = 0; n < count; n++)
4109 *mb++ = (uint64_t)(*ma++);
4164 tif,
"TIFFReadDirEntryPersampleShort",
4165 "Tag %s entry count is %" PRIu64
4166 " , whereas it should be SamplesPerPixel=%d. Assuming that "
4167 "missing entries are all at the value of the first one",
4174 "Tag %s entry count is %" PRIu64
4175 " , whereas it should be SamplesPerPixel=%d. "
4176 "Ignoring extra entries",
4193 if (*na++ != *value)
4431 assert(
sizeof(
double) == 8);
4432 assert(
sizeof(uint64_t) == 8);
4433 assert(
sizeof(uint32_t) == 4);
4451 if (m.
i[0] == 0 || m.
i[1] == 0)
4454 *value = (double)m.
i[0] / (
double)m.
i[1];
4484 assert(
sizeof(
double) == 8);
4485 assert(
sizeof(uint64_t) == 8);
4486 assert(
sizeof(int32_t) == 4);
4487 assert(
sizeof(uint32_t) == 4);
4505 if ((int32_t)m.
i[0] == 0 || m.
i[1] == 0)
4508 *value = (double)((int32_t)m.
i[0]) / (
double)m.
i[1];
4540 assert(
sizeof(
double) == 8);
4541 assert(
sizeof(uint64_t) == 8);
4542 assert(
sizeof(uint32_t) == 4);
4569 value->
uNum = m.
i[0];
4599 assert(
sizeof(
float) == 4);
4600 assert(
sizeof(uint32_t) == 4);
4601 assert(
sizeof(float_union) == 4);
4602 float_union.i = *(uint32_t *)(&direntry->
tdir_offset);
4603 *value = float_union.f;
4631 assert(
sizeof(
double) == 8);
4632 assert(
sizeof(uint64_t) == 8);
4648 *value = uint64_union.
d;
4712 if ((value < 0) || (value > 0xFF))
4754 if ((value < 0) || (value > 0xFF))
4796 if ((value < 0) || (value > 0xFF))
4859 if ((value < -0x80) || (value > 0x7F))
4901 if ((value < -0x80) || (value > 0x7F))
4943 if ((value < -0x80) || (value > 0x7F))
5027 if ((value < 0) || (value > 0xFFFF))
5069 if ((value < 0) || (value > 0xFFFF))
5132 if ((value < -0x8000) || (value > 0x7FFF))
5174 if ((value < -0x8000) || (value > 0x7FFF))
5258 if (value > UINT32_MAX)
5279 if ((value < 0) || (value > (int64_t)UINT32_MAX))
5300 if (value > 0x7FFFFFFFUL)
5322 if (value > 0x7FFFFFFF)
5345 if ((value < 0 - ((int64_t)0x7FFFFFFF + 1)) || (value > 0x7FFFFFFF))
5450 if (value > INT64_MAX)
5481 if (!
SeekOK(tif, offset))
5483 if (!
ReadOK(tif, dest, size))
5489 ma = (size_t)offset;
5490 if ((uint64_t)ma != offset || ma > (~(size_t)0) - (size_t)size)
5494 mb = (uint64_t)ma + (uint64_t)size;
5520 const char *module,
const char *
tagname,
5536 TIFFErrorExtR(tif, module,
"IO error during reading of \"%s\"",
5546 "Cannot handle different values per sample for \"%s\"",
5551 "Sanity check on size of \"%s\" value failed",
5555 TIFFErrorExtR(tif, module,
"Out of memory reading of \"%s\"",
5570 "Incorrect count for \"%s\"; tag ignored",
5575 "Incompatible type for \"%s\"; tag ignored",
5581 "IO error during reading of \"%s\"; tag ignored",
tagname);
5585 "Incorrect value for \"%s\"; tag ignored",
5590 "Cannot handle different values per sample for "
5591 "\"%s\"; tag ignored",
5597 "Sanity check on size of \"%s\" value failed; tag ignored",
5602 "Out of memory reading of \"%s\"; tag ignored",
5632 switch (photometric)
5697 if (offset <= filesize && bytecount > filesize - offset)
5707 if (bytecount < scanlinesize * tif->tif_dir.td_imagelength)
5735 const uint64_t data_width =
5737 if (data_width != 0 && dp->
tdir_count > UINT64_MAX / data_width)
5740 "Too large IFD data size");
5743 const uint64_t datalength = dp->
tdir_count * data_width;
5749 "Too large IFD data size");
5762 .
offset = (uint64_t)offset;
5849 uint64_t IFDendoffset;
5851 IFDendoffset = tif->
tif_diroff + 2 + (uint64_t)dircount * 12 + 4;
5853 IFDendoffset = tif->
tif_diroff + 8 + (uint64_t)dircount * 20 + 8;
5864 if (offset == IFDendoffset)
5869 else if (offset == IFDendoffset + 1)
5893 if (offset == IFDendoffset)
5913 static const char module[] = "TIFFReadDirectory";
5921 int bitspersample_read =
FALSE;
5951 "Failed to read directory at offset %" PRIu64,
5972 for (ma = dir, mb = 0; mb < dircount; ma++, mb++)
5976 for (na = ma + 1, nb = (uint16_t)(mb + 1); nb < dircount;
5990 tif->
tif_flags &= ~TIFF_CHOPPEDUPARRAYS;
5997 tif->
tif_flags &= ~TIFF_LAZYSTRILELOAD_DONE;
6019 "Failed to allocate memory for counting IFD data size at reading");
6087 for (di = 0, dp = dir; di < dircount; di++, dp++)
6097 "Unknown field with tag %" PRIu16
6098 " (0x%" PRIx16
") encountered",
6109 "Registering anonymous field with tag %" PRIu16
6110 " (0x%" PRIx16
") failed",
6180 "Planarconfig tag value assumed incorrect, "
6181 "assuming data is contig instead of chunky");
6197 for (di = 0, dp = dir; di < dircount; di++, dp++)
6232 fip ? fip->
field_name :
"unknown tagname", 0);
6238 bitspersample_read =
TRUE;
6245 double *data = NULL;
6247 uint32_t saved_flags;
6261 fip ? fip->
field_name :
"unknown tagname", 0);
6291 tif, module,
"Invalid data type for tag %s",
6320 tif, module,
"Invalid data type for tag %s",
6335 uint32_t countpersample;
6336 uint32_t countrequired;
6337 uint32_t incrementpersample;
6338 uint16_t *value = NULL;
6346 if (!bitspersample_read)
6351 "Ignoring %s since BitsPerSample tag not found",
6363 "Ignoring %s because BitsPerSample=%" PRIu16
">24",
6370 (dp->
tdir_count == (uint64_t)countpersample))
6372 countrequired = countpersample;
6373 incrementpersample = 0;
6377 countrequired = 3 * countpersample;
6378 incrementpersample = countpersample;
6380 if (dp->
tdir_count != (uint64_t)countrequired)
6391 fip ? fip->
field_name :
"unknown tagname", 1);
6396 value + incrementpersample,
6397 value + 2 * incrementpersample);
6440 err = TIFFReadDirEntryCheckedRationalDirect(
6453 snprintf(szAux,
sizeof(szAux) - 1,
"%d/%d",
6465 "Invalid data type for tag %s. "
6466 "ASCII or RATIONAL expected",
6468 :
"unknown tagname");
6505 "Photometric tag is missing, assuming data is YCbCr");
6513 "Photometric tag value assumed incorrect, "
6514 "assuming data is YCbCr instead of RGB");
6520 "BitsPerSample tag is missing, assuming 8 bits per sample");
6529 "SamplesPerPixel tag is missing, "
6530 "assuming correct SamplesPerPixel value is 3");
6537 "SamplesPerPixel tag is missing, "
6538 "applying correct SamplesPerPixel value of 3");
6575 TIFFErrorExtR(tif, module,
"Cannot handle zero number of %s",
6576 isTiled(tif) ?
"tiles" :
"strips");
6646 if (color_channels &&
6650 uint16_t old_extrasamples;
6651 uint16_t *new_sampleinfo;
6655 "Sum of Photometric type-related "
6656 "color channels and ExtraSamples doesn't match SamplesPerPixel. "
6657 "Defining non-color channels as ExtraSamples.");
6667 if (!new_sampleinfo)
6670 "Failed to allocate memory for "
6671 "temporary new sampleinfo array "
6672 "(%" PRIu16
" 16 bit elements)",
6677 if (old_extrasamples > 0)
6679 old_extrasamples *
sizeof(uint16_t));
6730 "TIFF directory is missing required "
6731 "\"StripByteCounts\" field, calculating from imagelength");
6745 "Bogus \"StripByteCounts\" field, ignoring and "
6746 "calculating from imagelength");
6770 "Wrong \"StripByteCounts\" field, ignoring and "
6771 "calculating from imagelength");
6790#ifdef STRIPBYTECOUNTSORTED_UNUSED
6800 tif->
tif_dir.td_stripbytecountsorted = 1;
6806 tif->
tif_dir.td_stripbytecountsorted = 0;
6858 TIFFErrorExtR(tif, module,
"Cannot handle zero scanline size");
6875 TIFFErrorExtR(tif, module,
"Cannot handle zero strip size");
6901 static const char module[] = "TIFFReadDirectoryCheckOrder";
6906 for (n = 0, o = dir; n < dircount; n++, o++)
6911 "Invalid TIFF directory; tags are not sorted in "
6940 for (m = dir, n = 0; n < dircount; m++, n++)
6992 *fii = (uint32_t)mb;
7002 static const char module[] = "TIFFReadCustomDirectory";
7010 assert(infoarray != NULL);
7015 "Failed to read custom directory at offset %" PRIu64,
7028 for (ma = dir, mb = 0; mb < dircount; ma++, mb++)
7032 for (na = ma + 1, nb = (uint16_t)(mb + 1); nb < dircount;
7064 "Failed to allocate memory for counting IFD data size at reading");
7070 for (di = 0, dp = dir; di < dircount; di++, dp++)
7106 for (uint32_t k = 0; k < default_fields->
count; k++)
7147 "Unknown field with tag %" PRIu16
7148 " (0x%" PRIx16
") encountered",
7160 "Registering anonymous field with tag %" PRIu16
7161 " (0x%" PRIx16
") failed",
7206 "Wrong data type %" PRIu16
7207 " for \"%s\"; tag ignored",
7302 static const char module[] = "EstimateStripByteCounts";
7312 const uint64_t allocsize = (uint64_t)td->
td_nstrips *
sizeof(uint64_t);
7313 uint64_t filesize = 0;
7314 if (allocsize > 100 * 1024 * 1024)
7319 if (allocsize > filesize)
7323 "Requested memory size for StripByteCounts of %" PRIu64
7324 " is greater than filesize %" PRIu64
". Memory not allocated",
7325 allocsize, filesize);
7333 tif, td->
td_nstrips,
sizeof(uint64_t),
"for \"StripByteCounts\" array");
7343 (
unsigned long)dircount * 12 + 4;
7346 sizeof(
TIFFHeaderBig) + 8 + (
unsigned long)dircount * 20 + 8;
7348 for (dp = dir, n = dircount; n > 0; n--, dp++)
7357 "Cannot determine size of unknown tag type %" PRIu16,
7361 if (dp->tdir_count > UINT64_MAX / typewidth)
7363 datasize = (uint64_t)typewidth * dp->tdir_count;
7374 if (space > UINT64_MAX - datasize)
7380 if (filesize < space)
7384 space = filesize - space;
7387 for (strip = 0; strip < td->
td_nstrips; strip++)
7419 for (strip = 0; strip < td->
td_nstrips; strip++)
7426 for (strip = 0; strip < td->
td_nstrips; strip++)
7428 if (rowbytes > 0 && rowsperstrip > UINT64_MAX / rowbytes)
7451 static const char module[] = "MissingRequired";
7454 "TIFF directory is missing required \"%s\" field",
tagname);
7473 const uint32_t hash = (uint32_t)(offsetAndDirNumber->
offset >> 32) ^
7474 ((uint32_t)offsetAndDirNumber->
offset & 0xFFFFFFFFU);
7497 return offsetAndDirNumber1->
offset == offsetAndDirNumber2->
offset;
7563 "Insertion in tif_map_dir_offset_to_number failed");
7569 "Insertion in tif_map_dir_number_to_offset failed");
7573 "Rollback of directory tracking entry failed");
7592 "Not enough memory");
7606 "Not enough memory");
7632 "TIFF directory %d has IFD looping to directory %u "
7633 "at offset 0x%" PRIx64
" (%" PRIu64
")",
7634 (
int)dirn - 1, foundEntry->
dirNumber, diroff,
7646 if (foundEntry->
offset != diroff)
7673 if (entryPtr == NULL)
7694 "Cannot handle more than %u TIFF directories",
7701 if (entryPtr == NULL)
7704 "Cannot allocate directory tracking entry");
7771 *diroff = foundEntry->
offset;
7784 entryOld.
offset = diroff;
7793 if (foundEntryOldOff)
7801 if (foundEntryOldDir)
7812 TIFFErrorExtR(tif,
"_TIFFRemoveEntryFromDirectoryListByOffset",
7813 "Unexpectedly tif_map_dir_number_to_offset is "
7814 "missing but tif_map_dir_offset_to_number exists.");
7845 "incorrect count for field \"%s\" (%" PRIu64
7846 ", expecting %" PRIu32
"); tag ignored",
7855 "incorrect count for field \"%s\" (%" PRIu64
7856 ", expecting %" PRIu32
"); tag trimmed",
7898 static const char module[] = "TIFFFetchDirectory";
7901 uint16_t dircount16;
7918 "%s: Seek error accessing TIFF directory",
7924 if (!
ReadOK(tif, &dircount16,
sizeof(uint16_t)))
7927 "%s: Can not read TIFF directory count",
7933 if (dircount16 > 4096)
7936 "Sanity check on directory count failed, this is "
7937 "probably not a valid IFD offset");
7944 uint64_t dircount64;
7945 if (!
ReadOK(tif, &dircount64,
sizeof(uint64_t)))
7948 "%s: Can not read TIFF directory count",
7954 if (dircount64 > 4096)
7957 "Sanity check on directory count failed, this is "
7958 "probably not a valid IFD offset");
7961 dircount16 = (uint16_t)dircount64;
7965 "to read TIFF directory");
7966 if (origdir == NULL)
7970 TIFFErrorExtR(tif, module,
"%.100s: Can not read TIFF directory",
7983 uint32_t nextdiroff32;
7984 if (!
ReadOK(tif, &nextdiroff32,
sizeof(uint32_t)))
7988 *nextdiroff = nextdiroff32;
7992 if (!
ReadOK(tif, nextdiroff,
sizeof(uint64_t)))
8005 TIFFErrorExtR(tif, module,
"Can not read TIFF directory count");
8021 m = (
tmsize_t)((uint64_t)off +
sizeof(uint16_t));
8022 if ((m < off) || ((uint64_t)m <
sizeof(uint16_t)) ||
8023 ((uint64_t)m > (uint64_t)tif->
tif_size))
8025 TIFFErrorExtR(tif, module,
"Can not read TIFF directory count");
8032 off = (
tmsize_t)((uint64_t)off +
sizeof(uint16_t));
8035 if (dircount16 > 4096)
8038 "Sanity check on directory count failed, this is "
8039 "probably not a valid IFD offset");
8046 uint64_t dircount64;
8047 m = (
tmsize_t)((uint64_t)off +
sizeof(uint64_t));
8048 if ((m < off) || ((uint64_t)m <
sizeof(uint64_t)) ||
8049 ((uint64_t)m > (uint64_t)tif->
tif_size))
8051 TIFFErrorExtR(tif, module,
"Can not read TIFF directory count");
8058 off = (
tmsize_t)((uint64_t)off +
sizeof(uint64_t));
8061 if (dircount64 > 4096)
8064 "Sanity check on directory count failed, this is "
8065 "probably not a valid IFD offset");
8068 dircount16 = (uint16_t)dircount64;
8071 if (dircount16 == 0)
8074 "Sanity check on directory count failed, zero tag "
8075 "directories not supported");
8081 uint64_t allocsize = (uint64_t)dircount16 * dirsize;
8082 if (allocsize > filesize)
8086 "Requested memory size for TIFF directory of %" PRIu64
8087 " is greater than filesize %" PRIu64
8088 ". Memory not allocated, TIFF directory not read",
8089 allocsize, filesize);
8093 "to read TIFF directory");
8094 if (origdir == NULL)
8096 m = off + dircount16 * dirsize;
8111 off += dircount16 * dirsize;
8114 uint32_t nextdiroff32;
8115 m = (
tmsize_t)((uint64_t)off +
sizeof(uint32_t));
8116 if ((m < off) || ((uint64_t)m <
sizeof(uint32_t)) ||
8117 ((uint64_t)m > (uint64_t)tif->
tif_size))
8124 *nextdiroff = nextdiroff32;
8128 m = (
tmsize_t)((uint64_t)off +
sizeof(uint64_t));
8129 if ((m < off) || ((uint64_t)m <
sizeof(uint64_t)) ||
8130 ((uint64_t)m > (uint64_t)tif->
tif_size))
8143 tif, dircount16,
sizeof(
TIFFDirEntry),
"to read TIFF directory");
8149 ma = (uint8_t *)origdir;
8151 for (n = 0; n < dircount16; n++)
8157 ma +=
sizeof(uint16_t);
8161 ma +=
sizeof(uint16_t);
8166 mb->
tdir_count = (uint64_t)(*(uint32_t *)ma);
8167 ma +=
sizeof(uint32_t);
8169 *(uint32_t *)(&mb->
tdir_offset) = *(uint32_t *)ma;
8170 ma +=
sizeof(uint32_t);
8177 ma +=
sizeof(uint64_t);
8179 ma +=
sizeof(uint64_t);
8219 static const char module[] = "TIFFFetchNormalTag";
8227 "No definition found for tag %" PRIu16, dp->
tdir_tag);
8231 assert(fip != NULL);
8243 tif,
"TIFFFetchNormalTag",
8244 "Defined set_get_field_type of custom tag %u (%s) is "
8245 "TIFF_SETGET_UNDEFINED and thus tag is not read from file",
8263 mb = strlen((
const char *)data);
8289 "ASCII value for tag \"%s\" contains null byte in "
8290 "value; value incorrectly truncated during reading due "
8291 "to implementation limitations",
8296 "ASCII value for tag \"%s\" does not end "
8297 "in null byte. Forcing it to be null",
8488 "incorrect count for field \"%s\", expected 2, "
8513 "incorrect count for field \"%s\", expected "
8548 "incorrect count for field \"%s\", expected "
8583 "incorrect count for field \"%s\", expected "
8618 "incorrect count for field \"%s\", expected "
8653 "incorrect count for field \"%s\", expected "
8688 "incorrect count for field \"%s\", expected "
8723 "incorrect count for field \"%s\", expected "
8758 "incorrect count for field \"%s\", expected "
8793 "incorrect count for field \"%s\", expected "
8830 "incorrect count for field \"%s\", expected "
8865 "incorrect count for field \"%s\", expected "
8915 "ASCII value for ASCII array tag "
8916 "\"%s\" does not end in null "
8917 "byte. Forcing it to be null",
9287 "ASCII value for ASCII array tag \"%s\" does not end "
9288 "in null byte. Forcing it to be null",
9340 data = (uint8_t *)origdata;
9341 count = (uint32_t)(count * 4);
9368 int8_t *data = NULL;
9416 int16_t *data = NULL;
9464 int32_t *data = NULL;
9512 int64_t *data = NULL;
9654 static const char module[] = "TIFFFetchStripThing";
9662 fip ? fip->
field_name :
"unknown tagname", 0);
9667 uint64_t *resizeddata;
9669 const char *pszMax = getenv(
"LIBTIFF_STRILE_ARRAY_MAX_RESIZE_COUNT");
9670 uint32_t max_nstrips = 1000000;
9675 (nstrips <= max_nstrips));
9677 if (nstrips > max_nstrips)
9683 const uint64_t allocsize = (uint64_t)nstrips *
sizeof(uint64_t);
9684 if (allocsize > 100 * 1024 * 1024)
9690 if (allocsize > filesize)
9694 "Requested memory size for StripArray of %" PRIu64
9695 " is greater than filesize %" PRIu64
9696 ". Memory not allocated",
9697 allocsize, filesize);
9703 tif, nstrips,
sizeof(uint64_t),
"for strip array");
9704 if (resizeddata == 0)
9744 static const char module[] = "TIFFFetchSubjectDistance";
9748 assert(
sizeof(
double) == 8);
9749 assert(
sizeof(uint64_t) == 8);
9750 assert(
sizeof(uint32_t) == 4);
9778 else if (m.
i[0] == 0xFFFFFFFF || m.
i[1] == 0)
9786 n = (double)m.
i[0] / (
double)m.
i[1];
9817 uint64_t stripbytes,
9818 uint32_t rowsperstrip)
9823 uint64_t last_offset;
9824 uint64_t last_bytecount;
9826 uint64_t *newcounts;
9827 uint64_t *newoffsets;
9832 if (last_offset > UINT64_MAX - last_bytecount ||
9833 last_offset + last_bytecount < offset)
9837 bytecount = last_offset + last_bytecount - offset;
9843 const uint64_t allocsize = (uint64_t)nstrips *
sizeof(uint64_t) * 2;
9844 if (allocsize > 100 * 1024 * 1024)
9847 if (allocsize > filesize)
9850 "Requested memory size for StripByteCount and "
9851 "StripOffsets %" PRIu64
9852 " is greater than filesize %" PRIu64
9853 ". Memory not allocated",
9854 allocsize, filesize);
9861 "for chopped \"StripByteCounts\" array");
9863 tif, nstrips,
sizeof(uint64_t),
"for chopped \"StripOffsets\" array");
9864 if (newcounts == NULL || newoffsets == NULL)
9870 if (newcounts != NULL)
9872 if (newoffsets != NULL)
9881 for (i = 0; i < nstrips; i++)
9883 if (stripbytes > bytecount)
9884 stripbytes = bytecount;
9885 newcounts[i] = stripbytes;
9886 newoffsets[i] = stripbytes ? offset : 0;
9887 offset += stripbytes;
9888 bytecount -= stripbytes;
9901#ifdef STRIPBYTECOUNTSORTED_UNUSED
9902 td->td_stripbytecountsorted = 1;
9935 uint64_t rowblockbytes;
9936 uint64_t stripbytes;
9938 uint32_t rowsperstrip;
9944 if (bytecount == 0 && tif->
tif_mode != O_RDONLY)
9959 stripbytes = rowblockbytes;
9960 rowsperstrip = rowblock;
9962 else if (rowblockbytes > 0)
9964 uint32_t rowblocksperstrip;
9966 rowsperstrip = rowblocksperstrip * rowblock;
9967 stripbytes = rowblocksperstrip * rowblockbytes;
9983 if (tif->
tif_mode == O_RDONLY && nstrips > 1000000 &&
10018 uint64_t rowblockbytes;
10020 uint64_t stripsize;
10021 uint32_t rowblocksperstrip;
10022 uint32_t rowsperstrip;
10023 uint64_t stripbytes;
10032 assert(stripsize > 0x7FFFFFFFUL);
10045 if (rowblockbytes == 0 || rowblockbytes > 0x7FFFFFFFUL)
10079 rowblocksperstrip = (uint32_t)(512 * 1024 * 1024 / rowblockbytes);
10080 if (rowblocksperstrip == 0)
10081 rowblocksperstrip = 1;
10082 rowsperstrip = rowblocksperstrip * rowblock;
10083 stripbytes = rowblocksperstrip * rowblockbytes;
10084 assert(stripbytes <= 0x7FFFFFFFUL);
10086 if (rowsperstrip == 0)
10094 if (tif->
tif_mode == O_RDONLY && nstrips > 1000000)
10098 uint64_t last_bytecount =
10100 if (last_offset > filesize || last_bytecount > filesize - last_offset)
10125 return a + (uint64_t)b;
10165 int strile, uint64_t *panVals)
10167 static const char module[] = "_TIFFPartialReadStripArray";
10168#define IO_CACHE_PAGE_SIZE 4096
10173 uint64_t nBaseOffset;
10175 uint64_t nOffsetStartPage;
10176 uint64_t nOffsetEndPage;
10179 uint64_t nLastStripOffset;
10189 sizeofval =
sizeof(uint16_t);
10193 sizeofval =
sizeof(uint32_t);
10197 sizeofval =
sizeof(uint64_t);
10203 sizeofval =
sizeof(int64_t);
10208 "Invalid type for [Strip|Tile][Offset/ByteCount] tag");
10209 panVals[strile] = 0;
10212 sizeofvalint = (int)(sizeofval);
10219 nBaseOffset = offset;
10226 nBaseOffset = offset;
10229 if (nBaseOffset > (uint64_t)INT64_MAX)
10231 TIFFErrorExtR(tif, module,
"Cannot read offset/size for strile %d",
10233 panVals[strile] = 0;
10236 nOffset = nBaseOffset + (uint64_t)sizeofval * (uint64_t)strile;
10240 if (nOffset + sizeofval > nOffsetEndPage)
10242#undef IO_CACHE_PAGE_SIZE
10244 nLastStripOffset = nBaseOffset + (uint64_t)arraySize * sizeofval;
10245 if (nLastStripOffset < nOffsetEndPage)
10246 nOffsetEndPage = nLastStripOffset;
10247 if (nOffsetStartPage >= nOffsetEndPage)
10249 TIFFErrorExtR(tif, module,
"Cannot read offset/size for strile %d",
10251 panVals[strile] = 0;
10254 if (!
SeekOK(tif, nOffsetStartPage))
10256 panVals[strile] = 0;
10260 nToRead = (
tmsize_t)(nOffsetEndPage - nOffsetStartPage);
10262 if (nRead < nToRead)
10265 "Cannot read offset/size for strile around ~%d", strile);
10268 iStartBefore = -(int)((nOffset - nOffsetStartPage) / sizeofval);
10269 if (strile + iStartBefore < 0)
10270 iStartBefore = -strile;
10271 for (i = iStartBefore;
10272 (uint32_t)(strile + i) < arraySize &&
10281 buffer + (nOffset - nOffsetStartPage) + i * sizeofvalint,
10285 panVals[strile + i] = val;
10291 buffer + (nOffset - nOffsetStartPage) + i * sizeofvalint,
10295 panVals[strile + i] = val;
10301 buffer + (nOffset - nOffsetStartPage) + i * sizeofvalint,
10305 panVals[strile + i] = val;
10312 buffer + (nOffset - nOffsetStartPage) + i * sizeofvalint,
10316 panVals[strile + i] = (uint64_t)val;
10378 static const char module[] = "_TIFFFetchStrileValue";
10384 if (strile >= td->td_stripoffsetbyteallocsize)
10387 uint32_t nStripArrayAllocNew;
10388 uint64_t nArraySize64;
10390 uint64_t *offsetArray;
10391 uint64_t *bytecountArray;
10393 if (strile > 1000000)
10399 if (strile > filesize /
sizeof(uint32_t))
10406 if (td->td_stripoffsetbyteallocsize == 0 &&
10407 td->td_nstrips < 1024 * 1024)
10409 nStripArrayAllocNew = td->td_nstrips;
10413#define TIFF_MAX(a, b) (((a) > (b)) ? (a) : (b))
10414#define TIFF_MIN(a, b) (((a) < (b)) ? (a) : (b))
10415 nStripArrayAllocNew =
TIFF_MAX(strile + 1, 1024U * 512U);
10416 if (nStripArrayAllocNew < 0xFFFFFFFFU / 2)
10417 nStripArrayAllocNew *= 2;
10418 nStripArrayAllocNew =
TIFF_MIN(nStripArrayAllocNew, td->td_nstrips);
10420 assert(strile < nStripArrayAllocNew);
10421 nArraySize64 = (uint64_t)
sizeof(uint64_t) * nStripArrayAllocNew;
10422 nArraySize = (size_t)(nArraySize64);
10423#if SIZEOF_SIZE_T == 4
10424 if (nArraySize != nArraySize64)
10427 "Cannot allocate strip offset and bytecount arrays");
10431 offsetArray = (uint64_t *)(
_TIFFreallocExt(tif, td->td_stripoffset_p,
10434 tif, td->td_stripbytecount_p, (
tmsize_t)nArraySize));
10436 td->td_stripoffset_p = offsetArray;
10437 if (bytecountArray)
10438 td->td_stripbytecount_p = bytecountArray;
10439 if (offsetArray && bytecountArray)
10441 td->td_stripoffsetbyteallocsize = nStripArrayAllocNew;
10444 memset(td->td_stripoffset_p + nStripArrayAllocBefore, 0xFF,
10445 (td->td_stripoffsetbyteallocsize - nStripArrayAllocBefore) *
10448 memset(td->td_stripbytecount_p + nStripArrayAllocBefore, 0xFF,
10449 (td->td_stripoffsetbyteallocsize - nStripArrayAllocBefore) *
10455 "Cannot allocate strip offset and bytecount arrays");
10457 td->td_stripoffset_p = NULL;
10459 td->td_stripbytecount_p = NULL;
10460 td->td_stripoffsetbyteallocsize = 0;
10463 if (*parray == NULL || strile >= td->td_stripoffsetbyteallocsize)
10466 if (~((*parray)[strile]) == 0)
10470 (*parray)[strile] = 0;
10525 "Inconsistent directory count between StripOffsets and "
10526 "StripByteCounts");
10559 if (*parray == NULL)
10565 return (*parray)[strile];
10628 int return_value = 1;
10661 if (loadStripByteCount &&
10671#ifdef STRIPBYTECOUNTSORTED_UNUSED
10676 tif->
tif_dir.td_stripbytecountsorted = 1;
10682 tif->
tif_dir.td_stripbytecountsorted = 0;
10689 return return_value;
uint32_t _TIFFParseUInt32(const char *str, uint32_t default_value, uint32_t max_value)
Parse a decimal unsigned integer with a fallback value.
#define TIFF_MAX_DIR_COUNT
Limit the number of IFDs the library may traverse in a file.
#define STRIP_SIZE_DEFAULT
Define the default target strip size in bytes.
#define TIFF_SSIZE_FORMAT
Provide the printf conversion fragment for tmsize_t, without a percent sign.
int _TIFFRemoveEntryFromDirectoryListByOffset(TIFF *tif, uint64_t diroff)
Attempt to remove a shared directory-map entry by offset.
int _TIFFCheckDirNumberAndOffset(TIFF *tif, tdir_t dirn, uint64_t diroff)
Register or validate a chain index/offset pair for loop detection.
static bool insertOffsetAndDirNumber(TIFF *tif, TIFFOffsetAndDirNumber *entryPtr)
Add a directory-tracking record to both directory maps.
int _TIFFGetOffsetFromDirNumber(TIFF *tif, tdir_t dirn, uint64_t *diroff)
Resolve an index from the existing number-to-offset map.
static bool equalFuncNumberToOffset(const void *elt1, const void *elt2)
Compare directory-map records by directory index.
int _TIFFGetDirNumberFromOffset(TIFF *tif, uint64_t diroff, tdir_t *dirn)
Resolve a directory offset using the chain maps.
int TIFFDefaultDirectory(TIFF *tif)
Install the image schema, default values, and core tag methods.
static unsigned long hashFuncOffsetToNumber(const void *elt)
Hash a directory-map offset key.
static bool equalFuncOffsetToNumber(const void *elt1, const void *elt2)
Compare directory-map records by offset.
static unsigned long hashFuncNumberToOffset(const void *elt)
Hash a directory-map directory index key.
#define FIELD_STRIPOFFSETS
Index the strile offsets presence bit; not an on-disk tag number.
int _TIFFMergeFields(TIFF *tif, const TIFFField info[], uint32_t n)
Merge borrowed field definitions into the lookup table.
#define FIELD_IMAGEDIMENSIONS
Index the image dimensions presence bit; not an on-disk tag number.
TIFFField * _TIFFCreateAnonField(TIFF *tif, uint32_t tag, TIFFDataType field_type)
Allocate a counted anonymous field descriptor.
#define FIELD_COLORMAP
Index the colormap presence bit; not an on-disk tag number.
#define FIELD_IGNORE
Mark a processed-but-discarded tag; bit zero is reserved.
const TIFFFieldArray * _TIFFGetFields(void)
Return the built-in image field schema.
#define TIFFFieldSet(tif, field)
Test a directory presence bit.
#define FIELD_MAXSAMPLEVALUE
Index the maximum sample value presence bit; not an on-disk tag number.
#define FIELD_TILEDIMENSIONS
Index the tile dimensions presence bit; not an on-disk tag number.
#define FIELD_ROWSPERSTRIP
Index the rows per strip presence bit; not an on-disk tag number.
#define FIELD_STRIPBYTECOUNTS
Index the strile byte counts presence bit; not an on-disk tag number.
void _TIFFSetupFields(TIFF *tif, const TIFFFieldArray *fieldarray)
Replace the registered field-pointer table with a schema.
const TIFFFieldArray * _TIFFGetGpsFields(void)
Return the built-in GPS field schema.
int _TIFFCheckFieldIsValidForCodec(TIFF *tif, ttag_t tag)
Filter recognised codec-specific tags against current compression.
#define FIELD_BITSPERSAMPLE
Index the bits per sample presence bit; not an on-disk tag number.
#define TIFFSetFieldBit(tif, field)
Set a directory presence bit.
#define FIELD_SAMPLESPERPIXEL
Index the samples per pixel presence bit; not an on-disk tag number.
const TIFFFieldArray * _TIFFGetExifFields(void)
Return the built-in EXIF field schema.
#define FIELD_PHOTOMETRIC
Index the photometric presence bit; not an on-disk tag number.
@ TIFF_SETGET_C16_UINT8
Unsigned 8-bit array with 16-bit explicit count.
@ TIFF_SETGET_C0_SINT64
Signed 64-bit array with implicit count.
@ TIFF_SETGET_DOUBLE
Double scalar storage.
@ TIFF_SETGET_SINT64
Signed 64-bit scalar storage.
@ TIFF_SETGET_C32_SINT32
Signed 32-bit array with 32-bit explicit count.
@ TIFF_SETGET_C16_FLOAT
Float array with 16-bit explicit count.
@ TIFF_SETGET_UNDEFINED
Unsupported or unspecified argument representation.
@ TIFF_SETGET_SINT8
Signed 8-bit scalar storage.
@ TIFF_SETGET_C32_ASCII
Character array with 32-bit explicit count.
@ TIFF_SETGET_INT
Promoted int scalar representation.
@ TIFF_SETGET_C32_UINT8
Unsigned 8-bit array with 32-bit explicit count.
@ TIFF_SETGET_IFD8
64-bit directory-offset scalar storage.
@ TIFF_SETGET_C32_UINT16
Unsigned 16-bit array with 32-bit explicit count.
@ TIFF_SETGET_C16_DOUBLE
Double array with 16-bit explicit count.
@ TIFF_SETGET_UINT64
Unsigned 64-bit scalar storage.
@ TIFF_SETGET_C0_UINT32
Unsigned 32-bit array with implicit count.
@ TIFF_SETGET_C16_UINT32
Unsigned 32-bit array with 16-bit explicit count.
@ TIFF_SETGET_UINT16_PAIR
Two separate promoted uint16_t values / uint16_t output slots.
@ TIFF_SETGET_C32_SINT16
Signed 16-bit array with 32-bit explicit count.
@ TIFF_SETGET_C16_UINT16
Unsigned 16-bit array with 16-bit explicit count.
@ TIFF_SETGET_C16_SINT64
Signed 64-bit array with 16-bit explicit count.
@ TIFF_SETGET_C0_FLOAT
Float array with implicit count.
@ TIFF_SETGET_C0_SINT32
Signed 32-bit array with implicit count.
@ TIFF_SETGET_C16_UINT64
Unsigned 64-bit array with 16-bit explicit count.
@ TIFF_SETGET_C32_UINT32
Unsigned 32-bit array with 32-bit explicit count.
@ TIFF_SETGET_C0_ASCII
Character array with implicit count.
@ TIFF_SETGET_C32_SINT8
Signed 8-bit array with 32-bit explicit count.
@ TIFF_SETGET_UINT16
Unsigned 16-bit scalar storage.
@ TIFF_SETGET_C16_SINT16
Signed 16-bit array with 16-bit explicit count.
@ TIFF_SETGET_C0_UINT8
Unsigned 8-bit array with implicit count.
@ TIFF_SETGET_ASCII
Null-terminated string representation.
@ TIFF_SETGET_C0_SINT8
Signed 8-bit array with implicit count.
@ TIFF_SETGET_C16_SINT8
Signed 8-bit array with 16-bit explicit count.
@ TIFF_SETGET_OTHER
Tag-specific calling convention outside the regular encodings.
@ TIFF_SETGET_C0_UINT64
Unsigned 64-bit array with implicit count.
@ TIFF_SETGET_FLOAT
Float scalar storage.
@ TIFF_SETGET_C16_SINT32
Signed 32-bit array with 16-bit explicit count.
@ TIFF_SETGET_SINT16
Signed 16-bit scalar storage.
@ TIFF_SETGET_C0_SINT16
Signed 16-bit array with implicit count.
@ TIFF_SETGET_C32_IFD8
64-bit directory-offset array with 32-bit explicit count.
@ TIFF_SETGET_UINT32
Unsigned 32-bit scalar storage.
@ TIFF_SETGET_C32_SINT64
Signed 64-bit array with 32-bit explicit count.
@ TIFF_SETGET_C16_ASCII
Character array with 16-bit explicit count.
@ TIFF_SETGET_C32_DOUBLE
Double array with 32-bit explicit count.
@ TIFF_SETGET_UINT8
Unsigned 8-bit scalar storage.
@ TIFF_SETGET_C0_UINT16
Unsigned 16-bit array with implicit count.
@ TIFF_SETGET_C32_UINT64
Unsigned 64-bit array with 32-bit explicit count.
@ TIFF_SETGET_C0_IFD8
64-bit directory-offset array with implicit count.
@ TIFF_SETGET_C16_IFD8
64-bit directory-offset array with 16-bit explicit count.
@ TIFF_SETGET_SINT32
Signed 32-bit scalar storage.
@ TIFF_SETGET_C32_FLOAT
Float array with 32-bit explicit count.
@ TIFF_SETGET_C0_DOUBLE
Double array with implicit count.
void * TIFFHashSetLookup(TIFFHashSet *set, const void *elt)
Find a borrowed stored element matching a key.
bool TIFFHashSetInsert(TIFFHashSet *set, void *elt)
Insert an element or replace an equal element.
bool TIFFHashSetRemove(TIFFHashSet *set, const void *elt)
Remove a matching element, disposing it if configured.
int TIFFHashSetSize(const TIFFHashSet *set)
Return the current live-element count.
TIFFHashSet * TIFFHashSetNew(TIFF *tif, TIFFHashSetHashFunc fnHashFunc, TIFFHashSetEqualFunc fnEqualFunc, TIFFHashSetFreeEltFunc fnFreeEltFunc)
Allocate an empty hash set with optional ownership callbacks.
#define FAILED_FII
Represent a missing field-table index with UINT32_MAX.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedLong8(TIFF *tif, TIFFDirEntry *direntry, uint64_t *value)
Read a prevalidated uint64_t value.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSrational(TIFF *tif, TIFFDirEntry *direntry, double *value)
Read a prevalidated srational value.
static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array(TIFF *tif, TIFFDirEntry *direntry, int64_t **value)
Read a directory array as int64_t elements.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong(uint32_t value)
Check whether uint32_t fits int16_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryShort(TIFF *tif, TIFFDirEntry *direntry, uint16_t *value)
Convert one directory value to uint16_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Sbyte(int8_t value)
Check whether int8_t fits uint64_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong(uint32_t value)
Check whether uint32_t fits uint16_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Slong8(int64_t value)
Check whether int64_t fits uint64_t.
#define INITIAL_THRESHOLD
Start progressive external-tag reads at one MiB on 64-bit hosts.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong(uint32_t value)
Check whether uint32_t fits uint8_t.
static void TIFFReadDirEntryCheckedSlong(TIFF *tif, TIFFDirEntry *direntry, int32_t *value)
Read a prevalidated int32_t value.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSshort(int16_t value)
Check whether int16_t fits int8_t.
static void TIFFReadDirectoryFindFieldInfo(TIFF *tif, uint16_t tagid, uint32_t *fii)
Locate the first registered descriptor index for a tag.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSbyte(int8_t value)
Check whether int8_t fits uint16_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryArray(TIFF *tif, TIFFDirEntry *direntry, uint32_t *count, uint32_t desttypesize, void **value)
Fetch raw directory array bytes with checked size limits.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSshort(int16_t value)
Check whether int16_t fits uint16_t.
static void CalcFinalIFDdatasizeReading(TIFF *tif, uint16_t dircount)
Estimate the reusable contiguous span of the loaded IFD.
#define MAX_THRESHOLD
Set the progressive read threshold cutoff to 1000 MiB.
static void TIFFReadDirEntryCheckedShort(TIFF *tif, TIFFDirEntry *direntry, uint16_t *value)
Read a prevalidated uint16_t value.
static void TIFFReadDirectoryCheckOrder(TIFF *tif, TIFFDirEntry *dir, uint16_t dircount)
Warn if directory tags are not strictly increasing.
static uint64_t TIFFReadUInt64(const uint8_t *value)
Copy eight unaligned bytes into a native uint64_t value.
static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8ArrayWithLimit(TIFF *tif, TIFFDirEntry *direntry, uint64_t **value, uint64_t maxcount)
Read a directory array as uint64_t elements.
static int ByteCountLooksBad(TIFF *tif)
Test whether the first strip byte count needs recovery.
static enum TIFFReadDirEntryErr TIFFReadDirEntryDoubleArray(TIFF *tif, TIFFDirEntry *direntry, double **value)
Read a directory array as double elements.
static void TIFFReadDirEntryOutputErr(TIFF *tif, enum TIFFReadDirEntryErr err, const char *module, const char *tagname, int recover)
Report a directory-entry conversion error at the requested severity.
static enum TIFFReadDirEntryErr TIFFReadDirEntryArrayWithLimit(TIFF *tif, TIFFDirEntry *direntry, uint32_t *count, uint32_t desttypesize, void **value, uint64_t maxcount)
Fetch raw directory array bytes with checked size limits.
static TIFFDirEntry * TIFFReadDirectoryFindEntry(TIFF *tif, TIFFDirEntry *dir, uint16_t dircount, uint16_t tagid)
Find the first parsed entry with a given tag.
static enum TIFFReadDirEntryErr TIFFReadDirEntryFloat(TIFF *tif, TIFFDirEntry *direntry, float *value)
Convert one directory value to float.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteShort(uint16_t value)
Check whether uint16_t fits uint8_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteShort(uint16_t value)
Check whether uint16_t fits int8_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongSlong8(int64_t value)
Check whether int64_t fits int32_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyte(TIFF *tif, TIFFDirEntry *direntry, int8_t *value)
Convert one directory value to int8_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong(uint32_t value)
Check whether uint32_t fits int8_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryByte(TIFF *tif, TIFFDirEntry *direntry, uint8_t *value)
Convert one directory value to uint8_t.
TIFFReadDirEntryErr
Classify directory-entry decoding failures.
static void TIFFReadDirEntryCheckedByte(TIFF *tif, TIFFDirEntry *direntry, uint8_t *value)
Read a prevalidated uint8_t value.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong(int32_t value)
Check whether int32_t fits int16_t.
static bool EvaluateIFDdatasizeReading(TIFF *tif, TIFFDirEntry *dp)
Record the external byte range of one IFD entry.
static enum TIFFReadDirEntryErr TIFFReadDirEntryData(TIFF *tif, uint64_t offset, tmsize_t size, void *dest)
Copy a raw external byte range into caller storage.
static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8(TIFF *tif, TIFFDirEntry *direntry, int64_t *value)
Convert one directory value to int64_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong8(uint64_t value)
Check whether uint64_t fits uint8_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong(int32_t value)
Check whether int32_t fits uint32_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSbyte(int8_t value)
Check whether int8_t fits uint8_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongLong(uint32_t value)
Check whether uint32_t fits int32_t.
static int cmpTIFFEntryOffsetAndLength(const void *a, const void *b)
Order external IFD ranges by starting byte offset.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSbyte(int8_t value)
Check whether int8_t fits uint32_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryDataAndRealloc(TIFF *tif, uint64_t offset, tmsize_t size, void **pdest)
Grow an owned buffer while reading an external value.
static uint16_t TIFFFetchDirectory(TIFF *tif, uint64_t diroff, TIFFDirEntry **pdir, uint64_t *nextdiroff)
Fetch and normalise raw classic TIFF or BigTIFF entries.
static enum TIFFReadDirEntryErr TIFFReadDirEntryDouble(TIFF *tif, TIFFDirEntry *direntry, double *value)
Convert one directory value to double.
static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8Array(TIFF *tif, TIFFDirEntry *direntry, uint64_t **value)
Read a directory array as uint64_t elements.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong(int32_t value)
Check whether int32_t fits uint8_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSshort(int16_t value)
Check whether int16_t fits uint32_t.
static void TIFFReadDirEntryCheckedFloat(TIFF *tif, TIFFDirEntry *direntry, float *value)
Read a prevalidated float value.
static enum TIFFReadDirEntryErr TIFFReadDirEntryLong(TIFF *tif, TIFFDirEntry *direntry, uint32_t *value)
Convert one directory value to uint32_t.
#define THRESHOLD_MULTIPLIER
Grow progressive read requests by a factor of ten.
static int TIFFFetchNormalTag(TIFF *, TIFFDirEntry *, int recover)
Decode a parsed value according to its registered set/get representation.
static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF *tif, TIFFDirEntry *direntry, int8_t **value)
Read a directory array as int8_t elements.
static void MissingRequired(TIFF *, const char *)
Report an absent required image tag.
static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF *tif, TIFFDirEntry *direntry, uint16_t **value)
Read a directory array as uint16_t elements.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong(int32_t value)
Check whether int32_t fits int8_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong8(uint64_t value)
Check whether uint64_t fits uint16_t.
static void TIFFReadDirEntryCheckedSshort(TIFF *tif, TIFFDirEntry *direntry, int16_t *value)
Read a prevalidated int16_t value.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong(int32_t value)
Check whether int32_t fits uint16_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongLong8(uint64_t value)
Check whether uint64_t fits int32_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray(TIFF *tif, TIFFDirEntry *direntry, int16_t **value)
Read a directory array as int16_t elements.
static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray(TIFF *tif, TIFFDirEntry *direntry, int32_t **value)
Read a directory array as int32_t elements.
static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF *tif, TIFFDirEntry *direntry, float **value)
Read a directory array as float elements.
static void TIFFReadDirEntryCheckedSbyte(TIFF *tif, TIFFDirEntry *direntry, int8_t *value)
Read a prevalidated int8_t value.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong8(uint64_t value)
Check whether uint64_t fits int8_t.
static void TIFFReadDirEntryCheckedLong(TIFF *tif, TIFFDirEntry *direntry, uint32_t *value)
Read a prevalidated uint32_t value.
static int EstimateStripByteCounts(TIFF *tif, TIFFDirEntry *dir, uint16_t dircount)
Replace missing or suspect strile byte counts with estimates.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteByte(uint8_t value)
Check whether uint8_t fits int8_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong8(int64_t value)
Check whether int64_t fits int8_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong8(int64_t value)
Check whether int64_t fits int16_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongLong8(uint64_t value)
Check whether uint64_t fits uint32_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSlong8(TIFF *tif, TIFFDirEntry *direntry, int64_t *value)
Read a prevalidated int64_t value.
static int CheckDirCount(TIFF *, TIFFDirEntry *, uint32_t)
Validate or trim an entry to its expected count.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Slong(int32_t value)
Check whether int32_t fits uint64_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8(TIFF *tif, TIFFDirEntry *direntry, uint64_t *value)
Convert one directory value to uint64_t directory offset.
static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong(TIFF *tif, TIFFDirEntry *direntry, int32_t *value)
Convert one directory value to int32_t.
#define TIFFCvtIEEEDoubleToNative(tif, n, dp)
Recognise already compatible double storage without conversion.
enum TIFFReadDirEntryErr _TIFFReadDirEntryCheckedRational(TIFF *tif, TIFFDirEntry *direntry, double *value)
Read a prevalidated rational value.
static int _TIFFGetMaxColorChannels(uint16_t photometric)
Classify the expected maximum colour-channel count.
#define MAX_SIZE_TAG_DATA
Limit source and converted tag arrays to INT32_MAX bytes.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong8(uint64_t value)
Check whether uint64_t fits int16_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSshort(int16_t value)
Check whether int16_t fits uint8_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8(TIFF *tif, TIFFDirEntry *direntry, uint64_t *value)
Convert one directory value to uint64_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedDouble(TIFF *tif, TIFFDirEntry *direntry, double *value)
Read a prevalidated double value.
static int TIFFFetchSubjectDistance(TIFF *, TIFFDirEntry *)
Decode EXIF SubjectDistance with its special sentinel values.
static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8Array(TIFF *tif, TIFFDirEntry *direntry, uint64_t **value)
Read a directory array as uint64_t directory offset elements.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong8(int64_t value)
Check whether int64_t fits uint32_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortShort(uint16_t value)
Check whether uint16_t fits int16_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryLongArray(TIFF *tif, TIFFDirEntry *direntry, uint32_t **value)
Read a directory array as uint32_t elements.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong8(int64_t value)
Check whether int64_t fits uint8_t.
union _UInt64Aligned_t UInt64Aligned_t
Provide aligned scalar and byte views of eight raw bytes.
static enum TIFFReadDirEntryErr TIFFReadDirEntrySshort(TIFF *tif, TIFFDirEntry *direntry, int16_t *value)
Convert one directory value to int16_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong8(int64_t value)
Check whether int64_t fits uint16_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF *tif, TIFFDirEntry *direntry, uint8_t **value)
Read a directory array as uint8_t elements.
static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleShort(TIFF *tif, TIFFDirEntry *direntry, uint16_t *value)
Reduce equal per-sample short values to one scalar.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Sshort(int16_t value)
Check whether int16_t fits uint64_t.
static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlong8Long8(uint64_t value)
Check whether uint64_t fits int64_t.
#define TIFFCvtIEEEFloatToNative(tif, n, fp)
Recognise already compatible float storage without conversion.
@ TIFFReadDirEntryErrPsdif
Per-sample values differ where uniform values are required.
@ TIFFReadDirEntryErrIo
Mapped extent, seek, or read failure.
@ TIFFReadDirEntryErrRange
Value cannot be represented by the target integer type.
@ TIFFReadDirEntryErrSizesan
Source or target array exceeds the configured sanity ceiling.
@ TIFFReadDirEntryErrAlloc
Allocation, policy, or large-request/file-size rejection.
@ TIFFReadDirEntryErrType
Unsupported source file data type.
@ TIFFReadDirEntryErrCount
Unsupported or inconsistent element count.
@ TIFFReadDirEntryErrOk
Successful or accepted empty conversion.
void _TIFFfreeExt(TIFF *tif, void *p)
Release a handle-aware allocation and its payload charge.
void * _TIFFreallocExt(TIFF *tif, void *p, tmsize_t s)
Resize a handle-aware block or release it for a nonpositive size.
void * _TIFFmallocExt(TIFF *tif, tmsize_t s)
Allocate uninitialised bytes under a handle's allocation policy.
void * _TIFFCheckMalloc(TIFF *tif, tmsize_t nmemb, tmsize_t elem_size, const char *what)
Allocate a checked array with an allocation-failure diagnostic.
void * _TIFFcallocExt(TIFF *tif, tmsize_t nmemb, tmsize_t siz)
Allocate a zero-filled array under a handle's allocation policy.
void _TIFFsetShortArrayExt(TIFF *tif, uint16_t **wpp, const uint16_t *wp, uint32_t n)
Replace an owned short array with a copied array.
#define TIFF_NON_EXISTENT_DIR_NUMBER
Mark an unknown or nonexistent directory index.
#define TIFFReadFile(tif, buf, size)
Invoke the handle's client read callback.
#define TIFF_CHOPPEDUPARRAYS
Mark strip arrays replaced by the strip-chopping operation.
#define isTiled(tif)
Test whether a handle uses tiled storage.
#define isUpSampled(tif)
Test whether the codec reports upsampled output.
#define TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
Suppress unsigned-overflow instrumentation on supported Clang functions.
#define ReadOK(tif, buf, size)
Test whether one client read transfers the entire requested byte count.
#define TIFF_PERSAMPLE
Select per-sample arrays for supported sample-valued fields.
#define TIFF_LAZYSTRILELOAD_ASKED
Record a lazy strip/tile loading request from the O open flag.
#define TIFF_LAZYSTRILELOAD_DONE
Record a switch from on-demand to full strip/tile-array loading.
#define SeekOK(tif, off)
Test whether an absolute seek reaches the requested file position.
#define TIFF_STRIPCHOP
Enable internal chopping of a large uncompressed strip.
#define isMapped(tif)
Test whether TIFF_MAPPED is set on a handle.
#define TIFF_DEFERSTRILELOAD
Defer loading strip/tile offset and byte-count arrays.
#define TRUE
Represent the legacy internal true value.
#define FALSE
Represent the legacy internal false value.
#define TIFFGetFileSize(tif)
Invoke the handle's client size callback.
#define TIFFSeekFile(tif, off, whence)
Invoke the handle's client seek callback.
#define TIFF_BIGTIFF
Mark the BigTIFF file format.
#define TIFF_SWAB
Request swapping multibyte file values to or from host order.
#define TIFFhowmany_32(x, y)
Compute a guarded 32-bit ceiling quotient.
#define TIFF_ISTILED
Mark tile-based rather than strip-based image storage.
void TIFFSwabArrayOfLong8(uint64_t *lp, tmsize_t n)
Reverse the byte order of each array element.
void TIFFSwabArrayOfShort(uint16_t *wp, tmsize_t n)
Reverse the byte order of each array element.
void TIFFSwabLong8(uint64_t *lp)
Reverse the byte order of one value.
void TIFFSwabShort(uint16_t *wp)
Reverse the byte order of one value.
void TIFFSwabArrayOfLong(uint32_t *lp, tmsize_t n)
Reverse the byte order of each array element.
void TIFFSwabLong(uint32_t *lp)
Reverse the byte order of one value.
#define FIELD_CUSTOM
Identify a field stored through the custom-metadata mechanism.
#define TIFF_SPP
Mark a field whose count follows SamplesPerPixel.
#define TIFF_VARIABLE
Mark a variable-length field with a 16-bit count convention.
#define TIFF_ANY
Match any data type when searching for a field descriptor.
#define TIFF_VARIABLE2
Mark a variable-length field with a 32-bit count convention.
void TIFFWarningExtR(TIFF *tif, const char *module, const char *fmt,...)
Dispatch a warning diagnostic to the configured handlers.
void TIFFErrorExtR(TIFF *tif, const char *module, const char *fmt,...)
Dispatch a error diagnostic to the configured handlers.
tdir_t TIFFNumberOfDirectories(TIFF *tif)
Count reachable main-chain directories from the cached file header.
void TIFFFreeDirectory(TIFF *tif)
Release the current directory's owned values and codec state.
int TIFFFieldIsAnonymous(const TIFFField *fip)
Test whether a field was registered as an unknown tag.
const TIFFField * TIFFFieldWithTag(TIFF *tif, uint32_t tag)
Find a registered field by tag number.
int TIFFDataWidth(TIFFDataType type)
Report the on-disk byte width of a TIFF data type.
int TIFFReadCustomDirectory(TIFF *tif, toff_t diroff, const TIFFFieldArray *infoarray)
Read metadata using an explicit custom field schema.
int TIFFReadGPSDirectory(TIFF *tif, toff_t diroff)
Read a EXIF GPS metadata directory.
int TIFFReadEXIFDirectory(TIFF *tif, toff_t diroff)
Read a EXIF metadata directory.
int TIFFReadDirectory(TIFF *tif)
Read and install the next image directory.
int TIFFSetupStrips(TIFF *tif)
Replace strile offset/count arrays from current geometry.
tmsize_t TIFFTileSize(TIFF *tif)
Compute the decoded-size estimate for the configured tile height.
tmsize_t TIFFStripSize(TIFF *tif)
Compute the decoded-size estimate for a nominal strip.
tmsize_t TIFFScanlineSize(TIFF *tif)
Compute the current scanline I/O byte estimate.
uint64_t TIFFVTileSize64(TIFF *tif, uint32_t nrows)
Compute the decoded-size estimate for a requested tile height.
uint64_t TIFFScanlineSize64(TIFF *tif)
Compute the current scanline I/O byte estimate.
uint32_t TIFFNumberOfStrips(TIFF *tif)
Compute the strip count from current image geometry.
uint64_t TIFFVStripSize64(TIFF *tif, uint32_t nrows)
Compute the decoded-size estimate for a requested strip height.
uint64_t TIFFTileSize64(TIFF *tif)
Compute the decoded-size estimate for the configured tile height.
uint64_t TIFFStripSize64(TIFF *tif)
Compute the decoded-size estimate for a nominal strip.
uint32_t TIFFNumberOfTiles(TIFF *tif)
Compute the tile count across image depth and sample planes.
void _TIFFmemset(void *p, int v, tmsize_t c)
Fill a byte range with one repeated byte.
void _TIFFmemcpy(void *d, const void *s, tmsize_t c)
Copy a non-overlapping byte range.
int TIFFSetField(TIFF *tif, uint32_t tag,...)
Set a tag value in the current in-memory directory.
TIFF_SSIZE_T tmsize_t
Represent a signed memory or I/O size in bytes.
TIFFDataType
Identify the on-disk representation of a TIFF directory field.
uint64_t toff_t
Represent an unsigned file byte offset independently of off_t.
uint32_t tdir_t
Represent a zero-based directory index, rather than a file offset.
@ TIFF_SSHORT
Signed 16-bit integer.
@ TIFF_SLONG
Signed 32-bit integer.
@ TIFF_BYTE
Unsigned 8-bit integer.
@ TIFF_SBYTE
Signed 8-bit integer.
@ TIFF_IFD
Unsigned 32-bit IFD byte offset.
@ TIFF_SHORT
Unsigned 16-bit integer.
@ TIFF_UNDEFINED
Untyped 8-bit data.
@ TIFF_LONG
Unsigned 32-bit integer.
@ TIFF_SLONG8
BigTIFF signed 64-bit integer.
@ TIFF_LONG8
BigTIFF unsigned 64-bit integer.
@ TIFF_ASCII
Sequence of 8-bit bytes ending in a null byte.
@ TIFF_FLOAT
32-bit IEEE floating-point value.
@ TIFF_DOUBLE
64-bit IEEE floating-point value.
@ TIFF_IFD8
BigTIFF unsigned 64-bit IFD byte offset.
@ TIFF_SRATIONAL
Signed 32-bit numerator and denominator.
@ TIFF_RATIONAL
Unsigned 32-bit numerator and denominator.
Represent a parsed directory entry before value conversion.
uint64_t tdir_count
Number of file-type elements, normalised to host order.
uint16_t toff_short
Raw 16-bit view of inline bytes or offset storage.
uint16_t tdir_type
On-disk TIFFDataType code.
uint64_t toff_long8
Raw 64-bit view of inline bytes or offset storage.
uint16_t tdir_tag
Directory tag identifier.
union TIFFDirEntry::@0 tdir_offset
Overlay raw directory inline bytes and offset-width views.
uint8_t tdir_ignore
Nonzero to suppress this entry during parsing, e.g. duplicate tags.
uint32_t toff_long
Raw 32-bit view of inline bytes or offset storage.
Store the current directory values and image traversal state.
uint32_t td_tiledepth
Tile depth in slices.
uint32_t td_dirdatasize_Noffsets
Number of ranges collected in td_dirdatasize_offsets.
uint64_t td_dirdatasize_read
Reusable IFD span including entry space and contiguous external data; UINT64_MAX permits extension at...
uint16_t * td_sampleinfo
Owned ExtraSamples interpretation array of td_extrasamples entries, or NULL.
tmsize_t td_tilesize
Cached decoded tile size in bytes; minus one when invalidated.
uint32_t td_rowsperstrip
Rows per strip; UINT32_MAX represents one whole-image strip.
uint32_t td_imagewidth
Image width in pixels.
uint16_t td_compression
COMPRESSION_* codec identifier.
uint16_t td_photometric
PHOTOMETRIC_* interpretation.
uint32_t td_tilewidth
Tile width in pixels.
tmsize_t td_scanlinesize
Cached decoded scanline size in bytes; zero when not computed.
uint16_t td_extrasamples
Number of extra samples described by td_sampleinfo.
uint16_t td_bitspersample
Bits in each sample.
TIFFDirEntry td_stripoffset_entry
Deferred offset entry; tag/type/count are swapped but offset storage is raw.
uint16_t td_maxsamplevalue
Legacy unsigned maximum sample value.
uint32_t td_imagedepth
Image depth in slices.
uint32_t td_stripsperimage
Strips or tiles per sample plane, despite the historic name.
uint16_t td_planarconfig
PLANARCONFIG_* sample-plane arrangement.
uint64_t * td_stripbytecount_p
Owned byte-count array/cache, possibly NULL or partial; use TIFFGetStrileByteCount().
unsigned char td_iswrittentofile
Nonzero when the current directory has an on-file representation.
uint64_t * td_stripoffset_p
Owned offset array/cache, possibly NULL or partial; use TIFFGetStrileOffset().
uint16_t td_ycbcrsubsampling[2]
Horizontal and vertical YCbCr subsampling factors.
uint16_t td_samplesperpixel
Samples per pixel, including extra samples.
uint32_t td_nstrips
Total strile count across all planes; logical array length.
TIFFDirEntry td_stripbytecount_entry
Deferred byte-count entry; offset storage still requires swapping.
uint32_t td_imagelength
Image length in rows.
uint32_t td_stripoffsetbyteallocsize
Allocated element capacity of lazy strile offset/count caches, not byte size.
TIFFEntryOffsetAndLength * td_dirdatasize_offsets
Owned auxiliary array of external IFD-value ranges, or NULL.
uint32_t td_tilelength
Tile length in rows.
Describe an external directory-value byte range.
uint64_t offset
External value offset in file bytes.
uint64_t length
External value length in bytes.
Pair a directory file offset with its main-IFD index.
tdir_t dirNumber
Zero-based main-directory index associated with offset.
uint64_t offset
Directory byte offset from the beginning of the file.
Represent an unsigned TIFF rational as numerator and denominator.
uint32_t uDenom
Unsigned 32-bit denominator; the representation itself performs no validation.
uint32_t uNum
Unsigned 32-bit numerator.
Describe a borrowed schema or owned compatibility batch.
uint32_t count
Number of valid descriptors in fields.
TIFFField * fields
Descriptor array; static/borrowed or owned according to allocated_size and creator.
Describe a field's file type and internal argument contract.
TIFFDataType field_type
On-disk TIFFDataType, distinct from the argument representation.
unsigned char field_passcount
Nonzero for an explicit count argument; tag-specific exceptions still apply.
const char * field_name
Borrowed or anonymous-owned null-terminated name; must remain live while used.
unsigned short field_bit
FIELD_* presence index; FIELD_CUSTOM shares storage through the custom list.
uint32_t field_tag
Tag identifier in this schema namespace.
short field_readcount
Fixed getter count or TIFF_VARIABLE/TIFF_VARIABLE2/TIFF_SPP rule.
TIFFSetGetFieldType set_get_field_type
Internal storage/count representation for tag access and conversion.
Associate an anonymous on-disk tag with a friendly print label.
Hold private state for one open TIFF library instance.
int tif_warn_about_unknown_tags
Nonzero to emit warnings for unknown tags.
int tif_setdirectory_force_absolute
Nonzero to force absolute rather than relative directory stepping.
TIFFBoolMethod tif_fixuptags
Codec callback for directory-dependent tag corrections.
TIFFHashSet * tif_map_dir_number_to_offset
Handle-managed directory-index-to-offset lookup map.
size_t tif_nfields
Number of entries in tif_fields.
uint64_t tif_nextdiroff
Next directory byte offset from the current chain link.
TIFFField ** tif_fields
Owned sorted array of field pointers; descriptors have mixed ownership.
TIFFHashSet * tif_map_dir_offset_to_number
Handle-managed directory-offset-to-index lookup map.
uint64_t tif_diroff
Current directory byte offset, or zero for an unlinked in-memory IFD.
char * tif_name
Current filename pointer; may refer to inline or client-supplied storage.
TIFFDirectory tif_dir
Inline representation of the current image directory.
tmsize_t tif_size
Mapped-file region length in bytes.
tdir_t tif_curdir
Track the current or last-written directory index.
uint32_t tif_flags
Bitmask combining the TIFF_* handle-state flags declared below.
int tif_mode
Current access mode using the O_* constants.
uint8_t * tif_base
Mapped-file base provided by tif_mapproc; released through tif_unmapproc by TIFFCleanup() only while ...
Provide configured integer types and legacy compatibility features.
Declare private library state, callbacks, and implementation helpers.
Provide aligned scalar and byte views of eight raw bytes.
uint8_t c[8]
Eight raw octets in copied order.
uint32_t i[2]
Two native 32-bit component views.
uint16_t s[4]
Four native 16-bit component views.
uint64_t l
Native uint64_t view.
double d
Native double view.