Ignore:
Timestamp:
Aug 27, 2010, 11:00:52 AM (11 years ago)
Author:
Silvan Scherrer
Message:

poppler update to 0.14.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/poppler/mypoppler/poppler/DCTStream.cc

    r277 r461  
    66//
    77// Copyright 2005 Jeff Muizelaar <jeff@infidigm.net>
    8 // Copyright 2005-2009 Albert Astals Cid <aacid@kde.org>
     8// Copyright 2005-2010 Albert Astals Cid <aacid@kde.org>
    99// Copyright 2009 Ryszard Trojnacki <rysiek@menel.com>
     10// Copyright 2010 Carlos Garcia Campos <carlosgc@gnome.org>
    1011//
    1112//========================================================================
     
    2122  int c;
    2223  struct str_src_mgr * src = (struct str_src_mgr *)cinfo->src;
    23   if (src->abort) return FALSE;
    2424  if (src->index == 0) {
    2525    c = 0xFF;
     
    6060DCTStream::DCTStream(Stream *strA, int colorXformA) :
    6161  FilterStream(strA) {
     62  colorXform = colorXformA;
    6263  init();
    6364}
     
    7172  j_decompress_ptr cinfo = (j_decompress_ptr)error;
    7273  str_src_mgr * src = (struct str_src_mgr *)cinfo->src;
    73   src->abort = true;
     74  longjmp(src->setjmp_buffer, 1);
    7475}
    7576
     
    8788  src.str = str;
    8889  src.index = 0;
    89   src.abort = false;
    9090  current = NULL;
    9191  limit = NULL;
     
    123123      {
    124124        error(-1, "Could not find start of jpeg data");
    125         src.abort = true;
    126125        return;
    127126      }
     
    140139  }
    141140
    142   jpeg_read_header(&cinfo, TRUE);
    143   if (src.abort) return;
    144 
    145   if (!jpeg_start_decompress(&cinfo))
    146   {
    147     src.abort = true;
    148     return;
    149   }
    150 
    151   row_stride = cinfo.output_width * cinfo.output_components;
    152   row_buffer = cinfo.mem->alloc_sarray((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
     141  if (!setjmp(src.setjmp_buffer)) {
     142    jpeg_read_header(&cinfo, TRUE);
     143
     144    // figure out color transform
     145    if (colorXform == -1 && !cinfo.saw_Adobe_marker) {
     146      if (cinfo.num_components == 3) {
     147        if (cinfo.saw_JFIF_marker) {
     148          colorXform = 1;
     149        } else if (cinfo.cur_comp_info[0]->component_id == 82 &&
     150                   cinfo.cur_comp_info[1]->component_id == 71 &&
     151                   cinfo.cur_comp_info[2]->component_id == 66) { // ASCII "RGB"
     152          colorXform = 0;
     153        } else {
     154          colorXform = 1;
     155        }
     156      } else {
     157        colorXform = 0;
     158      }
     159    } else if (cinfo.saw_Adobe_marker) {
     160      colorXform = cinfo.Adobe_transform;
     161    }
     162
     163    switch (cinfo.num_components) {
     164    case 3:
     165            cinfo.jpeg_color_space = colorXform ? JCS_YCbCr : JCS_RGB;
     166            break;
     167    case 4:
     168            cinfo.jpeg_color_space = colorXform ? JCS_YCCK : JCS_CMYK;
     169            break;
     170    }
     171
     172    jpeg_start_decompress(&cinfo);
     173
     174    row_stride = cinfo.output_width * cinfo.output_components;
     175    row_buffer = cinfo.mem->alloc_sarray((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
     176  }
    153177}
    154178
    155179int DCTStream::getChar() {
    156   if (src.abort) return EOF;
    157  
    158180  int c;
    159181
     
    161183    if (cinfo.output_scanline < cinfo.output_height)
    162184    {
    163       if (!jpeg_read_scanlines(&cinfo, row_buffer, 1)) return EOF;
    164       current = &row_buffer[0][0];
    165       limit = &row_buffer[0][(cinfo.output_width - 1) * cinfo.output_components] + cinfo.output_components;
     185      if (!setjmp(src.setjmp_buffer))
     186      {
     187        if (!jpeg_read_scanlines(&cinfo, row_buffer, 1)) return EOF;
     188        current = &row_buffer[0][0];
     189        limit = &row_buffer[0][(cinfo.output_width - 1) * cinfo.output_components] + cinfo.output_components;
     190      }
     191      else return EOF;
    166192    }
    167193    else return EOF;
     
    173199
    174200int DCTStream::lookChar() {
    175   if (src.abort) return EOF;
    176  
    177201  return *current;
    178202}
Note: See TracChangeset for help on using the changeset viewer.