Skip to main content

Module walk

Module walk 

Source
Expand description

Crate-agnostic TIFF structure walk for structural inventories.

Shared by zentiff and zenraw; each supplies its decoder rules. The walk parses a TIFF header, every IFD reachable from the IFD chain and from pointer entries, out-of-line values and the extents (strips, tiles, free space, JPEG streams) the directories reference. A crate supplies Rules saying what its decode path does with each piece; the walk never decodes pixels.

TIFF parts can interleave in any order, so a TIFF’s parts are siblings in file order: header, IFDs (each with one child Field per entry), out-of-line values (Field, same tag as their entry) and extents. Where parts overlap, each byte takes the strongest fate among the parts covering it (Placed); the others are split around it, with a note in both details. Nothing overlapping is ever emitted.

Structs§

Cand
A part before overlap resolution, with its own children.
ChunkGeom
The decoded layout of one strip or tile.
ChunkUse
How much of one strip or tile the decoder reads.
Entry
One IFD entry.
ExtentRule
An offset tag with the lengths of the extents it locates.
Fate
A disposition with an optional remark for the detail.
Ifd
One directory.
Layout
Byte order and offset width.
Placed
Parts that may overlap, resolved into non-overlapping siblings. Every byte goes to the candidate whose fate at that byte (the deepest part of its subtree there, or its body’s gap fate) ranks strongest; on a tie the candidate inserted first keeps it. Each candidate is then cut to the stretches it won.
Placement
A placed TIFF.
Walk
One parsed TIFF.

Enums§

Count
How long the extents of an ExtentRule are.
Kind
Which directory an IFD is, by how the walk reached it.
Loc
Where an entry’s value lives.

Constants§

BUDGET_GAP
Detail for bytes a walk could not account for because a budget or cap stopped it.
EXIF_IFD
FREE_BYTE_COUNTS
FREE_OFFSETS
GPS_IFD
INTEROP_IFD
JPEG_AC_TABLES
JPEG_DC_TABLES
JPEG_IF_LENGTH
JPEG_IF_OFFSET
JPEG_Q_TABLES
STRIP_BYTE_COUNTS
STRIP_OFFSETS
SUB_IFDS
TILE_BYTE_COUNTS
TILE_OFFSETS

Traits§

Rules
What one decode path does with a TIFF’s directories, entries and extents.

Functions§

add_note
Push text onto notes, keeping at most MAX_NOTES and one marker.
chunk_geometry
The decoded layout of chunks strips or tiles of ifd from its tags, as image-tiff computes it (readout_for_size, chunk_data_dimensions); None for subsampled YCbCr or missing dimensions.
default_chunk_use
Rules::chunk_use’s default, after image-tiff’s expand_chunk: it reads whole chunk rows (right-edge padding included, then discarded) for the rows inside the image only. Uncompressed and PackBits chunks are split at that point; for other compression the end of the coded data is not found.
emit
Push c (and its children) under parent.
emit_top
Push top-level parts (non-overlapping, in file order) with gaps between them: before logical_end a gap is gap (a lone odd-offset byte between parts is a word-alignment pad); the caller’s trailing fill covers the rest.
get
kind_name
A short name for a kind of directory.
place
Turn a walk into non-overlapping parts. first are placed right after the header, ahead of the TIFF’s own parts.
push_note
type_name
type_size
Size of one value of a TIFF field type, None for a type TIFF does not define.
union_fate
The fate of a piece of a directory reached by several paths: the strongest of fate(kind, followed) over its roles, the first role on a tie. A decoder that reads the directory by any path reads the piece.
walk
Parse the TIFF whose header is at base, with every position below limit, following pointers the way rules describes.
walk_ifd
Walk the directories starting at the absolute offset at, which has no TIFF header of its own (a maker-note IFD): offsets inside are relative to base, and lay gives the byte order. Every position stays below limit; the first directory is at pointer depth depth.