LibTIFF 4.7.2
TIFF library public API and implementation reference
Loading...
Searching...
No Matches
Typedefs | Functions
Layout calculations and sizing methods

Compute row/strile sizes and dispatch codec sizing recommendations. More...

Collaboration diagram for Layout calculations and sizing methods:

Typedefs

typedef uint32_t(* TIFFStripMethod) (TIFF *tif, uint32_t request)
 Recommend rows per strip for the current geometry and codec.
 
typedef void(* TIFFTileMethod) (TIFF *tif, uint32_t *tw, uint32_t *th)
 Adjust tile width and height for the current codec.
 

Functions

uint32_t _TIFFDefaultStripSize (TIFF *tif, uint32_t s)
 Choose a default strip height near STRIP_SIZE_DEFAULT bytes.
 
void _TIFFDefaultTileSize (TIFF *tif, uint32_t *tw, uint32_t *th)
 Supply default tile dimensions and round them to multiples of sixteen.
 
uint32_t _TIFFComputeTileExt (TIFF *tif, uint32_t x, uint32_t y, uint32_t z, uint16_t s, bool *pOverflowed)
 Compute a tile index as TIFFComputeTile() does, and record an index overflow in a caller-provided flag.
 
uint64_t _TIFFStrileSize64 (TIFF *tif, uint32_t nrows, int isStrip)
 Compute row-aligned decoded storage for a strip or tile-height request.
 

Detailed Description

Compute row/strile sizes and dispatch codec sizing recommendations.

Typedef Documentation

◆ TIFFStripMethod

typedef uint32_t(* TIFFStripMethod) (TIFF *tif, uint32_t request)

Recommend rows per strip for the current geometry and codec.

Invoked synchronously by TIFFDefaultStripSize() through a borrowed installed method. Return a recommendation without transferring ownership; dispatch does not apply it to the directory or validate it. The implementation may inspect/change codec state, call getters, allocate, or report diagnostics. Preserve the established geometry unless documented by the codec and keep callback code/context live while installed/in flight. No status channel separate from the row count is provided.

Parameters
[in,out]tifNon-NULL live handle with consistent current geometry; queries may use getters/callbacks. Serialise access externally.
[in]requestRequested row count, typically zero for a heuristic; default method uses signed 32-bit interpretation.
Returns
Recommended row count under the method's codec-specific rules; dispatch imposes no universal error sentinel.

Definition at line 297 of file tiffiop.h.

◆ TIFFTileMethod

typedef void(* TIFFTileMethod) (TIFF *tif, uint32_t *tw, uint32_t *th)

Adjust tile width and height for the current codec.

Invoked synchronously by TIFFDefaultTileSize() with borrowed writable slots. The installed method must leave a documented recommendation, normally valid multiples of sixteen, without transferring ownership. Dispatch does not apply tags or validate results. Codec state, allocation, getter, and diagnostic effects depend on the method; there is no return status or automatic recovery. Keep code/context live while installed/in flight and serialise handle access.

Parameters
[in,out]tifNon-NULL live handle with consistent current geometry; queries may use getters/callbacks. Serialise access externally.
[in,out]twNon-NULL caller-owned width request/result in pixels.
[in,out]thNon-NULL caller-owned height request/result in rows.

Definition at line 315 of file tiffiop.h.

Function Documentation

◆ _TIFFComputeTileExt()

uint32_t _TIFFComputeTileExt ( TIFF *  tif,
uint32_t  x,
uint32_t  y,
uint32_t  z,
uint16_t  s,
bool *  pOverflowed 
)
extern

Compute a tile index as TIFFComputeTile() does, and record an index overflow in a caller-provided flag.

TIFFComputeTile() calls this with a NULL flag. Zero is a valid tile index, so the return value alone cannot tell an overflow apart. When the tile index overflows, emits an error and sets *pOverflowed to true when pOverflowed is not NULL; the flag is never reset to false. A sample out of range for separate storage emits an error and returns zero without setting the flag: callers that test the flag are expected to have checked the coordinates with TIFFCheckTile() first. Does not validate or clamp x/y/z to the image. Does not allocate, perform I/O, or acquire ownership.

Parameters
[in]tifNon-NULL live handle with consistent current geometry; no ownership transfer.
[in]xPixel column; not checked against ImageWidth.
[in]yPixel row; not checked against ImageLength.
[in]zDepth slice; forced to zero when ImageDepth is one.
[in]sSeparate sample plane; ignored for contiguous storage.
[out]pOverflowedOverflow flag, or NULL; set to true when the tile index overflows and left unchanged otherwise.
Returns
Computed zero-based tile index; zero on overflow or sample rejection; or one for zero effective tile dimensions, as with TIFFComputeTile().

Definition at line 52 of file tif_tile.c.

References _TIFFAdd64Ext(), _TIFFCastUInt64ToUInt32Ext(), _TIFFMultiply32Ext(), PLANARCONFIG_SEPARATE, TIFFDirectory::td_tilewidth, tiff::tif_dir, TIFFErrorExtR(), and TIFFhowmany_32.

Referenced by _TIFFReadTileAndAllocBuffer(), TIFFComputeTile(), TIFFReadTile(), and TIFFWriteTile().

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

◆ _TIFFDefaultStripSize()

uint32_t _TIFFDefaultStripSize ( TIFF *  tif,
uint32_t  s 
)
extern

Choose a default strip height near STRIP_SIZE_DEFAULT bytes.

Interprets s through int32_t: zero or high-bit unsigned requests trigger the heuristic; positive signed-range requests pass through. Divides STRIP_SIZE_DEFAULT by TIFFScanlineSize64(), using one byte if that query returned zero, then clamps rows to [1,UINT32_MAX]. A diagnostic from scanline sizing does not prevent a recommendation. Does not set tags or allocate output; the scanline query may use getters/callbacks. No ownership transfer.

Parameters
[in,out]tifNon-NULL live handle with consistent current geometry; queries may use getters/callbacks. Serialise access externally.
[in]sRequested rows; interpreted as a signed 32-bit value for heuristic selection.
Returns
Input request when positive in signed interpretation, otherwise a bounded positive heuristic row count.

Definition at line 263 of file tif_strip.c.

References STRIP_SIZE_DEFAULT, and TIFFScanlineSize64().

Referenced by _TIFFSetDefaultCompressionState().

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

◆ _TIFFDefaultTileSize()

void _TIFFDefaultTileSize ( TIFF *  tif,
uint32_t *  tw,
uint32_t *  th 
)
extern

Supply default tile dimensions and round them to multiples of sixteen.

Reads each uint32_t request through its signed 32-bit representation. Nonpositive values, including high-bit unsigned requests, become 256; positive requests are rounded upward to a multiple of sixteen. Does not inspect tif, set tags, allocate, perform I/O, issue diagnostics, or transfer ownership. Both result slots remain caller-owned.

Parameters
[in]tifUnused compatibility context; may be NULL for this default implementation.
[in,out]twNon-NULL writable width request/result in pixels.
[in,out]thNon-NULL writable height request/result in rows.

Definition at line 326 of file tif_tile.c.

References TIFFroundup_32.

Referenced by _TIFFSetDefaultCompressionState().

Here is the caller graph for this function:

◆ _TIFFStrileSize64()

uint64_t _TIFFStrileSize64 ( TIFF *  tif,
uint32_t  nrows,
int  isStrip 
)
extern

Compute row-aligned decoded storage for a strip or tile-height request.

Strip mode maps UINT32_MAX rows to ImageLength. Tile mode rejects zero tile width/length/depth silently but does not multiply by depth. Packed contiguous non-upsampled YCbCr requires exactly three samples and horizontal/vertical factors each in {1,2,4}; invokes the defaulted subsampling getter, rounds width/height to sampling blocks and the entire horizontal block-row bit total to bytes, then multiplies by vertical block count. Other layouts multiply nrows by the scanline or tile-row estimate. Invalid YCbCr sample count or subsampling factors report an error and return zero. Checked products diagnose overflow, but conservative ceiling guards can return zero silently. Allocates no output and does not decode pixels; getters can mutate lookup/cache state or invoke callbacks. No ownership transfer; caller must establish consistent geometry.

Parameters
[in,out]tifNon-NULL live handle with consistent current geometry; queries may use getters/callbacks. Serialise access externally.
[in]nrowsRow count; UINT32_MAX is an all-image sentinel only in strip mode.
[in]isStripNonzero selects strip width/scanline and sentinel handling; zero selects tile geometry.
Returns
Byte estimate, or zero for empty/rejected/overflowed geometry; not a general multi-depth or buffer-validity guarantee.

Definition at line 106 of file tif_strip.c.

References _TIFFMultiply64(), isUpSampled, PHOTOMETRIC_YCBCR, PLANARCONFIG_CONTIG, TIFFDirectory::td_imagelength, tiff::tif_dir, TIFFErrorExtR(), TIFFGetFieldDefaulted(), TIFFhowmany8_64, TIFFhowmany_32, TIFFScanlineSize64(), TIFFTAG_YCBCRSUBSAMPLING, and TIFFTileRowSize64().

Referenced by TIFFVStripSize64(), and TIFFVTileSize64().

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