Bug 692002 - Jpeg 2000 decoding is EXTREMELY slow
Summary: Jpeg 2000 decoding is EXTREMELY slow
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: JPX/JBIG2 encode/decode (show other bugs)
Version: 9.00
Hardware: PC Linux
: P4 normal
Assignee: Alex Cherepanov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-25 23:04 UTC by aditsu
Modified: 2011-12-21 16:44 UTC (History)
2 users (show)

See Also:
Customer:
Word Size: ---


Attachments
Example file (824.82 KB, image/pdf)
2011-02-25 23:04 UTC, aditsu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description aditsu 2011-02-25 23:04:57 UTC
Created attachment 7292 [details]
Example file

I'm trying to convert pdf files to images, and I found that some files take a VERY long time. The reason appears to be jpeg2k/jpx decoding. With gs compiled without jpeg2k support, the conversion is almost instant (but misses the image).
I'm attaching a sample document. This is what I did and what happened:

% time gs -sDEVICE=jpeg -o d.jpg "Document (1).pdf"
GPL Ghostscript  9.00 (2010-09-14)
Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
   **** Warning: File has a corrupted %%EOF marker, or garbage after %%EOF.
Processing pages 1 through 1.
Page 1

   **** This file had errors that were repaired or ignored.
   **** The file was produced by: 
   **** >>>> OmniPage CSDK 16 <<<<
   **** Please notify the author of the software that produced this
   **** file that it does not conform to Adobe's published PDF
   **** specification.

gs -sDEVICE=jpeg -o d.jpg "Document (1).pdf"  4.49s user 42.65s system 98% cpu 47.621 total

This is on a Core(TM)2 Duo CPU E8500 @ 3.16GHz; on a Core(TM)2 Quad CPU Q9300 @ 2.50GHz it took 59 sec.
The same file opens quickly (within about 3 seconds) in adobe reader, mupdf and okular.
Comment 1 Henry Stiles 2011-02-25 23:28:34 UTC
Alex is this something that will be fixed with the openjpeg integration?
Comment 2 Alex Cherepanov 2011-03-03 03:28:58 UTC
The fact that most of the time was spent as system time indicates that
computer is using virtual memory. Ghostscript allocates 630M of memory
running the sample file. On my i7 920 the file finishes in 3.5 sec.
On an older box the file takes 8 sec of wall time.
Comment 3 Chris Liddell (chrisl) 2011-12-21 15:34:14 UTC
With the switch to OpenJPEG, on my core2 quad, the file now takes ~2 seconds, and uses <300Mb of memory.

I feel this is fixed.

http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=83b1e042
Comment 4 aditsu 2011-12-21 16:39:14 UTC
Thanks, what version will this be?
Comment 5 Chris Liddell (chrisl) 2011-12-21 16:44:12 UTC
Ghostscript 9.05 - scheduled for release in February 2012.