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

« back to all changes in this revision

Viewing changes to src/gdevjbig2.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: gdevjbig2.c 6300 2005-12-28 19:56:24Z giles $ */
15
 
/* JBIG2 encode filter test device */
16
 
 
17
 
#include "gdevprn.h"
18
 
#include "stream.h"
19
 
#include "strimpl.h"
20
 
#include "sjbig2_luratech.h"
21
 
 
22
 
 
23
 
/* Structure for the JBIG2-writing device. */
24
 
typedef struct gx_device_jbig2_s {
25
 
    gx_device_common;
26
 
    gx_prn_device_common;
27
 
} gx_device_jbig2;
28
 
 
29
 
/* The device descriptor */
30
 
static dev_proc_print_page(jbig2_print_page);
31
 
 
32
 
/* ------ The device descriptors ------ */
33
 
 
34
 
/* Default X and Y resolution. */
35
 
#ifndef X_DPI
36
 
#  define X_DPI 72
37
 
#endif
38
 
#ifndef Y_DPI
39
 
#  define Y_DPI 72
40
 
#endif
41
 
 
42
 
static dev_proc_print_page(jbig2_print_page);
43
 
 
44
 
/* Monochrome only */
45
 
 
46
 
const gx_device_printer gs_gdevjbig2_device =
47
 
prn_device(prn_std_procs, "jbig2",
48
 
        DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
49
 
        X_DPI, Y_DPI,   /* resolution */
50
 
        0, 0, 0, 0,     /* margins */
51
 
        1, jbig2_print_page);
52
 
 
53
 
 
54
 
/* Send the page to the file. */
55
 
static int
56
 
jbig2_print_page(gx_device_printer * pdev, FILE * prn_stream)
57
 
{
58
 
    gx_device_jbig2 *jdev = (gx_device_jbig2 *) pdev;
59
 
    gs_memory_t *mem = jdev->memory;
60
 
    int line_size = gdev_mem_bytes_per_scan_line((gx_device *) pdev);
61
 
    byte *in = gs_alloc_bytes(mem, line_size, "jbig2_print_page(in)");
62
 
    byte *fbuf = 0;
63
 
    uint fbuf_size;
64
 
    byte *jbuf = 0;
65
 
    uint jbuf_size;
66
 
    int lnum;
67
 
    int code = 0;
68
 
    stream_jbig2encode_state state;
69
 
    stream fstrm, cstrm;
70
 
 
71
 
    if (in == 0) {
72
 
        code = gs_note_error(gs_error_VMerror);
73
 
        goto fail;
74
 
    }
75
 
    /* Create the jbig2encode state. */
76
 
    s_init_state((stream_state *)&state, &s_jbig2encode_template, 0);
77
 
    if (state.template->set_defaults)
78
 
        (*state.template->set_defaults) ((stream_state *) & state);
79
 
    state.width = jdev->width;
80
 
    state.height = jdev->height;
81
 
    /* Set up the streams. */
82
 
    fbuf_size = max(512 /* arbitrary */ , state.template->min_out_size);
83
 
    jbuf_size = state.template->min_in_size;
84
 
    if ((fbuf = gs_alloc_bytes(mem, fbuf_size, "jbig2_print_page(fbuf)")) == 0 ||
85
 
        (jbuf = gs_alloc_bytes(mem, jbuf_size, "jbig2_print_page(jbuf)")) == 0
86
 
        ) {
87
 
        code = gs_note_error(gs_error_VMerror);
88
 
        goto done;
89
 
    }
90
 
    s_init(&fstrm, mem);
91
 
    swrite_file(&fstrm, prn_stream, fbuf, fbuf_size);
92
 
    s_init(&cstrm, mem);
93
 
    s_std_init(&cstrm, jbuf, jbuf_size, &s_filter_write_procs,
94
 
               s_mode_write);
95
 
    cstrm.state = (stream_state *) & state;
96
 
    cstrm.procs.process = state.template->process;
97
 
    cstrm.strm = &fstrm;
98
 
    if (state.template->init)
99
 
        (*state.template->init) (cstrm.state);
100
 
 
101
 
    /* Copy the data to the output. */
102
 
    for (lnum = 0; lnum < jdev->height; ++lnum) {
103
 
        byte *data;
104
 
        uint ignore_used;
105
 
 
106
 
        if (cstrm.end_status) {
107
 
            code = gs_note_error(gs_error_ioerror);
108
 
            goto done;
109
 
        }
110
 
        gdev_prn_get_bits(pdev, lnum, in, &data);
111
 
        sputs(&cstrm, data, state.stride, &ignore_used);
112
 
    }
113
 
 
114
 
    /* Wrap up. */
115
 
    sclose(&cstrm);
116
 
    sflush(&fstrm);
117
 
  done:
118
 
    gs_free_object(mem, jbuf, "jbig2_print_page(jbuf)");
119
 
    gs_free_object(mem, fbuf, "jbig2_print_page(fbuf)");
120
 
    gs_free_object(mem, in, "jbig2_print_page(in)");
121
 
    return code;
122
 
  fail:
123
 
    gs_free_object(mem, in, "jbig2_print_page(in)");
124
 
    return code;
125
 
}