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/pngget.c

    r561 r846  
    22/* pngget.c - retrieval of values from info struct
    33 *
    4  * Last changed in libpng 1.2.37 [June 4, 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.)
     
    1313 */
    1414
    15 #define PNG_INTERNAL
     15#define PNG_NO_PEDANTIC_WARNINGS
    1616#include "png.h"
    1717#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
     18#include "pngpriv.h"
    1819
    1920png_uint_32 PNGAPI
     
    2728}
    2829
    29 png_uint_32 PNGAPI
     30png_size_t PNGAPI
    3031png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
    3132{
     
    3738}
    3839
    39 #if defined(PNG_INFO_IMAGE_SUPPORTED)
     40#ifdef PNG_INFO_IMAGE_SUPPORTED
    4041png_bytepp PNGAPI
    4142png_get_rows(png_structp png_ptr, png_infop info_ptr)
     
    118119{
    119120   if (png_ptr != NULL && info_ptr != NULL)
    120 #if defined(PNG_pHYs_SUPPORTED)
     121#ifdef PNG_pHYs_SUPPORTED
    121122   if (info_ptr->valid & PNG_INFO_pHYs)
    122123   {
     
    139140{
    140141   if (png_ptr != NULL && info_ptr != NULL)
    141 #if defined(PNG_pHYs_SUPPORTED)
     142#ifdef PNG_pHYs_SUPPORTED
    142143   if (info_ptr->valid & PNG_INFO_pHYs)
    143144   {
     
    160161{
    161162   if (png_ptr != NULL && info_ptr != NULL)
    162 #if defined(PNG_pHYs_SUPPORTED)
     163#ifdef PNG_pHYs_SUPPORTED
    163164   if (info_ptr->valid & PNG_INFO_pHYs)
    164165   {
     
    183184   {
    184185   if (png_ptr != NULL && info_ptr != NULL)
    185 #if defined(PNG_pHYs_SUPPORTED)
     186#ifdef PNG_pHYs_SUPPORTED
    186187
    187188   if (info_ptr->valid & PNG_INFO_pHYs)
    188189   {
    189190      png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
     191
    190192      if (info_ptr->x_pixels_per_unit == 0)
    191193         return ((float)0.0);
     194
    192195      else
    193196         return ((float)((float)info_ptr->y_pixels_per_unit
     
    205208{
    206209   if (png_ptr != NULL && info_ptr != NULL)
    207 #if defined(PNG_oFFs_SUPPORTED)
     210#ifdef PNG_oFFs_SUPPORTED
    208211
    209212   if (info_ptr->valid & PNG_INFO_oFFs)
     
    228231   if (png_ptr != NULL && info_ptr != NULL)
    229232
    230 #if defined(PNG_oFFs_SUPPORTED)
     233#ifdef PNG_oFFs_SUPPORTED
    231234   if (info_ptr->valid & PNG_INFO_oFFs)
    232235   {
     
    250253   if (png_ptr != NULL && info_ptr != NULL)
    251254
    252 #if defined(PNG_oFFs_SUPPORTED)
     255#ifdef PNG_oFFs_SUPPORTED
    253256   if (info_ptr->valid & PNG_INFO_oFFs)
    254257   {
     
    272275   if (png_ptr != NULL && info_ptr != NULL)
    273276
    274 #if defined(PNG_oFFs_SUPPORTED)
     277#ifdef PNG_oFFs_SUPPORTED
    275278   if (info_ptr->valid & PNG_INFO_oFFs)
    276279   {
     
    325328}
    326329
    327 #if defined(PNG_pHYs_SUPPORTED)
     330#ifdef PNG_pHYs_SUPPORTED
    328331png_uint_32 PNGAPI
    329332png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
     
    335338   {
    336339      png_debug1(1, "in %s retrieval function", "pHYs");
     340
    337341      if (res_x != NULL)
    338342      {
     
    383387}
    384388
    385 #if defined(PNG_bKGD_SUPPORTED)
     389#ifdef PNG_bKGD_SUPPORTED
    386390png_uint_32 PNGAPI
    387391png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
     
    392396   {
    393397      png_debug1(1, "in %s retrieval function", "bKGD");
     398
    394399      *background = &(info_ptr->background);
    395400      return (PNG_INFO_bKGD);
     
    399404#endif
    400405
    401 #if defined(PNG_cHRM_SUPPORTED)
     406#ifdef PNG_cHRM_SUPPORTED
    402407#ifdef PNG_FLOATING_POINT_SUPPORTED
    403408png_uint_32 PNGAPI
     
    409414   {
    410415      png_debug1(1, "in %s retrieval function", "cHRM");
     416
    411417      if (white_x != NULL)
    412418         *white_x = (double)info_ptr->x_white;
     
    437443   png_fixed_point *blue_x, png_fixed_point *blue_y)
    438444{
     445   png_debug1(1, "in %s retrieval function", "cHRM");
     446
    439447   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
    440448   {
    441       png_debug1(1, "in %s retrieval function", "cHRM");
    442449      if (white_x != NULL)
    443450         *white_x = info_ptr->int_x_white;
     
    463470#endif
    464471
    465 #if defined(PNG_gAMA_SUPPORTED)
     472#ifdef PNG_gAMA_SUPPORTED
    466473#ifdef PNG_FLOATING_POINT_SUPPORTED
    467474png_uint_32 PNGAPI
    468475png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
    469476{
     477   png_debug1(1, "in %s retrieval function", "gAMA");
     478
    470479   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
    471480      && file_gamma != NULL)
    472481   {
    473       png_debug1(1, "in %s retrieval function", "gAMA");
    474482      *file_gamma = (double)info_ptr->gamma;
    475483      return (PNG_INFO_gAMA);
     
    483491    png_fixed_point *int_file_gamma)
    484492{
     493   png_debug1(1, "in %s retrieval function", "gAMA");
     494
    485495   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
    486496      && int_file_gamma != NULL)
    487497   {
    488       png_debug1(1, "in %s retrieval function", "gAMA");
    489498      *int_file_gamma = info_ptr->int_gamma;
    490499      return (PNG_INFO_gAMA);
     
    495504#endif
    496505
    497 #if defined(PNG_sRGB_SUPPORTED)
     506#ifdef PNG_sRGB_SUPPORTED
    498507png_uint_32 PNGAPI
    499508png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
    500509{
     510   png_debug1(1, "in %s retrieval function", "sRGB");
     511
    501512   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
    502513      && file_srgb_intent != NULL)
    503514   {
    504       png_debug1(1, "in %s retrieval function", "sRGB");
    505515      *file_srgb_intent = (int)info_ptr->srgb_intent;
    506516      return (PNG_INFO_sRGB);
     
    510520#endif
    511521
    512 #if defined(PNG_iCCP_SUPPORTED)
     522#ifdef PNG_iCCP_SUPPORTED
    513523png_uint_32 PNGAPI
    514524png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
     
    516526             png_charpp profile, png_uint_32 *proflen)
    517527{
     528   png_debug1(1, "in %s retrieval function", "iCCP");
     529
    518530   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
    519531      && name != NULL && profile != NULL && proflen != NULL)
    520532   {
    521       png_debug1(1, "in %s retrieval function", "iCCP");
    522533      *name = info_ptr->iccp_name;
    523534      *profile = info_ptr->iccp_profile;
     
    533544#endif
    534545
    535 #if defined(PNG_sPLT_SUPPORTED)
     546#ifdef PNG_sPLT_SUPPORTED
    536547png_uint_32 PNGAPI
    537548png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
     
    547558#endif
    548559
    549 #if defined(PNG_hIST_SUPPORTED)
     560#ifdef PNG_hIST_SUPPORTED
    550561png_uint_32 PNGAPI
    551562png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
    552563{
     564   png_debug1(1, "in %s retrieval function", "hIST");
     565
    553566   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
    554567      && hist != NULL)
    555568   {
    556       png_debug1(1, "in %s retrieval function", "hIST");
    557569      *hist = info_ptr->hist;
    558570      return (PNG_INFO_hIST);
     
    569581
    570582{
    571    if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL &&
    572       bit_depth != NULL && color_type != NULL)
    573    {
    574       png_debug1(1, "in %s retrieval function", "IHDR");
    575       *width = info_ptr->width;
    576       *height = info_ptr->height;
    577       *bit_depth = info_ptr->bit_depth;
    578       if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16)
    579          png_error(png_ptr, "Invalid bit depth");
    580 
    581       *color_type = info_ptr->color_type;
    582 
    583       if (info_ptr->color_type > 6)
    584          png_error(png_ptr, "Invalid color type");
    585 
    586       if (compression_type != NULL)
    587          *compression_type = info_ptr->compression_type;
    588 
    589       if (filter_type != NULL)
    590          *filter_type = info_ptr->filter_type;
    591 
    592       if (interlace_type != NULL)
    593          *interlace_type = info_ptr->interlace_type;
    594 
    595       /* Check for potential overflow of rowbytes */
    596       if (*width == 0 || *width > PNG_UINT_31_MAX)
    597         png_error(png_ptr, "Invalid image width");
    598 
    599       if (*height == 0 || *height > PNG_UINT_31_MAX)
    600         png_error(png_ptr, "Invalid image height");
    601 
    602       if (info_ptr->width > (PNG_UINT_32_MAX
    603                  >> 3)      /* 8-byte RGBA pixels */
    604                  - 64       /* bigrowbuf hack */
    605                  - 1        /* filter byte */
    606                  - 7*8      /* rounding of width to multiple of 8 pixels */
    607                  - 8)       /* extra max_pixel_depth pad */
    608       {
    609          png_warning(png_ptr,
    610             "Width too large for libpng to process image data.");
    611       }
    612 
    613       return (1);
    614    }
    615    return (0);
    616 }
    617 
    618 #if defined(PNG_oFFs_SUPPORTED)
     583   png_debug1(1, "in %s retrieval function", "IHDR");
     584
     585   if (png_ptr == NULL || info_ptr == NULL || width == NULL ||
     586       height == NULL || bit_depth == NULL || color_type == NULL)
     587      return (0);
     588
     589   *width = info_ptr->width;
     590   *height = info_ptr->height;
     591   *bit_depth = info_ptr->bit_depth;
     592   *color_type = info_ptr->color_type;
     593
     594   if (compression_type != NULL)
     595      *compression_type = info_ptr->compression_type;
     596
     597   if (filter_type != NULL)
     598      *filter_type = info_ptr->filter_type;
     599
     600   if (interlace_type != NULL)
     601      *interlace_type = info_ptr->interlace_type;
     602
     603   /* This is redundant if we can be sure that the info_ptr values were all
     604    * assigned in png_set_IHDR().  We do the check anyhow in case an
     605    * application has ignored our advice not to mess with the members
     606    * of info_ptr directly.
     607    */
     608   png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height,
     609       info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
     610       info_ptr->compression_type, info_ptr->filter_type);
     611
     612   return (1);
     613}
     614
     615#ifdef PNG_oFFs_SUPPORTED
    619616png_uint_32 PNGAPI
    620617png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
    621618   png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
    622619{
     620   png_debug1(1, "in %s retrieval function", "oFFs");
     621
    623622   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
    624623      && offset_x != NULL && offset_y != NULL && unit_type != NULL)
    625624   {
    626       png_debug1(1, "in %s retrieval function", "oFFs");
    627625      *offset_x = info_ptr->x_offset;
    628626      *offset_y = info_ptr->y_offset;
     
    634632#endif
    635633
    636 #if defined(PNG_pCAL_SUPPORTED)
     634#ifdef PNG_pCAL_SUPPORTED
    637635png_uint_32 PNGAPI
    638636png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
     
    640638   png_charp *units, png_charpp *params)
    641639{
     640   png_debug1(1, "in %s retrieval function", "pCAL");
     641
    642642   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
    643643       && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
    644644       nparams != NULL && units != NULL && params != NULL)
    645645   {
    646       png_debug1(1, "in %s retrieval function", "pCAL");
    647646      *purpose = info_ptr->pcal_purpose;
    648647      *X0 = info_ptr->pcal_X0;
     
    658657#endif
    659658
    660 #if defined(PNG_sCAL_SUPPORTED)
     659#ifdef PNG_sCAL_SUPPORTED
    661660#ifdef PNG_FLOATING_POINT_SUPPORTED
    662661png_uint_32 PNGAPI
     
    694693#endif
    695694
    696 #if defined(PNG_pHYs_SUPPORTED)
     695#ifdef PNG_pHYs_SUPPORTED
    697696png_uint_32 PNGAPI
    698697png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
     
    701700   png_uint_32 retval = 0;
    702701
     702   png_debug1(1, "in %s retrieval function", "pHYs");
     703
    703704   if (png_ptr != NULL && info_ptr != NULL &&
    704705      (info_ptr->valid & PNG_INFO_pHYs))
    705706   {
    706       png_debug1(1, "in %s retrieval function", "pHYs");
    707 
    708707      if (res_x != NULL)
    709708      {
     
    732731   int *num_palette)
    733732{
     733   png_debug1(1, "in %s retrieval function", "PLTE");
     734
    734735   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
    735736       && palette != NULL)
    736737   {
    737       png_debug1(1, "in %s retrieval function", "PLTE");
    738738      *palette = info_ptr->palette;
    739739      *num_palette = info_ptr->num_palette;
     
    744744}
    745745
    746 #if defined(PNG_sBIT_SUPPORTED)
     746#ifdef PNG_sBIT_SUPPORTED
    747747png_uint_32 PNGAPI
    748748png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
    749749{
     750   png_debug1(1, "in %s retrieval function", "sBIT");
     751
    750752   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
    751753      && sig_bit != NULL)
    752754   {
    753       png_debug1(1, "in %s retrieval function", "sBIT");
    754755      *sig_bit = &(info_ptr->sig_bit);
    755756      return (PNG_INFO_sBIT);
     
    759760#endif
    760761
    761 #if defined(PNG_TEXT_SUPPORTED)
     762#ifdef PNG_TEXT_SUPPORTED
    762763png_uint_32 PNGAPI
    763764png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
     
    784785#endif
    785786
    786 #if defined(PNG_tIME_SUPPORTED)
     787#ifdef PNG_tIME_SUPPORTED
    787788png_uint_32 PNGAPI
    788789png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
    789790{
     791   png_debug1(1, "in %s retrieval function", "tIME");
     792
    790793   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
    791794       && mod_time != NULL)
    792795   {
    793       png_debug1(1, "in %s retrieval function", "tIME");
    794796      *mod_time = &(info_ptr->mod_time);
    795797      return (PNG_INFO_tIME);
     
    799801#endif
    800802
    801 #if defined(PNG_tRNS_SUPPORTED)
     803#ifdef PNG_tRNS_SUPPORTED
    802804png_uint_32 PNGAPI
    803805png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
    804    png_bytep *trans, int *num_trans, png_color_16p *trans_values)
     806   png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
    805807{
    806808   png_uint_32 retval = 0;
     
    808810   {
    809811      png_debug1(1, "in %s retrieval function", "tRNS");
     812
    810813      if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
    811814      {
    812           if (trans != NULL)
     815          if (trans_alpha != NULL)
    813816          {
    814              *trans = info_ptr->trans;
     817             *trans_alpha = info_ptr->trans_alpha;
    815818             retval |= PNG_INFO_tRNS;
    816819          }
    817820
    818           if (trans_values != NULL)
    819              *trans_values = &(info_ptr->trans_values);
     821          if (trans_color != NULL)
     822             *trans_color = &(info_ptr->trans_color);
    820823      }
    821824      else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
    822825      {
    823           if (trans_values != NULL)
     826          if (trans_color != NULL)
    824827          {
    825              *trans_values = &(info_ptr->trans_values);
     828             *trans_color = &(info_ptr->trans_color);
    826829             retval |= PNG_INFO_tRNS;
    827830          }
    828831
    829           if (trans != NULL)
    830              *trans = NULL;
     832          if (trans_alpha != NULL)
     833             *trans_alpha = NULL;
    831834      }
    832835      if (num_trans != NULL)
     
    840843#endif
    841844
    842 #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
     845#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
    843846png_uint_32 PNGAPI
    844847png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
     
    854857#endif
    855858
    856 #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
     859#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
    857860png_byte PNGAPI
    858861png_get_rgb_to_gray_status (png_structp png_ptr)
     
    862865#endif
    863866
    864 #if defined(PNG_USER_CHUNKS_SUPPORTED)
     867#ifdef PNG_USER_CHUNKS_SUPPORTED
    865868png_voidp PNGAPI
    866869png_get_user_chunk_ptr(png_structp png_ptr)
     
    871874
    872875#ifdef PNG_WRITE_SUPPORTED
    873 png_uint_32 PNGAPI
     876png_size_t PNGAPI
    874877png_get_compression_buffer_size(png_structp png_ptr)
    875878{
    876    return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L);
    877 }
    878 #endif
    879 
    880 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
    881 #ifndef PNG_1_0_X
    882 /* This function was added to libpng 1.2.0 and should exist by default */
    883 png_uint_32 PNGAPI
    884 png_get_asm_flags (png_structp png_ptr)
    885 {
    886     /* Obsolete, to be removed from libpng-1.4.0 */
    887     return (png_ptr? 0L: 0L);
    888 }
    889 
    890 /* This function was added to libpng 1.2.0 and should exist by default */
    891 png_uint_32 PNGAPI
    892 png_get_asm_flagmask (int flag_select)
    893 {
    894     /* Obsolete, to be removed from libpng-1.4.0 */
    895     flag_select=flag_select;
    896     return 0L;
    897 }
    898 
    899     /* GRR:  could add this:   && defined(PNG_MMX_CODE_SUPPORTED) */
    900 /* This function was added to libpng 1.2.0 */
    901 png_uint_32 PNGAPI
    902 png_get_mmx_flagmask (int flag_select, int *compilerID)
    903 {
    904     /* Obsolete, to be removed from libpng-1.4.0 */
    905     flag_select=flag_select;
    906     *compilerID = -1;   /* unknown (i.e., no asm/MMX code compiled) */
    907     return 0L;
    908 }
    909 
    910 /* This function was added to libpng 1.2.0 */
    911 png_byte PNGAPI
    912 png_get_mmx_bitdepth_threshold (png_structp png_ptr)
    913 {
    914     /* Obsolete, to be removed from libpng-1.4.0 */
    915     return (png_ptr? 0: 0);
    916 }
    917 
    918 /* This function was added to libpng 1.2.0 */
    919 png_uint_32 PNGAPI
    920 png_get_mmx_rowbytes_threshold (png_structp png_ptr)
    921 {
    922     /* Obsolete, to be removed from libpng-1.4.0 */
    923     return (png_ptr? 0L: 0L);
    924 }
    925 #endif /* ?PNG_1_0_X */
    926 #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
     879   return (png_ptr ? png_ptr->zbuf_size : 0L);
     880}
     881#endif
     882
    927883
    928884#ifdef PNG_SET_USER_LIMITS_SUPPORTED
     
    938894    return (png_ptr? png_ptr->user_height_max : 0);
    939895}
     896/* This function was added to libpng 1.4.0 */
     897png_uint_32 PNGAPI
     898png_get_chunk_cache_max (png_structp png_ptr)
     899{
     900    return (png_ptr? png_ptr->user_chunk_cache_max? 0x7fffffffL :
     901       png_ptr->user_chunk_cache_max - 1 : 0);
     902}
    940903#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
    941904
     905#ifdef PNG_IO_STATE_SUPPORTED
     906png_uint_32 PNGAPI
     907png_get_io_state (png_structp png_ptr)
     908{
     909    return png_ptr->io_state;
     910}
     911
     912png_bytep PNGAPI
     913png_get_io_chunk_name (png_structp png_ptr)
     914{
     915   return png_ptr->chunk_name;
     916}
     917#endif /* ?PNG_IO_STATE_SUPPORTED */
    942918
    943919#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
Note: See TracChangeset for help on using the changeset viewer.