Skip to content

Commit

Permalink
Merge pull request #176 from aous72/modifying_packet_parsing
Browse files Browse the repository at this point in the history
This is a better way of packet header parsing.
  • Loading branch information
aous72 authored Feb 2, 2025
2 parents 2ba1b73 + 4bf915c commit dd9bd6d
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/core/codestream/ojph_precinct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ namespace ojph {
ph_bytes += cur_coded_list->buf_size - cur_coded_list->avail_size;
}

return coded ? cb_bytes + ph_bytes : 1;
return coded ? cb_bytes + ph_bytes : 1; // 1 for empty packet
}

//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -336,15 +336,6 @@ namespace ojph {
if (may_use_sop)
bb_skip_sop(&bb);

if (bands[0].empty && bands[1].empty && bands[2].empty && bands[3].empty)
{
ui32 bit = 0;
bb_read_bit(&bb, bit);
bb_terminate(&bb, uses_eph);
assert(bit == 0);
return;
}

bool empty_packet = true;
for (int s = 0; s < 4; ++s)
{
Expand Down Expand Up @@ -508,12 +499,19 @@ namespace ojph {
}
}
}
if (empty_packet)
{ // all subbands are empty
ui32 bit = 0;
bb_read_bit(&bb, bit);
//assert(bit == 0);
}
bb_terminate(&bb, uses_eph);
//read codeblock data
for (int s = 0; s < 4; ++s)
{
if (bands[s].empty)
continue;

ui32 band_width = bands[s].num_blocks.w;
ui32 width = cb_idxs[s].siz.w;
ui32 height = cb_idxs[s].siz.h;
Expand Down

0 comments on commit dd9bd6d

Please sign in to comment.