[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-2045-g9608d27
[email protected] (Robin Watts) Fri, 3 Jan 2020 16:44:02 +0000 (UTC)
| Newsgroups | gmane.comp.printing.ghostscript.cvs |
|---|---|
| Message-ID | <[email protected]> |
The ghostpdl branch, master has been updated
via 9608d275bd750b189dd52681791f31617a640817 (commit)
from 59ed026565b5be1bd055d0fbd1b066b8c07274e0 (commit)
----------------------------------------------------------------------
commit 9608d275bd750b189dd52681791f31617a640817
Author: Robin Watts <[email protected]>
Date: Fri Jan 3 15:51:00 2020 +0000
Use CAL halftoning in tiffsep1 post processing.
A quick back to back test with/without cal using:
bin/gswin32c.exe -sDEVICE=tiffsep1 -o out.tif -r600 -dMaxBitmap=80000000
examples/tiger.eps
shows timings of 1.142s vs 1.297s on my machine.
diff --git a/devices/devs.mak b/devices/devs.mak
index e9a439e..bcac0e9 100644
--- a/devices/devs.mak
+++ b/devices/devs.mak
@@ -1671,12 +1671,23 @@ $(DD)tiffgray.dev : $(libtiff_dev) $(tiffgray_) $(DD)tiffs.dev\
$(SETPDEV2) $(DD)tiffgray $(tiffgray_)
$(ADDMOD) $(DD)tiffgray -include $(DD)tiffs $(tiff_i_)
-$(DEVOBJ)gdevtsep.$(OBJ) : $(DEVSRC)gdevtsep.c $(PDEVH) $(stdint__h)\
+$(DEVOBJ)gdevtsep_0.$(OBJ) : $(DEVSRC)gdevtsep.c $(PDEVH) $(stdint__h)\
$(gdevtifs_h) $(gdevdevn_h) $(gxdevsop_h) $(gsequivc_h) $(stdio__h) $(ctype__h)\
$(gxdht_h) $(gxiodev_h) $(gxdownscale_h) $(gzht_h)\
$(gxgetbit_h) $(gdevppla_h) $(gp_h) $(gstiffio_h) $(gsicc_h)\
$(gscms_h) $(gsicc_cache_h) $(gxdevsop_h) $(GDEV) $(DEVS_MAK) $(MAKEDIRS)
- $(DEVCC) $(I_)$(TI_)$(_I) $(DEVO_)gdevtsep.$(OBJ) $(C_) $(DEVSRC)gdevtsep.c
+ $(DEVCC) $(I_)$(TI_)$(_I) $(DEVO_)gdevtsep_0.$(OBJ) $(C_) $(DEVSRC)gdevtsep.c
+
+$(DEVOBJ)gdevtsep_1.$(OBJ) : $(DEVSRC)gdevtsep.c $(PDEVH) $(stdint__h)\
+ $(gdevtifs_h) $(gdevdevn_h) $(gxdevsop_h) $(gsequivc_h) $(stdio__h) $(ctype__h)\
+ $(gxdht_h) $(gxiodev_h) $(gxdownscale_h) $(gzht_h)\
+ $(gxgetbit_h) $(gdevppla_h) $(gp_h) $(gstiffio_h) $(gsicc_h) $(cal_h)\
+ $(gscms_h) $(gsicc_cache_h) $(gxdevsop_h) $(GDEV) $(DEVS_MAK) $(MAKEDIRS)
+ $(DEVCC) $(D_)WITH_CAL$(_D) $(I_)$(CALSRCDIR)$(_I) $(I_)$(TI_)$(_I) $(DEVO_)gdevtsep_1.$(OBJ) $(C_) $(DEVSRC)gdevtsep.c
+
+$(DEVOBJ)gdevtsep.$(OBJ) : $(DEVOBJ)gdevtsep_$(WITH_CAL).$(OBJ)
+ $(CP_) $(DEVOBJ)gdevtsep_$(WITH_CAL).$(OBJ) $(DEVOBJ)gdevtsep.$(OBJ)
+
# TIFF Scaled (downscaled gray -> mono), configurable compression
diff --git a/devices/gdevtsep.c b/devices/gdevtsep.c
index 88822ab..17e31b0 100644
--- a/devices/gdevtsep.c
+++ b/devices/gdevtsep.c
@@ -50,6 +50,9 @@
#include "gsicc_cache.h"
#include "gxdevsop.h"
#include "gsicc.h"
+#ifdef WITH_CAL
+#include "cal.h"
+#endif
/*
* Some of the code in this module is based upon the gdevtfnx.c module.
@@ -2577,6 +2580,26 @@ done:
return code;
}
+#ifdef WITH_CAL
+static void
+ht_callback(cal_halftone_data_t *ht, void *arg)
+{
+ tiffsep1_device *tfdev = (tiffsep1_device *)arg;
+ int num_std_colorants = tfdev->devn_params.num_std_colorant_names;
+ int num_order = tfdev->devn_params.num_separation_order_names;
+ int num_spot = tfdev->devn_params.separations.num_separations;
+ int comp_num;
+ int num_comp = number_output_separations(tfdev->color_info.num_components,
+ num_std_colorants, num_order, num_spot);
+ /* Deliberately cast away const, cos tifflib has a bad interface. */
+ unsigned char *data = (unsigned char *)ht->data;
+
+ for (comp_num = 0; comp_num < num_comp; comp_num++) {
+ TIFFWriteScanline(tfdev->tiff[comp_num], &data[ht->raster*comp_num], ht->y, 0);
+ }
+}
+#endif
+
/*
* Output the image data for the tiff separation (tiffsep1) device. The data
* for the tiffsep1 device is written in separate planes to separate files.
@@ -2708,9 +2731,47 @@ tiffsep1_print_page(gx_device_printer * pdev, gp_file * file)
int pixel, y;
gs_get_bits_params_t params;
gs_int_rect rect;
+
+#ifdef WITH_CAL
+ cal_context *cal = pdev->memory->gs_lib_ctx->core->cal_ctx;
+ cal_halftone *cal_ht = NULL;
+ cal_matrix matrix = { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f };
+
+ cal_ht = cal_halftone_init(cal,
+ pdev->memory->non_gc_memory,
+ pdev->width,
+ pdev->height,
+ &matrix,
+ comp_num,
+ NULL,
+ 0,
+ 0,
+ pdev->width,
+ pdev->height,
+ 0);
+ if (cal_ht == NULL) {
+ code = gs_error_VMerror;
+ goto done;
+ }
+
+ for (comp_num = 0; comp_num < num_comp; comp_num++) {
+ if (cal_halftone_add_screen(cal,
+ pdev->memory->non_gc_memory,
+ cal_ht,
+ 0,
+ tfdev->thresholds[comp_num].dwidth,
+ tfdev->thresholds[comp_num].dheight,
+ 0,
+ 0,
+ tfdev->thresholds[comp_num].dstart) < 0) {
+ goto cal_fail;
+ }
+ }
+#else
/* the dithered_line is assumed to be 32-bit aligned by the alloc */
uint32_t *dithered_line = (uint32_t *)gs_alloc_bytes(pdev->memory, dithered_raster,
"tiffsep1_print_page");
+#endif
memset(planes, 0, sizeof(*planes) * GS_CLIENT_COLOR_MAX_COMPONENTS);
@@ -2731,7 +2792,11 @@ tiffsep1_print_page(gx_device_printer * pdev, gp_file * file)
}
}
- if (code < 0 || dithered_line == NULL) {
+ if (code < 0
+#ifndef WITH_CAL
+ || dithered_line == NULL
+#endif
+ ) {
code = gs_note_error(gs_error_VMerror);
goto cleanup;
}
@@ -2752,6 +2817,14 @@ tiffsep1_print_page(gx_device_printer * pdev, gp_file * file)
if (code < 0)
break;
+#ifdef WITH_CAL
+ if (cal_halftone_process_planar(cal_ht,
+ pdev->memory->non_gc_memory,
+ ¶ms.data[0],
+ ht_callback,
+ tfdev) < 0)
+ goto cal_fail;
+#else
/* Dither the separation and write it out */
for (comp_num = 0; comp_num < num_comp; comp_num++ ) {
@@ -2767,8 +2840,8 @@ tiffsep1_print_page(gx_device_printer * pdev, gp_file * file)
* 27% faster.
*/
#define USE_32_BIT_WRITES
- int threshline = tfdev->thresholds[comp_num].dheight - 1 -
- (y % tfdev->thresholds[comp_num].dheight);
+ int threshline = tfdev->thresholds[comp_num].dheight - 1 -
+ (y % tfdev->thresholds[comp_num].dheight);
byte *thresh_line_base = tfdev->thresholds[comp_num].dstart +
( threshline * tfdev->thresholds[comp_num].dwidth) ;
byte *thresh_ptr = thresh_line_base;
@@ -2819,6 +2892,7 @@ tiffsep1_print_page(gx_device_printer * pdev, gp_file * file)
#endif /* SKIP_HALFTONING_FOR_TIMING */
TIFFWriteScanline(tfdev->tiff[comp_num], (tdata_t)dithered_line, y, 0);
} /* end component loop */
+#endif
}
/* Update the strip data */
for (comp_num = 0; comp_num < num_comp; comp_num++ ) {
@@ -2841,9 +2915,19 @@ tiffsep1_print_page(gx_device_printer * pdev, gp_file * file)
}
code = code1;
+#ifdef WITH_CAL
+ if(0) {
+cal_fail:
+ code = gs_error_unknownerror;
+ }
+ cal_halftone_fin(cal_ht, pdev->memory->non_gc_memory);
+#endif
+
/* free any allocations and exit with code */
cleanup:
+#ifndef WITH_CAL
gs_free_object(pdev->memory, dithered_line, "tiffsep1_print_page");
+#endif
for (comp_num = 0; comp_num < num_comp; comp_num++) {
gs_free_object(pdev->memory, planes[comp_num], "tiffsep1_print_page");
}
Summary of changes:
devices/devs.mak | 15 +++++++--
devices/gdevtsep.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 100 insertions(+), 5 deletions(-)