|
LibTIFF 4.7.2
TIFF library public API and implementation reference
|
Implement filtered LZMA2 stream compression. More...
Data Structures | |
| struct | LZMAState |
| Own a filtered liblzma stream and predictor-prefixed methods. More... | |
Macros | |
| #define | LSTATE_INIT_DECODE 0x01 |
| Bit 0x01 of the codec state field: decoding has been set up. | |
| #define | LSTATE_INIT_ENCODE 0x02 |
| Bit 0x02 of the codec state field: encoding has been set up. | |
| #define | GetLZMAState(tif) ((LZMAState *)(tif)->tif_data) |
| Cast tif->tif_data to the LZMAState. | |
| #define | LZMADecoderState(tif) GetLZMAState(tif) |
| Alias of GetLZMAState(), returning the LZMAState for decoding. | |
| #define | LZMAEncoderState(tif) GetLZMAState(tif) |
| Alias of GetLZMAState(), returning the LZMAState for encoding. | |
Functions | |
| static const char * | LZMAStrerror (lzma_ret ret) |
| Describe a liblzma status using immutable text. | |
| static int | LZMAFixupTags (TIFF *tif) |
| Accept LZMA tag fixup without changes. | |
| static int | LZMASetupDecode (TIFF *tif) |
| Switch the liblzma stream to decode mode. | |
| static int | LZMAPreDecode (TIFF *tif, uint16_t s) |
| Initialise the liblzma decoder for one strile. | |
| static int | LZMADecode (TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s) |
| Expand cached liblzma input into caller output. | |
| static int | LZMASetupEncode (TIFF *tif) |
| Switch the liblzma stream to encode mode. | |
| static int | LZMAPreEncode (TIFF *tif, uint16_t s) |
| Initialise a filtered LZMA2 stream for one output strile. | |
| static int | LZMAEncode (TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) |
| Consume input through the active liblzma encoder. | |
| static int | LZMAPostEncode (TIFF *tif) |
| Finish the LZMA2 stream and flush produced output. | |
| static void | LZMACleanup (TIFF *tif) |
| End the dependency stream and release LZMA codec state. | |
| static int | LZMAVSetField (TIFF *tif, uint32_t tag, va_list ap) |
| Store LZMA preset or delegate a tag assignment. | |
| static int | LZMAVGetField (TIFF *tif, uint32_t tag, va_list ap) |
| Retrieve LZMA preset or delegate a tag query. | |
| static uint64_t | LZMAGetMaxCompressionRatio (TIFF *tif) |
| Report the empirical LZMA expansion heuristic. | |
| int | TIFFInitLZMA (TIFF *tif, int scheme) |
| Allocate predictor-aware LZMA2 codec state and install callbacks. | |
Variables | |
| static const TIFFField | lzmaFields [] |
| Define the LZMA compression-preset pseudo-tag. | |
Implement filtered LZMA2 stream compression.
| #define GetLZMAState | ( | tif | ) | ((LZMAState *)(tif)->tif_data) |
Cast tif->tif_data to the LZMAState.
tif is evaluated once. Requires the codec to be initialised (tif_data non-NULL).
| [in] | tif | Handle whose codec state is returned. |
Definition at line 94 of file tif_lzma.c.
| #define LSTATE_INIT_DECODE 0x01 |
Bit 0x01 of the codec state field: decoding has been set up.
Set by LZMASetupDecode(). Each setup first tears down the other mode, if active, and clears the field.
Definition at line 85 of file tif_lzma.c.
| #define LSTATE_INIT_ENCODE 0x02 |
Bit 0x02 of the codec state field: encoding has been set up.
Set by LZMASetupEncode(). Each setup first tears down the other mode, if active, and clears the field.
Definition at line 86 of file tif_lzma.c.
| #define LZMADecoderState | ( | tif | ) | GetLZMAState(tif) |
Alias of GetLZMAState(), returning the LZMAState for decoding.
tif is evaluated once. Requires the codec to be initialised.
| [in] | tif | Handle whose codec state is returned. |
Definition at line 95 of file tif_lzma.c.
| #define LZMAEncoderState | ( | tif | ) | GetLZMAState(tif) |
Alias of GetLZMAState(), returning the LZMAState for encoding.
tif is evaluated once. Requires the codec to be initialised.
| [in] | tif | Handle whose codec state is returned. |
Definition at line 96 of file tif_lzma.c.
|
static |
End the dependency stream and release LZMA codec state.
Restores predictor and saved tag hooks, ends active liblzma state, frees the outer Ext allocation, clears tif_data and installs default callbacks. Invalidates codec/dependency views. Does not finalise or flush pending payload, close the handle, or provide an error status.
| [in,out] | tif | Non-NULL live LZMA handle with predictor-prefixed state and valid raw buffers; serialise operations. |
Definition at line 607 of file tif_lzma.c.
References _TIFFfreeExt(), _TIFFSetDefaultCompressionState(), GetLZMAState, LZMAState::state, LZMAState::stream, tiff::tif_data, tiff::tif_tagmethods, TIFFPredictorCleanup(), TIFFTagMethods::vgetfield, LZMAState::vgetparent, TIFFTagMethods::vsetfield, and LZMAState::vsetparent.
Referenced by TIFFInitLZMA().
Expand cached liblzma input into caller output.
Requires successful predecode. A latched same-strile error clears requested output and fails. Configures input/output and runs until filled/end/error; memory-limit recovery can reinitialise the decoder at reported usage and restore saved input. Short output clears its remaining tail and latches failure. Other dependency errors can diagnose yet return success if output is already full. Only successful completion commits rawcp/rawcc; stream and output can change before failure. No caller ownership transfer or direct client I/O.
| [in,out] | tif | Non-NULL live LZMA handle with predictor-prefixed state and valid raw buffers; serialise operations. |
| [out] | op | Borrowed writable occ-byte decoded output, disjoint from raw/state storage. |
| [in] | occ | Nonnegative decoded byte count representable by size_t. |
| [in] | s | Unused sample-plane compatibility argument. |
Definition at line 279 of file tif_lzma.c.
References LSTATE_INIT_DECODE, LZMADecoderState, LZMAStrerror(), TIFFDirectory::td_row, tiff::tif_dir, tiff::tif_rawcc, tiff::tif_rawcp, TIFF_SIZE_FORMAT, and TIFFErrorExtR().
Referenced by TIFFInitLZMA().
Consume input through the active liblzma encoder.
Requires successful preencode and positive raw output capacity; a state not initialised for encoding is diagnosed and rejected. Checks size_t input conversion, calls lzma_code with RUN and flushes full raw buffers. Input remains unchanged. Dependency/flush failure can leave partial stream/file/cache progress and is not transactional; diagnostics follow the failing operation. No ownership transfer.
| [in,out] | tif | Non-NULL live LZMA handle with predictor-prefixed state and valid raw buffers; serialise operations. |
| [in] | bp | Borrowed readable cc-byte input, consumed synchronously without modification. |
| [in] | cc | Nonnegative input byte count representable by size_t. |
| [in] | s | Unused sample-plane compatibility argument. |
Definition at line 464 of file tif_lzma.c.
References LSTATE_INIT_ENCODE, LZMAEncoderState, LZMAStrerror(), TIFFDirectory::td_row, tiff::tif_dir, tiff::tif_rawcc, tiff::tif_rawdata, tiff::tif_rawdatasize, TIFFErrorExtR(), and TIFFFlushData1().
Referenced by TIFFInitLZMA().
|
static |
Accept LZMA tag fixup without changes.
No allocation, I/O, diagnostics, state or ownership effects.
| [in] | tif | Unused handle. |
Definition at line 165 of file tif_lzma.c.
Referenced by TIFFInitLZMA().
|
static |
Report the empirical LZMA expansion heuristic.
Ignores the handle; no allocation, I/O, diagnostics, state or ownership effects. This estimate is not a universal bound.
| [in] | tif | Unused handle. |
Definition at line 726 of file tif_lzma.c.
Referenced by TIFFInitLZMA().
|
static |
Finish the LZMA2 stream and flush produced output.
Runs FINISH until STREAM_END and flushes every nonempty raw extent. Requires valid preencode state; a state not initialised for encoding is diagnosed and rejected. Errors can leave an incomplete stream and changed file/cursor state. Does not persist the IFD or promise storage durability; no ownership transfer.
| [in,out] | tif | Non-NULL live LZMA handle with predictor-prefixed state and valid raw buffers; serialise operations. |
Definition at line 530 of file tif_lzma.c.
References LSTATE_INIT_ENCODE, LZMAEncoderState, LZMAStrerror(), tiff::tif_rawcc, tiff::tif_rawdata, tiff::tif_rawdatasize, TIFFErrorExtR(), and TIFFFlushData1().
Referenced by TIFFInitLZMA().
|
static |
Initialise the liblzma decoder for one strile.
Ensures decode mode, attaches raw input and checks size_t round-trip conversion, then calls lzma_stream_decoder with the memory limit disabled. Clears read_error only after successful setup. Dependency allocations remain codec-owned for cleanup; failures diagnose without rollback. No direct client I/O.
| [in,out] | tif | Non-NULL live LZMA handle with predictor-prefixed state and valid raw buffers; serialise operations. |
| [in] | s | Unused sample-plane compatibility argument. |
Definition at line 219 of file tif_lzma.c.
References LSTATE_INIT_DECODE, LZMADecoderState, LZMAStrerror(), tiff::tif_rawcc, tiff::tif_rawdata, tiff::tif_setupdecode, and TIFFErrorExtR().
Referenced by TIFFInitLZMA().
|
static |
Initialise a filtered LZMA2 stream for one output strile.
Ensures encode mode, attaches positive-capacity raw output, checks size_t conversion and initialises the configured filter chain/integrity-check mode. Dependency setup can allocate; errors diagnose with partial state retained for cleanup. No payload flush or ownership transfer.
| [in,out] | tif | Non-NULL live LZMA handle with predictor-prefixed state and valid raw buffers; serialise operations. |
| [in] | s | Unused sample-plane compatibility argument. |
Definition at line 412 of file tif_lzma.c.
References LSTATE_INIT_ENCODE, LZMAEncoderState, LZMAStrerror(), tiff::tif_rawdata, tiff::tif_rawdatasize, tiff::tif_setupencode, and TIFFErrorExtR().
Referenced by TIFFInitLZMA().
|
static |
Switch the liblzma stream to decode mode.
Ends a previous encode stream, clears mode and marks decode setup. Dependency allocations/views from the old mode can be invalidated. No payload I/O or caller storage ownership transfer.
| [in,out] | tif | Non-NULL live LZMA handle with predictor-prefixed state and valid raw buffers; serialise operations. |
Definition at line 183 of file tif_lzma.c.
References LSTATE_INIT_DECODE, LSTATE_INIT_ENCODE, LZMADecoderState, LZMAState::state, and LZMAState::stream.
Referenced by TIFFInitLZMA().
|
static |
Switch the liblzma stream to encode mode.
Ends previous decode state, clears mode and marks encode setup. Dependency allocations/views can be invalidated. Does not emit payload, allocate caller output or transfer ownership.
| [in,out] | tif | Non-NULL live LZMA handle with predictor-prefixed state and valid raw buffers; serialise operations. |
Definition at line 379 of file tif_lzma.c.
References LSTATE_INIT_DECODE, LSTATE_INIT_ENCODE, LZMAEncoderState, LZMAState::state, and LZMAState::stream.
Referenced by TIFFInitLZMA().
|
static |
Describe a liblzma status using immutable text.
Returns static library-lifetime string literals; unknown or newly added codes use a generic message. Do not modify or free the borrowed text. No allocation, I/O, diagnostics or state effects.
| [in] | ret | Dependency status code to describe. |
Definition at line 112 of file tif_lzma.c.
Referenced by LZMADecode(), LZMAEncode(), LZMAPostEncode(), LZMAPreDecode(), LZMAPreEncode(), and LZMAVSetField().
|
static |
Retrieve LZMA preset or delegate a tag query.
TIFFTAG_LZMAPRESET consumes a non-NULL int* and writes the cached preset; other tags follow the parent getter contract. No allocation or ownership transfer for the preset.
| [in,out] | tif | Non-NULL live LZMA handle with predictor-prefixed state and valid raw buffers; serialise operations. |
| [in] | tag | Codec pseudo-tag or delegated tag identifier. |
| [in,out] | ap | Live tag-specific va_list consumed synchronously; not retained. |
Definition at line 689 of file tif_lzma.c.
References GetLZMAState, LZMAState::preset, TIFFTAG_LZMAPRESET, and LZMAState::vgetparent.
Referenced by TIFFInitLZMA().
|
static |
Store LZMA preset or delegate a tag assignment.
TIFFTAG_LZMAPRESET consumes int, stores it, updates LZMA options without checking lzma_lzma_preset status and, in encode mode, reinitialises the stream immediately. Dependency reinitialisation errors diagnose but still return success. This can disturb an active frame; no rollback or ownership transfer. Other tags follow parent variadic contracts.
| [in,out] | tif | Non-NULL live LZMA handle with predictor-prefixed state and valid raw buffers; serialise operations. |
| [in] | tag | Codec pseudo-tag or delegated tag identifier. |
| [in,out] | ap | Live tag-specific va_list consumed synchronously; not retained. |
Definition at line 647 of file tif_lzma.c.
References GetLZMAState, LSTATE_INIT_ENCODE, LZMAStrerror(), TIFFErrorExtR(), and TIFFTAG_LZMAPRESET.
Referenced by TIFFInitLZMA().
|
extern |
Allocate predictor-aware LZMA2 codec state and install callbacks.
Requires cleaned-up previous state and COMPRESSION_LZMA. Merges preset metadata, allocates state and initialises dependency stream, saved tag hooks, default preset and no integrity check. Configures a byte-delta filter followed by LZMA2; delta distance is BitsPerSample/8 when BitsPerSample is a multiple of eight, otherwise one, using the bit depth current at initialisation. Installs methods and attempts PredictorInit without propagating its status. Failures diagnose; merged metadata or state changes are not rolled back. No pixel I/O.
| [in,out] | tif | Non-NULL handle whose previous codec state has been cleaned up; receives the new codec state. Serialise operations. |
| [in] | scheme | COMPRESSION_LZMA, asserted in debug builds. |
Definition at line 741 of file tif_lzma.c.
References _TIFFmallocExt(), _TIFFMergeFields(), COMPRESSION_LZMA, GetLZMAState, LZMACleanup(), LZMADecode(), LZMAEncode(), lzmaFields, LZMAFixupTags(), LZMAGetMaxCompressionRatio(), LZMAPostEncode(), LZMAPreDecode(), LZMAPreEncode(), LZMASetupDecode(), LZMASetupEncode(), LZMAVGetField(), LZMAVSetField(), TIFFDirectory::td_bitspersample, tiff::tif_cleanup, tiff::tif_data, tiff::tif_decoderow, tiff::tif_decodestrip, tiff::tif_decodetile, tiff::tif_dir, tiff::tif_encoderow, tiff::tif_encodestrip, tiff::tif_encodetile, tiff::tif_fixuptags, tiff::tif_getmaxcompressionratio, tiff::tif_postencode, tiff::tif_predecode, tiff::tif_preencode, tiff::tif_setupdecode, tiff::tif_setupencode, tiff::tif_tagmethods, TIFFArrayCount, TIFFErrorExtR(), TIFFPredictorInit(), TIFFTagMethods::vgetfield, and TIFFTagMethods::vsetfield.
|
static |
Define the LZMA compression-preset pseudo-tag.
Immutable library-lifetime metadata merged into a handle; no caller ownership transfer.
Definition at line 711 of file tif_lzma.c.
Referenced by TIFFInitLZMA().