Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for partial bitstream decoding #1251

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

chafey
Copy link
Contributor

@chafey chafey commented May 19, 2020

This PR adds support for partial bitstream decoding. Given a partial bitstream, it will still reconstruct an image with the data it has available.

@rouault
Copy link
Collaborator

rouault commented Oct 9, 2021

I've no idea what the last commit "added devcontainer and build.sh" does, and it should be removed from this PR

@@ -1348,6 +1347,7 @@ static OPJ_BOOL opj_t2_read_packet_data(opj_t2_t* p_t2,
opj_tcd_cblk_dec_t* l_cblk = 00;
opj_tcd_resolution_t* l_res =
&p_tile->comps[p_pi->compno].resolutions[p_pi->resno];
OPJ_UINT32 partial_buffer = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
OPJ_UINT32 partial_buffer = 0;
OPJ_BOOL partial_buffer = OPJ_FALSE;

"read: segment too long (%d) with max (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
l_seg->newlen, p_max_length, cblkno, p_pi->precno, bandno, p_pi->resno,
p_pi->compno);
return OPJ_FALSE;
// skip this codeblock since it is a partial read
partial_buffer = 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
partial_buffer = 1;
partial_buffer = OPJ_TRUE;

@@ -1523,7 +1547,7 @@ static OPJ_BOOL opj_t2_skip_packet_data(opj_t2_t* p_t2,
"skip: segment too long (%d) with max (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
l_seg->newlen, p_max_length, cblkno, p_pi->precno, bandno, p_pi->resno,
p_pi->compno);
return OPJ_FALSE;
//return OPJ_FALSE;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this commented line should be removed, and the message above turned as a EVT_WARNING ... when we allow decoding of partial bitstream.

I would like to see a public function
OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decoder_set_strict_mode(opj_codec_t *p_codec, OPJ_BOOL strict)
to control if we allow or not partial bitstreams.
We could potentially change the default to be the relaxed mode implemented in that PR, but if the user want the previous behaviour, they would call opj_decoder_set_strict_mode(codec, OPJ_TRUE). In that case the warnings should be errors, and the return OPJ_FALSE that have been removed would be used.

bitstream must be decoded or an error is returned. When it is disabled,
the decoder will decode partial bitstreams.
@param jp2 JP2 decompressor handle
@param strict JPH_TRUE for strict mode
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@param strict JPH_TRUE for strict mode
@param strict OPJ_TRUE for strict mode

* bitstreams as much as possible without erroring
*
* @param p_codec decompressor handler
* @param strict OBJ_TRUE to enable strict decoding, OBJ_FALSE to disable
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param strict OBJ_TRUE to enable strict decoding, OBJ_FALSE to disable
* @param strict OPJ_TRUE to enable strict decoding, OPJ_FALSE to disable

@rouault
Copy link
Collaborator

rouault commented Oct 13, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants