Grok 10.0.5
FileFormat.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#pragma once
22#include <string>
23
24namespace grk
25{
34
35#define JP2_JP 0x6a502020
36#define JP2_FTYP 0x66747970
37#define JP2_JP2H 0x6a703268
38#define JP2_IHDR 0x69686472
39#define JP2_COLR 0x636f6c72
40#define JP2_JP2C 0x6a703263
41#define JP2_PCLR 0x70636c72
42#define JP2_CMAP 0x636d6170
43#define JP2_CDEF 0x63646566
44#define JP2_DTBL 0x6474626c
45#define JP2_BPCC 0x62706363
46#define JP2_JP2 0x6a703220
47#define JP2_RES 0x72657320
48#define JP2_CAPTURE_RES 0x72657363
49#define JP2_DISPLAY_RES 0x72657364
50#define JP2_JP2I 0x6a703269
51#define JP2_XML 0x786d6c20
52#define JP2_UUID 0x75756964
53#define JP2_UINF 0x75696e66
54#define JP2_ULST 0x756c7374
55#define JP2_URL 0x75726c20
56#define JP2_ASOC 0x61736f63
57#define JP2_LBL 0x6c626c20
59#define JP2_MAX_NUM_UUIDS 128
60const uint8_t IPTC_UUID[16] = {0x33, 0xC7, 0xA4, 0xD2, 0xB8, 0x1D, 0x47, 0x23,
61 0xA0, 0xBA, 0xF1, 0xA3, 0xE0, 0x97, 0xAD, 0x38};
62const uint8_t XMP_UUID[16] = {0xBE, 0x7A, 0xCF, 0xCB, 0x97, 0xA9, 0x42, 0xE8,
63 0x9C, 0x71, 0x99, 0x94, 0x91, 0xE3, 0xAF, 0xAC};
64
65#define GRK_BOX_SIZE 1024
66#define GRK_RESOLUTION_BOX_SIZE (4 + 4 + 10)
67
69{
76 JP2_STATE_UNKNOWN = 0x7fffffff /* ISO C restricts enumerator values to range of 'int' */
77};
78
79struct FileFormatBox
80{
81 FileFormatBox() : length(0), type(0) {}
82 uint64_t length;
83 uint32_t type;
84};
85
86struct ComponentInfo
87{
88 ComponentInfo() : bpc(0) {}
89 uint8_t bpc;
90};
91
95struct AsocBox : FileFormatBox, grk_buf8
96{
97 ~AsocBox() override
98 {
99 dealloc();
100 }
101 void dealloc() override
102 {
103 grk_buf8::dealloc();
104 for(auto& as : children)
105 {
106 delete as;
107 }
108 children.clear();
109 }
110 std::string label;
111 std::vector<AsocBox*> children;
112};
113
114struct UUIDBox : public FileFormatBox, grk_buf8
115{
116 UUIDBox()
117 {
118 memset(uuid, 0, sizeof(uuid));
119 }
120 UUIDBox(const uint8_t myuuid[16], uint8_t* buf, size_t size)
121 : FileFormatBox(), grk_buf8(buf, size, false)
122 {
123 memcpy(uuid, myuuid, 16);
124 }
125 uint8_t uuid[16];
126};
127
131class FileFormat
132{
133 public:
134 FileFormat(void);
135 virtual ~FileFormat();
136
137 protected:
138 bool exec(std::vector<PROCEDURE_FUNC>* procs);
140 std::vector<PROCEDURE_FUNC>* validation_list_;
142 std::vector<PROCEDURE_FUNC>* procedure_list_;
143
144 /* width of image */
145 uint32_t w;
146 /* height of image */
147 uint32_t h;
148 /* number of components in the image */
149 uint16_t numcomps;
150 uint8_t bpc;
151 uint8_t C;
152 uint8_t UnkC;
153 uint8_t IPR;
154 uint8_t meth;
155 uint8_t approx;
157 uint8_t precedence;
158 uint32_t brand;
159 uint32_t minversion;
160 uint32_t numcl;
161 uint32_t* cl;
162 ComponentInfo* comps;
163
168
169 grk_buf8 xml;
170
172 uint32_t numUuids;
173};
174
177/* ----------------------------------------------------------------------- */
178
182
183} // namespace grk
uint8_t buf
Definition BitIO.h:84
std::vector< PROCEDURE_FUNC > validation_list_
Definition CodeStream.h:150
std::vector< PROCEDURE_FUNC > procedure_list_
Definition CodeStream.h:149
uint64_t length
Definition FileFormat.h:82
double capture_resolution[2]
Definition FileFormat.h:165
std::string label
Definition FileFormat.h:110
uint32_t * cl
Definition FileFormat.h:161
uint32_t numUuids
Definition FileFormat.h:172
double display_resolution[2]
Definition FileFormat.h:167
uint8_t bpc
Definition FileFormat.h:89
uint8_t approx
Definition FileFormat.h:155
uint8_t UnkC
Definition FileFormat.h:152
uint32_t h
Definition FileFormat.h:147
bool has_display_resolution
Definition FileFormat.h:166
uint8_t uuid[16]
Definition FileFormat.h:125
uint32_t minversion
Definition FileFormat.h:159
GRK_ENUM_COLOUR_SPACE enumcs
Definition FileFormat.h:156
uint8_t C
Definition FileFormat.h:151
std::vector< AsocBox * > children
Definition FileFormat.h:111
bool has_capture_resolution
Definition FileFormat.h:164
uint8_t meth
Definition FileFormat.h:154
uint32_t brand
Definition FileFormat.h:158
grk_buf8 xml
Definition FileFormat.h:169
UUIDBox uuids[JP2_MAX_NUM_UUIDS]
Definition FileFormat.h:171
uint8_t precedence
Definition FileFormat.h:157
ComponentInfo * comps
Definition FileFormat.h:162
uint8_t IPR
Definition FileFormat.h:153
uint32_t w
Definition FileFormat.h:145
uint32_t type
Definition FileFormat.h:83
uint16_t numcomps
Definition FileFormat.h:149
uint32_t numcl
Definition FileFormat.h:160
#define JP2_MAX_NUM_UUIDS
enum _GRK_ENUM_COLOUR_SPACE GRK_ENUM_COLOUR_SPACE
grk_buf< uint8_t, AllocatorVanilla > grk_buf8
Definition TileCache.h:202
Copyright (C) 2016-2023 Grok Image Compression Inc.
Definition ICacheable.h:20
const uint8_t IPTC_UUID[16]
Definition FileFormat.h:60
JP2_STATE
Definition FileFormat.h:69
@ JP2_STATE_UNKNOWN
Definition FileFormat.h:76
@ JP2_STATE_FILE_TYPE
Definition FileFormat.h:72
@ JP2_STATE_SIGNATURE
Definition FileFormat.h:71
@ JP2_STATE_CODESTREAM
Definition FileFormat.h:74
@ JP2_STATE_NONE
Definition FileFormat.h:70
@ JP2_STATE_HEADER
Definition FileFormat.h:73
@ JP2_STATE_END_CODESTREAM
Definition FileFormat.h:75
grk_buf< uint8_t, AllocatorVanilla > grk_buf8
Definition buffer.h:201
const uint8_t XMP_UUID[16]
Definition FileFormat.h:62