Grok 20.3.2
ITileProcessor.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016-2026 Grok Image Compression Inc.
3 *
4 * This source code is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License, version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This source code is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Affero General Public License for more details.
12 *
13 * You should have received a copy of the GNU Affero General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#pragma once
19
20namespace grk
21{
22
24{
25 uint32_t tilePartLength_ = 0;
26 uint8_t tilePart_ = 0;
28};
29
30class Mct;
31
37{
41 virtual ~ITileProcessor() = default;
42
47 virtual void setProcessors(MarkerParser* parser) = 0;
48
53 virtual bool init(void) = 0;
54
60 virtual void setStream(IStream* stream, bool ownsStream) = 0;
61
71 virtual bool decompressWithTLM(const std::shared_ptr<TPFetchSeq>& tilePartFetchSeq,
72 CoderPool* streamPool, Rect32 unreducedImageBounds,
73 std::function<void()> post, TileFutureManager& futures) = 0;
74
80 virtual bool decompressPrepareWithTLM(const std::shared_ptr<TPFetchSeq>& tilePartFetchSeq) = 0;
81
86 virtual bool doPostT1(void) = 0;
87
91 virtual void prepareForDecompression(void) = 0;
92
101 virtual bool parseTilePart(std::vector<std::unique_ptr<MarkerParser>>* parsers,
102 IStream* bifurcatedStream, uint16_t mainMarkerId,
103 TilePartInfo tilePartInfo) = 0;
104
111
121 virtual bool readSOT(IStream* stream, uint8_t* headerData, uint16_t headerSize,
122 TilePartInfo& tilePartInfo, bool needToReadIndexAndLength) = 0;
123
131 virtual void scheduleAndRunDecompress(CoderPool* coderPool, Rect32 unreducedImageBounds,
132 std::function<void()> post, TileFutureManager& futures) = 0;
133
138 virtual void post_decompressT2T1(GrkImage* scratch) = 0;
139
145 virtual bool differentialUpdate(Rect32 unreducedImageBounds) = 0;
146
151 virtual GrkImage* getImage(void) = 0;
152
157 virtual void setImage(GrkImage* img) = 0;
158
164
169 virtual TileCodingParams* getTCP(void) = 0;
170
175 virtual uint8_t getMaxNumDecompressResolutions(void) = 0;
176
181 virtual IStream* getStream(void) = 0;
182
187 virtual uint16_t getIndex(void) const = 0;
188
192 virtual void incrementIndex(void) = 0;
193
198 virtual Tile* getTile(void) = 0;
199
205
210 virtual CodecScheduler* getScheduler(void) = 0;
211
216 virtual bool isCompressor(void) = 0;
217
222 virtual uint64_t getNumProcessedPackets(void) = 0;
223
227 virtual void incNumProcessedPackets(void) = 0;
228
233 virtual void incNumProcessedPackets(uint64_t numPackets) = 0;
234
238 virtual void incNumReadDataPackets(void) = 0;
239
244 virtual uint32_t getTileCacheStrategy(void) = 0;
245
250 virtual grk_plugin_tile* getCurrentPluginTile(void) const = 0;
251
256 virtual void setCurrentPluginTile(grk_plugin_tile* tile) = 0;
257
262 virtual CodingParams* getCodingParams(void) = 0;
263
268 virtual GrkImage* getHeaderImage(void) = 0;
269
274 virtual std::shared_ptr<PacketLengthCache<uint32_t>> getPacketLengthCache(void) = 0;
275
281 virtual bool needsMctDecompress(uint16_t compno) = 0;
282
287 virtual bool needsMctDecompress(void) = 0;
288
295 virtual bool shouldDecodeComponent(uint16_t compno) = 0;
296
301 virtual Mct* getMCT(void) = 0;
302
306 virtual void release(void) = 0;
307
312 virtual void release(uint32_t strategy) = 0;
313
317 virtual void releaseForSwath() = 0;
318
325 virtual bool readPLT(uint8_t* headerData, uint16_t headerSize) = 0;
326
331 virtual bool allSOTMarkersParsed() = 0;
332
341 virtual bool hasUnparsedTileParts() = 0;
342
346 virtual void resetSOTParsing() = 0;
347
351 virtual void setTruncated(void) = 0;
352
357 virtual bool hasError(void) = 0;
358
363 virtual bool isInitialized(void) = 0;
364
369 virtual bool isBestEffortDecompressed(void) = 0;
370 virtual void setBestEffortDecompressed(void) = 0;
371
372 virtual bool scheduledForDecompression(void) = 0;
373
382 virtual bool reinitForReDecompress(void) = 0;
383
387 virtual bool isStripOutputWritten() const = 0;
388};
389
390} // namespace grk
Definition TileFutureManager.h:29
An abstract class that can execute T1 phase of codec by running a tf::Executor.
Definition CodecScheduler.h:72
Stores header and data for an image.
Definition GrkImage.h:54
Definition mct.h:48
ResWindow.
Definition CompressedChunkCache.h:36
Rect< uint32_t > Rect32
Definition geometry.h:64
Definition CoderPool.h:53
Coding parameters.
Definition CodingParams.h:402
Definition IStream.h:60
Interface for managing tile compression/decompression.
Definition ITileProcessor.h:37
virtual bool readPLT(uint8_t *headerData, uint16_t headerSize)=0
Reads a PLT marker (Packet length, tile-part header).
virtual CodecScheduler * getScheduler(void)=0
Gets the codec scheduler.
virtual uint64_t getNumProcessedPackets(void)=0
Gets the number of processed packets.
virtual void prepareForDecompression(void)=0
Prepares the processor for decompression.
virtual ~ITileProcessor()=default
Destroys the TileProcessor.
virtual void releaseForSwath()=0
Unconditionally releases both image and tile data (swath consumer path).
virtual bool decompressFromCachedTileParts()=0
Parse tile-part packets using cached SOT offsets from tilePartSeq_, without re-reading SOT markers.
virtual bool decompressWithTLM(const std::shared_ptr< TPFetchSeq > &tilePartFetchSeq, CoderPool *streamPool, Rect32 unreducedImageBounds, std::function< void()> post, TileFutureManager &futures)=0
Decompresses the tile using Tile Length Markers (TLM).
virtual void scheduleAndRunDecompress(CoderPool *coderPool, Rect32 unreducedImageBounds, std::function< void()> post, TileFutureManager &futures)=0
Schedules T2/T1 decompression tasks.
virtual TileCodingParams * getTCP(void)=0
Gets the Tile Coding Parameters (TCP).
virtual bool needsMctDecompress(void)=0
Checks if MCT decompression is needed overall.
virtual void setImage(GrkImage *img)=0
Sets the associated GrkImage for the tile.
virtual grk_progression_state getProgressionState()=0
Gets the progression state.
virtual void resetSOTParsing()=0
Reset SOT parsing state so the tile can be re-parsed from the codestream.
virtual bool isInitialized(void)=0
Checks if the processor is initialized.
virtual bool doPostT1(void)=0
Performs post-T1 processing.
virtual bool allSOTMarkersParsed()=0
Checks if all SOT markers for the tile are parsed.
virtual GrkImage * getImage(void)=0
Gets the associated GrkImage for the tile.
virtual void incNumProcessedPackets(uint64_t numPackets)=0
Increments the number of processed packets by a specified amount.
virtual Rect32 getUnreducedTileWindow(void)=0
Gets the unreduced tile window.
virtual void release(uint32_t strategy)=0
Releases select resources based on strategy.
virtual IStream * getStream(void)=0
Gets the associated stream.
virtual void post_decompressT2T1(GrkImage *scratch)=0
Performs post-T2+T1 decompression processing.
virtual bool scheduledForDecompression(void)=0
virtual bool isStripOutputWritten() const =0
Check if strip-mode output was written directly (bypass multi-tile band callback).
virtual bool hasUnparsedTileParts()=0
True when we know for certain that tile parts are missing.
virtual bool readSOT(IStream *stream, uint8_t *headerData, uint16_t headerSize, TilePartInfo &tilePartInfo, bool needToReadIndexAndLength)=0
Reads the Start of Tile (SOT) marker.
virtual void setBestEffortDecompressed(void)=0
virtual CodingParams * getCodingParams(void)=0
Gets the coding parameters.
virtual std::shared_ptr< PacketLengthCache< uint32_t > > getPacketLengthCache(void)=0
Gets the packet length cache.
virtual void incNumReadDataPackets(void)=0
Increments the number of read data packets by 1.
virtual void setTruncated(void)=0
Sets the processor to truncated state if not all tile parts are parsed.
virtual void release(void)=0
Releases all resources (image and tile).
virtual grk_plugin_tile * getCurrentPluginTile(void) const =0
Gets the current plugin tile.
virtual bool differentialUpdate(Rect32 unreducedImageBounds)=0
Updates the differential decompression state.
virtual bool needsMctDecompress(uint16_t compno)=0
Checks if MCT decompression is needed for a specific component.
virtual void incrementIndex(void)=0
Increments the tile index.
virtual Tile * getTile(void)=0
Gets the associated Tile.
virtual uint8_t getMaxNumDecompressResolutions(void)=0
Gets the maximum number of decompress resolutions.
virtual void setStream(IStream *stream, bool ownsStream)=0
Sets the stream for input/output operations.
virtual bool reinitForReDecompress(void)=0
Reinitialize for re-decompression after LRU eviction.
virtual GrkImage * getHeaderImage(void)=0
Gets the header image.
virtual bool decompressPrepareWithTLM(const std::shared_ptr< TPFetchSeq > &tilePartFetchSeq)=0
Prepares for decompression using Tile Length Markers (TLM).
virtual uint16_t getIndex(void) const =0
Gets the tile index.
virtual void setProcessors(MarkerParser *parser)=0
Sets the marker parser for processing.
virtual bool isBestEffortDecompressed(void)=0
Check if tile was decompressed on a best-effort basis (may have been truncated or errored).
virtual Mct * getMCT(void)=0
Gets the MCT (Multi-Component Transform) object.
virtual uint32_t getTileCacheStrategy(void)=0
Gets the tile cache strategy.
virtual void incNumProcessedPackets(void)=0
Increments the number of processed packets by 1.
virtual bool isCompressor(void)=0
Checks if the processor is in compressor mode.
virtual void setCurrentPluginTile(grk_plugin_tile *tile)=0
Sets the current plugin tile.
virtual bool shouldDecodeComponent(uint16_t compno)=0
Check if a component should be decoded based on user selection.
virtual bool init(void)=0
Initializes the TileProcessor.
virtual bool hasError(void)=0
Checks if an error has occurred.
virtual bool parseTilePart(std::vector< std::unique_ptr< MarkerParser > > *parsers, IStream *bifurcatedStream, uint16_t mainMarkerId, TilePartInfo tilePartInfo)=0
Parses a tile part.
Definition MarkerParser.h:61
Tile coding parameters : this structure is used to store coding/decoding parameters common to all til...
Definition CodingParams.h:124
Definition Tile.h:39
Definition ITileProcessor.h:24
uint32_t tilePartLength_
Definition ITileProcessor.h:25
uint64_t remainingTilePartBytes_
Definition ITileProcessor.h:27
uint8_t tilePart_
Definition ITileProcessor.h:26
Plugin tile.
Stores progression state information Note: limited to 256 components.