Skip to content

Commit

Permalink
png: Import upstream release 1.6.42.
Browse files Browse the repository at this point in the history
  • Loading branch information
julliard committed Feb 17, 2024
1 parent 3881edf commit 1e5cc50
Show file tree
Hide file tree
Showing 16 changed files with 371 additions and 296 deletions.
30 changes: 19 additions & 11 deletions libs/png/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ PNG REFERENCE LIBRARY AUTHORS
This is the list of PNG Reference Library ("libpng") Contributing
Authors, for copyright and licensing purposes.

* Adam Richter
* Andreas Dilger
* Cosmin Truta
* Dave Martindale
Expand Down Expand Up @@ -33,20 +34,27 @@ Authors, for copyright and licensing purposes.
* Vadim Barkov
* Willem van Schaik
* Zhijie Liang
* Apple Inc.
- Zixu Wang (王子旭)
* Arm Holdings
- Richard Townsend
- Richard Townsend
* Google Inc.
- Dan Field
- Leon Scroggins III
- Matt Sarett
- Mike Klein
- Sami Boukortt
- Wan-Teh Chang
- Dan Field
- Leon Scroggins III
- Matt Sarett
- Mike Klein
- Sami Boukortt
- Wan-Teh Chang
* Loongson Technology Corporation Ltd.
- GuXiWei (顾希伟)
- JinBo (金波)
- ZhangLixia (张利霞)

The build projects, the build scripts, the test scripts, and other
files in the "ci", "projects", "scripts" and "tests" directories, have
files in the "projects", "scripts" and "tests" directories, have
other copyright owners, but are released under the libpng license.

Some files in the "contrib" directory, and some tools-generated files
that are distributed with libpng, have other copyright owners, and are
released under other open source licenses.
Some files in the "ci" and "contrib" directories, as well as some
of the tools-generated files that are distributed with libpng, have
other copyright owners, and are released under other open source
licenses.
4 changes: 2 additions & 2 deletions libs/png/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
PNG Reference Library License version 2
---------------------------------------

* Copyright (c) 1995-2023 The PNG Reference Library Authors.
* Copyright (c) 2018-2023 Cosmin Truta.
* Copyright (c) 1995-2024 The PNG Reference Library Authors.
* Copyright (c) 2018-2024 Cosmin Truta.
* Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
* Copyright (c) 1996-1997 Andreas Dilger.
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
Expand Down
73 changes: 14 additions & 59 deletions libs/png/png.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

/* png.c - location for general purpose libpng functions
*
* Copyright (c) 2018-2023 Cosmin Truta
* Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
Expand All @@ -14,27 +14,7 @@
#include "pngpriv.h"

/* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_6_40 Your_png_h_is_not_version_1_6_40;

#ifdef __GNUC__
/* The version tests may need to be added to, but the problem warning has
* consistently been fixed in GCC versions which obtain wide-spread release.
* The problem is that many versions of GCC rearrange comparison expressions in
* the optimizer in such a way that the results of the comparison will change
* if signed integer overflow occurs. Such comparisons are not permitted in
* ANSI C90, however GCC isn't clever enough to work out that that do not occur
* below in png_ascii_from_fp and png_muldiv, so it produces a warning with
* -Wextra. Unfortunately this is highly dependent on the optimizer and the
* machine architecture so the warning comes and goes unpredictably and is
* impossible to "fix", even were that a good idea.
*/
#if __GNUC__ == 7 && __GNUC_MINOR__ == 1
#define GCC_STRICT_OVERFLOW 1
#endif /* GNU 7.1.x */
#endif /* GNU */
#ifndef GCC_STRICT_OVERFLOW
#define GCC_STRICT_OVERFLOW 0
#endif
typedef png_libpng_version_1_6_42 Your_png_h_is_not_version_1_6_42;

/* Tells libpng that we have already handled the first "num_bytes" bytes
* of the PNG file signature. If the PNG data is embedded into another
Expand Down Expand Up @@ -73,21 +53,21 @@ png_set_sig_bytes(png_structrp png_ptr, int num_bytes)
int PNGAPI
png_sig_cmp(png_const_bytep sig, size_t start, size_t num_to_check)
{
png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
static const png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};

if (num_to_check > 8)
num_to_check = 8;

else if (num_to_check < 1)
return (-1);
return -1;

if (start > 7)
return (-1);
return -1;

if (start + num_to_check > 8)
num_to_check = 8 - start;

return ((int)(memcmp(&sig[start], &png_signature[start], num_to_check)));
return memcmp(&sig[start], &png_signature[start], num_to_check);
}

#endif /* READ */
Expand Down Expand Up @@ -447,7 +427,6 @@ png_info_init_3,(png_infopp ptr_ptr, size_t png_info_struct_size),
memset(info_ptr, 0, (sizeof *info_ptr));
}

/* The following API is not called internally */
void PNGAPI
png_data_freer(png_const_structrp png_ptr, png_inforp info_ptr,
int freer, png_uint_32 mask)
Expand Down Expand Up @@ -686,9 +665,9 @@ png_voidp PNGAPI
png_get_io_ptr(png_const_structrp png_ptr)
{
if (png_ptr == NULL)
return (NULL);
return NULL;

return (png_ptr->io_ptr);
return png_ptr->io_ptr;
}

#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
Expand Down Expand Up @@ -752,7 +731,7 @@ png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime)

{
size_t pos = 0;
char number_buf[5]; /* enough for a four-digit year */
char number_buf[5] = {0, 0, 0, 0, 0}; /* enough for a four-digit year */

# define APPEND_STRING(string) pos = png_safecat(out, 29, pos, (string))
# define APPEND_NUMBER(format, value)\
Expand Down Expand Up @@ -815,8 +794,8 @@ png_get_copyright(png_const_structrp png_ptr)
return PNG_STRING_COPYRIGHT
#else
return PNG_STRING_NEWLINE \
"libpng version 1.6.40" PNG_STRING_NEWLINE \
"Copyright (c) 2018-2023 Cosmin Truta" PNG_STRING_NEWLINE \
"libpng version 1.6.42" PNG_STRING_NEWLINE \
"Copyright (c) 2018-2024 Cosmin Truta" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \
PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
Expand Down Expand Up @@ -977,7 +956,7 @@ png_reset_zstream(png_structrp png_ptr)
return Z_STREAM_ERROR;

/* WARNING: this resets the window bits to the maximum! */
return (inflateReset(&png_ptr->zstream));
return inflateReset(&png_ptr->zstream);
}
#endif /* READ */

Expand All @@ -986,7 +965,7 @@ png_uint_32 PNGAPI
png_access_version_number(void)
{
/* Version of *.c files used when building libpng */
return((png_uint_32)PNG_LIBPNG_VER);
return (png_uint_32)PNG_LIBPNG_VER;
}

#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
Expand Down Expand Up @@ -2891,14 +2870,6 @@ png_pow10(int power)
/* Function to format a floating point value in ASCII with a given
* precision.
*/
#if GCC_STRICT_OVERFLOW
#pragma GCC diagnostic push
/* The problem arises below with exp_b10, which can never overflow because it
* comes, originally, from frexp and is therefore limited to a range which is
* typically +/-710 (log2(DBL_MAX)/log2(DBL_MIN)).
*/
#pragma GCC diagnostic warning "-Wstrict-overflow=2"
#endif /* GCC_STRICT_OVERFLOW */
void /* PRIVATE */
png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, size_t size,
double fp, unsigned int precision)
Expand Down Expand Up @@ -3220,10 +3191,6 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, size_t size,
/* Here on buffer too small. */
png_error(png_ptr, "ASCII conversion buffer too small");
}
#if GCC_STRICT_OVERFLOW
#pragma GCC diagnostic pop
#endif /* GCC_STRICT_OVERFLOW */

# endif /* FLOATING_POINT */

# ifdef PNG_FIXED_POINT_SUPPORTED
Expand Down Expand Up @@ -3251,7 +3218,7 @@ png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii,
if (num <= 0x80000000) /* else overflowed */
{
unsigned int ndigits = 0, first = 16 /* flag value */;
char digits[10];
char digits[10] = {0};

while (num)
{
Expand Down Expand Up @@ -3336,15 +3303,6 @@ png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text)
* the nearest .00001). Overflow and divide by zero are signalled in
* the result, a boolean - true on success, false on overflow.
*/
#if GCC_STRICT_OVERFLOW /* from above */
/* It is not obvious which comparison below gets optimized in such a way that
* signed overflow would change the result; looking through the code does not
* reveal any tests which have the form GCC complains about, so presumably the
* optimizer is moving an add or subtract into the 'if' somewhere.
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic warning "-Wstrict-overflow=2"
#endif /* GCC_STRICT_OVERFLOW */
int
png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,
png_int_32 divisor)
Expand Down Expand Up @@ -3459,9 +3417,6 @@ png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,

return 0;
}
#if GCC_STRICT_OVERFLOW
#pragma GCC diagnostic pop
#endif /* GCC_STRICT_OVERFLOW */
#endif /* READ_GAMMA || INCH_CONVERSIONS */

#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)
Expand Down
50 changes: 27 additions & 23 deletions libs/png/png.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

/* png.h - header file for PNG reference library
*
* libpng version 1.6.40
* libpng version 1.6.42
*
* Copyright (c) 2018-2023 Cosmin Truta
* Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
Expand All @@ -15,7 +15,7 @@
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.6.35, July 2018:
* Glenn Randers-Pehrson
* libpng versions 1.6.36, December 2018, through 1.6.40, June 2023:
* libpng versions 1.6.36, December 2018, through 1.6.42, January 2024:
* Cosmin Truta
* See also "Contributing Authors", below.
*/
Expand All @@ -27,8 +27,8 @@
* PNG Reference Library License version 2
* ---------------------------------------
*
* * Copyright (c) 1995-2023 The PNG Reference Library Authors.
* * Copyright (c) 2018-2023 Cosmin Truta.
* * Copyright (c) 1995-2024 The PNG Reference Library Authors.
* * Copyright (c) 2018-2024 Cosmin Truta.
* * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
* * Copyright (c) 1996-1997 Andreas Dilger.
* * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
Expand Down Expand Up @@ -239,7 +239,7 @@
* ...
* 1.5.30 15 10530 15.so.15.30[.0]
* ...
* 1.6.40 16 10640 16.so.16.40[.0]
* 1.6.42 16 10641 16.so.16.41[.0]
*
* Henceforth the source version will match the shared-library major and
* minor numbers; the shared-library major version number will be used for
Expand Down Expand Up @@ -278,16 +278,16 @@
*/

/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.6.40"
#define PNG_HEADER_VERSION_STRING " libpng version 1.6.40 - June 21, 2023\n"
#define PNG_LIBPNG_VER_STRING "1.6.42"
#define PNG_HEADER_VERSION_STRING " libpng version " PNG_LIBPNG_VER_STRING "\n"

#define PNG_LIBPNG_VER_SONUM 16
#define PNG_LIBPNG_VER_DLLNUM 16

/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 6
#define PNG_LIBPNG_VER_RELEASE 40
#define PNG_LIBPNG_VER_RELEASE 41

/* This should be zero for a public release, or non-zero for a
* development version. [Deprecated]
Expand Down Expand Up @@ -318,7 +318,7 @@
* From version 1.0.1 it is:
* XXYYZZ, where XX=major, YY=minor, ZZ=release
*/
#define PNG_LIBPNG_VER 10640 /* 1.6.40 */
#define PNG_LIBPNG_VER 10641 /* 1.6.42 */

/* Library configuration: these options cannot be changed after
* the library has been built.
Expand Down Expand Up @@ -428,7 +428,7 @@ extern "C" {
/* This triggers a compiler error in png.c, if png.c and png.h
* do not agree upon the version number.
*/
typedef char* png_libpng_version_1_6_40;
typedef char* png_libpng_version_1_6_42;

/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
*
Expand Down Expand Up @@ -849,7 +849,7 @@ PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef);
#define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */
/* Added to libpng-1.5.4 */
#define PNG_TRANSFORM_EXPAND_16 0x4000 /* read only */
#if INT_MAX >= 0x8000 /* else this might break */
#if ~0U > 0xffffU /* or else this might break on a 16-bit machine */
#define PNG_TRANSFORM_SCALE_16 0x8000 /* read only */
#endif

Expand Down Expand Up @@ -908,15 +908,15 @@ PNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes));
/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a
* PNG file. Returns zero if the supplied bytes match the 8-byte PNG
* signature, and non-zero otherwise. Having num_to_check == 0 or
* start > 7 will always fail (ie return non-zero).
* start > 7 will always fail (i.e. return non-zero).
*/
PNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, size_t start,
size_t num_to_check));

/* Simple signature checking function. This is the same as calling
* png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).
* png_check_sig(sig, n) := (png_sig_cmp(sig, 0, n) == 0).
*/
#define png_check_sig(sig, n) !png_sig_cmp((sig), 0, (n))
#define png_check_sig(sig, n) (png_sig_cmp((sig), 0, (n)) == 0) /* DEPRECATED */

/* Allocate and initialize png_ptr struct for reading, and any other memory. */
PNG_EXPORTA(4, png_structp, png_create_read_struct,
Expand Down Expand Up @@ -1730,12 +1730,9 @@ PNG_EXPORT(97, void, png_free, (png_const_structrp png_ptr, png_voidp ptr));
PNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr,
png_inforp info_ptr, png_uint_32 free_me, int num));

/* Reassign responsibility for freeing existing data, whether allocated
/* Reassign the responsibility for freeing existing data, whether allocated
* by libpng or by the application; this works on the png_info structure passed
* in, it does not change the state for other png_info structures.
*
* It is unlikely that this function works correctly as of 1.6.0 and using it
* may result either in memory leaks or double free of allocated data.
* in, without changing the state for other png_info structures.
*/
PNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr,
png_inforp info_ptr, int freer, png_uint_32 mask));
Expand Down Expand Up @@ -3207,11 +3204,18 @@ PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory,
#ifdef PNG_MIPS_MSA_API_SUPPORTED
# define PNG_MIPS_MSA 6 /* HARDWARE: MIPS Msa SIMD instructions supported */
#endif
#define PNG_IGNORE_ADLER32 8
#ifdef PNG_DISABLE_ADLER32_CHECK_SUPPORTED
# define PNG_IGNORE_ADLER32 8 /* SOFTWARE: disable Adler32 check on IDAT */
#endif
#ifdef PNG_POWERPC_VSX_API_SUPPORTED
# define PNG_POWERPC_VSX 10 /* HARDWARE: PowerPC VSX SIMD instructions supported */
# define PNG_POWERPC_VSX 10 /* HARDWARE: PowerPC VSX SIMD instructions
* supported */
#endif
#define PNG_OPTION_NEXT 12 /* Next option - numbers must be even */
#ifdef PNG_MIPS_MMI_API_SUPPORTED
# define PNG_MIPS_MMI 12 /* HARDWARE: MIPS MMI SIMD instructions supported */
#endif

#define PNG_OPTION_NEXT 14 /* Next option - numbers must be even */

/* Return values: NOTE: there are four values and 'off' is *not* zero */
#define PNG_OPTION_UNSET 0 /* Unset - defaults to off */
Expand Down
4 changes: 2 additions & 2 deletions libs/png/pngconf.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

/* pngconf.h - machine-configurable file for libpng
*
* libpng version 1.6.40
* libpng version 1.6.42
*
* Copyright (c) 2018-2022 Cosmin Truta
* Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
Expand Down
Loading

0 comments on commit 1e5cc50

Please sign in to comment.