OpenJPH Open-source implementation of JPEG2000 Part-15

Loading...
Searching...
No Matches
ojph_params.h
Go to the documentation of this file.
1//***************************************************************************/
2// This software is released under the 2-Clause BSD license, included
3// below.
4//
5// Copyright (c) 2019, Aous Naman
6// Copyright (c) 2019, Kakadu Software Pty Ltd, Australia
7// Copyright (c) 2019, The University of New South Wales, Australia
8//
9// Redistribution and use in source and binary forms, with or without
10// modification, are permitted provided that the following conditions are
11// met:
12//
13// 1. Redistributions of source code must retain the above copyright
14// notice, this list of conditions and the following disclaimer.
15//
16// 2. Redistributions in binary form must reproduce the above copyright
17// notice, this list of conditions and the following disclaimer in the
18// documentation and/or other materials provided with the distribution.
19//
20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
26// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31//***************************************************************************/
32// This file is part of the OpenJPH software implementation.
33// File: ojph_params.h
34// Author: Aous Naman
35// Date: 28 August 2019
36//***************************************************************************/
37
38
39#ifndef OJPH_PARAMS_H
40#define OJPH_PARAMS_H
41
42#include "ojph_arch.h"
43#include "ojph_base.h"
44
45 namespace ojph {
46
47 /***************************************************************************/
48 // defined here
49 class param_siz;
50 class param_cod;
51 class param_qcd;
52 class param_cap;
53 class param_nlt;
54 class codestream;
55
56 /***************************************************************************/
57 // prototyping from local
58 namespace local {
59 struct param_siz;
60 struct param_cod;
61 struct param_qcd;
62 struct param_cap;
63 struct param_nlt;
64 class codestream;
65 }
66
67 /***************************************************************************/
68 class OJPH_EXPORT param_siz
69 {
70 public:
71 param_siz(local::param_siz *p) : state(p) {}
72
73 //setters
74 void set_image_extent(point extent);
75 void set_tile_size(size s);
76 void set_image_offset(point offset);
77 void set_tile_offset(point offset);
78 void set_num_components(ui32 num_comps);
79 void set_component(ui32 comp_num, const point& downsampling,
80 ui32 bit_depth, bool is_signed);
81
82 //getters
83 point get_image_extent() const;
84 point get_image_offset() const;
85 size get_tile_size() const;
86 point get_tile_offset() const;
87 ui32 get_num_components() const;
88 ui32 get_bit_depth(ui32 comp_num) const;
89 bool is_signed(ui32 comp_num) const;
90 point get_downsampling(ui32 comp_num) const;
91
92 //deeper getters
93 ui32 get_recon_width(ui32 comp_num) const;
94 ui32 get_recon_height(ui32 comp_num) const;
95
96 private:
97 local::param_siz* state;
98 };
99
100 /*****************************************************************************
101 * @brief An interface to COD and COC marker segments.
102 *
103 * The param_cod object uses Pimpl design.
104 * The top set of functions give access to the COD marker segment, while
105 * the lower set, the ones that have comp_idx as the first parameter,
106 * gives access to COC marker segment.
107 * The functions:
108 * - set_num_decomposition(ui32 comp_idx, ...)
109 * - set_block_dims(ui32 comp_idx, ...)
110 * - set_precinct_size(ui32 comp_idx, ...)
111 * - set_reversible(ui32 comp_idx, ...)
112 * create a COC segment on first call; subsequent calls to these
113 * functions on the same component index will use the COC segment
114 * created by the first call. On first creation, the COC segment is
115 * initialized to the default COD settings; in particular, 5 levels of
116 * decomposition, 64x64 codeblocks, reversible 5/3 transform and no
117 * precinct size is defined, which gives 32768x32768 precincts.
118 */
119 class OJPH_EXPORT param_cod
120 {
121 public:
122 param_cod(local::param_cod* p) : state(p) {}
123
124 // COD marker segment interface
125 void set_num_decomposition(ui32 num_decompositions);
126 void set_block_dims(ui32 width, ui32 height);
127 void set_precinct_size(int num_levels, size* precinct_size);
128 void set_progression_order(const char *name);
129 void set_color_transform(bool color_transform);
130 void set_reversible(bool reversible);
131
132 ui32 get_num_decompositions() const;
133 size get_block_dims() const;
134 size get_log_block_dims() const;
135 bool is_reversible() const;
136 size get_precinct_size(ui32 level_num) const;
137 size get_log_precinct_size(ui32 level_num) const;
138 int get_progression_order() const;
139 const char* get_progression_order_as_string() const;
140 int get_num_layers() const;
141 bool is_using_color_transform() const;
142 bool packets_may_use_sop() const;
143 bool packets_use_eph() const;
144 bool get_block_vertical_causality() const;
145
146 // COC marker segment interface
147 void set_num_decomposition(ui32 comp_idx, ui32 num_decompositions);
148 void set_block_dims(ui32 comp_idx, ui32 width, ui32 height);
149 void set_precinct_size(ui32 comp_idx, int num_levels, size* precinct_size);
150 void set_reversible(ui32 comp_idx, bool reversible);
151
152 ui32 get_num_decompositions(ui32 comp_idx) const;
153 size get_block_dims(ui32 comp_idx) const;
154 size get_log_block_dims(ui32 comp_idx) const;
155 bool is_reversible(ui32 comp_idx) const;
156 size get_precinct_size(ui32 comp_idx, ui32 level_num) const;
157 size get_log_precinct_size(ui32 comp_idx, ui32 level_num) const;
158 bool get_block_vertical_causality(ui32 comp_idx) const;
159
160 private:
161 local::param_cod* state;
162 };
163
164 /***************************************************************************/
169 class OJPH_EXPORT param_qcd
170 {
171 public:
172 enum comp_type : ui8 { // Note the numbers are used by the code
173 OJPH_COMP_Y = 0,
174 OJPH_COMP_CB = 1,
175 OJPH_COMP_CR = 2,
176 OJPH_COMP_UNDEFINED = 0xFF
177 };
178 static comp_type ui8_2_comp_type(ui8 c)
179 {
180 if (c >= OJPH_COMP_Y && c <= OJPH_COMP_CR)
181 return static_cast<comp_type>(c);
182 else
183 return OJPH_COMP_UNDEFINED;
184 }
185
186 param_qcd(local::param_qcd* p) : state(p) {}
187
196 void set_irrev_quant(float delta);
197
216 void set_qfactor(ui8 qfactor);
217
229 void set_irrev_quant(ui32 comp_idx, float delta);
230
243 void set_qfactor(ui32 comp_idx, comp_type ctype, ui8 qfactor);
244
245 private:
246 local::param_qcd* state;
247 };
248
249 /*************************************************************************/
299 class OJPH_EXPORT param_nlt
300 {
301 public:
302 enum special_comp_num : ui16 { ALL_COMPS = 65535 };
303 enum nonlinearity : ui8 {
304 OJPH_NLT_NO_NLT = 0, // supported
305 OJPH_NLT_GAMMA_STYLE_NLT = 1, // not supported
306 OJPH_NLT_LUT_STYLE_NLT = 2, // not supported
307 OJPH_NLT_BINARY_COMPLEMENT_NLT = 3, // supported
308 OJPH_NLT_UNDEFINED = 255 // This is used internally and is
309 // not part of the standard
310 };
311 public:
312 param_nlt(local::param_nlt* p) : state(p) {}
313
325 void set_nonlinear_transform(ui32 comp_num, ui8 nl_type);
326
337 bool get_nonlinear_transform(ui32 comp_num, ui8& bit_depth,
338 bool& is_signed, ui8& nl_type) const;
339
340 private:
341 local::param_nlt* state;
342 };
343
344 /***************************************************************************/
345 class OJPH_EXPORT comment_exchange
346 {
347 friend class local::codestream;
348 public:
349 comment_exchange() : data(NULL), len(0), Rcom(0) {}
350 void set_string(const char* str);
351 void set_data(const char* data, ui16 len);
352
353 private:
354 const char* data;
355 ui16 len;
356 ui16 Rcom;
357 };
358
359}
360
361#endif // !OJPH_PARAMS_H
ojph::codestream
The object represent a codestream.
Definition ojph_codestream.h:89
ojph::comment_exchange::comment_exchange
comment_exchange()
Definition ojph_params.h:349
ojph::comment_exchange::len
ui16 len
Definition ojph_params.h:355
ojph::comment_exchange::Rcom
ui16 Rcom
Definition ojph_params.h:356
ojph::comment_exchange::data
const char * data
Definition ojph_params.h:354
ojph::local::codestream
Definition ojph_codestream_local.h:65
ojph::param_cod
Definition ojph_params.h:120
ojph::param_cod::state
local::param_cod * state
Definition ojph_params.h:161
ojph::param_cod::param_cod
param_cod(local::param_cod *p)
Definition ojph_params.h:122
ojph::param_nlt
non-linearity point transformation object (implements NLT marker segment)
Definition ojph_params.h:300
ojph::param_nlt::nonlinearity
nonlinearity
Definition ojph_params.h:303
ojph::param_nlt::OJPH_NLT_NO_NLT
@ OJPH_NLT_NO_NLT
Definition ojph_params.h:304
ojph::param_nlt::OJPH_NLT_BINARY_COMPLEMENT_NLT
@ OJPH_NLT_BINARY_COMPLEMENT_NLT
Definition ojph_params.h:307
ojph::param_nlt::OJPH_NLT_UNDEFINED
@ OJPH_NLT_UNDEFINED
Definition ojph_params.h:308
ojph::param_nlt::OJPH_NLT_LUT_STYLE_NLT
@ OJPH_NLT_LUT_STYLE_NLT
Definition ojph_params.h:306
ojph::param_nlt::OJPH_NLT_GAMMA_STYLE_NLT
@ OJPH_NLT_GAMMA_STYLE_NLT
Definition ojph_params.h:305
ojph::param_nlt::special_comp_num
special_comp_num
Definition ojph_params.h:302
ojph::param_nlt::ALL_COMPS
@ ALL_COMPS
Definition ojph_params.h:302
ojph::param_nlt::param_nlt
param_nlt(local::param_nlt *p)
Definition ojph_params.h:312
ojph::param_nlt::state
local::param_nlt * state
Definition ojph_params.h:341
ojph::param_qcd
Quantization parameters object.
Definition ojph_params.h:170
ojph::param_qcd::comp_type
comp_type
Definition ojph_params.h:172
ojph::param_qcd::OJPH_COMP_CB
@ OJPH_COMP_CB
Definition ojph_params.h:174
ojph::param_qcd::OJPH_COMP_UNDEFINED
@ OJPH_COMP_UNDEFINED
Definition ojph_params.h:176
ojph::param_qcd::OJPH_COMP_Y
@ OJPH_COMP_Y
Definition ojph_params.h:173
ojph::param_qcd::OJPH_COMP_CR
@ OJPH_COMP_CR
Definition ojph_params.h:175
ojph::param_qcd::state
local::param_qcd * state
Definition ojph_params.h:246
ojph::param_qcd::param_qcd
param_qcd(local::param_qcd *p)
Definition ojph_params.h:186
ojph::param_qcd::ui8_2_comp_type
static comp_type ui8_2_comp_type(ui8 c)
Definition ojph_params.h:178
ojph::param_siz
Definition ojph_params.h:69
ojph::param_siz::state
local::param_siz * state
Definition ojph_params.h:97
ojph::param_siz::param_siz
param_siz(local::param_siz *p)
Definition ojph_params.h:71
ojph::local
Definition ojph_bitbuffer_read.h:53
ojph
Definition ojph_img_io.h:52
ojph::ui16
uint16_t ui16
Definition ojph_defs.h:52
ojph::ui32
uint32_t ui32
Definition ojph_defs.h:54
ojph::ui8
uint8_t ui8
Definition ojph_defs.h:50
ojph_arch.h
OJPH_EXPORT
#define OJPH_EXPORT
Definition ojph_arch.h:144
ojph_base.h
ojph::local::param_cap
Definition ojph_params_local.h:920
ojph::local::param_cod
Definition ojph_params_local.h:385
ojph::local::param_nlt
Definition ojph_params_local.h:842
ojph::local::param_qcd
Definition ojph_params_local.h:687
ojph::local::param_siz
Definition ojph_params_local.h:166
ojph::point
Definition ojph_base.h:58
ojph::size
Definition ojph_base.h:48