OpenJPH
Open-source implementation of JPEG2000 Part-15
Toggle main menu visibility
Loading...
Searching...
No Matches
ojph_tile_comp.cpp
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_tile_comp.cpp
34
// Author: Aous Naman
35
// Date: 28 August 2019
36
//***************************************************************************/
37
38
39
#include <climits>
40
#include <cmath>
41
42
#include "
ojph_mem.h
"
43
#include "
ojph_params.h
"
44
#include "
ojph_codestream_local.h
"
45
#include "
ojph_tile_comp.h
"
46
#include "
ojph_resolution.h
"
47
48
namespace
ojph
{
49
50
namespace
local
51
{
52
54
void
tile_comp::pre_alloc
(
codestream
*
codestream
,
ui32
comp_num
,
55
const
rect
&
comp_rect
,
56
const
rect
& recon_comp_rect)
57
{
58
mem_fixed_allocator
* allocator =
codestream
->
get_allocator
();
59
60
//allocate a resolution
61
ui32
num_decomps
;
62
num_decomps
=
codestream
->
get_coc
(
comp_num
)->
get_num_decompositions
();
63
allocator->
pre_alloc_obj
<
resolution
>(1);
64
65
resolution::pre_alloc
(
codestream
,
comp_rect
, recon_comp_rect,
comp_num
,
66
num_decomps
);
67
}
68
70
void
tile_comp::finalize_alloc
(
codestream
*
codestream
,
tile
*parent,
71
ui32
comp_num
,
const
rect
&
comp_rect
,
72
const
rect
& recon_comp_rect)
73
{
74
mem_fixed_allocator
* allocator =
codestream
->
get_allocator
();
75
76
//allocate a resolution
77
num_decomps
=
codestream
->
get_coc
(
comp_num
)->
get_num_decompositions
();
78
79
comp_downsamp
=
codestream
->
get_siz
()->
get_downsampling
(
comp_num
);
80
this->comp_rect =
comp_rect
;
81
this->
parent_tile
= parent;
82
83
this->comp_num =
comp_num
;
84
this->
num_bytes
= 0;
85
res
= allocator->
post_alloc_obj
<
resolution
>(1);
86
res
->
finalize_alloc
(
codestream
,
comp_rect
, recon_comp_rect,
comp_num
,
87
num_decomps
,
comp_downsamp
,
comp_downsamp
,
this
,
88
NULL);
89
}
90
92
line_buf
*
tile_comp::get_line
()
93
{
94
return
res
->
get_line
();
95
}
96
98
void
tile_comp::push_line
()
99
{
100
res
->
push_line
();
101
}
102
104
line_buf
*
tile_comp::pull_line
()
105
{
106
return
res
->
pull_line
();
107
}
108
110
ui32
tile_comp::prepare_precincts
()
111
{
112
this->
num_bytes
=
res
->
prepare_precinct
();
113
return
this->
num_bytes
;
114
}
115
117
void
tile_comp::write_precincts
(
ui32
res_num,
outfile_base
*file)
118
{
119
assert(res_num <=
num_decomps
);
120
res_num =
num_decomps
- res_num;
//how many levels to go down
121
resolution
*r =
res
;
122
while
(res_num > 0 && r != NULL)
123
{
124
r = r->
next_resolution
();
125
--res_num;
126
}
127
if
(r)
//resolution does not exist if r is NULL
128
r->
write_precincts
(file);
129
}
130
132
bool
tile_comp::get_top_left_precinct
(
ui32
res_num,
point
&top_left)
133
{
134
int
resolution_num = (int)
num_decomps
- (
int
)res_num;
135
resolution
*r =
res
;
136
while
(resolution_num > 0 && r != NULL)
137
{
138
r = r->
next_resolution
();
139
--resolution_num;
140
}
141
if
(r)
//resolution does not exist if r is NULL
142
return
r->
get_top_left_precinct
(top_left);
143
else
144
return
false
;
145
}
146
148
void
tile_comp::write_one_precinct
(
ui32
res_num,
outfile_base
*file)
149
{
150
int
resolution_num = (int)
num_decomps
- (
int
)res_num;
151
resolution
*r =
res
;
152
while
(resolution_num > 0 && r != NULL)
153
{
154
r = r->
next_resolution
();
155
--resolution_num;
156
}
157
if
(r)
//resolution does not exist if r is NULL
158
r->
write_one_precinct
(file);
159
}
160
162
void
tile_comp::parse_precincts
(
ui32
res_num,
ui32
& data_left,
163
infile_base
*file)
164
{
165
assert(res_num <=
num_decomps
);
166
res_num =
num_decomps
- res_num;
//how many levels to go down
167
resolution
*r =
res
;
168
while
(res_num > 0 && r != NULL)
169
{
170
r = r->
next_resolution
();
171
--res_num;
172
}
173
if
(r)
//resolution does not exist if r is NULL
174
r->
parse_all_precincts
(data_left, file);
175
}
176
177
179
void
tile_comp::parse_one_precinct
(
ui32
res_num,
ui32
& data_left,
180
infile_base
*file)
181
{
182
assert(res_num <=
num_decomps
);
183
res_num =
num_decomps
- res_num;
184
resolution
*r =
res
;
185
while
(res_num > 0 && r != NULL)
186
{
187
r = r->
next_resolution
();
188
--res_num;
189
}
190
if
(r)
//resolution does not exist if r is NULL
191
r->
parse_one_precinct
(data_left, file);
192
}
193
195
ui32
tile_comp::get_num_bytes
(
ui32
resolution_num)
const
196
{
197
return
res
->
get_num_bytes
(resolution_num);
198
}
199
}
200
}
ojph::infile_base
Definition
ojph_file.h:267
ojph::line_buf
Definition
ojph_mem.h:161
ojph::local::codestream
Definition
ojph_codestream_local.h:65
ojph::local::codestream::get_coc
const param_cod * get_coc(ui32 comp_num)
Definition
ojph_codestream_local.h:85
ojph::local::codestream::get_siz
const param_siz * get_siz()
Definition
ojph_codestream_local.h:79
ojph::local::codestream::get_allocator
mem_fixed_allocator * get_allocator()
Definition
ojph_codestream_local.h:93
ojph::local::resolution
Definition
ojph_resolution.h:62
ojph::local::resolution::get_top_left_precinct
bool get_top_left_precinct(point &top_left)
Definition
ojph_resolution.cpp:975
ojph::local::resolution::parse_one_precinct
void parse_one_precinct(ui32 &data_left, infile_base *file)
Definition
ojph_resolution.cpp:1020
ojph::local::resolution::push_line
void push_line()
Definition
ojph_resolution.cpp:547
ojph::local::resolution::get_num_bytes
ui32 get_num_bytes() const
Definition
ojph_resolution.h:95
ojph::local::resolution::prepare_precinct
ui32 prepare_precinct()
Definition
ojph_resolution.cpp:952
ojph::local::resolution::write_precincts
void write_precincts(outfile_base *file)
Definition
ojph_resolution.cpp:967
ojph::local::resolution::pull_line
line_buf * pull_line()
Definition
ojph_resolution.cpp:713
ojph::local::resolution::get_line
line_buf * get_line()
Definition
ojph_resolution.cpp:530
ojph::local::resolution::pre_alloc
static void pre_alloc(codestream *codestream, const rect &res_rect, const rect &recon_res_rect, ui32 comp_num, ui32 res_num)
Definition
ojph_resolution.cpp:59
ojph::local::resolution::finalize_alloc
void finalize_alloc(codestream *codestream, const rect &res_rect, const rect &recon_res_rect, ui32 comp_num, ui32 res_num, point comp_downsamp, point res_downsamp, tile_comp *parent_tile_comp, resolution *parent_res)
Definition
ojph_resolution.cpp:240
ojph::local::resolution::next_resolution
resolution * next_resolution()
Definition
ojph_resolution.h:91
ojph::local::resolution::parse_all_precincts
void parse_all_precincts(ui32 &data_left, infile_base *file)
Definition
ojph_resolution.cpp:1001
ojph::local::resolution::write_one_precinct
void write_one_precinct(outfile_base *file)
Definition
ojph_resolution.cpp:987
ojph::local::tile_comp::get_line
line_buf * get_line()
Definition
ojph_tile_comp.cpp:92
ojph::local::tile_comp::num_decomps
ui32 num_decomps
Definition
ojph_tile_comp.h:95
ojph::local::tile_comp::parent_tile
tile * parent_tile
Definition
ojph_tile_comp.h:91
ojph::local::tile_comp::get_top_left_precinct
bool get_top_left_precinct(ui32 res_num, point &top_left)
Definition
ojph_tile_comp.cpp:132
ojph::local::tile_comp::num_bytes
ui32 num_bytes
Definition
ojph_tile_comp.h:97
ojph::local::tile_comp::write_one_precinct
void write_one_precinct(ui32 res_num, outfile_base *file)
Definition
ojph_tile_comp.cpp:148
ojph::local::tile_comp::pull_line
line_buf * pull_line()
Definition
ojph_tile_comp.cpp:104
ojph::local::tile_comp::pre_alloc
static void pre_alloc(codestream *codestream, ui32 comp_num, const rect &comp_rect, const rect &recon_comp_rect)
Definition
ojph_tile_comp.cpp:54
ojph::local::tile_comp::comp_rect
rect comp_rect
Definition
ojph_tile_comp.h:93
ojph::local::tile_comp::comp_num
ui32 comp_num
Definition
ojph_tile_comp.h:96
ojph::local::tile_comp::res
resolution * res
Definition
ojph_tile_comp.h:92
ojph::local::tile_comp::finalize_alloc
void finalize_alloc(codestream *codestream, tile *parent, ui32 comp_num, const rect &comp_rect, const rect &recon_comp_rect)
Definition
ojph_tile_comp.cpp:70
ojph::local::tile_comp::parse_one_precinct
void parse_one_precinct(ui32 res_num, ui32 &data_left, infile_base *file)
Definition
ojph_tile_comp.cpp:179
ojph::local::tile_comp::push_line
void push_line()
Definition
ojph_tile_comp.cpp:98
ojph::local::tile_comp::comp_downsamp
ojph::point comp_downsamp
Definition
ojph_tile_comp.h:94
ojph::local::tile_comp::prepare_precincts
ui32 prepare_precincts()
Definition
ojph_tile_comp.cpp:110
ojph::local::tile_comp::write_precincts
void write_precincts(ui32 res_num, outfile_base *file)
Definition
ojph_tile_comp.cpp:117
ojph::local::tile_comp::get_num_bytes
ui32 get_num_bytes() const
Definition
ojph_tile_comp.h:87
ojph::local::tile_comp::parse_precincts
void parse_precincts(ui32 res_num, ui32 &data_left, infile_base *file)
Definition
ojph_tile_comp.cpp:162
ojph::local::tile
Definition
ojph_tile.h:61
ojph::mem_fixed_allocator
Definition
ojph_mem.h:59
ojph::mem_fixed_allocator::pre_alloc_obj
void pre_alloc_obj(size_t num_ele)
Definition
ojph_mem.h:78
ojph::mem_fixed_allocator::post_alloc_obj
T * post_alloc_obj(size_t num_ele)
Definition
ojph_mem.h:119
ojph::outfile_base
Definition
ojph_file.h:75
ojph::local
Definition
ojph_bitbuffer_read.h:53
ojph
Definition
ojph_img_io.h:52
ojph::ui32
uint32_t ui32
Definition
ojph_defs.h:54
ojph_codestream_local.h
ojph_mem.h
ojph_params.h
ojph_resolution.h
ojph_tile_comp.h
ojph::local::param_cod::get_num_decompositions
ui8 get_num_decompositions() const
Definition
ojph_params_local.h:504
ojph::local::param_siz::get_downsampling
point get_downsampling(ui32 comp_num) const
Definition
ojph_params_local.h:262
ojph::point
Definition
ojph_base.h:58
ojph::rect
Definition
ojph_base.h:65
src
core
codestream
ojph_tile_comp.cpp
Generated by
1.18.0