Ticket #1249: libpng.diff

File libpng.diff, 76.9 KB (added by ekdahl, 12 years ago)
  • src/libs/png/pngerror.c

     
    11
    22/* pngerror.c - stub functions for i/o and memory allocation
    33 *
    4  * Last changed in libpng 1.2.9 April 14, 2006
     4 * Last changed in libpng 1.2.13 November 13, 2006
    55 * For conditions of distribution and use, see copyright notice in png.h
    66 * Copyright (c) 1998-2006 Glenn Randers-Pehrson
    77 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
     
    113113 * if the character is invalid.
    114114 */
    115115#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
    116 static PNG_CONST char png_digit[16] = {
     116const static PNG_CONST char png_digit[16] = {
    117117   '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
    118118   'A', 'B', 'C', 'D', 'E', 'F'
    119119};
     
    157157   char msg[18+64];
    158158   if (png_ptr == NULL)
    159159     png_error(png_ptr, error_message);
    160    png_format_buffer(png_ptr, msg, error_message);
    161    png_error(png_ptr, msg);
     160   else
     161   {
     162     png_format_buffer(png_ptr, msg, error_message);
     163     png_error(png_ptr, msg);
     164   }
    162165}
    163166
    164167void PNGAPI
     
    167170   char msg[18+64];
    168171   if (png_ptr == NULL)
    169172     png_warning(png_ptr, warning_message);
    170    png_format_buffer(png_ptr, msg, warning_message);
    171    png_warning(png_ptr, msg);
     173   else
     174   {
     175     png_format_buffer(png_ptr, msg, warning_message);
     176     png_warning(png_ptr, msg);
     177   }
    172178}
    173179
    174180/* This is the default error handling function.  Note that replacements for
     
    206212#endif
    207213
    208214#ifdef PNG_SETJMP_SUPPORTED
     215   if (png_ptr)
     216   {
    209217#  ifdef USE_FAR_KEYWORD
    210218   {
    211219      jmp_buf jmpbuf;
     
    214222   }
    215223#  else
    216224   longjmp(png_ptr->jmpbuf, 1);
    217 # endif
     225#  endif
     226   }
    218227#else
    219    /* make compiler happy */ ;
    220    if (png_ptr)
    221228   PNG_ABORT();
    222229#endif
    223230#ifdef PNG_NO_CONSOLE_IO
  • src/libs/png/pngrio.c

     
    11
    22/* pngrio.c - functions for data input
    33 *
    4  * Last changed in libpng 1.2.9 April 14, 2006
     4 * Last changed in libpng 1.2.13 November 13, 2006
    55 * For conditions of distribution and use, see copyright notice in png.h
    66 * Copyright (c) 1998-2006 Glenn Randers-Pehrson
    77 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
     
    4646{
    4747   png_size_t check;
    4848
     49   if(png_ptr == NULL) return;
    4950   /* fread() returns 0 on error, so it is OK to store this in a png_size_t
    5051    * instead of an int, which is what fread() actually returns.
    5152    */
     
    7677   png_byte *n_data;
    7778   png_FILE_p io_ptr;
    7879
     80   if(png_ptr == NULL) return;
    7981   /* Check if data really is near. If so, use usual code. */
    8082   n_data = (png_byte *)CVT_PTR_NOCHECK(data);
    8183   io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
     
    136138png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
    137139   png_rw_ptr read_data_fn)
    138140{
     141   if(png_ptr == NULL) return;
    139142   png_ptr->io_ptr = io_ptr;
    140143
    141144#if !defined(PNG_NO_STDIO)
  • src/libs/png/pngwrite.c

     
    11
    22/* pngwrite.c - general routines to write a PNG file
    33 *
    4  * Last changed in libpng 1.2.9 April 14, 2006
     4 * Last changed in libpng 1.2.15 January 5, 2007
    55 * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2006 Glenn Randers-Pehrson
     6 * Copyright (c) 1998-2007 Glenn Randers-Pehrson
    77 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    88 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
    99 */
     
    461461
    462462#if !defined(PNG_1_0_X)
    463463#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
     464#ifdef PNG_MMX_CODE_SUPPORTED
    464465   png_init_mmx_flags(png_ptr);   /* 1.2.0 addition */
    465466#endif
     467#endif
    466468#endif /* PNG_1_0_X */
    467469
    468470   /* added at libpng-1.2.6 */
     
    576578   png_size_t png_struct_size, png_size_t png_info_size)
    577579{
    578580   /* We only come here via pre-1.0.12-compiled applications */
     581   if(png_ptr == NULL) return;
    579582#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
    580583   if(png_sizeof(png_struct) > png_struct_size ||
    581584      png_sizeof(png_info) > png_info_size)
     
    670673
    671674#if !defined(PNG_1_0_X)
    672675#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
     676#ifdef PNG_MMX_CODE_SUPPORTED
    673677   png_init_mmx_flags(png_ptr);   /* 1.2.0 addition */
    674678#endif
     679#endif
    675680#endif /* PNG_1_0_X */
    676681
    677682#ifdef PNG_SETJMP_SUPPORTED
  • src/libs/png/pngpread.c

     
    11
    22/* pngpread.c - read a png file in push mode
    33 *
    4  * Last changed in libpng 1.2.11 - June 7, 2004
     4 * Last changed in libpng 1.2.17 May 15, 2007
    55 * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2006 Glenn Randers-Pehrson
     6 * Copyright (c) 1998-2007 Glenn Randers-Pehrson
    77 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    88 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
    99 */
     
    2828png_process_data(png_structp png_ptr, png_infop info_ptr,
    2929   png_bytep buffer, png_size_t buffer_size)
    3030{
     31   if(png_ptr == NULL) return;
    3132   png_push_restore_buffer(png_ptr, buffer, buffer_size);
    3233
    3334   while (png_ptr->buffer_size)
     
    4243void /* PRIVATE */
    4344png_process_some_data(png_structp png_ptr, png_infop info_ptr)
    4445{
     46   if(png_ptr == NULL) return;
    4547   switch (png_ptr->process_mode)
    4648   {
    4749      case PNG_READ_SIG_MODE:
     
    561563{
    562564   png_bytep ptr;
    563565
     566   if(png_ptr == NULL) return;
    564567   ptr = buffer;
    565568   if (png_ptr->save_buffer_size)
    566569   {
     
    14851488#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
    14861489   if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS)
    14871490   {
    1488        png_unknown_chunk chunk;
    1489 
    14901491#ifdef PNG_MAX_MALLOC_64K
    14911492       if (length > (png_uint_32)65535L)
    14921493       {
     
    14951496           length = (png_uint_32)65535L;
    14961497       }
    14971498#endif
    1498 
    1499        png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name);
    1500        chunk.data = (png_bytep)png_malloc(png_ptr, length);
    1501        png_crc_read(png_ptr, chunk.data, length);
    1502        chunk.size = length;
     1499       png_strcpy((png_charp)png_ptr->unknown_chunk.name,
     1500         (png_charp)png_ptr->chunk_name);
     1501       png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length);
     1502       png_ptr->unknown_chunk.size = (png_size_t)length;
     1503       png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length);
    15031504#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
    15041505       if(png_ptr->read_user_chunk_fn != NULL)
    15051506       {
    15061507          /* callback to user unknown chunk handler */
    1507           if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0)
     1508          int ret;
     1509          ret = (*(png_ptr->read_user_chunk_fn))
     1510            (png_ptr, &png_ptr->unknown_chunk);
     1511          if (ret < 0)
     1512             png_chunk_error(png_ptr, "error in user chunk");
     1513          if (ret == 0)
    15081514          {
    15091515             if (!(png_ptr->chunk_name[0] & 0x20))
    15101516                if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
    15111517                     PNG_HANDLE_CHUNK_ALWAYS)
    15121518                   png_chunk_error(png_ptr, "unknown critical chunk");
     1519                png_set_unknown_chunks(png_ptr, info_ptr,
     1520                   &png_ptr->unknown_chunk, 1);
    15131521          }
    1514              png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
    15151522       }
    1516        else
     1523#else
     1524       png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1);
    15171525#endif
    1518           png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
    1519        png_free(png_ptr, chunk.data);
     1526       png_free(png_ptr, png_ptr->unknown_chunk.data);
     1527       png_ptr->unknown_chunk.data = NULL;
    15201528   }
    15211529   else
    15221530#endif
     
    15541562   const int FARDATA png_pass_dsp_mask[7] =
    15551563      {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
    15561564#endif
     1565   if(png_ptr == NULL) return;
    15571566   if (new_row != NULL)    /* new_row must == png_ptr->row_buf here. */
    15581567      png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]);
    15591568}
     
    15631572   png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
    15641573   png_progressive_end_ptr end_fn)
    15651574{
     1575   if(png_ptr == NULL) return;
    15661576   png_ptr->info_fn = info_fn;
    15671577   png_ptr->row_fn = row_fn;
    15681578   png_ptr->end_fn = end_fn;
     
    15731583png_voidp PNGAPI
    15741584png_get_progressive_ptr(png_structp png_ptr)
    15751585{
     1586   if(png_ptr == NULL) return (NULL);
    15761587   return png_ptr->io_ptr;
    15771588}
    15781589#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
  • src/libs/png/pngset.c

     
    11
    22/* pngset.c - storage of image information into info struct
    33 *
    4  * Last changed in libpng 1.2.9 April 14, 2006
     4 * Last changed in libpng 1.2.17 May 15, 2007
    55 * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2006 Glenn Randers-Pehrson
     6 * Copyright (c) 1998-2007 Glenn Randers-Pehrson
    77 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    88 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
    99 *
     
    877877         textp->itxt_length = 0;
    878878#endif
    879879      }
     880#if 0 /* appears to be redundant; */
    880881      info_ptr->text[info_ptr->num_text]= *textp;
     882#endif
    881883      info_ptr->num_text++;
    882884      png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text);
    883885   }
     
    976978        /* TODO: use png_malloc_warn */
    977979        png_strcpy(to->name, from->name);
    978980        to->entries = (png_sPLT_entryp)png_malloc(png_ptr,
    979             from->nentries * png_sizeof(png_sPLT_t));
     981            from->nentries * png_sizeof(png_sPLT_entry));
    980982        /* TODO: use png_malloc_warn */
    981983        png_memcpy(to->entries, from->entries,
    982             from->nentries * png_sizeof(png_sPLT_t));
     984            from->nentries * png_sizeof(png_sPLT_entry));
    983985        to->nentries = from->nentries;
    984986        to->depth = from->depth;
    985987    }
     
    11911193void PNGAPI
    11921194png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags)
    11931195{
     1196#ifdef PNG_MMX_CODE_SUPPORTED
    11941197    png_uint_32 settable_asm_flags;
    11951198    png_uint_32 settable_mmx_flags;
    1196 
     1199#endif
    11971200    if (png_ptr == NULL)
    11981201       return;
     1202#ifdef PNG_MMX_CODE_SUPPORTED
    11991203
    12001204    settable_mmx_flags =
    1201 #ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
     1205#ifdef PNG_HAVE_MMX_COMBINE_ROW
    12021206                         PNG_ASM_FLAG_MMX_READ_COMBINE_ROW  |
    12031207#endif
    1204 #ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE
     1208#ifdef PNG_HAVE_MMX_READ_INTERLACE
    12051209                         PNG_ASM_FLAG_MMX_READ_INTERLACE    |
    12061210#endif
    1207 #ifdef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
     1211#ifdef PNG_HAVE_MMX_READ_FILTER_ROW
    12081212                         PNG_ASM_FLAG_MMX_READ_FILTER_SUB   |
    12091213                         PNG_ASM_FLAG_MMX_READ_FILTER_UP    |
    12101214                         PNG_ASM_FLAG_MMX_READ_FILTER_AVG   |
     
    12241228    }
    12251229
    12261230    /* we're replacing the settable bits with those passed in by the user,
    1227      * so first zero them out of the master copy, then logical-OR in the
     1231     * so first zero them out of the master copy, then bitwise-OR in the
    12281232     * allowed subset that was requested */
    12291233
    12301234    png_ptr->asm_flags &= ~settable_asm_flags;               /* zero them */
    12311235    png_ptr->asm_flags |= (asm_flags & settable_asm_flags);  /* set them */
     1236#endif /* ?PNG_MMX_CODE_SUPPORTED */
    12321237}
    1233 #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
    12341238
    1235 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
    12361239/* this function was added to libpng 1.2.0 */
    12371240void PNGAPI
    12381241png_set_mmx_thresholds (png_structp png_ptr,
     
    12411244{
    12421245    if (png_ptr == NULL)
    12431246       return;
     1247#ifdef PNG_MMX_CODE_SUPPORTED
    12441248    png_ptr->mmx_bitdepth_threshold = mmx_bitdepth_threshold;
    12451249    png_ptr->mmx_rowbytes_threshold = mmx_rowbytes_threshold;
     1250#endif /* ?PNG_MMX_CODE_SUPPORTED */
    12461251}
    12471252#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
    12481253
     
    12561261     * rejected by png_set_IHDR().  To accept any PNG datastream
    12571262     * regardless of dimensions, set both limits to 0x7ffffffL.
    12581263     */
     1264    if(png_ptr == NULL) return;
    12591265    png_ptr->user_width_max = user_width_max;
    12601266    png_ptr->user_height_max = user_height_max;
    12611267}
  • src/libs/png/LICENSE

     
    88If you modify libpng you may insert additional notices immediately following
    99this sentence.
    1010
    11 libpng versions 1.2.6, August 15, 2004, through 1.2.12, June 27, 2006, are
    12 Copyright (c) 2004, 2006 Glenn Randers-Pehrson, and are
     11libpng versions 1.2.6, August 15, 2004, through 1.2.18, May 15, 2007, are
     12Copyright (c) 2004, 2006-2007 Glenn Randers-Pehrson, and are
    1313distributed according to the same disclaimer and license as libpng-1.2.5
    1414with the following individual added to the list of Contributing Authors
    1515
     
    106106
    107107Glenn Randers-Pehrson
    108108glennrp at users.sourceforge.net
    109 June 27, 2006
     109May 15, 2007
  • src/libs/png/pngwio.c

     
    11
    22/* pngwio.c - functions for data output
    33 *
    4  * Last changed in libpng 1.2.3 - May 21, 2002
     4 * Last changed in libpng 1.2.13 November 13, 2006
    55 * For conditions of distribution and use, see copyright notice in png.h
    66 * Copyright (c) 1998-2002 Glenn Randers-Pehrson
    77 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
     
    4545{
    4646   png_uint_32 check;
    4747
     48   if(png_ptr == NULL) return;
    4849#if defined(_WIN32_WCE)
    4950   if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
    5051      check = 0;
     
    7071   png_byte *near_data;  /* Needs to be "png_byte *" instead of "png_bytep" */
    7172   png_FILE_p io_ptr;
    7273
     74   if(png_ptr == NULL) return;
    7375   /* Check if data really is near. If so, use usual code. */
    7476   near_data = (png_byte *)CVT_PTR_NOCHECK(data);
    7577   io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
     
    131133{
    132134#if !defined(_WIN32_WCE)
    133135   png_FILE_p io_ptr;
     136#endif
     137   if(png_ptr == NULL) return;
     138#if !defined(_WIN32_WCE)
    134139   io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
    135140   if (io_ptr != NULL)
    136141      fflush(io_ptr);
     
    165170png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
    166171   png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
    167172{
     173   if(png_ptr == NULL) return;
    168174   png_ptr->io_ptr = io_ptr;
    169175
    170176#if !defined(PNG_NO_STDIO)
  • src/libs/png/pngrutil.c

     
    11
    22/* pngrutil.c - utilities to read a PNG file
    33 *
    4  * Last changed in libpng 1.2.11 June 4, 2006
     4 * Last changed in libpng 1.2.17 May 15, 2007
    55 * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2006 Glenn Randers-Pehrson
     6 * Copyright (c) 1998-2007 Glenn Randers-Pehrson
    77 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    88 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
    99 *
     
    1616
    1717#if defined(PNG_READ_SUPPORTED)
    1818
    19 #if defined(_WIN32_WCE)
     19#ifdef PNG_FLOATING_POINT_SUPPORTED
     20#  if defined(_WIN32_WCE)
    2021/* strtod() function is not supported on WindowsCE */
    21 #  ifdef PNG_FLOATING_POINT_SUPPORTED
    22 __inline double strtod(const char *nptr, char **endptr)
     22__inline double png_strtod(png_structp png_ptr, const char *nptr, char **endptr)
    2323{
    2424   double result = 0;
    2525   int len;
    2626   wchar_t *str, *end;
    2727
    2828   len = MultiByteToWideChar(CP_ACP, 0, nptr, -1, NULL, 0);
    29    str = (wchar_t *)malloc(len * sizeof(wchar_t));
     29   str = (wchar_t *)png_malloc(png_ptr, len * sizeof(wchar_t));
    3030   if ( NULL != str )
    3131   {
    3232      MultiByteToWideChar(CP_ACP, 0, nptr, -1, str, len);
    3333      result = wcstod(str, &end);
    3434      len = WideCharToMultiByte(CP_ACP, 0, end, -1, NULL, 0, NULL, NULL);
    3535      *endptr = (char *)nptr + (png_strlen(nptr) - len + 1);
    36       free(str);
     36      png_free(str);
    3737   }
    3838   return result;
    3939}
     40#  else
     41#    define png_strtod(p,a,b) strtod(a,b)
    4042#  endif
    4143#endif
    4244
     
    9092void /* PRIVATE */
    9193png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length)
    9294{
     95   if(png_ptr == NULL) return;
    9396   png_read_data(png_ptr, buf, length);
    9497   png_calculate_crc(png_ptr, buf, length);
    9598}
     
    178181                              png_charp chunkdata, png_size_t chunklength,
    179182                              png_size_t prefix_size, png_size_t *newlength)
    180183{
    181    static char msg[] = "Error decoding compressed text";
     184   const static char msg[] = "Error decoding compressed text";
    182185   png_charp text;
    183186   png_size_t text_size;
    184187
     
    13111314   }
    13121315
    13131316   if (png_crc_finish(png_ptr, 0))
     1317   {
     1318      png_ptr->num_trans = 0;
    13141319      return;
     1320   }
    13151321
    13161322   png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans,
    13171323      &(png_ptr->trans_values));
     
    17301736   ep = buffer + 1;        /* skip unit byte */
    17311737
    17321738#ifdef PNG_FLOATING_POINT_SUPPORTED
    1733    width = strtod(ep, &vp);
     1739   width = png_strtod(png_ptr, ep, &vp);
    17341740   if (*vp)
    17351741   {
    17361742       png_warning(png_ptr, "malformed width string in sCAL chunk");
     
    17531759   ep++;
    17541760
    17551761#ifdef PNG_FLOATING_POINT_SUPPORTED
    1756    height = strtod(ep, &vp);
     1762   height = png_strtod(png_ptr, ep, &vp);
    17571763   if (*vp)
    17581764   {
    17591765       png_warning(png_ptr, "malformed height string in sCAL chunk");
     
    21702176   if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) ||
    21712177       (png_ptr->read_user_chunk_fn != NULL))
    21722178   {
    2173        png_unknown_chunk chunk;
    2174 
    21752179#ifdef PNG_MAX_MALLOC_64K
    21762180       if (length > (png_uint_32)65535L)
    21772181       {
     
    21802184           length = (png_uint_32)65535L;
    21812185       }
    21822186#endif
    2183        png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name);
    2184        chunk.data = (png_bytep)png_malloc(png_ptr, length);
    2185        chunk.size = (png_size_t)length;
    2186        png_crc_read(png_ptr, (png_bytep)chunk.data, length);
     2187       png_strcpy((png_charp)png_ptr->unknown_chunk.name,
     2188         (png_charp)png_ptr->chunk_name);
     2189       png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length);
     2190       png_ptr->unknown_chunk.size = (png_size_t)length;
     2191       png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length);
    21872192#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
    21882193       if(png_ptr->read_user_chunk_fn != NULL)
    21892194       {
    21902195          /* callback to user unknown chunk handler */
    2191           if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0)
     2196          int ret;
     2197          ret = (*(png_ptr->read_user_chunk_fn))
     2198            (png_ptr, &png_ptr->unknown_chunk);
     2199          if (ret < 0)
     2200             png_chunk_error(png_ptr, "error in user chunk");
     2201          if (ret == 0)
    21922202          {
    21932203             if (!(png_ptr->chunk_name[0] & 0x20))
    21942204                if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
    21952205                     PNG_HANDLE_CHUNK_ALWAYS)
    2196                  {
    2197                    png_free(png_ptr, chunk.data);
    21982206                   png_chunk_error(png_ptr, "unknown critical chunk");
    2199                  }
    2200              png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
     2207             png_set_unknown_chunks(png_ptr, info_ptr,
     2208               &png_ptr->unknown_chunk, 1);
    22012209          }
    22022210       }
    2203        else
     2211#else
     2212       png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1);
    22042213#endif
    2205           png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
    2206        png_free(png_ptr, chunk.data);
     2214       png_free(png_ptr, png_ptr->unknown_chunk.data);
     2215       png_ptr->unknown_chunk.data = NULL;
    22072216   }
    22082217   else
    22092218#endif
     
    22462255   a zero indicates the pixel is to be skipped.  This is in addition
    22472256   to any alpha or transparency value associated with the pixel.  If
    22482257   you want all pixels to be combined, pass 0xff (255) in mask.  */
    2249 #ifndef PNG_HAVE_ASSEMBLER_COMBINE_ROW
     2258#ifndef PNG_HAVE_MMX_COMBINE_ROW
    22502259void /* PRIVATE */
    22512260png_combine_row(png_structp png_ptr, png_bytep row, int mask)
    22522261{
     
    24472456      }
    24482457   }
    24492458}
    2450 #endif /* !PNG_HAVE_ASSEMBLER_COMBINE_ROW */
     2459#endif /* !PNG_HAVE_MMX_COMBINE_ROW */
    24512460
    24522461#ifdef PNG_READ_INTERLACING_SUPPORTED
    2453 #ifndef PNG_HAVE_ASSEMBLER_READ_INTERLACE   /* else in pngvcrd.c, pnggccrd.c */
     2462#ifndef PNG_HAVE_MMX_READ_INTERLACE   /* else in pngvcrd.c, pnggccrd.c */
    24542463/* OLD pre-1.0.9 interface:
    24552464void png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
    24562465   png_uint_32 transformations)
     
    26762685      return;
    26772686#endif
    26782687}
    2679 #endif /* !PNG_HAVE_ASSEMBLER_READ_INTERLACE */
     2688#endif /* !PNG_HAVE_MMX_READ_INTERLACE */
    26802689#endif /* PNG_READ_INTERLACING_SUPPORTED */
    26812690
    2682 #ifndef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
     2691#ifndef PNG_HAVE_MMX_READ_FILTER_ROW
    26832692void /* PRIVATE */
    26842693png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
    26852694   png_bytep prev_row, int filter)
     
    28022811         break;
    28032812   }
    28042813}
    2805 #endif /* !PNG_HAVE_ASSEMBLER_READ_FILTER_ROW */
     2814#endif /* !PNG_HAVE_MMX_READ_FILTER_ROW */
    28062815
    28072816void /* PRIVATE */
    28082817png_read_finish_row(png_structp png_ptr)
     
    31043113   if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L)
    31053114      png_error(png_ptr, "This image requires a row greater than 64KB");
    31063115#endif
    3107    if ((png_uint_32)png_ptr->rowbytes > PNG_SIZE_MAX - 1)
     3116   if ((png_uint_32)png_ptr->rowbytes > (png_uint_32)(PNG_SIZE_MAX - 1))
    31083117      png_error(png_ptr, "Row has too many bytes to allocate in memory.");
    31093118   png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)(
    31103119      png_ptr->rowbytes + 1));
  • src/libs/png/pngwutil.c

     
    11
    22/* pngwutil.c - utilities to write a PNG file
    33 *
    4  * Last changed in libpng 1.2.11 June 4, 2006
     4 * Last changed in libpng 1.2.15 January 5, 2007
    55 * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2006 Glenn Randers-Pehrson
     6 * Copyright (c) 1998-2007 Glenn Randers-Pehrson
    77 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    88 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
    99 */
     
    6262png_write_chunk(png_structp png_ptr, png_bytep chunk_name,
    6363   png_bytep data, png_size_t length)
    6464{
     65   if(png_ptr == NULL) return;
    6566   png_write_chunk_start(png_ptr, chunk_name, (png_uint_32)length);
    6667   png_write_chunk_data(png_ptr, data, length);
    6768   png_write_chunk_end(png_ptr);
     
    7778{
    7879   png_byte buf[4];
    7980   png_debug2(0, "Writing %s chunk (%lu bytes)\n", chunk_name, length);
     81   if(png_ptr == NULL) return;
    8082
    8183   /* write the length */
    8284   png_save_uint_32(buf, length);
     
    98100png_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length)
    99101{
    100102   /* write the data, and run the CRC over it */
     103   if(png_ptr == NULL) return;
    101104   if (data != NULL && length > 0)
    102105   {
    103106      png_calculate_crc(png_ptr, data, length);
     
    111114{
    112115   png_byte buf[4];
    113116
     117   if(png_ptr == NULL) return;
     118
    114119   /* write the crc */
    115120   png_save_uint_32(buf, png_ptr->crc);
    116121
     
    518523      png_ptr->zlib_window_bits = 15;
    519524   if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_METHOD))
    520525      png_ptr->zlib_method = 8;
    521    deflateInit2(&png_ptr->zstream, png_ptr->zlib_level,
     526   if (deflateInit2(&png_ptr->zstream, png_ptr->zlib_level,
    522527      png_ptr->zlib_method, png_ptr->zlib_window_bits,
    523       png_ptr->zlib_mem_level, png_ptr->zlib_strategy);
     528      png_ptr->zlib_mem_level, png_ptr->zlib_strategy) != Z_OK)
     529       png_error(png_ptr, "zlib failed to initialize compressor");
    524530   png_ptr->zstream.next_out = png_ptr->zbuf;
    525531   png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
    526532   /* libpng is not interested in zstream.data_type */
     
    728734   png_size_t name_len;
    729735   png_charp new_name;
    730736   compression_state comp;
     737   int embedded_profile_len = 0;
    731738
    732739   png_debug(1, "in png_write_iCCP\n");
    733740
     
    750757   if (profile == NULL)
    751758      profile_len = 0;
    752759
     760   if (profile_len > 3)
     761      embedded_profile_len =
     762          ((*( (png_bytep)profile  ))<<24) |
     763          ((*( (png_bytep)profile+1))<<16) |
     764          ((*( (png_bytep)profile+2))<< 8) |
     765          ((*( (png_bytep)profile+3))    );
     766
     767   if (profile_len < embedded_profile_len)
     768     {
     769        png_warning(png_ptr,
     770          "Embedded profile length too large in iCCP chunk");
     771        return;
     772     }
     773
     774   if (profile_len > embedded_profile_len)
     775     {
     776        png_warning(png_ptr,
     777          "Truncating profile to actual length in iCCP chunk");
     778        profile_len = embedded_profile_len;
     779     }
     780
    753781   if (profile_len)
    754782       profile_len = png_text_compress(png_ptr, profile, (png_size_t)profile_len,
    755783          PNG_COMPRESSION_TYPE_BASE, &comp);
  • src/libs/png/pngread.c

     
    11
    22/* pngread.c - read a PNG file
    33 *
    4  * Last changed in libpng 1.2.11 June 7, 2006
     4 * Last changed in libpng 1.2.15 January 5, 2007
    55 * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2006 Glenn Randers-Pehrson
     6 * Copyright (c) 1998-2007 Glenn Randers-Pehrson
    77 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    88 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
    99 *
     
    5656      return (NULL);
    5757
    5858#if !defined(PNG_1_0_X)
    59 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
     59#ifdef PNG_MMX_CODE_SUPPORTED
    6060   png_init_mmx_flags(png_ptr);   /* 1.2.0 addition */
    6161#endif
    6262#endif /* PNG_1_0_X */
     
    188188   png_size_t png_struct_size, png_size_t png_info_size)
    189189{
    190190   /* We only come here via pre-1.0.12-compiled applications */
     191   if(png_ptr == NULL) return;
    191192#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
    192193   if(png_sizeof(png_struct) > png_struct_size ||
    193194      png_sizeof(png_info) > png_info_size)
     
    239240
    240241   png_structp png_ptr=*ptr_ptr;
    241242
     243   if(png_ptr == NULL) return;
     244
    242245   do
    243246   {
    244247     if(user_png_ver[i] != png_libpng_ver[i])
     
    317320void PNGAPI
    318321png_read_info(png_structp png_ptr, png_infop info_ptr)
    319322{
     323   if(png_ptr == NULL) return;
    320324   png_debug(1, "in png_read_info\n");
    321325   /* If we haven't checked all of the PNG signature bytes, do so now. */
    322326   if (png_ptr->sig_bytes < 8)
     
    533537png_read_update_info(png_structp png_ptr, png_infop info_ptr)
    534538{
    535539   png_debug(1, "in png_read_update_info\n");
     540   if(png_ptr == NULL) return;
    536541   if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
    537542      png_read_start_row(png_ptr);
    538543   else
     
    551556png_start_read_image(png_structp png_ptr)
    552557{
    553558   png_debug(1, "in png_start_read_image\n");
     559   if(png_ptr == NULL) return;
    554560   if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
    555561      png_read_start_row(png_ptr);
    556562}
     
    566572   const int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
    567573#endif
    568574   int ret;
     575   if(png_ptr == NULL) return;
    569576   png_debug2(1, "in png_read_row (row %lu, pass %d)\n",
    570577      png_ptr->row_number, png_ptr->pass);
    571578   if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
     
    824831   png_bytepp dp;
    825832
    826833   png_debug(1, "in png_read_rows\n");
     834   if(png_ptr == NULL) return;
    827835   rp = row;
    828836   dp = display_row;
    829837   if (rp != NULL && dp != NULL)
     
    872880   png_bytepp rp;
    873881
    874882   png_debug(1, "in png_read_image\n");
     883   if(png_ptr == NULL) return;
    875884
    876885#ifdef PNG_READ_INTERLACING_SUPPORTED
    877886   pass = png_set_interlace_handling(png_ptr);
     
    910919   png_uint_32 length;
    911920
    912921   png_debug(1, "in png_read_end\n");
     922   if(png_ptr == NULL) return;
    913923   png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */
    914924
    915925   do
     
    13001310void PNGAPI
    13011311png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn)
    13021312{
     1313   if(png_ptr == NULL) return;
    13031314   png_ptr->read_row_fn = read_row_fn;
    13041315}
    13051316
     
    13131324{
    13141325   int row;
    13151326
     1327   if(png_ptr == NULL) return;
    13161328#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
    13171329   /* invert the alpha channel from opacity to transparency
    13181330    */
  • src/libs/png/pngmem.c

     
    11
    22/* pngmem.c - stub functions for memory allocation
    33 *
    4  * Last changed in libpng 1.2.9 April 14, 2006
     4 * Last changed in libpng 1.2.13 November 13, 2006
    55 * For conditions of distribution and use, see copyright notice in png.h
    66 * Copyright (c) 1998-2006 Glenn Randers-Pehrson
    77 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
     
    137137   png_voidp ret;
    138138#endif /* PNG_USER_MEM_SUPPORTED */
    139139
     140   if (png_ptr == NULL || size == 0)
     141      return (NULL);
     142
    140143#ifdef PNG_MAX_MALLOC_64K
    141144   if (size > (png_uint_32)65536L)
    142145   {
     
    290293{
    291294#endif /* PNG_USER_MEM_SUPPORTED */
    292295
     296   if(png_ptr == NULL) return;
     297
    293298   if (png_ptr->offset_table != NULL)
    294299   {
    295300      int i;
     
    536541png_malloc_warn(png_structp png_ptr, png_uint_32 size)
    537542{
    538543   png_voidp ptr;
    539    png_uint_32 save_flags=png_ptr->flags;
     544   png_uint_32 save_flags;
     545   if(png_ptr == NULL) return (NULL);
    540546
     547   save_flags=png_ptr->flags;
    541548   png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
    542549   ptr = (png_voidp)png_malloc((png_structp)png_ptr, size);
    543550   png_ptr->flags=save_flags;
     
    580587png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
    581588  malloc_fn, png_free_ptr free_fn)
    582589{
     590   if(png_ptr != NULL) {
    583591   png_ptr->mem_ptr = mem_ptr;
    584592   png_ptr->malloc_fn = malloc_fn;
    585593   png_ptr->free_fn = free_fn;
     594   }
    586595}
    587596
    588597/* This function returns a pointer to the mem_ptr associated with the user
     
    592601png_voidp PNGAPI
    593602png_get_mem_ptr(png_structp png_ptr)
    594603{
     604   if(png_ptr == NULL) return (NULL);
    595605   return ((png_voidp)png_ptr->mem_ptr);
    596606}
    597607#endif /* PNG_USER_MEM_SUPPORTED */
  • src/libs/png/pngget.c

     
    11
    22/* pngget.c - retrieval of values from info struct
    33 *
    4  * Last changed in libpng 1.2.9 April 14, 2006
     4 * Last changed in libpng 1.2.15 January 5, 2007
    55 * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2006 Glenn Randers-Pehrson
     6 * Copyright (c) 1998-2007 Glenn Randers-Pehrson
    77 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    88 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
    99 */
     
    829829}
    830830#endif
    831831
     832#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
    832833#ifndef PNG_1_0_X
    833 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
    834834/* this function was added to libpng 1.2.0 and should exist by default */
    835835png_uint_32 PNGAPI
    836836png_get_asm_flags (png_structp png_ptr)
    837837{
     838#ifdef PNG_MMX_CODE_SUPPORTED
    838839    return (png_uint_32)(png_ptr? png_ptr->asm_flags : 0L);
     840#else
     841    return (png_ptr? 0L: 0L);
     842#endif
    839843}
    840844
    841845/* this function was added to libpng 1.2.0 and should exist by default */
    842846png_uint_32 PNGAPI
    843847png_get_asm_flagmask (int flag_select)
    844848{
     849#ifdef PNG_MMX_CODE_SUPPORTED
    845850    png_uint_32 settable_asm_flags = 0;
    846851
    847852    if (flag_select & PNG_SELECT_READ)
     
    862867#endif /* 0 */
    863868
    864869    return settable_asm_flags;  /* _theoretically_ settable capabilities only */
     870#else
     871    return (0L);
     872#endif /* PNG_MMX_CODE_SUPPORTED */
    865873}
    866 #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
    867874
    868875
    869 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
    870876    /* GRR:  could add this:   && defined(PNG_MMX_CODE_SUPPORTED) */
    871877/* this function was added to libpng 1.2.0 */
    872878png_uint_32 PNGAPI
    873879png_get_mmx_flagmask (int flag_select, int *compilerID)
    874880{
     881#if defined(PNG_MMX_CODE_SUPPORTED)
    875882    png_uint_32 settable_mmx_flags = 0;
    876883
    877884    if (flag_select & PNG_SELECT_READ)
     
    902909    }
    903910
    904911    return settable_mmx_flags;  /* _theoretically_ settable capabilities only */
     912#else
     913    return (0L);
     914#endif /* ?PNG_MMX_CODE_SUPPORTED */
    905915}
    906916
    907917/* this function was added to libpng 1.2.0 */
    908918png_byte PNGAPI
    909919png_get_mmx_bitdepth_threshold (png_structp png_ptr)
    910920{
     921#if defined(PNG_MMX_CODE_SUPPORTED)
    911922    return (png_byte)(png_ptr? png_ptr->mmx_bitdepth_threshold : 0);
     923#else
     924    return (png_ptr? 0: 0);
     925#endif /* ?PNG_MMX_CODE_SUPPORTED */
    912926}
    913927
    914928/* this function was added to libpng 1.2.0 */
    915929png_uint_32 PNGAPI
    916930png_get_mmx_rowbytes_threshold (png_structp png_ptr)
    917931{
     932#if defined(PNG_MMX_CODE_SUPPORTED)
    918933    return (png_uint_32)(png_ptr? png_ptr->mmx_rowbytes_threshold : 0L);
     934#else
     935    return (png_ptr? 0L: 0L);
     936#endif /* ?PNG_MMX_CODE_SUPPORTED */
    919937}
     938#endif /* ?PNG_1_0_X */
    920939#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
    921 #endif /* ?PNG_1_0_X */
    922940
    923941#ifdef PNG_SET_USER_LIMITS_SUPPORTED
    924942/* these functions were added to libpng 1.2.6 */
  • src/libs/png/png.c

     
    11
    22/* png.c - location for general purpose libpng functions
    33 *
    4  * Last changed in libpng 1.2.9 April 14, 2006
     4 * Last changed in libpng 1.2.17 May 15, 2007
    55 * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2006 Glenn Randers-Pehrson
     6 * Copyright (c) 1998-2007 Glenn Randers-Pehrson
    77 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    88 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
    99 */
     
    1313#include "png.h"
    1414
    1515/* Generate a compiler error if there is an old png.h in the search path. */
    16 typedef version_1_2_12 Your_png_h_is_not_version_1_2_12;
     16typedef version_1_2_18 Your_png_h_is_not_version_1_2_18;
    1717
    1818/* Version information for C files.  This had better match the version
    1919 * string defined in png.h.  */
     
    6868const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
    6969
    7070/* width of interlace block (used in assembler routines only) */
    71 #ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
     71#ifdef PNG_HAVE_MMX_COMBINE_ROW
    7272const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1};
    7373#endif
    7474
     
    9797void PNGAPI
    9898png_set_sig_bytes(png_structp png_ptr, int num_bytes)
    9999{
     100   if(png_ptr == NULL) return;
    100101   png_debug(1, "in png_set_sig_bytes\n");
    101102   if (num_bytes > 8)
    102103      png_error(png_ptr, "Too many bytes for PNG signature.");
     
    153154png_zalloc(voidpf png_ptr, uInt items, uInt size)
    154155{
    155156   png_voidp ptr;
    156    png_structp p=png_ptr;
     157   png_structp p=(png_structp)png_ptr;
    157158   png_uint_32 save_flags=p->flags;
    158159   png_uint_32 num_bytes;
    159160
     161   if(png_ptr == NULL) return (NULL);
    160162   if (items > PNG_UINT_32_MAX/size)
    161163   {
    162      png_warning (png_ptr, "Potential overflow in png_zalloc()");
     164     png_warning (p, "Potential overflow in png_zalloc()");
    163165     return (NULL);
    164166   }
    165167   num_bytes = (png_uint_32)items * size;
     
    266268png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
    267269{
    268270   png_infop info_ptr = NULL;
     271   if(png_ptr == NULL) return;
    269272
    270273   png_debug(1, "in png_destroy_info_struct\n");
    271274   if (info_ptr_ptr != NULL)
     
    304307{
    305308   png_infop info_ptr = *ptr_ptr;
    306309
     310   if(info_ptr == NULL) return;
     311
    307312   png_debug(1, "in png_info_init_3\n");
    308313
    309314   if(png_sizeof(png_info) > png_info_struct_size)
     
    485490#endif
    486491
    487492#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
     493  if(png_ptr->unknown_chunk.data)
     494  {
     495    png_free(png_ptr, png_ptr->unknown_chunk.data);
     496    png_ptr->unknown_chunk.data = NULL;
     497  }
    488498#ifdef PNG_FREE_ME_SUPPORTED
    489499if ((mask & PNG_FREE_UNKN) & info_ptr->free_me)
    490500#else
     
    611621png_voidp PNGAPI
    612622png_get_io_ptr(png_structp png_ptr)
    613623{
     624   if(png_ptr == NULL) return (NULL);
    614625   return (png_ptr->io_ptr);
    615626}
    616627
     
    626637png_init_io(png_structp png_ptr, png_FILE_p fp)
    627638{
    628639   png_debug(1, "in png_init_io\n");
     640   if(png_ptr == NULL) return;
    629641   png_ptr->io_ptr = (png_voidp)fp;
    630642}
    631643#endif
     
    641653        {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
    642654         "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
    643655
     656   if(png_ptr == NULL) return (NULL);
    644657   if (png_ptr->time_buffer == NULL)
    645658   {
    646659      png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29*
     
    693706png_get_copyright(png_structp png_ptr)
    694707{
    695708   if (&png_ptr != NULL)  /* silence compiler warning about unused png_ptr */
    696    return ((png_charp) "\n libpng version 1.2.12 - June 27, 2006\n\
    697    Copyright (c) 1998-2006 Glenn Randers-Pehrson\n\
     709   return ((png_charp) "\n libpng version 1.2.18 - May 15, 2007\n\
     710   Copyright (c) 1998-2007 Glenn Randers-Pehrson\n\
    698711   Copyright (c) 1996-1997 Andreas Dilger\n\
    699712   Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n");
    700713   return ((png_charp) "");
     
    757770int PNGAPI
    758771png_reset_zstream(png_structp png_ptr)
    759772{
     773   if (png_ptr == NULL) return Z_STREAM_ERROR;
    760774   return (inflateReset(&png_ptr->zstream));
    761775}
    762776#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
     
    770784}
    771785
    772786
    773 #if defined(PNG_READ_SUPPORTED)
     787#if defined(PNG_READ_SUPPORTED) && defined(PNG_ASSEMBLER_CODE_SUPPORTED)
    774788#if !defined(PNG_1_0_X)
    775 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
    776     /* GRR:  could add this:   && defined(PNG_MMX_CODE_SUPPORTED) */
     789#if defined(PNG_MMX_CODE_SUPPORTED)
    777790/* this INTERNAL function was added to libpng 1.2.0 */
    778791void /* PRIVATE */
    779792png_init_mmx_flags (png_structp png_ptr)
    780793{
     794    if(png_ptr == NULL) return;
    781795    png_ptr->mmx_rowbytes_threshold = 0;
    782796    png_ptr->mmx_bitdepth_threshold = 0;
    783797
     
    787801
    788802    if (png_mmx_support() > 0) {
    789803        png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU
    790 #    ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
     804#    ifdef PNG_HAVE_MMX_COMBINE_ROW
    791805                              | PNG_ASM_FLAG_MMX_READ_COMBINE_ROW
    792806#    endif
    793 #    ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE
     807#    ifdef PNG_HAVE_MMX_READ_INTERLACE
    794808                              | PNG_ASM_FLAG_MMX_READ_INTERLACE
    795809#    endif
    796 #    ifndef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
     810#    ifndef PNG_HAVE_MMX_READ_FILTER_ROW
    797811                              ;
    798812#    else
    799813                              | PNG_ASM_FLAG_MMX_READ_FILTER_SUB
     
    810824                               | PNG_MMX_WRITE_FLAGS );
    811825    }
    812826
    813 #  else /* !((PNGVCRD || PNGGCCRD) && PNG_ASSEMBLER_CODE_SUPPORTED)) */
     827#  else /* !(PNGVCRD || PNGGCCRD) */
    814828
    815829    /* clear all MMX flags; no support is compiled in */
    816830    png_ptr->asm_flags &= ~( PNG_MMX_FLAGS );
     
    818832#  endif /* ?(PNGVCRD || PNGGCCRD) */
    819833}
    820834
    821 #endif /* !(PNG_ASSEMBLER_CODE_SUPPORTED) */
     835#endif /* !(PNG_MMX_CODE_SUPPORTED) */
    822836
    823837/* this function was added to libpng 1.2.0 */
    824838#if !defined(PNG_USE_PNGGCCRD) && \
    825     !(defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD))
     839    !(defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD))
    826840int PNGAPI
    827841png_mmx_support(void)
    828842{
    829843    return -1;
    830844}
    831845#endif
    832 #endif /* PNG_1_0_X */
     846#endif /* PNG_1_0_X  && PNG_ASSEMBLER_CODE_SUPPORTED */
    833847#endif /* PNG_READ_SUPPORTED */
    834848
    835849#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
  • src/libs/png/Jamfile

     
    33SetSubDirSupportedPlatformsBeOSCompatible ;
    44AddSubDirSupportedPlatforms libbe_test ;
    55
    6 UseLibraryHeaders zlib ;
     6UseLibraryHeaders png zlib ;
    77
    8 local shared_files = 
     8local shared_files =
    99    png.c
    1010    pngerror.c
    1111    pnggccrd.c
  • src/libs/png/pnggccrd.c

     
    77 *     and http://www.intel.com/drg/pentiumII/appnotes/923/923.htm
    88 *     for Intel's performance analysis of the MMX vs. non-MMX code.
    99 *
    10  * Last changed in libpng 1.2.9 April 14, 2006
     10 * Last changed in libpng 1.2.15 January 5, 2007
    1111 * For conditions of distribution and use, see copyright notice in png.h
    12  * Copyright (c) 1998-2006 Glenn Randers-Pehrson
     12 * Copyright (c) 1998-2007 Glenn Randers-Pehrson
    1313 * Copyright (c) 1998, Intel Corporation
    1414 *
    1515 * Based on MSVC code contributed by Nirav Chhatrapati, Intel Corp., 1998.
     
    245245#define PNG_INTERNAL
    246246#include "png.h"
    247247
    248 #if defined(PNG_USE_PNGGCCRD)
     248#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGGCCRD)
    249249
    250250int PNGAPI png_mmx_support(void);
    251251
    252252#ifdef PNG_USE_LOCAL_ARRAYS
    253 static const int FARDATA png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
    254 static const int FARDATA png_pass_inc[7]   = {8, 8, 4, 4, 2, 2, 1};
    255 static const int FARDATA png_pass_width[7] = {8, 4, 4, 2, 2, 1, 1};
     253const static int FARDATA png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
     254const static int FARDATA png_pass_inc[7]   = {8, 8, 4, 4, 2, 2, 1};
     255const static int FARDATA png_pass_width[7] = {8, 4, 4, 2, 2, 1, 1};
    256256#endif
    257257
    258 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
     258#if defined(PNG_MMX_CODE_SUPPORTED)
    259259/* djgpp, Win32, Cygwin, and OS2 add their own underscores to global variables,
    260260 * so define them without: */
    261261#if defined(__DJGPP__) || defined(WIN32) || defined(__CYGWIN__) || \
     
    311311static int _unmask;
    312312#endif
    313313
    314 static unsigned long long _mask8_0  = 0x0102040810204080LL;
     314const static unsigned long long _mask8_0  = 0x0102040810204080LL;
    315315
    316 static unsigned long long _mask16_1 = 0x0101020204040808LL;
    317 static unsigned long long _mask16_0 = 0x1010202040408080LL;
     316const static unsigned long long _mask16_1 = 0x0101020204040808LL;
     317const static unsigned long long _mask16_0 = 0x1010202040408080LL;
    318318
    319 static unsigned long long _mask24_2 = 0x0101010202020404LL;
    320 static unsigned long long _mask24_1 = 0x0408080810101020LL;
    321 static unsigned long long _mask24_0 = 0x2020404040808080LL;
     319const static unsigned long long _mask24_2 = 0x0101010202020404LL;
     320const static unsigned long long _mask24_1 = 0x0408080810101020LL;
     321const static unsigned long long _mask24_0 = 0x2020404040808080LL;
    322322
    323 static unsigned long long _mask32_3 = 0x0101010102020202LL;
    324 static unsigned long long _mask32_2 = 0x0404040408080808LL;
    325 static unsigned long long _mask32_1 = 0x1010101020202020LL;
    326 static unsigned long long _mask32_0 = 0x4040404080808080LL;
     323const static unsigned long long _mask32_3 = 0x0101010102020202LL;
     324const static unsigned long long _mask32_2 = 0x0404040408080808LL;
     325const static unsigned long long _mask32_1 = 0x1010101020202020LL;
     326const static unsigned long long _mask32_0 = 0x4040404080808080LL;
    327327
    328 static unsigned long long _mask48_5 = 0x0101010101010202LL;
    329 static unsigned long long _mask48_4 = 0x0202020204040404LL;
    330 static unsigned long long _mask48_3 = 0x0404080808080808LL;
    331 static unsigned long long _mask48_2 = 0x1010101010102020LL;
    332 static unsigned long long _mask48_1 = 0x2020202040404040LL;
    333 static unsigned long long _mask48_0 = 0x4040808080808080LL;
     328const static unsigned long long _mask48_5 = 0x0101010101010202LL;
     329const static unsigned long long _mask48_4 = 0x0202020204040404LL;
     330const static unsigned long long _mask48_3 = 0x0404080808080808LL;
     331const static unsigned long long _mask48_2 = 0x1010101010102020LL;
     332const static unsigned long long _mask48_1 = 0x2020202040404040LL;
     333const static unsigned long long _mask48_0 = 0x4040808080808080LL;
    334334
    335 static unsigned long long _const4   = 0x0000000000FFFFFFLL;
    336 //static unsigned long long _const5 = 0x000000FFFFFF0000LL;     // NOT USED
    337 static unsigned long long _const6   = 0x00000000000000FFLL;
     335const static unsigned long long _const4   = 0x0000000000FFFFFFLL;
     336//const static unsigned long long _const5 = 0x000000FFFFFF0000LL;     // NOT USED
     337const static unsigned long long _const6   = 0x00000000000000FFLL;
    338338
    339339// These are used in the row-filter routines and should/would be local
    340340//  variables if not for gcc addressing limitations.
     
    378378   _mask48_1 = _mask48_1;
    379379   _mask48_0 = _mask48_0;
    380380}
    381 #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
     381#endif /* PNG_MMX_CODE_SUPPORTED */
    382382
    383383
    384384static int _mmx_supported = 2;
     
    389389/*                                                                           */
    390390/*===========================================================================*/
    391391
    392 #if defined(PNG_HAVE_ASSEMBLER_COMBINE_ROW)
     392#if defined(PNG_HAVE_MMX_COMBINE_ROW)
    393393
    394394#define BPP2  2
    395395#define BPP3  3 /* bytes per pixel (a.k.a. pixel_bytes) */
     
    416416{
    417417   png_debug(1, "in png_combine_row (pnggccrd.c)\n");
    418418
    419 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
     419#if defined(PNG_MMX_CODE_SUPPORTED)
    420420   if (_mmx_supported == 2) {
    421421#if !defined(PNG_1_0_X)
    422422       /* this should have happened in png_init_mmx_flags() already */
     
    607607            png_bytep srcptr;
    608608            png_bytep dstptr;
    609609
    610 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
     610#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
    611611#if !defined(PNG_1_0_X)
    612612            if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW)
    613613                /* && _mmx_supported */ )
     
    700700               );
    701701            }
    702702            else /* mmx _not supported - Use modified C routine */
    703 #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
     703#endif /* PNG_MMX_CODE_SUPPORTED */
    704704            {
    705705               register png_uint_32 i;
    706706               png_uint_32 initial_val = png_pass_start[png_ptr->pass];
     
    745745            png_bytep srcptr;
    746746            png_bytep dstptr;
    747747
    748 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
     748#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
    749749#if !defined(PNG_1_0_X)
    750750            if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW)
    751751                /* && _mmx_supported */ )
     
    854854               );
    855855            }
    856856            else /* mmx _not supported - Use modified C routine */
    857 #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
     857#endif /* PNG_MMX_CODE_SUPPORTED */
    858858            {
    859859               register png_uint_32 i;
    860860               png_uint_32 initial_val = BPP2 * png_pass_start[png_ptr->pass];
     
    898898            png_bytep srcptr;
    899899            png_bytep dstptr;
    900900
    901 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
     901#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
    902902#if !defined(PNG_1_0_X)
    903903            if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW)
    904904                /* && _mmx_supported */ )
     
    10221022               );
    10231023            }
    10241024            else /* mmx _not supported - Use modified C routine */
    1025 #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
     1025#endif /* PNG_MMX_CODE_SUPPORTED */
    10261026            {
    10271027               register png_uint_32 i;
    10281028               png_uint_32 initial_val = BPP3 * png_pass_start[png_ptr->pass];
     
    10661066            png_bytep srcptr;
    10671067            png_bytep dstptr;
    10681068
    1069 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
     1069#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
    10701070#if !defined(PNG_1_0_X)
    10711071            if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW)
    10721072                /* && _mmx_supported */ )
     
    11971197               );
    11981198            }
    11991199            else /* mmx _not supported - Use modified C routine */
    1200 #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
     1200#endif /* PNG_MMX_CODE_SUPPORTED */
    12011201            {
    12021202               register png_uint_32 i;
    12031203               png_uint_32 initial_val = BPP4 * png_pass_start[png_ptr->pass];
     
    12411241            png_bytep srcptr;
    12421242            png_bytep dstptr;
    12431243
    1244 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
     1244#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
    12451245#if !defined(PNG_1_0_X)
    12461246            if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW)
    12471247                /* && _mmx_supported */ )
     
    13891389               );
    13901390            }
    13911391            else /* mmx _not supported - Use modified C routine */
    1392 #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
     1392#endif /* PNG_MMX_CODE_SUPPORTED */
    13931393            {
    13941394               register png_uint_32 i;
    13951395               png_uint_32 initial_val = BPP6 * png_pass_start[png_ptr->pass];
     
    14801480
    14811481} /* end png_combine_row() */
    14821482
    1483 #endif /* PNG_HAVE_ASSEMBLER_COMBINE_ROW */
     1483#endif /* PNG_HAVE_MMX_COMBINE_ROW */
    14841484
    14851485
    14861486
     
    14921492/*===========================================================================*/
    14931493
    14941494#if defined(PNG_READ_INTERLACING_SUPPORTED)
    1495 #if defined(PNG_HAVE_ASSEMBLER_READ_INTERLACE)
     1495#if defined(PNG_HAVE_MMX_READ_INTERLACE)
    14961496
    14971497/* png_do_read_interlace() is called after any 16-bit to 8-bit conversion
    14981498 * has taken place.  [GRR: what other steps come before and/or after?]
     
    15101510
    15111511   png_debug(1, "in png_do_read_interlace (pnggccrd.c)\n");
    15121512
    1513 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
     1513#if defined(PNG_MMX_CODE_SUPPORTED)
    15141514   if (_mmx_supported == 2) {
    15151515#if !defined(PNG_1_0_X)
    15161516       /* this should have happened in png_init_mmx_flags() already */
     
    17231723
    17241724            /* New code by Nirav Chhatrapati - Intel Corporation */
    17251725
    1726 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
     1726#if defined(PNG_MMX_CODE_SUPPORTED)
    17271727#if !defined(PNG_1_0_X)
    17281728            if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_INTERLACE)
    17291729                /* && _mmx_supported */ )
     
    26282628                 /* GRR 19991007:  does it?  or should pixel_bytes in each
    26292629                  *   block be replaced with immediate value (e.g., 1)? */
    26302630                 /* GRR 19991017:  replaced with constants in each case */
    2631 #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
     2631#endif /* PNG_MMX_CODE_SUPPORTED */
    26322632            {
    26332633               if (pixel_bytes == 1)
    26342634               {
     
    27532753
    27542754} /* end png_do_read_interlace() */
    27552755
    2756 #endif /* PNG_HAVE_ASSEMBLER_READ_INTERLACE */
     2756#endif /* PNG_HAVE_MMX_READ_INTERLACE */
    27572757#endif /* PNG_READ_INTERLACING_SUPPORTED */
    27582758
    27592759
    27602760
    2761 #if defined(PNG_HAVE_ASSEMBLER_READ_FILTER_ROW)
    2762 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
     2761#if defined(PNG_HAVE_MMX_READ_FILTER_ROW)
     2762#if defined(PNG_MMX_CODE_SUPPORTED)
    27632763
    27642764// These variables are utilized in the functions below.  They are declared
    27652765// globally here to ensure alignment on 8-byte boundaries.
     
    50665066
    50675067} // end of png_read_filter_row_mmx_up()
    50685068
    5069 #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
     5069#endif /* PNG_MMX_CODE_SUPPORTED */
    50705070
    50715071
    50725072
     
    50885088   char filnm[10];
    50895089#endif
    50905090
    5091 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
     5091#if defined(PNG_MMX_CODE_SUPPORTED)
    50925092/* GRR:  these are superseded by png_ptr->asm_flags: */
    50935093#define UseMMX_sub    1   // GRR:  converted 20000730
    50945094#define UseMMX_up     1   // GRR:  converted 20000729
     
    51025102#endif
    51035103       png_mmx_support();
    51045104   }
    5105 #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
     5105#endif /* PNG_MMX_CODE_SUPPORTED */
    51065106
    51075107#ifdef PNG_DEBUG
    51085108   png_debug(1, "in png_read_filter_row (pnggccrd.c)\n");
     
    51115111      case 0: sprintf(filnm, "none");
    51125112         break;
    51135113      case 1: sprintf(filnm, "sub-%s",
    5114 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
     5114#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
    51155115#if !defined(PNG_1_0_X)
    51165116        (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "MMX" :
    51175117#endif
     
    51195119"x86");
    51205120         break;
    51215121      case 2: sprintf(filnm, "up-%s",
    5122 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
     5122#ifdef PNG_MMX_CODE_SUPPORTED
    51235123#if !defined(PNG_1_0_X)
    51245124        (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP)? "MMX" :
    51255125#endif
     
    51275127 "x86");
    51285128         break;
    51295129      case 3: sprintf(filnm, "avg-%s",
    5130 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
     5130#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
    51315131#if !defined(PNG_1_0_X)
    51325132        (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)? "MMX" :
    51335133#endif
     
    51355135 "x86");
    51365136         break;
    51375137      case 4: sprintf(filnm, "Paeth-%s",
    5138 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
     5138#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
    51395139#if !defined(PNG_1_0_X)
    51405140        (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)? "MMX":
    51415141#endif
     
    51585158         break;
    51595159
    51605160      case PNG_FILTER_VALUE_SUB:
    5161 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
     5161#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
    51625162#if !defined(PNG_1_0_X)
    51635163         if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB) &&
    51645164             (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) &&
     
    51705170            png_read_filter_row_mmx_sub(row_info, row);
    51715171         }
    51725172         else
    5173 #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
     5173#endif /* PNG_MMX_CODE_SUPPORTED */
    51745174         {
    51755175            png_uint_32 i;
    51765176            png_uint_32 istop = row_info->rowbytes;
     
    51875187         break;
    51885188
    51895189      case PNG_FILTER_VALUE_UP:
    5190 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
     5190#if defined(PNG_MMX_CODE_SUPPORTED)
    51915191#if !defined(PNG_1_0_X)
    51925192         if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP) &&
    51935193             (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) &&
     
    51995199            png_read_filter_row_mmx_up(row_info, row, prev_row);
    52005200         }
    52015201          else
    5202 #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
     5202#endif /* PNG_MMX_CODE_SUPPORTED */
    52035203         {
    52045204            png_uint_32 i;
    52055205            png_uint_32 istop = row_info->rowbytes;
     
    52155215         break;
    52165216
    52175217      case PNG_FILTER_VALUE_AVG:
    5218 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
     5218#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
    52195219#if !defined(PNG_1_0_X)
    52205220         if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG) &&
    52215221             (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) &&
     
    52275227            png_read_filter_row_mmx_avg(row_info, row, prev_row);
    52285228         }
    52295229         else
    5230 #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
     5230#endif /* PNG_MMX_CODE_SUPPORTED */
    52315231         {
    52325232            png_uint_32 i;
    52335233            png_bytep rp = row;
     
    52535253         break;
    52545254
    52555255      case PNG_FILTER_VALUE_PAETH:
    5256 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
     5256#if defined(PNG_MMX_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
    52575257#if !defined(PNG_1_0_X)
    52585258         if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH) &&
    52595259             (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) &&
     
    52655265            png_read_filter_row_mmx_paeth(row_info, row, prev_row);
    52665266         }
    52675267         else
    5268 #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
     5268#endif /* PNG_MMX_CODE_SUPPORTED */
    52695269         {
    52705270            png_uint_32 i;
    52715271            png_bytep rp = row;
     
    53265326   }
    53275327}
    53285328
    5329 #endif /* PNG_HAVE_ASSEMBLER_READ_FILTER_ROW */
     5329#endif /* PNG_HAVE_MMX_READ_FILTER_ROW */
    53305330
    53315331
    53325332/*===========================================================================*/
  • src/libs/png/pngrtran.c

     
    11
    22/* pngrtran.c - transforms the data in a row for PNG readers
    33 *
    4  * Last changed in libpng 1.2.11 June 15, 2006
     4 * Last changed in libpng 1.2.15 January 5, 2007
    55 * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2006 Glenn Randers-Pehrson
     6 * Copyright (c) 1998-2007 Glenn Randers-Pehrson
    77 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    88 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
    99 *
     
    2424{
    2525   png_debug(1, "in png_set_crc_action\n");
    2626   /* Tell libpng how we react to CRC errors in critical chunks */
     27   if(png_ptr == NULL) return;
    2728   switch (crit_action)
    2829   {
    2930      case PNG_CRC_NO_CHANGE:                        /* leave setting as is */
     
    8081   int need_expand, double background_gamma)
    8182{
    8283   png_debug(1, "in png_set_background\n");
     84   if(png_ptr == NULL) return;
    8385   if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN)
    8486   {
    8587      png_warning(png_ptr, "Application must supply a known background gamma");
     
    9294   png_ptr->background_gamma = (float)background_gamma;
    9395   png_ptr->background_gamma_type = (png_byte)(background_gamma_code);
    9496   png_ptr->transformations |= (need_expand ? PNG_BACKGROUND_EXPAND : 0);
    95 
    96    /* Note:  if need_expand is set and color_type is either RGB or RGB_ALPHA
    97     * (in which case need_expand is superfluous anyway), the background color
    98     * might actually be gray yet not be flagged as such. This is not a problem
    99     * for the current code, which uses PNG_BACKGROUND_IS_GRAY only to
    100     * decide when to do the png_do_gray_to_rgb() transformation.
    101     */
    102    if ((need_expand && !(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) ||
    103        (!need_expand && background_color->red == background_color->green &&
    104         background_color->red == background_color->blue))
    105       png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;
    10697}
    10798#endif
    10899
     
    112103png_set_strip_16(png_structp png_ptr)
    113104{
    114105   png_debug(1, "in png_set_strip_16\n");
     106   if(png_ptr == NULL) return;
    115107   png_ptr->transformations |= PNG_16_TO_8;
    116108}
    117109#endif
     
    121113png_set_strip_alpha(png_structp png_ptr)
    122114{
    123115   png_debug(1, "in png_set_strip_alpha\n");
     116   if(png_ptr == NULL) return;
    124117   png_ptr->flags |= PNG_FLAG_STRIP_ALPHA;
    125118}
    126119#endif
     
    150143   int full_dither)
    151144{
    152145   png_debug(1, "in png_set_dither\n");
     146   if(png_ptr == NULL) return;
    153147   png_ptr->transformations |= PNG_DITHER;
    154148
    155149   if (!full_dither)
     
    533527png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma)
    534528{
    535529   png_debug(1, "in png_set_gamma\n");
     530   if(png_ptr == NULL) return;
    536531   if ((fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD) ||
    537532       (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) ||
    538533       (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE))
     
    551546png_set_expand(png_structp png_ptr)
    552547{
    553548   png_debug(1, "in png_set_expand\n");
     549   if(png_ptr == NULL) return;
    554550   png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
    555551}
    556552
     
    576572png_set_palette_to_rgb(png_structp png_ptr)
    577573{
    578574   png_debug(1, "in png_set_palette_to_rgb\n");
     575   if(png_ptr == NULL) return;
    579576   png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
    580577}
    581578
     
    585582png_set_expand_gray_1_2_4_to_8(png_structp png_ptr)
    586583{
    587584   png_debug(1, "in png_set_expand_gray_1_2_4_to_8\n");
    588    png_ptr->transformations |= PNG_EXPAND_tRNS;
     585   if(png_ptr == NULL) return;
     586   png_ptr->transformations |= PNG_EXPAND;
    589587}
    590588#endif
    591589
     
    596594png_set_gray_1_2_4_to_8(png_structp png_ptr)
    597595{
    598596   png_debug(1, "in png_set_gray_1_2_4_to_8\n");
     597   if(png_ptr == NULL) return;
    599598   png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
    600599}
    601600#endif
     
    631630{
    632631      int red_fixed = (int)((float)red*100000.0 + 0.5);
    633632      int green_fixed = (int)((float)green*100000.0 + 0.5);
     633      if(png_ptr == NULL) return;
    634634      png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed);
    635635}
    636636#endif
     
    640640   png_fixed_point red, png_fixed_point green)
    641641{
    642642   png_debug(1, "in png_set_rgb_to_gray\n");
     643   if(png_ptr == NULL) return;
    643644   switch(error_action)
    644645   {
    645646      case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY;
     
    690691   read_user_transform_fn)
    691692{
    692693   png_debug(1, "in png_set_read_user_transform_fn\n");
     694   if(png_ptr == NULL) return;
    693695#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
    694696   png_ptr->transformations |= PNG_USER_TRANSFORM;
    695697   png_ptr->read_user_transform_fn = read_user_transform_fn;
     
    719721#endif
    720722
    721723#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)
     724
     725#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
     726   /* Detect gray background and attempt to enable optimization
     727    * for gray --> RGB case */
     728   /* Note:  if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or
     729    * RGB_ALPHA (in which case need_expand is superfluous anyway), the
     730    * background color might actually be gray yet not be flagged as such.
     731    * This is not a problem for the current code, which uses
     732    * PNG_BACKGROUND_IS_GRAY only to decide when to do the
     733    * png_do_gray_to_rgb() transformation.
     734    */
    722735   if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
     736       !(color_type & PNG_COLOR_MASK_COLOR))
     737   {
     738          png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;
     739   } else if ((png_ptr->transformations & PNG_BACKGROUND) &&
     740              !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
     741              (png_ptr->transformations & PNG_GRAY_TO_RGB) &&
     742              png_ptr->background.red == png_ptr->background.green &&
     743              png_ptr->background.red == png_ptr->background.blue)
     744   {
     745          png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;
     746          png_ptr->background.gray = png_ptr->background.red;
     747   }
     748#endif
     749
     750   if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
    723751       (png_ptr->transformations & PNG_EXPAND))
    724752   {
    725753      if (!(color_type & PNG_COLOR_MASK_COLOR))  /* i.e., GRAY or GRAY_ALPHA */
     
    12651293      if(rgb_error)
    12661294      {
    12671295         png_ptr->rgb_to_gray_status=1;
    1268          if(png_ptr->transformations == PNG_RGB_TO_GRAY_WARN)
     1296         if(png_ptr->transformations & PNG_RGB_TO_GRAY_WARN)
    12691297            png_warning(png_ptr, "png_do_rgb_to_gray found nongray pixel");
    1270          if(png_ptr->transformations == PNG_RGB_TO_GRAY_ERR)
     1298         if(png_ptr->transformations & PNG_RGB_TO_GRAY_ERR)
    12711299            png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel");
    12721300      }
    12731301   }
     
    39373965
    39383966#ifdef PNG_FLOATING_POINT_SUPPORTED
    39393967#if defined(PNG_READ_GAMMA_SUPPORTED)
    3940 static int png_gamma_shift[] =
     3968const static int png_gamma_shift[] =
    39413969   {0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0, 0x00};
    39423970
    39433971/* We build the 8- or 16-bit gamma tables here.  Note that for 16-bit
  • src/libs/png/pngtrans.c

     
    11
    22/* pngtrans.c - transforms the data in a row (used by both readers and writers)
    33 *
    4  * Last changed in libpng 1.2.9 April 14, 2006
     4 * Last changed in libpng 1.2.13 November 13, 2006
    55 * For conditions of distribution and use, see copyright notice in png.h
    66 * Copyright (c) 1998-2006 Glenn Randers-Pehrson
    77 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
     
    1818png_set_bgr(png_structp png_ptr)
    1919{
    2020   png_debug(1, "in png_set_bgr\n");
     21   if(png_ptr == NULL) return;
    2122   png_ptr->transformations |= PNG_BGR;
    2223}
    2324#endif
     
    2829png_set_swap(png_structp png_ptr)
    2930{
    3031   png_debug(1, "in png_set_swap\n");
     32   if(png_ptr == NULL) return;
    3133   if (png_ptr->bit_depth == 16)
    3234      png_ptr->transformations |= PNG_SWAP_BYTES;
    3335}
     
    3941png_set_packing(png_structp png_ptr)
    4042{
    4143   png_debug(1, "in png_set_packing\n");
     44   if(png_ptr == NULL) return;
    4245   if (png_ptr->bit_depth < 8)
    4346   {
    4447      png_ptr->transformations |= PNG_PACK;
     
    5356png_set_packswap(png_structp png_ptr)
    5457{
    5558   png_debug(1, "in png_set_packswap\n");
     59   if(png_ptr == NULL) return;
    5660   if (png_ptr->bit_depth < 8)
    5761      png_ptr->transformations |= PNG_PACKSWAP;
    5862}
     
    6367png_set_shift(png_structp png_ptr, png_color_8p true_bits)
    6468{
    6569   png_debug(1, "in png_set_shift\n");
     70   if(png_ptr == NULL) return;
    6671   png_ptr->transformations |= PNG_SHIFT;
    6772   png_ptr->shift = *true_bits;
    6873}
     
    7479png_set_interlace_handling(png_structp png_ptr)
    7580{
    7681   png_debug(1, "in png_set_interlace handling\n");
    77    if (png_ptr->interlaced)
     82   if (png_ptr && png_ptr->interlaced)
    7883   {
    7984      png_ptr->transformations |= PNG_INTERLACE;
    8085      return (7);
     
    9499png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
    95100{
    96101   png_debug(1, "in png_set_filler\n");
     102   if(png_ptr == NULL) return;
    97103   png_ptr->transformations |= PNG_FILLER;
    98104   png_ptr->filler = (png_byte)filler;
    99105   if (filler_loc == PNG_FILLER_AFTER)
     
    126132png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
    127133{
    128134   png_debug(1, "in png_set_add_alpha\n");
     135   if(png_ptr == NULL) return;
    129136   png_set_filler(png_ptr, filler, filler_loc);
    130137   png_ptr->transformations |= PNG_ADD_ALPHA;
    131138}
     
    139146png_set_swap_alpha(png_structp png_ptr)
    140147{
    141148   png_debug(1, "in png_set_swap_alpha\n");
     149   if(png_ptr == NULL) return;
    142150   png_ptr->transformations |= PNG_SWAP_ALPHA;
    143151}
    144152#endif
     
    149157png_set_invert_alpha(png_structp png_ptr)
    150158{
    151159   png_debug(1, "in png_set_invert_alpha\n");
     160   if(png_ptr == NULL) return;
    152161   png_ptr->transformations |= PNG_INVERT_ALPHA;
    153162}
    154163#endif
     
    158167png_set_invert_mono(png_structp png_ptr)
    159168{
    160169   png_debug(1, "in png_set_invert_mono\n");
     170   if(png_ptr == NULL) return;
    161171   png_ptr->transformations |= PNG_INVERT_MONO;
    162172}
    163173
     
    242252#endif
    243253
    244254#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
    245 static PNG_CONST png_byte onebppswaptable[256] = {
     255const static PNG_CONST png_byte onebppswaptable[256] = {
    246256   0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0,
    247257   0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
    248258   0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8,
     
    277287   0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF
    278288};
    279289
    280 static PNG_CONST png_byte twobppswaptable[256] = {
     290const static PNG_CONST png_byte twobppswaptable[256] = {
    281291   0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0,
    282292   0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0,
    283293   0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4,
     
    312322   0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF
    313323};
    314324
    315 static PNG_CONST png_byte fourbppswaptable[256] = {
     325const static PNG_CONST png_byte fourbppswaptable[256] = {
    316326   0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,
    317327   0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0,
    318328   0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71,
     
    621631   user_transform_ptr, int user_transform_depth, int user_transform_channels)
    622632{
    623633   png_debug(1, "in png_set_user_transform_info\n");
     634   if(png_ptr == NULL) return;
    624635#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
    625636   png_ptr->user_transform_ptr = user_transform_ptr;
    626637   png_ptr->user_transform_depth = (png_byte)user_transform_depth;
     
    642653png_get_user_transform_ptr(png_structp png_ptr)
    643654{
    644655#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
     656   if (png_ptr == NULL) return (NULL);
    645657   return ((png_voidp)png_ptr->user_transform_ptr);
    646658#else
    647    if(png_ptr)
    648      return (NULL);
    649659   return (NULL);
    650660#endif
    651661}
  • headers/libs/png/pngconf.h

     
    11
    22/* pngconf.h - machine configurable file for libpng
    33 *
    4  * libpng version 1.2.12 - June 27, 2006
     4 * libpng version 1.2.18 - May 15, 2007
    55 * For conditions of distribution and use, see copyright notice in png.h
    6  * Copyright (c) 1998-2005 Glenn Randers-Pehrson
     6 * Copyright (c) 1998-2007 Glenn Randers-Pehrson
    77 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    88 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
    99 */
     
    721721#endif
    722722
    723723/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0
    724    even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined */
     724 * even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined.
     725 *
     726 * PNG_NO_ASSEMBLER_CODE disables use of all assembler code and optimized C,
     727 * and removes or includes several functions in the API.
     728 *
     729 * PNG_NO_MMX_CODE disables the use of MMX code without changing the API.
     730 * When MMX code is off, then optimized C replacement functions are used.
     731*/
    725732#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE)
    726733#  ifndef PNG_ASSEMBLER_CODE_SUPPORTED
    727734#    define PNG_ASSEMBLER_CODE_SUPPORTED
    728735#  endif
     736#  if defined(XP_MACOSX) && !defined(PNG_NO_MMX_CODE)
     737     /* work around Intel-Mac compiler bug */
     738#    define PNG_NO_MMX_CODE
     739#  endif
    729740#  if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) && \
    730741     defined(__MMX__)
    731742#    define PNG_MMX_CODE_SUPPORTED
     
    14471458 * MMX will be detected at run time and used if present.
    14481459 */
    14491460#ifdef PNG_USE_PNGVCRD
    1450 #  define PNG_HAVE_ASSEMBLER_COMBINE_ROW
    1451 #  define PNG_HAVE_ASSEMBLER_READ_INTERLACE
    1452 #  define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
     1461#  define PNG_HAVE_MMX_COMBINE_ROW
     1462#  define PNG_HAVE_MMX_READ_INTERLACE
     1463#  define PNG_HAVE_MMX_READ_FILTER_ROW
    14531464#endif
    14541465
    14551466/* Set this in the makefile for gcc/as on Pentium, not here. */
     
    14571468 * MMX will be detected at run time and used if present.
    14581469 */
    14591470#ifdef PNG_USE_PNGGCCRD
    1460 #  define PNG_HAVE_ASSEMBLER_COMBINE_ROW
    1461 #  define PNG_HAVE_ASSEMBLER_READ_INTERLACE
    1462 #  define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
     1471#  define PNG_HAVE_MMX_COMBINE_ROW
     1472#  define PNG_HAVE_MMX_READ_INTERLACE
     1473#  define PNG_HAVE_MMX_READ_FILTER_ROW
    14631474#endif
    14641475/* - see pnggccrd.c for info about what is currently enabled */
    14651476
  • headers/libs/png/png.h

     
    11
    22/* png.h - header file for PNG reference library
    33 *
    4  * libpng version 1.2.12 - June 27, 2006
    5  * Copyright (c) 1998-2006 Glenn Randers-Pehrson
     4 * libpng version 1.2.18 - May 15, 2007
     5 * Copyright (c) 1998-2007 Glenn Randers-Pehrson
    66 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    77 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
    88 *
    99 * Authors and maintainers:
    1010 *  libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
    1111 *  libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
    12  *  libpng versions 0.97, January 1998, through 1.2.12 - June 27, 2006: Glenn
     12 *  libpng versions 0.97, January 1998, through 1.2.18 - May 15, 2007: Glenn
    1313 *  See also "Contributing Authors", below.
    1414 *
    1515 * Note about libpng version numbers:
     
    126126 *    1.2.11                  13    10211  12.so.0.11[.0]
    127127 *    1.0.20                  10    10020  10.so.0.20[.0]
    128128 *    1.2.12                  13    10212  12.so.0.12[.0]
     129 *    1.2.13beta1             13    10213  12.so.0.13[.0]
     130 *    1.0.21                  10    10021  10.so.0.21[.0]
     131 *    1.2.13                  13    10213  12.so.0.13[.0]
     132 *    1.2.14beta1-2           13    10214  12.so.0.14[.0]
     133 *    1.0.22rc1               10    10022  10.so.0.22[.0]
     134 *    1.2.14rc1               13    10214  12.so.0.14[.0]
     135 *    1.0.22                  10    10022  10.so.0.22[.0]
     136 *    1.2.14                  13    10214  12.so.0.14[.0]
     137 *    1.2.15beta1-6           13    10215  12.so.0.15[.0]
     138 *    1.0.23rc1-5             10    10023  10.so.0.23[.0]
     139 *    1.2.15rc1-5             13    10215  12.so.0.15[.0]
     140 *    1.0.23                  10    10023  10.so.0.23[.0]
     141 *    1.2.15                  13    10215  12.so.0.15[.0]
     142 *    1.2.16beta1-2           13    10216  12.so.0.16[.0]
     143 *    1.2.16rc1               13    10216  12.so.0.16[.0]
     144 *    1.0.24                  10    10024  10.so.0.24[.0]
     145 *    1.2.16                  13    10216  12.so.0.16[.0]
     146 *    1.2.17beta1-2           13    10217  12.so.0.17[.0]
     147 *    1.0.25rc1               10    10025  10.so.0.25[.0]
     148 *    1.2.17rc1-3             13    10217  12.so.0.17[.0]
     149 *    1.0.25                  10    10025  10.so.0.25[.0]
     150 *    1.2.17                  13    10217  12.so.0.17[.0]
     151 *    1.0.26                  10    10026  10.so.0.26[.0]
     152 *    1.2.18                  13    10218  12.so.0.18[.0]
    129153 *
    130154 *    Henceforth the source version will match the shared-library major
    131155 *    and minor numbers; the shared-library major version number will be
     
    155179 * If you modify libpng you may insert additional notices immediately following
    156180 * this sentence.
    157181 *
    158  * libpng versions 1.2.6, August 15, 2004, through 1.2.12, June 27, 2006, are
    159  * Copyright (c) 2004, 2006 Glenn Randers-Pehrson, and are
     182 * libpng versions 1.2.6, August 15, 2004, through 1.2.18, May 15, 2007, are
     183 * Copyright (c) 2004, 2006-2007 Glenn Randers-Pehrson, and are
    160184 * distributed according to the same disclaimer and license as libpng-1.2.5
    161185 * with the following individual added to the list of Contributing Authors:
    162186 *
     
    267291 * Y2K compliance in libpng:
    268292 * =========================
    269293 *
    270  *    June 27, 2006
     294 *    May 15, 2007
    271295 *
    272296 *    Since the PNG Development group is an ad-hoc body, we can't make
    273297 *    an official declaration.
    274298 *
    275299 *    This is your unofficial assurance that libpng from version 0.71 and
    276  *    upward through 1.2.12 are Y2K compliant.  It is my belief that earlier
     300 *    upward through 1.2.18 are Y2K compliant.  It is my belief that earlier
    277301 *    versions were also Y2K compliant.
    278302 *
    279303 *    Libpng only has three year fields.  One is a 2-byte unsigned integer
     
    329353 */
    330354
    331355/* Version information for png.h - this should match the version in png.c */
    332 #define PNG_LIBPNG_VER_STRING "1.2.12"
     356#define PNG_LIBPNG_VER_STRING "1.2.18"
    333357#define PNG_HEADER_VERSION_STRING \
    334    " libpng version 1.2.12 - June 27, 2006 (header)\n"
     358   " libpng version 1.2.18 - May 15, 2007 (header)\n"
    335359
    336360#define PNG_LIBPNG_VER_SONUM   0
    337361#define PNG_LIBPNG_VER_DLLNUM  13
     
    339363/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
    340364#define PNG_LIBPNG_VER_MAJOR   1
    341365#define PNG_LIBPNG_VER_MINOR   2
    342 #define PNG_LIBPNG_VER_RELEASE 12
     366#define PNG_LIBPNG_VER_RELEASE 18
    343367/* This should match the numeric part of the final component of
    344368 * PNG_LIBPNG_VER_STRING, omitting any leading zero: */
    345369
     
    367391 * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
    368392 * version 1.0.0 was mis-numbered 100 instead of 10000).  From
    369393 * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release */
    370 #define PNG_LIBPNG_VER 10212 /* 1.2.12 */
     394#define PNG_LIBPNG_VER 10218 /* 1.2.18 */
    371395
    372396#ifndef PNG_VERSION_INFO_ONLY
    373397/* include the compression library's header */
     
    13341358#endif
    13351359
    13361360/* New members added in libpng-1.2.0 */
    1337 #if !defined(PNG_1_0_X) && defined(PNG_ASSEMBLER_CODE_SUPPORTED)
     1361#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
     1362#  if !defined(PNG_1_0_X)
     1363#    if defined(PNG_MMX_CODE_SUPPORTED)
    13381364   png_byte     mmx_bitdepth_threshold;
    13391365   png_uint_32  mmx_rowbytes_threshold;
     1366#    endif
    13401367   png_uint_32  asm_flags;
     1368#  endif
    13411369#endif
    13421370
    13431371/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */
     
    13671395   png_uint_32 user_height_max;
    13681396#endif
    13691397
     1398/* New member added in libpng-1.0.25 and 1.2.17 */
     1399#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
     1400   /* storage for unknown chunk that the library doesn't recognize. */
     1401   png_unknown_chunk unknown_chunk;
     1402#endif
    13701403};
    13711404
    13721405
    13731406/* This triggers a compiler error in png.c, if png.c and png.h
    13741407 * do not agree upon the version number.
    13751408 */
    1376 typedef png_structp version_1_2_12;
     1409typedef png_structp version_1_2_18;
    13771410
    13781411typedef png_struct FAR * FAR * png_structpp;
    13791412
     
    23692402   handling or default unknown chunk handling is not desired.  Any chunks not
    23702403   listed will be handled in the default manner.  The IHDR and IEND chunks
    23712404   must not be listed.
    2372       keep = 0: follow default behavour
     2405      keep = 0: follow default behaviour
    23732406           = 1: do not keep
    23742407           = 2: keep only if safe-to-copy
    23752408           = 3: keep even if unsafe-to-copy
     
    24792512
    24802513/* Added to version 1.2.0 */
    24812514#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
     2515#if defined(PNG_MMX_CODE_SUPPORTED)
    24822516#define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED  0x01  /* not user-settable */
    24832517#define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU    0x02  /* not user-settable */
    24842518#define PNG_ASM_FLAG_MMX_READ_COMBINE_ROW  0x04
     
    25042538
    25052539#define PNG_SELECT_READ   1
    25062540#define PNG_SELECT_WRITE  2
     2541#endif /* PNG_MMX_CODE_SUPPORTED */
    25072542
    25082543#if !defined(PNG_1_0_X)
    25092544/* pngget.c */
     
    25362571   png_uint_32 mmx_rowbytes_threshold));
    25372572
    25382573#endif /* PNG_1_0_X */
    2539 #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
    25402574
    25412575#if !defined(PNG_1_0_X)
    25422576/* png.c, pnggccrd.c, or pngvcrd.c */
    25432577extern PNG_EXPORT(int,png_mmx_support) PNGARG((void));
     2578#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
    25442579
    25452580/* Strip the prepended error numbers ("#nnn ") from error and warning
    25462581 * messages before passing them to the error or warning handler. */
     
    26482683 * be found in the files where the functions are located.
    26492684 */
    26502685
    2651 #if defined(PNG_INTERNAL)
    26522686
    2653 /* Various modes of operation.  Note that after an init, mode is set to
    2654  * zero automatically when the structure is created.
     2687/* Various modes of operation, that are visible to applications because
     2688 * they are used for unknown chunk location.
    26552689 */
    26562690#define PNG_HAVE_IHDR               0x01
    26572691#define PNG_HAVE_PLTE               0x02
    26582692#define PNG_HAVE_IDAT               0x04
    26592693#define PNG_AFTER_IDAT              0x08 /* Have complete zlib datastream */
    26602694#define PNG_HAVE_IEND               0x10
     2695
     2696#if defined(PNG_INTERNAL)
     2697
     2698/* More modes of operation.  Note that after an init, mode is set to
     2699 * zero automatically when the structure is created.
     2700 */
    26612701#define PNG_HAVE_gAMA               0x20
    26622702#define PNG_HAVE_cHRM               0x40
    26632703#define PNG_HAVE_sRGB               0x80
     
    34423482#endif
    34433483
    34443484#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
     3485#if defined(PNG_MMX_CODE_SUPPORTED)
    34453486/* png.c */ /* PRIVATE */
    34463487PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr));
    34473488#endif
     3489#endif
    34483490
    34493491#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
    34503492PNG_EXTERN png_uint_32 png_get_pixels_per_inch PNGARG((png_structp png_ptr,