Grok 10.0.5
FileFormatDecompress.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016-2023 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 * This source code incorporates work covered by the BSD 2-clause license.
18 * Please see the LICENSE file in the root directory for details.
19 *
20 */
21
22#pragma once
23
24namespace grk
25{
26typedef std::function<bool(uint8_t* headerData, uint32_t header_size)> BOX_FUNC;
27
28class FileFormatDecompress : public FileFormat, public ICodeStreamDecompress
29{
30 public:
31 FileFormatDecompress(BufferedStream* stream);
32 virtual ~FileFormatDecompress();
33 bool readHeader(grk_header_info* header_info);
34 GrkImage* getImage(uint16_t tileIndex);
35 GrkImage* getImage(void);
36 void init(grk_decompress_core_params* p_param);
37 bool setDecompressRegion(grk_rect_single region);
38 bool decompress(grk_plugin_tile* tile);
39 bool decompressTile(uint16_t tileIndex);
40 bool end(void);
41 bool postProcess(void);
42 bool preProcess(void);
43 void dump(uint32_t flag, FILE* outputFileStream);
44
45 private:
46 grk_color* getColour(void);
47 uint32_t read_asoc(AsocBox* parent, uint8_t** header_data, uint32_t* header_data_size,
48 uint32_t asocSize);
49 bool readHeaderProcedureImpl(void);
50 bool read_box_hdr(FileFormatBox* box, uint32_t* p_number_bytes_read, BufferedStream* stream);
51 bool read_ihdr(uint8_t* p_image_header_data, uint32_t image_header_size);
52 bool read_xml(uint8_t* p_xml_data, uint32_t xml_size);
53 bool read_uuid(uint8_t* headerData, uint32_t header_size);
54 bool read_res_box(uint32_t* id, uint32_t* num, uint32_t* den, uint32_t* exponent,
55 uint8_t** p_resolution_data);
56 bool read_res(uint8_t* p_resolution_data, uint32_t resolution_size);
57 double calc_res(uint16_t num, uint16_t den, uint8_t exponent);
58 bool read_bpc(uint8_t* p_bpc_header_data, uint32_t bpc_header_size);
59 bool read_channel_definition(uint8_t* p_cdef_header_data, uint32_t cdef_header_size);
60 bool read_colr(uint8_t* p_colr_header_data, uint32_t colr_header_size);
61 bool read_component_mapping(uint8_t* component_mapping_header_data,
62 uint32_t component_mapping_header_size);
63 bool read_palette_clr(uint8_t* p_pclr_header_data, uint32_t pclr_header_size);
64 const BOX_FUNC find_handler(uint32_t id);
65 const BOX_FUNC img_find_handler(uint32_t id);
66 bool read_jp(uint8_t* headerData, uint32_t header_size);
67 bool read_ftyp(uint8_t* headerData, uint32_t header_size);
68 bool read_jp2h(uint8_t* headerData, uint32_t header_size);
69 bool read_box(FileFormatBox* box, uint8_t* p_data, uint32_t* p_number_bytes_read,
70 uint64_t p_box_max_size);
71 bool read_asoc(uint8_t* header_data, uint32_t header_data_size);
72 void serializeAsoc(AsocBox* asoc, grk_asoc* serial_asocs, uint32_t* num_asocs, uint32_t level);
73 std::map<uint32_t, BOX_FUNC> header;
74 std::map<uint32_t, BOX_FUNC> img_header;
75
77 AsocBox root_asoc;
78 CodeStreamDecompress* codeStream;
79 uint32_t jp2_state;
80};
81
82} // namespace grk
BufferedStream * stream
Definition BitIO.h:88
bool headerError_
Definition CodeStreamDecompress.h:324
CodeStreamCompress * codeStream
Definition FileFormatCompress.h:60
AsocBox root_asoc
Definition FileFormatDecompress.h:77
std::map< uint32_t, BOX_FUNC > img_header
Definition FileFormatDecompress.h:74
uint32_t jp2_state
Definition FileFormatDecompress.h:79
std::map< uint32_t, BOX_FUNC > header
Definition FileFormatDecompress.h:73
TagTreeNode * parent
Definition TagTree.h:36
uint8_t * end
pointer to the end of the buffer
Definition mqc.h:58
Copyright (C) 2016-2023 Grok Image Compression Inc.
Definition ICacheable.h:20
grk_rect< float > grk_rect_single
Definition geometry.h:63
std::function< bool(uint8_t *headerData, uint32_t header_size)> BOX_FUNC
Definition FileFormatDecompress.h:26
grk_plugin_tile * tile
Definition plugin_interface.h:64
uint32_t level
Definition plugin_interface.h:44
grk_header_info header_info
Definition plugin_interface.h:111
Association box info.
Definition TileCache.h:333
ICC profile, palette, channel definition.
Definition TileCache.h:320
Core decompression parameters.
Definition TileCache.h:481
Header info.
Definition TileCache.h:362
Plugin tile.
Definition TileCache.h:740