LibTIFF 4.7.2
TIFF library public API and implementation reference
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
Uncompressed and byte-run codecs

Implement uncompressed PackBits ThunderScan and NeXT transfers. More...

Collaboration diagram for Uncompressed and byte-run codecs:

Data Structures

struct  TIFFByteCursor
 Track a borrowed byte range as a pointer and a remaining count. More...
 

Macros

#define SETPIXEL(op, v)
 Store a 2-bit pixel into the packed output byte at op.
 
#define LITERALROW   0x00
 NeXT row opcode: the scanline follows as td_scanlinesize literal bytes.
 
#define LITERALSPAN   0x40
 NeXT row opcode: a 16-bit big-endian offset and length precede a literal byte span within the white scanline.
 
#define THUNDER_CODE   0xc0 /* mask for 2-bit code word */
 Mask selecting the 2-bit code word in the top bits of a ThunderScan byte.
 
#define THUNDER_RUN   0x00 /* run of pixels w/ encoded count */
 ThunderScan code word for a run of the previous pixel.
 
#define THUNDER_2BITDELTAS   0x40 /* 3 pixels w/ encoded 2-bit deltas */
 ThunderScan code word for three packed 2-bit pixel deltas.
 
#define DELTA2_SKIP   2 /* skip code for 2-bit deltas */
 2-bit delta value meaning "no pixel" in a THUNDER_2BITDELTAS byte.
 
#define THUNDER_3BITDELTAS   0x80 /* 2 pixels w/ encoded 3-bit deltas */
 ThunderScan code word for two packed 3-bit pixel deltas.
 
#define DELTA3_SKIP   4 /* skip code for 3-bit deltas */
 3-bit delta value meaning "no pixel" in a THUNDER_3BITDELTAS byte.
 
#define THUNDER_RAW   0xc0 /* raw data encoded */
 ThunderScan code word for a literal 4-bit pixel.
 
#define SETPIXEL(op, v)
 Store a 4-bit pixel into the packed output if maxpixels has not been reached.
 

Functions

static int _TIFFByteCursorGetU8 (TIFFByteCursor *c, uint8_t *out)
 Read one byte from a cursor.
 
static int _TIFFByteCursorFill (TIFFByteCursor *dst, uint8_t value, tmsize_t n)
 Write n copies of value to a cursor.
 
static int _TIFFByteCursorCopy (TIFFByteCursor *dst, TIFFByteCursor *src, tmsize_t n)
 Move n bytes from src to dst.
 
static int DumpFixupTags (TIFF *tif)
 Accept uncompressed tag fixup without changes.
 
static int DumpModeEncode (TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
 Copy uncompressed bytes into the raw output buffer.
 
static int DumpModeDecode (TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s)
 Copy uncompressed raw input into decoded output.
 
static int DumpModeSeek (TIFF *tif, uint32_t nrows)
 Advance uncompressed raw input by complete scanlines.
 
static int NeXTDecode (TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s)
 Expand NeXT literal rows spans and grayscale runs.
 
static int NeXTPreDecode (TIFF *tif, uint16_t s)
 Validate two-bit single-plane NeXT decoding.
 
static int PackBitsPreEncode (TIFF *tif, uint16_t s)
 Allocate and cache the PackBits row byte extent.
 
static int PackBitsPostEncode (TIFF *tif)
 Release the PackBits cached row-size allocation.
 
static int PackBitsEncode (TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s)
 Encode one byte run region using PackBits packets.
 
static int PackBitsEncodeChunk (TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
 Split PackBits input into row-bounded encoding requests.
 
static int PackBitsDecode (TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s)
 Expand PackBits packets into a bounded byte destination.
 
static uint64_t PackBitsGetMaxCompressionRatio (TIFF *tif)
 Report the PackBits expansion heuristic.
 
static int ThunderSetupDecode (TIFF *tif)
 Validate four-bit single-plane ThunderScan decoding.
 
static int ThunderDecode (TIFF *tif, uint8_t *op0, tmsize_t maxpixels)
 Expand one ThunderScan row into packed four-bit samples.
 
static int ThunderDecodeRow (TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s)
 Decode complete ThunderScan scanlines into caller storage.
 
int TIFFInitDumpMode (TIFF *tif, int scheme)
 Install uncompressed transfer callbacks.
 
int TIFFInitPackBits (TIFF *tif, int scheme)
 Install PackBits transfer callbacks.
 
int TIFFInitThunderScan (TIFF *tif, int scheme)
 Install ThunderScan transfer callbacks.
 
int TIFFInitNeXT (TIFF *tif, int scheme)
 Install NeXT transfer callbacks.
 

Variables

static const int twobitdeltas [4] = {0, 1, 0, -1}
 Map two-bit delta codes to signed pixel increments.
 
static const int threebitdeltas [8] = {0, 1, 2, 3, 0, -3, -2, -1}
 Map three-bit delta codes to signed pixel increments.
 

Detailed Description

Implement uncompressed PackBits ThunderScan and NeXT transfers.

Macro Definition Documentation

◆ DELTA2_SKIP

#define DELTA2_SKIP   2 /* skip code for 2-bit deltas */

2-bit delta value meaning "no pixel" in a THUNDER_2BITDELTAS byte.

Definition at line 77 of file tif_thunder.c.

◆ DELTA3_SKIP

#define DELTA3_SKIP   4 /* skip code for 3-bit deltas */

3-bit delta value meaning "no pixel" in a THUNDER_3BITDELTAS byte.

Definition at line 89 of file tif_thunder.c.

◆ LITERALROW

#define LITERALROW   0x00

NeXT row opcode: the scanline follows as td_scanlinesize literal bytes.

Definition at line 81 of file tif_next.c.

◆ LITERALSPAN

#define LITERALSPAN   0x40

NeXT row opcode: a 16-bit big-endian offset and length precede a literal byte span within the white scanline.

Any other leading byte starts a sequence of grey runs.

Definition at line 89 of file tif_next.c.

◆ SETPIXEL [1/2]

#define SETPIXEL (   op,
  v 
)
Value:
{ \
switch (npixels++ & 3) \
{ \
case 0: \
op[0] = (unsigned char)((v) << 6); \
break; \
case 1: \
op[0] |= (unsigned char)((v) << 4); \
break; \
case 2: \
op[0] |= (unsigned char)((v) << 2); \
break; \
case 3: \
*op++ |= (unsigned char)(v); \
op_offset++; \
break; \
default: \
break; \
} \
}

Store a 2-bit pixel into the packed output byte at op.

Store a 4-bit pixel into the packed output if maxpixels has not been reached.

Statement macro used by the run branch of NeXTDecode(). Increments the caller local npixels and, by its previous value mod 4, places v in bits 7-6 (assigning op[0], which clears the rest), 5-4, 3-2 or 1-0 (ORing into op[0]). After the fourth pixel it advances op and increments the caller local op_offset. Performs no bounds check: the caller loop stops when npixels reaches the image width or op_offset reaches the scanline size. v is evaluated once and must fit in 2 bits. The break statements belong to the macro's internal switch; no hidden control flow.

Parameters
[in,out]opOutput byte-pointer lvalue, advanced every fourth pixel.
[in]vPixel value 0-3.

Statement macro used by ThunderDecode(). Always sets the caller local lastpixel to (v) & 0xf, so later deltas are relative to it. If npixels < maxpixels it increments npixels and writes the nibble: an even pixel index stores it in the high nibble of op[0] (clearing the low nibble), an odd index ORs it into the low nibble and advances op. Pixels beyond maxpixels are dropped silently; ThunderDecode() reports the count mismatch afterwards. v is evaluated once; op is read and may be incremented once. No hidden control flow.

Parameters
[in,out]opOutput byte-pointer lvalue, advanced after each odd pixel.
[in]vPixel value; only the low 4 bits are used.

Definition at line 54 of file tif_next.c.

◆ SETPIXEL [2/2]

#define SETPIXEL (   op,
  v 
)
Value:
{ \
lastpixel = (v) & 0xf; \
if (npixels < maxpixels) \
{ \
if (npixels++ & 1) \
*op++ |= (uint8_t)lastpixel; \
else \
op[0] = (uint8_t)(lastpixel << 4); \
} \
}

Store a 4-bit pixel into the packed output if maxpixels has not been reached.

Statement macro used by ThunderDecode(). Always sets the caller local lastpixel to (v) & 0xf, so later deltas are relative to it. If npixels < maxpixels it increments npixels and writes the nibble: an even pixel index stores it in the high nibble of op[0] (clearing the low nibble), an odd index ORs it into the low nibble and advances op. Pixels beyond maxpixels are dropped silently; ThunderDecode() reports the count mismatch afterwards. v is evaluated once; op is read and may be incremented once. No hidden control flow.

Parameters
[in,out]opOutput byte-pointer lvalue, advanced after each odd pixel.
[in]vPixel value; only the low 4 bits are used.

Definition at line 131 of file tif_thunder.c.

◆ THUNDER_2BITDELTAS

#define THUNDER_2BITDELTAS   0x40 /* 3 pixels w/ encoded 2-bit deltas */

ThunderScan code word for three packed 2-bit pixel deltas.

Deltas sit in bits 5-4, 3-2 and 1-0 and index twobitdeltas.

Definition at line 72 of file tif_thunder.c.

◆ THUNDER_3BITDELTAS

#define THUNDER_3BITDELTAS   0x80 /* 2 pixels w/ encoded 3-bit deltas */

ThunderScan code word for two packed 3-bit pixel deltas.

Deltas sit in bits 5-3 and 2-0 and index threebitdeltas.

Definition at line 84 of file tif_thunder.c.

◆ THUNDER_CODE

#define THUNDER_CODE   0xc0 /* mask for 2-bit code word */

Mask selecting the 2-bit code word in the top bits of a ThunderScan byte.

The remaining low 6 bits carry the run count, packed deltas or raw pixel.

Definition at line 57 of file tif_thunder.c.

◆ THUNDER_RAW

#define THUNDER_RAW   0xc0 /* raw data encoded */

ThunderScan code word for a literal 4-bit pixel.

Same value as THUNDER_CODE; the pixel is in the low 4 bits.

Definition at line 96 of file tif_thunder.c.

◆ THUNDER_RUN

#define THUNDER_RUN   0x00 /* run of pixels w/ encoded count */

ThunderScan code word for a run of the previous pixel.

The low 6 bits give the repeat count; a count of zero emits nothing.

Definition at line 65 of file tif_thunder.c.

Function Documentation

◆ _TIFFByteCursorCopy()

static int _TIFFByteCursorCopy ( TIFFByteCursor *  dst,
TIFFByteCursor *  src,
tmsize_t  n 
)
inlinestatic

Move n bytes from src to dst.

On success both cursors advance by n bytes. The two ranges must not overlap.

Parameters
[in,out]dstNon-NULL cursor over writable storage.
[in,out]srcNon-NULL cursor over readable storage.
[in]nNumber of bytes to move.
Returns
1 after moving n bytes, 0 and changes nothing if n is negative or exceeds the bytes left in either cursor.

Definition at line 115 of file tif_bytecursor.h.

References _TIFFmemcpy(), TIFFByteCursor::left, and TIFFByteCursor::p.

Referenced by PackBitsDecode().

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

◆ _TIFFByteCursorFill()

static int _TIFFByteCursorFill ( TIFFByteCursor *  dst,
uint8_t  value,
tmsize_t  n 
)
inlinestatic

Write n copies of value to a cursor.

On success the cursor advances by n bytes.

Parameters
[in,out]dstNon-NULL cursor over writable storage.
[in]valueByte value to write.
[in]nNumber of bytes to write.
Returns
1 after writing n bytes, 0 and writes nothing if n is negative or does not fit.

Definition at line 91 of file tif_bytecursor.h.

References _TIFFmemset(), TIFFByteCursor::left, and TIFFByteCursor::p.

Referenced by PackBitsDecode().

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

◆ _TIFFByteCursorGetU8()

static int _TIFFByteCursorGetU8 ( TIFFByteCursor *  c,
uint8_t *  out 
)
inlinestatic

Read one byte from a cursor.

On success the cursor advances by one byte.

Parameters
[in,out]cNon-NULL cursor to read from.
[out]outNon-NULL destination for the byte read; left untouched if no byte is left.
Returns
1 after reading one byte, 0 (and leaves *out untouched) if none is left.

Definition at line 70 of file tif_bytecursor.h.

References TIFFByteCursor::left, and TIFFByteCursor::p.

Referenced by PackBitsDecode().

Here is the caller graph for this function:

◆ DumpFixupTags()

static int DumpFixupTags ( TIFF *  tif)
static

Accept uncompressed tag fixup without changes.

Ignores tif; no allocation, I/O, diagnostics, ownership or state effects.

Parameters
[in]tifHandle (ignored).
Returns
One unconditionally.

Definition at line 46 of file tif_dumpmode.c.

Referenced by TIFFInitDumpMode().

Here is the caller graph for this function:

◆ DumpModeDecode()

static int DumpModeDecode ( TIFF *  tif,
uint8_t *  buf,
tmsize_t  cc,
uint16_t  s 
)
static

Copy uncompressed raw input into decoded output.

Checks available rawcc before copying, skips exact-pointer self-copy, then advances rawcp and reduces rawcc. Requires nonnegative cc and sufficient destination; nonidentical overlap is unsupported. Diagnoses insufficient data without copying, zeroing the cc destination bytes instead. No allocation, file I/O or ownership transfer.

Parameters
[in,out]tifNon-NULL live handle whose raw cursor and count are consumed; serialise access.
[out]bufBorrowed writable decoded output covering the requested byte extent.
[in]ccNonnegative number of bytes to copy out of the raw buffer.
[in]sSample plane (ignored).
Returns
One after complete copy, zero for insufficient raw bytes.

Definition at line 124 of file tif_dumpmode.c.

References _TIFFmemcpy(), TIFFDirectory::td_row, tiff::tif_dir, tiff::tif_rawcc, tiff::tif_rawcp, TIFF_SSIZE_FORMAT, and TIFFErrorExtR().

Referenced by TIFFInitDumpMode().

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

◆ DumpModeEncode()

static int DumpModeEncode ( TIFF *  tif,
uint8_t *  pp,
tmsize_t  cc,
uint16_t  s 
)
static

Copy uncompressed bytes into the raw output buffer.

Requires positive usable raw capacity and coherent cursor/counts. Copies input unless it already equals rawcp, advances cursors and flushes when full. Flush can write/seek and diagnose; partial file/cache changes survive failure. Nonidentical overlapping regions are not supported. No input ownership transfer.

Parameters
[in,out]tifNon-NULL live handle with an allocated raw buffer; the raw cursor and count advance and TIFFFlushData1() can be called; serialise access.
[in]ppBorrowed readable input of cc bytes.
[in]ccNonnegative number of input bytes to buffer.
[in]sSample plane (ignored).
Returns
One after all requested bytes buffered, zero on flush failure.

Definition at line 73 of file tif_dumpmode.c.

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

Referenced by TIFFInitDumpMode().

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

◆ DumpModeSeek()

static int DumpModeSeek ( TIFF *  tif,
uint32_t  nrows 
)
static

Advance uncompressed raw input by complete scanlines.

Uses cached nonnegative scanline byte size, checks multiplication and available rawcc, then advances rawcp and reduces rawcc. Diagnoses rejection; no client seek, allocation or ownership transfer.

Parameters
[in,out]tifNon-NULL live handle whose cached scanline size is read and raw cursor and count are advanced; serialise access.
[in]nrowsNonnegative number of complete cached scanlines to skip.
Returns
One after cursor adjustment, zero on overflow or insufficient data.

Definition at line 167 of file tif_dumpmode.c.

References TIFFDirectory::td_scanlinesize, tiff::tif_dir, tiff::tif_rawcc, tiff::tif_rawcp, TIFF_TMSIZE_T_MAX, and TIFFErrorExtR().

Referenced by TIFFInitDumpMode().

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

◆ NeXTDecode()

static int NeXTDecode ( TIFF *  tif,
uint8_t *  buf,
tmsize_t  occ,
uint16_t  s 
)
static

Expand NeXT literal rows spans and grayscale runs.

Initialises the whole requested output to white, then checks complete scanline divisibility and decodes available cached input. Requires positive cached row size, nonnegative output extent, matching width and disjoint storage. Malformed spans/runs diagnose and return zero without generally committing local raw cursor progress; output can already be changed. Input exhaustion between rows can end the loop with a successful status and white remaining rows. Normal completion commits raw cursor/counts. No allocation/client I/O or ownership transfer.

Parameters
[in,out]tifNon-NULL live handle with validated two-bit geometry whose raw cursor and count are updated on success; serialise access.
[out]bufBorrowed writable decoded output covering the requested byte extent.
[in]occNonnegative decoded output byte extent.
[in]sSample plane (ignored).
Returns
One on normal loop exit, including between-row input exhaustion; zero on detected fractional/malformed/truncated row.

Definition at line 113 of file tif_next.c.

References _TIFFmemcpy(), isTiled, LITERALROW, LITERALSPAN, SETPIXEL, TIFFDirectory::td_imagewidth, TIFFDirectory::td_row, TIFFDirectory::td_scanlinesize, TIFFDirectory::td_tilewidth, tiff::tif_dir, tiff::tif_rawcc, tiff::tif_rawcp, and TIFFErrorExtR().

Referenced by TIFFInitNeXT().

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

◆ NeXTPreDecode()

static int NeXTPreDecode ( TIFF *  tif,
uint16_t  s 
)
static

Validate two-bit single-plane NeXT decoding.

Requires BitsPerSample two and either one sample or separate planes. Diagnoses unsupported settings; no allocation, I/O, buffer changes or ownership transfer.

Parameters
[in]tifNon-NULL live handle whose BitsPerSample, SamplesPerPixel and PlanarConfiguration are checked; serialise access.
[in]sSample plane (ignored).
Returns
One for accepted layout, zero otherwise.

Definition at line 239 of file tif_next.c.

References PLANARCONFIG_SEPARATE, tiff::tif_dir, and TIFFErrorExtR().

Referenced by TIFFInitNeXT().

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

◆ PackBitsDecode()

static int PackBitsDecode ( TIFF *  tif,
uint8_t *  op,
tmsize_t  occ,
uint16_t  s 
)
static

Expand PackBits packets into a bounded byte destination.

Consumes raw cached bytes, ignores -128 no-op packets and clips overlong output runs with warnings. Short input warns, clears the unfilled output tail, diagnoses and returns zero. Raw cursor/counts are updated even on incomplete output. No allocation/client I/O or ownership transfer; requires nonnegative output length and disjoint storage.

Parameters
[in,out]tifNon-NULL live handle whose raw cursor and count are consumed and updated; serialise access.
[out]opBorrowed writable output of occ bytes.
[in]occNonnegative decoded output byte extent.
[in]sSample plane (ignored).
Returns
One when output extent is filled, zero when input cannot fill it.

Definition at line 370 of file tif_packbits.c.

References _TIFFByteCursorCopy(), _TIFFByteCursorFill(), _TIFFByteCursorGetU8(), TIFFByteCursor::left, TIFFByteCursor::p, TIFFDirectory::td_row, tiff::tif_dir, tiff::tif_rawcc, tiff::tif_rawcp, TIFF_SSIZE_FORMAT, TIFFErrorExtR(), and TIFFWarningExtR().

Referenced by TIFFInitPackBits().

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

◆ PackBitsEncode()

static int PackBitsEncode ( TIFF *  tif,
uint8_t *  buf,
tmsize_t  cc,
uint16_t  s 
)
static

Encode one byte run region using PackBits packets.

Requires nonnegative input length and an allocated raw output buffer. Combines literal and repeated runs, caps packet lengths at 128, and flushes preserving pending literals as needed. If the raw buffer still lacks room for the next packet byte(s) after a flush, as can happen with a small caller-supplied buffer, it records the bytes already encoded in the raw cursor and count, emits an error and fails rather than overrun the buffer. Does not modify caller input. Output/cursors and file bytes can change before a failure; diagnostics follow I/O helpers. No returned ownership.

Parameters
[in,out]tifNon-NULL live handle with an allocated raw buffer; the raw cursor and count advance and TIFFFlushData1() can be called; serialise access.
[in]bufBorrowed readable input covering the requested byte extent.
[in]ccNonnegative number of input bytes to encode.
[in]sSample plane (ignored).
Returns
One after encoding, zero on flush failure or when the raw buffer is too small.

Begin a new packet.

Extend the current literal packet.

Continue after a repeated-byte packet.

Remember a literal followed by a run for possible merging.

Definition at line 122 of file tif_packbits.c.

References tiff::tif_rawcc, tiff::tif_rawcp, tiff::tif_rawdata, tiff::tif_rawdatasize, TIFF_SSIZE_FORMAT, TIFFErrorExtR(), and TIFFFlushData1().

Referenced by PackBitsEncodeChunk(), and TIFFInitPackBits().

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

◆ PackBitsEncodeChunk()

static int PackBitsEncodeChunk ( TIFF *  tif,
uint8_t *  bp,
tmsize_t  cc,
uint16_t  s 
)
static

Split PackBits input into row-bounded encoding requests.

Requires positive cached rowsize and a nonnegative input extent. Breaks at row boundaries, permitting a final partial row. Stops at the first inner encoder failure and releases the preencode state with PackBitsPostEncode(), since the caller then returns without calling tif_postencode. Caller input remains borrowed; raw/file state can change.

Parameters
[in,out]tifNon-NULL live handle whose tif_data holds the cached row size from PackBitsPreEncode(); serialise access.
[in]bpBorrowed readable input of cc bytes.
[in]ccNonnegative number of input bytes, split into row-sized chunks.
[in]sSample plane, forwarded unchanged to PackBitsEncode().
Returns
One after encoding all chunks, zero if PackBitsEncode() fails.

Definition at line 325 of file tif_packbits.c.

References PackBitsEncode(), PackBitsPostEncode(), and tiff::tif_data.

Referenced by TIFFInitPackBits().

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

◆ PackBitsGetMaxCompressionRatio()

static uint64_t PackBitsGetMaxCompressionRatio ( TIFF *  tif)
static

Report the PackBits expansion heuristic.

Returns an empirical ratio without inspecting the handle, allocating, mutating state or doing I/O; not a validity proof or universal bound.

Parameters
[in]tifHandle (ignored).
Returns
Sixty-four.

Definition at line 449 of file tif_packbits.c.

Referenced by TIFFInitPackBits().

Here is the caller graph for this function:

◆ PackBitsPostEncode()

static int PackBitsPostEncode ( TIFF *  tif)
static

Release the PackBits cached row-size allocation.

Frees non-NULL tif_data using Ext allocation and clears the pointer, so a repeated call is harmless. PackBitsEncodeChunk() also calls it when encoding fails, because the caller then skips tif_postencode. No payload flush, I/O or separate diagnostic status.

Parameters
[in,out]tifNon-NULL live handle whose tif_data allocation, if any, is freed and reset to NULL; serialise access.
Returns
One unconditionally.

Definition at line 87 of file tif_packbits.c.

References _TIFFfreeExt(), and tiff::tif_data.

Referenced by PackBitsEncodeChunk(), and TIFFInitPackBits().

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

◆ PackBitsPreEncode()

static int PackBitsPreEncode ( TIFF *  tif,
uint16_t  s 
)
static

Allocate and cache the PackBits row byte extent.

Allocates a handle-owned tmsize_t slot and computes tile-row or scanline size. Requires no previous unreleased tif_data allocation. The calculated size is not checked here; chunk encoding requires it positive. No payload I/O.

Parameters
[in,out]tifNon-NULL live handle with matching validated geometry and codec methods; serialise access.
[in]sSample plane (ignored).
Returns
One after allocation even if row size is zero, zero on allocation failure.

Definition at line 57 of file tif_packbits.c.

References _TIFFmallocExt(), isTiled, tiff::tif_data, TIFFScanlineSize(), and TIFFTileRowSize().

Referenced by TIFFInitPackBits().

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

◆ ThunderDecode()

static int ThunderDecode ( TIFF *  tif,
uint8_t *  op0,
tmsize_t  maxpixels 
)
static

Expand one ThunderScan row into packed four-bit samples.

Consumes raw/delta/run codes, writes high nibble first, and bounds emitted pixels by maxpixels. Updates raw cursor/counts; diagnoses too few/many pixels and clears the remaining packed tail on rejection. Requires nonnegative representable pixel count and ceil(maxpixels/2) destination bytes. No allocation/client I/O or ownership transfer.

Parameters
[in,out]tifNon-NULL live handle whose raw cursor and count are consumed and updated; serialise access.
[out]op0Borrowed writable packed four-bit output for maxpixels pixels.
[in]maxpixelsNonnegative target pixel count with representable rounded packed size.
Returns
One for exact pixel count, zero on mismatch; decoded pixels before the mismatch remain and the rest of the row is zeroed.

Definition at line 198 of file tif_thunder.c.

References DELTA2_SKIP, DELTA3_SKIP, SETPIXEL, TIFFDirectory::td_row, threebitdeltas, THUNDER_2BITDELTAS, THUNDER_3BITDELTAS, THUNDER_CODE, THUNDER_RAW, THUNDER_RUN, tiff::tif_dir, tiff::tif_rawcc, tiff::tif_rawcp, TIFFErrorExtR(), and twobitdeltas.

Referenced by ThunderDecodeRow().

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

◆ ThunderDecodeRow()

static int ThunderDecodeRow ( TIFF *  tif,
uint8_t *  buf,
tmsize_t  occ,
uint16_t  s 
)
static

Decode complete ThunderScan scanlines into caller storage.

Requires positive cached scanline size, nonnegative extent divisible by it, and validated four-bit geometry. Calls ThunderDecode per row. On a failed row clears that entire row and the remaining requested output, leaving earlier rows and raw progress. No allocation/client I/O or ownership transfer.

Parameters
[in,out]tifNon-NULL live handle with validated four-bit geometry whose raw cursor and count are consumed; serialise access.
[out]bufBorrowed writable decoded output covering the requested byte extent.
[in]occNonnegative decoded output byte extent.
[in]sSample plane (ignored).
Returns
One after complete rows, zero on fractional extent or failed row.

Definition at line 305 of file tif_thunder.c.

References TIFFDirectory::td_imagewidth, TIFFDirectory::td_scanlinesize, ThunderDecode(), tiff::tif_dir, and TIFFErrorExtR().

Referenced by TIFFInitThunderScan().

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

◆ ThunderSetupDecode()

static int ThunderSetupDecode ( TIFF *  tif)
static

Validate four-bit single-plane ThunderScan decoding.

Requires BitsPerSample four and either one sample or separate planes. Diagnoses unsupported settings; no allocation, I/O, buffer changes or ownership transfer.

Parameters
[in]tifNon-NULL live handle whose BitsPerSample, SamplesPerPixel and PlanarConfiguration are checked; serialise access.
Returns
One for accepted layout, zero otherwise.

Definition at line 155 of file tif_thunder.c.

References PLANARCONFIG_SEPARATE, TIFFDirectory::td_bitspersample, TIFFDirectory::td_planarconfig, TIFFDirectory::td_samplesperpixel, tiff::tif_dir, and TIFFErrorExtR().

Referenced by TIFFInitThunderScan().

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

◆ TIFFInitDumpMode()

int TIFFInitDumpMode ( TIFF *  tif,
int  scheme 
)
extern

Install uncompressed transfer callbacks.

Requires prior default compression state and cleanup of any previous codec. Assigns supported callbacks without allocating outer state or touching payload. Installs direct-copy encoding/decoding and buffered forward row seek. No ownership transfer; later transfer callbacks have their own state and I/O effects.

Parameters
[in,out]tifNon-NULL live handle whose codec methods are overwritten; geometry is not consulted. Serialise access.
[in]schemeUnused compatibility compression identifier.
Returns
One unconditionally.

Definition at line 192 of file tif_dumpmode.c.

References DumpFixupTags(), DumpModeDecode(), DumpModeEncode(), DumpModeSeek(), tiff::tif_decoderow, tiff::tif_decodestrip, tiff::tif_decodetile, tiff::tif_encoderow, tiff::tif_encodestrip, tiff::tif_encodetile, tiff::tif_fixuptags, and tiff::tif_seek.

Here is the call graph for this function:

◆ TIFFInitNeXT()

int TIFFInitNeXT ( TIFF *  tif,
int  scheme 
)
extern

Install NeXT transfer callbacks.

Requires prior default compression state and cleanup of any previous codec. Assigns supported callbacks without allocating outer state or touching payload. NeXT installs decode-only row/strip/tile methods. No ownership transfer; later transfer callbacks have their own state and I/O effects.

Parameters
[in,out]tifNon-NULL live handle whose codec methods are overwritten; geometry is not consulted. Serialise access.
[in]schemeUnused compatibility compression identifier.
Returns
One unconditionally.

Definition at line 262 of file tif_next.c.

References NeXTDecode(), NeXTPreDecode(), tiff::tif_decoderow, tiff::tif_decodestrip, tiff::tif_decodetile, and tiff::tif_predecode.

Here is the call graph for this function:

◆ TIFFInitPackBits()

int TIFFInitPackBits ( TIFF *  tif,
int  scheme 
)
extern

Install PackBits transfer callbacks.

Requires prior default compression state and cleanup of any previous codec. Assigns supported callbacks without allocating outer state or touching payload. PackBits encoding callbacks are omitted in PACKBITS_READ_ONLY builds. No ownership transfer; later transfer callbacks have their own state and I/O effects.

Parameters
[in,out]tifNon-NULL live handle whose codec methods are overwritten; geometry is not consulted. Serialise access.
[in]schemeUnused compatibility compression identifier.
Returns
One unconditionally.

Definition at line 459 of file tif_packbits.c.

References PackBitsDecode(), PackBitsEncode(), PackBitsEncodeChunk(), PackBitsGetMaxCompressionRatio(), PackBitsPostEncode(), PackBitsPreEncode(), tiff::tif_decoderow, tiff::tif_decodestrip, tiff::tif_decodetile, tiff::tif_encoderow, tiff::tif_encodestrip, tiff::tif_encodetile, tiff::tif_getmaxcompressionratio, tiff::tif_postencode, and tiff::tif_preencode.

Here is the call graph for this function:

◆ TIFFInitThunderScan()

int TIFFInitThunderScan ( TIFF *  tif,
int  scheme 
)
extern

Install ThunderScan transfer callbacks.

Requires prior default compression state and cleanup of any previous codec. Assigns supported callbacks without allocating outer state or touching payload. ThunderScan installs row/strip decoding only; no tile encoder/decoder is installed. No ownership transfer; later transfer callbacks have their own state and I/O effects.

Parameters
[in,out]tifNon-NULL live handle whose codec methods are overwritten; geometry is not consulted. Serialise access.
[in]schemeUnused compatibility compression identifier.
Returns
One unconditionally.

Definition at line 335 of file tif_thunder.c.

References ThunderDecodeRow(), ThunderSetupDecode(), tiff::tif_decoderow, tiff::tif_decodestrip, and tiff::tif_setupdecode.

Here is the call graph for this function:

Variable Documentation

◆ threebitdeltas

const int threebitdeltas[8] = {0, 1, 2, 3, 0, -3, -2, -1}
static

Map three-bit delta codes to signed pixel increments.

Indexed by a 3-bit delta field; index DELTA3_SKIP is never looked up.

Definition at line 111 of file tif_thunder.c.

Referenced by ThunderDecode().

◆ twobitdeltas

const int twobitdeltas[4] = {0, 1, 0, -1}
static

Map two-bit delta codes to signed pixel increments.

Indexed by a 2-bit delta field; index DELTA2_SKIP is never looked up.

Definition at line 104 of file tif_thunder.c.

Referenced by ThunderDecode().