OpenJPH
Open-source implementation of JPEG2000 Part-15
Toggle main menu visibility
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(
float
qfactor);
217
229
void
set_irrev_quant(
ui32
comp_idx,
float
delta);
230
243
void
set_qfactor(
ui32
comp_idx, comp_type ctype,
float
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,
// supported
307
OJPH_NLT_BINARY_COMPLEMENT_NLT
= 3,
// supported
308
OJPH_NLT_BINARY_COMPLEMENT_PLUS_LUT
= 4,
// experimental
309
OJPH_NLT_UNDEFINED
= 255
// This is used internally and
310
// is not part of the standard
311
};
312
public
:
313
param_nlt
(
local::param_nlt
* p) :
state
(p) {}
314
315
/*************************************************************************
316
* @brief Sets nonlinearity to OJPH_NLT_NO_NLT = 0 or
317
* OJPH_NLT_BINARY_COMPLEMENT_NLT = 3, which is sometimes called SMAG or
318
* UMAG.
319
* When creating a codestream for writing, call this function before
320
* you call codestream::write_headers.
321
*
322
* The standard requires "If the binary complement to sign-magnitude
323
* conversion transformation is used, the bit-depth of the input samples
324
* to this transformation shall be equal to the bit-depth of the samples
325
* generated by the transformation, and the signed-ness of the input
326
* samples shall be equal to the signed-ness of the output samples."
327
*
328
* @param comp_num: component number, or ALL_COMPS for all components
329
* @param nlt_type: desired non-linearity from enum nonlinearity, only
330
* OJPH_NLT_NO_NLT and OJPH_NLT_BINARY_COMPLEMENT_NLT are allowed
331
*/
332
void
set_nonlinear_transform(
ui32
comp_num,
ui8
nl_type);
333
334
/*************************************************************************
335
* @brief Sets nonlinearity to OJPH_NLT_LUT_STYLE_NLT = 2 or
336
* OJPH_NLT_BINARY_COMPLEMENT_PLUS_LUT = 4 nonlinearity. Note that as of
337
* this writing OJPH_NLT_BINARY_COMPLEMENT_PLUS_LUT is not part of the
338
* standard.
339
* When creating a codestream for writing, call this function before
340
* you call codestream::write_headers.
341
* Note that a component, as defined by the codestream headers, has
342
* bitdepth/signedness specified in SIZ marker segment; this is also
343
* the internal format used in encoding/decoding the samples.
344
* The nonlinearity stage allows you to define a different format for
345
* data exchange (for feeding-in and extracting samples) with the library;
346
* this different format is communicated using decoded_bit_depth and
347
* decoded_signedness. Said differently, the nonlinearity can take-in
348
* samples in one format (NLT format) and store them in a different format
349
* (SIZ format).
350
*
351
* The information needed for this call is defined in A.3.10 Non-linearity
352
* point transformation (NLT) of the JPEG2000 Standard Part 2
353
*
354
* @param comp_num: component number, or ALL_COMPS for all components
355
* @param decoded_bit_depth: the number of bits for the fed-in or
356
* extracted samples
357
* @param decoded_signedness: the signedness of the fed-in or extracted
358
* samples
359
* @param d_min: Dmin parameters as defined in the standard
360
* @param d_max: Dmax parameters as defined in the standard
361
* @param pt_val: PTval parameters as defined in the standard
362
* @param num_points: the number of points in the next `points` array
363
* @param points: An array that has `num_points` entries; the size of
364
* each entry depends on pt_val; 1 byte for pt_val \in [1,8],
365
* 2 bytes for pt_val \in [9,16], and 4 bytes for pt_val \in
366
* [17,32].
367
* @param nlt_type: desired non-linearity from enum nonlinearity, only
368
* OJPH_NLT_LUT_STYLE_NLT and OJPH_NLT_BINARY_COMPLEMENT_PLUS_LUT
369
* are allowed
370
*/
371
void
set_nonlinear_transform(
ui32
comp_num,
372
ui8
decoded_bit_depth,
bool
decoded_signedness,
373
ui32
d_min,
ui32
d_max,
ui8
pt_val,
374
ui16
num_points,
void
* points,
ui8
nl_type);
375
376
/*************************************************************************
377
* @brief get the nonlinearity type associated with comp_num, which
378
* should be one from enum nonlinearity
379
*
380
* @param comp_num: component number, or ALL_COMPS for all components
381
* @param decoded_bit_depth: returns the bit depth of the decoded samples
382
* for component samples
383
* @param decoded_signedness: returns signedness of decoded samples for
384
* the component samples
385
* @param type: nonlinearity type
386
* @return true if the nonlinearity for comp_num is set
387
*/
388
bool
get_nonlinear_transform(
ui32
comp_num,
ui8
& decoded_bit_depth,
389
bool
& decoded_signedness,
ui8
& nl_type)
const
;
390
391
private
:
392
local::param_nlt
*
state
;
393
};
394
395
/***************************************************************************/
396
class
OJPH_EXPORT
comment_exchange
397
{
398
friend
class
local::codestream
;
399
public
:
400
comment_exchange
() :
data
(NULL),
len
(0),
Rcom
(0) {}
401
void
set_string(
const
char
* str);
402
void
set_data(
const
char
* data,
ui16
len);
403
404
private
:
405
const
char
*
data
;
406
ui16
len
;
407
ui16
Rcom
;
408
};
409
410
}
411
412
#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:400
ojph::comment_exchange::len
ui16 len
Definition
ojph_params.h:406
ojph::comment_exchange::Rcom
ui16 Rcom
Definition
ojph_params.h:407
ojph::comment_exchange::data
const char * data
Definition
ojph_params.h:405
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:309
ojph::param_nlt::OJPH_NLT_BINARY_COMPLEMENT_PLUS_LUT
@ OJPH_NLT_BINARY_COMPLEMENT_PLUS_LUT
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:313
ojph::param_nlt::state
local::param_nlt * state
Definition
ojph_params.h:392
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:1016
ojph::local::param_cod
Definition
ojph_params_local.h:385
ojph::local::param_nlt
Definition
ojph_params_local.h:910
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
src
core
openjph
ojph_params.h
Generated by
1.18.0