Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/3rdparty/libpng/pngwutil.c

    r561 r846  
    22/* pngwutil.c - utilities to write a PNG file
    33 *
    4  * Last changed in libpng 1.2.40 [September 10, 2009]
    5  * Copyright (c) 1998-2009 Glenn Randers-Pehrson
     4 * Last changed in libpng 1.4.0 [January 3, 2010]
     5 * Copyright (c) 1998-2010 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.)
     
    1212 */
    1313
    14 #define PNG_INTERNAL
     14#define PNG_NO_PEDANTIC_WARNINGS
    1515#include "png.h"
    1616#ifdef PNG_WRITE_SUPPORTED
     17#include "pngpriv.h"
    1718
    1819/* Place a 32-bit number into a buffer in PNG byte order.  We work
     
    2930}
    3031
     32#ifdef PNG_SAVE_INT_32_SUPPORTED
    3133/* The png_save_int_32 function assumes integers are stored in two's
    3234 * complement format.  If this isn't the case, then this routine needs to
     
    4143   buf[3] = (png_byte)(i & 0xff);
    4244}
     45#endif
    4346
    4447/* Place a 16-bit number into a buffer in PNG byte order.
     
    5962 * bytes have already been written.
    6063 */
    61 void /* PRIVATE */
     64void PNGAPI
    6265png_write_sig(png_structp png_ptr)
    6366{
    6467   png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
     68
     69#ifdef PNG_IO_STATE_SUPPORTED
     70   /* Inform the I/O callback that the signature is being written */
     71   png_ptr->io_state = PNG_IO_WRITING | PNG_IO_SIGNATURE;
     72#endif
    6573
    6674   /* Write the rest of the 8 byte signature */
     
    107115      return;
    108116
     117#ifdef PNG_IO_STATE_SUPPORTED
     118   /* Inform the I/O callback that the chunk header is being written.
     119    * PNG_IO_CHUNK_HDR requires a single I/O call.
     120    */
     121   png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_HDR;
     122#endif
     123
    109124   /* Write the length and the chunk name */
    110125   png_save_uint_32(buf, length);
     
    115130   /* Reset the crc and run it over the chunk name */
    116131   png_reset_crc(png_ptr);
    117    png_calculate_crc(png_ptr, chunk_name, (png_size_t)4);
     132   png_calculate_crc(png_ptr, chunk_name, 4);
     133
     134#ifdef PNG_IO_STATE_SUPPORTED
     135   /* Inform the I/O callback that chunk data will (possibly) be written.
     136    * PNG_IO_CHUNK_DATA does NOT require a specific number of I/O calls.
     137    */
     138   png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_DATA;
     139#endif
    118140}
    119141
     
    147169   if (png_ptr == NULL) return;
    148170
     171#ifdef PNG_IO_STATE_SUPPORTED
     172   /* Inform the I/O callback that the chunk CRC is being written.
     173    * PNG_IO_CHUNK_CRC requires a single I/O function call.
     174    */
     175   png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_CRC;
     176#endif
     177
    149178   /* Write the crc in a single operation */
    150179   png_save_uint_32(buf, png_ptr->crc);
     
    193222   if (compression >= PNG_TEXT_COMPRESSION_LAST)
    194223   {
    195 #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
     224#ifdef PNG_STDIO_SUPPORTED
    196225      char msg[50];
    197226      png_snprintf(msg, 50, "Unknown compression type %d", compression);
     
    252281               old_ptr = comp->output_ptr;
    253282               comp->output_ptr = (png_charpp)png_malloc(png_ptr,
    254                   (png_uint_32)
     283                  (png_alloc_size_t)
    255284                  (comp->max_output_ptr * png_sizeof(png_charpp)));
    256285               png_memcpy(comp->output_ptr, old_ptr, old_max
     
    260289            else
    261290               comp->output_ptr = (png_charpp)png_malloc(png_ptr,
    262                   (png_uint_32)
     291                  (png_alloc_size_t)
    263292                  (comp->max_output_ptr * png_sizeof(png_charp)));
    264293         }
     
    267296         comp->output_ptr[comp->num_output_ptr] =
    268297            (png_charp)png_malloc(png_ptr,
    269             (png_uint_32)png_ptr->zbuf_size);
     298            (png_alloc_size_t)png_ptr->zbuf_size);
    270299         png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf,
    271300            png_ptr->zbuf_size);
     
    304333                  /* This could be optimized to realloc() */
    305334                  comp->output_ptr = (png_charpp)png_malloc(png_ptr,
    306                      (png_uint_32)(comp->max_output_ptr *
     335                     (png_alloc_size_t)(comp->max_output_ptr *
    307336                     png_sizeof(png_charp)));
    308337                  png_memcpy(comp->output_ptr, old_ptr,
     
    312341               else
    313342                  comp->output_ptr = (png_charpp)png_malloc(png_ptr,
    314                      (png_uint_32)(comp->max_output_ptr *
     343                     (png_alloc_size_t)(comp->max_output_ptr *
    315344                     png_sizeof(png_charp)));
    316345            }
     
    319348            comp->output_ptr[comp->num_output_ptr] =
    320349               (png_charp)png_malloc(png_ptr,
    321                (png_uint_32)png_ptr->zbuf_size);
     350               (png_alloc_size_t)png_ptr->zbuf_size);
    322351            png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf,
    323352               png_ptr->zbuf_size);
     
    367396         (png_size_t)png_ptr->zbuf_size);
    368397      png_free(png_ptr, comp->output_ptr[i]);
    369        comp->output_ptr[i]=NULL;
    370398   }
    371399   if (comp->max_output_ptr != 0)
    372400      png_free(png_ptr, comp->output_ptr);
    373        comp->output_ptr=NULL;
    374401   /* Write anything left in zbuf */
    375402   if (png_ptr->zstream.avail_out < (png_uint_32)png_ptr->zbuf_size)
     
    392419   int interlace_type)
    393420{
    394 #ifdef PNG_USE_LOCAL_ARRAYS
    395421   PNG_IHDR;
    396 #endif
    397422   int ret;
    398423
     
    460485    */
    461486   if (
    462 #if defined(PNG_MNG_FEATURES_SUPPORTED)
     487#ifdef PNG_MNG_FEATURES_SUPPORTED
    463488      !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
    464489      ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) &&
     
    488513   png_ptr->color_type = (png_byte)color_type;
    489514   png_ptr->interlaced = (png_byte)interlace_type;
    490 #if defined(PNG_MNG_FEATURES_SUPPORTED)
     515#ifdef PNG_MNG_FEATURES_SUPPORTED
    491516   png_ptr->filter_type = (png_byte)filter_type;
    492517#endif
     
    570595png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal)
    571596{
    572 #ifdef PNG_USE_LOCAL_ARRAYS
    573597   PNG_PLTE;
    574 #endif
    575598   png_uint_32 i;
    576599   png_colorp pal_ptr;
     
    580603
    581604   if ((
    582 #if defined(PNG_MNG_FEATURES_SUPPORTED)
     605#ifdef PNG_MNG_FEATURES_SUPPORTED
    583606        !(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) &&
    584607#endif
     
    608631   png_write_chunk_start(png_ptr, (png_bytep)png_PLTE,
    609632     (png_uint_32)(num_pal * 3));
    610 #ifndef PNG_NO_POINTER_INDEXING
     633#ifdef PNG_POINTER_INDEXING_SUPPORTED
    611634   for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++)
    612635   {
     
    635658png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
    636659{
    637 #ifdef PNG_USE_LOCAL_ARRAYS
    638660   PNG_IDAT;
    639 #endif
    640661
    641662   png_debug(1, "in png_write_IDAT");
     
    690711png_write_IEND(png_structp png_ptr)
    691712{
    692 #ifdef PNG_USE_LOCAL_ARRAYS
    693713   PNG_IEND;
    694 #endif
    695714
    696715   png_debug(1, "in png_write_IEND");
    697716
    698    png_write_chunk(png_ptr, (png_bytep)png_IEND, png_bytep_NULL,
     717   png_write_chunk(png_ptr, (png_bytep)png_IEND, NULL,
    699718     (png_size_t)0);
    700719   png_ptr->mode |= PNG_HAVE_IEND;
    701720}
    702721
    703 #if defined(PNG_WRITE_gAMA_SUPPORTED)
     722#ifdef PNG_WRITE_gAMA_SUPPORTED
    704723/* Write a gAMA chunk */
    705724#ifdef PNG_FLOATING_POINT_SUPPORTED
     
    707726png_write_gAMA(png_structp png_ptr, double file_gamma)
    708727{
    709 #ifdef PNG_USE_LOCAL_ARRAYS
    710728   PNG_gAMA;
    711 #endif
    712729   png_uint_32 igamma;
    713730   png_byte buf[4];
     
    725742png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma)
    726743{
    727 #ifdef PNG_USE_LOCAL_ARRAYS
    728744   PNG_gAMA;
    729 #endif
    730745   png_byte buf[4];
    731746
     
    739754#endif
    740755
    741 #if defined(PNG_WRITE_sRGB_SUPPORTED)
     756#ifdef PNG_WRITE_sRGB_SUPPORTED
    742757/* Write a sRGB chunk */
    743758void /* PRIVATE */
    744759png_write_sRGB(png_structp png_ptr, int srgb_intent)
    745760{
    746 #ifdef PNG_USE_LOCAL_ARRAYS
    747761   PNG_sRGB;
    748 #endif
    749762   png_byte buf[1];
    750763
     
    759772#endif
    760773
    761 #if defined(PNG_WRITE_iCCP_SUPPORTED)
     774#ifdef PNG_WRITE_iCCP_SUPPORTED
    762775/* Write an iCCP chunk */
    763776void /* PRIVATE */
     
    765778   png_charp profile, int profile_len)
    766779{
    767 #ifdef PNG_USE_LOCAL_ARRAYS
    768780   PNG_iCCP;
    769 #endif
    770781   png_size_t name_len;
    771782   png_charp new_name;
     
    840851#endif
    841852
    842 #if defined(PNG_WRITE_sPLT_SUPPORTED)
     853#ifdef PNG_WRITE_sPLT_SUPPORTED
    843854/* Write a sPLT chunk */
    844855void /* PRIVATE */
    845856png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette)
    846857{
    847 #ifdef PNG_USE_LOCAL_ARRAYS
    848858   PNG_sPLT;
    849 #endif
    850859   png_size_t name_len;
    851860   png_charp new_name;
    852861   png_byte entrybuf[10];
    853    int entry_size = (spalette->depth == 8 ? 6 : 10);
    854    int palette_size = entry_size * spalette->nentries;
     862   png_size_t entry_size = (spalette->depth == 8 ? 6 : 10);
     863   png_size_t palette_size = entry_size * spalette->nentries;
    855864   png_sPLT_entryp ep;
    856 #ifdef PNG_NO_POINTER_INDEXING
     865#ifndef PNG_POINTER_INDEXING_SUPPORTED
    857866   int i;
    858867#endif
     
    871880
    872881   /* Loop through each palette entry, writing appropriately */
    873 #ifndef PNG_NO_POINTER_INDEXING
     882#ifdef PNG_POINTER_INDEXING_SUPPORTED
    874883   for (ep = spalette->entries; ep<spalette->entries + spalette->nentries; ep++)
    875884   {
     
    921930#endif
    922931
    923 #if defined(PNG_WRITE_sBIT_SUPPORTED)
     932#ifdef PNG_WRITE_sBIT_SUPPORTED
    924933/* Write the sBIT chunk */
    925934void /* PRIVATE */
    926935png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type)
    927936{
    928 #ifdef PNG_USE_LOCAL_ARRAYS
    929937   PNG_sBIT;
    930 #endif
    931938   png_byte buf[4];
    932939   png_size_t size;
     
    978985#endif
    979986
    980 #if defined(PNG_WRITE_cHRM_SUPPORTED)
     987#ifdef PNG_WRITE_cHRM_SUPPORTED
    981988/* Write the cHRM chunk */
    982989#ifdef PNG_FLOATING_POINT_SUPPORTED
     
    986993   double blue_x, double blue_y)
    987994{
    988 #ifdef PNG_USE_LOCAL_ARRAYS
    989995   PNG_cHRM;
    990 #endif
    991996   png_byte buf[32];
    992997
     
    10051010   int_blue_y  = (png_uint_32)(blue_y  * 100000.0 + 0.5);
    10061011
    1007 #if !defined(PNG_NO_CHECK_cHRM)
     1012#ifdef PNG_CHECK_cHRM_SUPPORTED
    10081013   if (png_check_cHRM_fixed(png_ptr, int_white_x, int_white_y,
    10091014      int_red_x, int_red_y, int_green_x, int_green_y, int_blue_x, int_blue_y))
     
    10351040   png_fixed_point blue_y)
    10361041{
    1037 #ifdef PNG_USE_LOCAL_ARRAYS
    10381042   PNG_cHRM;
    1039 #endif
    10401043   png_byte buf[32];
    10411044
     
    10431046
    10441047   /* Each value is saved in 1/100,000ths */
    1045 #if !defined(PNG_NO_CHECK_cHRM)
     1048#ifdef PNG_CHECK_cHRM_SUPPORTED
    10461049   if (png_check_cHRM_fixed(png_ptr, white_x, white_y, red_x, red_y,
    10471050      green_x, green_y, blue_x, blue_y))
     
    10661069#endif
    10671070
    1068 #if defined(PNG_WRITE_tRNS_SUPPORTED)
     1071#ifdef PNG_WRITE_tRNS_SUPPORTED
    10691072/* Write the tRNS chunk */
    10701073void /* PRIVATE */
    1071 png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,
     1074png_write_tRNS(png_structp png_ptr, png_bytep trans_alpha, png_color_16p tran,
    10721075   int num_trans, int color_type)
    10731076{
    1074 #ifdef PNG_USE_LOCAL_ARRAYS
    10751077   PNG_tRNS;
    1076 #endif
    10771078   png_byte buf[6];
    10781079
     
    10871088      }
    10881089      /* Write the chunk out as it is */
    1089       png_write_chunk(png_ptr, (png_bytep)png_tRNS, trans,
     1090      png_write_chunk(png_ptr, (png_bytep)png_tRNS, trans_alpha,
    10901091        (png_size_t)num_trans);
    10911092   }
     
    11231124#endif
    11241125
    1125 #if defined(PNG_WRITE_bKGD_SUPPORTED)
     1126#ifdef PNG_WRITE_bKGD_SUPPORTED
    11261127/* Write the background chunk */
    11271128void /* PRIVATE */
    11281129png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
    11291130{
    1130 #ifdef PNG_USE_LOCAL_ARRAYS
    11311131   PNG_bKGD;
    1132 #endif
    11331132   png_byte buf[6];
    11341133
     
    11381137   {
    11391138      if (
    1140 #if defined(PNG_MNG_FEATURES_SUPPORTED)
     1139#ifdef PNG_MNG_FEATURES_SUPPORTED
    11411140          (png_ptr->num_palette ||
    11421141          (!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) &&
     
    11771176#endif
    11781177
    1179 #if defined(PNG_WRITE_hIST_SUPPORTED)
     1178#ifdef PNG_WRITE_hIST_SUPPORTED
    11801179/* Write the histogram */
    11811180void /* PRIVATE */
    11821181png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist)
    11831182{
    1184 #ifdef PNG_USE_LOCAL_ARRAYS
    11851183   PNG_hIST;
    1186 #endif
    11871184   int i;
    11881185   png_byte buf[3];
     
    12541251         ((png_byte)*kp > 0x7E && (png_byte)*kp < 0xA1))
    12551252      {
    1256 #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
     1253#ifdef PNG_STDIO_SUPPORTED
    12571254         char msg[40];
    12581255
     
    13261323   {
    13271324      png_free(png_ptr, *new_key);
    1328        *new_key=NULL;
    13291325      png_warning(png_ptr, "Zero length keyword");
    13301326   }
     
    13411337#endif
    13421338
    1343 #if defined(PNG_WRITE_tEXt_SUPPORTED)
     1339#ifdef PNG_WRITE_tEXt_SUPPORTED
    13441340/* Write a tEXt chunk */
    13451341void /* PRIVATE */
     
    13471343   png_size_t text_len)
    13481344{
    1349 #ifdef PNG_USE_LOCAL_ARRAYS
    13501345   PNG_tEXt;
    1351 #endif
    13521346   png_size_t key_len;
    13531347   png_charp new_key;
     
    13821376#endif
    13831377
    1384 #if defined(PNG_WRITE_zTXt_SUPPORTED)
     1378#ifdef PNG_WRITE_zTXt_SUPPORTED
    13851379/* Write a compressed text chunk */
    13861380void /* PRIVATE */
     
    13881382   png_size_t text_len, int compression)
    13891383{
    1390 #ifdef PNG_USE_LOCAL_ARRAYS
    13911384   PNG_zTXt;
    1392 #endif
    13931385   png_size_t key_len;
    13941386   char buf[1];
     
    14421434#endif
    14431435
    1444 #if defined(PNG_WRITE_iTXt_SUPPORTED)
     1436#ifdef PNG_WRITE_iTXt_SUPPORTED
    14451437/* Write an iTXt chunk */
    14461438void /* PRIVATE */
     
    14481440    png_charp lang, png_charp lang_key, png_charp text)
    14491441{
    1450 #ifdef PNG_USE_LOCAL_ARRAYS
    14511442   PNG_iTXt;
    1452 #endif
    14531443   png_size_t lang_len, key_len, lang_key_len, text_len;
    14541444   png_charp new_lang;
     
    15311521#endif
    15321522
    1533 #if defined(PNG_WRITE_oFFs_SUPPORTED)
     1523#ifdef PNG_WRITE_oFFs_SUPPORTED
    15341524/* Write the oFFs chunk */
    15351525void /* PRIVATE */
     
    15371527   int unit_type)
    15381528{
    1539 #ifdef PNG_USE_LOCAL_ARRAYS
    15401529   PNG_oFFs;
    1541 #endif
    15421530   png_byte buf[9];
    15431531
     
    15541542}
    15551543#endif
    1556 #if defined(PNG_WRITE_pCAL_SUPPORTED)
     1544#ifdef PNG_WRITE_pCAL_SUPPORTED
    15571545/* Write the pCAL chunk (described in the PNG extensions document) */
    15581546void /* PRIVATE */
     
    15601548   png_int_32 X1, int type, int nparams, png_charp units, png_charpp params)
    15611549{
    1562 #ifdef PNG_USE_LOCAL_ARRAYS
    15631550   PNG_pCAL;
    1564 #endif
    15651551   png_size_t purpose_len, units_len, total_len;
    15661552   png_uint_32p params_len;
     
    15811567
    15821568   params_len = (png_uint_32p)png_malloc(png_ptr,
    1583       (png_uint_32)(nparams * png_sizeof(png_uint_32)));
     1569      (png_alloc_size_t)(nparams * png_sizeof(png_uint_32)));
    15841570
    15851571   /* Find the length of each parameter, making sure we don't count the
     
    16171603#endif
    16181604
    1619 #if defined(PNG_WRITE_sCAL_SUPPORTED)
     1605#ifdef PNG_WRITE_sCAL_SUPPORTED
    16201606/* Write the sCAL chunk */
    1621 #if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO)
     1607#if defined(PNG_FLOATING_POINT_SUPPORTED) && defined(PNG_STDIO_SUPPORTED)
    16221608void /* PRIVATE */
    16231609png_write_sCAL(png_structp png_ptr, int unit, double width, double height)
    16241610{
    1625 #ifdef PNG_USE_LOCAL_ARRAYS
    16261611   PNG_sCAL;
    1627 #endif
    16281612   char buf[64];
    16291613   png_size_t total_len;
     
    16321616
    16331617   buf[0] = (char)unit;
    1634 #if defined(_WIN32_WCE)
    1635 /* sprintf() function is not supported on WindowsCE */
    1636    {
    1637       wchar_t wc_buf[32];
    1638       size_t wc_len;
    1639       swprintf(wc_buf, TEXT("%12.12e"), width);
    1640       wc_len = wcslen(wc_buf);
    1641       WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, buf + 1, wc_len, NULL, NULL);
    1642       total_len = wc_len + 2;
    1643       swprintf(wc_buf, TEXT("%12.12e"), height);
    1644       wc_len = wcslen(wc_buf);
    1645       WideCharToMultiByte(CP_ACP, 0, wc_buf, -1, buf + total_len, wc_len,
    1646          NULL, NULL);
    1647       total_len += wc_len;
    1648    }
    1649 #else
    16501618   png_snprintf(buf + 1, 63, "%12.12e", width);
    16511619   total_len = 1 + png_strlen(buf + 1) + 1;
    16521620   png_snprintf(buf + total_len, 64-total_len, "%12.12e", height);
    16531621   total_len += png_strlen(buf + total_len);
    1654 #endif
    16551622
    16561623   png_debug1(3, "sCAL total length = %u", (unsigned int)total_len);
     
    16631630   png_charp height)
    16641631{
    1665 #ifdef PNG_USE_LOCAL_ARRAYS
    16661632   PNG_sCAL;
    1667 #endif
    16681633   png_byte buf[64];
    16691634   png_size_t wlen, hlen, total_len;
     
    16911656#endif
    16921657
    1693 #if defined(PNG_WRITE_pHYs_SUPPORTED)
     1658#ifdef PNG_WRITE_pHYs_SUPPORTED
    16941659/* Write the pHYs chunk */
    16951660void /* PRIVATE */
     
    16981663   int unit_type)
    16991664{
    1700 #ifdef PNG_USE_LOCAL_ARRAYS
    17011665   PNG_pHYs;
    1702 #endif
    17031666   png_byte buf[9];
    17041667
     
    17161679#endif
    17171680
    1718 #if defined(PNG_WRITE_tIME_SUPPORTED)
     1681#ifdef PNG_WRITE_tIME_SUPPORTED
    17191682/* Write the tIME chunk.  Use either png_convert_from_struct_tm()
    17201683 * or png_convert_from_time_t(), or fill in the structure yourself.
     
    17231686png_write_tIME(png_structp png_ptr, png_timep mod_time)
    17241687{
    1725 #ifdef PNG_USE_LOCAL_ARRAYS
    17261688   PNG_tIME;
    1727 #endif
    17281689   png_byte buf[7];
    17291690
     
    17541715{
    17551716#ifdef PNG_WRITE_INTERLACING_SUPPORTED
    1756 #ifdef PNG_USE_LOCAL_ARRAYS
    17571717   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
    17581718
     
    17691729   int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
    17701730#endif
    1771 #endif
    17721731
    17731732   png_size_t buf_size;
     
    17801739   /* Set up row buffer */
    17811740   png_ptr->row_buf = (png_bytep)png_malloc(png_ptr,
    1782      (png_uint_32)buf_size);
     1741     (png_alloc_size_t)buf_size);
    17831742   png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE;
    17841743
    1785 #ifndef PNG_NO_WRITE_FILTER
     1744#ifdef PNG_WRITE_FILTER_SUPPORTED
    17861745   /* Set up filtering buffer, if using this filter */
    17871746   if (png_ptr->do_filter & PNG_FILTER_SUB)
    17881747   {
    17891748      png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,
    1790          (png_uint_32)(png_ptr->rowbytes + 1));
     1749         (png_alloc_size_t)(png_ptr->rowbytes + 1));
    17911750      png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
    17921751   }
     
    17951754   if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH))
    17961755   {
    1797      /* Set up previous row buffer */
    1798      png_ptr->prev_row = (png_bytep)png_malloc(png_ptr,
    1799         (png_uint_32)buf_size);
    1800      png_memset(png_ptr->prev_row, 0, buf_size);
     1756      /* Set up previous row buffer */
     1757      png_ptr->prev_row = (png_bytep)png_calloc(png_ptr,
     1758         (png_alloc_size_t)buf_size);
    18011759
    18021760      if (png_ptr->do_filter & PNG_FILTER_UP)
    18031761      {
    18041762         png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
    1805            (png_uint_32)(png_ptr->rowbytes + 1));
     1763            (png_size_t)(png_ptr->rowbytes + 1));
    18061764         png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
    18071765      }
     
    18101768      {
    18111769         png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
    1812            (png_uint_32)(png_ptr->rowbytes + 1));
     1770            (png_alloc_size_t)(png_ptr->rowbytes + 1));
    18131771         png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
    18141772      }
     
    18171775      {
    18181776         png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,
    1819            (png_uint_32)(png_ptr->rowbytes + 1));
     1777            (png_size_t)(png_ptr->rowbytes + 1));
    18201778         png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
    18211779      }
    18221780   }
    1823 #endif /* PNG_NO_WRITE_FILTER */
     1781#endif /* PNG_WRITE_FILTER_SUPPORTED */
    18241782
    18251783#ifdef PNG_WRITE_INTERLACING_SUPPORTED
     
    18551813{
    18561814#ifdef PNG_WRITE_INTERLACING_SUPPORTED
    1857 #ifdef PNG_USE_LOCAL_ARRAYS
    18581815   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
    18591816
     
    18691826   /* Offset to next interlace block in the y direction */
    18701827   int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
    1871 #endif
    18721828#endif
    18731829
     
    19631919}
    19641920
    1965 #if defined(PNG_WRITE_INTERLACING_SUPPORTED)
     1921#ifdef PNG_WRITE_INTERLACING_SUPPORTED
    19661922/* Pick out the correct pixels for the interlace pass.
    19671923 * The basic idea here is to go through the row with a source
     
    19741930png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
    19751931{
    1976 #ifdef PNG_USE_LOCAL_ARRAYS
    19771932   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
    19781933
     
    19821937   /* Offset to next interlace block */
    19831938   int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
    1984 #endif
    19851939
    19861940   png_debug(1, "in png_do_write_interlace");
    19871941
    19881942   /* We don't have to do anything on the last pass (6) */
    1989 #if defined(PNG_USELESS_TESTS_SUPPORTED)
    1990    if (row != NULL && row_info != NULL && pass < 6)
    1991 #else
    19921943   if (pass < 6)
    1993 #endif
    19941944   {
    19951945      /* Each pixel depth is handled separately */
     
    21472097{
    21482098   png_bytep best_row;
    2149 #ifndef PNG_NO_WRITE_FILTER
     2099#ifdef PNG_WRITE_FILTER_SUPPORTED
    21502100   png_bytep prev_row, row_buf;
    21512101   png_uint_32 mins, bpp;
     
    21582108   png_debug(1, "in png_write_find_filter");
    21592109
     2110#ifndef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
     2111  if (png_ptr->row_number == 0 && filter_to_do == PNG_ALL_FILTERS)
     2112  {
     2113      /* These will never be selected so we need not test them. */
     2114      filter_to_do &= ~(PNG_FILTER_UP | PNG_FILTER_PAETH);
     2115  }
     2116#endif
     2117
    21602118   /* Find out how many bytes offset each pixel is */
    21612119   bpp = (row_info->pixel_depth + 7) >> 3;
     
    21642122#endif
    21652123   best_row = png_ptr->row_buf;
    2166 #ifndef PNG_NO_WRITE_FILTER
     2124#ifdef PNG_WRITE_FILTER_SUPPORTED
    21672125   row_buf = best_row;
    21682126   mins = PNG_MAXSUM;
     
    22072165      }
    22082166
    2209 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
     2167#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
    22102168      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
    22112169      {
     
    22712229      int v;
    22722230
    2273 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
     2231#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
    22742232      /* We temporarily increase the "minimum sum" by the factor we
    22752233       * would reduce the sum of this filter, so that we can do the
     
    23242282      }
    23252283
    2326 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
     2284#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
    23272285      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
    23282286      {
     
    23852343
    23862344
    2387 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
     2345#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
    23882346      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
    23892347      {
     
    24272385      }
    24282386
    2429 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
     2387#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
    24302388      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
    24312389      {
     
    24902448      int v;
    24912449
    2492 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
     2450#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
    24932451      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
    24942452      {
     
    25392497      }
    25402498
    2541 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
     2499#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
    25422500      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
    25432501      {
     
    26232581      int v;
    26242582
    2625 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
     2583#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
    26262584      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
    26272585      {
     
    27042662      }
    27052663
    2706 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
     2664#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
    27072665      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
    27082666      {
     
    27402698      }
    27412699   }
    2742 #endif /* PNG_NO_WRITE_FILTER */
     2700#endif /* PNG_WRITE_FILTER_SUPPORTED */
    27432701   /* Do the actual writing of the filtered row data from the chosen filter. */
    27442702
    27452703   png_write_filtered_row(png_ptr, best_row);
    27462704
    2747 #ifndef PNG_NO_WRITE_FILTER
    2748 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
     2705#ifdef PNG_WRITE_FILTER_SUPPORTED
     2706#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
    27492707   /* Save the type of filter we picked this time for future calculations */
    27502708   if (png_ptr->num_prev_filters > 0)
     
    27582716   }
    27592717#endif
    2760 #endif /* PNG_NO_WRITE_FILTER */
     2718#endif /* PNG_WRITE_FILTER_SUPPORTED */
    27612719}
    27622720
     
    28132771   png_write_finish_row(png_ptr);
    28142772
    2815 #if defined(PNG_WRITE_FLUSH_SUPPORTED)
     2773#ifdef PNG_WRITE_FLUSH_SUPPORTED
    28162774   png_ptr->flush_rows++;
    28172775
Note: See TracChangeset for help on using the changeset viewer.