LibTIFF 4.7.2
TIFF library public API and implementation reference
Loading...
Searching...
No Matches
Functions

Transfer complete JBIG image planes through strip callbacks. More...

Collaboration diagram for JBIG plane codec:

Functions

static int JBIGSetupDecode (TIFF *tif)
 Require one strip for JBIG decoding.
 
static int JBIGDecode (TIFF *tif, uint8_t *buffer, tmsize_t size, uint16_t s)
 Decode one complete JBIG plane into caller storage.
 
static int JBIGSetupEncode (TIFF *tif)
 Require one strip for JBIG encoding.
 
static int JBIGCopyEncodedData (TIFF *tif, unsigned char *pp, size_t cc, uint16_t s)
 Copy JBIG output fragments into the buffered raw stream.
 
static void JBIGOutputBie (unsigned char *buffer, size_t len, void *userData)
 Reverse and forward a dependency-produced JBIG output fragment.
 
static int JBIGEncode (TIFF *tif, uint8_t *buffer, tmsize_t size, uint16_t s)
 Encode a complete single-sample one-bit JBIG image plane.
 
int TIFFInitJBIG (TIFF *tif, int scheme)
 Install single-strip JBIG callbacks and mutable raw-input policy.
 

Detailed Description

Transfer complete JBIG image planes through strip callbacks.

Function Documentation

◆ JBIGCopyEncodedData()

static int JBIGCopyEncodedData ( TIFF *  tif,
unsigned char *  pp,
size_t  cc,
uint16_t  s 
)
static

Copy JBIG output fragments into the buffered raw stream.

Requires positive usable raw capacity, coherent cursor/counts and a cc extent representable by tmsize_t. Copies borrowed bytes, advances cursors and flushes full buffers. I/O/diagnostic side effects can leave partial file data on failure. Does not retain input or transfer ownership.

Parameters
[in,out]tifNon-NULL live JBIG handle with coherent writable raw storage and validated single-strip geometry; serialise access.
[in]ppBorrowed readable dependency output of cc bytes, valid only during the call.
[in]ccByte extent representable by tmsize_t with valid cursor additions.
[in]sUnused sample-plane argument.
Returns
One after all bytes buffered/flushed, minus one on flush failure.

Definition at line 253 of file tif_jbig.c.

References _TIFFmemcpy(), tiff::tif_rawcc, tiff::tif_rawcp, tiff::tif_rawdatasize, and TIFFFlushData1().

Referenced by JBIGOutputBie().

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

◆ JBIGDecode()

static int JBIGDecode ( TIFF *  tif,
uint8_t *  buffer,
tmsize_t  size,
uint16_t  s 
)
static

Decode one complete JBIG plane into caller storage.

May reverse raw input bits in place and optionally update BIE length without checking that helper status. Creates a temporary dependency decoder, decodes all raw input and frees it on every ordinary exit. Dependency error clears requested output and diagnoses; a decoded image smaller than the request warns and zero-pads, while a larger image, one whose size is not representable as tmsize_t, or a missing decoded image is diagnosed and clears requested output before rejection. Success copies plane zero then consumes all raw bytes; failure can leave raw bytes reversed or output changed. No caller ownership transfer or direct client I/O.

Parameters
[in,out]tifNon-NULL live JBIG handle with coherent writable raw storage and validated single-strip geometry; serialise access.
[out]bufferBorrowed writable size-byte output, disjoint from raw input.
[in]sizeNonnegative output byte extent; bytes beyond a shorter decoded plane are zeroed.
[in]sUnused sample-plane argument.
Returns
One after accepted plane copy including short-image padding, zero on dependency error or oversized decoded plane.

Definition at line 98 of file tif_jbig.c.

References _TIFFmemcpy(), isFillOrder, TIFFDirectory::td_fillorder, tiff::tif_dir, tiff::tif_rawcc, tiff::tif_rawcp, TIFF_SSIZE_FORMAT, TIFF_TMSIZE_T_MAX, TIFFErrorExtR(), TIFFReverseBits(), and TIFFWarningExtR().

Referenced by TIFFInitJBIG().

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

◆ JBIGEncode()

static int JBIGEncode ( TIFF *  tif,
uint8_t *  buffer,
tmsize_t  size,
uint16_t  s 
)
static

Encode a complete single-sample one-bit JBIG image plane.

Validates bit depth, sample count and single-strip organisation, computes a checked complete-plane extent and rejects short input. Creates a temporary dependency encoder referencing caller bytes synchronously, emits data through JBIGOutputBie and frees encoder state. Caller input is not modified by this function. Output callback flush status is ignored, so encoder success does not prove successful payload writes. No caller ownership transfer; output/file changes are not transactional.

Parameters
[in,out]tifNon-NULL live JBIG handle with coherent writable raw storage; geometry is checked here. Serialise access.
[in]bufferBorrowed readable complete image plane of at least size bytes.
[in]sizeByte count available in buffer; must be at least the complete plane size.
[in]sUnused sample-plane argument.
Returns
One after dependency encoding returns, zero on explicit input/extent validation failure; callback I/O errors are not reflected. An empty (zero-width or zero-length) plane returns zero without a diagnostic.

Definition at line 334 of file tif_jbig.c.

References _TIFFCastUInt64ToSSize(), _TIFFMultiply64(), JBIGOutputBie(), tiff::tif_dir, TIFF_SSIZE_FORMAT, TIFFErrorExtR(), TIFFhowmany8_64, and TIFFNumberOfStrips().

Referenced by TIFFInitJBIG().

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

◆ JBIGOutputBie()

static void JBIGOutputBie ( unsigned char *  buffer,
size_t  len,
void *  userData 
)
static

Reverse and forward a dependency-produced JBIG output fragment.

Borrows writable dependency output and the handle context. Reverses bits when required then calls JBIGCopyEncodedData, ignoring its status because this void callback has no error channel. Flush failures can diagnose and mutate file/cache state without propagating to the outer encoder. No retained output pointer or ownership transfer.

Parameters
[in,out]bufferBorrowed mutable dependency-produced output of len bytes; not retained.
[in]lenMutable dependency output extent representable by tmsize_t.
[in,out]userDataBorrowed live TIFF handle supplied to the dependency output callback.

Definition at line 298 of file tif_jbig.c.

References isFillOrder, JBIGCopyEncodedData(), TIFFDirectory::td_fillorder, tiff::tif_dir, and TIFFReverseBits().

Referenced by JBIGEncode().

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

◆ JBIGSetupDecode()

static int JBIGSetupDecode ( TIFF *  tif)
static

Require one strip for JBIG decoding.

Checks the current logical strip count and diagnoses rejection. Does not validate every sample/geometry constraint, allocate, access payload or transfer ownership.

Parameters
[in]tifNon-NULL live JBIG handle whose strip count is checked.
Returns
One for exactly one strip, zero otherwise.

Definition at line 61 of file tif_jbig.c.

References TIFFErrorExtR(), and TIFFNumberOfStrips().

Referenced by TIFFInitJBIG().

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

◆ JBIGSetupEncode()

static int JBIGSetupEncode ( TIFF *  tif)
static

Require one strip for JBIG encoding.

Checks the strip count and diagnoses rejection. Does not itself validate sample depth, allocate or perform payload I/O. No ownership transfer.

Parameters
[in]tifNon-NULL live JBIG handle whose strip count is checked.
Returns
One for exactly one strip, zero otherwise.

Definition at line 223 of file tif_jbig.c.

References TIFFErrorExtR(), and TIFFNumberOfStrips().

Referenced by TIFFInitJBIG().

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

◆ TIFFInitJBIG()

int TIFFInitJBIG ( TIFF *  tif,
int  scheme 
)
extern

Install single-strip JBIG callbacks and mutable raw-input policy.

Requires cleaned-up previous codec state and COMPRESSION_JBIG. Sets NOBITREV, clears MAPPED, and detaches a previously mapped raw view while restoring owned-buffer policy. Does not free the mapping, allocate outer state or perform pixel I/O. Installs strip decode/encode and setup methods; no row or tile transfer support. No ownership transfer of caller storage.

Parameters
[in,out]tifNon-NULL handle whose previous codec state has been cleaned up; its flags, raw-buffer fields and methods are changed. Serialise access.
[in]schemeCOMPRESSION_JBIG, asserted in debug builds.
Returns
One unconditionally.

Definition at line 387 of file tif_jbig.c.

References COMPRESSION_JBIG, JBIGDecode(), JBIGEncode(), JBIGSetupDecode(), JBIGSetupEncode(), tiff::tif_decodestrip, tiff::tif_encodestrip, tiff::tif_flags, tiff::tif_rawdata, tiff::tif_rawdatasize, tiff::tif_setupdecode, tiff::tif_setupencode, TIFF_BUFFERMMAP, TIFF_MYBUFFER, and TIFF_NOBITREV.

Here is the call graph for this function: