|
LibTIFF 4.7.2
TIFF library public API and implementation reference
|
Stage and transfer WebP RGB or RGBA frames. More...
Data Structures | |
| struct | WebPState |
| Own WebP frame staging dependency objects and saved tag 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 | LState(tif) ((WebPState *)(tif)->tif_data) |
| Cast tif->tif_data to the WebPState. | |
| #define | DecoderState(tif) LState(tif) |
| Alias of LState(), returning the WebPState for decoding. | |
| #define | EncoderState(tif) LState(tif) |
| Alias of LState(), returning the WebPState for encoding. | |
Functions | |
| static void | TWebPGetStrileDimensions (const TIFF *tif, uint32_t *width, uint32_t *height) |
| Compute the pixel extent of the current strip or tile. | |
| static int | TWebPDatasetWriter (const uint8_t *data, size_t data_size, const WebPPicture *const picture) |
| Append one dependency output fragment to the raw TIFF buffer. | |
| static int | TWebPEncode (TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) |
| Accumulate decoded WebP input in the strile staging buffer. | |
| static int | TWebPDecode (TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s) |
| Decode a WebP strile or retrieve its next decoded rows. | |
| static int | TWebPFixupTags (TIFF *tif) |
| Reject noncontiguous WebP sample organisation. | |
| static int | TWebPSetupDecode (TIFF *tif) |
| Validate WebP channel support and enter decode mode. | |
| static int | TWebPPreDecode (TIFF *tif, uint16_t s) |
| Reset WebP per-strile decode state and error latch. | |
| static int | TWebPSetupEncode (TIFF *tif) |
| Validate WebP input and initialise picture and encoder configuration. | |
| static int | TWebPPreEncode (TIFF *tif, uint16_t s) |
| Allocate full-strile WebP input staging and attach the output writer. | |
| static int | TWebPPostEncode (TIFF *tif) |
| Import staged RGB or RGBA encode it and flush the WebP frame. | |
| static void | TWebPCleanup (TIFF *tif) |
| Release WebP picture decoder staging and outer codec state. | |
| static int | TWebPVSetField (TIFF *tif, uint32_t tag, va_list ap) |
| Store WebP quality lossless settings or delegate another tag. | |
| static int | TWebPVGetField (TIFF *tif, uint32_t tag, va_list ap) |
| Retrieve WebP quality or lossless settings or delegate a tag. | |
| static uint64_t | TWebPGetMaxCompressionRatio (TIFF *tif) |
| Report the channel-dependent WebP expansion heuristic. | |
| int | TIFFInitWebP (TIFF *tif, int scheme) |
| Allocate WebP codec state and install buffered frame callbacks. | |
Variables | |
| static const TIFFField | TWebPFields [] |
| Define WebP quality lossless and exact pseudo-tags. | |
Stage and transfer WebP RGB or RGBA frames.
| #define DecoderState | ( | tif | ) | LState(tif) |
Alias of LState(), returning the WebPState for decoding.
tif is evaluated once. Requires the codec to be initialised.
| [in] | tif | Handle whose codec state is returned. |
Definition at line 117 of file tif_webp.c.
| #define EncoderState | ( | tif | ) | LState(tif) |
Alias of LState(), returning the WebPState for encoding.
tif is evaluated once. Requires the codec to be initialised.
| [in] | tif | Handle whose codec state is returned. |
Definition at line 118 of file tif_webp.c.
| #define LState | ( | tif | ) | ((WebPState *)(tif)->tif_data) |
Cast tif->tif_data to the WebPState.
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 116 of file tif_webp.c.
| #define LSTATE_INIT_DECODE 0x01 |
Bit 0x01 of the codec state field: decoding has been set up.
Set by TWebPSetupDecode(). Each setup first tears down the other mode, if active, and clears the field.
Definition at line 45 of file tif_webp.c.
| #define LSTATE_INIT_ENCODE 0x02 |
Bit 0x02 of the codec state field: encoding has been set up.
Set by TWebPSetupEncode(). Each setup first tears down the other mode, if active, and clears the field.
Definition at line 46 of file tif_webp.c.
|
extern |
Allocate WebP codec state and install buffered frame callbacks.
Requires cleaned-up previous codec state and COMPRESSION_WEBP. Merges pseudo-tags, allocates outer Ext state, saves tag hooks and sets defaults quality 75, lossy, exact enabled for later lossless use. Installs row/strile transfer and cleanup callbacks; row encoding stages input until postencode. Field/allocation failure diagnoses without general rollback. Dependency objects and staging are created lazily. No pixel I/O.
| [in,out] | tif | Non-NULL handle whose previous codec state has been cleaned up; receives the new codec state. Geometry is checked later, at setup. Serialise operations. |
| [in] | scheme | COMPRESSION_WEBP, asserted in debug builds. |
Definition at line 1167 of file tif_webp.c.
References _TIFFmallocExt(), _TIFFMergeFields(), COMPRESSION_WEBP, LState, tiff::tif_cleanup, tiff::tif_data, tiff::tif_decoderow, tiff::tif_decodestrip, tiff::tif_decodetile, 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(), TWebPCleanup(), TWebPDecode(), TWebPEncode(), TWebPFields, TWebPFixupTags(), TWebPGetMaxCompressionRatio(), TWebPPostEncode(), TWebPPreDecode(), TWebPPreEncode(), TWebPSetupDecode(), TWebPSetupEncode(), TWebPVGetField(), TWebPVSetField(), TIFFTagMethods::vgetfield, and TIFFTagMethods::vsetfield.
|
static |
Release WebP picture decoder staging and outer codec state.
Restores saved tag hooks, releases dependency picture/decoder/buffer descriptor and Ext staging/state allocations, clears tif_data and resets methods. Invalidates state, dependency and retained borrowed-output views. Does not finish or flush a pending frame or close the borrowed handle; no status result.
| [in,out] | tif | Non-NULL live WebP handle with coherent raw buffers and established contiguous eight-bit RGB/RGBA geometry; serialise operations. |
Definition at line 991 of file tif_webp.c.
References _TIFFfreeExt(), _TIFFSetDefaultCompressionState(), WebPState::last_y, LState, LSTATE_INIT_ENCODE, WebPState::pBuffer, WebPState::psDecoder, WebPState::sDecBuffer, WebPState::sPicture, WebPState::state, tiff::tif_data, tiff::tif_tagmethods, TIFFTagMethods::vgetfield, WebPState::vgetparent, TIFFTagMethods::vsetfield, and WebPState::vsetparent.
Referenced by TIFFInitWebP().
|
static |
Append one dependency output fragment to the raw TIFF buffer.
Requires valid picture context and representable byte/cursor arithmetic. Checks remaining raw capacity, copies bytes and advances rawcp/rawcc; diagnoses insufficient space without flushing. No retained input, allocation or ownership transfer.
| [in] | data | Borrowed dependency output valid for the duration of the writer callback. |
| [in] | data_size | Output byte extent, representable by tmsize_t with checked-by-caller cursor sums. |
| [in] | picture | Borrowed picture whose custom_ptr contains the live TIFF handle. |
Definition at line 172 of file tif_webp.c.
References _TIFFmemcpy(), TIFF_SIZE_FORMAT, and TIFFErrorExtR().
Referenced by TWebPPreEncode().
Decode a WebP strile or retrieve its next decoded rows.
Requires successful predecode and validated positive geometry/stride. On first use checks blob dimensions and, for available ABI, channel compatibility (opaque RGB blob may fill RGBA). Uses caller output directly for a full-strile request or codec-owned staging for partial rows; lazily creates a dependency decoder. Requires complete row extents and enough newly decoded rows. Success consumes all raw input, advances last_y, and deletes a completed direct-output decoder. Errors normally clear requested output and latch read_error; fractional-row usage errors do not latch. Decoder/stream state can change before failure, and a direct-output decoder can retain the borrowed output pointer until the next predecode/cleanup. No ownership transfer or direct client I/O.
| [in,out] | tif | Non-NULL live WebP handle with coherent raw buffers and established contiguous eight-bit RGB/RGBA geometry; serialise operations. |
| [out] | op | Borrowed writable occ-byte output; keep it live until predecode/cleanup if an external-buffer decode fails before decoder release. |
| [in] | occ | Nonnegative whole-row output byte extent. |
| [in] | s | Unused sample-plane argument. |
Definition at line 275 of file tif_webp.c.
References _TIFFfreeExt(), _TIFFmallocExt(), WebPState::buffer_size, DecoderState, WebPState::last_y, LSTATE_INIT_DECODE, WebPState::nSamples, WebPState::pBuffer, WebPState::psDecoder, WebPState::read_error, WebPState::sDecBuffer, WebPState::state, TIFFDirectory::td_row, tiff::tif_dir, tiff::tif_rawcc, tiff::tif_rawcp, TIFFErrorExtR(), and TWebPGetStrileDimensions().
Referenced by TIFFInitWebP().
Accumulate decoded WebP input in the strile staging buffer.
Requires successful preencode and nonnegative count; a state not initialised for encoding, as after reading on an "r+" handle, is diagnosed and rejected. Bounds offset+cc against buffer_size using uint64_t, copies input and advances offset. Does not compress until postencode. Input remains caller-owned/unmodified; rejection diagnoses, no client I/O or ownership transfer.
| [in,out] | tif | Non-NULL live WebP handle with coherent raw buffers and established contiguous eight-bit RGB/RGBA geometry; serialise operations. |
| [in] | bp | Borrowed readable cc-byte input, copied synchronously without modification. |
| [in] | cc | Nonnegative input byte extent within the remaining strile allocation. |
| [in] | s | Unused sample-plane argument. |
Definition at line 221 of file tif_webp.c.
References EncoderState, LSTATE_INIT_ENCODE, and TIFFErrorExtR().
Referenced by TIFFInitWebP().
|
static |
Reject noncontiguous WebP sample organisation.
Checks PLANARCONFIG_CONTIG and diagnoses rejection. No allocation, payload I/O, state mutation or ownership transfer.
| [in] | tif | Non-NULL live WebP handle whose PlanarConfiguration is checked. |
Definition at line 526 of file tif_webp.c.
References PLANARCONFIG_CONTIG, TIFFDirectory::td_planarconfig, tiff::tif_dir, and TIFFErrorExtR().
Referenced by TIFFInitWebP().
|
static |
Report the channel-dependent WebP expansion heuristic.
Reads sample count without allocation, diagnostics, I/O or state/ownership effects. Uses lossless-derived estimates regardless of selected mode; not a universal bound.
| [in] | tif | Non-NULL live WebP handle; only SamplesPerPixel is read. |
Definition at line 1156 of file tif_webp.c.
References TIFFDirectory::td_samplesperpixel, and tiff::tif_dir.
Referenced by TIFFInitWebP().
|
static |
Compute the pixel extent of the current strip or tile.
A tile always has the full TileWidth by TileLength extent. A strip is ImageWidth wide and RowsPerStrip high, truncated to the rows left from td_row for the final strip. Reads directory state only.
| [in] | tif | Non-NULL live handle with established geometry and current row. |
| [out] | width | Non-NULL slot receiving the strile width in pixels. |
| [out] | height | Non-NULL slot receiving the strile height in rows. |
Definition at line 136 of file tif_webp.c.
References isTiled, TIFFDirectory::td_imagelength, TIFFDirectory::td_imagewidth, TIFFDirectory::td_row, TIFFDirectory::td_rowsperstrip, TIFFDirectory::td_tilelength, TIFFDirectory::td_tilewidth, and tiff::tif_dir.
Referenced by TWebPDecode(), TWebPPreDecode(), and TWebPPreEncode().
|
static |
Import staged RGB or RGBA encode it and flush the WebP frame.
Fails with a diagnostic unless the state is initialised for encoding. Staging that was not fully filled has its unwritten tail cleared, so uninitialised memory is never compressed; the cleared bytes are encoded as zero samples. Imports dependency picture data, encodes through the bounded raw-buffer writer then flushes. Picture/custom context and raw/file state can change on failure. Dependency ABI selects RGBA/error-detail support. No IFD persistence, durability guarantee or input ownership transfer.
| [in,out] | tif | Non-NULL live WebP handle with coherent raw buffers and established contiguous eight-bit RGB/RGBA geometry; serialise operations. |
Definition at line 870 of file tif_webp.c.
References WebPState::buffer_offset, WebPState::buffer_size, EncoderState, LSTATE_INIT_ENCODE, WebPState::nSamples, WebPState::pBuffer, WebPState::sEncoderConfig, WebPState::sPicture, WebPState::state, TIFFErrorExtR(), and TIFFFlushData1().
Referenced by TIFFInitWebP().
|
static |
Reset WebP per-strile decode state and error latch.
Computes tile or truncated-strip dimensions and rejects either above
| [in,out] | tif | Non-NULL live WebP handle with coherent raw buffers and established contiguous eight-bit RGB/RGBA geometry; serialise operations. |
| [in] | s | Unused sample-plane argument. |
Definition at line 633 of file tif_webp.c.
References DecoderState, LSTATE_INIT_DECODE, WebPState::psDecoder, WebPState::read_error, WebPState::sDecBuffer, WebPState::state, tiff::tif_setupdecode, TIFFErrorExtR(), and TWebPGetStrileDimensions().
Referenced by TIFFInitWebP().
|
static |
Allocate full-strile WebP input staging and attach the output writer.
Runs encoder setup when the state is not yet initialised for encoding and fails if it fails, computes the tile/truncated-strip extent with TWebPGetStrileDimensions(), rejects dimensions above 16383 and replaces the old staging allocation. Requires valid positive geometry and a successful encoder configuration. Size is bounded below one GiB for at most four samples. Sets picture width/height, writer and borrowed handle context. Failure can discard the old staging buffer; no payload I/O or ownership transfer.
| [in,out] | tif | Non-NULL live WebP handle with coherent raw buffers and established contiguous eight-bit RGB/RGBA geometry; serialise operations. |
| [in] | s | Unused sample-plane argument. |
Definition at line 801 of file tif_webp.c.
References _TIFFfreeExt(), _TIFFmallocExt(), WebPState::buffer_offset, WebPState::buffer_size, EncoderState, LSTATE_INIT_ENCODE, WebPState::nSamples, WebPState::pBuffer, WebPState::sPicture, WebPState::state, tiff::tif_setupencode, TIFFErrorExtR(), TWebPDatasetWriter(), and TWebPGetStrileDimensions().
Referenced by TIFFInitWebP().
|
static |
Validate WebP channel support and enter decode mode.
Caches sample count and accepts three channels or four when encoder ABI supports them. Current sample-format check rejects only when both bit depth differs from eight and format differs from unsigned, so caller must establish valid eight-bit unsigned data separately. Releases an old encoder picture/staging buffer when switching modes. State/views can change before later failure; no client I/O or caller ownership transfer.
| [in,out] | tif | Non-NULL live WebP handle with coherent raw buffers and established contiguous eight-bit RGB/RGBA geometry; serialise operations. |
Definition at line 560 of file tif_webp.c.
References _TIFFfreeExt(), WebPState::buffer_offset, DecoderState, LSTATE_INIT_DECODE, LSTATE_INIT_ENCODE, WebPState::nSamples, WebPState::pBuffer, WebPState::sPicture, WebPState::state, TIFFDirectory::td_bitspersample, TIFFDirectory::td_sampleformat, TIFFDirectory::td_samplesperpixel, tiff::tif_dir, and TIFFErrorExtR().
Referenced by TIFFInitWebP().
|
static |
Validate WebP input and initialise picture and encoder configuration.
Requires unsigned eight-bit RGB or ABI-supported RGBA; separate PlanarConfig is diagnosed and rejected, since the dependency encodes interleaved pixels only. Ends decoder mode, initialises dependency picture/config at cached quality, applies supported lossless/exact settings and validates config. Errors diagnose after some mode/config state can change. Dependency picture storage is codec-owned until cleanup; no pixel I/O or caller ownership transfer.
| [in,out] | tif | Non-NULL live WebP handle with coherent raw buffers and established contiguous eight-bit RGB/RGBA geometry; serialise operations. |
Definition at line 684 of file tif_webp.c.
References EncoderState, WebPState::last_y, WebPState::lossless, WebPState::lossless_exact, LSTATE_INIT_DECODE, LSTATE_INIT_ENCODE, WebPState::nSamples, PLANARCONFIG_CONTIG, WebPState::psDecoder, WebPState::quality_level, SAMPLEFORMAT_UINT, WebPState::sDecBuffer, WebPState::sEncoderConfig, WebPState::sPicture, WebPState::state, TIFFDirectory::td_bitspersample, TIFFDirectory::td_planarconfig, TIFFDirectory::td_sampleformat, TIFFDirectory::td_samplesperpixel, tiff::tif_dir, and TIFFErrorExtR().
Referenced by TIFFInitWebP().
|
static |
Retrieve WebP quality or lossless settings or delegate a tag.
Codec pseudo-tags consume non-NULL int* outputs for cached level, lossless and exact values; other tags follow parent getter contracts. No allocation or ownership transfer for codec settings.
| [in,out] | tif | Non-NULL live WebP handle with coherent raw buffers and established contiguous eight-bit RGB/RGBA geometry; 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 1108 of file tif_webp.c.
References WebPState::lossless, WebPState::lossless_exact, LState, WebPState::quality_level, TIFFTAG_WEBP_LEVEL, TIFFTAG_WEBP_LOSSLESS, TIFFTAG_WEBP_LOSSLESS_EXACT, and WebPState::vgetparent.
Referenced by TIFFInitWebP().
|
static |
Store WebP quality lossless settings or delegate another tag.
WEBP_LEVEL consumes int and stores it even outside 1..100, warning without rejection. WEBP_LOSSLESS consumes int when supported and sets quality to 100 when enabled. WEBP_LOSSLESS_EXACT consumes int when supported. Older ABI rejection diagnoses and returns zero. Values apply at encoder setup; current active config is not generally rebuilt. Parent tags follow their variadic contracts; no ownership transfer.
| [in,out] | tif | Non-NULL live WebP handle with coherent raw buffers and established contiguous eight-bit RGB/RGBA geometry; 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 1045 of file tif_webp.c.
References LState, TIFFErrorExtR(), TIFFTAG_WEBP_LEVEL, TIFFTAG_WEBP_LOSSLESS, TIFFTAG_WEBP_LOSSLESS_EXACT, and TIFFWarningExtR().
Referenced by TIFFInitWebP().
|
static |
Define WebP quality lossless and exact pseudo-tags.
Immutable library-lifetime metadata merged into a handle; no caller ownership transfer.
Definition at line 1136 of file tif_webp.c.
Referenced by TIFFInitWebP().