jdk/src/java.desktop/share/native/libsplashscreen/libpng/png.h
changeset 43321 2b8d397c03a4
parent 40436 94ae0ede53a5
equal deleted inserted replaced
43320:6351c8545289 43321:2b8d397c03a4
    27  * This file is available under and governed by the GNU General Public
    27  * This file is available under and governed by the GNU General Public
    28  * License version 2 only, as published by the Free Software Foundation.
    28  * License version 2 only, as published by the Free Software Foundation.
    29  * However, the following notice accompanied the original version of this
    29  * However, the following notice accompanied the original version of this
    30  * file and, per its terms, should not be removed:
    30  * file and, per its terms, should not be removed:
    31  *
    31  *
    32  * libpng version 1.6.23, June 9, 2016
    32  * libpng version 1.6.28, January 5, 2017
    33  *
    33  *
    34  * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
    34  * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
    35  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    35  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
    36  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
    36  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
    37  *
    37  *
    38  * This code is released under the libpng license (See LICENSE, below)
    38  * This code is released under the libpng license (See LICENSE, below)
    39  *
    39  *
    40  * Authors and maintainers:
    40  * Authors and maintainers:
    41  *   libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
    41  *   libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
    42  *   libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
    42  *   libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
    43  *   libpng versions 0.97, January 1998, through 1.6.23, June 9, 2016:
    43  *   libpng versions 0.97, January 1998, through 1.6.28, January 5, 2017:
    44  *     Glenn Randers-Pehrson.
    44  *     Glenn Randers-Pehrson.
    45  *   See also "Contributing Authors", below.
    45  *   See also "Contributing Authors", below.
    46  */
    46  */
    47 
    47 
    48 /*
    48 /*
    51  * If you modify libpng you may insert additional notices immediately following
    51  * If you modify libpng you may insert additional notices immediately following
    52  * this sentence.
    52  * this sentence.
    53  *
    53  *
    54  * This code is released under the libpng license.
    54  * This code is released under the libpng license.
    55  *
    55  *
    56  * Some files in the "contrib" directory and some configure-generated
    56  * libpng versions 1.0.7, July 1, 2000 through 1.6.28, January 5, 2017 are
    57  * files that are distributed with libpng have other copyright owners and
    57  * Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
    58  * are released under other open source licenses.
       
    59  *
       
    60  * libpng versions 1.0.7, July 1, 2000 through 1.6.23, June 9, 2016 are
       
    61  * Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
       
    62  * derived from libpng-1.0.6, and are distributed according to the same
    58  * derived from libpng-1.0.6, and are distributed according to the same
    63  * disclaimer and license as libpng-1.0.6 with the following individuals
    59  * disclaimer and license as libpng-1.0.6 with the following individuals
    64  * added to the list of Contributing Authors:
    60  * added to the list of Contributing Authors:
    65  *
    61  *
    66  *    Simon-Pierre Cadieux
    62  *    Simon-Pierre Cadieux
    67  *    Eric S. Raymond
    63  *    Eric S. Raymond
    68  *    Mans Rullgard
    64  *    Mans Rullgard
    69  *    Cosmin Truta
    65  *    Cosmin Truta
    70  *    Gilles Vollant
    66  *    Gilles Vollant
    71  *    James Yu
    67  *    James Yu
       
    68  *    Mandar Sahastrabuddhe
    72  *
    69  *
    73  * and with the following additions to the disclaimer:
    70  * and with the following additions to the disclaimer:
    74  *
    71  *
    75  *    There is no warranty against interference with your enjoyment of the
    72  *    There is no warranty against interference with your enjoyment of the
    76  *    library or against infringement.  There is no warranty that our
    73  *    library or against infringement.  There is no warranty that our
    77  *    efforts or the library will fulfill any of your particular purposes
    74  *    efforts or the library will fulfill any of your particular purposes
    78  *    or needs.  This library is provided with all faults, and the entire
    75  *    or needs.  This library is provided with all faults, and the entire
    79  *    risk of satisfactory quality, performance, accuracy, and effort is with
    76  *    risk of satisfactory quality, performance, accuracy, and effort is with
    80  *    the user.
    77  *    the user.
    81  *
    78  *
    82  * Some files in the "contrib" directory have other copyright owners and
    79  * Some files in the "contrib" directory and some configure-generated
       
    80  * files that are distributed with libpng have other copyright owners and
    83  * are released under other open source licenses.
    81  * are released under other open source licenses.
    84  *
       
    85  *
    82  *
    86  * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
    83  * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
    87  * Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
    84  * Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
    88  * libpng-0.96, and are distributed according to the same disclaimer and
    85  * libpng-0.96, and are distributed according to the same disclaimer and
    89  * license as libpng-0.96, with the following individuals added to the list
    86  * license as libpng-0.96, with the following individuals added to the list
    90  * of Contributing Authors:
    87  * of Contributing Authors:
    91  *
    88  *
    92  *    Tom Lane
    89  *    Tom Lane
    93  *    Glenn Randers-Pehrson
    90  *    Glenn Randers-Pehrson
    94  *    Willem van Schaik
    91  *    Willem van Schaik
    95  *
       
    96  * Some files in the "scripts" directory have different copyright owners
       
    97  * but are also released under this license.
       
    98  *
    92  *
    99  * libpng versions 0.89, June 1996, through 0.96, May 1997, are
    93  * libpng versions 0.89, June 1996, through 0.96, May 1997, are
   100  * Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
    94  * Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
   101  * and are distributed according to the same disclaimer and license as
    95  * and are distributed according to the same disclaimer and license as
   102  * libpng-0.88, with the following individuals added to the list of
    96  * libpng-0.88, with the following individuals added to the list of
   239  *    1.0.7rc1-2               1    10007  2.1.0.7rc1-2 (binary compatible)
   233  *    1.0.7rc1-2               1    10007  2.1.0.7rc1-2 (binary compatible)
   240  *    1.0.7                    1    10007  (still compatible)
   234  *    1.0.7                    1    10007  (still compatible)
   241  *    ...
   235  *    ...
   242  *    1.0.19                  10    10019  10.so.0.19[.0]
   236  *    1.0.19                  10    10019  10.so.0.19[.0]
   243  *    ...
   237  *    ...
   244  *    1.2.56                  13    10256  12.so.0.56[.0]
   238  *    1.2.57                  13    10257  12.so.0.57[.0]
   245  *    ...
   239  *    ...
   246  *    1.5.27                  15    10527  15.so.15.27[.0]
   240  *    1.5.28                  15    10527  15.so.15.28[.0]
   247  *    ...
   241  *    ...
   248  *    1.6.23                  16    10623  16.so.16.23[.0]
   242  *    1.6.28                  16    10628  16.so.16.28[.0]
   249  *
   243  *
   250  *    Henceforth the source version will match the shared-library major
   244  *    Henceforth the source version will match the shared-library major
   251  *    and minor numbers; the shared-library major version number will be
   245  *    and minor numbers; the shared-library major version number will be
   252  *    used for changes in backward compatibility, as it is intended.  The
   246  *    used for changes in backward compatibility, as it is intended.  The
   253  *    PNG_LIBPNG_VER macro, which is not used within libpng but is available
   247  *    PNG_LIBPNG_VER macro, which is not used within libpng but is available
   271 
   265 
   272 /*
   266 /*
   273  * Y2K compliance in libpng:
   267  * Y2K compliance in libpng:
   274  * =========================
   268  * =========================
   275  *
   269  *
   276  *    June 9, 2016
   270  *    January 5, 2017
   277  *
   271  *
   278  *    Since the PNG Development group is an ad-hoc body, we can't make
   272  *    Since the PNG Development group is an ad-hoc body, we can't make
   279  *    an official declaration.
   273  *    an official declaration.
   280  *
   274  *
   281  *    This is your unofficial assurance that libpng from version 0.71 and
   275  *    This is your unofficial assurance that libpng from version 0.71 and
   282  *    upward through 1.6.23 are Y2K compliant.  It is my belief that
   276  *    upward through 1.6.28 are Y2K compliant.  It is my belief that
   283  *    earlier versions were also Y2K compliant.
   277  *    earlier versions were also Y2K compliant.
   284  *
   278  *
   285  *    Libpng only has two year fields.  One is a 2-byte unsigned integer
   279  *    Libpng only has two year fields.  One is a 2-byte unsigned integer
   286  *    that will hold years up to 65535.  The other, which is deprecated,
   280  *    that will hold years up to 65535.  The other, which is deprecated,
   287  *    holds the date in text format, and will hold years up to 9999.
   281  *    holds the date in text format, and will hold years up to 9999.
   339  * If you just need to read a PNG file and don't want to read the documentation
   333  * If you just need to read a PNG file and don't want to read the documentation
   340  * skip to the end of this file and read the section entitled 'simplified API'.
   334  * skip to the end of this file and read the section entitled 'simplified API'.
   341  */
   335  */
   342 
   336 
   343 /* Version information for png.h - this should match the version in png.c */
   337 /* Version information for png.h - this should match the version in png.c */
   344 #define PNG_LIBPNG_VER_STRING "1.6.23"
   338 #define PNG_LIBPNG_VER_STRING "1.6.28"
   345 #define PNG_HEADER_VERSION_STRING \
   339 #define PNG_HEADER_VERSION_STRING " libpng version 1.6.28 - January 5, 2017\n"
   346      " libpng version 1.6.23 - June 9, 2016\n"
       
   347 
   340 
   348 #define PNG_LIBPNG_VER_SONUM   16
   341 #define PNG_LIBPNG_VER_SONUM   16
   349 #define PNG_LIBPNG_VER_DLLNUM  16
   342 #define PNG_LIBPNG_VER_DLLNUM  16
   350 
   343 
   351 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
   344 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
   352 #define PNG_LIBPNG_VER_MAJOR   1
   345 #define PNG_LIBPNG_VER_MAJOR   1
   353 #define PNG_LIBPNG_VER_MINOR   6
   346 #define PNG_LIBPNG_VER_MINOR   6
   354 #define PNG_LIBPNG_VER_RELEASE 23
   347 #define PNG_LIBPNG_VER_RELEASE 28
   355 
   348 
   356 /* This should match the numeric part of the final component of
   349 /* This should match the numeric part of the final component of
   357  * PNG_LIBPNG_VER_STRING, omitting any leading zero:
   350  * PNG_LIBPNG_VER_STRING, omitting any leading zero:
   358  */
   351  */
   359 
   352 
   380  * We must not include leading zeros.
   373  * We must not include leading zeros.
   381  * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
   374  * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
   382  * version 1.0.0 was mis-numbered 100 instead of 10000).  From
   375  * version 1.0.0 was mis-numbered 100 instead of 10000).  From
   383  * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release
   376  * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release
   384  */
   377  */
   385 #define PNG_LIBPNG_VER 10623 /* 1.6.23 */
   378 #define PNG_LIBPNG_VER 10628 /* 1.6.28 */
   386 
   379 
   387 /* Library configuration: these options cannot be changed after
   380 /* Library configuration: these options cannot be changed after
   388  * the library has been built.
   381  * the library has been built.
   389  */
   382  */
   390 #ifndef PNGLCONF_H
   383 #ifndef PNGLCONF_H
   391     /* If pnglibconf.h is missing, you can
   384 /* If pnglibconf.h is missing, you can
   392      * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h
   385  * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h
   393      */
   386  */
   394 #   include "pnglibconf.h"
   387 #   include "pnglibconf.h"
   395 #endif
   388 #endif
   396 
   389 
   397 #ifndef PNG_VERSION_INFO_ONLY
   390 #ifndef PNG_VERSION_INFO_ONLY
   398    /* Machine specific configuration. */
   391 /* Machine specific configuration. */
   399 #  include "pngconf.h"
   392 #  include "pngconf.h"
   400 #endif
   393 #endif
   401 
   394 
   402 /*
   395 /*
   403  * Added at libpng-1.2.8
   396  * Added at libpng-1.2.8
   490  */
   483  */
   491 
   484 
   492 /* This triggers a compiler error in png.c, if png.c and png.h
   485 /* This triggers a compiler error in png.c, if png.c and png.h
   493  * do not agree upon the version number.
   486  * do not agree upon the version number.
   494  */
   487  */
   495 typedef char* png_libpng_version_1_6_23;
   488 typedef char* png_libpng_version_1_6_28;
   496 
   489 
   497 /* Basic control structions.  Read libpng-manual.txt or libpng.3 for more info.
   490 /* Basic control structions.  Read libpng-manual.txt or libpng.3 for more info.
   498  *
   491  *
   499  * png_struct is the cache of information used while reading or writing a single
   492  * png_struct is the cache of information used while reading or writing a single
   500  * PNG file.  One of these is always required, although the simplified API
   493  * PNG file.  One of these is always required, although the simplified API
   683  *
   676  *
   684  * The data in the structure is set by libpng on read and used on write.
   677  * The data in the structure is set by libpng on read and used on write.
   685  */
   678  */
   686 typedef struct png_unknown_chunk_t
   679 typedef struct png_unknown_chunk_t
   687 {
   680 {
   688     png_byte name[5]; /* Textual chunk name with '\0' terminator */
   681    png_byte name[5]; /* Textual chunk name with '\0' terminator */
   689     png_byte *data;   /* Data, should not be modified on read! */
   682    png_byte *data;   /* Data, should not be modified on read! */
   690     png_size_t size;
   683    png_size_t size;
   691 
   684 
   692     /* On write 'location' must be set using the flag values listed below.
   685    /* On write 'location' must be set using the flag values listed below.
   693      * Notice that on read it is set by libpng however the values stored have
   686     * Notice that on read it is set by libpng however the values stored have
   694      * more bits set than are listed below.  Always treat the value as a
   687     * more bits set than are listed below.  Always treat the value as a
   695      * bitmask.  On write set only one bit - setting multiple bits may cause the
   688     * bitmask.  On write set only one bit - setting multiple bits may cause the
   696      * chunk to be written in multiple places.
   689     * chunk to be written in multiple places.
   697      */
   690     */
   698     png_byte location; /* mode of operation at read time */
   691    png_byte location; /* mode of operation at read time */
   699 }
   692 }
   700 png_unknown_chunk;
   693 png_unknown_chunk;
   701 
   694 
   702 typedef png_unknown_chunk * png_unknown_chunkp;
   695 typedef png_unknown_chunk * png_unknown_chunkp;
   703 typedef const png_unknown_chunk * png_const_unknown_chunkp;
   696 typedef const png_unknown_chunk * png_const_unknown_chunkp;
  2326  *    If num_chunks is negative, then the "keep" parameter specifies the manner
  2319  *    If num_chunks is negative, then the "keep" parameter specifies the manner
  2327  *    for handling all unknown chunks plus all chunks recognized by libpng
  2320  *    for handling all unknown chunks plus all chunks recognized by libpng
  2328  *    except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to
  2321  *    except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to
  2329  *    be processed by libpng.
  2322  *    be processed by libpng.
  2330  */
  2323  */
       
  2324 #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
  2331 PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr,
  2325 PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr,
  2332     int keep, png_const_bytep chunk_list, int num_chunks));
  2326     int keep, png_const_bytep chunk_list, int num_chunks));
       
  2327 #endif /* HANDLE_AS_UNKNOWN */
  2333 
  2328 
  2334 /* The "keep" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned;
  2329 /* The "keep" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned;
  2335  * the result is therefore true (non-zero) if special handling is required,
  2330  * the result is therefore true (non-zero) if special handling is required,
  2336  * false for the default handling.
  2331  * false for the default handling.
  2337  */
  2332  */
  2338 PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr,
  2333 PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr,
  2339     png_const_bytep chunk_name));
  2334     png_const_bytep chunk_name));
  2340 #endif
  2335 #endif /* SET_UNKNOWN_CHUNKS */
  2341 
  2336 
  2342 #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
  2337 #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
  2343 PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr,
  2338 PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr,
  2344     png_inforp info_ptr, png_const_unknown_chunkp unknowns,
  2339     png_inforp info_ptr, png_const_unknown_chunkp unknowns,
  2345     int num_unknowns));
  2340     int num_unknowns));
  2556  * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]
  2551  * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]
  2557  */
  2552  */
  2558 
  2553 
  2559  /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */
  2554  /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */
  2560 
  2555 
  2561 #  define png_composite(composite, fg, alpha, bg)         \
  2556 #  define png_composite(composite, fg, alpha, bg)        \
  2562      { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \
  2557    {                                                     \
  2563            * (png_uint_16)(alpha)                         \
  2558       png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \
  2564            + (png_uint_16)(bg)*(png_uint_16)(255          \
  2559           * (png_uint_16)(alpha)                         \
  2565            - (png_uint_16)(alpha)) + 128);                \
  2560           + (png_uint_16)(bg)*(png_uint_16)(255          \
  2566        (composite) = (png_byte)(((temp + (temp >> 8)) >> 8) & 0xff); }
  2561           - (png_uint_16)(alpha)) + 128);                \
  2567 
  2562       (composite) = (png_byte)(((temp + (temp >> 8)) >> 8) & 0xff); \
  2568 #  define png_composite_16(composite, fg, alpha, bg)       \
  2563    }
  2569      { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg)  \
  2564 
  2570            * (png_uint_32)(alpha)                          \
  2565 #  define png_composite_16(composite, fg, alpha, bg)     \
  2571            + (png_uint_32)(bg)*(65535                      \
  2566    {                                                     \
  2572            - (png_uint_32)(alpha)) + 32768);               \
  2567       png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \
  2573        (composite) = (png_uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); }
  2568           * (png_uint_32)(alpha)                         \
       
  2569           + (png_uint_32)(bg)*(65535                     \
       
  2570           - (png_uint_32)(alpha)) + 32768);              \
       
  2571       (composite) = (png_uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); \
       
  2572    }
  2574 
  2573 
  2575 #else  /* Standard method using integer division */
  2574 #else  /* Standard method using integer division */
  2576 
  2575 
  2577 #  define png_composite(composite, fg, alpha, bg)                        \
  2576 #  define png_composite(composite, fg, alpha, bg)                      \
  2578      (composite) =                                                       \
  2577    (composite) =                                                       \
  2579          (png_byte)(0xff & (((png_uint_16)(fg) * (png_uint_16)(alpha) +  \
  2578        (png_byte)(0xff & (((png_uint_16)(fg) * (png_uint_16)(alpha) +  \
  2580          (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \
  2579        (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \
  2581          127) / 255))
  2580        127) / 255))
  2582 
  2581 
  2583 #  define png_composite_16(composite, fg, alpha, bg)                         \
  2582 #  define png_composite_16(composite, fg, alpha, bg)                       \
  2584      (composite) =                                                           \
  2583    (composite) =                                                           \
  2585          (png_uint_16)(0xffff & (((png_uint_32)(fg) * (png_uint_32)(alpha) + \
  2584        (png_uint_16)(0xffff & (((png_uint_32)(fg) * (png_uint_32)(alpha) + \
  2586          (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) +     \
  2585        (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) +     \
  2587          32767) / 65535))
  2586        32767) / 65535))
  2588 #endif /* READ_COMPOSITE_NODIV */
  2587 #endif /* READ_COMPOSITE_NODIV */
  2589 
  2588 
  2590 #ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
  2589 #ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
  2591 PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf));
  2590 PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf));
  2592 PNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf));
  2591 PNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf));
  2618 /* Inline macros to do direct reads of bytes from the input buffer.
  2617 /* Inline macros to do direct reads of bytes from the input buffer.
  2619  * The png_get_int_32() routine assumes we are using two's complement
  2618  * The png_get_int_32() routine assumes we are using two's complement
  2620  * format for negative values, which is almost certainly true.
  2619  * format for negative values, which is almost certainly true.
  2621  */
  2620  */
  2622 #  define PNG_get_uint_32(buf) \
  2621 #  define PNG_get_uint_32(buf) \
  2623      (((png_uint_32)(*(buf)) << 24) + \
  2622    (((png_uint_32)(*(buf)) << 24) + \
  2624       ((png_uint_32)(*((buf) + 1)) << 16) + \
  2623     ((png_uint_32)(*((buf) + 1)) << 16) + \
  2625       ((png_uint_32)(*((buf) + 2)) << 8) + \
  2624     ((png_uint_32)(*((buf) + 2)) << 8) + \
  2626       ((png_uint_32)(*((buf) + 3))))
  2625     ((png_uint_32)(*((buf) + 3))))
  2627 
  2626 
  2628    /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
  2627    /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
  2629     * function) incorrectly returned a value of type png_uint_32.
  2628     * function) incorrectly returned a value of type png_uint_32.
  2630     */
  2629     */
  2631 #  define PNG_get_uint_16(buf) \
  2630 #  define PNG_get_uint_16(buf) \
  2632      ((png_uint_16) \
  2631    ((png_uint_16) \
  2633       (((unsigned int)(*(buf)) << 8) + \
  2632     (((unsigned int)(*(buf)) << 8) + \
  2634        ((unsigned int)(*((buf) + 1)))))
  2633     ((unsigned int)(*((buf) + 1)))))
  2635 
  2634 
  2636 #  define PNG_get_int_32(buf) \
  2635 #  define PNG_get_int_32(buf) \
  2637      ((png_int_32)((*(buf) & 0x80) \
  2636    ((png_int_32)((*(buf) & 0x80) \
  2638       ? -((png_int_32)(((png_get_uint_32(buf)^0xffffffffU)+1U)&0x7fffffffU)) \
  2637     ? -((png_int_32)(((png_get_uint_32(buf)^0xffffffffU)+1U)&0x7fffffffU)) \
  2639       : (png_int_32)png_get_uint_32(buf)))
  2638     : (png_int_32)png_get_uint_32(buf)))
  2640 
  2639 
  2641    /* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h,
  2640 /* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h,
  2642     * but defining a macro name prefixed with PNG_PREFIX.
  2641  * but defining a macro name prefixed with PNG_PREFIX.
  2643     */
  2642  */
  2644 #  ifndef PNG_PREFIX
  2643 #  ifndef PNG_PREFIX
  2645 #     define png_get_uint_32(buf) PNG_get_uint_32(buf)
  2644 #    define png_get_uint_32(buf) PNG_get_uint_32(buf)
  2646 #     define png_get_uint_16(buf) PNG_get_uint_16(buf)
  2645 #    define png_get_uint_16(buf) PNG_get_uint_16(buf)
  2647 #     define png_get_int_32(buf)  PNG_get_int_32(buf)
  2646 #    define png_get_int_32(buf)  PNG_get_int_32(buf)
  2648 #  endif
  2647 #  endif
  2649 #else
  2648 #else
  2650 #  ifdef PNG_PREFIX
  2649 #  ifdef PNG_PREFIX
  2651       /* No macros; revert to the (redefined) function */
  2650    /* No macros; revert to the (redefined) function */
  2652 #     define PNG_get_uint_32 (png_get_uint_32)
  2651 #    define PNG_get_uint_32 (png_get_uint_32)
  2653 #     define PNG_get_uint_16 (png_get_uint_16)
  2652 #    define PNG_get_uint_16 (png_get_uint_16)
  2654 #     define PNG_get_int_32  (png_get_int_32)
  2653 #    define PNG_get_int_32  (png_get_int_32)
  2655 #  endif
  2654 #  endif
  2656 #endif
  2655 #endif
  2657 
  2656 
  2658 #ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
  2657 #ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
  2659 PNG_EXPORT(242, void, png_set_check_for_invalid_index,
  2658 PNG_EXPORT(242, void, png_set_check_for_invalid_index,
  3197    /* An upper bound on the size of the data in the PNG IDAT chunks. */
  3196    /* An upper bound on the size of the data in the PNG IDAT chunks. */
  3198 
  3197 
  3199 #define PNG_IMAGE_PNG_SIZE_MAX_(image, image_size)\
  3198 #define PNG_IMAGE_PNG_SIZE_MAX_(image, image_size)\
  3200    ((8U/*sig*/+25U/*IHDR*/+16U/*gAMA*/+44U/*cHRM*/+12U/*IEND*/+\
  3199    ((8U/*sig*/+25U/*IHDR*/+16U/*gAMA*/+44U/*cHRM*/+12U/*IEND*/+\
  3201     (((image).format&PNG_FORMAT_FLAG_COLORMAP)?/*colormap: PLTE, tRNS*/\
  3200     (((image).format&PNG_FORMAT_FLAG_COLORMAP)?/*colormap: PLTE, tRNS*/\
  3202      12U+3U*(image).colormap_entries/*PLTE data*/+\
  3201     12U+3U*(image).colormap_entries/*PLTE data*/+\
  3203      (((image).format&PNG_FORMAT_FLAG_ALPHA)?\
  3202     (((image).format&PNG_FORMAT_FLAG_ALPHA)?\
  3204       12U/*tRNS*/+(image).colormap_entries:0U):0U)+\
  3203     12U/*tRNS*/+(image).colormap_entries:0U):0U)+\
  3205     12U)+(12U*((image_size)/PNG_ZBUF_SIZE))/*IDAT*/+(image_size))
  3204     12U)+(12U*((image_size)/PNG_ZBUF_SIZE))/*IDAT*/+(image_size))
  3206    /* A helper for the following macro; if your compiler cannot handle the
  3205    /* A helper for the following macro; if your compiler cannot handle the
  3207     * following macro use this one with the result of
  3206     * following macro use this one with the result of
  3208     * PNG_IMAGE_COMPRESSED_SIZE_MAX(image) as the second argument (most
  3207     * PNG_IMAGE_COMPRESSED_SIZE_MAX(image) as the second argument (most
  3209     * compilers should handle this just fine.)
  3208     * compilers should handle this just fine.)
  3247 #ifdef PNG_ARM_NEON_API_SUPPORTED
  3246 #ifdef PNG_ARM_NEON_API_SUPPORTED
  3248 #  define PNG_ARM_NEON   0 /* HARDWARE: ARM Neon SIMD instructions supported */
  3247 #  define PNG_ARM_NEON   0 /* HARDWARE: ARM Neon SIMD instructions supported */
  3249 #endif
  3248 #endif
  3250 #define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */
  3249 #define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */
  3251 #define PNG_SKIP_sRGB_CHECK_PROFILE 4 /* SOFTWARE: Check ICC profile for sRGB */
  3250 #define PNG_SKIP_sRGB_CHECK_PROFILE 4 /* SOFTWARE: Check ICC profile for sRGB */
  3252 #define PNG_OPTION_NEXT  6 /* Next option - numbers must be even */
  3251 #ifdef PNG_MIPS_MSA_API_SUPPORTED
       
  3252 #  define PNG_MIPS_MSA   6 /* HARDWARE: MIPS Msa SIMD instructions supported */
       
  3253 #endif
       
  3254 #define PNG_IGNORE_ADLER32 8
       
  3255 #define PNG_OPTION_NEXT  10 /* Next option - numbers must be even */
  3253 
  3256 
  3254 /* Return values: NOTE: there are four values and 'off' is *not* zero */
  3257 /* Return values: NOTE: there are four values and 'off' is *not* zero */
  3255 #define PNG_OPTION_UNSET   0 /* Unset - defaults to off */
  3258 #define PNG_OPTION_UNSET   0 /* Unset - defaults to off */
  3256 #define PNG_OPTION_INVALID 1 /* Option number out of range */
  3259 #define PNG_OPTION_INVALID 1 /* Option number out of range */
  3257 #define PNG_OPTION_OFF     2
  3260 #define PNG_OPTION_OFF     2