TiffChunkPlan class
A plan for decoding a page's TiffImage.decodeRegionRgba8 in a series of horizontal chunks, computed to avoid two failure modes at once:
- Redundant redecoding. TiffImage.decodeRegionRgba8 has no cross-call cache — a strip or tile that's taller than one chunk gets independently redecoded once per chunk it overlaps. For a real whole-slide-image file (512px-tall tiles are common), decoding one thin row at a time can mean the same tile gets redecoded 500+ times over the course of a page.
- Unbounded memory. A page's tile/strip height can be much taller than a caller wants to hold in memory at once — for an extremely wide page, even one full tile row can be hundreds of MB.
forBudget resolves the tension by starting from the page's natural
tile/strip height (so every chunk of the underlying compressed data is
decoded exactly once) and only shrinking below it if the caller's
TiffChunkPlan.forBudget's maxBytesPerChunk forces that — the
remaining redundancy in that fallback case is the acknowledged cost of
keeping memory bounded, not an oversight.
Constructors
- TiffChunkPlan.forBudget(TiffImageMetadata metadata, {required int maxBytesPerChunk, int minChunkHeight = 1})
-
Plans chunks for
metadataso that one chunk's raw decode costs no more thanmaxBytesPerChunk— a budget the caller computes however it likes (a fixed constant, a fraction of a live memory reading, a per-device number, ...); this factory does no I/O and reads no process/OS state of its own.factory
Properties
- bytesPerChunk → int
-
The actual raw decode cost of one chunkHeight-tall chunk — at most
the
maxBytesPerChunkforBudget was given, but never more (and often noticeably less, since chunkHeight is rounded to a whole number of tile/strip rows). Pass this to recommendedWorkerCount rather than re-deriving it — the per-pixel cost model behind it is this package's own internal detail, not meant to be recomputed by a caller.final - chunkHeight → int
-
Height in rows of every chunk except possibly the last, which is
shorter if TiffImageMetadata.height isn't a multiple of it.
final
-
chunks
→ List<
(int, int)> -
(y, height)pairs covering the whole page top to bottom, each ready to hand straight toTiffImage.decodeRegionRgba8(paired withx: 0, width: metadata.width).final - hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
recommendedWorkerCount(
{required int bytesPerChunk, required int aggregateBudgetBytes, required int cpuCount}) → int -
How many chunks of
bytesPerChunkeach (typically a plan's own TiffChunkPlan.bytesPerChunk) can run at once without the aggregate exceedingaggregateBudgetBytes— the number to pass as a parallel decoder's worker count when chunk size was chosen independently of worker count (as forBudget does; see its doc comment for why shrinking chunks to fit more workers is usually the wrong trade-off). Also capped atcpuCount(never spawn more workers than there are cores to run them on) and always at least 1.