[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1617-gb9e4b4e
[email protected] (Robin Watts)
| Newsgroups | gmane.comp.printing.ghostscript.cvs |
|---|---|
| Message-ID | <[email protected]> |
The ghostpdl branch, master has been updated
via b9e4b4e4d97a2f0c32596fed0342fb83773a56c2 (commit)
via 0d46b4f51b5efba7e72b7d45517d0fba642477aa (commit)
via 42f386a85d3998310f0317501b54780ffbe6dc6b (commit)
from dea69cd04964b27a08c8b340476d58031cb9e517 (commit)
----------------------------------------------------------------------
commit b9e4b4e4d97a2f0c32596fed0342fb83773a56c2
Author: Robin Watts <[email protected]>
Date: Tue Aug 27 17:45:57 2019 +0100
Bug 701446: Avoid division by zero in gx_shade_trapezoid
Remove some incorrect clipping code.
diff --git a/base/gxshade6.c b/base/gxshade6.c
index 337e79c..11fe3cc 100644
--- a/base/gxshade6.c
+++ b/base/gxshade6.c
@@ -941,41 +941,43 @@ gx_shade_trapezoid(patch_fill_state_t *pfs, const gs_fixed_point q[4],
} else if (le.start.x > xleft)
xleft = le.start.x;
+ ybot = max(ybot, min(le.start.y, re.start.y));
+ ytop = min(ytop, max(le.end.y, re.end.y));
+#if 0
+ /* RJW: I've disabled this code a) because it doesn't make any
+ * difference in the cluster tests, and b) because I think it's wrong.
+ * Taking the first case as an example; just because the le.start.x
+ * is > xright, does not mean that we can simply truncate the edge at
+ * xright, as this may throw away part of the trap between ybot and
+ * the new le.start.y. */
/* Reduce the edges to the left/right of the clipping region. */
/* Only in the 4 cases which can bring ytop/ybot closer */
if (le.start.x > xright) {
le.start.y += (fixed)((int64_t)(le.end.y-le.start.y)*
(int64_t)(le.start.x-xright)/
(int64_t)(le.start.x-le.end.x));
- if (le.start.y > ybot) {
- ybot = le.start.y;
- }
le.start.x = xright;
}
if (re.start.x < xleft) {
re.start.y += (fixed)((int64_t)(re.end.y-re.start.y)*
(int64_t)(xleft-re.start.x)/
(int64_t)(re.end.x-re.start.x));
- if (re.start.y > ybot)
- ybot = re.start.y;
re.start.x = xleft;
}
if (le.end.x > xright) {
le.end.y -= (fixed)((int64_t)(le.end.y-le.start.y)*
(int64_t)(le.end.x-xright)/
(int64_t)(le.end.x-le.start.x));
- if (le.end.y < ytop)
- ytop = le.end.y;
le.end.x = xright;
}
if (re.end.x < xleft) {
re.end.y -= (fixed)((int64_t)(re.end.y-re.start.y)*
(int64_t)(xleft-re.end.x)/
(int64_t)(re.start.x-re.end.x));
- if (re.end.y < ytop)
- ytop = re.end.y;
re.end.x = xleft;
}
+#endif
+
if (ybot >= ytop)
return 0;
/* Follow the edges in, so that le.start.y == ybot etc. */
----------------------------------------------------------------------
commit 0d46b4f51b5efba7e72b7d45517d0fba642477aa
Author: Robin Watts <[email protected]>
Date: Tue Aug 27 15:54:36 2019 +0100
Exit early from gx_shade_trapezoid in more cases.
A zero height trap isn't plotted, so we can bail out early in
that case.
diff --git a/base/gxshade6.c b/base/gxshade6.c
index 890a1ac..337e79c 100644
--- a/base/gxshade6.c
+++ b/base/gxshade6.c
@@ -976,7 +976,7 @@ gx_shade_trapezoid(patch_fill_state_t *pfs, const gs_fixed_point q[4],
ytop = re.end.y;
re.end.x = xleft;
}
- if (ybot > ytop)
+ if (ybot >= ytop)
return 0;
/* Follow the edges in, so that le.start.y == ybot etc. */
if (le.start.y < ybot) {
@@ -1039,7 +1039,7 @@ gx_shade_trapezoid(patch_fill_state_t *pfs, const gs_fixed_point q[4],
(int64_t)(le.start.x-le.end.x));
le.start.x = re.start.x;
}
- if (ybot > ytop)
+ if (ybot >= ytop)
return 0;
le.start.y = ybot;
re.start.y = ybot;
@@ -1056,7 +1056,7 @@ gx_shade_trapezoid(patch_fill_state_t *pfs, const gs_fixed_point q[4],
(int64_t)(le.end.x-le.start.x));
le.end.x = re.end.x;
}
- if (ybot > ytop)
+ if (ybot >= ytop)
return 0;
le.end.y = ytop;
re.end.y = ytop;
----------------------------------------------------------------------
commit 42f386a85d3998310f0317501b54780ffbe6dc6b
Author: Robin Watts <[email protected]>
Date: Mon Aug 26 17:02:03 2019 +0100
Fix deep colour transparency "uncompositing".
Uncompositing a group uses a scale factor that is greater in range
than we'd like; we need to resort to 64bit to do this to avoid
losing accuracy.
This solves problems seen in:
tests_private/comparefiles/Bug689918.pdf.psdcmyk16.300.1
diff --git a/base/gxblend.c b/base/gxblend.c
index cf9991b..6d7db5e 100644
--- a/base/gxblend.c
+++ b/base/gxblend.c
@@ -2189,13 +2189,16 @@ art_pdf_recomposite_group_16(uint16_t *gs_restrict *dstp, uint16_t *gs_restrict
"src = (src, src_alpha_g) over dst" for src */
scale = ((unsigned int)(dst_alpha * 65535 + (src_alpha_g>>1))) / src_alpha_g -
dst_alpha;
+ /* scale is NOT in 16.16 form here. I've seen values of 0xfefe01, for example. */
for (i = 0; i < n_chan; i++) {
int si, di;
+ int64_t tmp64;
si = src[i];
di = dst[i];
- tmp = (si - di) * scale + 0x8000;
- tmp = si + (tmp >> 16);
+ /* RJW: Nasty that we have to resort to 64bit here, but we'll live with it. */
+ tmp64 = (si - di) * (int64_t)scale + 0x8000;
+ tmp = si + (tmp64 >> 16);
/* todo: it should be possible to optimize these cond branches */
if (tmp < 0)
Summary of changes:
base/gxblend.c | 7 +++++--
base/gxshade6.c | 26 ++++++++++++++------------
2 files changed, 19 insertions(+), 14 deletions(-)