[Poppler-bugs] [Bug 58906] 0.22.0 does not find openjpeg-2.0.0

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Sat May 10 11:32:03 PDT 2014


https://bugs.freedesktop.org/show_bug.cgi?id=58906

--- Comment #19 from tarlou.gd at gmail.com ---
Hello,

I was trying to completely remove openjpeg 1 from my computer these days, and I
was so lucky to find this work. (What a coincidence!) Thanks for your patches!
That helped a lot.

And here is a bug report for the patch. It does not work on the file
http://fanat1k.ru/tmp/test_pdf.pdf (It was from this post
https://github.com/mozilla/pdf.js/issues/2788.)

The reason is the file needs OPJ_CODEC_J2K, but jpxData->pos was not set to 0
when OPJ_CODEC_JP2 decoding failed and started to try OPJ_CODEC_J2K. Maybe you
can move the jpxData definition (and stream) to init2, and that should solve
the problem. (If I'm not wrong, probably you might also need to release
variables stream and decoder after the "error:" line to avoid memory leak.)

A better solution is to determine the format before decoding. I checked some
codes from ghostscript. If the first two bytes of buf is 0xFF, 0x4F, then use
OPJ_CODEC_J2K; otherwise use OPJ_CODEC_JP2. We can safely ignore OPJ_CODEC_JPT,
because it is not implemented in openjpeg. (See the code of
opj_create_decompress in libopenjpeg/openjpeg.c in opengjpeg 1.5.1 or
src/lib/openjp2/openjpeg.c in openjpeg 2.1.0.)

I attached the JPEG2000Stream.cc file I'm using. (It is basically your patch
with some tweaks.) I also removed opj_end_decompress (is it useful?) and
restored the skip function to the way it should be (it should return
jpxData->pos instead of skip). And it works perfectly on the above test_pdf.pdf
file. There are also no openjpeg errors for the pdf file in provided "Comment
#2" (but there is an error from poppler, which seems doesn't matter). Hope this
will be useful.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/poppler-bugs/attachments/20140510/86e9a438/attachment-0001.html>


More information about the Poppler-bugs mailing list