~ubuntu-branches/debian/squeeze/ghostscript/squeeze

« back to all changes in this revision

Viewing changes to jbig2dec/jbig2_page.c

  • Committer: Bazaar Package Importer
  • Author(s): Masayuki Hatta (mhatta)
  • Date: 2009-01-04 12:09:59 UTC
  • mfrom: (16.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20090104120959-m9lbagj775ucg0h3
Tags: 8.63.dfsg.1-2
libgs-dev: put versioned dependency on libgs8 - closes: #510691

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
    Artifex Software, Inc.,  101 Lucas Valley Road #110,
14
14
    San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15
15
 
16
 
    $Id: jbig2_page.c 8320 2007-10-25 22:14:22Z giles $
 
16
    $Id: jbig2_page.c 8778 2008-05-26 19:04:05Z giles $
17
17
*/
18
18
 
19
19
#ifdef HAVE_CONFIG_H
194
194
 *
195
195
 * called upon seeing an 'end of page' segment, this routine
196
196
 * marks a page as completed so it can be returned.
197
 
 * compositing will have already happened in the previous 
 
197
 * compositing will have already happened in the previous
198
198
 * segment handlers.
199
199
 **/
200
200
int
201
201
jbig2_complete_page (Jbig2Ctx *ctx)
202
202
{
 
203
 
 
204
    /* check for unfinished segments */
 
205
    if (ctx->segment_index != ctx->n_segments) {
 
206
      Jbig2Segment *segment = ctx->segments[ctx->segment_index];
 
207
      int code = 0;
 
208
      /* Some versions of Xerox Workcentre generate PDF files
 
209
         with the segment data length field of the last segment
 
210
         set to -1. Try to cope with this here. */
 
211
      if ((segment->data_length & 0xffffffff) == 0xffffffff) {
 
212
        jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number,
 
213
          "File has an invalid segment data length!"
 
214
          " Trying to decode using the available data.");
 
215
        segment->data_length = ctx->buf_wr_ix - ctx->buf_rd_ix;
 
216
        code = jbig2_parse_segment(ctx, segment, ctx->buf + ctx->buf_rd_ix);
 
217
        ctx->buf_rd_ix += segment->data_length;
 
218
        ctx->segment_index++;
 
219
      }
 
220
    }
203
221
    ctx->pages[ctx->current_page].state = JBIG2_PAGE_COMPLETE;
204
222
 
205
223
    return 0;