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

« back to all changes in this revision

Viewing changes to src/zfilter2.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: zfilter2.c 8250 2007-09-25 13:31:24Z giles $ */
15
 
/* Additional filter creation */
16
 
#include "memory_.h"
17
 
#include "ghost.h"
18
 
#include "oper.h"
19
 
#include "gsstruct.h"
20
 
#include "ialloc.h"
21
 
#include "idict.h"
22
 
#include "idparam.h"
23
 
#include "store.h"
24
 
#include "strimpl.h"
25
 
#include "sfilter.h"
26
 
#include "scfx.h"
27
 
#include "slzwx.h"
28
 
#include "spdiffx.h"
29
 
#include "spngpx.h"
30
 
#include "ifilter.h"
31
 
#include "ifilter2.h"
32
 
#include "ifwpred.h"
33
 
 
34
 
/* ------ CCITTFaxEncode filter ------ */
35
 
 
36
 
/* <target> <dict> CCITTFaxEncode/filter <file> */
37
 
static int
38
 
zCFE(i_ctx_t *i_ctx_p)
39
 
{
40
 
    os_ptr op = osp;
41
 
    stream_CFE_state cfs;
42
 
    int code;
43
 
 
44
 
    check_type(*op, t_dictionary);
45
 
    check_dict_read(*op);
46
 
    code = zcf_setup(op, (stream_CF_state *)&cfs, iimemory);
47
 
    if (code < 0)
48
 
        return code;
49
 
    return filter_write(i_ctx_p, 0, &s_CFE_template, (stream_state *)&cfs, 0);
50
 
}
51
 
 
52
 
/* ------ Common setup for possibly pixel-oriented encoding filters ------ */
53
 
 
54
 
int
55
 
filter_write_predictor(i_ctx_t *i_ctx_p, int npop,
56
 
                       const stream_template * template, stream_state * st)
57
 
{
58
 
    os_ptr op = osp;
59
 
    int predictor, code;
60
 
    stream_PDiff_state pds;
61
 
    stream_PNGP_state pps;
62
 
 
63
 
    if (r_has_type(op, t_dictionary)) {
64
 
        if ((code = dict_int_param(op, "Predictor", 0, 15, 1, &predictor)) < 0)
65
 
            return code;
66
 
        switch (predictor) {
67
 
            case 0:             /* identity */
68
 
                predictor = 1;
69
 
            case 1:             /* identity */
70
 
                break;
71
 
            case 2:             /* componentwise horizontal differencing */
72
 
                code = zpd_setup(op, &pds);
73
 
                break;
74
 
            case 10:
75
 
            case 11:
76
 
            case 12:
77
 
            case 13:
78
 
            case 14:
79
 
            case 15:
80
 
                /* PNG prediction */
81
 
                code = zpp_setup(op, &pps);
82
 
                break;
83
 
            default:
84
 
                return_error(e_rangecheck);
85
 
        }
86
 
        if (code < 0)
87
 
            return code;
88
 
    } else
89
 
        predictor = 1;
90
 
    if (predictor == 1)
91
 
        return filter_write(i_ctx_p, npop, template, st, 0);
92
 
    {
93
 
        /* We need to cascade filters. */
94
 
        ref rtarget, rdict;
95
 
        int code;
96
 
 
97
 
        /* Save the operands, just in case. */
98
 
        ref_assign(&rtarget, op - 1);
99
 
        ref_assign(&rdict, op);
100
 
        code = filter_write(i_ctx_p, npop, template, st, 0);
101
 
        if (code < 0)
102
 
            return code;
103
 
        /* filter_write changed osp.... */
104
 
        op = osp;
105
 
        code =
106
 
            (predictor == 2 ?
107
 
             filter_write(i_ctx_p, 0, &s_PDiffE_template, (stream_state *)&pds, 0) :
108
 
             filter_write(i_ctx_p, 0, &s_PNGPE_template, (stream_state *)&pps, 0));
109
 
        if (code < 0) {
110
 
            /* Restore the operands.  Don't bother trying to clean up */
111
 
            /* the first stream. */
112
 
            osp = ++op;
113
 
            ref_assign(op - 1, &rtarget);
114
 
            ref_assign(op, &rdict);
115
 
            return code;
116
 
        }
117
 
        /*
118
 
         * Mark the compression stream as temporary, and propagate
119
 
         * CloseTarget from it to the predictor stream.
120
 
         */
121
 
        filter_mark_strm_temp(op, 2);
122
 
        return code;
123
 
    }
124
 
}
125
 
 
126
 
/* ------ LZW encoding filter ------ */
127
 
 
128
 
/* <target> LZWEncode/filter <file> */
129
 
/* <target> <dict> LZWEncode/filter <file> */
130
 
static int
131
 
zLZWE(i_ctx_t *i_ctx_p)
132
 
{
133
 
    os_ptr op = osp;
134
 
    stream_LZW_state lzs;
135
 
    int code = zlz_setup(op, &lzs);
136
 
 
137
 
    if (code < 0)
138
 
        return code;
139
 
    return filter_write_predictor(i_ctx_p, 0, &s_LZWE_template,
140
 
                                  (stream_state *) & lzs);
141
 
}
142
 
 
143
 
/* ================ Initialization procedure ================ */
144
 
 
145
 
const op_def zfilter2_op_defs[] =
146
 
{
147
 
    op_def_begin_filter(),
148
 
    {"2CCITTFaxEncode", zCFE},
149
 
    {"1LZWEncode", zLZWE},
150
 
    op_def_end(0)
151
 
};