Skip to content

Commit e60473c

Browse files
committed
Bug fixes. Improvements.
1 parent bf48100 commit e60473c

File tree

8 files changed

+145
-137
lines changed

8 files changed

+145
-137
lines changed

src/core/codestream/ojph_resolution.cpp

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -207,20 +207,31 @@ namespace ojph {
207207

208208
const param_qcd* qp = codestream->access_qcd()->get_qcc(comp_num);
209209
ui32 precision = qp->propose_precision(cdp);
210+
const param_atk* atk = cdp->access_atk();
211+
bool reversible = atk->is_reversible();
210212

211213
ui32 width = res_rect.siz.w + 1;
212-
if (precision <= 32) {
213-
for (ui32 i = 0; i < num_steps; ++i)
214+
if (reversible)
215+
{
216+
if (precision <= 32) {
217+
for (ui32 i = 0; i < num_steps; ++i)
218+
allocator->pre_alloc_data<si32>(width, 1);
214219
allocator->pre_alloc_data<si32>(width, 1);
215-
allocator->pre_alloc_data<si32>(width, 1);
216-
allocator->pre_alloc_data<si32>(width, 1);
220+
allocator->pre_alloc_data<si32>(width, 1);
221+
}
222+
else
223+
{
224+
for (ui32 i = 0; i < num_steps; ++i)
225+
allocator->pre_alloc_data<si64>(width, 1);
226+
allocator->pre_alloc_data<si64>(width, 1);
227+
allocator->pre_alloc_data<si64>(width, 1);
228+
}
217229
}
218-
else
219-
{
230+
else {
220231
for (ui32 i = 0; i < num_steps; ++i)
221-
allocator->pre_alloc_data<si64>(width, 1);
222-
allocator->pre_alloc_data<si64>(width, 1);
223-
allocator->pre_alloc_data<si64>(width, 1);
232+
allocator->pre_alloc_data<float>(width, 1);
233+
allocator->pre_alloc_data<float>(width, 1);
234+
allocator->pre_alloc_data<float>(width, 1);
224235
}
225236
}
226237
}
@@ -474,21 +485,38 @@ namespace ojph {
474485

475486
// initiate storage of line_buf
476487
ui32 width = res_rect.siz.w + 1;
477-
if (precision <= 32)
488+
if (this->reversible)
478489
{
479-
for (ui32 i = 0; i < num_steps; ++i)
480-
ssp[i].line->wrap(
490+
if (precision <= 32)
491+
{
492+
for (ui32 i = 0; i < num_steps; ++i)
493+
ssp[i].line->wrap(
494+
allocator->post_alloc_data<si32>(width, 1), width, 1);
495+
sig->line->wrap(
481496
allocator->post_alloc_data<si32>(width, 1), width, 1);
482-
sig->line->wrap(allocator->post_alloc_data<si32>(width, 1), width, 1);
483-
aug->line->wrap(allocator->post_alloc_data<si32>(width, 1), width, 1);
497+
aug->line->wrap(
498+
allocator->post_alloc_data<si32>(width, 1), width, 1);
499+
}
500+
else
501+
{
502+
for (ui32 i = 0; i < num_steps; ++i)
503+
ssp[i].line->wrap(
504+
allocator->post_alloc_data<si64>(width, 1), width, 1);
505+
sig->line->wrap(
506+
allocator->post_alloc_data<si64>(width, 1), width, 1);
507+
aug->line->wrap(
508+
allocator->post_alloc_data<si64>(width, 1), width, 1);
509+
}
484510
}
485-
else
511+
else
486512
{
487-
for (ui32 i = 0; i < num_steps; ++i)
488-
ssp[i].line->wrap(
489-
allocator->post_alloc_data<si64>(width, 1), width, 1);
490-
sig->line->wrap(allocator->post_alloc_data<si64>(width, 1), width, 1);
491-
aug->line->wrap(allocator->post_alloc_data<si64>(width, 1), width, 1);
513+
for (ui32 i = 0; i < num_steps; ++i)
514+
ssp[i].line->wrap(
515+
allocator->post_alloc_data<float>(width, 1), width, 1);
516+
sig->line->wrap(
517+
allocator->post_alloc_data<float>(width, 1), width, 1);
518+
aug->line->wrap(
519+
allocator->post_alloc_data<float>(width, 1), width, 1);
492520
}
493521

494522
cur_line = 0;

src/core/codestream/ojph_subband.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ namespace ojph {
9292

9393
const param_qcd* qp = codestream->access_qcd()->get_qcc(comp_num);
9494
ui32 precision = qp->propose_precision(cdp);
95+
const param_atk* atk = cdp->access_atk();
96+
bool reversible = atk->is_reversible();
9597

9698
for (ui32 i = 0; i < num_blocks.w; ++i)
9799
codeblock::pre_alloc(codestream, nominal, precision);
@@ -100,10 +102,15 @@ namespace ojph {
100102
allocator->pre_alloc_obj<line_buf>(1);
101103
//allocate line_buf
102104
ui32 width = band_rect.siz.w + 1;
103-
if (precision <= 32)
104-
allocator->pre_alloc_data<si32>(width, 1);
105+
if (reversible)
106+
{
107+
if (precision <= 32)
108+
allocator->pre_alloc_data<si32>(width, 1);
109+
else
110+
allocator->pre_alloc_data<si64>(width, 1);
111+
}
105112
else
106-
allocator->pre_alloc_data<si64>(width, 1);
113+
allocator->pre_alloc_data<float>(width, 1);
107114
}
108115

109116
//////////////////////////////////////////////////////////////////////////
@@ -201,10 +208,15 @@ namespace ojph {
201208
lines = allocator->post_alloc_obj<line_buf>(1);
202209
//allocate line_buf
203210
ui32 width = band_rect.siz.w + 1;
204-
if (precision <= 32)
205-
lines->wrap(allocator->post_alloc_data<si32>(width, 1), width, 1);
211+
if (reversible)
212+
{
213+
if (precision <= 32)
214+
lines->wrap(allocator->post_alloc_data<si32>(width, 1), width, 1);
215+
else
216+
lines->wrap(allocator->post_alloc_data<si64>(width, 1), width, 1);
217+
}
206218
else
207-
lines->wrap(allocator->post_alloc_data<si64>(width, 1), width, 1);
219+
lines->wrap(allocator->post_alloc_data<float>(width, 1), width, 1);
208220
}
209221

210222
//////////////////////////////////////////////////////////////////////////

src/core/codestream/ojph_tile.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,16 @@ namespace ojph {
122122
}
123123

124124
//allocate lines
125-
if (codestream->get_cod()->is_employing_color_transform())
125+
const param_cod* cdp = codestream->get_cod();
126+
if (cdp->is_employing_color_transform())
126127
{
127128
allocator->pre_alloc_obj<line_buf>(3);
128-
for (int i = 0; i < 3; ++i)
129-
allocator->pre_alloc_data<si32>(width, 0);
129+
if (cdp->access_atk()->is_reversible())
130+
for (int i = 0; i < 3; ++i)
131+
allocator->pre_alloc_data<si32>(width, 0);
132+
else
133+
for (int i = 0; i < 3; ++i)
134+
allocator->pre_alloc_data<float>(width, 0);
130135
}
131136
}
132137

@@ -230,8 +235,14 @@ namespace ojph {
230235
{
231236
num_lines = 3;
232237
lines = allocator->post_alloc_obj<line_buf>(num_lines);
233-
for (int i = 0; i < 3; ++i)
234-
lines[i].wrap(allocator->post_alloc_data<si32>(width, 0), width, 0);
238+
if (reversible)
239+
for (int i = 0; i < 3; ++i)
240+
lines[i].wrap(
241+
allocator->post_alloc_data<si32>(width, 0), width, 0);
242+
else
243+
for (int i = 0; i < 3; ++i)
244+
lines[i].wrap(
245+
allocator->post_alloc_data<float>(width, 0), width, 0);
235246
}
236247
else
237248
{

src/core/common/ojph_mem.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -142,26 +142,14 @@ namespace ojph {
142142
LFT_16BIT = 0x02, // Set when data is 2 bytes (not used)
143143
LFT_32BIT = 0x04, // Set when data is 4 bytes
144144
LFT_64BIT = 0x08, // Set when data is 8 bytes
145-
LFT_REVERSIBLE = 0x10, // Set when data is used for reversible coding
146-
// Not all combinations are useful
145+
LFT_INTEGER = 0x10, // Set when data is an integer, in other words
146+
// 32bit integer, not 32bit float
147147
LFT_SIZE_MASK = 0x0F, // To extract data size
148148
};
149149

150150
public:
151151
line_buf() : size(0), pre_size(0), flags(LFT_UNDEFINED), i32(0) {}
152152

153-
template<typename T>
154-
void pre_alloc(mem_fixed_allocator *p, size_t num_ele, ui32 pre_size)
155-
{
156-
memset(this, 0, sizeof(line_buf));
157-
p->pre_alloc_data<T>(num_ele, pre_size);
158-
size = num_ele;
159-
this->pre_size = pre_size;
160-
}
161-
162-
template<typename T>
163-
void finalize_alloc(mem_fixed_allocator *p);
164-
165153
template<typename T>
166154
void wrap(T *buffer, size_t num_ele, ui32 pre_size);
167155

src/core/others/ojph_mem.cpp

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -49,38 +49,14 @@ namespace ojph {
4949
//
5050
////////////////////////////////////////////////////////////////////////////
5151

52-
////////////////////////////////////////////////////////////////////////////
53-
template<>
54-
void line_buf::finalize_alloc<si32>(mem_fixed_allocator *p)
55-
{
56-
assert(p != 0 && size != 0);
57-
i32 = p->post_alloc_data<si32>(size, pre_size);
58-
}
59-
60-
////////////////////////////////////////////////////////////////////////////
61-
template<>
62-
void line_buf::finalize_alloc<float>(mem_fixed_allocator *p)
63-
{
64-
assert(p != 0 && size != 0);
65-
f32 = p->post_alloc_data<float>(size, pre_size);
66-
}
67-
68-
////////////////////////////////////////////////////////////////////////////
69-
template<>
70-
void line_buf::finalize_alloc<si64>(mem_fixed_allocator *p)
71-
{
72-
assert(p != 0 && size != 0);
73-
i64 = p->post_alloc_data<si64>(size, pre_size);
74-
}
75-
7652
////////////////////////////////////////////////////////////////////////////
7753
template<>
7854
void line_buf::wrap(si32 *buffer, size_t num_ele, ui32 pre_size)
7955
{
8056
this->i32 = buffer;
8157
this->size = num_ele;
8258
this->pre_size = pre_size;
83-
this->flags = LFT_32BIT | LFT_REVERSIBLE;
59+
this->flags = LFT_32BIT | LFT_INTEGER;
8460
}
8561

8662
////////////////////////////////////////////////////////////////////////////
@@ -100,7 +76,7 @@ namespace ojph {
10076
this->i64 = buffer;
10177
this->size = num_ele;
10278
this->pre_size = pre_size;
103-
this->flags = LFT_64BIT | LFT_REVERSIBLE;
79+
this->flags = LFT_64BIT | LFT_INTEGER;
10480
}
10581

10682
////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)