`opj_compress` sometimes loses data when encoding in lossless mode
Repro:
- Download this input file: ref.zip It contains ref.bmp.
It looks like so (in png form, for github's preview):
-
Download osx-arm64 version from https://github.com/uclouvain/openjpeg/releases/tag/v2.5.3, fix up the rpath with
install_name_tool -add_rpath "@loader_path/../lib" ~/Downloads/openjpeg-v2.5.3-osx-arm64/bin/opj_compress -
Compress ref.bmp losslessly like so:
~/Downloads/openjpeg-v2.5.3-osx-arm64/bin/opj_compress -i ref.bmp -o openjpeg-lossless-rgba-u8-prog0-tile3x2-res5.jp2 -n 5 -t 39,53 -C "opj_compress -n 5 -t 39,53" -
Uncompress it again (or look at it in Preview.app):
~/Downloads/openjpeg-v2.5.3-osx-arm64/bin/opj_decompress -i openjpeg-lossless-rgba-u8-prog0-tile3x2-res5.jp2 -o out.png
The output looks like so:
Note the two white stripes at the far right. (This is a true effect in the color channels, not an alpha handling effect.)
This is probably related to the rightmost tiles being just 2 pixels wide. Since we have 4 decompositions, the LL band and the first decomposition after it are empty, which might confuse something.
Jasper does not have this problem: % .../jasper-build/src/app/jasper --input ref.bmp --output jasper-tile3x2-res5.jp2 -O tilewidth=39 -O tileheight=53 -O numrlvls=5 also produces a jp2 file that has a 0x4 LL layer in tile 3 and has several empty subbands after this, but it decodes fine in all viewers.
Jasper's output attached: jasper-tile3x2-res5.zip