[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1749-g45d2ab4

[email protected] (Robin Watts) Thu, 24 Oct 2019 12:12:02 +0000 (UTC)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
The ghostpdl branch, master has been updated
       via  45d2ab4602384974ea4af1ba60a38c4999bc9f87 (commit)
      from  a44d0ce727f2095fbbedb8bf6b1e062fca3c8f01 (commit)

----------------------------------------------------------------------
commit 45d2ab4602384974ea4af1ba60a38c4999bc9f87
Author: Robin Watts <[email protected]>
Date:   Mon Oct 21 17:37:59 2019 +0100

    Use CAL implementation of ETS in WITH_CAL builds.

diff --git a/base/cal.mak b/base/cal.mak
index c1a7b8c..7ffc870 100644
--- a/base/cal.mak
+++ b/base/cal.mak
@@ -118,5 +118,11 @@ $(CAL_OBJ)$(CAL_PREFIX)blendsse42.$(OBJ) : $(CAL_SRC)blendsse42.c $(cal_HDRS) $(
 $(CAL_OBJ)$(CAL_PREFIX)blend.$(OBJ) : $(CAL_SRC)blend.c $(cal_HDRS) $(CAL_DEP) $(gsmemory_h)
 	$(CAL_CC) $(I_)$(GLSRC) $(CAL_O)blend.$(OBJ) $(C_) $(CAL_SRC)blend.c
 
+cal_ets_h=$(CAL_SRC)cal_ets.h
+ca_ets_tm_h=$(CAL_SRC)cal_ets_tm.h
+$(GLOBJ)ets_1.$(OBJ) : $(CAL_SRC)cal_ets.c $(CAL_SRC)ets_template.c $(AK) \
+ $(cal_ets_h) $(cal_ets_tm_h) $(LIB_MAK) $(MAKEDIRS)
+	$(GLCC) $(GLO_)ets_1.$(OBJ) $(C_) $(CAL_SRC)cal_ets.c
+
 
 # end of file
diff --git a/base/ets.h b/base/ets.h
index a549da5..4b009b8 100644
--- a/base/ets.h
+++ b/base/ets.h
@@ -120,6 +120,7 @@ ets_line(ETS_Ctx *ctx, unsigned char **dest, const ETS_SrcPixel * const * gs_res
 void
 ets_destroy(void *malloc_arg, ETS_Ctx *ctx);
 
+/* These are called from ETS and must be implemented by the calling code. */
 void *
 ets_malloc(void *malloc_arg, int size);
 
diff --git a/base/gxdownscale.c b/base/gxdownscale.c
index e2e83ea..8721d1d 100644
--- a/base/gxdownscale.c
+++ b/base/gxdownscale.c
@@ -19,7 +19,12 @@
 #include "string_.h"
 #include "gdevprn.h"
 #include "assert_.h"
+
+#ifdef WITH_CAL
+#include "cal_ets.h"
+#else
 #include "ets.h"
+#endif
 
 /* Nasty inline declaration, as gxht_thresh.h requires penum */
 void gx_ht_threshold_row_bit_sub(byte *contone,  byte *threshold_strip,
@@ -1799,6 +1804,57 @@ static int check_trapping(gs_memory_t *memory, int trap_w, int trap_h,
     return 0;
 }
 
+static void
+find_aspect_ratio(float *res, int *a, int *b)
+{
+    float xres = res[0];
+    float yres = res[1];
+    float f;
+
+    if (xres == yres) {
+        *a = *b = 1;
+        return;
+    }
+    else if (xres > yres)
+    {
+        xres /= yres;
+        f = xres - (int)xres;
+        if (f >= 0.2 && f < 0.3)
+            xres *= 4, yres = 4;
+        else if (f >= 0.3 && f < 0.4)
+            xres *= 3, yres = 3;
+        else if (f >= 0.4 && f < 0.6)
+            xres *= 2, yres = 2;
+        else if (f >= 0.6 && f < 0.7)
+            xres *= 3, yres = 3;
+        else if (f >= 0.7 && f < 0.8)
+            xres *= 4, yres = 4;
+        else
+            yres = 1;
+        *a = (int)(xres + 0.5);
+        *b = (int)yres;
+    }
+    else
+    {
+        yres /= xres;
+        f = yres - (int)yres;
+        if (f >= 0.2 && f < 0.3)
+            yres *= 4, xres = 4;
+        else if (f >= 0.3 && f < 0.4)
+            yres *= 3, xres = 3;
+        else if (f >= 0.4 && f < 0.6)
+            yres *= 2, xres = 2;
+        else if (f >= 0.6 && f < 0.7)
+            yres *= 3, xres = 3;
+        else if (f >= 0.7 && f < 0.8)
+            yres *= 4, xres = 4;
+        else
+            xres = 1;
+        *a = (int)xres;
+        *b = (int)(yres + 0.5);
+    }
+}
+
 static int init_ets(gx_downscaler_t *ds, int num_planes, gx_downscale_core *downscale_core)
 {
     ETS_Params params = { 0 };
@@ -1831,13 +1887,15 @@ static int init_ets(gx_downscaler_t *ds, int num_planes, gx_downscale_core *down
     for (i = 0; i < num_planes; i++)
         rs_luts[i] = rs_lut;
 
+#ifdef WITH_CAL
+    params.context = ds->dev->memory->gs_lib_ctx->core->cal_ctx;
+#endif
     params.width = ds->width;
     params.n_planes = num_planes;
     params.levels = 2;
     params.luts = luts;
     params.distscale = 0;
-    params.aspect_x = 1;
-    params.aspect_y = 1;
+    find_aspect_ratio(ds->dev->HWResolution, &params.aspect_x, &params.aspect_y);
     params.strengths = strengths;
     params.rand_scale = 0;
     params.c1_scale = c1_scale;
diff --git a/base/lib.mak b/base/lib.mak
index 274a071..5c243f4 100644
--- a/base/lib.mak
+++ b/base/lib.mak
@@ -1363,19 +1363,30 @@ ets_h=$(GLSRC)ets.h
 ets_tm_h=$(GLSRC)ets_tm.h
 ets=$(GLOBJ)ets.$(OBJ)
 
-$(GLOBJ)ets.$(OBJ) : $(GLSRC)ets.c $(AK) \
+$(GLOBJ)ets_0.$(OBJ) : $(GLSRC)ets.c $(AK) \
  $(ets_h) $(ets_tm_h) $(LIB_MAK) $(MAKEDIRS)
-	$(GLCC) $(GLO_)ets.$(OBJ) $(C_) $(GLSRC)ets.c
+	$(GLCC) $(GLO_)ets_0.$(OBJ) $(C_) $(GLSRC)ets.c
+
+$(GLOBJ)ets.$(OBJ) : $(GLOBJ)ets_$(WITH_CAL).$(OBJ)  $(AK) $(gp_h)
+	$(CP_) $(GLOBJ)ets_$(WITH_CAL).$(OBJ) $(GLOBJ)ets.$(OBJ)
 
 # ----------- Downsampling routines ------------ #
 gxdownscale_h=$(GLSRC)gxdownscale.h
 downscale_=$(GLOBJ)gxdownscale.$(OBJ) $(claptrap) $(ets)
 
-$(GLOBJ)gxdownscale.$(OBJ) : $(GLSRC)gxdownscale.c $(AK) $(string__h)\
+$(GLOBJ)gxdownscale_0.$(OBJ) : $(GLSRC)gxdownscale.c $(AK) $(string__h)\
  $(gxdownscale_h) $(gserrors_h) $(gdevprn_h) $(assert__h) $(ets_h)\
  $(LIB_MAK) $(MAKEDIRS)
 	$(GLCC) $(GLO_)gxdownscale.$(OBJ) $(C_) $(GLSRC)gxdownscale.c
 
+$(GLOBJ)gxdownscale_1.$(OBJ) : $(GLSRC)gxdownscale.c $(AK) $(string__h)\
+ $(gxdownscale_h) $(gserrors_h) $(gdevprn_h) $(assert__h) $(ets_h)\
+ $(LIB_MAK) $(MAKEDIRS)
+	$(GLCC) $(D_)WITH_CAL$(_D) $(I_)$(CALSRCDIR)$(_I) $(GLO_)gxdownscale.$(OBJ) $(C_) $(GLSRC)gxdownscale.c
+
+$(GLOBJ)gxdownscale.$(OBJ) : $(GLOBJ)gxdownscale_$(WITH_CAL).$(OBJ) $(AK) $(gp_h)
+	$(CP_) $(GLOBJ)gxdownscale_$(WITH_CAL).$(OBJ) $(GLOBJ)gxdownscale.$(OBJ)
+
 ###### Create a pseudo-"feature" for the entire graphics library.
 
 LIB0s=$(GLOBJ)gpmisc.$(OBJ) $(GLOBJ)stream.$(OBJ) $(GLOBJ)strmio.$(OBJ)


Summary of changes:
 base/cal.mak       |  6 ++++++
 base/ets.h         |  1 +
 base/gxdownscale.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
 base/lib.mak       | 17 ++++++++++++---
 4 files changed, 81 insertions(+), 5 deletions(-)