Bug 694990 - mode 9 uncompress simply does not work correctly.
Summary: mode 9 uncompress simply does not work correctly.
Status: RESOLVED FIXED
Alias: None
Product: GhostPCL
Classification: Unclassified
Component: PCL raster (show other bugs)
Version: master
Hardware: PC Linux
: P4 normal
Assignee: Ken Sharp
URL:
Keywords: bountiable
Depends on:
Blocks:
 
Reported: 2014-01-30 22:48 UTC by Hin-Tak Leung
Modified: 2023-06-01 09:08 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments
mode 9 test file (4.83 MB, application/octet-stream)
2014-01-30 22:48 UTC, Hin-Tak Leung
Details
possible patch (2.04 KB, patch)
2014-01-30 22:53 UTC, Hin-Tak Leung
Details | Diff
-sDEVICE=pdfwrite result (2.36 MB, application/pdf)
2014-02-01 09:11 UTC, Hin-Tak Leung
Details
final part of the mode 9 compression (1.21 KB, patch)
2023-05-28 00:48 UTC, Hin-Tak Leung
Details | Diff
Removing the misleading comment about mode 9. (1.34 KB, patch)
2023-05-28 00:51 UTC, Hin-Tak Leung
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hin-Tak Leung 2014-01-30 22:48:24 UTC
Created attachment 10631 [details]
mode 9 test file

test file from HP's OfficeJet Series 300 driver. testfile also does not display on x11 (Bug 694988) and need to distill through to see anything.

Also patch to follow - not quite working yet, but far more correct than current code.
Comment 1 Hin-Tak Leung 2014-01-30 22:53:47 UTC
Created attachment 10632 [details]
possible patch

possible patch, not quite completely correct yet, but at least it is more correct than the current code, and you get to see the tiger, mostly.
Comment 2 Hin-Tak Leung 2014-02-01 09:11:01 UTC
Created attachment 10637 [details]
-sDEVICE=pdfwrite  result

I came up with a better patch, and can confirm the code has always been wrong (for as long as it was, which was 1998!).

Here is the pdfwrite result from the corrected code. Strange the resolution seems to be off by a factor of two, despite the fact that the input does not seem to contain any undocumented, etc, instructions. But the rendering is "obviously correct"...
Comment 3 Hin-Tak Leung 2014-02-02 22:25:16 UTC
The "always been wrong" code was part of a single code drop in 1998:

commit 9267edc4dbc22ae78acf61e12b15a35aa9ec4fca
Author: Henry Stiles <henry.stiles@artifex.com>
Date:   Mon Aug 10 03:06:20 1998 +0000

    This is the first archived release of jan's pcl5c code.  There is no
    version number yet.
Comment 4 Hin-Tak Leung 2014-02-04 09:57:58 UTC
left "pcl6-win32-mode9and10.exe" in my home dir in casper.
Comment 5 Ken Sharp 2023-05-27 09:31:10 UTC
I've committed the patch, it does not 100% decompress the sample file but it is much improved. Thanks for the code Hin-Tak, I've no idea whay this wasn't included before since the old code is clearly wrong.

The fix is no 100%, so I have not closed the bug, but I think its well worth having the improvement anyway.
Comment 6 Hin-Tak Leung 2023-05-27 15:27:12 UTC
It seems I have a diff from a little after this patch, slightly different, plus some debugging code within too, so probably can revisit and/or see whether the small additions does what it does.

Btw, you said you would, but haven't made this bountiable yet.
Comment 7 Ken Sharp 2023-05-27 15:31:44 UTC
(In reply to Hin-Tak Leung from comment #6)
> It seems I have a diff from a little after this patch, slightly different,
> plus some debugging code within too, so probably can revisit and/or see
> whether the small additions does what it does.
> 
> Btw, you said you would, but haven't made this bountiable yet.

Oops,sorry, E_TOOMANYBUGS.....

Done now.
Comment 8 Hin-Tak Leung 2023-05-27 15:49:03 UTC
Thanks.

My local patch seems to differ slightly, and with some more debug code within, and also, most interestingly, remove the entire block of (presumably wrong) comments just before. So it is quite likely I have gotten to the end of it and started "fixing" the comments. I shall revisit this and see what further progress I made a long time ago.
Comment 9 Hin-Tak Leung 2023-05-28 00:48:16 UTC
Created attachment 24347 [details]
final part of the mode 9 compression

This small change is an update to https://bugs.ghostscript.com/attachment.cgi?id=10632 to make it all work.
Comment 10 Hin-Tak Leung 2023-05-28 00:51:07 UTC
Created attachment 24348 [details]
Removing the misleading comment about mode 9.

This is an addtional optional change I made ages ago, to remove the block of misleading comments above that routine.
Comment 11 Hin-Tak Leung 2023-05-28 00:56:45 UTC
I wrote in comment 2 that "I came up with a better patch", I think this is it.

Back then the color was correct but the resolution is off by 2x2, now the color is wrong (the tiger comes out as purple), but the resolution is corrrect.

I'd say commit these, close this, and start a new one on the "color regression".

I don't feel too strongly about removing the comment, but included it as a separate patch, just in case somebody else agrees with me also.
Comment 12 Hin-Tak Leung 2023-05-29 01:53:53 UTC
Argh, ignored this part - the resolution is still wrong. The color wrong (but related and also mode 9) file is bug 695047.

So probably should have two follow-up bug, one for this on resolution, the other on 695047 for the colour.

(In reply to Hin-Tak Leung from comment #11)
...
> Back then the color was correct but the resolution is off by 2x2, now the
> color is wrong (the tiger comes out as purple), but the resolution is
> corrrect.
...
Comment 13 Ken Sharp 2023-05-29 12:41:16 UTC
(In reply to Hin-Tak Leung from comment #11)

> Back then the color was correct but the resolution is off by 2x2, now the
> color is wrong (the tiger comes out as purple), but the resolution is
> corrrect.
> 
> I'd say commit these, close this, and start a new one on the "color
> regression".
> 
> I don't feel too strongly about removing the comment, but included it as a
> separate patch, just in case somebody else agrees with me also.

This does indeed seem to work correctly (as regards decompression) now, and 695047 also decompresses correctly. Colour is still wrong but that is a separate issue. Thanks!

As I mentioned in bug 694082, I assume we have a signed contributers agreement from you and have managed to send you bounties in the past so if you'd just confirm how to go about that (by private email to me please) then I'll get that sorted.

As with 694082 I'm leaving this bug open (and not yet pushing the commits to master) until we've got that sorted out, to make sure I do not forget.
Comment 14 Hin-Tak Leung 2023-05-30 12:31:14 UTC
Yes, faxed contributers agreement to Miles over a decade ago.

The follow-up about the wrong resolution
is bug 706749.
Comment 15 Ken Sharp 2023-06-01 09:08:22 UTC
Fixed in commit 1a458b1c130a273d923b5dfbf8dc205a8104f637