openjpeg icon indicating copy to clipboard operation
openjpeg copied to clipboard

OPJ fails to decode image that KDU manages correctly

Open gcode-importer opened this issue 11 years ago • 2 comments

Originally reported on Google Code with ID 406

OPJ fails to decode attached image:

[11:59:09 ~/dev/opj/git/openjpeg-build/bin] opj_decompress -i ~/Downloads/opj_wrong_kdu_ok.jp2
-o ~/Downloads/opj_wrong_kdu_ok.jp2_opj.ppm

[INFO] Start to read j2k main header (85).
[INFO] Main header has been correctly decoded.
[INFO] No decoded area parameters, set the decoded area to the whole image
[INFO] Header of tile 0 / 1 has been read.
Expected SOP marker
Error : expected SOP marker
Error : expected EPH marker
read: segment too long (4) with max (0) for codeblock 0 (p=0, b=1, r=5, c=1)
[ERROR] Failed to decode.
[ERROR] Failed to decode tile 1/2
[ERROR] Failed to decode the codestream in the JP2 file
ERROR -> opj_decompress: failed to decode image!


While kakadu decodes it correctly:

[12:00:15 ~/dev/opj/git/openjpeg-build/bin] kdu_expand -i ~/Downloads/opj_wrong_kdu_ok.jp2
-o ~/Downloads/opj_wrong_kdu_ok.jp2_kdu.tif

Consumed 2 tile-part(s) from a total of 2 tile(s).
Consumed 110,407 codestream bytes (excluding any file format) = 1.179209
bits/pel.
Processed using the multi-threaded environment, with
    4 parallel threads of execution

Reported by detonin on 2014-10-01 10:01:33


- _Attachment: [opj_wrong_kdu_ok.jp2](https://storage.googleapis.com/google-code-attachments/openjpeg/issue-406/comment-0/opj_wrong_kdu_ok.jp2)_

gcode-importer avatar Oct 01 '14 10:10 gcode-importer

First investigation shows that 16th tile-part is read beyond its end => this makes openjpeg
start reading 17th tile-part at a wrong place, and explains why it does not find SOP
nor EPH marker.

Reported by detonin on 2014-10-01 10:03:21

gcode-importer avatar Oct 01 '14 10:10 gcode-importer

Where is the sample? @detonin

ValZapod avatar May 11 '22 08:05 ValZapod