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

CMAP: MTYP == 0 (direct use) not handled properly #235

Closed
gcode-importer opened this issue Sep 6, 2013 · 19 comments
Closed

CMAP: MTYP == 0 (direct use) not handled properly #235

gcode-importer opened this issue Sep 6, 2013 · 19 comments
Assignees
Milestone

Comments

@gcode-importer
Copy link

Originally reported on Google Code with ID 235

The attached file appears blurred in openjpeg-2.0 because the final tile part is higher
than expected and so opj_j2k_read_sot exits too early.

I have attached a patch to resolve this.

Reported by slmistry on 2013-09-06 22:04:47


- _Attachment: [blur.patch](https://storage.googleapis.com/google-code-attachments/openjpeg/issue-235/comment-0/blur.patch)_ - _Attachment: [Bug691816.pdf](https://storage.googleapis.com/google-code-attachments/openjpeg/issue-235/comment-0/Bug691816.pdf)_
@gcode-importer
Copy link
Author

Reported by malaterre on 2014-02-25 15:48:16

  • Labels added: Milestone-Release2.1

@gcode-importer
Copy link
Author

I've -painfully- extracted the JP2 file from the attached PDF file, see issue235.jp2.
If I did it correctly the file is reported to be buggy as per kakadu point of view:

$ kdu_expand -i issue235.jp2 -o issue235.tiff
Error in Kakadu File Format Support:
JPX source contains a codestream with a palette (pclr) box, but no component
mapping (cmap) box.  This illegal situation has been detected after examining
both the codestream header (chdr) box, if any, for that codestream, and the
default JP2 header (jp2h) box, if any.

Reported by malaterre on 2014-02-26 16:57:29

  • Labels added: Priority-Low
  • Labels removed: Priority-Medium

- _Attachment: [issue235.jp2](https://storage.googleapis.com/google-code-attachments/openjpeg/issue-235/comment-2/issue235.jp2)_

@gcode-importer
Copy link
Author

Ok looks like there is a colormap in another PDF/XObject. Could someone please extract
the actual JP2 file from this PDF ?

Reported by malaterre on 2014-02-26 17:00:53

@gcode-importer
Copy link
Author

FYI, I followed instructions from: http://blog.idrsolutions.com/2011/07/extract-raw-jpeg-images-from-a-pdf-file/

Reported by malaterre on 2014-02-26 17:05:58

@gcode-importer
Copy link
Author

Original bug report is at: http://bugs.ghostscript.com/show_bug.cgi?id=691816

Reported by malaterre on 2014-03-04 13:16:11

@gcode-importer
Copy link
Author

cmap box is actually a toplevel box instead of being a subbox, hence kakadu is failing
to decode it properly.

Reported by malaterre on 2014-03-04 13:21:40

@gcode-importer
Copy link
Author

One need to change the size of the ihdr box from 827 to 847 to correct the file, and
have cmap be a subbox instead of toplevel.

Reported by malaterre on 2014-03-04 13:32:02


- _Attachment: [issue235_cmapsubbox.jp2](https://storage.googleapis.com/google-code-attachments/openjpeg/issue-235/comment-7/issue235_cmapsubbox.jp2)_

@gcode-importer
Copy link
Author

With current r2573, here is what I get:

$ make opj_decompress && ./bin/opj_decompress -i /tmp/issue235_cmapsubbox.jp2 -o bla.tif
[ 84%] Built target openjp2
[100%] Built target opj_decompress

[INFO] Start to read j2k main header (925).
[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.
[INFO] Tile 1/2 has been decoded.
[INFO] Image data has been updated with tile 1.

[INFO] Header of tile 1 / 1 has been read.
[INFO] Tile 2/2 has been decoded.
[INFO] Image data has been updated with tile 2.

[ERROR] Component 0 is mapped twice.
[ERROR] Component 0 is mapped twice.
[ERROR] Component 1 doesn't have a mapping.
[ERROR] Component 2 doesn't have a mapping.
ERROR -> opj_decompress: failed to decode image!


While kakadu seems happy about this file.

Reported by malaterre on 2014-03-04 13:35:28

@gcode-importer
Copy link
Author

Reported by malaterre on 2014-03-05 08:38:12

  • Status changed: Started

@gcode-importer
Copy link
Author

This issue was updated by revision r2577.

Reported by malaterre on 2014-03-05 09:45:10

@gcode-importer
Copy link
Author

Steps:

$ kdu_transcode -i issue235_cmapsubbox.jp2 -o issue235_cmapsubbox.j2k

-> kakadu and openjpeg produce the exact same output (bitwise).

Reported by malaterre on 2014-03-12 16:25:04

@gcode-importer
Copy link
Author

Need to check which bit plane (R,G,B) is causing the issue.

Reported by malaterre on 2014-03-12 17:12:55

@gcode-importer
Copy link
Author

For reference:

$ kdu_expand -i issue235_cmapsubbox.jp2 -o red.kdu.pgm,grn.kdu.pgm,blu.kdu.pgm
$ kdu_transcode -i issue235_cmapsubbox.jp2 -o issue235_cmapsubbox.j2k
$ kdu_expand -i issue235_cmapsubbox.j2k -o issue235_cmapsubbox.j2k.pgm
$ crc32 issue235_cmapsubbox.j2k.pgm
66b73a0b
$ crc32 red.kdu.pgm grn.kdu.pgm blu.kdu.pgm
e1d8ac31    red.kdu.pgm
66b73a0b    grn.kdu.pgm
66b73a0b    blu.kdu.pgm

Reported by malaterre on 2014-03-13 09:51:24

@gcode-importer
Copy link
Author

This issue was updated by revision r2705.

Reported by malaterre on 2014-03-13 09:57:25

@gcode-importer
Copy link
Author

This issue was updated by revision r2707.

Reported by malaterre on 2014-03-13 10:35:48

@gcode-importer
Copy link
Author

If one activate code from r2707. The openjpeg behave oddly and does not produce the
same output image whether it is contained in a JP2 or in a J2K container.

$ opj_decompress -i issue235_cmapsubbox.j2k -o issue235_cmapsubbox.j2k.pgm
$ mv /tmp/0.raw /tmp/0.j2k.raw
$ opj_decompress -i issue235_cmapsubbox.jp2 -o issue235_cmapsubbox.jp2.ppm
$ crc32 /tmp/0*.raw
16be4dd0    /tmp/0.j2k.raw
9e822ba3    /tmp/0.raw

Reported by malaterre on 2014-03-13 10:37:26

@gcode-importer
Copy link
Author

@mathieu,

I think this is the exact same thing as Issue 447, can you have a look at that ?
IMHO, there's nothing wrong with MTYP == 0 at r2949. Same output as kakadu (with cmap
in jp2h & issue 254 patch)
The blurred sub-issue is issue 254.

Reported by mayeut on 2014-12-06 11:05:57

Related to #447

@detonin
Copy link
Contributor

detonin commented Jul 20, 2015

@mayeut the test you added is failing on myside ... Is this expected?
http://my.cdash.org/viewTest.php?onlydelta&buildid=796186

@detonin detonin reopened this Jul 20, 2015
@mayeut
Copy link
Collaborator

mayeut commented Jul 20, 2015

@detonin,

I've seen this. I forgot to add the dump for issue235.jp2, it's fixed.

@mayeut mayeut closed this as completed Jul 20, 2015
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

4 participants