~ubuntu-branches/ubuntu/utopic/ghostscript/utopic-proposed

« back to all changes in this revision

Viewing changes to debian/patches/020140331-41ab485-pxl-transform-deep-images-with-icc-transform-to-emit-high-level-images.patch

  • Committer: Package Import Robot
  • Author(s): Till Kamppeter
  • Date: 2014-03-31 18:24:33 UTC
  • Revision ID: package-import@ubuntu.com-20140331182433-h4hi1ud2b70gu2jj
Tags: 9.10~dfsg-0ubuntu10
* debian/patches/1001_pxlcolor-support-jpeg-in-output.patch,
  debian/patches/020140331-4b44b41-pxlcolor-support-jpeg-in-output.patch:
  Replaced preliminary patch by what got actually committed upstream
  (Upstream bug #691880).
* debian/patches/020140331-41ab485-pxl-transform-deep-images-with-icc-transform-to-emit-high-level-images.patch,
  debian/patches/020140331-8ae4ee2-fixes-pxl-segfault-with-trying-to-set-up-icc-transform-for-bitmasks.patch:
  Transform deep (24-bit) images with an ICC transform to emit high-level
  images (Upstream bug #691880).
* debian/patches/1002_pxl-make-dicctransform-default.patch: Make deep iamge
  ICC transform default (Upstream bug #695124).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--- a/devices/vector/gdevpx.c
 
2
+++ b/devices/vector/gdevpx.c
 
3
@@ -38,6 +38,7 @@
 
4
 #include "gxlum.h"
 
5
 #include "gdevpcl.h" /* for gdev_pcl_mode3compress() */
 
6
 #include "gsicc_manage.h"
 
7
+#include "gsicc_cache.h"
 
8
 #include <stdlib.h> /* abs() */
 
9
 
 
10
 /* ---------------- Device definition ---------------- */
 
11
@@ -108,6 +109,7 @@
 
12
     floatp y_scale;
 
13
     bool pen_null;
 
14
     bool brush_null;
 
15
+    bool iccTransform;
 
16
 } gx_device_pclxl;
 
17
 
 
18
 gs_public_st_suffix_add0_final(st_device_pclxl, gx_device_pclxl,
 
19
@@ -349,6 +351,22 @@
 
20
              index == gs_color_space_index_ICC);
 
21
 }
 
22
 
 
23
+/* Test whether we can icclink-transform an image. */
 
24
+static bool
 
25
+pclxl_can_icctransform(const gs_image_t * pim)
 
26
+{
 
27
+    const gs_color_space *pcs = pim->ColorSpace;
 
28
+    int bits_per_pixel =
 
29
+       (pim->ImageMask ? 1 :
 
30
+        pim->BitsPerComponent * gs_color_space_num_components(pcs));
 
31
+
 
32
+    if ((gs_color_space_get_index(pcs) == gs_color_space_index_ICC)
 
33
+       && (bits_per_pixel == 24))
 
34
+       return true;
 
35
+
 
36
+    return false;
 
37
+}
 
38
+
 
39
 /* Set brush, pen, and mode for painting a path. */
 
40
 static void
 
41
 pclxl_set_paints(gx_device_pclxl * xdev, gx_path_type_t type)
 
42
@@ -1533,6 +1551,7 @@
 
43
     xdev->MediaPosition = eAutoSelect;
 
44
     xdev->MediaType_old[0] = '\0';
 
45
     xdev->MediaType[0] = '\0';
 
46
+    /* xdev->iccTransform = false; */ /* set true/false here to ignore command line */
 
47
     return 0;
 
48
 }
 
49
 
 
50
@@ -1893,6 +1912,7 @@
 
51
         uint raster;
 
52
     } rows;
 
53
     bool flipped;
 
54
+  gsicc_link_t *icclink;
 
55
 } pclxl_image_enum_t;
 
56
 gs_private_st_suffix_add1(st_pclxl_image_enum, pclxl_image_enum_t,
 
57
                           "pclxl_image_enum_t", pclxl_image_enum_enum_ptrs,
 
58
@@ -1939,9 +1959,10 @@
 
59
          !((mat.xx == 0) && (mat.yy == 0) && (mat.xy * mat.yx != 0))) ||
 
60
         (pim->ImageMask ?
 
61
          (!gx_dc_is_pure(pdcolor) || pim->CombineWithColor) :
 
62
-         (!pclxl_can_handle_color_space(pim->ColorSpace) ||
 
63
-          (bits_per_pixel != 1 && bits_per_pixel != 4 &&
 
64
-           bits_per_pixel != 8 && bits_per_pixel !=24))) ||
 
65
+         ((!pclxl_can_handle_color_space(pcs) ||
 
66
+           (bits_per_pixel != 1 && bits_per_pixel != 4 &&
 
67
+            bits_per_pixel != 8 && bits_per_pixel !=24))
 
68
+          && !(pclxl_can_icctransform(pim) && xdev->iccTransform) )) ||
 
69
         format != gs_image_format_chunky || pim->Interpolate ||
 
70
         prect
 
71
         )
 
72
@@ -2047,6 +2068,17 @@
 
73
     pie->rows.num_rows = num_rows;
 
74
     pie->rows.first_y = 0;
 
75
     pie->rows.raster = row_raster;
 
76
+    if (!pclxl_can_handle_color_space(pcs)
 
77
+       && pclxl_can_icctransform(pim) && pcs->cmm_icc_profile_data) {
 
78
+       gsicc_rendering_param_t rendering_params;
 
79
+
 
80
+       rendering_params.black_point_comp = pis->blackptcomp;
 
81
+       rendering_params.graphics_type_tag = GS_IMAGE_TAG;
 
82
+       rendering_params.rendering_intent = pis->renderingintent;
 
83
+       pie->icclink = gsicc_get_link(pis, dev, pcs, NULL /*des */ ,
 
84
+                                     &rendering_params, pis->memory);
 
85
+    } else
 
86
+       pie->icclink = NULL;
 
87
     *pinfo = (gx_image_enum_common_t *) pie;
 
88
     {
 
89
         gs_logical_operation_t lop = pis->log_op;
 
90
@@ -2188,11 +2220,12 @@
 
91
         px_put_ub(s, eBit_values[8]);
 
92
         PX_PUT_LIT(s, ci_);
 
93
         if (xdev->color_info.depth==8) {
 
94
+          rows_raster/=3;
 
95
+          if (!pie->icclink) {
 
96
           byte *in=pie->rows.data + offset_lastflippedstrip;
 
97
           byte *out=pie->rows.data + offset_lastflippedstrip;
 
98
           int i;
 
99
           int j;
 
100
-          rows_raster/=3;
 
101
           for (j=0;  j<h;  j++) {
 
102
             for (i=0;  i<rows_raster;  i++) {
 
103
               *out = (byte)( ((*(in+0) * (ulong) lum_red_weight) +
 
104
@@ -2203,6 +2236,7 @@
 
105
               out++;
 
106
             }
 
107
           }
 
108
+          }
 
109
         }
 
110
     } else {
 
111
         static const byte ii_[] = {
 
112
@@ -2245,10 +2279,32 @@
 
113
                 return code;
 
114
             pie->rows.first_y = pie->y;
 
115
         }
 
116
+        if (!pie->icclink)
 
117
         memcpy(pie->rows.data +
 
118
                  pie->rows.raster * (pie->flipped ? (pie->rows.num_rows - (pie->y - pie->rows.first_y) -1) :(pie->y - pie->rows.first_y)),
 
119
                planes[0].data + planes[0].raster * i + (data_bit >> 3),
 
120
                pie->rows.raster);
 
121
+        else {
 
122
+          gsicc_bufferdesc_t input_buff_desc;
 
123
+          gsicc_bufferdesc_t output_buff_desc;
 
124
+          int pixels_per_row = pie->rows.raster / 3 ;
 
125
+          int out_raster_stride = pixels_per_row * info->dev->color_info.num_components;
 
126
+          gsicc_init_buffer(&input_buff_desc, 3 /*num_chan*/, 1 /*bytes_per_chan*/,
 
127
+                            false/*has_alpha*/, false/*alpha_first*/, false /*is_planar*/,
 
128
+                            0 /*plane_stride*/, pie->rows.raster /*row_stride*/,
 
129
+                            1/*num_rows*/, pixels_per_row /*pixels_per_row*/);
 
130
+          gsicc_init_buffer(&output_buff_desc, info->dev->color_info.num_components, 1,
 
131
+                            false, false, false,
 
132
+                            0, out_raster_stride,
 
133
+                            1, pixels_per_row);
 
134
+          gscms_transform_color_buffer(info->dev, pie->icclink,
 
135
+                                       &input_buff_desc,
 
136
+                                       &output_buff_desc,
 
137
+                                       (void *)(planes[0].data + planes[0].raster * i + (data_bit >> 3)), /*src*/
 
138
+                                       pie->rows.data +
 
139
+                                       out_raster_stride * (pie->flipped ? (pie->rows.num_rows - (pie->y - pie->rows.first_y) -1) : (pie->y - pie->rows.first_y)) /*des*/
 
140
+                                       );
 
141
+        }
 
142
     }
 
143
     *rows_used = height;
 
144
     return pie->y >= pie->height;
 
145
@@ -2341,6 +2397,9 @@
 
146
                               &(xdev->CompressMode))) < 0)
 
147
     return (code);
 
148
 
 
149
+  if ((code = param_write_bool(plist, "iccTransform", &(xdev->iccTransform))) < 0)
 
150
+    return (code);
 
151
+
 
152
   return (0);
 
153
 }
 
154
 
 
155
@@ -2446,6 +2505,7 @@
 
156
   }
 
157
   booloption(Tumble, "Tumble")
 
158
   intoption(CompressMode, "CompressMode", int)
 
159
+  booloption(iccTransform, "iccTransform")
 
160
 
 
161
  /*
 
162
   * Then process standard page device parameters...