-
-
Notifications
You must be signed in to change notification settings - Fork 699
make jp2kload work with the openjpeg test images #4158
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
Conversation
We were not taking account of x0/y0 correctly. See #4154 Thanks @mika-fischer
Test data here: https://github.com/uclouvain/openjpeg-data/tree/master/baseline/nonregression With this PR, we now load
|
OK, this now seems to load all the openjpeg test images correctly. Thanks again for reporting this, @mika-fischer This will be a pain to review :( sorry. I added two tricky jp2k images from the openjpeg set to our test suite. |
Perhaps this should target the FWIW, LLVM does this very neatly with a bot that automates the entire process via I was thinking about adopting a similar approach for libvips, which would avoid the need to retarget PRs and regularly merging release branches back into the master branch.
Don't worry, reviewing this with the |
Thanks for working on this! I can confirm the two files above are working now. Unfortunately, I still get crashes with the following files :-/
|
It feels like a relatively large change, so I was thinking 8.16 would be a better place for it. I'll have a look at the LLVM doc, thanks!
Oh poop. I'll have a look. I noticed imagemagick gets quite a few of the openjpeg test files wrong too, fwiw. Their API really is very hard to work with, but still somehow easier than kakadu hehe. |
libvips won't be able to support jp2ks like this (you don't know what format they are until after you have decoded them), unfortunately. I'll have to add a lot of sanity checks on every decode operation. (what a ridiculous format! why is this allowed?) |
I feel your pain 😬 Just to be clear, I don't really care whether vips can read any of these files correctly. It just should not crash, since we use vips as a library... |
I agree it shouldn't crash. You could just disable the libvips openjpeg loader, of course, that would probably be a safer fix. If you set the |
Sure, that's what we did for the moment (falling back to ffmpeg). But of course one of the reasons we use vips in the first place is to be able to read formats like JPEG2000.
I see, but we need JPEG2000, JPEG-XL & PPM, which we would lose that way, so that's not really a good option... |
Some valid jp2k images appear to be mono (for example) when you read the header, but are RGB when decoded. This will break libvips's guarantees about header and image being consistent, so we can't load them. Reject all images of this type.
It's now detecting when decoded pixels don't match the jpeg2000 header and flagging an error, which seems to fix that set of crashes. |
Ah OK. As long as your users aren't uploading these strange jpeg2000 files, then it should work now. |
Great, thanks! I can confirm that the crashes are all gone and there are no valgrind warnings for the whole openjpeg folder. |
Great! Thanks for testing @mika-fischer, and thanks for reporting this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
We were not taking account of x0/y0 correctly.
See #4154
Thanks @mika-fischer