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

« back to all changes in this revision

Viewing changes to src/gxctable.c

  • 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: gxctable.c 8250 2007-09-25 13:31:24Z giles $ */
15
 
/* Color table lookup and interpolation */
16
 
#include "gx.h"
17
 
#include "gxfixed.h"
18
 
#include "gxfrac.h"
19
 
#include "gxctable.h"
20
 
 
21
 
/* See gxctable.h for the API and structure definitions. */
22
 
 
23
 
/*
24
 
 * Define an implementation that simply picks the nearest value without
25
 
 * any interpolation.
26
 
 */
27
 
void
28
 
gx_color_interpolate_nearest(const fixed * pi,
29
 
                             const gx_color_lookup_table * pclt, frac * pv)
30
 
{
31
 
    const int *pdim = pclt->dims;
32
 
    int m = pclt->m;
33
 
    const gs_const_string *table = pclt->table;
34
 
 
35
 
    if (pclt->n > 3) {
36
 
        table += fixed2int_var_rounded(pi[0]) * pdim[1];
37
 
        ++pi, ++pdim;
38
 
    } {
39
 
        int ic = fixed2int_var_rounded(pi[2]);
40
 
        int ib = fixed2int_var_rounded(pi[1]);
41
 
        int ia = fixed2int_var_rounded(pi[0]);
42
 
        const byte *p = pclt->table[ia].data + (ib * pdim[2] + ic) * m;
43
 
        int j;
44
 
 
45
 
        for (j = 0; j < m; ++j, ++p)
46
 
            pv[j] = byte2frac(*p);
47
 
    }
48
 
}
49
 
 
50
 
/*
51
 
 * Define an implementation that uses trilinear interpolation.
52
 
 */
53
 
static void
54
 
interpolate_accum(const fixed * pi, const gx_color_lookup_table * pclt,
55
 
                  frac * pv, fixed factor)
56
 
{
57
 
    const int *pdim = pclt->dims;
58
 
    int m = pclt->m;
59
 
 
60
 
    if (pclt->n > 3) {
61
 
        /* Do two 3-D interpolations, interpolating between them. */
62
 
        gx_color_lookup_table clt3;
63
 
        int ix = fixed2int_var(pi[0]);
64
 
        fixed fx = fixed_fraction(pi[0]);
65
 
 
66
 
        clt3.n = 3;
67
 
        clt3.dims[0] = pdim[1]; /* needed only for range checking */
68
 
        clt3.dims[1] = pdim[2];
69
 
        clt3.dims[2] = pdim[3];
70
 
        clt3.m = m;
71
 
        clt3.table = pclt->table + ix * pdim[1];
72
 
        interpolate_accum(pi + 1, &clt3, pv, fixed_1);
73
 
        if (ix == pdim[0] - 1)
74
 
            return;
75
 
        clt3.table += pdim[1];
76
 
        interpolate_accum(pi + 1, &clt3, pv, fx);
77
 
    } else {
78
 
        int ic = fixed2int_var(pi[2]);
79
 
        fixed fc = fixed_fraction(pi[2]);
80
 
        uint dc1 = (ic == pdim[2] - 1 ? 0 : m);
81
 
        int ib = fixed2int_var(pi[1]);
82
 
        fixed fb = fixed_fraction(pi[1]);
83
 
        uint db1 = (ib == pdim[1] - 1 ? 0 : pdim[2] * m);
84
 
        uint dbc = (ib * pdim[2] + ic) * m;
85
 
        uint dbc1 = db1 + dc1;
86
 
        int ia = fixed2int_var(pi[0]);
87
 
        fixed fa = fixed_fraction(pi[0]);
88
 
        const byte *pa0 = pclt->table[ia].data + dbc;
89
 
        const byte *pa1 =
90
 
            (ia == pdim[0] - 1 ? pa0 : pclt->table[ia + 1].data + dbc);
91
 
        int j;
92
 
 
93
 
        /* The values to be interpolated are */
94
 
        /* pa{0,1}[{0,db1,dc1,dbc1}]. */
95
 
        for (j = 0; j < m; ++j, ++pa0, ++pa1) {
96
 
            frac v000 = byte2frac(pa0[0]);
97
 
            frac v001 = byte2frac(pa0[dc1]);
98
 
            frac v010 = byte2frac(pa0[db1]);
99
 
            frac v011 = byte2frac(pa0[dbc1]);
100
 
            frac v100 = byte2frac(pa1[0]);
101
 
            frac v101 = byte2frac(pa1[dc1]);
102
 
            frac v110 = byte2frac(pa1[db1]);
103
 
            frac v111 = byte2frac(pa1[dbc1]);
104
 
            frac rv;
105
 
 
106
 
            frac v00 = v000 +
107
 
                (frac) arith_rshift((long)fc * (v001 - v000),
108
 
                                    _fixed_shift);
109
 
            frac v01 = v010 +
110
 
                (frac) arith_rshift((long)fc * (v011 - v010),
111
 
                                    _fixed_shift);
112
 
            frac v10 = v100 +
113
 
                (frac) arith_rshift((long)fc * (v101 - v100),
114
 
                                    _fixed_shift);
115
 
            frac v11 = v110 +
116
 
                (frac) arith_rshift((long)fc * (v111 - v110),
117
 
                                    _fixed_shift);
118
 
 
119
 
            frac v0 = v00 +
120
 
                (frac) arith_rshift((long)fb * (v01 - v00),
121
 
                                    _fixed_shift);
122
 
            frac v1 = v10 +
123
 
                (frac) arith_rshift((long)fb * (v11 - v10),
124
 
                                    _fixed_shift);
125
 
 
126
 
            rv = v0 +
127
 
                (frac) arith_rshift((long)fa * (v1 - v0),
128
 
                                    _fixed_shift);
129
 
            if (factor == fixed_1)
130
 
                pv[j] = rv;
131
 
            else
132
 
                pv[j] += (frac) arith_rshift((long)factor * (rv - pv[j]),
133
 
                                             _fixed_shift);
134
 
        }
135
 
    }
136
 
}
137
 
void
138
 
gx_color_interpolate_linear(const fixed * pi,
139
 
                            const gx_color_lookup_table * pclt, frac * pv)
140
 
{
141
 
    interpolate_accum(pi, pclt, pv, fixed_1);
142
 
}