|
LibTIFF 4.7.2
TIFF library public API and implementation reference
|
Count, convert, encode, link, and patch directory entries and payloads. More...
Macros | |
| #define | TIFFCvtNativeToIEEEFloat(tif, n, fp) |
| Recognise already compatible float storage without conversion. | |
| #define | TIFFCvtNativeToIEEEDouble(tif, n, dp) |
| Recognise already compatible double storage without conversion. | |
| #define | MAX_ITERATIONS 64 |
| Bound the rational approximation loop to 64 iterations. | |
Functions | |
| static int | TIFFRewriteDirectorySec (TIFF *tif, int isimage, int imagedone, uint64_t *pdiroff) |
| Detach and relocate an IFD using the requested writer mode. | |
| static int | TIFFWriteDirectorySec (TIFF *tif, int isimage, int imagedone, uint64_t *pdiroff) |
| Serialise the current IFD using image/custom and completion modes. | |
| static int8_t | TIFFClampDoubleToInt8 (double val) |
| Clamp and convert a double to int8. | |
| static int16_t | TIFFClampDoubleToInt16 (double val) |
| Clamp and convert a double to int16. | |
| static int32_t | TIFFClampDoubleToInt32 (double val) |
| Clamp and convert a double to int32. | |
| static uint8_t | TIFFClampDoubleToUInt8 (double val) |
| Clamp and convert a double to uint8. | |
| static uint16_t | TIFFClampDoubleToUInt16 (double val) |
| Clamp and convert a double to uint16. | |
| static uint32_t | TIFFClampDoubleToUInt32 (double val) |
| Clamp and convert a double to uint32. | |
| static int | TIFFWriteDirectoryTagSampleformatArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, double *value) |
| Account for or emit Sampleformat array tag data. | |
| static int | TIFFWriteDirectoryTagAscii (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, char *value) |
| Account for or emit Ascii tag data. | |
| static int | TIFFWriteDirectoryTagUndefinedArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint8_t *value) |
| Account for or emit Undefined array tag data. | |
| static int | TIFFWriteDirectoryTagByteArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint8_t *value) |
| Account for or emit Byte array tag data. | |
| static int | TIFFWriteDirectoryTagSbyteArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, int8_t *value) |
| Account for or emit Sbyte array tag data. | |
| static int | TIFFWriteDirectoryTagShort (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint16_t value) |
| Account for or emit Short tag data. | |
| static int | TIFFWriteDirectoryTagShortArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint16_t *value) |
| Account for or emit Short array tag data. | |
| static int | TIFFWriteDirectoryTagShortPerSample (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint16_t value) |
| Account for or emit Short per sample tag data. | |
| static int | TIFFWriteDirectoryTagSshortArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, int16_t *value) |
| Account for or emit Sshort array tag data. | |
| static int | TIFFWriteDirectoryTagLong (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t value) |
| Account for or emit Long tag data. | |
| static int | TIFFWriteDirectoryTagLongArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint32_t *value) |
| Account for or emit Long array tag data. | |
| static int | TIFFWriteDirectoryTagSlongArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, int32_t *value) |
| Account for or emit Slong array tag data. | |
| static int | TIFFWriteDirectoryTagLong8Array (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint64_t *value) |
| Account for or emit Long8 array tag data. | |
| static int | TIFFWriteDirectoryTagSlong8Array (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, int64_t *value) |
| Account for or emit Slong8 array tag data. | |
| static int | TIFFWriteDirectoryTagRational (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, double value) |
| Account for or emit Rational tag data. | |
| static int | TIFFWriteDirectoryTagRationalArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, float *value) |
| Account for or emit Rational array tag data. | |
| static int | TIFFWriteDirectoryTagSrationalArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, float *value) |
| Account for or emit Srational array tag data. | |
| static int | TIFFWriteDirectoryTagRationalDoubleArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, double *value) |
| Account for or emit RationalDouble array tag data. | |
| static int | TIFFWriteDirectoryTagSrationalDoubleArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, double *value) |
| Account for or emit SrationalDouble array tag data. | |
| static int | TIFFWriteDirectoryTagFloatArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, float *value) |
| Account for or emit Float array tag data. | |
| static int | TIFFWriteDirectoryTagDoubleArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, double *value) |
| Account for or emit Double array tag data. | |
| static int | TIFFWriteDirectoryTagIfdArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint32_t *value) |
| Account for or emit Ifd array tag data. | |
| static int | TIFFWriteDirectoryTagShortLong (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t value) |
| Account for or emit ShortLong tag data. | |
| static int | _WriteAsType (TIFF *tif, uint64_t strile_size, uint64_t uncompressed_threshold) |
| Choose whether a strile count needs a wider integer type. | |
| static int | WriteAsLong8 (TIFF *tif, uint64_t strile_size) |
| Choose whether a strile count needs a wider integer type. | |
| static int | WriteAsLong4 (TIFF *tif, uint64_t strile_size) |
| Choose whether a strile count needs a wider integer type. | |
| static int | TIFFWriteDirectoryTagLongLong8Array (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint64_t *value) |
| Account for or emit LongLong8 array tag data. | |
| static int | TIFFWriteDirectoryTagIfdIfd8Array (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint64_t *value) |
| Account for or emit IfdIfd8 array tag data. | |
| static void | EvaluateIFDdatasizeWrite (TIFF *tif, uint32_t count, uint32_t typesize, uint32_t *ndir) |
| Accumulate external payload size and one IFD entry. | |
| static int | TIFFWriteDirectoryTagColormap (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir) |
| Account for or emit Colormap tag data. | |
| static int | TIFFWriteDirectoryTagTransferfunction (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir) |
| Account for or emit Transferfunction tag data. | |
| static int | TIFFWriteDirectoryTagSubifd (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir) |
| Account for or emit Subifd tag data. | |
| static int | TIFFWriteDirectoryTagCheckedAscii (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, char *value) |
| Account for or emit Ascii tag data. | |
| static int | TIFFWriteDirectoryTagCheckedUndefinedArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint8_t *value) |
| Account for or emit Undefined array tag data. | |
| static int | TIFFWriteDirectoryTagCheckedByteArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint8_t *value) |
| Account for or emit Byte array tag data. | |
| static int | TIFFWriteDirectoryTagCheckedSbyteArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, int8_t *value) |
| Account for or emit Sbyte array tag data. | |
| static int | TIFFWriteDirectoryTagCheckedShort (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint16_t value) |
| Account for or emit Short tag data. | |
| static int | TIFFWriteDirectoryTagCheckedShortArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint16_t *value) |
| Account for or emit Short array tag data. | |
| static int | TIFFWriteDirectoryTagCheckedSshortArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, int16_t *value) |
| Account for or emit Sshort array tag data. | |
| static int | TIFFWriteDirectoryTagCheckedLong (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t value) |
| Account for or emit Long tag data. | |
| static int | TIFFWriteDirectoryTagCheckedLongArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint32_t *value) |
| Account for or emit Long array tag data. | |
| static int | TIFFWriteDirectoryTagCheckedSlongArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, int32_t *value) |
| Account for or emit Slong array tag data. | |
| static int | TIFFWriteDirectoryTagCheckedLong8Array (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint64_t *value) |
| Account for or emit Long8 array tag data. | |
| static int | TIFFWriteDirectoryTagCheckedSlong8Array (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, int64_t *value) |
| Account for or emit Slong8 array tag data. | |
| static int | TIFFWriteDirectoryTagCheckedRational (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, double value) |
| Account for or emit Rational tag data. | |
| static int | TIFFWriteDirectoryTagCheckedRationalArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, float *value) |
| Account for or emit Rational array tag data. | |
| static int | TIFFWriteDirectoryTagCheckedSrationalArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, float *value) |
| Account for or emit Srational array tag data. | |
| static int | TIFFWriteDirectoryTagCheckedRationalDoubleArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, double *value) |
| Account for or emit RationalDouble array tag data. | |
| static int | TIFFWriteDirectoryTagCheckedSrationalDoubleArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, double *value) |
| Account for or emit SrationalDouble array tag data. | |
| static void | ToRationalEuclideanGCD (double value, int blnUseSignedRange, int blnUseSmallRange, uint64_t *ullNum, uint64_t *ullDenom) |
| Approximate a nonnegative scalar by bounded rational components. | |
| static void | DoubleToRational (double value, uint32_t *num, uint32_t *denom) |
| Convert a double into unsigned 32-bit rational components. | |
| static void | DoubleToSrational (double value, int32_t *num, int32_t *denom) |
| Convert a non-NaN double into signed rational components. | |
| static int | TIFFWriteDirectoryTagCheckedFloatArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, float *value) |
| Account for or emit Float array tag data. | |
| static int | TIFFWriteDirectoryTagCheckedDoubleArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, double *value) |
| Account for or emit Double array tag data. | |
| static int | TIFFWriteDirectoryTagCheckedIfdArray (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint32_t *value) |
| Account for or emit Ifd array tag data. | |
| static int | TIFFWriteDirectoryTagCheckedIfd8Array (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, uint64_t *value) |
| Account for or emit Ifd8 array tag data. | |
| static int | TIFFWriteDirectoryTagData (TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint16_t datatype, uint32_t count, uint32_t datalength, void *data) |
| Insert one sorted IFD entry and emit its raw payload. | |
| static int | TIFFLinkDirectory (TIFF *tif) |
| Link a new IFD at an even end-of-file offset. | |
| int | _TIFFRewriteField (TIFF *tif, uint16_t tag, TIFFDataType in_datatype, tmsize_t count, void *data) |
| Patch an existing field in the current on-file IFD. | |
Count, convert, encode, link, and patch directory entries and payloads.
| #define MAX_ITERATIONS 64 |
Bound the rational approximation loop to 64 iterations.
There is a mathematical theorem to convert real numbers into a rational (integer fraction) number. This is called "continuous fraction" which uses the Euclidean algorithm to find the greatest common divisor (GCD). (ref. e.g. https://de.wikipedia.org/wiki/Kettenbruch or https://en.wikipedia.org/wiki/Continued_fraction https://en.wikipedia.org/wiki/Euclidean_algorithm) The following functions implement the
-— ToRationalEuclideanGCD() --------------------------------------— Calculates the rational fractional of a double input value
Source-local macro used by ToRationalEuclideanGCD(); it does not bound all setup work.
| #define TIFFCvtNativeToIEEEDouble | ( | tif, | |
| n, | |||
| dp | |||
| ) |
Recognise already compatible double storage without conversion.
With HAVE_IEEEFP defined this is a no-op macro: arguments are not evaluated and no state, ownership, I/O, diagnostics, or storage changes occur. Non-IEEE ports instead require the external platform hook with this name.
| [in] | tif | Ignored handle expression. |
| [in] | n | Ignored element-count expression. |
| [in,out] | dp | Ignored data-pointer expression; storage is unchanged. |
Definition at line 67 of file tif_dirwrite.c.
| #define TIFFCvtNativeToIEEEFloat | ( | tif, | |
| n, | |||
| fp | |||
| ) |
Recognise already compatible float storage without conversion.
With HAVE_IEEEFP defined this is a no-op macro: arguments are not evaluated and no state, ownership, I/O, diagnostics, or storage changes occur. Non-IEEE ports instead require the external platform hook with this name.
| [in] | tif | Ignored handle expression. |
| [in] | n | Ignored element-count expression. |
| [in,out] | fp | Ignored data-pointer expression; storage is unchanged. |
Definition at line 53 of file tif_dirwrite.c.
|
extern |
Patch an existing field in the current on-file IFD.
Requires a writable, non-mapped handle with a nonzero current IFD offset and an existing entry (including a deferred placeholder). Searches entries, allocates a copy, range-checks supported 64-to-32/16 integer/IFD conversions, swaps the copy, and overwrites matching payload storage or appends/replaces it and patches the entry. Data remains borrowed and unchanged. Moves I/O position and can update cached deferred-strile type/count metadata before write success; does not reconcile general in-memory tag values. No atomicity/rollback or fsync guarantee. Entry, allocation, range, and I/O failures report diagnostics, but some seeks are unchecked and the unsupported-conversion path leaks its temporary buffer. Caller must provide a valid positive representable element extent and a supported integer/IFD or same-type representation; byte-width copying/swapping alone is not general rational conversion.
| [in,out] | tif | Non-NULL live handle with matching schema/state; serialise access externally. |
| [in] | tag | On-disk 16-bit field identifier already present in the IFD. |
| [in] | in_datatype | Type of input elements; supported narrowing is LONG8/SLONG8/IFD8 to matching shorter integer/IFD types. |
| [in] | count | Positive element count with representable allocation/file entry size. |
| [in] | data | Readable borrowed input array of count elements; no alias with mutable handle bookkeeping. |
Definition at line 5133 of file tif_dirwrite.c.
References _TIFFCheckMalloc(), _TIFFfreeExt(), isMapped, ReadOK, SeekOK, TIFFDirectory::td_stripbytecount_entry, TIFFDirectory::td_stripoffset_entry, TIFFDirEntry::tdir_count, TIFFDirEntry::tdir_offset, TIFFDirEntry::tdir_type, tiff::tif_dir, tiff::tif_diroff, tiff::tif_flags, tiff::tif_name, TIFF_ANY, TIFF_BIGTIFF, TIFF_IFD, TIFF_IFD8, TIFF_LONG, TIFF_LONG8, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SWAB, TIFFDataWidth(), TIFFErrorExtR(), TIFFFindField(), TIFFSeekFile, TIFFStripSize64(), TIFFSwabArrayOfLong(), TIFFSwabArrayOfLong8(), TIFFSwabArrayOfShort(), TIFFSwabLong(), TIFFSwabLong8(), TIFFSwabShort(), TIFFTAG_STRIPBYTECOUNTS, TIFFTAG_STRIPOFFSETS, TIFFTAG_TILEBYTECOUNTS, TIFFTAG_TILEOFFSETS, TIFFTileSize64(), TIFFDirEntry::toff_long8, WriteAsLong4(), WriteAsLong8(), and WriteOK.
Referenced by TIFFForceStrileArrayWriting().
|
static |
Choose whether a strile count needs a wider integer type.
Uncompressed counts use a strict size-threshold comparison. Selected codecs use a pessimistic factor-ten expansion threshold; other codecs always choose wider storage. Pure selection heuristic: no payload inspection, allocation, diagnostics, state change, or ownership transfer.
| [in] | tif | Non-NULL handle whose compression mode is inspected. |
| [in] | strile_size | Uncompressed strile size in bytes. |
| [in] | uncompressed_threshold | Narrower unsigned type's maximum byte count. |
Definition at line 2700 of file tif_dirwrite.c.
References COMPRESSION_ADOBE_DEFLATE, COMPRESSION_DEFLATE, COMPRESSION_JPEG, COMPRESSION_JXL, COMPRESSION_LERC, COMPRESSION_LZMA, COMPRESSION_LZW, COMPRESSION_NONE, COMPRESSION_WEBP, COMPRESSION_ZSTD, TIFFDirectory::td_compression, and tiff::tif_dir.
Referenced by WriteAsLong4(), and WriteAsLong8().
|
static |
Convert a double into unsigned 32-bit rational components.
-— DoubleToRational() --------------------------------------------— Calculates the rational fractional of a double input value for UN-SIGNED rationals,
Negative/NaN input reports a global TIFFErrorExt() diagnostic with zero context and returns zero/zero. Above UINT32_MAX returns maximum/zero without a diagnostic. Exact integers use denominator one; tiny positive values use zero/UINT32_MAX. Otherwise compares two bounded GCD approximations. No allocation/ownership transfer or handle state. Internal range-invariant violations report globally and produce maximum/zero; diagnostics are not a caller-visible status result.
| [in] | value | Scalar to encode, including documented negative/NaN/overflow cases. |
| [out] | num | Non-NULL numerator slot, distinct from denom. |
| [out] | denom | Non-NULL denominator slot; zero is a sentinel rather than guaranteed finite quotient. |
Definition at line 4374 of file tif_dirwrite.c.
References FALSE, TIFF_DOUBLE_EQ, TIFFErrorExt(), ToRationalEuclideanGCD(), and TRUE.
Referenced by TIFFWriteDirectoryTagCheckedRational(), TIFFWriteDirectoryTagCheckedRationalArray(), and TIFFWriteDirectoryTagCheckedRationalDoubleArray().
|
static |
Convert a non-NaN double into signed rational components.
Requires non-NaN input: NaN reaches unsupported floating-to-integer conversion. Encodes sign in numerator for normal values, with a positive denominator. Magnitudes above INT32_MAX, including either infinity, produce positive INT32_MAX/zero (negative overflow loses its sign). Exact integers use denominator one; tiny magnitudes use zero/INT32_MAX. Otherwise selects the more accurate of two bounded GCD approximations. No allocation/ownership transfer or handle state. Internal invariant violations use global diagnostics and produce INT32_MAX/zero carrying the value's sign; there is no status result.
| [in] | value | Non-NaN scalar; finite supported magnitudes or documented infinity/overflow cases. |
| [out] | num | Non-NULL signed numerator slot, distinct from denom. |
| [out] | denom | Non-NULL signed denominator slot; zero may encode overflow. |
Definition at line 4472 of file tif_dirwrite.c.
References FALSE, TIFF_DOUBLE_EQ, TIFFErrorExt(), ToRationalEuclideanGCD(), and TRUE.
Referenced by TIFFWriteDirectoryTagCheckedSrationalArray(), and TIFFWriteDirectoryTagCheckedSrationalDoubleArray().
|
static |
Accumulate external payload size and one IFD entry.
Computes count*typesize in uint64_t, adds even-padded payload bytes only when larger than inline storage, and increments *ndir. Does not allocate, write, emit diagnostics, or transfer ownership. Accumulation/increment overflow is not checked here; caller must keep totals representable.
| [in,out] | tif | Non-NULL live handle with matching schema/state; serialise access externally. |
| [in] | count | Element count. |
| [in] | typesize | Positive file element width in bytes. |
| [in,out] | ndir | Non-NULL entry counter to increment. |
Definition at line 3030 of file tif_dirwrite.c.
References TIFFDirectory::td_dirdatasize_write, tiff::tif_dir, tiff::tif_flags, and TIFF_BIGTIFF.
Referenced by TIFFWriteDirectoryTagCheckedAscii(), TIFFWriteDirectoryTagCheckedByteArray(), TIFFWriteDirectoryTagCheckedDoubleArray(), TIFFWriteDirectoryTagCheckedFloatArray(), TIFFWriteDirectoryTagCheckedIfd8Array(), TIFFWriteDirectoryTagCheckedIfdArray(), TIFFWriteDirectoryTagCheckedLong8Array(), TIFFWriteDirectoryTagCheckedLongArray(), TIFFWriteDirectoryTagCheckedRationalArray(), TIFFWriteDirectoryTagCheckedRationalDoubleArray(), TIFFWriteDirectoryTagCheckedSbyteArray(), TIFFWriteDirectoryTagCheckedShortArray(), TIFFWriteDirectoryTagCheckedSlong8Array(), TIFFWriteDirectoryTagCheckedSlongArray(), TIFFWriteDirectoryTagCheckedSrationalArray(), TIFFWriteDirectoryTagCheckedSrationalDoubleArray(), TIFFWriteDirectoryTagCheckedSshortArray(), TIFFWriteDirectoryTagCheckedUndefinedArray(), TIFFWriteDirectoryTagColormap(), and TIFFWriteDirectoryTagTransferfunction().
|
static |
Clamp and convert a double to int16.
Clamps infinities/out-of-range values to target bounds, then truncates finite in-range values toward zero. NaN maps to the signed minimum. No allocation, diagnostic, handle state, or ownership effects.
| [in] | val | Input double, including infinities or NaN. |
Definition at line 1659 of file tif_dirwrite.c.
Referenced by TIFFWriteDirectoryTagSampleformatArray().
|
static |
Clamp and convert a double to int32.
Clamps infinities/out-of-range values to target bounds, then truncates finite in-range values toward zero. NaN maps to the signed minimum. No allocation, diagnostic, handle state, or ownership effects.
| [in] | val | Input double, including infinities or NaN. |
Definition at line 1679 of file tif_dirwrite.c.
Referenced by TIFFWriteDirectoryTagSampleformatArray().
|
static |
Clamp and convert a double to int8.
Clamps infinities/out-of-range values to target bounds, then truncates finite in-range values toward zero. NaN maps to the signed minimum. No allocation, diagnostic, handle state, or ownership effects.
| [in] | val | Input double, including infinities or NaN. |
Definition at line 1639 of file tif_dirwrite.c.
Referenced by TIFFWriteDirectoryTagSampleformatArray().
|
static |
Clamp and convert a double to uint16.
Clamps infinities/out-of-range values to target bounds, then truncates finite in-range values toward zero. NaN maps to the unsigned maximum. No allocation, diagnostic, handle state, or ownership effects.
| [in] | val | Input double, including infinities or NaN. |
Definition at line 1719 of file tif_dirwrite.c.
Referenced by TIFFWriteDirectoryTagSampleformatArray().
|
static |
Clamp and convert a double to uint32.
Clamps infinities/out-of-range values to target bounds, then truncates finite in-range values toward zero. NaN maps to the unsigned maximum. No allocation, diagnostic, handle state, or ownership effects.
| [in] | val | Input double, including infinities or NaN. |
Definition at line 1739 of file tif_dirwrite.c.
Referenced by TIFFWriteDirectoryTagSampleformatArray().
|
static |
Clamp and convert a double to uint8.
Clamps infinities/out-of-range values to target bounds, then truncates finite in-range values toward zero. NaN maps to the unsigned maximum. No allocation, diagnostic, handle state, or ownership effects.
| [in] | val | Input double, including infinities or NaN. |
Definition at line 1699 of file tif_dirwrite.c.
Referenced by TIFFWriteDirectoryTagSampleformatArray().
|
static |
Link a new IFD at an even end-of-file offset.
Patches the next pending SubIFD slot, the first-header pointer, or a main-chain terminal link, using cached last-offset information where available. Requires writable, seekable, consistent chain/SubIFD state. Updates current/last offsets, child-slot counters and cached main count; allocates no owned return. Traversal can seek/read and dispatch diagnostics, and is not general malformed-chain validation. Fails before any link write if the initial end-of-file seek fails. Some seeks and narrowing on SubIFD paths are unchecked. Link writes precede directory content emission; failure does not restore file/cache state.
| [in,out] | tif | Non-NULL live handle with matching schema/state; serialise access externally. |
Definition at line 4857 of file tif_dirwrite.c.
References _TIFFCheckDirNumberAndOffset(), _TIFFGetDirNumberFromOffset(), TIFFHeaderUnion::big, TIFFHeaderUnion::classic, ReadOK, SeekOK, TIFFDirectory::td_iswrittentofile, tiff::tif_curdircount, tiff::tif_dir, tiff::tif_diroff, tiff::tif_flags, tiff::tif_header, tiff::tif_lastdiroff, tiff::tif_name, tiff::tif_nsubifd, tiff::tif_subifdoff, TIFF_BIGTIFF, TIFFHeaderClassic::tiff_diroff, TIFFHeaderBig::tiff_diroff, TIFF_INSUBIFD, TIFF_SWAB, TIFFErrorExtR(), TIFFSeekFile, TIFFSwabLong(), TIFFSwabLong8(), TIFFSwabShort(), and WriteOK.
Referenced by TIFFWriteDirectorySec().
|
static |
Detach and relocate an IFD using the requested writer mode.
Requires an existing main-chain-reachable IFD on a writable seekable resource. Clears its header/preceding link and map entry before calling TIFFWriteDirectorySec(); old bytes remain unused. The walk to the preceding link checks each IFD through _TIFFCheckDirNumberAndOffset() and fails on a detected IFD loop before patching anything. Partial link/file/cache changes survive failure, and some seek/map-removal results are unchecked. Does not independently reject read-only mode before detachment. If current offset is zero, delegates to TIFFWriteDirectory() and ignores the requested mode/output arguments. Allocations, callback/encoder work, ownership invalidation, and diagnostics otherwise follow the shared writer.
| [in,out] | tif | Non-NULL live handle with matching schema/state; serialise access externally. |
| [in] | isimage | Nonzero for image-bit plus custom values; zero for custom values only. |
| [in] | imagedone | Nonzero to finish encoding and reset values; zero to retain directory state. |
| [out] | pdiroff | Optional custom-offset slot as required by the downstream mode; not assigned on the zero-offset fallback. |
Definition at line 399 of file tif_dirwrite.c.
References _TIFFCheckDirNumberAndOffset(), _TIFFRemoveEntryFromDirectoryListByOffset(), TIFFHeaderUnion::big, TIFFHeaderUnion::classic, ReadOK, SeekOK, tiff::tif_diroff, tiff::tif_flags, tiff::tif_header, tiff::tif_lastdiroff, tiff::tif_name, TIFF_BIGTIFF, TIFFHeaderClassic::tiff_diroff, TIFFHeaderBig::tiff_diroff, TIFF_SWAB, TIFFErrorExtR(), TIFFSeekFile, TIFFSwabLong(), TIFFSwabLong8(), TIFFSwabShort(), TIFFWriteDirectory(), TIFFWriteDirectorySec(), and WriteOK.
Referenced by TIFFRewriteDirectory(), and TIFFWriteDirectorySec().
|
static |
Serialise the current IFD using image/custom and completion modes.
Read-only mode returns one immediately without assigning pdiroff or finalising state. Otherwise attempts strile fill (unchecked), optionally finishes encoding/raw data, and performs count/size and emission passes. Builds sorted entries, writes external data, links/relocates/reuses IFD space, writes raw IFD bytes, and updates index/count/maps. Codec-range tags whose field bit is set but whose value TIFFGetField() cannot fetch, as when an earlier codec on this directory shared that bit, are skipped. A custom value whose field type has no writer reports an error and fails. Appending a custom IFD fails if the end-of-file seek fails. Some arrays are swapped in place. Final map-check errors are diagnosed but do not change success. Completion frees/resets directory/codec storage; retaining mode keeps values and records written size. Any failure can leave partial bytes, links, state, or mutated arrays; temporary entry/serialisation buffers are freed on the ordinary bad path, without rollback.
| [in,out] | tif | Non-NULL live handle with matching schema/state; serialise access externally. |
| [in] | isimage | Nonzero for image directory including core field bits; zero for custom-value-only emission. |
| [in] | imagedone | Nonzero to finalise encoder/raw data and release/reset directory after writing. |
| [out] | pdiroff | Optional (may be NULL) slot that receives the IFD offset in either mode; may be set before a later failure; untouched by the read-only no-op. |
Definition at line 620 of file tif_dirwrite.c.
References _TIFFCheckDirNumberAndOffset(), _TIFFCheckMalloc(), _TIFFFillStriles(), _TIFFfreeExt(), _TIFFmallocExt(), _TIFFmemcpy(), COMPRESSION_DEFLATE, TIFFTagValue::count, _TIFFField::field_bit, FIELD_BITSPERSAMPLE, FIELD_CODEC, FIELD_COLORMAP, FIELD_COMPRESSION, FIELD_EXTRASAMPLES, FIELD_FILLORDER, FIELD_HALFTONEHINTS, FIELD_IMAGEDEPTH, FIELD_IMAGEDIMENSIONS, FIELD_INKNAMES, FIELD_MAXSAMPLEVALUE, FIELD_MINSAMPLEVALUE, _TIFFField::field_name, FIELD_NUMBEROFINKS, FIELD_ORIENTATION, FIELD_PAGENUMBER, _TIFFField::field_passcount, FIELD_PHOTOMETRIC, FIELD_PLANARCONFIG, FIELD_POSITION, _TIFFField::field_readcount, FIELD_REFBLACKWHITE, FIELD_RESOLUTION, FIELD_RESOLUTIONUNIT, FIELD_ROWSPERSTRIP, FIELD_SAMPLEFORMAT, FIELD_SAMPLESPERPIXEL, FIELD_SMAXSAMPLEVALUE, FIELD_SMINSAMPLEVALUE, FIELD_STRIPBYTECOUNTS, FIELD_STRIPOFFSETS, FIELD_SUBFILETYPE, FIELD_SUBIFD, _TIFFField::field_tag, FIELD_THRESHHOLDING, FIELD_TILEDEPTH, FIELD_TILEDIMENSIONS, FIELD_TRANSFERFUNCTION, _TIFFField::field_type, FIELD_YCBCRPOSITIONING, FIELD_YCBCRSUBSAMPLING, TIFFTagValue::info, isTiled, SeekOK, _TIFFField::set_get_field_type, TIFFDirectory::td_bitspersample, TIFFDirectory::td_compression, TIFFDirectory::td_customValueCount, TIFFDirectory::td_customValues, TIFFDirectory::td_dirdatasize_read, TIFFDirectory::td_dirdatasize_write, TIFFDirectory::td_extrasamples, TIFFDirectory::td_fillorder, TIFFDirectory::td_halftonehints, TIFFDirectory::td_imagedepth, TIFFDirectory::td_imagelength, TIFFDirectory::td_imagewidth, TIFFDirectory::td_inknames, TIFFDirectory::td_inknameslen, TIFFDirectory::td_iswrittentofile, TIFFDirectory::td_maxsamplevalue, TIFFDirectory::td_minsamplevalue, TIFFDirectory::td_nstrips, TIFFDirectory::td_numberofinks, TIFFDirectory::td_orientation, TIFFDirectory::td_pagenumber, TIFFDirectory::td_photometric, TIFFDirectory::td_planarconfig, TIFFDirectory::td_refblackwhite, TIFFDirectory::td_resolutionunit, TIFFDirectory::td_rowsperstrip, TIFFDirectory::td_sampleformat, TIFFDirectory::td_samplesperpixel, TIFFDirectory::td_smaxsamplevalue, TIFFDirectory::td_sminsamplevalue, TIFFDirectory::td_stripbytecount_p, TIFFDirectory::td_stripoffset_p, TIFFDirectory::td_subfiletype, TIFFDirectory::td_threshholding, TIFFDirectory::td_tiledepth, TIFFDirectory::td_tilelength, TIFFDirectory::td_tilewidth, TIFFDirectory::td_xposition, TIFFDirectory::td_xresolution, TIFFDirectory::td_ycbcrpositioning, TIFFDirectory::td_ycbcrsubsampling, TIFFDirectory::td_yposition, TIFFDirectory::td_yresolution, TIFFDirEntry::tdir_count, TIFFDirEntry::tdir_offset, TIFFDirEntry::tdir_tag, TIFFDirEntry::tdir_type, tiff::tif_close, tiff::tif_curdir, tiff::tif_curdircount, tiff::tif_dataoff, tiff::tif_dir, tiff::tif_diroff, tiff::tif_fields, tiff::tif_flags, tiff::tif_mode, tiff::tif_nextdiroff, tiff::tif_nfields, tiff::tif_nsubifd, tiff::tif_postencode, tiff::tif_rawcc, tiff::tif_rawcp, tiff::tif_rawdata, tiff::tif_rawdataloaded, tiff::tif_rawdataoff, tiff::tif_rawdatasize, tiff::tif_subifdoff, TIFF_ASCII, TIFF_BEENWRITING, TIFF_BIGTIFF, TIFF_BUFFERSETUP, TIFF_BYTE, TIFF_DOUBLE, TIFF_FLOAT, TIFF_IFD, TIFF_IFD8, TIFF_INSUBIFD, TIFF_LONG, TIFF_LONG8, TIFF_MYBUFFER, TIFF_NON_EXISTENT_DIR_NUMBER, TIFF_NOTYPE, TIFF_POSTENCODE, TIFF_RATIONAL, TIFF_SBYTE, TIFF_SETGET_ASCII, TIFF_SETGET_C0_ASCII, TIFF_SETGET_C0_DOUBLE, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_C0_IFD8, TIFF_SETGET_C0_SINT16, TIFF_SETGET_C0_SINT32, TIFF_SETGET_C0_SINT64, TIFF_SETGET_C0_SINT8, TIFF_SETGET_C0_UINT16, TIFF_SETGET_C0_UINT32, TIFF_SETGET_C0_UINT64, TIFF_SETGET_C0_UINT8, TIFF_SETGET_C16_ASCII, TIFF_SETGET_C16_DOUBLE, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_C16_IFD8, TIFF_SETGET_C16_SINT16, TIFF_SETGET_C16_SINT32, TIFF_SETGET_C16_SINT64, TIFF_SETGET_C16_SINT8, TIFF_SETGET_C16_UINT16, TIFF_SETGET_C16_UINT32, TIFF_SETGET_C16_UINT64, TIFF_SETGET_C16_UINT8, TIFF_SETGET_C32_ASCII, TIFF_SETGET_C32_DOUBLE, TIFF_SETGET_C32_FLOAT, TIFF_SETGET_C32_IFD8, TIFF_SETGET_C32_SINT16, TIFF_SETGET_C32_SINT32, TIFF_SETGET_C32_SINT64, TIFF_SETGET_C32_SINT8, TIFF_SETGET_C32_UINT16, TIFF_SETGET_C32_UINT32, TIFF_SETGET_C32_UINT64, TIFF_SETGET_C32_UINT8, TIFF_SETGET_DOUBLE, TIFF_SETGET_FLOAT, TIFF_SETGET_IFD8, TIFF_SETGET_INT, TIFF_SETGET_OTHER, TIFF_SETGET_SINT16, TIFF_SETGET_SINT32, TIFF_SETGET_SINT64, TIFF_SETGET_SINT8, TIFF_SETGET_UINT16, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UINT32, TIFF_SETGET_UINT64, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SRATIONAL, TIFF_SSHORT, TIFF_SWAB, TIFF_UNDEFINED, TIFF_VARIABLE, TIFF_VARIABLE2, TIFFCreateDirectory(), TIFFErrorExtR(), TIFFFieldSet, TIFFFieldSetGetSize(), TIFFFieldTag(), TIFFFlushData1(), TIFFFreeDirectory(), TIFFGetField(), TIFFGetFieldDefaulted(), TIFFLinkDirectory(), TIFFNumberOfDirectories(), TIFFRewriteDirectorySec(), TIFFSeekFile, TIFFSwabLong(), TIFFSwabLong8(), TIFFSwabShort(), TIFFTAG_BITSPERSAMPLE, TIFFTAG_COMPRESSION, TIFFTAG_EXTRASAMPLES, TIFFTAG_FILLORDER, TIFFTAG_HALFTONEHINTS, TIFFTAG_IMAGEDEPTH, TIFFTAG_IMAGELENGTH, TIFFTAG_IMAGEWIDTH, TIFFTAG_INKNAMES, TIFFTAG_MAXSAMPLEVALUE, TIFFTAG_MINSAMPLEVALUE, TIFFTAG_NUMBEROFINKS, TIFFTAG_ORIENTATION, TIFFTAG_PAGENUMBER, TIFFTAG_PHOTOMETRIC, TIFFTAG_PLANARCONFIG, TIFFTAG_REFERENCEBLACKWHITE, TIFFTAG_RESOLUTIONUNIT, TIFFTAG_ROWSPERSTRIP, TIFFTAG_SAMPLEFORMAT, TIFFTAG_SAMPLESPERPIXEL, TIFFTAG_SMAXSAMPLEVALUE, TIFFTAG_SMINSAMPLEVALUE, TIFFTAG_STRIPBYTECOUNTS, TIFFTAG_STRIPOFFSETS, TIFFTAG_SUBFILETYPE, TIFFTAG_SUBIFD, TIFFTAG_THRESHHOLDING, TIFFTAG_TILEBYTECOUNTS, TIFFTAG_TILEDEPTH, TIFFTAG_TILELENGTH, TIFFTAG_TILEOFFSETS, TIFFTAG_TILEWIDTH, TIFFTAG_XPOSITION, TIFFTAG_XRESOLUTION, TIFFTAG_YCBCRPOSITIONING, TIFFTAG_YCBCRSUBSAMPLING, TIFFTAG_YPOSITION, TIFFTAG_YRESOLUTION, TIFFWarningExtR(), TIFFWriteDirectoryTagAscii(), TIFFWriteDirectoryTagByteArray(), TIFFWriteDirectoryTagColormap(), TIFFWriteDirectoryTagDoubleArray(), TIFFWriteDirectoryTagFloatArray(), TIFFWriteDirectoryTagIfdArray(), TIFFWriteDirectoryTagIfdIfd8Array(), TIFFWriteDirectoryTagLong(), TIFFWriteDirectoryTagLong8Array(), TIFFWriteDirectoryTagLongArray(), TIFFWriteDirectoryTagLongLong8Array(), TIFFWriteDirectoryTagRational(), TIFFWriteDirectoryTagRationalArray(), TIFFWriteDirectoryTagRationalDoubleArray(), TIFFWriteDirectoryTagSampleformatArray(), TIFFWriteDirectoryTagSbyteArray(), TIFFWriteDirectoryTagShort(), TIFFWriteDirectoryTagShortArray(), TIFFWriteDirectoryTagShortLong(), TIFFWriteDirectoryTagShortPerSample(), TIFFWriteDirectoryTagSlong8Array(), TIFFWriteDirectoryTagSlongArray(), TIFFWriteDirectoryTagSrationalArray(), TIFFWriteDirectoryTagSrationalDoubleArray(), TIFFWriteDirectoryTagSshortArray(), TIFFWriteDirectoryTagSubifd(), TIFFWriteDirectoryTagTransferfunction(), TIFFWriteDirectoryTagUndefinedArray(), TRUE, TIFFTagValue::value, and WriteOK.
Referenced by TIFFCheckpointDirectory(), TIFFRewriteDirectorySec(), TIFFWriteCustomDirectory(), and TIFFWriteDirectory().
|
static |
Account for or emit Ascii tag data.
Forwards to TIFFWriteDirectoryTagCheckedAscii(). Writes exactly count bytes as ASCII; any NUL terminator must be included in count. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in] | value | Array of count char values; not modified. |
Definition at line 1885 of file tif_dirwrite.c.
References TIFFWriteDirectoryTagCheckedAscii().
Referenced by TIFFWriteDirectorySec().
|
static |
Account for or emit Byte array tag data.
Forwards to TIFFWriteDirectoryTagCheckedByteArray(). Writes count bytes as BYTE without conversion. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in] | value | Array of count uint8_t values; not modified. |
Definition at line 1945 of file tif_dirwrite.c.
References TIFFWriteDirectoryTagCheckedByteArray().
Referenced by TIFFWriteDirectorySec(), and TIFFWriteDirectoryTagSampleformatArray().
|
static |
Account for or emit Ascii tag data.
Writes exactly count bytes as ASCII; any NUL terminator must be included in count. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in] | value | Array of count char values; not modified. Not accessed by the sizing pass. |
Definition at line 3356 of file tif_dirwrite.c.
References EvaluateIFDdatasizeWrite(), TIFF_ASCII, and TIFFWriteDirectoryTagData().
Referenced by TIFFWriteDirectoryTagAscii().
|
static |
Account for or emit Byte array tag data.
Writes count bytes as BYTE without conversion. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in] | value | Array of count uint8_t values; not modified. Not accessed by the sizing pass. |
Definition at line 3430 of file tif_dirwrite.c.
References EvaluateIFDdatasizeWrite(), TIFF_BYTE, and TIFFWriteDirectoryTagData().
Referenced by TIFFWriteDirectoryTagByteArray().
|
static |
Account for or emit Double array tag data.
Writes count values as DOUBLE. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). The emission pass converts value in place to IEEE format with TIFFCvtNativeToIEEEDouble() (a no-op on IEEE hosts) and, when TIFF_SWAB is set, byte-swaps it in place; value is not restored. A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in,out] | value | Array of count double values; converted and byte-swapped in place by the emission pass. Not accessed by the sizing pass. |
Definition at line 4615 of file tif_dirwrite.c.
References EvaluateIFDdatasizeWrite(), tiff::tif_flags, TIFF_DOUBLE, TIFF_SWAB, TIFFCvtNativeToIEEEDouble, TIFFSwabArrayOfDouble(), and TIFFWriteDirectoryTagData().
Referenced by TIFFWriteDirectoryTagDoubleArray().
|
static |
Account for or emit Float array tag data.
Writes count values as FLOAT. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). The emission pass converts value in place to IEEE format with TIFFCvtNativeToIEEEFloat() (a no-op on IEEE hosts) and, when TIFF_SWAB is set, byte-swaps it in place; value is not restored. A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in,out] | value | Array of count float values; converted and byte-swapped in place by the emission pass. Not accessed by the sizing pass. |
Definition at line 4570 of file tif_dirwrite.c.
References EvaluateIFDdatasizeWrite(), tiff::tif_flags, TIFF_FLOAT, TIFF_SWAB, TIFFCvtNativeToIEEEFloat, TIFFSwabArrayOfFloat(), and TIFFWriteDirectoryTagData().
Referenced by TIFFWriteDirectoryTagFloatArray().
|
static |
Account for or emit Ifd8 array tag data.
Writes count values as IFD8. Requires BigTIFF, which is checked only by assert(). Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). When the file byte order differs from the host (TIFF_SWAB), the emission pass byte-swaps value in place and does not restore it. A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in,out] | value | Array of count uint64_t values; byte-swapped in place by the emission pass when TIFF_SWAB is set. Not accessed by the sizing pass. |
Definition at line 4701 of file tif_dirwrite.c.
References EvaluateIFDdatasizeWrite(), tiff::tif_flags, TIFF_BIGTIFF, TIFF_IFD8, TIFF_SWAB, TIFFSwabArrayOfLong8(), and TIFFWriteDirectoryTagData().
Referenced by TIFFWriteDirectoryTagIfdIfd8Array(), and TIFFWriteDirectoryTagSubifd().
|
static |
Account for or emit Ifd array tag data.
Writes count values as IFD. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). When the file byte order differs from the host (TIFF_SWAB), the emission pass byte-swaps value in place and does not restore it. A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in,out] | value | Array of count uint32_t values; byte-swapped in place by the emission pass when TIFF_SWAB is set. Not accessed by the sizing pass. |
Definition at line 4659 of file tif_dirwrite.c.
References EvaluateIFDdatasizeWrite(), tiff::tif_flags, TIFF_IFD, TIFF_SWAB, TIFFSwabArrayOfLong(), and TIFFWriteDirectoryTagData().
Referenced by TIFFWriteDirectoryTagIfdArray(), TIFFWriteDirectoryTagIfdIfd8Array(), and TIFFWriteDirectoryTagSubifd().
|
static |
Account for or emit Long tag data.
Writes one LONG, byte-swapping a local copy when TIFF_SWAB is set. The value always fits inline in the entry, so sizing adds no payload size and emission cannot fail.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | value | Value to write. |
Definition at line 3634 of file tif_dirwrite.c.
References tiff::tif_flags, TIFF_LONG, TIFF_SWAB, TIFFSwabLong(), and TIFFWriteDirectoryTagData().
Referenced by TIFFWriteDirectoryTagLong(), and TIFFWriteDirectoryTagShortLong().
|
static |
Account for or emit Long8 array tag data.
Writes count values as LONG8. In classic TIFF, reports an error and returns zero in both passes; narrowing is done only by TIFFWriteDirectoryTagLong8Array(). Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). When the file byte order differs from the host (TIFF_SWAB), the emission pass byte-swaps value in place and does not restore it. A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in,out] | value | Array of count uint64_t values; byte-swapped in place by the emission pass when TIFF_SWAB is set. Not accessed by the sizing pass. |
Definition at line 3764 of file tif_dirwrite.c.
References EvaluateIFDdatasizeWrite(), tiff::tif_flags, TIFF_BIGTIFF, TIFF_LONG8, TIFF_SWAB, TIFFErrorExtR(), TIFFSwabArrayOfLong8(), and TIFFWriteDirectoryTagData().
Referenced by TIFFWriteDirectoryTagLong8Array(), and TIFFWriteDirectoryTagLongLong8Array().
|
static |
Account for or emit Long array tag data.
Writes count values as LONG. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). When the file byte order differs from the host (TIFF_SWAB), the emission pass byte-swaps value in place and does not restore it. A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in,out] | value | Array of count uint32_t values; byte-swapped in place by the emission pass when TIFF_SWAB is set. Not accessed by the sizing pass. |
Definition at line 3677 of file tif_dirwrite.c.
References EvaluateIFDdatasizeWrite(), tiff::tif_flags, TIFF_LONG, TIFF_SWAB, TIFFSwabArrayOfLong(), and TIFFWriteDirectoryTagData().
Referenced by TIFFWriteDirectoryTagLong8Array(), TIFFWriteDirectoryTagLongArray(), and TIFFWriteDirectoryTagLongLong8Array().
|
static |
Account for or emit Rational tag data.
Rejects negative and NaN values with an error in both passes, then converts value with DoubleToRational() into two uint32_t components, byte-swapped when TIFF_SWAB is set. Sizing adds 8 bytes of payload in classic TIFF and none in BigTIFF, where the value is inline. A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | value | Value to write. |
Definition at line 3859 of file tif_dirwrite.c.
References DoubleToRational(), TIFFDirectory::td_dirdatasize_write, tiff::tif_dir, tiff::tif_flags, TIFF_BIGTIFF, TIFF_RATIONAL, TIFF_SWAB, TIFFErrorExtR(), TIFFSwabLong(), and TIFFWriteDirectoryTagData().
Referenced by TIFFWriteDirectoryTagRational().
|
static |
Account for or emit Rational array tag data.
Converts each element with DoubleToRational() into a temporary buffer of numerator/denominator pairs (emission pass only) and writes them as RATIONAL, byte-swapped when TIFF_SWAB is set. A negative or NaN element is reported by DoubleToRational() and written as 0/0 without failing. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in] | value | Array of count float values; not modified. Not accessed by the sizing pass. |
Definition at line 3922 of file tif_dirwrite.c.
References _TIFFCheckMalloc(), _TIFFfreeExt(), DoubleToRational(), EvaluateIFDdatasizeWrite(), tiff::tif_flags, TIFF_RATIONAL, TIFF_SWAB, TIFFErrorExtR(), TIFFSwabArrayOfLong(), and TIFFWriteDirectoryTagData().
Referenced by TIFFWriteDirectoryTagRationalArray().
|
static |
Account for or emit RationalDouble array tag data.
Converts each element with DoubleToRational() into a temporary buffer of numerator/denominator pairs (emission pass only) and writes them as RATIONAL, byte-swapped when TIFF_SWAB is set. A negative or NaN element is reported by DoubleToRational() and written as 0/0 without failing. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in] | value | Array of count double values; not modified. Not accessed by the sizing pass. |
Definition at line 4064 of file tif_dirwrite.c.
References _TIFFCheckMalloc(), _TIFFfreeExt(), DoubleToRational(), EvaluateIFDdatasizeWrite(), tiff::tif_flags, TIFF_RATIONAL, TIFF_SWAB, TIFFErrorExtR(), TIFFSwabArrayOfLong(), and TIFFWriteDirectoryTagData().
Referenced by TIFFWriteDirectoryTagRationalDoubleArray().
|
static |
Account for or emit Sbyte array tag data.
Writes count bytes as SBYTE without conversion. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in] | value | Array of count int8_t values; not modified. Not accessed by the sizing pass. |
Definition at line 3467 of file tif_dirwrite.c.
References EvaluateIFDdatasizeWrite(), TIFF_SBYTE, and TIFFWriteDirectoryTagData().
Referenced by TIFFWriteDirectoryTagSbyteArray().
|
static |
Account for or emit Short tag data.
Writes one SHORT, byte-swapping a local copy when TIFF_SWAB is set. The value always fits inline in the entry, so sizing adds no payload size and emission cannot fail.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | value | Value to write. |
Definition at line 3499 of file tif_dirwrite.c.
References tiff::tif_flags, TIFF_SHORT, TIFF_SWAB, TIFFSwabShort(), and TIFFWriteDirectoryTagData().
Referenced by TIFFWriteDirectoryTagShort(), and TIFFWriteDirectoryTagShortLong().
|
static |
Account for or emit Short array tag data.
Writes count values as SHORT. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). When the file byte order differs from the host (TIFF_SWAB), the emission pass byte-swaps value in place and does not restore it. A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in,out] | value | Array of count uint16_t values; byte-swapped in place by the emission pass when TIFF_SWAB is set. Not accessed by the sizing pass. May be NULL for sizing, as TIFFWriteDirectoryTagShortPerSample() passes. |
Definition at line 3543 of file tif_dirwrite.c.
References EvaluateIFDdatasizeWrite(), tiff::tif_flags, TIFF_SHORT, TIFF_SWAB, TIFFErrorExtR(), TIFFSwabArrayOfShort(), and TIFFWriteDirectoryTagData().
Referenced by TIFFWriteDirectoryTagColormap(), TIFFWriteDirectoryTagLongLong8Array(), TIFFWriteDirectoryTagShortArray(), TIFFWriteDirectoryTagShortPerSample(), and TIFFWriteDirectoryTagTransferfunction().
|
static |
Account for or emit Slong8 array tag data.
Writes count values as SLONG8. In classic TIFF, reports an error and returns zero in both passes; narrowing is done only by TIFFWriteDirectoryTagSlong8Array(). Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). When the file byte order differs from the host (TIFF_SWAB), the emission pass byte-swaps value in place and does not restore it. A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in,out] | value | Array of count int64_t values; byte-swapped in place by the emission pass when TIFF_SWAB is set. Not accessed by the sizing pass. |
Definition at line 3815 of file tif_dirwrite.c.
References EvaluateIFDdatasizeWrite(), tiff::tif_flags, TIFF_BIGTIFF, TIFF_SLONG8, TIFF_SWAB, TIFFErrorExtR(), TIFFSwabArrayOfLong8(), and TIFFWriteDirectoryTagData().
Referenced by TIFFWriteDirectoryTagSlong8Array().
|
static |
Account for or emit Slong array tag data.
Writes count values as SLONG. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). When the file byte order differs from the host (TIFF_SWAB), the emission pass byte-swaps value in place and does not restore it. A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in,out] | value | Array of count int32_t values; byte-swapped in place by the emission pass when TIFF_SWAB is set. Not accessed by the sizing pass. |
Definition at line 3719 of file tif_dirwrite.c.
References EvaluateIFDdatasizeWrite(), tiff::tif_flags, TIFF_SLONG, TIFF_SWAB, TIFFSwabArrayOfLong(), and TIFFWriteDirectoryTagData().
Referenced by TIFFWriteDirectoryTagSlong8Array(), and TIFFWriteDirectoryTagSlongArray().
|
static |
Account for or emit Srational array tag data.
Converts each element with DoubleToSrational() into a temporary buffer of numerator/denominator pairs (emission pass only) and writes them as SRATIONAL, byte-swapped when TIFF_SWAB is set. NaN elements are not checked and are not valid input to DoubleToSrational(). Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in] | value | Array of count float values; not modified. Not accessed by the sizing pass. |
Definition at line 3992 of file tif_dirwrite.c.
References _TIFFCheckMalloc(), _TIFFfreeExt(), DoubleToSrational(), EvaluateIFDdatasizeWrite(), tiff::tif_flags, TIFF_SRATIONAL, TIFF_SWAB, TIFFErrorExtR(), TIFFSwabArrayOfLong(), and TIFFWriteDirectoryTagData().
Referenced by TIFFWriteDirectoryTagSrationalArray().
|
static |
Account for or emit SrationalDouble array tag data.
Converts each element with DoubleToSrational() into a temporary buffer of numerator/denominator pairs (emission pass only) and writes them as SRATIONAL, byte-swapped when TIFF_SWAB is set. NaN elements are not checked and are not valid input to DoubleToSrational(). Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in] | value | Array of count double values; not modified. Not accessed by the sizing pass. |
Definition at line 4133 of file tif_dirwrite.c.
References _TIFFCheckMalloc(), _TIFFfreeExt(), DoubleToSrational(), EvaluateIFDdatasizeWrite(), tiff::tif_flags, TIFF_SRATIONAL, TIFF_SWAB, TIFFErrorExtR(), TIFFSwabArrayOfLong(), and TIFFWriteDirectoryTagData().
Referenced by TIFFWriteDirectoryTagSrationalDoubleArray().
|
static |
Account for or emit Sshort array tag data.
Writes count values as SSHORT. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). When the file byte order differs from the host (TIFF_SWAB), the emission pass byte-swaps value in place and does not restore it. A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in,out] | value | Array of count int16_t values; byte-swapped in place by the emission pass when TIFF_SWAB is set. Not accessed by the sizing pass. |
Definition at line 3592 of file tif_dirwrite.c.
References EvaluateIFDdatasizeWrite(), tiff::tif_flags, TIFF_SSHORT, TIFF_SWAB, TIFFErrorExtR(), TIFFSwabArrayOfShort(), and TIFFWriteDirectoryTagData().
Referenced by TIFFWriteDirectoryTagSshortArray().
|
static |
Account for or emit Undefined array tag data.
Writes count bytes as UNDEFINED without conversion. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in] | value | Array of count uint8_t values; not modified. Not accessed by the sizing pass. |
Definition at line 3392 of file tif_dirwrite.c.
References EvaluateIFDdatasizeWrite(), TIFF_UNDEFINED, and TIFFWriteDirectoryTagData().
Referenced by TIFFWriteDirectoryTagUndefinedArray().
|
static |
Account for or emit Colormap tag data.
Writes the directory's three td_colormap planes, each of td_colormap_count entries (the length they were installed with, not one derived from the current BitsPerSample), as one SHORT array of 3 * td_colormap_count values. A zero count warns, skips the tag, and returns one without incrementing *ndir, in either pass. Size products that overflow are reported as errors. The emission pass concatenates the planes into a temporary buffer, so td_colormap is not modified. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted, but not when the tag is skipped. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
Definition at line 3071 of file tif_dirwrite.c.
References _TIFFCastUInt64ToSSize(), _TIFFCastUInt64ToUInt32(), _TIFFCheckMalloc(), _TIFFfreeExt(), _TIFFmemcpy(), _TIFFMultiply64(), EvaluateIFDdatasizeWrite(), TIFFDirectory::td_colormap, TIFFDirectory::td_colormap_count, tiff::tif_dir, TIFFErrorExtR(), TIFFTAG_COLORMAP, TIFFWarningExtR(), and TIFFWriteDirectoryTagCheckedShortArray().
Referenced by TIFFWriteDirectorySec().
|
static |
Insert one sorted IFD entry and emit its raw payload.
Requires non-NULL dir with capacity and a unique tag; shifts existing entries before payload I/O. Copies inline bytes or writes external bytes at tif_dataoff, checks wrap/classic size and the external 2 GiB ceiling, and aligns the next payload offset. Caller supplies already encoded/file-order data; this helper only swaps the stored external offset. Does not allocate or take ownership. On failure dir may already be shifted/initialised and file bytes/position may change even though *ndir was not incremented. Diagnostics accompany detected size/seek/write failures; no rollback.
| [in,out] | tif | Non-NULL live handle with matching schema/state; serialise access externally. |
| [in,out] | ndir | Non-NULL populated-entry count, incremented only on successful completion. |
| [in,out] | dir | Writable borrowed sorted entry array with one spare slot. |
| [in] | tag | Unique on-disk tag number. |
| [in] | datatype | File data-type code. |
| [in] | count | File element count. |
| [in] | datalength | Representable raw byte extent, consistent with file type/count. |
| [in] | data | Readable borrowed file-order bytes; NULL is only appropriate for a zero/placeholder inline payload. |
Definition at line 4750 of file tif_dirwrite.c.
References _TIFFmemcpy(), SeekOK, TIFFDirEntry::tdir_count, TIFFDirEntry::tdir_offset, TIFFDirEntry::tdir_tag, TIFFDirEntry::tdir_type, tiff::tif_dataoff, tiff::tif_flags, TIFF_BIGTIFF, TIFF_SWAB, TIFFErrorExtR(), TIFFSwabLong(), TIFFSwabLong8(), TIFFDirEntry::toff_long8, and WriteOK.
Referenced by TIFFWriteDirectoryTagCheckedAscii(), TIFFWriteDirectoryTagCheckedByteArray(), TIFFWriteDirectoryTagCheckedDoubleArray(), TIFFWriteDirectoryTagCheckedFloatArray(), TIFFWriteDirectoryTagCheckedIfd8Array(), TIFFWriteDirectoryTagCheckedIfdArray(), TIFFWriteDirectoryTagCheckedLong(), TIFFWriteDirectoryTagCheckedLong8Array(), TIFFWriteDirectoryTagCheckedLongArray(), TIFFWriteDirectoryTagCheckedRational(), TIFFWriteDirectoryTagCheckedRationalArray(), TIFFWriteDirectoryTagCheckedRationalDoubleArray(), TIFFWriteDirectoryTagCheckedSbyteArray(), TIFFWriteDirectoryTagCheckedShort(), TIFFWriteDirectoryTagCheckedShortArray(), TIFFWriteDirectoryTagCheckedSlong8Array(), TIFFWriteDirectoryTagCheckedSlongArray(), TIFFWriteDirectoryTagCheckedSrationalArray(), TIFFWriteDirectoryTagCheckedSrationalDoubleArray(), TIFFWriteDirectoryTagCheckedSshortArray(), TIFFWriteDirectoryTagCheckedUndefinedArray(), and TIFFWriteDirectoryTagLongLong8Array().
|
static |
Account for or emit Double array tag data.
Forwards to TIFFWriteDirectoryTagCheckedDoubleArray(). Writes count values as DOUBLE. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). The emission pass converts value in place to IEEE format with TIFFCvtNativeToIEEEDouble() (a no-op on IEEE hosts) and, when TIFF_SWAB is set, byte-swaps it in place; value is not restored. A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in,out] | value | Array of count double values; converted and byte-swapped in place by the emission pass. |
Definition at line 2615 of file tif_dirwrite.c.
References TIFFWriteDirectoryTagCheckedDoubleArray().
Referenced by TIFFWriteDirectorySec(), and TIFFWriteDirectoryTagSampleformatArray().
|
static |
Account for or emit Float array tag data.
Forwards to TIFFWriteDirectoryTagCheckedFloatArray(). Writes count values as FLOAT. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). The emission pass converts value in place to IEEE format with TIFFCvtNativeToIEEEFloat() (a no-op on IEEE hosts) and, when TIFF_SWAB is set, byte-swaps it in place; value is not restored. A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in,out] | value | Array of count float values; converted and byte-swapped in place by the emission pass. |
Definition at line 2581 of file tif_dirwrite.c.
References TIFFWriteDirectoryTagCheckedFloatArray().
Referenced by TIFFWriteDirectorySec(), and TIFFWriteDirectoryTagSampleformatArray().
|
static |
Account for or emit Ifd array tag data.
Forwards to TIFFWriteDirectoryTagCheckedIfdArray(). Writes count values as IFD. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). When the file byte order differs from the host (TIFF_SWAB), the emission pass byte-swaps value in place and does not restore it. A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in,out] | value | Array of count uint32_t values; byte-swapped in place by the emission pass when TIFF_SWAB is set. |
Definition at line 2648 of file tif_dirwrite.c.
References TIFFWriteDirectoryTagCheckedIfdArray().
Referenced by TIFFWriteDirectorySec().
|
static |
Account for or emit IfdIfd8 array tag data.
In BigTIFF, forwards to TIFFWriteDirectoryTagCheckedIfd8Array(), which writes IFD8 and byte-swaps value in place when TIFF_SWAB is set. In classic TIFF, copies value to a temporary uint32_t array in both passes, reports an error for any offset above 0xFFFFFFFF, and writes the copy as IFD. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in,out] | value | Array of count uint64_t IFD offsets; modified in place only in BigTIFF. |
Definition at line 2963 of file tif_dirwrite.c.
References _TIFFCheckMalloc(), _TIFFfreeExt(), tiff::tif_flags, TIFF_BIGTIFF, TIFFErrorExtR(), TIFFWriteDirectoryTagCheckedIfd8Array(), and TIFFWriteDirectoryTagCheckedIfdArray().
Referenced by TIFFWriteDirectorySec().
|
static |
Account for or emit Long tag data.
Forwards to TIFFWriteDirectoryTagCheckedLong(). Writes one LONG. The value always fits inline in the entry, so sizing adds no payload size and emission cannot fail.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | value | Value to write. |
Definition at line 2143 of file tif_dirwrite.c.
References TIFFWriteDirectoryTagCheckedLong().
Referenced by TIFFWriteDirectorySec().
|
static |
Account for or emit Long8 array tag data.
In BigTIFF, forwards to TIFFWriteDirectoryTagCheckedLong8Array(), which writes LONG8 and byte-swaps value in place when TIFF_SWAB is set. In classic TIFF, copies value to a temporary uint32_t array in both passes, reports an error for any value above 0xFFFFFFFF, and writes the copy as LONG. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in,out] | value | Array of count uint64_t values; modified in place only in BigTIFF. |
Definition at line 2248 of file tif_dirwrite.c.
References _TIFFCheckMalloc(), _TIFFfreeExt(), tiff::tif_flags, TIFF_BIGTIFF, TIFFErrorExtR(), TIFFWriteDirectoryTagCheckedLong8Array(), and TIFFWriteDirectoryTagCheckedLongArray().
Referenced by TIFFWriteDirectorySec().
|
static |
Account for or emit Long array tag data.
Forwards to TIFFWriteDirectoryTagCheckedLongArray(). Writes count values as LONG. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). When the file byte order differs from the host (TIFF_SWAB), the emission pass byte-swaps value in place and does not restore it. A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in,out] | value | Array of count uint32_t values; byte-swapped in place by the emission pass when TIFF_SWAB is set. |
Definition at line 2175 of file tif_dirwrite.c.
References TIFFWriteDirectoryTagCheckedLongArray().
Referenced by TIFFWriteDirectorySec(), and TIFFWriteDirectoryTagSampleformatArray().
|
static |
Account for or emit LongLong8 array tag data.
Writes a strip/tile offset or byte-count array. If strile-array writing is deferred (td_deferstrilearraywriting), value is ignored: sizing only increments *ndir, and emission inserts a TIFF_NOTYPE, zero-count placeholder entry to be patched later by TIFFForceStrileArrayWriting(). Otherwise BigTIFF writes LONG8 directly from value (byte-swapped in place when TIFF_SWAB is set), unless the tag is StripByteCounts or TileByteCounts, count > 1, and WriteAsLong8() decides the strip/tile size allows a narrower type. Classic TIFF and narrowed BigTIFF copy value to a temporary array in both passes: SHORT for those byte-count tags when WriteAsLong4() allows it, otherwise LONG; a value that does not fit is reported and fails. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in,out] | value | Array of count uint64_t values; ignored in deferred mode, and modified in place only on the direct BigTIFF LONG8 path. |
Definition at line 2805 of file tif_dirwrite.c.
References _TIFFCheckMalloc(), _TIFFfreeExt(), TIFFDirectory::td_deferstrilearraywriting, tiff::tif_dir, tiff::tif_flags, TIFF_BIGTIFF, TIFF_NOTYPE, TIFFErrorExtR(), TIFFStripSize64(), TIFFTAG_STRIPBYTECOUNTS, TIFFTAG_TILEBYTECOUNTS, TIFFTileSize64(), TIFFWriteDirectoryTagCheckedLong8Array(), TIFFWriteDirectoryTagCheckedLongArray(), TIFFWriteDirectoryTagCheckedShortArray(), TIFFWriteDirectoryTagData(), WriteAsLong4(), and WriteAsLong8().
Referenced by TIFFWriteDirectorySec().
|
static |
Account for or emit Rational tag data.
Forwards to TIFFWriteDirectoryTagCheckedRational(). Rejects negative and NaN values with an error in both passes, then converts value with DoubleToRational() into one RATIONAL. Sizing adds 8 bytes of payload in classic TIFF and none in BigTIFF, where the value is inline. A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | value | Value to write. |
Definition at line 2407 of file tif_dirwrite.c.
References TIFFWriteDirectoryTagCheckedRational().
Referenced by TIFFWriteDirectorySec().
|
static |
Account for or emit Rational array tag data.
Forwards to TIFFWriteDirectoryTagCheckedRationalArray(). Converts each element with DoubleToRational() into a temporary buffer of numerator/denominator pairs (emission pass only) and writes them as RATIONAL, byte-swapped when TIFF_SWAB is set. A negative or NaN element is reported by DoubleToRational() and written as 0/0 without failing. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in] | value | Array of count float values; not modified. |
Definition at line 2440 of file tif_dirwrite.c.
References TIFFWriteDirectoryTagCheckedRationalArray().
Referenced by TIFFWriteDirectorySec().
|
static |
Account for or emit RationalDouble array tag data.
Forwards to TIFFWriteDirectoryTagCheckedRationalDoubleArray(). Converts each element with DoubleToRational() into a temporary buffer of numerator/denominator pairs (emission pass only) and writes them as RATIONAL, byte-swapped when TIFF_SWAB is set. A negative or NaN element is reported by DoubleToRational() and written as 0/0 without failing. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in] | value | Array of count double values; not modified. |
Definition at line 2509 of file tif_dirwrite.c.
References TIFFWriteDirectoryTagCheckedRationalDoubleArray().
Referenced by TIFFWriteDirectorySec().
|
static |
Account for or emit Sampleformat array tag data.
Converts value to the directory's SampleFormat and BitsPerSample in a temporary buffer (allocated in both passes) and writes it as SBYTE/SSHORT/SLONG, BYTE/SHORT/LONG or FLOAT, clamping out-of-range values (NaN becomes the signed minimum or the unsigned maximum). IEEE floating point samples wider than 32 bits are written as DOUBLE directly from value, which the emission pass then byte-swaps in place when TIFF_SWAB is set. Any other SampleFormat returns zero without a diagnostic. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in,out] | value | Array of count double values; modified in place only on the DOUBLE path. |
Definition at line 1777 of file tif_dirwrite.c.
References _TIFFCheckMalloc(), _TIFFClampDoubleToFloat(), _TIFFfreeExt(), SAMPLEFORMAT_IEEEFP, SAMPLEFORMAT_INT, SAMPLEFORMAT_UINT, TIFFDirectory::td_bitspersample, TIFFDirectory::td_sampleformat, tiff::tif_dir, TIFFClampDoubleToInt16(), TIFFClampDoubleToInt32(), TIFFClampDoubleToInt8(), TIFFClampDoubleToUInt16(), TIFFClampDoubleToUInt32(), TIFFClampDoubleToUInt8(), TIFFErrorExtR(), TIFFWriteDirectoryTagByteArray(), TIFFWriteDirectoryTagDoubleArray(), TIFFWriteDirectoryTagFloatArray(), TIFFWriteDirectoryTagLongArray(), TIFFWriteDirectoryTagSbyteArray(), TIFFWriteDirectoryTagShortArray(), TIFFWriteDirectoryTagSlongArray(), and TIFFWriteDirectoryTagSshortArray().
Referenced by TIFFWriteDirectorySec().
|
static |
Account for or emit Sbyte array tag data.
Forwards to TIFFWriteDirectoryTagCheckedSbyteArray(). Writes count bytes as SBYTE without conversion. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in] | value | Array of count int8_t values; not modified. |
Definition at line 1975 of file tif_dirwrite.c.
References TIFFWriteDirectoryTagCheckedSbyteArray().
Referenced by TIFFWriteDirectorySec(), and TIFFWriteDirectoryTagSampleformatArray().
|
static |
Account for or emit Short tag data.
Forwards to TIFFWriteDirectoryTagCheckedShort(). Writes one SHORT. The value always fits inline in the entry, so sizing adds no payload size and emission cannot fail.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | value | Value to write. |
Definition at line 2000 of file tif_dirwrite.c.
References TIFFWriteDirectoryTagCheckedShort().
Referenced by TIFFWriteDirectorySec().
|
static |
Account for or emit Short array tag data.
Forwards to TIFFWriteDirectoryTagCheckedShortArray(). Writes count values as SHORT. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). When the file byte order differs from the host (TIFF_SWAB), the emission pass byte-swaps value in place and does not restore it. A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in,out] | value | Array of count uint16_t values; byte-swapped in place by the emission pass when TIFF_SWAB is set. |
Definition at line 2032 of file tif_dirwrite.c.
References TIFFWriteDirectoryTagCheckedShortArray().
Referenced by TIFFWriteDirectorySec(), and TIFFWriteDirectoryTagSampleformatArray().
|
static |
Account for or emit ShortLong tag data.
Writes value as one SHORT if it is at most 0xFFFF, otherwise as one LONG. The value always fits inline in the entry, so sizing adds no payload size and emission cannot fail.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | value | Value to write. |
Definition at line 2673 of file tif_dirwrite.c.
References TIFFWriteDirectoryTagCheckedLong(), and TIFFWriteDirectoryTagCheckedShort().
Referenced by TIFFWriteDirectorySec().
|
static |
Account for or emit Short per sample tag data.
Writes value repeated SamplesPerPixel times as a SHORT array. The sizing pass passes a NULL array to TIFFWriteDirectoryTagCheckedShortArray(), which only uses the count; the emission pass builds a temporary array. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | value | Value to write. |
Definition at line 2063 of file tif_dirwrite.c.
References _TIFFCheckMalloc(), _TIFFfreeExt(), TIFFDirectory::td_samplesperpixel, tiff::tif_dir, TIFFErrorExtR(), and TIFFWriteDirectoryTagCheckedShortArray().
Referenced by TIFFWriteDirectorySec().
|
static |
Account for or emit Slong8 array tag data.
In BigTIFF, forwards to TIFFWriteDirectoryTagCheckedSlong8Array(), which writes SLONG8 and byte-swaps value in place when TIFF_SWAB is set. In classic TIFF, copies value to a temporary int32_t array in both passes, reports an error for any value outside the int32_t range, and writes the copy as SLONG. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in,out] | value | Array of count int64_t values; modified in place only in BigTIFF. |
Definition at line 2328 of file tif_dirwrite.c.
References _TIFFCheckMalloc(), _TIFFfreeExt(), tiff::tif_flags, TIFF_BIGTIFF, TIFFErrorExtR(), TIFFWriteDirectoryTagCheckedSlong8Array(), and TIFFWriteDirectoryTagCheckedSlongArray().
Referenced by TIFFWriteDirectorySec().
|
static |
Account for or emit Slong array tag data.
Forwards to TIFFWriteDirectoryTagCheckedSlongArray(). Writes count values as SLONG. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). When the file byte order differs from the host (TIFF_SWAB), the emission pass byte-swaps value in place and does not restore it. A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in,out] | value | Array of count int32_t values; byte-swapped in place by the emission pass when TIFF_SWAB is set. |
Definition at line 2208 of file tif_dirwrite.c.
References TIFFWriteDirectoryTagCheckedSlongArray().
Referenced by TIFFWriteDirectorySec(), and TIFFWriteDirectoryTagSampleformatArray().
|
static |
Account for or emit Srational array tag data.
Forwards to TIFFWriteDirectoryTagCheckedSrationalArray(). Converts each element with DoubleToSrational() into a temporary buffer of numerator/denominator pairs (emission pass only) and writes them as SRATIONAL, byte-swapped when TIFF_SWAB is set. NaN elements are not checked and are not valid input to DoubleToSrational(). Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in] | value | Array of count float values; not modified. |
Definition at line 2474 of file tif_dirwrite.c.
References TIFFWriteDirectoryTagCheckedSrationalArray().
Referenced by TIFFWriteDirectorySec().
|
static |
Account for or emit SrationalDouble array tag data.
Forwards to TIFFWriteDirectoryTagCheckedSrationalDoubleArray(). Converts each element with DoubleToSrational() into a temporary buffer of numerator/denominator pairs (emission pass only) and writes them as SRATIONAL, byte-swapped when TIFF_SWAB is set. NaN elements are not checked and are not valid input to DoubleToSrational(). Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in] | value | Array of count double values; not modified. |
Definition at line 2545 of file tif_dirwrite.c.
References TIFFWriteDirectoryTagCheckedSrationalDoubleArray().
Referenced by TIFFWriteDirectorySec().
|
static |
Account for or emit Sshort array tag data.
Forwards to TIFFWriteDirectoryTagCheckedSshortArray(). Writes count values as SSHORT. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). When the file byte order differs from the host (TIFF_SWAB), the emission pass byte-swaps value in place and does not restore it. A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in,out] | value | Array of count int16_t values; byte-swapped in place by the emission pass when TIFF_SWAB is set. |
Definition at line 2118 of file tif_dirwrite.c.
References TIFFWriteDirectoryTagCheckedSshortArray().
Referenced by TIFFWriteDirectorySec(), and TIFFWriteDirectoryTagSampleformatArray().
|
static |
Account for or emit Subifd tag data.
If td_nsubifd is zero, there is no SubIFD tag to write: returns one without adding an entry. Otherwise writes td_subifd as the SubIFD tag: in classic TIFF as IFD from a temporary uint32_t copy made in both passes (an offset above 0xFFFFFFFF is an error), and in BigTIFF as IFD8 directly from td_subifd, which the emission pass byte-swaps in place when TIFF_SWAB is set. After a successful emission, sets TIFF_INSUBIFD and tif_nsubifd so that the next td_nsubifd directories are written as children and, for more than one child, the external child-link patch location tif_subifdoff (a single inline child is located later by TIFFWriteDirectorySec()). Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted, but not when there are no SubIFDs. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
Definition at line 3263 of file tif_dirwrite.c.
References _TIFFCheckMalloc(), _TIFFfreeExt(), TIFFDirectory::td_nsubifd, TIFFDirectory::td_subifd, tiff::tif_dataoff, tiff::tif_dir, tiff::tif_flags, tiff::tif_nsubifd, tiff::tif_subifdoff, TIFF_BIGTIFF, TIFF_INSUBIFD, TIFFErrorExtR(), TIFFTAG_SUBIFD, TIFFWriteDirectoryTagCheckedIfd8Array(), and TIFFWriteDirectoryTagCheckedIfdArray().
Referenced by TIFFWriteDirectorySec().
|
static |
Account for or emit Transferfunction tag data.
Writes TransferFunction as one SHORT array of n * td_transferfunction_count values, where n is 3 if SamplesPerPixel - ExtraSamples > 1 and 1 otherwise; three identical curves are written as one. The count is the length the curves were installed with, not one derived from the current BitsPerSample. If the count is zero or any of the n required td_transferfunction curves is NULL, warns, skips the tag, and returns one without incrementing *ndir, in either pass. The emission pass concatenates the curves into a temporary buffer. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted, but not when the tag is skipped. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
Definition at line 3146 of file tif_dirwrite.c.
References _TIFFCastUInt64ToSSize(), _TIFFCastUInt64ToUInt32(), _TIFFCheckMalloc(), _TIFFfreeExt(), _TIFFmemcmp(), _TIFFmemcpy(), _TIFFMultiply64(), EvaluateIFDdatasizeWrite(), TIFFDirectory::td_extrasamples, TIFFDirectory::td_samplesperpixel, TIFFDirectory::td_transferfunction, TIFFDirectory::td_transferfunction_count, tiff::tif_dir, TIFFErrorExtR(), TIFFTAG_TRANSFERFUNCTION, TIFFWarningExtR(), and TIFFWriteDirectoryTagCheckedShortArray().
Referenced by TIFFWriteDirectorySec().
|
static |
Account for or emit Undefined array tag data.
Forwards to TIFFWriteDirectoryTagCheckedUndefinedArray(). Writes count bytes as UNDEFINED without conversion. Sizing pass (dir NULL): adds any payload too large for the entry to td_dirdatasize_write and increments *ndir. Emission pass: inserts the entry in tag order and writes any out-of-line payload at tif_dataoff through TIFFWriteDirectoryTagData(). A failed emission can leave dir shifted and payload bytes written without incrementing *ndir; nothing is rolled back.
| [in,out] | tif | Handle whose directory is being written. |
| [in,out] | ndir | Running entry count; incremented by one when the entry is counted or inserted. |
| [in,out] | dir | NULL for the sizing pass, or the tag-sorted entry array with room for one more entry after the first *ndir entries. |
| [in] | tag | Tag number; must not already be present in dir. |
| [in] | count | Number of elements in value. |
| [in] | value | Array of count uint8_t values; not modified. |
Definition at line 1915 of file tif_dirwrite.c.
References TIFFWriteDirectoryTagCheckedUndefinedArray().
Referenced by TIFFWriteDirectorySec().
|
static |
Approximate a nonnegative scalar by bounded rational components.
Requires finite nonnegative input within the caller's established magnitude range and distinct writable outputs. Constructs a binary fraction then limits continued-fraction/GCD work to MAX_ITERATIONS, using selected signed/unsigned component bounds and initial precision. Returns unsigned magnitude components without applying a sign. No allocation, handle state, diagnostics, or ownership transfer; unsuitable for NaN/infinite/arbitrary out-of-range input.
| [in] | value | Finite nonnegative scalar within established converter range. |
| [in] | blnUseSignedRange | Nonzero limits components to INT32_MAX, zero to UINT32_MAX. |
| [in] | blnUseSmallRange | Nonzero uses the smaller initial precision range. |
| [out] | ullNum | Non-NULL numerator magnitude slot. |
| [out] | ullDenom | Non-NULL denominator magnitude slot. |
Definition at line 4227 of file tif_dirwrite.c.
References MAX_ITERATIONS, and TIFF_DOUBLE_EQ.
Referenced by DoubleToRational(), and DoubleToSrational().
|
static |
Choose whether a strile count needs a wider integer type.
Uncompressed counts use a strict size-threshold comparison. Selected codecs use a pessimistic factor-ten expansion threshold; other codecs always choose wider storage. Uses UINT16_MAX as the narrower threshold. Pure selection heuristic: no payload inspection, allocation, diagnostics, state change, or ownership transfer.
| [in] | tif | Non-NULL handle whose compression mode is inspected. |
| [in] | strile_size | Uncompressed strile size in bytes. |
Definition at line 2760 of file tif_dirwrite.c.
References _WriteAsType().
Referenced by _TIFFRewriteField(), and TIFFWriteDirectoryTagLongLong8Array().
|
static |
Choose whether a strile count needs a wider integer type.
Uncompressed counts use a strict size-threshold comparison. Selected codecs use a pessimistic factor-ten expansion threshold; other codecs always choose wider storage. Uses UINT32_MAX as the narrower threshold. Pure selection heuristic: no payload inspection, allocation, diagnostics, state change, or ownership transfer.
| [in] | tif | Non-NULL handle whose compression mode is inspected. |
| [in] | strile_size | Uncompressed strile size in bytes. |
Definition at line 2740 of file tif_dirwrite.c.
References _WriteAsType().
Referenced by _TIFFRewriteField(), and TIFFWriteDirectoryTagLongLong8Array().