Grok 20.3.2
FileFormatJP2Decompress.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// Constants below are only used in decompress path (not needed by compress)
23const uint32_t JP2_DTBL = 0x6474626c;
24const uint32_t JP2_UINF = 0x75696e66;
25const uint32_t JP2_ULST = 0x756c7374;
26const uint32_t JP2_URL = 0x75726c20;
27const uint32_t JP2_JUMB = 0x6a756d62;
28
29const uint8_t IPTC_UUID[16] = {0x33, 0xC7, 0xA4, 0xD2, 0xB8, 0x1D, 0x47, 0x23,
30 0xA0, 0xBA, 0xF1, 0xA3, 0xE0, 0x97, 0xAD, 0x38};
31const uint8_t XMP_UUID[16] = {0xBE, 0x7A, 0xCF, 0xCB, 0x97, 0xA9, 0x42, 0xE8,
32 0x9C, 0x71, 0x99, 0x94, 0x91, 0xE3, 0xAF, 0xAC};
33// EXIF UUID: ASCII "JpgTiffExif->JP2" (ExifTool convention)
34const uint8_t EXIF_UUID[16] = {0x4A, 0x70, 0x67, 0x54, 0x69, 0x66, 0x66, 0x45,
35 0x78, 0x69, 0x66, 0x2D, 0x3E, 0x4A, 0x50, 0x32};
36// EXIF UUID written by Photoshop/Adobe JPEG2000 plugin
37const uint8_t EXIF_UUID_PS[16] = {0x05, 0x37, 0xCD, 0xAB, 0x9D, 0x0C, 0x44, 0x31,
38 0xA7, 0x2A, 0xFA, 0x56, 0x1F, 0x2A, 0x11, 0x3E};
39// GeoTIFF UUID (GeoJP2): used by GDAL and other GIS tools for georeferencing
40const uint8_t GEOTIFF_UUID[16] = {0xB1, 0x4B, 0xF8, 0xBD, 0x08, 0x3D, 0x4B, 0x43,
41 0xA5, 0xAE, 0x8C, 0xD7, 0xD5, 0xA6, 0xCE, 0x03};
42// MSIG UUID: MapInfo worldfile-style georeferencing (legacy)
43const uint8_t MSIG_UUID[16] = {0x96, 0xA9, 0xF1, 0xF1, 0xDC, 0x98, 0x40, 0x2D,
44 0xA7, 0xAE, 0xD6, 0x8E, 0x34, 0x45, 0x18, 0x09};
45
47{
48public:
49 explicit FileFormatJP2Decompress(IStream* stream);
51
52 bool readHeader(grk_header_info* header_info) override;
53 GrkImage* getImage(uint16_t tile_index, bool wait) override;
54 GrkImage* getImage(void) override;
55 void init(grk_decompress_parameters* param) override;
56 grk_progression_state getProgressionState(uint16_t tile_index) override;
57 bool setProgressionState(grk_progression_state state) override;
58 bool decompress(grk_plugin_tile* tile) override;
59 bool decompressTile(uint16_t tile_index) override;
60 bool end(void);
61 bool postProcess(GrkImage* img);
62 void dump(uint32_t flag, FILE* outputFileStream) override;
63 void wait(grk_wait_swath* swath) override;
64 void scheduleSwathCopy(const grk_wait_swath* swath, grk_swath_buffer* buf) override;
65 void waitSwathCopy() override;
66 void setBandCallback(grk_io_band_callback callback, void* user_data) override;
68
69private:
70 GrkImage* getHeaderImage(void) override;
71
72 bool read_xml(uint8_t* p_xml_data, uint32_t xml_size);
73 bool read_uuid(uint8_t* headerData, uint32_t headerSize);
74 bool read_ipr(uint8_t* headerData, uint32_t headerSize);
75
76protected:
78};
79
80} // namespace grk
Manages decompression.
Definition CodeStreamDecompress.h:36
void wait(grk_wait_swath *swath) override
Waits for asynchronous decompression to complete.
Definition FileFormatJP2Decompress.cpp:206
CodeStreamDecompress * codeStream
Definition FileFormatJP2Decompress.h:77
CodingParams * getCodingParams(void)
Definition FileFormatJP2Decompress.cpp:269
bool read_uuid(uint8_t *headerData, uint32_t headerSize)
Definition FileFormatJP2Decompress.cpp:313
bool readHeader(grk_header_info *header_info) override
Reads header.
Definition FileFormatJP2Decompress.cpp:92
bool setProgressionState(grk_progression_state state) override
Sets the grk_progression_state for a tile.
Definition FileFormatJP2Decompress.cpp:198
~FileFormatJP2Decompress()
Definition FileFormatJP2Decompress.cpp:74
void scheduleSwathCopy(const grk_wait_swath *swath, grk_swath_buffer *buf) override
Schedule Taskflow copy tasks for tiles in a completed swath.
Definition FileFormatJP2Decompress.cpp:210
bool decompressTile(uint16_t tile_index) override
Decompresses a single tile.
Definition FileFormatJP2Decompress.cpp:261
void setBandCallback(grk_io_band_callback callback, void *user_data) override
Sets a band-completion callback for incremental writing.
Definition FileFormatJP2Decompress.cpp:273
bool read_xml(uint8_t *p_xml_data, uint32_t xml_size)
Definition FileFormatJP2Decompress.cpp:278
FileFormatJP2Decompress(IStream *stream)
Definition FileFormatJP2Decompress.cpp:58
bool read_ipr(uint8_t *headerData, uint32_t headerSize)
Definition FileFormatJP2Decompress.cpp:338
void dump(uint32_t flag, FILE *outputFileStream) override
Dumps image tags to file.
Definition FileFormatJP2Decompress.cpp:265
GrkImage * getImage(void) override
Gets composite GrkImage for all tiles in decompress region.
Definition FileFormatJP2Decompress.cpp:87
void waitSwathCopy() override
Wait for all in-flight swath copy tasks to complete.
Definition FileFormatJP2Decompress.cpp:214
GrkImage * getHeaderImage(void) override
Definition FileFormatJP2Decompress.cpp:79
grk_progression_state getProgressionState(uint16_t tile_index) override
Gets the grk_progression_state for a tile.
Definition FileFormatJP2Decompress.cpp:202
void init(grk_decompress_parameters *param) override
Set up decompressor function handler.
Definition FileFormatJP2Decompress.cpp:220
bool postProcess(GrkImage *img)
Definition FileFormatJP2Decompress.cpp:236
bool decompress(grk_plugin_tile *tile) override
Decompresses image / image region.
Definition FileFormatJP2Decompress.cpp:226
FileFormatJP2Family(IStream *stream)
Definition FileFormatJP2Family.cpp:48
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
const uint8_t IPTC_UUID[16]
JUMBF super box (ISO/IEC 19566-5).
Definition FileFormatJP2Decompress.h:29
const uint8_t MSIG_UUID[16]
Definition FileFormatJP2Decompress.h:43
const uint8_t EXIF_UUID_PS[16]
Definition FileFormatJP2Decompress.h:37
const uint8_t GEOTIFF_UUID[16]
Definition FileFormatJP2Decompress.h:40
const uint32_t JP2_UINF
Data Reference box.
Definition FileFormatJP2Decompress.h:24
const uint8_t XMP_UUID[16]
Definition FileFormatJP2Decompress.h:31
const uint32_t JP2_URL
UUID list box.
Definition FileFormatJP2Decompress.h:26
const uint8_t EXIF_UUID[16]
Definition FileFormatJP2Decompress.h:34
const uint32_t JP2_DTBL
Definition FileFormatJP2Decompress.h:23
const uint32_t JP2_ULST
UUID info box (super-box).
Definition FileFormatJP2Decompress.h:25
const uint32_t JP2_JUMB
Data entry URL box.
Definition FileFormatJP2Decompress.h:27
Coding parameters.
Definition CodingParams.h:402
Decompress interface.
Definition IDecompressor.h:29
Definition IStream.h:60
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