|
LibTIFF 4.7.2
TIFF library public API and implementation reference
|
Implement built-in/custom value access and allocate cached defaults. More...
Macros | |
| #define | DATATYPE_VOID 0 /* !untyped data */ |
| Identify legacy DataType untyped samples. | |
| #define | DATATYPE_INT 1 /* !signed integer data */ |
| Identify legacy DataType signed integer samples. | |
| #define | DATATYPE_UINT 2 /* !unsigned integer data */ |
| Identify legacy DataType unsigned integer samples. | |
| #define | DATATYPE_IEEEFP 3 /* !IEEE floating point data */ |
| Identify legacy DataType IEEE floating-point samples. | |
| #define | EXTRASAMPLE_COREL_UNASSALPHA 999 |
| Recognise Corel's nonstandard unassociated-alpha code. | |
Functions | |
| static int | TIFFDefaultTransferFunction (TIFF *tif, TIFFDirectory *td) |
| Allocate and cache default gamma transfer tables. | |
| static int | TIFFDefaultRefBlackWhite (TIFF *tif, TIFFDirectory *td) |
| Allocate and cache six default reference levels. | |
| static void | cancelColorMap (TIFF *tif) |
| Drop a ColorMap that no longer describes the directory it belongs to. | |
| static void | cancelTransferFunction (TIFF *tif) |
| Drop a TransferFunction that no longer describes the directory it belongs to. | |
| static int | setColorMap (TIFF *tif, va_list ap, uint32_t count) |
| Install the ColorMap arrays. | |
| static int | setTransferFunction (TIFF *tif, va_list ap, uint32_t count) |
| Install the TransferFunction curves. | |
| static int | setExtraSamples (TIFF *tif, va_list ap, uint32_t *v) |
| Validate and install extra-sample interpretations. | |
| static uint16_t | countInkNamesString (TIFF *tif, uint32_t slen, const char *s) |
| Count terminated ink names within a byte extent. | |
| static void | removeCustomValue (TIFFDirectory *td, int i) |
| Remove a custom tag entry whose value could not be set. | |
| static int | _TIFFVSetField (TIFF *tif, uint32_t tag, va_list ap) |
| Implement core and generic custom-tag storage. | |
| static int | OkToChangeTag (TIFF *tif, uint32_t tag) |
| Check registration and tag mutability during writing. | |
| static int | _TIFFVGetField (TIFF *tif, uint32_t tag, va_list ap) |
| Implement core and generic custom-tag queries. | |
Implement built-in/custom value access and allocate cached defaults.
| #define DATATYPE_IEEEFP 3 /* !IEEE floating point data */ |
| #define DATATYPE_INT 1 /* !signed integer data */ |
| #define DATATYPE_UINT 2 /* !unsigned integer data */ |
| #define DATATYPE_VOID 0 /* !untyped data */ |
| #define EXTRASAMPLE_COREL_UNASSALPHA 999 |
Recognise Corel's nonstandard unassociated-alpha code.
setExtraSamples() repairs this value in the caller's array before copying it.
|
static |
Implement core and generic custom-tag queries.
See Tag arguments for exact pointer types, counts, exceptions, and lifetimes. Values are read from the current in-memory directory, not reread wholesale from disk. Registered pseudo-tags bypass the presence- bit test and may have codec effects. Array/string results are borrowed and must not be freed or modified; replacement, unsetting, directory change, codec cleanup, or handle cleanup can invalidate them. Deferred strip/tile arrays may allocate and perform I/O. Missing fields normally return zero silently; codec, I/O, and allocation failures can dispatch diagnostics. Outputs are usable only on success, and failure need not preserve them. A custom tag without a stored value is reported as absent unless its count is passed back. No errno contract is provided. The dispatcher normally checks registration and presence first. The ordinary TransferFunction case consumes three output pointers even for one channel, unlike the one-pointer default fallback.
| [in,out] | tif | Non-NULL live TIFF handle; accessed without internal locking. |
| [in] | tag | Registered core/custom tag number. |
| [in,out] | ap | Borrowed output argument list; traversal and pointed-to outputs may change. |
Definition at line 1720 of file tif_dir.c.
References _TIFFFillStriles(), TIFFTagValue::count, DATATYPE_IEEEFP, DATATYPE_INT, DATATYPE_UINT, DATATYPE_VOID, EXTRASAMPLE_ASSOCALPHA, _TIFFField::field_bit, FIELD_CUSTOM, _TIFFField::field_name, _TIFFField::field_passcount, _TIFFField::field_readcount, _TIFFField::field_tag, _TIFFField::field_type, TIFFTagValue::info, isPseudoTag, SAMPLEFORMAT_IEEEFP, SAMPLEFORMAT_INT, SAMPLEFORMAT_UINT, SAMPLEFORMAT_VOID, TIFFDirectory::td_bitspersample, TIFFDirectory::td_colormap, TIFFDirectory::td_compression, TIFFDirectory::td_customValueCount, TIFFDirectory::td_customValues, TIFFDirectory::td_extrasamples, TIFFDirectory::td_fillorder, TIFFDirectory::td_halftonehints, TIFFDirectory::td_imagedepth, TIFFDirectory::td_imagelength, TIFFDirectory::td_imagewidth, TIFFDirectory::td_inknames, TIFFDirectory::td_maxsamplevalue, TIFFDirectory::td_minsamplevalue, TIFFDirectory::td_nsubifd, 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_sampleinfo, TIFFDirectory::td_samplesperpixel, TIFFDirectory::td_smaxsamplevalue, TIFFDirectory::td_sminsamplevalue, TIFFDirectory::td_stripbytecount_p, TIFFDirectory::td_stripoffset_p, TIFFDirectory::td_subfiletype, TIFFDirectory::td_subifd, TIFFDirectory::td_threshholding, TIFFDirectory::td_tiledepth, TIFFDirectory::td_tilelength, TIFFDirectory::td_tilewidth, TIFFDirectory::td_transferfunction, TIFFDirectory::td_xposition, TIFFDirectory::td_xresolution, TIFFDirectory::td_ycbcrpositioning, TIFFDirectory::td_ycbcrsubsampling, TIFFDirectory::td_yposition, TIFFDirectory::td_yresolution, tiff::tif_dir, tiff::tif_flags, tiff::tif_name, TIFF_ANY, TIFF_ASCII, TIFF_BYTE, TIFF_DOUBLE, TIFF_FLOAT, TIFF_IFD, TIFF_IFD8, TIFF_LONG, TIFF_LONG8, TIFF_NOTYPE, TIFF_PERSAMPLE, TIFF_RATIONAL, TIFF_SBYTE, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SPP, TIFF_SRATIONAL, TIFF_SSHORT, TIFF_UNDEFINED, TIFF_VARIABLE, TIFF_VARIABLE2, TIFFErrorExtR(), TIFFFieldSetGetSize(), TIFFFindField(), TIFFTAG_BITSPERSAMPLE, TIFFTAG_COLORMAP, TIFFTAG_COMPRESSION, TIFFTAG_DATATYPE, TIFFTAG_DOTRANGE, TIFFTAG_EXTRASAMPLES, TIFFTAG_FILLORDER, TIFFTAG_HALFTONEHINTS, TIFFTAG_IMAGEDEPTH, TIFFTAG_IMAGELENGTH, TIFFTAG_IMAGEWIDTH, TIFFTAG_INKNAMES, TIFFTAG_MATTEING, 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_TRANSFERFUNCTION, TIFFTAG_XPOSITION, TIFFTAG_XRESOLUTION, TIFFTAG_YCBCRPOSITIONING, TIFFTAG_YCBCRSUBSAMPLING, TIFFTAG_YPOSITION, TIFFTAG_YRESOLUTION, and TIFFTagValue::value.
Referenced by TIFFDefaultDirectory().
|
static |
Implement core and generic custom-tag storage.
See Tag arguments for exact promoted values, counts, array lengths, and exceptions. Changes update memory and dirty/field bits; file- directory persistence requires a later write/flush. An unregistered tag returns zero silently (and without va_end); registration and mutability are diagnosed by OkToChangeTag() in TIFFVSetField(), not here. Codec selection may clean up and reinitialise codec state. Core setters copy arrays/strings without taking ownership, but ExtraSamples may repair a caller element in place. Replacement copies the new value before releasing the old one, so input may alias the stored value it replaces. Failure can discard old values or alter codec/related tags; there is no rollback. A changed BitsPerSample sets the recorded length of a set ColorMap when the new length fits the allocated planes (so narrowing and widening again restores the entries), and otherwise cancels it with a warning; it always cancels a set TransferFunction with a warning. ColorMap and TransferFunction reject a NULL array before replacing anything, and report a copy failure after discarding the whole table. A custom tag whose new value cannot be stored is removed from the directory, together with any previous value, rather than left as an entry without a value. Some void array-copy helpers lose data on allocation failure of a core tag without changing the setter's success result. Diagnostics and errno alone do not establish success. The caller must already have passed OkToChangeTag(); codec overrides normally delegate here.
| [in,out] | tif | Non-NULL live TIFF handle; accessed without internal locking. |
| [in] | tag | Registered core/custom tag number. |
| [in,out] | ap | Borrowed promoted value list; see Tag arguments. The helper traverses the supplied list and calls va_end(ap) on its normal and value-error exit paths, but not on the early unregistered-tag return; pass a dedicated copy when retaining another traversal. |
Definition at line 599 of file tif_dir.c.
References _TIFFCheckMalloc(), _TIFFClampDoubleToFloat(), _TIFFfreeExt(), _TIFFmemcpy(), _TIFFmemset(), _TIFFMultiplySSize(), _TIFFNoPostDecode(), _TIFFreallocExt(), _TIFFsetDoubleArrayExt(), _TIFFsetFloatArrayExt(), _TIFFsetLong8Array(), _TIFFsetNString(), _TIFFsetShortArrayExt(), _TIFFSwab16BitData(), _TIFFSwab24BitData(), _TIFFSwab32BitData(), _TIFFSwab64BitData(), cancelColorMap(), cancelTransferFunction(), TIFFTagValue::count, countInkNamesString(), DATATYPE_IEEEFP, DATATYPE_INT, DATATYPE_UINT, DATATYPE_VOID, EXTRASAMPLE_ASSOCALPHA, _TIFFField::field_bit, FIELD_COLORMAP, FIELD_COMPRESSION, FIELD_CUSTOM, FIELD_IGNORE, FIELD_INKNAMES, _TIFFField::field_name, FIELD_NUMBEROFINKS, _TIFFField::field_passcount, FIELD_SAMPLESPERPIXEL, FIELD_SMAXSAMPLEVALUE, FIELD_SMINSAMPLEVALUE, _TIFFField::field_tag, FIELD_TILEDIMENSIONS, FIELD_TRANSFERFUNCTION, _TIFFField::field_type, _TIFFField::field_writecount, FILLORDER_LSB2MSB, FILLORDER_MSB2LSB, TIFFTagValue::info, isPseudoTag, ORIENTATION_LEFTBOT, ORIENTATION_TOPLEFT, PERSAMPLE_MULTI, PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, removeCustomValue(), RESUNIT_CENTIMETER, RESUNIT_NONE, SAMPLEFORMAT_COMPLEXIEEEFP, SAMPLEFORMAT_COMPLEXINT, SAMPLEFORMAT_IEEEFP, SAMPLEFORMAT_INT, SAMPLEFORMAT_UINT, SAMPLEFORMAT_VOID, setByteArray(), setColorMap(), setDoubleArrayOneValue(), setExtraSamples(), setTransferFunction(), tiff::tif_cleanup, tiff::tif_dir, tiff::tif_flags, tiff::tif_mode, tiff::tif_name, tiff::tif_postdecode, TIFF_ANY, TIFF_ASCII, TIFF_BIGTIFF, TIFF_BYTE, TIFF_DIRTYDIRECT, TIFF_DOUBLE, TIFF_FLOAT, TIFF_IFD, TIFF_IFD8, TIFF_INSUBIFD, TIFF_ISTILED, TIFF_LONG, TIFF_LONG8, TIFF_NOTYPE, TIFF_PERSAMPLE, TIFF_RATIONAL, TIFF_SBYTE, TIFF_SHORT, TIFF_SLONG, TIFF_SLONG8, TIFF_SPP, TIFF_SRATIONAL, TIFF_SSHORT, TIFF_SWAB, TIFF_UNDEFINED, TIFF_VARIABLE, TIFF_VARIABLE2, TIFFClrFieldBit, TIFFErrorExtR(), TIFFFieldSet, TIFFFieldSetGetSize(), TIFFFieldWithTag(), TIFFFindField(), TIFFSetCompressionScheme(), TIFFSetFieldBit, TIFFTAG_BITSPERSAMPLE, TIFFTAG_COLORMAP, TIFFTAG_COMPRESSION, TIFFTAG_DATATYPE, TIFFTAG_DOTRANGE, TIFFTAG_EXTRASAMPLES, TIFFTAG_FILLORDER, TIFFTAG_HALFTONEHINTS, TIFFTAG_IMAGEDEPTH, TIFFTAG_IMAGELENGTH, TIFFTAG_IMAGEWIDTH, TIFFTAG_INKNAMES, TIFFTAG_MATTEING, TIFFTAG_MAXSAMPLEVALUE, TIFFTAG_MINSAMPLEVALUE, TIFFTAG_NUMBEROFINKS, TIFFTAG_ORIENTATION, TIFFTAG_PAGENUMBER, TIFFTAG_PERSAMPLE, TIFFTAG_PHOTOMETRIC, TIFFTAG_PLANARCONFIG, TIFFTAG_REFERENCEBLACKWHITE, TIFFTAG_RESOLUTIONUNIT, TIFFTAG_ROWSPERSTRIP, TIFFTAG_SAMPLEFORMAT, TIFFTAG_SAMPLESPERPIXEL, TIFFTAG_SMAXSAMPLEVALUE, TIFFTAG_SMINSAMPLEVALUE, TIFFTAG_SUBFILETYPE, TIFFTAG_SUBIFD, TIFFTAG_THRESHHOLDING, TIFFTAG_TILEDEPTH, TIFFTAG_TILELENGTH, TIFFTAG_TILEWIDTH, TIFFTAG_TRANSFERFUNCTION, TIFFTAG_XPOSITION, TIFFTAG_XRESOLUTION, TIFFTAG_YCBCRPOSITIONING, TIFFTAG_YCBCRSUBSAMPLING, TIFFTAG_YPOSITION, TIFFTAG_YRESOLUTION, TIFFWarningExtR(), and TIFFTagValue::value.
Referenced by TIFFDefaultDirectory().
|
static |
Drop a ColorMap that no longer describes the directory it belongs to.
Releases every plane, clears the recorded length and capacity with them, and unsets FIELD_COLORMAP. Safe to call when nothing is installed.
| [in,out] | tif | Directory handle owning the planes. |
Definition at line 264 of file tif_dir.c.
References _TIFFfreeExt(), FIELD_COLORMAP, TIFFDirectory::td_colormap, TIFFDirectory::td_colormap_alloc, TIFFDirectory::td_colormap_count, tiff::tif_dir, and TIFFClrFieldBit.
Referenced by _TIFFVSetField(), and setColorMap().
|
static |
Drop a TransferFunction that no longer describes the directory it belongs to.
Releases every curve, clears the recorded length with them, and unsets FIELD_TRANSFERFUNCTION. Safe to call when nothing is installed.
| [in,out] | tif | Directory handle owning the curves. |
Definition at line 292 of file tif_dir.c.
References _TIFFfreeExt(), FIELD_TRANSFERFUNCTION, TIFFDirectory::td_transferfunction, TIFFDirectory::td_transferfunction_count, tiff::tif_dir, and TIFFClrFieldBit.
Referenced by _TIFFVSetField(), setExtraSamples(), and setTransferFunction().
|
static |
Count terminated ink names within a byte extent.
Scans without copying or taking ownership. Every component must end within the extent. Uses a uint16_t counter, so callers must keep the number of names representable.
| [in] | tif | Non-NULL handle; used only for its name and to dispatch the diagnostic. |
| [in] | slen | Byte extent of s; zero is reported as invalid. |
| [in] | s | Readable borrowed sequence of null-terminated names spanning slen bytes. |
Definition at line 512 of file tif_dir.c.
References tiff::tif_name, and TIFFErrorExtR().
Referenced by _TIFFVSetField().
|
static |
Check registration and tag mutability during writing.
Looks up the descriptor and its ok-to-change flag, allowing ImageLength after writing begins. Unknown or immutable tags dispatch an error. No values are consumed, no ownership changes, and only the lookup cache changes.
| [in,out] | tif | Non-NULL live TIFF handle; accessed without internal locking. |
| [in] | tag | Requested tag number. |
Definition at line 1594 of file tif_dir.c.
References _TIFFField::field_name, _TIFFField::field_oktochange, isPseudoTag, tiff::tif_flags, tiff::tif_name, TIFF_ANY, TIFF_BEENWRITING, TIFFErrorExtR(), TIFFFindField(), and TIFFTAG_IMAGELENGTH.
Referenced by TIFFVSetField().
|
static |
Remove a custom tag entry whose value could not be set.
Keeping such an entry would leave a non-zero count with a NULL value, which the getters and the directory writer treat as a valid field. Shifts later entries down by one and decrements the entry count, without shrinking the array. Does not free the entry's value, which the caller must already have released or detached, and does not change field bits.
| [in,out] | td | Directory whose custom-value array holds entry i. |
| [in] | i | Index of the entry to remove, from zero to td_customValueCount - 1. |
Definition at line 554 of file tif_dir.c.
References TIFFDirectory::td_customValueCount, and TIFFDirectory::td_customValues.
Referenced by _TIFFVSetField().
|
static |
Install the ColorMap arrays.
All three planes hold count entries and are installed as a unit, so that the length of the ColorMap never has to be derived from BitsPerSample again. A missing plane is rejected here rather than left as a NULL pointer for TIFFWriteDirectory() to dereference. count is recorded as both the length and the capacity of the planes.
| [in,out] | tif | Directory handle receiving the ColorMap. |
| [in] | ap | Argument list positioned at three uint16_t arrays. |
| [in] | count | Number of entries in each plane. |
Definition at line 325 of file tif_dir.c.
References cancelColorMap(), setShortArrayWithCount(), TIFFDirectory::td_colormap, TIFFDirectory::td_colormap_alloc, TIFFDirectory::td_colormap_count, tiff::tif_dir, tiff::tif_name, and TIFFErrorExtR().
Referenced by _TIFFVSetField().
|
static |
Validate and install extra-sample interpretations.
Reads promoted count and a mutable uint16_t array. Converts Corel value 999 to unassociated alpha in caller storage, even before a later element might fail. If the change makes a previously single-channel TransferFunction require three channels, warns and cancels it: every curve is freed, the recorded length is cleared, and FIELD_TRANSFERFUNCTION is unset. Replaces the owned sample-info copy destructively; copy allocation failure is not reflected in the return value.
| [in,out] | tif | Non-NULL live TIFF handle; accessed without internal locking. |
| [in,out] | ap | Borrowed list containing promoted count and mutable array pointer. |
| [out] | v | Non-NULL slot receiving the truncated uint16_t count for the caller diagnostic. |
Definition at line 441 of file tif_dir.c.
References _TIFFsetShortArrayExt(), cancelTransferFunction(), EXTRASAMPLE_COREL_UNASSALPHA, EXTRASAMPLE_UNASSALPHA, TIFFDirectory::td_extrasamples, TIFFDirectory::td_sampleinfo, TIFFDirectory::td_samplesperpixel, TIFFDirectory::td_transferfunction, tiff::tif_dir, and TIFFWarningExtR().
Referenced by _TIFFVSetField().
|
static |
Install the TransferFunction curves.
Depending on SamplesPerPixel and ExtraSamples either one or three curves of count entries are expected. As for the ColorMap, the curves and the count they were allocated for are installed as a unit, and a missing curve is rejected before any of them is installed.
| [in,out] | tif | Directory handle receiving the curves. |
| [in] | ap | Argument list positioned at one or three uint16_t arrays. |
| [in] | count | Number of entries in each curve. |
Definition at line 372 of file tif_dir.c.
References cancelTransferFunction(), setShortArrayWithCount(), TIFFDirectory::td_extrasamples, TIFFDirectory::td_samplesperpixel, TIFFDirectory::td_transferfunction, TIFFDirectory::td_transferfunction_count, tiff::tif_dir, tiff::tif_name, and TIFFErrorExtR().
Referenced by _TIFFVSetField().
|
static |
Allocate and cache six default reference levels.
Requires an empty reference array slot; allocates handle-owned floats without setting tag presence. YCbCr uses {0,255,128,255,128,255}; other photometrics use zero and the bit-depth maximum per channel, capped at UINT64_MAX for 64 or more bits. Does not free an existing array. Allocation-policy diagnostics can occur; exhaustion otherwise returns zero silently.
| [in,out] | tif | Non-NULL live TIFF handle; accessed without internal locking. |
| [in,out] | td | Non-NULL directory with an empty reference slot and current bit depth/photometric. |
Definition at line 378 of file tif_aux.c.
References _TIFFmallocExt(), PHOTOMETRIC_YCBCR, TIFFDirectory::td_bitspersample, TIFFDirectory::td_photometric, and TIFFDirectory::td_refblackwhite.
Referenced by TIFFVGetFieldDefaulted().
|
static |
Allocate and cache default gamma transfer tables.
Requires empty transfer-function slots; clears all three slots on entry without freeing old allocations. Builds 2^BitsPerSample entries using gamma 2.2 and allocates one or three identical arrays according to colour-channel count. Rejects more than 24 bits. On partial allocation failure frees all new arrays and leaves slots NULL. Clears td_transferfunction_count on entry and records the curve length only once every curve is in place. The directory owns successful arrays and releases them in TIFFFreeDirectory(). Does not mark tag presence. Caller adds the ordinary no-space diagnostic; allocation policy may report separately.
| [in,out] | tif | Non-NULL live TIFF handle; accessed without internal locking. |
| [in,out] | td | Non-NULL directory with empty transfer-function slots and consistent sample counts. |
Definition at line 301 of file tif_aux.c.
References _TIFFfreeExt(), _TIFFmallocExt(), _TIFFmemcpy(), TIFFDirectory::td_bitspersample, TIFFDirectory::td_extrasamples, TIFFDirectory::td_samplesperpixel, TIFFDirectory::td_transferfunction, and TIFFDirectory::td_transferfunction_count.
Referenced by TIFFVGetFieldDefaulted().