Grok 20.3.2
IDecompressor.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
29{
30public:
35 virtual ~IDecompressor() = default;
41 virtual bool readHeader(grk_header_info* header_info) = 0;
47 virtual GrkImage* getImage(uint16_t tile_index, bool wait) = 0;
52 virtual GrkImage* getImage(void) = 0;
53
58 virtual void wait(grk_wait_swath* swath) = 0;
59
64 virtual void init(grk_decompress_parameters* param) = 0;
65
71 virtual void setBandCallback(grk_io_band_callback callback, void* user_data)
72 {
73 (void)callback;
74 (void)user_data;
75 }
76
83 virtual grk_progression_state getProgressionState(uint16_t tile_index) = 0;
84
92
99 virtual bool decompress(grk_plugin_tile* tile) = 0;
100
107 virtual bool decompressTile(uint16_t tile_index) = 0;
108
115 virtual void dump(uint32_t flag, FILE* outputFileStream) = 0;
116
117 virtual uint32_t getNumSamples(void)
118 {
119 return 1;
120 }
121 virtual bool decompressSample(uint32_t sampleIndex)
122 {
123 (void)sampleIndex;
124 return decompress(nullptr);
125 }
126 virtual GrkImage* getSampleImage(uint32_t sampleIndex)
127 {
128 (void)sampleIndex;
129 return getImage();
130 }
131 virtual GrkImage* getSampleTileImage(uint32_t sampleIndex, uint16_t tileIndex)
132 {
133 (void)sampleIndex;
134 return getImage(tileIndex, true);
135 }
136
145 virtual void scheduleSwathCopy([[maybe_unused]] const grk_wait_swath* swath,
146 [[maybe_unused]] grk_swath_buffer* buf)
147 {}
148
152 virtual void waitSwathCopy() {}
153};
154
155} // namespace grk
Stores header and data for an image.
Definition GrkImage.h:54
bool(* grk_io_band_callback)(uint32_t yBegin, uint32_t yEnd, grk_image *image, void *user_data)
Callback invoked when a horizontal band of the decompressed image is ready for writing.
Definition grok.h:647
ResWindow.
Definition CompressedChunkCache.h:36
Decompress interface.
Definition IDecompressor.h:29
virtual GrkImage * getSampleImage(uint32_t sampleIndex)
Definition IDecompressor.h:126
virtual void dump(uint32_t flag, FILE *outputFileStream)=0
Dumps image tags to file.
virtual grk_progression_state getProgressionState(uint16_t tile_index)=0
Gets the grk_progression_state for a tile.
virtual void scheduleSwathCopy(const grk_wait_swath *swath, grk_swath_buffer *buf)
Schedule Taskflow copy tasks for tiles in a completed swath.
Definition IDecompressor.h:145
virtual uint32_t getNumSamples(void)
Definition IDecompressor.h:117
virtual bool decompressSample(uint32_t sampleIndex)
Definition IDecompressor.h:121
virtual GrkImage * getSampleTileImage(uint32_t sampleIndex, uint16_t tileIndex)
Definition IDecompressor.h:131
virtual bool setProgressionState(grk_progression_state state)=0
Sets the grk_progression_state for a tile.
virtual bool decompress(grk_plugin_tile *tile)=0
Decompresses image / image region.
virtual void wait(grk_wait_swath *swath)=0
Waits for asynchronous decompression to complete.
virtual bool readHeader(grk_header_info *header_info)=0
Reads header.
virtual bool decompressTile(uint16_t tile_index)=0
Decompresses a single tile.
virtual void setBandCallback(grk_io_band_callback callback, void *user_data)
Sets a band-completion callback for incremental writing.
Definition IDecompressor.h:71
virtual void waitSwathCopy()
Wait for all in-flight swath copy tasks to complete.
Definition IDecompressor.h:152
virtual ~IDecompressor()=default
Destroys the IDecompressor object.
virtual GrkImage * getImage(void)=0
Gets composite GrkImage for all tiles in decompress region.
virtual void init(grk_decompress_parameters *param)=0
Initializes decompressor.
virtual GrkImage * getImage(uint16_t tile_index, bool wait)=0
Gets GrkImage for specified tile.
Decompression parameters.
JPEG 2000 header info.
Plugin tile.
Stores progression state information Note: limited to 256 components.
User-managed output buffer for asynchronous swath tile copy-and-convert.
Definition grok.h:974
Specify swath region to wait on during asynchronous decompression.
Definition grok.h:1004