|
LibTIFF 4.7.2
TIFF library public API and implementation reference
|
Attach borrowed buffers, allocate owned buffers, and prepare strile arrays. More...
Functions | |
| int | TIFFReadBufferSetup (TIFF *tif, void *bp, tmsize_t size) |
| Replace the handle's raw reading buffer. | |
| int | TIFFWriteBufferSetup (TIFF *tif, void *bp, tmsize_t size) |
| Replace the handle's encoding buffer. | |
| int | TIFFSetupStrips (TIFF *tif) |
| Replace strile offset/count arrays from current geometry. | |
| int | TIFFWriteCheck (TIFF *tif, int tiles, const char *module) |
| Validate and prepare geometry for image writing. | |
| uint64_t | TIFFGetMaxCompressionRatio (TIFF *tif) |
| Query the codec's allocation-recovery compression-ratio heuristic. | |
Attach borrowed buffers, allocate owned buffers, and prepare strile arrays.
|
extern |
Query the codec's allocation-recovery compression-ratio heuristic.
Invokes the installed optional ratio callback; absent callback returns zero. Used by selected large-allocation sanity checks, not a mathematically guaranteed compression bound or output-buffer capacity. Callback effects/diagnostics depend on the codec; no ownership transfers and dispatch imposes no other validation.
| [in] | tif | Non-NULL live handle with matching current geometry and codec methods; the built-in callbacks only read it. Serialise access externally. |
Definition at line 272 of file tif_compress.c.
References tiff::tif_getmaxcompressionratio.
Referenced by _TIFFReadEncodedStripAndAllocBuffer(), _TIFFReadEncodedTileAndAllocBuffer(), TIFFFillStrip(), and TIFFFillTile().
Replace the handle's raw reading buffer.
Detaches old raw storage, freeing it only when TIFF_MYBUFFER marks ownership. A non-NULL bp is borrowed: keep it live, writable, and large enough until detached/handle cleanup; the library does not free it. NULL requests matching Ext allocation owned/released by the handle. Never pass the old owned allocation back as bp: it is freed first. Replacement is destructive, with no rollback on allocation failure. Requires a raw-capable codec; owned capacity is rounded to 1024 bytes and zero-filled. Explicit borrowed capacity is stored as supplied, so the caller must provide a valid positive size. Clears the raw cursor, count and loaded extent and forgets the current strip/tile, so the next read reloads its strile into the new buffer; with a codec that cannot seek within a strile, scanline reading must then restart at the strile's first row. Does not otherwise restart codec state. Allocation/policy failures dispatch diagnostics. After a failed owned allocation the handle has no raw buffer and a zero capacity but keeps TIFF_MYBUFFER, so a later strip or tile read allocates its own buffer again. No caller allocation ownership transfers merely by attaching bp.
| [in,out] | tif | Non-NULL live handle with matching current geometry and codec methods; serialise access externally. |
| [in] | bp | Borrowed writable buffer that later raw reads fill, or NULL to allocate owned storage; not dereferenced here and must not alias an allocation being released. |
| [in] | size | Positive buffer capacity in bytes; with bp NULL it is rounded up to a multiple of 1024, and a size that rounds to zero is rejected. |
Definition at line 1802 of file tif_read.c.
References _TIFFcallocExt(), _TIFFfreeExt(), NOSTRIP, NOTILE, TIFFDirectory::td_curstrip, TIFFDirectory::td_curtile, TIFFDirectory::td_row, tiff::tif_dir, tiff::tif_flags, tiff::tif_rawcc, tiff::tif_rawcp, tiff::tif_rawdata, tiff::tif_rawdataloaded, tiff::tif_rawdataoff, tiff::tif_rawdatasize, TIFF_MYBUFFER, TIFF_NOREADRAW, TIFFErrorExtR(), and TIFFroundup_64.
Referenced by TIFFFillStrip(), and TIFFFillTile().
|
extern |
Replace strile offset/count arrays from current geometry.
Computes counts, enforces directory array-size limits, frees old arrays and allocates zeroed replacements with the handle allocator. Requires consistent nonzero sample/row/tile geometry, particularly separate-plane divisor. Updates cached counts before allocations; failure can leave one array allocated and the other NULL, with old values lost. Sets offset/count presence bits only on success. Does not write payloads or the IFD. Diagnostics follow geometry/size/allocation helpers; borrowed array views are invalidated.
| [in,out] | tif | Non-NULL live handle with matching current geometry and codec methods; serialise access externally. |
Definition at line 729 of file tif_write.c.
References _TIFFCheckMalloc(), _TIFFfreeExt(), _TIFFmemset(), FIELD_ROWSPERSTRIP, FIELD_STRIPBYTECOUNTS, FIELD_STRIPOFFSETS, FIELD_TILEDIMENSIONS, isTiled, isUnspecified, PLANARCONFIG_SEPARATE, TIFFDirectory::td_nstrips, TIFFDirectory::td_planarconfig, TIFFDirectory::td_samplesperpixel, TIFFDirectory::td_stripbytecount_p, TIFFDirectory::td_stripoffset_p, TIFFDirectory::td_stripsperimage, tiff::tif_dir, tiff::tif_flags, TIFF_BIGTIFF, TIFFErrorExtR(), TIFFNumberOfStrips(), TIFFNumberOfTiles(), and TIFFSetFieldBit.
Referenced by TIFFCheckpointDirectory(), TIFFForceStrileArrayWriting(), TIFFReadDirectory(), and TIFFWriteCheck().
Replace the handle's encoding buffer.
Detaches old raw storage, freeing it only when TIFF_MYBUFFER marks ownership. A non-NULL bp is borrowed: keep it live, writable, and large enough until detached/handle cleanup; the library does not free it. NULL requests matching Ext allocation owned/released by the handle. Never pass the old owned allocation back as bp: it is freed first. A size other than minus one must be positive; any other value is diagnosed and rejected before the old buffer is touched. Replacement is otherwise destructive, with no rollback on allocation failure. Minus one forces owned allocation, ignoring bp, using a geometry estimate plus margin and at least 8192 bytes. Initialises raw cursor/count and buffer-setup flag on success; does not flush pending encoded bytes before replacement. Allocation failure dispatches a diagnostic. No caller allocation ownership transfers merely by attaching bp.
| [in,out] | tif | Non-NULL live handle with matching current geometry and codec methods; serialise access externally. |
| [in] | bp | Borrowed writable buffer that later encoding fills, or NULL to allocate owned storage; not dereferenced here and must not alias an allocation being released. |
| [in] | size | Buffer capacity in bytes, or minus one to allocate owned storage sized from the current geometry (bp is then ignored). |
Definition at line 860 of file tif_write.c.
References _TIFFfreeExt(), _TIFFmallocExt(), isTiled, TIFFDirectory::td_tilesize, tiff::tif_dir, tiff::tif_flags, tiff::tif_rawcc, tiff::tif_rawcp, tiff::tif_rawdata, tiff::tif_rawdatasize, TIFF_BUFFERSETUP, TIFF_MYBUFFER, TIFF_SSIZE_FORMAT, TIFF_TMSIZE_T_MAX, TIFFErrorExtR(), and TIFFStripSize().
Referenced by _TIFFReserveLargeEnoughWriteBuffer().
|
extern |
Validate and prepare geometry for image writing.
Checks writable mode and organisation, attempts deferred-array fill without propagating its result, validates image-width presence, allocates missing strile arrays, computes cached tile/scanline sizes, and sets TIFF_BEENWRITING to freeze most format tags. Can force deferred strile-array writing; if that fails, clears TIFF_BEENWRITING again and fails. Does not validate every tag, input buffer, or codec operation. Reads deferred strile arrays when present and, in update mode with placeholder strile entries, rewrites them in the file through TIFFForceStrileArrayWriting(). Invokes tag/diagnostic callbacks but no codec callbacks, and encodes no image data. Failure can leave new arrays/counts/caches and flags; no rollback. No ownership transfers. No errno or durability guarantee. See Image transfers and buffers.
| [in,out] | tif | Non-NULL live handle with matching current geometry and codec methods; serialise access externally. |
| [in] | tiles | Exactly one for tiled operations, zero for strips/scanlines. |
| [in] | module | Borrowed diagnostic context string, or NULL. |
Definition at line 783 of file tif_write.c.
References _TIFFFillStriles(), FIELD_IMAGEDIMENSIONS, isTiled, TIFFDirectory::td_nstrips, TIFFDirectory::td_scanlinesize, TIFFDirectory::td_stripbytecount_entry, TIFFDirectory::td_stripoffset_entry, TIFFDirectory::td_stripoffset_p, TIFFDirectory::td_tilesize, TIFFDirEntry::tdir_count, TIFFDirEntry::tdir_offset, TIFFDirEntry::tdir_tag, TIFFDirEntry::tdir_type, tiff::tif_dir, tiff::tif_flags, tiff::tif_mode, TIFF_BEENWRITING, TIFF_DIRTYDIRECT, TIFFErrorExtR(), TIFFFieldSet, TIFFForceStrileArrayWriting(), TIFFScanlineSize(), TIFFSetupStrips(), TIFFTileSize(), and TIFFDirEntry::toff_long8.