[gs-commits] ghostpdl branch, gs9.28-temp-for-testing, updated. gs9.28-temp-for-testing-tag-7-ga6d0709

[email protected] (Robin Watts)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
The ghostpdl branch, gs9.28-temp-for-testing has been updated
       via  a6d07099578f3a4f9a5aaceb83e944382b93210d (commit)
      from  3b5cffabfad0daa430be50c7c70bc111bf1a9dd2 (commit)

----------------------------------------------------------------------
commit a6d07099578f3a4f9a5aaceb83e944382b93210d
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 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.