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

read: segment too long (6182) with max (35872) for codeblock 0 (p=19, b=2, r=5, c=1) #284

Closed
gcode-importer opened this issue Mar 12, 2014 · 6 comments
Assignees
Milestone

Comments

@gcode-importer
Copy link

Originally reported on Google Code with ID 284

The attached file (see issue 135 for construction) fails to decode in current openjpeg:

read: segment too long (6182) with max (35872) for codeblock 0 (p=19, b=2, r=5, c=1)
[ERROR] Failed to decode.
[ERROR] Failed to decode tile 1/1
ERROR -> opj_decompress: failed to decode image!

Reported by malaterre on 2014-03-12 15:40:04


- _Attachment: [issue135.trans.j2k](https://storage.googleapis.com/google-code-attachments/openjpeg/issue-284/comment-0/issue135.trans.j2k)_
@gcode-importer
Copy link
Author

I suspect issue comes from r2266. Indeed code read as:

                                if (l_current_data + l_seg->newlen > p_src_data + p_max_length)
{
                                        return OPJ_FALSE;
                                }
[...]
                                if ((l_cblk->data_current_size + l_seg->newlen) > l_cblk->data_max_size)
{
                                    OPJ_BYTE* new_cblk_data = (OPJ_BYTE*) opj_realloc(l_cblk->data,
l_cblk->data_current_size + l_seg->newlen);

Reported by malaterre on 2014-03-12 15:41:46

  • Labels added: Milestone-Release2.1

@gcode-importer
Copy link
Author

Reported by malaterre on 2014-03-14 14:04:28

  • Status changed: Started

@tfmorris
Copy link

I have no idea if the above analysis is correct, but just to update the references:
r2262 == commit b65bf48

Code snippet above in diff: b65bf48#diff-1bfcd820328c9d73ee9052a650febf3eR1114

Code snippet in current master: https://github.com/uclouvain/openjpeg/blob/master/src/lib/openjp2/t2.c#L1191

@tfmorris
Copy link

I have additional images that demonstrate this problem if it would help with the debug. JPEG2000 is used extensively by the Internet Archive and OpenJPEG only appears to be able to decode about half the pages there. The kdu_expand program doesn't have an issue with them.

@tfmorris
Copy link

Oops! Ignore my comment. My problem was due to an problem further upstream in the processing pipeline which was feeding truncated JP2K data to OpenJPEG. Now opj_decompress seems to be working find as a drop-in replacement for kdu_expand.

@detonin detonin modified the milestones: OPJ v2.1.1, OPJ v2.2.0 Apr 15, 2016
@rouault
Copy link
Collaborator

rouault commented Jul 29, 2017

From latest comment, closing as not a bug

@rouault rouault closed this as completed Jul 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants