[bug-pcl] bugs in PCL compression mode 9
Henry Stiles
henry.stiles at artifex.com
Mon Mar 21 09:54:43 PST 2005
Hello Derek
Thanks for the patch, could you post the pcl file that prompted the
change. Thanks in advance.
Derek B. Noonburg writes:
> There are a couple of problems with the uncompress_9 function in
> GhostPCL 1.41. I'm attaching a patch file.
>
> I've only done minor testing (with output from a Windows driver for the
> Brother 1850). Also, it seems to match up with the code in the PCL3
> driver in ghostscript (which compresses images using mode 9).
>
> - Derek
> *** rtrstcmp.c.orig Mon Mar 14 17:16:12 2005
> --- rtrstcmp.c Mon Mar 14 17:16:52 2005
> ***************
> *** 194,201 ****
> if (comp) {
> offset = (val >> 5) & 0x3;
> more_offset = (offset == 0x3);
> ! cnt = (val & 0x1f) + 1;
> ! more_cnt = (cnt == 0x20);
> } else {
> offset = (val >> 3) & 0xf;
> more_offset = (offset == 0xf);
> --- 194,201 ----
> if (comp) {
> offset = (val >> 5) & 0x3;
> more_offset = (offset == 0x3);
> ! cnt = (val & 0x1f) + 2;
> ! more_cnt = (cnt == 0x21);
> } else {
> offset = (val >> 3) & 0xf;
> more_offset = (offset == 0xf);
> ***************
> *** 213,244 ****
> uint extra = *pin++;
>
> more_cnt = (extra == 0xff);
> ! offset += extra;
> }
>
> if ((pb += offset) >= plim)
> break;
> if (comp) {
> ! uint j = i / 2;
> !
> ! while (j-- > 0) {
> ! uint rep_cnt = *pin++;
> ! uint rep_val = *pin++;
> !
> ! if (rep_cnt > plim - pb)
> ! rep_cnt = plim - pb;
> ! while (rep_cnt-- > 0)
> ! *pb++ = rep_val;
> ! }
> ! i -= 2 * j;
>
> } else {
> if (cnt > i)
> cnt = i;
> - i -= cnt;
> - pin += cnt;
> if (cnt > plim - pb)
> cnt = plim - pb;
> while (cnt-- > 0)
> *pb++ = *pin++;
> }
> --- 213,240 ----
> uint extra = *pin++;
>
> more_cnt = (extra == 0xff);
> ! cnt += extra;
> }
>
> if ((pb += offset) >= plim)
> break;
> if (comp) {
> ! uint rep_val = 0;
> ! if (i > 0) {
> ! rep_val = *pin++;
> ! --i;
> ! }
> ! if (cnt > plim - pb)
> ! cnt = plim - pb;
> ! while (cnt-- > 0)
> ! *pb++ = rep_val;
>
> } else {
> if (cnt > i)
> cnt = i;
> if (cnt > plim - pb)
> cnt = plim - pb;
> + i -= cnt;
> while (cnt-- > 0)
> *pb++ = *pin++;
> }
> _______________________________________________
> bug-pcl mailing list
> bug-pcl at ghostscript.com
> http://www.ghostscript.com/mailman/listinfo/bug-pcl
--
./Henry
Artifex Software
More information about the bug-pcl
mailing list