LibTIFF 4.7.2
TIFF library public API and implementation reference
Loading...
Searching...
No Matches
Modules | Data Structures | Typedefs | Functions | Variables
Compression registry and dispatch

Register, enumerate, and install compression implementations. More...

Collaboration diagram for Compression registry and dispatch:

Modules

 Predictor transforms
 Chain codec methods and transform predicted rows.
 
 Uncompressed and byte-run codecs
 Implement uncompressed PackBits ThunderScan and NeXT transfers.
 
 LZW codec
 Manage TIFF LZW dictionaries bit streams and predictor-aware transfers.
 
 ZSTD streaming codec
 Implement predictor-aware ZSTD frame streaming.
 
 LZMA2 streaming codec
 Implement filtered LZMA2 stream compression.
 
 Deflate codec
 Implement zlib and optional whole-strile libdeflate compression.
 
 WebP frame codec
 Stage and transfer WebP RGB or RGBA frames.
 
 JBIG plane codec
 Transfer complete JBIG image planes through strip callbacks.
 
 LERC frame codec
 Stage scalar samples validity masks and secondary compression.
 
 CCITT fax codecs
 Encode and decode Group3 Group4 and aligned bilevel runs.
 
 PixarLog codec
 Compand linear samples into predicted eleven-bit zlib streams.
 
 SGILog codec
 Compress logarithmic luminance and packed LogLuv pixel rows.
 
 JPEG dependency interface
 Bridge dependency error handling and borrowed JPEG buffers.
 
 Old-style JPEG reconstruction
 The decode-only old-style JPEG codec reconstructs a single dependency stream.
 

Data Structures

struct  _codec
 Link a dynamically registered codec allocation. More...
 

Typedefs

typedef struct _codec codec_t
 Link a dynamically registered codec allocation.
 

Functions

static int _notConfigured (TIFF *tif)
 Report that the current compression support was not built.
 
static int NotConfigured (TIFF *tif, int scheme)
 Install unavailable-codec setup methods while accepting metadata access.
 
static int TIFFNoEncode (TIFF *tif, const char *method)
 Diagnose an unsupported encoder operation.
 
static int TIFFNoDecode (TIFF *tif, const char *method)
 Diagnose an unsupported decoder operation.
 
static int _TIFFNoFixupTags (TIFF *tif)
 Accept a no-op codec tag fixup.
 
static int _TIFFtrue (TIFF *tif)
 Accept a no-op codec setup or completion.
 
static void _TIFFvoid (TIFF *tif)
 Perform no codec close or cleanup work.
 
static uint64_t _TIFFDefaultGetMaxCompressionRatio (TIFF *tif)
 Report an unknown codec compression ratio.
 
static uint64_t _TIFFGetMaxCompressionRatioOne (TIFF *tif)
 Report the uncompressed ratio of one.
 
int _TIFFNoRowEncode (TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
 Report unsupported codec encoding.
 
int _TIFFNoStripEncode (TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
 Report unsupported codec encoding.
 
int _TIFFNoTileEncode (TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
 Report unsupported codec encoding.
 
int _TIFFNoRowDecode (TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
 Report unsupported codec decoding.
 
int _TIFFNoStripDecode (TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
 Report unsupported codec decoding.
 
int _TIFFNoTileDecode (TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
 Report unsupported codec decoding.
 
int _TIFFNoPreCode (TIFF *tif, uint16_t s)
 Accept a no-op codec preparation.
 
int _TIFFNoSeek (TIFF *tif, uint32_t off)
 Report unsupported codec seeking.
 
void _TIFFSetDefaultCompressionState (TIFF *tif)
 Install fallback codec callbacks and reset raw-access flags.
 
int TIFFSetCompressionScheme (TIFF *tif, int scheme)
 Reset methods and install the selected compression implementation.
 
int TIFFSetDefaultCompressionState (TIFF *tif)
 Retain an obsolete declaration with no library implementation.
 

Variables

static codec_t * registeredCODECS = NULL
 Head the newest-first registered codec list.
 
const TIFFCodec _TIFFBuiltinCODECS []
 Describe built-in compression names and initialisers.
 

Detailed Description

Register, enumerate, and install compression implementations.

Typedef Documentation

◆ codec_t

typedef struct _codec codec_t

Link a dynamically registered codec allocation.

The node, descriptor and copied name share one allocation released by unregister. Global list operations require external serialisation.

Function Documentation

◆ _notConfigured()

static int _notConfigured ( TIFF *  tif)
static

Report that the current compression support was not built.

Looks up a display name and dispatches handle diagnostics; no allocation, pixel I/O, or buffer ownership transfer.

Parameters
[in]tifNon-NULL live handle; td_compression and tif_name are read for the diagnostic and codec state is unchanged.
Returns
Zero unconditionally.

Definition at line 126 of file tif_codec.c.

References TIFFCodec::name, TIFFDirectory::td_compression, tiff::tif_dir, tiff::tif_name, TIFFErrorExtR(), and TIFFFindCODEC().

Referenced by NotConfigured().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _TIFFDefaultGetMaxCompressionRatio()

static uint64_t _TIFFDefaultGetMaxCompressionRatio ( TIFF *  tif)
static

Report an unknown codec compression ratio.

No state, allocation, I/O, diagnostics or ownership effects.

Parameters
[in]tifHandle (ignored).
Returns
Zero for unknown.

Definition at line 210 of file tif_compress.c.

Referenced by _TIFFSetDefaultCompressionState().

Here is the caller graph for this function:

◆ _TIFFGetMaxCompressionRatioOne()

static uint64_t _TIFFGetMaxCompressionRatioOne ( TIFF *  tif)
static

Report the uncompressed ratio of one.

No state, allocation, I/O, diagnostics or ownership effects.

Parameters
[in]tifHandle (ignored).
Returns
One unconditionally.

Definition at line 225 of file tif_compress.c.

Referenced by TIFFSetCompressionScheme().

Here is the caller graph for this function:

◆ _TIFFNoFixupTags()

static int _TIFFNoFixupTags ( TIFF *  tif)
static

Accept a no-op codec tag fixup.

Ignores the handle; no state, allocation, I/O, diagnostics or ownership effects.

Parameters
[in]tifHandle (ignored).
Returns
One unconditionally.

Definition at line 130 of file tif_compress.c.

Referenced by _TIFFSetDefaultCompressionState().

Here is the caller graph for this function:

◆ _TIFFNoPreCode()

int _TIFFNoPreCode ( TIFF *  tif,
uint16_t  s 
)
extern

Accept a no-op codec preparation.

No pixel buffer access, allocation, I/O, or ownership transfer. Ignores all arguments without diagnostics.

Parameters
[in]tifUnused handle.
[in]sUnused compatibility argument; does not select a working codec operation.
Returns
One unconditionally.

Definition at line 168 of file tif_compress.c.

Referenced by _TIFFSetDefaultCompressionState().

Here is the caller graph for this function:

◆ _TIFFNoRowDecode()

int _TIFFNoRowDecode ( TIFF *  tif,
uint8_t *  pp,
tmsize_t  cc,
uint16_t  s 
)
extern

Report unsupported codec decoding.

No pixel buffer access, allocation, I/O, or ownership transfer. Dispatches handle diagnostics; registry lookup supplies the name when available.

Parameters
[in]tifNon-NULL live handle; only td_compression and tif_name are read, for the diagnostic. Not modified.
[in]ppUnused compatibility argument; no buffer access occurs.
[in]ccUnused compatibility argument; does not select a working codec operation.
[in]sUnused compatibility argument; does not select a working codec operation.
Returns
Zero unconditionally.

Definition at line 136 of file tif_compress.c.

References TIFFNoDecode().

Referenced by _TIFFSetDefaultCompressionState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _TIFFNoRowEncode()

int _TIFFNoRowEncode ( TIFF *  tif,
uint8_t *  pp,
tmsize_t  cc,
uint16_t  s 
)
extern

Report unsupported codec encoding.

No pixel buffer access, allocation, I/O, or ownership transfer. Dispatches handle diagnostics; registry lookup supplies the name when available.

Parameters
[in]tifNon-NULL live handle; only td_compression and tif_name are read, for the diagnostic. Not modified.
[in]ppUnused compatibility argument; no buffer access occurs.
[in]ccUnused compatibility argument; does not select a working codec operation.
[in]sUnused compatibility argument; does not select a working codec operation.
Returns
Minus one unconditionally.

Definition at line 69 of file tif_compress.c.

References TIFFNoEncode().

Referenced by _TIFFSetDefaultCompressionState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _TIFFNoSeek()

int _TIFFNoSeek ( TIFF *  tif,
uint32_t  off 
)
extern

Report unsupported codec seeking.

No pixel buffer access, allocation, I/O, or ownership transfer. Reports that the compression algorithm does not support random access through the handle's error handler.

Parameters
[in]tifNon-NULL live handle used for the diagnostic (tif_name); not modified.
[in]offUnused compatibility argument; does not select a working codec operation.
Returns
Zero unconditionally.

Definition at line 160 of file tif_compress.c.

References tiff::tif_name, and TIFFErrorExtR().

Referenced by _TIFFSetDefaultCompressionState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _TIFFNoStripDecode()

int _TIFFNoStripDecode ( TIFF *  tif,
uint8_t *  pp,
tmsize_t  cc,
uint16_t  s 
)
extern

Report unsupported codec decoding.

No pixel buffer access, allocation, I/O, or ownership transfer. Dispatches handle diagnostics; registry lookup supplies the name when available.

Parameters
[in]tifNon-NULL live handle; only td_compression and tif_name are read, for the diagnostic. Not modified.
[in]ppUnused compatibility argument; no buffer access occurs.
[in]ccUnused compatibility argument; does not select a working codec operation.
[in]sUnused compatibility argument; does not select a working codec operation.
Returns
Zero unconditionally.

Definition at line 144 of file tif_compress.c.

References TIFFNoDecode().

Referenced by _TIFFSetDefaultCompressionState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _TIFFNoStripEncode()

int _TIFFNoStripEncode ( TIFF *  tif,
uint8_t *  pp,
tmsize_t  cc,
uint16_t  s 
)
extern

Report unsupported codec encoding.

No pixel buffer access, allocation, I/O, or ownership transfer. Dispatches handle diagnostics; registry lookup supplies the name when available.

Parameters
[in]tifNon-NULL live handle; only td_compression and tif_name are read, for the diagnostic. Not modified.
[in]ppUnused compatibility argument; no buffer access occurs.
[in]ccUnused compatibility argument; does not select a working codec operation.
[in]sUnused compatibility argument; does not select a working codec operation.
Returns
Minus one unconditionally.

Definition at line 77 of file tif_compress.c.

References TIFFNoEncode().

Referenced by _TIFFSetDefaultCompressionState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _TIFFNoTileDecode()

int _TIFFNoTileDecode ( TIFF *  tif,
uint8_t *  pp,
tmsize_t  cc,
uint16_t  s 
)
extern

Report unsupported codec decoding.

No pixel buffer access, allocation, I/O, or ownership transfer. Dispatches handle diagnostics; registry lookup supplies the name when available.

Parameters
[in]tifNon-NULL live handle; only td_compression and tif_name are read, for the diagnostic. Not modified.
[in]ppUnused compatibility argument; no buffer access occurs.
[in]ccUnused compatibility argument; does not select a working codec operation.
[in]sUnused compatibility argument; does not select a working codec operation.
Returns
Zero unconditionally.

Definition at line 152 of file tif_compress.c.

References TIFFNoDecode().

Referenced by _TIFFSetDefaultCompressionState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _TIFFNoTileEncode()

int _TIFFNoTileEncode ( TIFF *  tif,
uint8_t *  pp,
tmsize_t  cc,
uint16_t  s 
)
extern

Report unsupported codec encoding.

No pixel buffer access, allocation, I/O, or ownership transfer. Dispatches handle diagnostics; registry lookup supplies the name when available.

Parameters
[in]tifNon-NULL live handle; only td_compression and tif_name are read, for the diagnostic. Not modified.
[in]ppUnused compatibility argument; no buffer access occurs.
[in]ccUnused compatibility argument; does not select a working codec operation.
[in]sUnused compatibility argument; does not select a working codec operation.
Returns
Minus one unconditionally.

Definition at line 85 of file tif_compress.c.

References TIFFNoEncode().

Referenced by _TIFFSetDefaultCompressionState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _TIFFSetDefaultCompressionState()

void _TIFFSetDefaultCompressionState ( TIFF *  tif)
extern

Install fallback codec callbacks and reset raw-access flags.

Assigns no-op setup/close/cleanup, unsupported encode/decode/seek methods, default sizing, and unknown ratio. Sets tif_decodestatus and tif_encodestatus to TRUE and clears NOBITREV/NOREADRAW/UPSAMPLED, so a codec change does not inherit a previous codec's upsampling. Does not free old state, flush data, allocate, read/write bytes, or report status. Caller must clean up previous codec first.

Parameters
[in,out]tifNon-NULL live handle whose codec methods and flags are overwritten; serialise access externally.

Definition at line 231 of file tif_compress.c.

References _TIFFDefaultGetMaxCompressionRatio(), _TIFFDefaultStripSize(), _TIFFDefaultTileSize(), _TIFFNoFixupTags(), _TIFFNoPreCode(), _TIFFNoRowDecode(), _TIFFNoRowEncode(), _TIFFNoSeek(), _TIFFNoStripDecode(), _TIFFNoStripEncode(), _TIFFNoTileDecode(), _TIFFNoTileEncode(), _TIFFtrue(), _TIFFvoid(), tiff::tif_cleanup, tiff::tif_close, tiff::tif_decoderow, tiff::tif_decodestatus, tiff::tif_decodestrip, tiff::tif_decodetile, tiff::tif_defstripsize, tiff::tif_deftilesize, tiff::tif_encoderow, tiff::tif_encodestatus, tiff::tif_encodestrip, tiff::tif_encodetile, tiff::tif_fixuptags, tiff::tif_flags, tiff::tif_getmaxcompressionratio, tiff::tif_postencode, tiff::tif_predecode, tiff::tif_preencode, tiff::tif_seek, tiff::tif_setupdecode, tiff::tif_setupencode, TIFF_NOBITREV, TIFF_NOREADRAW, TIFF_UPSAMPLED, and TRUE.

Referenced by JPEGCleanup(), LERCCleanup(), LogLuvCleanup(), LZMACleanup(), LZWCleanup(), OJPEGCleanup(), PixarLogCleanup(), TIFFClientOpenExt(), TIFFSetCompressionScheme(), TWebPCleanup(), ZIPCleanup(), and ZSTDCleanup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _TIFFtrue()

static int _TIFFtrue ( TIFF *  tif)
static

Accept a no-op codec setup or completion.

Ignores the handle; no state, allocation, I/O, diagnostics or ownership effects.

Parameters
[in]tifHandle (ignored).
Returns
One unconditionally.

Definition at line 185 of file tif_compress.c.

Referenced by _TIFFSetDefaultCompressionState().

Here is the caller graph for this function:

◆ _TIFFvoid()

static void _TIFFvoid ( TIFF *  tif)
static

Perform no codec close or cleanup work.

Ignores the handle; does not free codec state, flush, diagnose, allocate or transfer ownership.

Parameters
[in]tifHandle (ignored).

Definition at line 199 of file tif_compress.c.

Referenced by _TIFFSetDefaultCompressionState().

Here is the caller graph for this function:

◆ NotConfigured()

static int NotConfigured ( TIFF *  tif,
int  scheme 
)
static

Install unavailable-codec setup methods while accepting metadata access.

Sets fixup/setup callbacks to _notConfigured and clears encode/decode status. Does not allocate state, access payload, or diagnose until callbacks are used.

Parameters
[in,out]tifNon-NULL live handle whose fixup/setup callbacks and encode/decode status flags are replaced; serialise access externally.
[in]schemeUnused compression identifier.
Returns
One unconditionally.

Definition at line 153 of file tif_codec.c.

References _notConfigured(), FALSE, tiff::tif_decodestatus, tiff::tif_encodestatus, tiff::tif_fixuptags, tiff::tif_setupdecode, and tiff::tif_setupencode.

Referenced by TIFFIsCODECConfigured().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFNoDecode()

static int TIFFNoDecode ( TIFF *  tif,
const char *  method 
)
static

Diagnose an unsupported decoder operation.

Looks up the name and invokes handle diagnostics; no buffer access, allocation or pixel I/O.

Parameters
[in]tifNon-NULL live handle; td_compression and tif_name are read for the diagnostic and codec state is unchanged.
[in]methodBorrowed method label used only during diagnostics.
Returns
Zero unconditionally.

Definition at line 105 of file tif_compress.c.

References TIFFCodec::name, TIFFDirectory::td_compression, tiff::tif_dir, tiff::tif_name, TIFFErrorExtR(), and TIFFFindCODEC().

Referenced by _TIFFNoRowDecode(), _TIFFNoStripDecode(), and _TIFFNoTileDecode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFNoEncode()

static int TIFFNoEncode ( TIFF *  tif,
const char *  method 
)
static

Diagnose an unsupported encoder operation.

Looks up the name and invokes handle diagnostics; no buffer access, allocation or pixel I/O.

Parameters
[in]tifNon-NULL live handle; td_compression and tif_name are read for the diagnostic and codec state is unchanged.
[in]methodBorrowed method label used only during diagnostics.
Returns
Minus one unconditionally.

Definition at line 50 of file tif_compress.c.

References TIFFCodec::name, TIFFDirectory::td_compression, tiff::tif_dir, tiff::tif_name, TIFFErrorExtR(), and TIFFFindCODEC().

Referenced by _TIFFNoRowEncode(), _TIFFNoStripEncode(), and _TIFFNoTileEncode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFSetCompressionScheme()

int TIFFSetCompressionScheme ( TIFF *  tif,
int  scheme 
)
extern

Reset methods and install the selected compression implementation.

Looks up the uint16_t scheme, resets default callbacks/flags, sets ratio one for COMPRESSION_NONE, and invokes the selected init if present. Unknown schemes return success with fallback methods so metadata can still be inspected. Requires previous codec cleanup by the caller; this function does not release prior tif_data. Initialiser allocation/diagnostic/state effects can survive failure; no pixel I/O is performed directly. The process-global registry is unsynchronised; serialise queries and modifications externally. No registry operation manages active codec state or unloads callback code.

Parameters
[in,out]tifNon-NULL live handle whose codec state can be changed; caller serialises handle and registry access.
[in]schemeRequested compression identifier; lookup narrows to uint16_t.
Returns
Initialiser status for a known descriptor, otherwise one; not proof that pixel I/O is supported.

Definition at line 256 of file tif_compress.c.

References _TIFFGetMaxCompressionRatioOne(), _TIFFSetDefaultCompressionState(), COMPRESSION_NONE, TIFFCodec::init, tiff::tif_getmaxcompressionratio, and TIFFFindCODEC().

Referenced by _TIFFVSetField().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIFFSetDefaultCompressionState()

int TIFFSetDefaultCompressionState ( TIFF *  tif)
extern

Retain an obsolete declaration with no library implementation.

This spelling has no definition in this source tree and must not be called. The implemented private reset helper is _TIFFSetDefaultCompressionState(). No error, ownership, lifetime or side-effect contract exists for this unimplemented declaration.

Parameters
[in,out]tifHistorical handle argument; no valid invocation is available in this library.
Returns
No defined result: this declaration has no implementation.
Deprecated:
Use _TIFFSetDefaultCompressionState() for the implemented private reset operation.

Variable Documentation

◆ _TIFFBuiltinCODECS

const TIFFCodec _TIFFBuiltinCODECS[]
extern

Describe built-in compression names and initialisers.

Immutable library-lifetime name-NULL terminated array; disabled entries refer to a metadata-accepting stub. Borrowed storage must not be modified or freed.

Definition at line 91 of file tif_codec.c.

Referenced by TIFFFindCODEC(), and TIFFGetConfiguredCODECs().

◆ registeredCODECS

codec_t* registeredCODECS = NULL
static

Head the newest-first registered codec list.

Process-global unsynchronised state; nodes are owned until unregister.

Definition at line 304 of file tif_compress.c.

Referenced by TIFFFindCODEC(), TIFFGetConfiguredCODECs(), TIFFRegisterCODEC(), and TIFFUnRegisterCODEC().