~ubuntu-branches/ubuntu/jaunty/ghostscript/jaunty-updates

« back to all changes in this revision

Viewing changes to base/gxsamplp.h

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2009-01-20 16:40:45 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120164045-lnfhi0n30o5lwhwa
Tags: 8.64.dfsg.1~svn9377-0ubuntu1
* New upstream release (SVN rev 9377)
   o Fixes many bugs concerning PDF rendering, to make the PDF printing
     workflow correctly working.
   o Fixes long-standing bugs in many drivers, like input paper tray and
     duplex options not working for the built-in PCL 4, 5, 5c, 5e, and
     6/XL drivers, PDF input not working for bjc600, bjc800, and cups
     output devices, several options not working and uninitialized
     memory with cups output device.
   o Merged nearly all patches of the Ubuntu and Debian packages upstream.
   o Fixes LP: #317810, LP: #314439, LP: #314018.
* debian/patches/03_libpaper_support.dpatch,
  debian/patches/11_gs-cjk_font_glyph_handling_fix.dpatch,
  debian/patches/12_gs-cjk_vertical_writing_metrics_fix.dpatch,
  debian/patches/13_gs-cjk_cjkps_examples.dpatch,
  debian/patches/20_bbox_segv_fix.dpatch,
  debian/patches/21_brother_7x0_gdi_fix.dpatch,
  debian/patches/22_epsn_margin_workaround.dpatch,
  debian/patches/24_gs_man_fix.dpatch,
  debian/patches/25_toolbin_insecure_tmp_usage_fix.dpatch,
  debian/patches/26_assorted_script_fixes.dpatch,
  debian/patches/29_gs_css_fix.dpatch,
  debian/patches/30_ps2pdf_man_improvement.dpatch,
  debian/patches/31_fix-gc-sigbus.dpatch,
  debian/patches/34_ftbfs-on-hurd-fix.dpatch,
  debian/patches/35_disable_libcairo.dpatch,
  debian/patches/38_pxl-duplex.dpatch,
  debian/patches/39_pxl-resolution.dpatch,
  debian/patches/42_gs-init-ps-delaybind-fix.dpatch,
  debian/patches/45_bjc600-bjc800-pdf-input.dpatch,
  debian/patches/48_cups-output-device-pdf-duplex-uninitialized-memory-fix.dpatch,
  debian/patches/50_lips4-floating-point-exception.dpatch,
  debian/patches/52_cups-device-logging.dpatch,
  debian/patches/55_pcl-input-slot-fix.dpatch,
  debian/patches/57_pxl-input-slot-fix.dpatch,
  debian/patches/60_pxl-cups-driver-pdf.dpatch,
  debian/patches/62_onebitcmyk-pdf.dpatch,
  debian/patches/65_too-big-temp-files-1.dpatch,
  debian/patches/67_too-big-temp-files-2.dpatch,
  debian/patches/70_take-into-account-data-in-stream-buffer-before-refill.dpatch:
  Removed, applied upstream.
* debian/patches/01_docdir_fix_for_debian.dpatch,
  debian/patches/02_gs_man_fix_debian.dpatch,
  debian/patches/01_docdir-fix-for-debian.dpatch,
  debian/patches/02_docdir-fix-for-debian.dpatch: Renamed patches to
  make merging with Debian easier.
* debian/patches/32_improve-handling-of-media-size-changes-from-gv.dpatch, 
  debian/patches/33_bad-params-to-xinitimage-on-large-bitmaps.dpatch:
  regenerated for new source directory structure.
* debian/rules: Corrected paths to remove cidfmap (it is in Resource/Init/
  in GS 8.64) and to install headers (source paths are psi/ and base/ now).
* debian/rules: Remove all fontmaps, as DeFoMa replaces them.
* debian/local/pdftoraster/pdftoraster.c,
  debian/local/pdftoraster/pdftoraster.convs, debian/rules: Removed
  added pdftoraster filter and use the one which comes with Ghostscript.
* debian/ghostscript.links: s/8.63/8.64/

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
 
2
   All Rights Reserved.
 
3
  
 
4
   This software is provided AS-IS with no warranty, either express or
 
5
   implied.
 
6
 
 
7
   This software is distributed under license and may not be copied, modified
 
8
   or distributed except as expressly authorized under the terms of that
 
9
   license.  Refer to licensing information at http://www.artifex.com/
 
10
   or contact Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134,
 
11
   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
 
12
*/
 
13
 
 
14
/* $Id: gxsamplp.h 8766 2008-05-21 19:46:43Z giles $ */
 
15
/* Templates for sample lookup and expansion */
 
16
 
 
17
/* This module is allowed to include several times into a single .c file. 
 
18
   The following macros to be defined in advance :
 
19
        MULTIPLE_MAPS - 1 if num_components_per_plane > 0 and 
 
20
                        components use different maps, 0 otherwise.
 
21
        TEMPLATE_sample_unpack_1 - a name for the function
 
22
        TEMPLATE_sample_unpack_2 - a name for the function
 
23
        TEMPLATE_sample_unpack_4 - a name for the function
 
24
        TEMPLATE_sample_unpack_8 - a name for the function
 
25
 */
 
26
 
 
27
#if MULTIPLE_MAPS
 
28
#   define NEXT_MAP map = smap[++smap_index % num_components_per_plane].table.lookup4x1to32
 
29
#   define NEXT_MAP8 map = smap[++smap_index % num_components_per_plane].table.lookup8
 
30
#   define DEFINE_SMAP_INDEX int smap_index = 0;
 
31
#else
 
32
#   define NEXT_MAP
 
33
#   define NEXT_MAP8
 
34
#   define DEFINE_SMAP_INDEX
 
35
#endif
 
36
 
 
37
const byte *
 
38
TEMPLATE_sample_unpack_1(byte * bptr, int *pdata_x, const byte * data, int data_x,
 
39
                uint dsize, const sample_map *smap, int spread,
 
40
                int num_components_per_plane)
 
41
{
 
42
    const sample_lookup_t * ptab = &smap->table;
 
43
    const byte *psrc = data + (data_x >> 3);
 
44
    int left = dsize - (data_x >> 3);
 
45
    DEFINE_SMAP_INDEX
 
46
 
 
47
    if (spread == 1) {
 
48
        bits32 *bufp = (bits32 *) bptr;
 
49
        const bits32 *map = &ptab->lookup4x1to32[0];
 
50
        uint b;
 
51
 
 
52
        if (left & 1) {
 
53
            b = psrc[0];
 
54
            bufp[0] = map[b >> 4];
 
55
            NEXT_MAP;
 
56
            bufp[1] = map[b & 0xf];
 
57
            NEXT_MAP;
 
58
            psrc++, bufp += 2;
 
59
        }
 
60
        left >>= 1;
 
61
        while (left--) {
 
62
            b = psrc[0];
 
63
            bufp[0] = map[b >> 4];
 
64
            NEXT_MAP;
 
65
            bufp[1] = map[b & 0xf];
 
66
            NEXT_MAP;
 
67
            b = psrc[1];
 
68
            bufp[2] = map[b >> 4];
 
69
            NEXT_MAP;
 
70
            bufp[3] = map[b & 0xf];
 
71
            NEXT_MAP;
 
72
            psrc += 2, bufp += 4;
 
73
        }
 
74
    } else {
 
75
        byte *bufp = bptr;
 
76
        const byte *map = &ptab->lookup8[0];
 
77
 
 
78
        while (left--) {
 
79
            uint b = *psrc++;
 
80
 
 
81
            *bufp = map[b >> 7];
 
82
            NEXT_MAP8;
 
83
            bufp += spread;
 
84
            *bufp = map[(b >> 6) & 1];
 
85
            NEXT_MAP8;
 
86
            bufp += spread;
 
87
            *bufp = map[(b >> 5) & 1];
 
88
            NEXT_MAP8;
 
89
            bufp += spread;
 
90
            *bufp = map[(b >> 4) & 1];
 
91
            NEXT_MAP8;
 
92
            bufp += spread;
 
93
            *bufp = map[(b >> 3) & 1];
 
94
            NEXT_MAP8;
 
95
            bufp += spread;
 
96
            *bufp = map[(b >> 2) & 1];
 
97
            NEXT_MAP8;
 
98
            bufp += spread;
 
99
            *bufp = map[(b >> 1) & 1];
 
100
            NEXT_MAP8;
 
101
            bufp += spread;
 
102
            *bufp = map[b & 1];
 
103
            NEXT_MAP8;
 
104
            bufp += spread;
 
105
        }
 
106
    }
 
107
    *pdata_x = data_x & 7;
 
108
    return bptr;
 
109
}
 
110
 
 
111
#undef NEXT_MAP
 
112
 
 
113
#if MULTIPLE_MAPS
 
114
#   define NEXT_MAP  map = smap[++smap_index % num_components_per_plane].table.lookup2x2to16
 
115
#else
 
116
#   define NEXT_MAP
 
117
#endif
 
118
 
 
119
const byte *
 
120
TEMPLATE_sample_unpack_2(byte * bptr, int *pdata_x, const byte * data, int data_x,
 
121
                uint dsize, const sample_map *smap, int spread,
 
122
                int num_components_per_plane)
 
123
{
 
124
    const sample_lookup_t * ptab = &smap->table;
 
125
    const byte *psrc = data + (data_x >> 2);
 
126
    int left = dsize - (data_x >> 2);
 
127
    DEFINE_SMAP_INDEX
 
128
 
 
129
    if (spread == 1) {
 
130
        bits16 *bufp = (bits16 *) bptr;
 
131
        const bits16 *map = &ptab->lookup2x2to16[0];
 
132
 
 
133
        while (left--) {
 
134
            uint b = *psrc++;
 
135
 
 
136
            *bufp++ = map[b >> 4];
 
137
            NEXT_MAP;
 
138
            *bufp++ = map[b & 0xf];
 
139
            NEXT_MAP;
 
140
        }
 
141
    } else {
 
142
        byte *bufp = bptr;
 
143
        const byte *map = &ptab->lookup8[0];
 
144
 
 
145
        while (left--) {
 
146
            unsigned b = *psrc++;
 
147
 
 
148
            *bufp = map[b >> 6];
 
149
            NEXT_MAP8;
 
150
            bufp += spread;
 
151
            *bufp = map[(b >> 4) & 3];
 
152
            NEXT_MAP8;
 
153
            bufp += spread;
 
154
            *bufp = map[(b >> 2) & 3];
 
155
            NEXT_MAP8;
 
156
            bufp += spread;
 
157
            *bufp = map[b & 3];
 
158
            NEXT_MAP8;
 
159
            bufp += spread;
 
160
        }
 
161
    }
 
162
    *pdata_x = data_x & 3;
 
163
    return bptr;
 
164
}
 
165
 
 
166
#undef NEXT_MAP
 
167
 
 
168
const byte *
 
169
TEMPLATE_sample_unpack_4(byte * bptr, int *pdata_x, const byte * data, int data_x,
 
170
                uint dsize, const sample_map *smap, int spread,
 
171
                int num_components_per_plane)
 
172
{
 
173
    const sample_lookup_t * ptab = &smap->table;
 
174
    byte *bufp = bptr;
 
175
    const byte *psrc = data + (data_x >> 1);
 
176
    int left = dsize - (data_x >> 1);
 
177
    const byte *map = &ptab->lookup8[0];
 
178
    DEFINE_SMAP_INDEX
 
179
 
 
180
    while (left--) {
 
181
        uint b = *psrc++;
 
182
 
 
183
        *bufp = map[b >> 4];
 
184
        NEXT_MAP8;
 
185
        bufp += spread;
 
186
        *bufp = map[b & 0xf];
 
187
        NEXT_MAP8;
 
188
        bufp += spread;
 
189
    }
 
190
    *pdata_x = data_x & 1;
 
191
    return bptr;
 
192
}
 
193
 
 
194
const byte *
 
195
TEMPLATE_sample_unpack_8(byte * bptr, int *pdata_x, const byte * data, int data_x,
 
196
                uint dsize, const sample_map *smap, int spread,
 
197
                int num_components_per_plane)
 
198
{
 
199
    const sample_lookup_t * ptab = &smap->table;
 
200
    byte *bufp = bptr;
 
201
    const byte *psrc = data + data_x;
 
202
    DEFINE_SMAP_INDEX
 
203
 
 
204
    *pdata_x = 0;
 
205
    if (spread == 1) {
 
206
        if (MULTIPLE_MAPS ||
 
207
            ptab->lookup8[0] != 0 ||
 
208
            ptab->lookup8[255] != 255
 
209
            ) {
 
210
            uint left = dsize - data_x;
 
211
            const byte *map = &ptab->lookup8[0];
 
212
 
 
213
            while (left--) {
 
214
                *bufp++ = map[*psrc++];
 
215
                NEXT_MAP8;
 
216
            }
 
217
        } else {                /* No copying needed, and we'll use the data right away. */
 
218
            return psrc;
 
219
        }
 
220
    } else {
 
221
        int left = dsize - data_x;
 
222
        const byte *map = &ptab->lookup8[0];
 
223
 
 
224
        for (; left--; psrc++, bufp += spread) {
 
225
            *bufp = map[*psrc];
 
226
            NEXT_MAP8;
 
227
        }
 
228
    }
 
229
    return bptr;
 
230
}
 
231
 
 
232
#undef NEXT_MAP
 
233
#undef NEXT_MAP8
 
234
#undef DEFINE_SMAP_INDEX