Skip to content

Commit

Permalink
Debugging changes for testing htj2k decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
wayfarer3130 committed Aug 30, 2024
1 parent e01c7b7 commit 520ac9d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
24 changes: 22 additions & 2 deletions src/core/codestream/ojph_tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,8 @@ namespace ojph {
}
++next_tile_part;

OJPH_INFO(0x00010002, "parse tile header 1");

//tile_end_location used on failure
ui64 tile_end_location = tile_start_location + sot.get_payload_length();

Expand All @@ -683,9 +685,12 @@ namespace ojph {

try
{
OJPH_INFO(0x00010002, "parse tile header 2.1 %d", prog_order);
//sequence the reading of precincts according to progression order
if (prog_order == OJPH_PO_LRCP || prog_order == OJPH_PO_RLCP)
{
OJPH_INFO(0x00010002, "parse tile header 3a");

max_decompositions -= skipped_res_for_read;
for (ui32 r = 0; r <= max_decompositions; ++r)
for (ui32 c = 0; c < num_comps; ++c)
Expand All @@ -694,11 +699,14 @@ namespace ojph {
}
else if (prog_order == OJPH_PO_RPCL)
{
OJPH_INFO(0x00010002, "parse tile header 3b");
max_decompositions -= skipped_res_for_read;
for (ui32 r = 0; r <= max_decompositions; ++r)
{
while (true)
{
OJPH_INFO(0x00010002, "parse tile header 3b.2 num_comps=%d", num_comps);

bool found = false;
ui32 comp_num = 0;
point smallest(INT_MAX, INT_MAX), cur;
Expand All @@ -714,15 +722,21 @@ namespace ojph {
else if (cur.y == smallest.y && cur.x < smallest.x)
{ smallest = cur; comp_num = c; }
}
if (found == true && data_left > 0)
if (found == true && data_left > 0)
{
OJPH_INFO(0x00010002, "parse tile header 3b.2.2");
comps[comp_num].parse_one_precinct(r, data_left, file);
OJPH_INFO(0x00010002, "parse tile header 3b.2.3");
}
else
break;
}
}
OJPH_INFO(0x00010002, "parse tile header 3b.3");
}
else if (prog_order == OJPH_PO_PCRL)
{
OJPH_INFO(0x00010002, "parse tile header 3c");
while (true)
{
bool found = false;
Expand Down Expand Up @@ -758,6 +772,7 @@ namespace ojph {
}
else if (prog_order == OJPH_PO_CPRL)
{
OJPH_INFO(0x00010002, "parse tile header 3d");
for (ui32 c = 0; c < num_comps; ++c)
{
while (true)
Expand All @@ -784,8 +799,12 @@ namespace ojph {
}
}
}
else
else {
OJPH_INFO(0x00010002, "Assert 0 on prog_order %d", prog_order);

assert(0);
}
OJPH_INFO(0x00010002, "parse tile header 3.4");

}
catch (const char *error)
Expand All @@ -795,6 +814,7 @@ namespace ojph {
else
OJPH_ERROR(0x00030092, "%s", error)
}
OJPH_INFO(0x00010002, "parse tile header 4 - seek");
file->seek((si64)tile_end_location, infile_base::OJPH_SEEK_SET);
}

Expand Down
11 changes: 10 additions & 1 deletion src/core/codestream/ojph_tile_comp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,25 @@ namespace ojph {
void tile_comp::parse_one_precinct(ui32 res_num, ui32& data_left,
infile_base *file)
{
OJPH_INFO(0x00010002, "parse_one_precint 1 %d <= %d", res_num, num_decomps);

assert(res_num <= num_decomps);
res_num = num_decomps - res_num;
resolution *r = res;
while (res_num > 0 && r != NULL)
{
OJPH_INFO(0x00010002, "parse_one_precint 2.1");
r = r->next_resolution();
--res_num;
OJPH_INFO(0x00010002, "parse_one_precint 2.2");
}
if (r) //resolution does not exist if r is NULL
if (r != NULL) //resolution does not exist if r is NULL
{
OJPH_INFO(0x00010002, "parse_one_precint 2.3 r=%d", r);
r->parse_one_precinct(data_left, file);
OJPH_INFO(0x00010002, "parse_one_precint 2.4");
}
OJPH_INFO(0x00010002, "parse_one_precint 3");
}

//////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 520ac9d

Please sign in to comment.