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
45namespace 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 /***************************************************************************/
69 {
70 public:
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:
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 */
120 {
121 public:
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:
162 };
163
164 /***************************************************************************/
170 {
171 public:
172 enum comp_type : ui8 { // Note the numbers are used by the code
177 };
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
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:
247 };
248
249 /*************************************************************************/
300 {
301 public:
302 enum special_comp_num : ui16 { ALL_COMPS = 65535 };
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
308 OJPH_NLT_UNDEFINED = 255 // This is used internally and is
309 // not part of the standard
310 };
311 public:
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:
342 };
343
344 /***************************************************************************/
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;
357 };
358
359}
360
361#endif // !OJPH_PARAMS_H
The object represent a codestream.
local::param_cod * state
param_cod(local::param_cod *p)
non-linearity point transformation object (implements NLT marker segment)
@ OJPH_NLT_BINARY_COMPLEMENT_NLT
param_nlt(local::param_nlt *p)
local::param_nlt * state
Quantization parameters object.
local::param_qcd * state
param_qcd(local::param_qcd *p)
static comp_type ui8_2_comp_type(ui8 c)
local::param_siz * state
Definition ojph_params.h:97
param_siz(local::param_siz *p)
Definition ojph_params.h:71
uint16_t ui16
Definition ojph_defs.h:52
uint32_t ui32
Definition ojph_defs.h:54
uint8_t ui8
Definition ojph_defs.h:50
#define OJPH_EXPORT
Definition ojph_arch.h:144