|
LibTIFF 4.7.2
TIFF library public API and implementation reference
|
Chain codec methods and transform predicted rows. More...
Data Structures | |
| struct | TIFFPredictorState |
| Prefix codec state with Predictor method chains and row geometry. More... | |
Macros | |
| #define | PredictorState(tif) ((TIFFPredictorState *)(tif)->tif_data) |
| Borrow the predictor prefix of codec-owned tif_data. | |
| #define | REPEAT4(n, op) |
| Repeat a statement using an unrolled small-count switch. | |
| #define | OP |
| Accumulate the next byte in the floating-point fast path. | |
| #define | FIELD_PREDICTOR (FIELD_CODEC + 0) /* XXX */ |
| Reserve the codec field bit for Predictor. | |
Typedefs | |
| typedef int(* | TIFFEncodeDecodeMethod) (TIFF *tif, uint8_t *buf, tmsize_t size) |
| Transform one decoded row in place for a Predictor wrapper. | |
Functions | |
| static int | PredictorSetup (TIFF *tif) |
| Validate predictor format and cache stride and row extent. | |
| static int | PredictorSetupDecode (TIFF *tif) |
| Chain parent decoder setup and install predictor decoding. | |
| static int | PredictorSetupEncode (TIFF *tif) |
| Chain parent encoder setup and install predictor encoding. | |
| static TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW void | PredictorAccumulate16NativeUnaligned (uint8_t *current, const uint8_t *previous) |
| Add two unaligned native-order 16-bit samples modulo their width. | |
| static TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW void | PredictorAccumulate32NativeUnaligned (uint8_t *current, const uint8_t *previous) |
| Add two unaligned native-order 32-bit samples modulo their width. | |
| static TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW void | PredictorAccumulate64NativeUnaligned (uint8_t *current, const uint8_t *previous) |
| Add two unaligned native-order 64-bit samples modulo their width. | |
| static void | PredictorSwabByteStream16 (uint8_t *cp, tmsize_t n) |
| Reverse each 16-bit sample in an unaligned byte stream. | |
| static void | PredictorSwabByteStream32 (uint8_t *cp, tmsize_t n) |
| Reverse each 32-bit sample in an unaligned byte stream. | |
| static void | PredictorSwabByteStream64 (uint8_t *cp, tmsize_t n) |
| Reverse each 64-bit sample in an unaligned byte stream. | |
| static int | horAcc8 (TIFF *tif, uint8_t *cp0, tmsize_t cc) |
| Accumulate 8-bit horizontal predictor samples in place. | |
| static int | swabHorAcc16 (TIFF *tif, uint8_t *cp0, tmsize_t cc) |
| Swap and accumulate 16-bit horizontal predictor samples in place. | |
| static int | horAcc16 (TIFF *tif, uint8_t *cp0, tmsize_t cc) |
| Accumulate 16-bit horizontal predictor samples in place. | |
| static int | swabHorAcc32 (TIFF *tif, uint8_t *cp0, tmsize_t cc) |
| Swap and accumulate 32-bit horizontal predictor samples in place. | |
| static int | horAcc32 (TIFF *tif, uint8_t *cp0, tmsize_t cc) |
| Accumulate 32-bit horizontal predictor samples in place. | |
| static int | swabHorAcc64 (TIFF *tif, uint8_t *cp0, tmsize_t cc) |
| Swap and accumulate 64-bit horizontal predictor samples in place. | |
| static int | horAcc64 (TIFF *tif, uint8_t *cp0, tmsize_t cc) |
| Accumulate 64-bit horizontal predictor samples in place. | |
| static int | fpAcc (TIFF *tif, uint8_t *cp0, tmsize_t cc) |
| Undo floating-point byte-plane prediction on one row. | |
| static int | PredictorDecodeRow (TIFF *tif, uint8_t *op0, tmsize_t occ0, uint16_t s) |
| Decode one row then undo prediction in place. | |
| static int | PredictorDecodeTile (TIFF *tif, uint8_t *op0, tmsize_t occ0, uint16_t s) |
| Decode a strile then undo prediction row by row. | |
| static int | horDiff8 (TIFF *tif, uint8_t *cp0, tmsize_t cc) |
| Difference 8-bit horizontal predictor samples in place. | |
| static int | horDiff16 (TIFF *tif, uint8_t *cp0, tmsize_t cc) |
| Difference 16-bit horizontal predictor samples in place. | |
| static int | swabHorDiff16 (TIFF *tif, uint8_t *cp0, tmsize_t cc) |
| Swap and difference 16-bit horizontal predictor samples in place. | |
| static int | horDiff32 (TIFF *tif, uint8_t *cp0, tmsize_t cc) |
| Difference 32-bit horizontal predictor samples in place. | |
| static int | swabHorDiff32 (TIFF *tif, uint8_t *cp0, tmsize_t cc) |
| Swap and difference 32-bit horizontal predictor samples in place. | |
| static int | horDiff64 (TIFF *tif, uint8_t *cp0, tmsize_t cc) |
| Difference 64-bit horizontal predictor samples in place. | |
| static int | swabHorDiff64 (TIFF *tif, uint8_t *cp0, tmsize_t cc) |
| Swap and difference 64-bit horizontal predictor samples in place. | |
| static int | fpDiff (TIFF *tif, uint8_t *cp0, tmsize_t cc) |
| Apply floating-point byte-plane prediction on one row. | |
| static int | PredictorEncodeRow (TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) |
| Transform a temporary row copy then call the parent encoder. | |
| static int | PredictorEncodeTile (TIFF *tif, uint8_t *bp0, tmsize_t cc0, uint16_t s) |
| Transform a temporary strile copy then call the parent encoder. | |
| static int | PredictorVSetField (TIFF *tif, uint32_t tag, va_list ap) |
| Store Predictor or delegate another variadic tag assignment. | |
| static int | PredictorVGetField (TIFF *tif, uint32_t tag, va_list ap) |
| Fetch Predictor or delegate another variadic tag query. | |
| static void | PredictorPrintDir (TIFF *tif, FILE *fd, long flags) |
| Print predictor information then chain the parent printer. | |
| int | TIFFPredictorInit (TIFF *tif) |
| Install Predictor tag and setup hooks around a codec. | |
| int | TIFFPredictorCleanup (TIFF *tif) |
| Restore saved Predictor tag print and setup hooks. | |
Variables | |
| static const TIFFField | predictFields [] |
| Define the codec-owned Predictor field metadata. | |
Chain codec methods and transform predicted rows.
| #define FIELD_PREDICTOR (FIELD_CODEC + 0) /* XXX */ |
Reserve the codec field bit for Predictor.
Value FIELD_CODEC + 0, the first codec-private field bit. Used in predictFields, set by PredictorVSetField when Predictor is assigned, and tested by PredictorPrintDir.
Definition at line 1620 of file tif_predict.c.
| #define OP |
Accumulate the next byte in the floating-point fast path.
Local to the stride-1 path of fpAcc: adds the byte at cp[0] to cp[1] modulo 256 and advances the enclosing cp by one. Undefined again after that loop.
| #define PredictorState | ( | tif | ) | ((TIFFPredictorState *)(tif)->tif_data) |
Borrow the predictor prefix of codec-owned tif_data.
Expands to a cast of tif->tif_data to TIFFPredictorState *, evaluating tif once. Valid only for codecs whose state struct begins with a TIFFPredictorState member and that have called TIFFPredictorInit; nothing is checked.
| [in] | tif | TIFF handle whose codec state is borrowed. |
Definition at line 42 of file tif_predict.c.
| #define REPEAT4 | ( | n, | |
| op | |||
| ) |
Repeat a statement using an unrolled small-count switch.
Expands to a switch on n whose cases fall through, so op runs n times for n from 0 to 4 and, through a loop in the default case, n times for larger n. A negative n reaches the default case and runs op four times. n is evaluated twice. The default case declares a block-local tmsize_t i, so op must not refer to an outer i.
| [in] | n | Repeat count, normally the stride; evaluated twice. |
| [in] | op | Statement to repeat. |
Definition at line 389 of file tif_predict.c.
Transform one decoded row in place for a Predictor wrapper.
Called synchronously with a selected integer or floating-point transform. Borrows storage and handle; no returned ownership. Integer transforms generally diagnose divisibility errors without allocation; floating transforms allocate temporary storage. Buffer can change before failure; callers must honour the transform-specific alignment/extent requirements.
| [in,out] | tif | Non-NULL live handle whose tif_data begins with a valid TIFFPredictorState; serialise codec operations. |
| [in,out] | buf | Borrowed writable complete row in the transform-specific byte/sample order. |
| [in] | size | Positive complete row byte count satisfying stride/sample-size divisibility. |
Definition at line 59 of file tif_predict.h.
Undo floating-point byte-plane prediction on one row.
Requires setup-selected nonzero bytes per sample and stride, a positive complete row extent divisible by their product, and sufficient writable storage. Accumulates byte planes then interlaces them into native sample order. Allocates a row-sized temporary buffer, released on success; rejected divisibility or allocation returns zero. Does not perform floating-point arithmetic on sample values. Buffer mutations survive later failure; no pixel I/O or ownership transfer.
| [in,out] | tif | Non-NULL live handle whose tif_data begins with a valid TIFFPredictorState; serialise codec operations. |
| [in,out] | cp0 | Borrowed writable row storage of cc bytes; cc must be positive, since a zero extent fails the temporary allocation. |
| [in] | cc | Row byte extent under the selected transform preconditions. |
Definition at line 903 of file tif_predict.c.
References _TIFFfreeExt(), _TIFFmallocExt(), _TIFFmemcpy(), OP, PredictorState, REPEAT4, TIFFDirectory::td_bitspersample, tiff::tif_dir, and TIFFErrorExtR().
Referenced by PredictorSetupDecode().
|
static |
Apply floating-point byte-plane prediction on one row.
Requires setup-selected nonzero bytes per sample and stride, a positive complete row extent divisible by their product, and sufficient writable storage. Reorders native sample bytes into byte planes then differences those planes. Allocates a row-sized temporary buffer, released on success; rejected divisibility or allocation returns zero. Does not perform floating-point arithmetic on sample values. Buffer mutations survive later failure; no pixel I/O or ownership transfer.
| [in,out] | tif | Non-NULL live handle whose tif_data begins with a valid TIFFPredictorState; serialise codec operations. |
| [in,out] | cp0 | Borrowed writable row storage of cc bytes; cc must be positive, since a zero extent fails the temporary allocation. |
| [in] | cc | Row byte extent under the selected transform preconditions. |
Definition at line 1449 of file tif_predict.c.
References _TIFFfreeExt(), _TIFFmallocExt(), _TIFFmemcpy(), PredictorState, REPEAT4, TIFFDirectory::td_bitspersample, tiff::tif_dir, and TIFFErrorExtR().
Referenced by PredictorSetupEncode().
|
static |
Accumulate 16-bit horizontal predictor samples in place.
Requires positive nonzero cached stride and nonnegative complete row bytes divisible by 2*stride, with representable products and live writable storage. Uses unsigned modular arithmetic; first-pixel channel samples remain unchanged. Accumulation uses byte-stream/memcpy helpers and accepts unaligned storage. No allocation, pixel I/O, or ownership transfer; invalid extent is diagnosed through handle callbacks.
| [in] | tif | Non-NULL handle whose TIFFPredictorState supplies the cached stride; used otherwise only for diagnostics. |
| [in,out] | cp0 | Borrowed writable row storage of cc bytes. |
| [in] | cc | Row byte extent under the selected transform preconditions. |
Definition at line 715 of file tif_predict.c.
References PredictorAccumulate16NativeUnaligned(), PredictorState, REPEAT4, and TIFFErrorExtR().
Referenced by PredictorSetupDecode(), and swabHorAcc16().
|
static |
Accumulate 32-bit horizontal predictor samples in place.
Requires positive nonzero cached stride and nonnegative complete row bytes divisible by 4*stride, with representable products and live writable storage. Uses unsigned modular arithmetic; first-pixel channel samples remain unchanged. Accumulation uses byte-stream/memcpy helpers and accepts unaligned storage. No allocation, pixel I/O, or ownership transfer; invalid extent is diagnosed through handle callbacks.
| [in] | tif | Non-NULL handle whose TIFFPredictorState supplies the cached stride; used otherwise only for diagnostics. |
| [in,out] | cp0 | Borrowed writable row storage of cc bytes. |
| [in] | cc | Row byte extent under the selected transform preconditions. |
Definition at line 785 of file tif_predict.c.
References PredictorAccumulate32NativeUnaligned(), PredictorState, REPEAT4, and TIFFErrorExtR().
Referenced by PredictorSetupDecode(), and swabHorAcc32().
|
static |
Accumulate 64-bit horizontal predictor samples in place.
Requires positive nonzero cached stride and nonnegative complete row bytes divisible by 8*stride, with representable products and live writable storage. Uses unsigned modular arithmetic; first-pixel channel samples remain unchanged. Accumulation uses byte-stream/memcpy helpers and accepts unaligned storage. No allocation, pixel I/O, or ownership transfer; invalid extent is diagnosed through handle callbacks.
| [in] | tif | Non-NULL handle whose TIFFPredictorState supplies the cached stride; used otherwise only for diagnostics. |
| [in,out] | cp0 | Borrowed writable row storage of cc bytes. |
| [in] | cc | Row byte extent under the selected transform preconditions. |
Definition at line 855 of file tif_predict.c.
References PredictorAccumulate64NativeUnaligned(), PredictorState, REPEAT4, and TIFFErrorExtR().
Referenced by PredictorSetupDecode(), and swabHorAcc64().
|
static |
Accumulate 8-bit horizontal predictor samples in place.
Requires positive nonzero cached stride and nonnegative complete row bytes divisible by 1*stride, with representable products and live writable storage. Uses unsigned modular arithmetic; first-pixel channel samples remain unchanged. No allocation, pixel I/O, or ownership transfer; invalid extent is diagnosed through handle callbacks.
| [in] | tif | Non-NULL handle whose TIFFPredictorState supplies the cached stride; used otherwise only for diagnostics. |
| [in,out] | cp0 | Borrowed writable row storage of cc bytes. |
| [in] | cc | Row byte extent under the selected transform preconditions. |
Definition at line 596 of file tif_predict.c.
References PredictorState, REPEAT4, and TIFFErrorExtR().
Referenced by PredictorSetupDecode().
|
static |
Difference 16-bit horizontal predictor samples in place.
Requires positive nonzero cached stride and nonnegative complete row bytes divisible by 2*stride, with representable products and live writable storage. Uses unsigned modular arithmetic; first-pixel channel samples remain unchanged. Requires uint16_t alignment for typed differencing. No allocation, pixel I/O, or ownership transfer; invalid extent is diagnosed through handle callbacks.
| [in] | tif | Non-NULL handle whose TIFFPredictorState supplies the cached stride; used otherwise only for diagnostics. |
| [in,out] | cp0 | Borrowed writable row storage of cc bytes. |
| [in] | cc | Row byte extent under the selected transform preconditions. |
Definition at line 1222 of file tif_predict.c.
References PredictorState, REPEAT4, TIFFPredictorState::stride, and TIFFErrorExtR().
Referenced by PredictorSetupEncode(), and swabHorDiff16().
|
static |
Difference 32-bit horizontal predictor samples in place.
Requires positive nonzero cached stride and nonnegative complete row bytes divisible by 4*stride, with representable products and live writable storage. Uses unsigned modular arithmetic; first-pixel channel samples remain unchanged. Requires uint32_t alignment for typed differencing. No allocation, pixel I/O, or ownership transfer; invalid extent is diagnosed through handle callbacks.
| [in] | tif | Non-NULL handle whose TIFFPredictorState supplies the cached stride; used otherwise only for diagnostics. |
| [in,out] | cp0 | Borrowed writable row storage of cc bytes. |
| [in] | cc | Row byte extent under the selected transform preconditions. |
Definition at line 1298 of file tif_predict.c.
References PredictorState, REPEAT4, TIFFPredictorState::stride, and TIFFErrorExtR().
Referenced by PredictorSetupEncode(), and swabHorDiff32().
|
static |
Difference 64-bit horizontal predictor samples in place.
Requires positive nonzero cached stride and nonnegative complete row bytes divisible by 8*stride, with representable products and live writable storage. Uses unsigned modular arithmetic; first-pixel channel samples remain unchanged. Requires uint64_t alignment for typed differencing. No allocation, pixel I/O, or ownership transfer; invalid extent is diagnosed through handle callbacks.
| [in] | tif | Non-NULL handle whose TIFFPredictorState supplies the cached stride; used otherwise only for diagnostics. |
| [in,out] | cp0 | Borrowed writable row storage of cc bytes. |
| [in] | cc | Row byte extent under the selected transform preconditions. |
Definition at line 1371 of file tif_predict.c.
References PredictorState, REPEAT4, TIFFPredictorState::stride, and TIFFErrorExtR().
Referenced by PredictorSetupEncode(), and swabHorDiff64().
|
static |
Difference 8-bit horizontal predictor samples in place.
Requires positive nonzero cached stride and nonnegative complete row bytes divisible by 1*stride, with representable products and live writable storage. Uses unsigned modular arithmetic; first-pixel channel samples remain unchanged. No allocation, pixel I/O, or ownership transfer; invalid extent is diagnosed through handle callbacks.
| [in] | tif | Non-NULL handle whose TIFFPredictorState supplies the cached stride; used otherwise only for diagnostics. |
| [in,out] | cp0 | Borrowed writable row storage of cc bytes. |
| [in] | cc | Row byte extent under the selected transform preconditions. |
Definition at line 1127 of file tif_predict.c.
References PredictorState, REPEAT4, TIFFPredictorState::stride, and TIFFErrorExtR().
Referenced by PredictorSetupEncode().
|
static |
Add two unaligned native-order 16-bit samples modulo their width.
Uses fixed-size memcpy to load/store without typed alignment requirements. Reads previous before overwriting current, permitting identical slots. No bounds checks, allocation, I/O, diagnostics, handle changes or ownership effects.
| [in,out] | current | Writable byte storage for one native-order sample, unaligned allowed. |
| [in] | previous | Readable byte storage for one same-width native-order sample, unaligned allowed. |
Definition at line 440 of file tif_predict.c.
Referenced by horAcc16().
|
static |
Add two unaligned native-order 32-bit samples modulo their width.
Uses fixed-size memcpy to load/store without typed alignment requirements. Reads previous before overwriting current, permitting identical slots. No bounds checks, allocation, I/O, diagnostics, handle changes or ownership effects.
| [in,out] | current | Writable byte storage for one native-order sample, unaligned allowed. |
| [in] | previous | Readable byte storage for one same-width native-order sample, unaligned allowed. |
Definition at line 467 of file tif_predict.c.
Referenced by horAcc32().
|
static |
Add two unaligned native-order 64-bit samples modulo their width.
Uses fixed-size memcpy to load/store without typed alignment requirements. Reads previous before overwriting current, permitting identical slots. No bounds checks, allocation, I/O, diagnostics, handle changes or ownership effects.
| [in,out] | current | Writable byte storage for one native-order sample, unaligned allowed. |
| [in] | previous | Readable byte storage for one same-width native-order sample, unaligned allowed. |
Definition at line 493 of file tif_predict.c.
Referenced by horAcc64().
Decode one row then undo prediction in place.
Requires installed parent decoder and transform. Parent callback consumes raw input and can allocate/diagnose; transform runs only on nonzero parent status. Caller retains output, which can be partial or changed on failure. No rollback or ownership transfer.
| [in,out] | tif | Non-NULL live handle whose tif_data begins with a valid TIFFPredictorState; serialise codec operations. |
| [out] | op0 | Caller-owned writable decoded output of occ0 bytes. |
| [in] | occ0 | Nonnegative decoded byte extent, complete rows for strile wrappers. |
| [in] | s | Sample plane passed unchanged to the parent codec. |
Definition at line 1036 of file tif_predict.c.
References TIFFPredictorState::decodepfunc, TIFFPredictorState::decoderow, and PredictorState.
Referenced by PredictorSetupDecode().
Decode a strile then undo prediction row by row.
Calls saved decodetile for both strip and tile wrapping, then requires an extent divisible by positive rowsize. Invokes decodepfunc per row and stops on failure. Parent input progress and earlier output rows remain changed. No rollback or output ownership transfer; callbacks may allocate, diagnose and read client data.
| [in,out] | tif | Non-NULL live handle whose tif_data begins with a valid TIFFPredictorState; serialise codec operations. |
| [out] | op0 | Caller-owned writable decoded output of occ0 bytes. |
| [in] | occ0 | Nonnegative decoded byte extent, complete rows for strile wrappers. |
| [in] | s | Sample plane passed unchanged to the parent codec. |
Definition at line 1078 of file tif_predict.c.
References TIFFPredictorState::decodepfunc, TIFFPredictorState::decodetile, PredictorState, TIFFPredictorState::rowsize, and TIFFErrorExtR().
Referenced by PredictorSetupDecode().
Transform a temporary row copy then call the parent encoder.
Allocates a working copy, preserves caller bytes from this predictor layer, checks transform status, invokes the parent encoder and frees temporary storage on each exit. Parent state/output effects remain on failure; public write postdecode conversion can separately mutate the original input. Reports allocation failure; no ownership transfer.
| [in,out] | tif | Non-NULL live handle whose tif_data begins with a valid TIFFPredictorState; serialise codec operations. |
| [in] | bp | Borrowed readable row input of cc bytes, copied before prediction. |
| [in] | cc | Row byte extent under the selected transform preconditions. |
| [in] | s | Sample plane passed unchanged to the parent codec. |
Definition at line 1510 of file tif_predict.c.
References _TIFFfreeExt(), _TIFFmallocExt(), PredictorState, and TIFFErrorExtR().
Referenced by PredictorSetupEncode().
Transform a temporary strile copy then call the parent encoder.
Allocates/copies input and validates divisibility by positive rowsize. Transforms each row, failing without calling the parent if any encodepfunc transform fails, then calls saved encodetile for both strip and tile wrappers. Frees temporary storage on every ordinary exit. Caller bytes are preserved by this layer; parent state/output can change on failure. No ownership transfer.
| [in,out] | tif | Non-NULL live handle whose tif_data begins with a valid TIFFPredictorState; serialise codec operations. |
| [in] | bp0 | Borrowed readable strile input of cc0 bytes, copied before prediction. |
| [in] | cc0 | Positive complete-row input byte extent. |
| [in] | s | Sample plane passed unchanged to the parent codec. |
Definition at line 1566 of file tif_predict.c.
References _TIFFfreeExt(), _TIFFmallocExt(), PredictorState, and TIFFErrorExtR().
Referenced by PredictorSetupEncode().
|
static |
Print predictor information then chain the parent printer.
Writes to borrowed FILE without checking stdio errors, prints only when its field bit is set, then invokes saved printer with flags. Does not close the stream or transfer ownership; parent printer effects apply. No separate status channel.
| [in] | tif | Non-NULL handle whose TIFFPredictorState holds the predictor value and saved parent printer; not modified. |
| [in,out] | fd | Borrowed writable stdio stream; remains caller-owned. |
| [in] | flags | Print flags forwarded to the saved printer. |
Definition at line 1721 of file tif_predict.c.
References FIELD_PREDICTOR, TIFFPredictorState::predictor, PredictorState, TIFFPredictorState::printdir, and TIFFFieldSet.
Referenced by TIFFPredictorInit().
|
static |
Validate predictor format and cache stride and row extent.
Accepts no predictor, integer horizontal 8/16/32/64-bit samples, or floating-point 16/24/32/64-bit samples. Derives contiguous sample stride or separate stride one and a positive decoded row size. Diagnoses unsupported settings; no pixel I/O or owned result allocation. Cached state may change before failure.
| [in,out] | tif | Non-NULL live handle whose tif_data begins with a valid TIFFPredictorState; serialise codec operations. |
Definition at line 83 of file tif_predict.c.
References _TIFFCastUInt64ToSSize(), _TIFFMultiply64(), isTiled, PLANARCONFIG_CONTIG, PREDICTOR_FLOATINGPOINT, PREDICTOR_HORIZONTAL, PREDICTOR_NONE, PredictorState, SAMPLEFORMAT_IEEEFP, TIFFDirectory::td_bitspersample, TIFFDirectory::td_planarconfig, TIFFDirectory::td_sampleformat, TIFFDirectory::td_samplesperpixel, TIFFDirectory::td_tilewidth, tiff::tif_dir, TIFFErrorExtR(), TIFFhowmany8_64, and TIFFScanlineSize().
Referenced by PredictorSetupDecode(), and PredictorSetupEncode().
|
static |
Chain parent decoder setup and install predictor decoding.
Invokes parent setup first without undoing its effects on later failure. Selects accumulation, wraps row/strile callbacks, and disables ordinary postdecode swapping where the predictor handles byte order. Requires fresh/non-recursive parent chains; may allocate through parent setup and diagnostics, but does not read pixels directly.
| [in,out] | tif | Non-NULL live handle whose tif_data begins with a valid TIFFPredictorState; serialise codec operations. |
Definition at line 177 of file tif_predict.c.
References _TIFFNoPostDecode(), TIFFPredictorState::decodepfunc, TIFFPredictorState::decoderow, TIFFPredictorState::decodestrip, TIFFPredictorState::decodetile, fpAcc(), horAcc16(), horAcc32(), horAcc64(), horAcc8(), TIFFPredictorState::predictor, PredictorDecodeRow(), PredictorDecodeTile(), PredictorSetup(), PredictorState, TIFFPredictorState::setupdecode, swabHorAcc16(), swabHorAcc32(), swabHorAcc64(), TIFFDirectory::td_bitspersample, tiff::tif_decoderow, tiff::tif_decodestrip, tiff::tif_decodetile, tiff::tif_dir, tiff::tif_flags, tiff::tif_postdecode, and TIFF_SWAB.
Referenced by TIFFPredictorInit().
|
static |
Chain parent encoder setup and install predictor encoding.
Invokes parent setup then validates predictor geometry and selects differencing/wrappers. Can disable ordinary postdecode swapping. Parent and wrapper changes survive failure; parent allocation/diagnostic effects apply. Does not write pixels directly.
| [in,out] | tif | Non-NULL live handle whose tif_data begins with a valid TIFFPredictorState; serialise codec operations. |
Definition at line 291 of file tif_predict.c.
References _TIFFNoPostDecode(), TIFFPredictorState::encodepfunc, TIFFPredictorState::encoderow, TIFFPredictorState::encodestrip, TIFFPredictorState::encodetile, fpDiff(), horDiff16(), horDiff32(), horDiff64(), horDiff8(), TIFFPredictorState::predictor, PredictorEncodeRow(), PredictorEncodeTile(), PredictorSetup(), PredictorState, TIFFPredictorState::setupencode, swabHorDiff16(), swabHorDiff32(), swabHorDiff64(), TIFFDirectory::td_bitspersample, tiff::tif_dir, tiff::tif_encoderow, tiff::tif_encodestrip, tiff::tif_encodetile, tiff::tif_flags, tiff::tif_postdecode, and TIFF_SWAB.
Referenced by TIFFPredictorInit().
|
static |
Reverse each 16-bit sample in an unaligned byte stream.
Swaps bytes directly; zero count performs no accesses. No bounds checks, allocation, I/O, diagnostics, or ownership effects.
| [in,out] | cp | Writable byte stream covering n complete samples. |
| [in] | n | Nonnegative sample count. |
Definition at line 514 of file tif_predict.c.
Referenced by swabHorAcc16().
|
static |
Reverse each 32-bit sample in an unaligned byte stream.
Swaps bytes directly; zero count performs no accesses. No bounds checks, allocation, I/O, diagnostics, or ownership effects.
| [in,out] | cp | Writable byte stream covering n complete samples. |
| [in] | n | Nonnegative sample count. |
Definition at line 535 of file tif_predict.c.
Referenced by swabHorAcc32().
|
static |
Reverse each 64-bit sample in an unaligned byte stream.
Swaps bytes directly; zero count performs no accesses. No bounds checks, allocation, I/O, diagnostics, or ownership effects.
| [in,out] | cp | Writable byte stream covering n complete samples. |
| [in] | n | Nonnegative sample count. |
Definition at line 559 of file tif_predict.c.
Referenced by swabHorAcc64().
|
static |
Fetch Predictor or delegate another variadic tag query.
For TIFFTAG_PREDICTOR consumes a non-NULL uint16_t* and writes the cached value. Other tags follow the saved parent getter contract. No output allocation or ownership transfer for Predictor; parent effects depend on tag.
| [in,out] | tif | Non-NULL live handle whose tif_data begins with a valid TIFFPredictorState; serialise codec operations. |
| [in] | tag | Tag identifier; delegated tags follow their usual argument contract. |
| [in,out] | ap | Live va_list cursor carrying the tag-specific promoted value/output pointer; consumed synchronously, not retained. |
Definition at line 1689 of file tif_predict.c.
References TIFFPredictorState::predictor, PredictorState, TIFFTAG_PREDICTOR, and TIFFPredictorState::vgetparent.
Referenced by TIFFPredictorInit().
|
static |
Store Predictor or delegate another variadic tag assignment.
For TIFFTAG_PREDICTOR consumes uint16_vap (normally promoted int), narrows to uint16_t, sets the field bit and directory dirty flag. Does not validate predictor support until setup. Other tags consume their usual variadic contract through saved vsetparent. Callbacks can mutate/allocate/diagnose; no ownership transfer for Predictor.
| [in,out] | tif | Non-NULL live handle whose tif_data begins with a valid TIFFPredictorState; serialise codec operations. |
| [in] | tag | Tag identifier; delegated tags follow their usual argument contract. |
| [in,out] | ap | Live va_list cursor carrying the tag-specific promoted value/output pointer; consumed synchronously, not retained. |
Definition at line 1652 of file tif_predict.c.
References FIELD_PREDICTOR, TIFFPredictorState::predictor, PredictorState, tiff::tif_flags, TIFF_DIRTYDIRECT, TIFFSetFieldBit, TIFFTAG_PREDICTOR, and TIFFPredictorState::vsetparent.
Referenced by TIFFPredictorInit().
Swap and accumulate 16-bit horizontal predictor samples in place.
Requires positive nonzero cached stride and nonnegative complete row bytes divisible by 2*stride, with representable products and live writable storage. Swaps complete samples before accumulation, even before the inner divisibility rejection; input can change on rejection. Accumulation uses byte-stream/memcpy helpers and accepts unaligned storage. No allocation, pixel I/O, or ownership transfer; invalid extent is diagnosed through handle callbacks.
| [in] | tif | Non-NULL handle whose TIFFPredictorState supplies the cached stride; used otherwise only for diagnostics. |
| [in,out] | cp0 | Borrowed writable row storage of cc bytes. |
| [in] | cc | Row byte extent under the selected transform preconditions. |
Definition at line 689 of file tif_predict.c.
References horAcc16(), and PredictorSwabByteStream16().
Referenced by PredictorSetupDecode().
Swap and accumulate 32-bit horizontal predictor samples in place.
Requires positive nonzero cached stride and nonnegative complete row bytes divisible by 4*stride, with representable products and live writable storage. Swaps complete samples before accumulation, even before the inner divisibility rejection; input can change on rejection. Accumulation uses byte-stream/memcpy helpers and accepts unaligned storage. No allocation, pixel I/O, or ownership transfer; invalid extent is diagnosed through handle callbacks.
| [in] | tif | Non-NULL handle whose TIFFPredictorState supplies the cached stride; used otherwise only for diagnostics. |
| [in,out] | cp0 | Borrowed writable row storage of cc bytes. |
| [in] | cc | Row byte extent under the selected transform preconditions. |
Definition at line 759 of file tif_predict.c.
References horAcc32(), and PredictorSwabByteStream32().
Referenced by PredictorSetupDecode().
Swap and accumulate 64-bit horizontal predictor samples in place.
Requires positive nonzero cached stride and nonnegative complete row bytes divisible by 8*stride, with representable products and live writable storage. Swaps complete samples before accumulation, even before the inner divisibility rejection; input can change on rejection. Accumulation uses byte-stream/memcpy helpers and accepts unaligned storage. No allocation, pixel I/O, or ownership transfer; invalid extent is diagnosed through handle callbacks.
| [in] | tif | Non-NULL handle whose TIFFPredictorState supplies the cached stride; used otherwise only for diagnostics. |
| [in,out] | cp0 | Borrowed writable row storage of cc bytes. |
| [in] | cc | Row byte extent under the selected transform preconditions. |
Definition at line 829 of file tif_predict.c.
References horAcc64(), and PredictorSwabByteStream64().
Referenced by PredictorSetupDecode().
Swap and difference 16-bit horizontal predictor samples in place.
Requires positive nonzero cached stride and nonnegative complete row bytes divisible by 2*stride, with representable products and live writable storage. Differences native-order samples first, then swaps after success. Requires uint16_t alignment for typed differencing. No allocation, pixel I/O, or ownership transfer; invalid extent is diagnosed through handle callbacks.
| [in] | tif | Non-NULL handle whose TIFFPredictorState supplies the cached stride; used otherwise only for diagnostics. |
| [in,out] | cp0 | Borrowed writable row storage of cc bytes. |
| [in] | cc | Row byte extent under the selected transform preconditions. |
Definition at line 1268 of file tif_predict.c.
References horDiff16(), and TIFFSwabArrayOfShort().
Referenced by PredictorSetupEncode().
Swap and difference 32-bit horizontal predictor samples in place.
Requires positive nonzero cached stride and nonnegative complete row bytes divisible by 4*stride, with representable products and live writable storage. Differences native-order samples first, then swaps after success. Requires uint32_t alignment for typed differencing. No allocation, pixel I/O, or ownership transfer; invalid extent is diagnosed through handle callbacks.
| [in] | tif | Non-NULL handle whose TIFFPredictorState supplies the cached stride; used otherwise only for diagnostics. |
| [in,out] | cp0 | Borrowed writable row storage of cc bytes. |
| [in] | cc | Row byte extent under the selected transform preconditions. |
Definition at line 1341 of file tif_predict.c.
References horDiff32(), and TIFFSwabArrayOfLong().
Referenced by PredictorSetupEncode().
Swap and difference 64-bit horizontal predictor samples in place.
Requires positive nonzero cached stride and nonnegative complete row bytes divisible by 8*stride, with representable products and live writable storage. Differences native-order samples first, then swaps after success. Requires uint64_t alignment for typed differencing. No allocation, pixel I/O, or ownership transfer; invalid extent is diagnosed through handle callbacks.
| [in] | tif | Non-NULL handle whose TIFFPredictorState supplies the cached stride; used otherwise only for diagnostics. |
| [in,out] | cp0 | Borrowed writable row storage of cc bytes. |
| [in] | cc | Row byte extent under the selected transform preconditions. |
Definition at line 1414 of file tif_predict.c.
References horDiff64(), and TIFFSwabArrayOfLong8().
Referenced by PredictorSetupEncode().
|
extern |
Restore saved Predictor tag print and setup hooks.
Requires initialised predictor state and still-valid saved callbacks. Restores tag get/set, printer and setup hooks; does not restore wrapped row/strile methods, postdecode swapping, or remove field definitions. Does not free tif_data, flush, allocate, or perform pixel I/O. The outer codec must complete teardown before state is released.
| [in,out] | tif | Non-NULL live handle whose tif_data begins with a valid TIFFPredictorState; serialise codec operations. |
Definition at line 1789 of file tif_predict.c.
References PredictorState, TIFFPredictorState::printdir, TIFFTagMethods::printdir, TIFFPredictorState::setupdecode, TIFFPredictorState::setupencode, tiff::tif_setupdecode, tiff::tif_setupencode, tiff::tif_tagmethods, TIFFTagMethods::vgetfield, TIFFPredictorState::vgetparent, TIFFTagMethods::vsetfield, and TIFFPredictorState::vsetparent.
Referenced by LZMACleanup(), LZWCleanup(), PixarLogCleanup(), ZIPCleanup(), and ZSTDCleanup().
|
extern |
Install Predictor tag and setup hooks around a codec.
Requires predictor state first in an existing codec-owned tif_data block and initialised parent methods. Merges field metadata, saves the parent tag get/set, print and setup-decode/encode methods and installs predictor wrappers for them, sets the predictor to one and clears the transform functions. The row/strip/tile decode and encode wrappers are installed later by the setup wrappers, only when a predictor is active. Must not be called repeatedly on active chains. Field merge failure is diagnosed; allocations/state changes are not transactional. Does not allocate the outer codec state or perform pixel I/O.
| [in,out] | tif | Non-NULL live handle whose tif_data begins with a valid TIFFPredictorState; serialise codec operations. |
Definition at line 1749 of file tif_predict.c.
References _TIFFMergeFields(), TIFFPredictorState::decodepfunc, TIFFPredictorState::encodepfunc, predictFields, TIFFPredictorState::predictor, PredictorPrintDir(), PredictorSetupDecode(), PredictorSetupEncode(), PredictorState, PredictorVGetField(), PredictorVSetField(), TIFFPredictorState::printdir, TIFFTagMethods::printdir, TIFFPredictorState::setupdecode, TIFFPredictorState::setupencode, tiff::tif_setupdecode, tiff::tif_setupencode, tiff::tif_tagmethods, TIFFArrayCount, TIFFErrorExtR(), TIFFTagMethods::vgetfield, TIFFPredictorState::vgetparent, TIFFTagMethods::vsetfield, and TIFFPredictorState::vsetparent.
Referenced by LZWSetupDecode(), TIFFInitLZMA(), TIFFInitLZW(), TIFFInitPixarLog(), TIFFInitZIP(), and TIFFInitZSTD().
|
static |
Define the codec-owned Predictor field metadata.
Immutable library-lifetime table merged during initialisation; do not free it.
Definition at line 1629 of file tif_predict.c.
Referenced by TIFFPredictorInit().