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

Decompression does not work with sequential data source #613

Closed
smuehlst opened this issue Oct 2, 2015 · 6 comments
Closed

Decompression does not work with sequential data source #613

smuehlst opened this issue Oct 2, 2015 · 6 comments

Comments

@smuehlst
Copy link
Contributor

smuehlst commented Oct 2, 2015

I'm referring to the thread Decompressing JPEG2000 from sequential input on the OpenJPEG mailing list.

I want to embed OpenJPEG in an application that reads its data from a data source that is only accessible in a sequential manner. Therefore an opj_stream_t objects was constructed with opj_stream_create() and only the read and skip functions were supplied via opj_stream_set_read_function() and opj_stream_set_skip_function(). With this implementation the decompression of all JPEG 2000 images fails with the error "opj_j2k_apply_nb_tile_parts_correction error".

In the mailing list thread it was suggested to implement the seek function but only implement forward seeking, and that should work, only some features would be missing. I did that, returning OPJ_FALSE in the seek function if a backward seek was attempted, and this didn't change the behavior.

This was tested with the current HEAD of the master branch, cf352af at the time of this writing.

@malaterre
Copy link
Collaborator

seek function requirement was added recently. There was no such thing in opj 2.0 and opj 2.1.0 release. Please make sure seek is not required.

@mayeut
Copy link
Collaborator

mayeut commented Oct 2, 2015

This seems to be related to the patch from PR #514 which fixes #254 .
Can you try using -DOPJ_DISABLE_TPSOT_FIX:BOOL=YES when running cmake and see if that changes anything ?

@smuehlst
Copy link
Contributor Author

smuehlst commented Oct 5, 2015

@mayeut: Yes, -DOPJ_DISABLE_TPSOT_FIX:BOOL=YES helps, then decompression works without having a seek function, thank you.
After reading #254, do I understand it correctly that the tradeoff is that certain broken JPEG 2000 images produced by Adobe tools cannot be decompressed?

@mayeut
Copy link
Collaborator

mayeut commented Oct 5, 2015

I've commited a fix for the workaround of #254 not to be enable if no seek function is provided.
You should be able to build openjpeg without -DOPJ_DISABLE_TPSOT_FIX:BOOL=YES and still get a working streaming implementation.

Images that are affected by the bug described in #254 will be decoded with a quality loss.

@smuehlst
Copy link
Contributor Author

smuehlst commented Oct 6, 2015

@mayeut: I tested the fix, and yes, I can build openjpeg without -DOPJ_DISABLE_TPSOT_FIX:BOOL=YES now and I'm still getting a working streaming implementation, thank you.

@ideasman42
Copy link
Contributor

Note, I ran into this issue OPJ_DISABLE_TPSOT_FIX worked. But the actual cause was my seek function was using SEEK_CUR instead of SEEK_SET behavior.

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

No branches or pull requests

4 participants