Skip to content

Commit bf4b0db

Browse files
committed
Bug Fixes.
1 parent e3e6b4d commit bf4b0db

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/core/codestream/ojph_params.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ namespace ojph {
914914

915915
//marker size excluding header
916916
Lcod = num_comps < 257 ? 9 : 10;
917-
Lcod = (ui16)(Lcod + (Scod & 1 ? SPcod.num_decomp : 0));
917+
Lcod = (ui16)(Lcod + (Scod & 1 ? 1 + SPcod.num_decomp : 0));
918918

919919
ui8 buf[4];
920920
bool result = true;

src/core/codestream/ojph_tile_comp.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ namespace ojph {
5858
mem_fixed_allocator* allocator = codestream->get_allocator();
5959

6060
//allocate a resolution
61-
ui32 num_decomps = codestream->access_cod().get_num_decompositions();
61+
ui32 num_decomps;
62+
num_decomps = codestream->get_coc(comp_num)->get_num_decompositions();
6263
allocator->pre_alloc_obj<resolution>(1);
6364

6465
resolution::pre_alloc(codestream, comp_rect, recon_comp_rect, comp_num,
@@ -130,13 +131,12 @@ namespace ojph {
130131
//////////////////////////////////////////////////////////////////////////
131132
bool tile_comp::get_top_left_precinct(ui32 res_num, point &top_left)
132133
{
133-
assert(res_num <= num_decomps);
134-
res_num = num_decomps - res_num;
134+
int resolution_num = (int)num_decomps - (int)res_num;
135135
resolution *r = res;
136-
while (res_num > 0 && r != NULL)
136+
while (resolution_num > 0 && r != NULL)
137137
{
138138
r = r->next_resolution();
139-
--res_num;
139+
--resolution_num;
140140
}
141141
if (r) //resolution does not exist if r is NULL
142142
return r->get_top_left_precinct(top_left);
@@ -147,13 +147,12 @@ namespace ojph {
147147
//////////////////////////////////////////////////////////////////////////
148148
void tile_comp::write_one_precinct(ui32 res_num, outfile_base *file)
149149
{
150-
assert(res_num <= num_decomps);
151-
res_num = num_decomps - res_num;
150+
int resolution_num = (int)num_decomps - (int)res_num;
152151
resolution *r = res;
153-
while (res_num > 0 && r != NULL)
152+
while (resolution_num > 0 && r != NULL)
154153
{
155154
r = r->next_resolution();
156-
--res_num;
155+
--resolution_num;
157156
}
158157
if (r) //resolution does not exist if r is NULL
159158
r->write_one_precinct(file);

0 commit comments

Comments
 (0)