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

incorrect encoding (index out of bounds) if number of resolution is >= 10 #493

Open
gcode-importer opened this issue May 19, 2015 · 4 comments

Comments

@gcode-importer
Copy link

Originally reported on Google Code with ID 493

What steps will reproduce the problem?
1.opj_compress  -i ocean3.tif -o ocean3.jp2 -q 40,40,40 -n 11
2.opj_decompress -i ocean3.jp2 -o out.tif
3.use any image viewer to view out.tif. 

What is the expected output? What do you see instead?
out.tif should be very close to image ocean3.tif, but it looks very different instead.


What version of the product are you using? On what operating system?
I am using openjpeg 2.1 on linux  2.6.39-400.211.1.el6uek.x86_64.  

Please provide any additional information below.
I think the key point is parameter "-n 11". If the number of resolution is 10 or less,
the result looks ok. If the number of resolution is great or equal to 10, the result
is not good. 

Note: the attached file is ocean3.jpg because ocean3.tif is larger than 10M. Please
first uncompress ocean3.jpg to ocean3.tif to run the test case. 


Reported by fechen on 2015-05-19 18:45:09

@gcode-importer
Copy link
Author

Hi fechen,

Seems that the image is mostly black. I guess that PNG shall be less than 10MB. In
that case, could you check that the issue is still here with PNG & attach that file.
This will avoid an unnecessary conversion outside of tested software. Thanks.

Reported by mayeut on 2015-05-20 21:01:50

@gcode-importer
Copy link
Author

Here is the same image in PNG format. The problem still exists. 
command: 
   opj_compress -i ocean3.png -o ocean3.jp2 -q 40,40,40 -n 11
   opj_decompress -i ocean3.jp2 -o out.tif

The image is mostly black on the left (which is supposed to be the ocean), on the top
right side it has data (which is supposed to be the land). This is an image with only
one component. After jp2 compression and decompression, the ocean that surrounds the
land is not black anymore, it is in gray color, which I think is not correct. 

Reported by fechen on 2015-05-22 14:07:57


- _Attachment: ocean3.png
![ocean3.png](https://storage.googleapis.com/google-code-attachments/openjpeg/issue-493/comment-2/ocean3.png)_

@gcode-importer
Copy link
Author

Hi,

I have uploaded the PNG file and the problem still exists. Please take a
look again.

Reported by fechen on 2015-05-28 14:16:42

@rouault
Copy link
Collaborator

rouault commented Jul 30, 2017

The issue here is that we are calling opj_dwt_getnorm () with a level number that is outside the size of the opj_dwt_norms array

0x00007ffff6b0f048 in opj_dwt_getnorm (level=10, orient=0) at /home/even/openjpeg/openjpeg/src/lib/openjp2/dwt.c:1205
1205	    return opj_dwt_norms[orient][level];

@rouault rouault changed the title incorrect encoding or decoding result incorrect encoding (index out of bounds) if number of resolution is >= 10 Aug 1, 2017
rouault added a commit that referenced this issue Sep 19, 2017
…1 or higher. But not a proper fix itself (refs #493)
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

2 participants