diff options
author | George Hazan <george.hazan@gmail.com> | 2014-12-18 11:45:07 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-12-18 11:45:07 +0000 |
commit | c554ec47dca508a085c4206aea5cc5cadc1311fb (patch) | |
tree | 6f00b5382e5d13fb72e4174017c8a344b4436902 | |
parent | 040c8cd3bba9c42d5db076c6e612638a9c32a932 (diff) |
libpng updated to 1.6.15
git-svn-id: http://svn.miranda-ng.org/main/trunk@11507 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
33 files changed, 2386 insertions, 2098 deletions
diff --git a/plugins/AdvaImg/src/LibPNG/ANNOUNCE b/plugins/AdvaImg/src/LibPNG/ANNOUNCE index bfd62d13c3..29b40b432d 100644 --- a/plugins/AdvaImg/src/LibPNG/ANNOUNCE +++ b/plugins/AdvaImg/src/LibPNG/ANNOUNCE @@ -1,5 +1,4 @@ -
-Libpng 1.6.10 - March 6, 2014
+Libpng 1.6.15 - November 20, 2014
This is a public release of libpng, intended for use in production codes.
@@ -8,80 +7,55 @@ Files available for download: Source files with LF line endings (for Unix/Linux) and with a
"configure" script
- libpng-1.6.10.tar.xz (LZMA-compressed, recommended)
- libpng-1.6.10.tar.gz
+ libpng-1.6.15.tar.xz (LZMA-compressed, recommended)
+ libpng-1.6.15.tar.gz
Source files with CRLF line endings (for Windows), without the
"configure" script
- lpng1610.7z (LZMA-compressed, recommended)
- lpng1610.zip
+ lpng1615.7z (LZMA-compressed, recommended)
+ lpng1615.zip
Other information:
- libpng-1.6.10-README.txt
- libpng-1.6.10-LICENSE.txt
- libpng-1.6.10-*.asc (armored detached GPG signatures)
+ libpng-1.6.15-README.txt
+ libpng-1.6.15-LICENSE.txt
+ libpng-1.6.15-*.asc (armored detached GPG signatures)
-Changes since the last public release (1.6.9):
- Backported changes from libpng-1.7.0beta30 and beta31:
- Fixed a large number of instances where PNGCBAPI was omitted from
- function definitions.
- Added pngimage test program for png_read_png() and png_write_png()
- with two new test scripts.
- Removed dependence on !PNG_READ_EXPAND_SUPPORTED for calling
- png_set_packing() in png_read_png().
- Fixed combination of ~alpha with shift. On read invert alpha, processing
- occurred after shift processing, which causes the final values to be
- outside the range that should be produced by the shift. Reversing the
- order on read makes the two transforms work together correctly and mirrors
- the order used on write.
- Do not read invalid sBIT chunks. Previously libpng only checked sBIT
- values on write, so a malicious PNG writer could therefore cause
- the read code to return an invalid sBIT chunk, which might lead to
- application errors or crashes. Such chunks are now skipped (with
- chunk_benign_error).
- Make png_read_png() and png_write_png() prototypes in png.h depend
- upon PNG_READ_SUPPORTED and PNG_WRITE_SUPPORTED.
- Support builds with unsupported PNG_TRANSFORM_* values. All of the
- PNG_TRANSFORM_* values are always defined in png.h and, because they
- are used for both read and write in some cases, it is not reliable
- to #if out ones that are totally unsupported. This change adds error
- detection in png_read_image() and png_write_image() to do a
- png_app_error() if the app requests something that cannot be done
- and it adds corresponding code to pngimage.c to handle such options
- by not attempting to test them.
- Moved redefines of png_error(), png_warning(), png_chunk_error(),
- and png_chunk_warning() from pngpriv.h to png.h to make them visible
- to libpng-calling applications.
- Moved OS dependent code from arm/arm_init.c, to allow the included
- implementation of the ARM NEON discovery function to be set at
- build-time and provide sample implementations from the current code in the
- contrib/arm-neon subdirectory. The __linux__ code has also been changed to
- compile and link on Android by using /proc/cpuinfo, and the old linux code
- is in contrib/arm-neon/linux-auxv.c. The new code avoids POSIX and Linux
- dependencies apart from opening /proc/cpuinfo and is C90 compliant.
- Check for info_ptr == NULL early in png_read_end() so we don't need to
- run all the png_handle_*() and depend on them to return if info_ptr == NULL.
- This improves the performance of png_read_end(png_ptr, NULL) and makes
- it more robust against future programming errors.
- Check for __has_extension before using it in pngconf.h, to
- support older Clang versions (Jeremy Sequoia).
- Treat CRC error handling with png_set_crc_action(), instead of with
- png_set_benign_errors(), which has been the case since libpng-1.6.0beta18.
- Use a user warning handler in contrib/gregbook/readpng2.c instead of default,
- so warnings will be put on stderr even if libpng has CONSOLE_IO disabled.
- Added png_ptr->process_mode = PNG_READ_IDAT_MODE in png_push_read_chunk
- after recognizing the IDAT chunk, which avoids an infinite loop while
- reading a datastream whose first IDAT chunk is of zero-length.
- This fixes CERT VU#684412 and CVE-2014-0333.
- Don't recognize known sRGB profiles as sRGB if they have been hacked,
- but don't reject them and don't issue a copyright violation warning.
- Moved some documentation from png.h to libpng.3 and libpng-manual.txt
- Minor editing of contrib/arm-neon/README and contrib/examples/*.c
- Fixed typos in the manual and in scripts/pnglibconf.dfa (CFLAGS -> CPPFLAGS
- and PNG_USR_CONFIG -> PNG_USER_CONFIG).
- Un-deprecated png_data_freer().
+Changes since the last public release (1.6.14):
+ Changed "if (!x)" to "if (x == 0)" and "if (x)" to "if (x != 0)"
+ Simplified png_free_data().
+ Added missing "ptr = NULL" after some instances of png_free().
+ Made a one-line revision to configure.ac to support ARM on aarch64
+ (bug report by Marcin Juszkiewicz, fix by John Bowler).
+ Avoid out-of-bounds memory access in png_user_version_check().
+ Simplified and future-proofed png_user_version_check().
+ Fixed GCC unsigned int->float warnings. Various versions of GCC
+ seem to generate warnings when an unsigned value is implicitly
+ converted to double. This is probably a GCC bug but this change
+ avoids the issue by explicitly converting to (int) where safe.
+ Free all allocated memory in pngimage. The file buffer cache was left
+ allocated at the end of the program, harmless but it causes memory
+ leak reports from clang.
+ Fixed array size calculations to avoid warnings. At various points
+ in the code the number of elements in an array is calculated using
+ sizeof. This generates a compile time constant of type (size_t) which
+ is then typically assigned to an (unsigned int) or (int). Some versions
+ of GCC on 64-bit systems warn about the apparent narrowing, even though
+ the same compiler does apparently generate the correct, in-range,
+ numeric constant. This adds appropriate, safe, casts to make the
+ warnings go away.
+ Removed #ifdef PNG_16BIT_SUPPORTED/#endif around png_product2(); it is
+ needed by png_reciprocal2().
+ Added #ifdef PNG_16BIT_SUPPORTED/#endif around png_log16bit() and
+ png_do_swap().
+ Changed all "#endif /* PNG_FEATURE_SUPPORTED */" to "#endif /* FEATURE */"
+ The macros passed in the command line to Borland make were ignored if
+ similarly-named macros were already defined in makefiles. This behavior
+ is different from POSIX make and other make programs. Surround the
+ macro definitions with ifndef guards (Cosmin).
+ Added "-D_CRT_SECURE_NO_WARNINGS" to CFLAGS in scripts/makefile.vcwin32.
+ Removed the obsolete $ARCH variable from scripts/makefile.darwin.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
@@ -90,4 +64,3 @@ to subscribe) or to glennrp at users.sourceforge.net
Glenn R-P
-#endif
diff --git a/plugins/AdvaImg/src/LibPNG/CHANGES b/plugins/AdvaImg/src/LibPNG/CHANGES index 8d9a4f3556..689ef9f55b 100644 --- a/plugins/AdvaImg/src/LibPNG/CHANGES +++ b/plugins/AdvaImg/src/LibPNG/CHANGES @@ -1,4 +1,4 @@ -#if 0
+
CHANGES - changes for libpng
Version 0.2
@@ -4345,8 +4345,9 @@ Version 1.6.0beta37 [January 10, 2013] programs to generate and test a PNG which should have the problem.
Version 1.6.0beta39 [January 19, 2013]
- Again corrected attempt at overflow detection in png_set_unknown_chunks().
- Added overflow detection in png_set_sPLT() and png_set_text_2().
+ Again corrected attempt at overflow detection in png_set_unknown_chunks()
+ (CVE-2013-7353). Added overflow detection in png_set_sPLT() and
+ png_set_text_2() (CVE-2013-7354).
Version 1.6.0beta40 [January 20, 2013]
Use consistent handling of overflows in text, sPLT and unknown png_set_* APIs
@@ -4429,7 +4430,7 @@ Version 1.6.1beta05 [March 1, 2013] Version 1.6.1beta06 [March 4, 2013]
Better documentation of unknown handling API interactions.
Corrected Android builds and corrected libpng.vers with symbol
- prefixing This adds an API to set optimization options externally,
+ prefixing. This adds an API to set optimization options externally,
providing an alternative and general solution for the non-portable
run-time tests used by the ARM Neon code. It also makes those tests
compile and link on Android.
@@ -4873,6 +4874,229 @@ Version 1.6.10rc03 [March 4, 2014] Un-deprecated png_data_freer().
Version 1.6.10 [March 6, 2014]
+ No changes.
+
+Version 1.6.11beta01 [March 17, 2014]
+ Use "if (value != 0)" instead of "if (value)" consistently.
+ Changed ZlibSrcDir from 1.2.5 to 1.2.8 in projects/vstudio.
+ Moved configuration information from the manual to the INSTALL file.
+
+Version 1.6.11beta02 [April 6, 2014]
+ Removed #if/#else/#endif from inside two pow() calls in pngvalid.c because
+ they were handled improperly by Portland Group's PGI-14.1 - PGI-14.3
+ when using its "__builtin_pow()" function.
+ Silence 'unused parameter' build warnings (Cosmin Truta).
+ $(CP) is now used alongside $(RM_F). Also, use 'copy' instead of 'cp'
+ where applicable, and applied other minor makefile changes (Cosmin).
+ Don't warn about invalid dimensions exceeding user limits (Cosmin).
+ Allow an easy replacement of the default pre-built configuration
+ header with a custom header, via the make PNGLIBCONF_H_PREBUILT
+ macro (Cosmin).
+
+Version 1.6.11beta03 [April 6, 2014]
+ Fixed a typo in pngrutil.c, introduced in libpng-1.5.6, that interferes
+ with "blocky" expansion of sub-8-bit interlaced PNG files (Eric Huss).
+ Optionally use __builtin_bswap16() in png_do_swap().
+
+Version 1.6.11beta04 [April 19, 2014]
+ Made progressive reading of interlaced images consistent with the
+ behavior of the sequential reader and consistent with the manual, by
+ moving some code out of the PNG_READ_INTERLACING_SUPPORTED blocks. The
+ row_callback now receives the proper pass number and unexpanded rows, when
+ png_combine_row() isn't built or used, and png_set_interlace_handling()
+ is not called.
+ Allow PNG_sRGB_PROFILE_CHECKING = (-1) to mean no sRGB profile checking.
+
+Version 1.6.11beta05 [April 26, 2014]
+ Do not reject ICC V2 profiles that lack padding (Kai-Uwe Behrmann).
+ Relocated closing bracket of the sRGB profile test loop to avoid getting
+ "Not recognizing known sRGB profile that has been edited" warning for
+ ICC V2 profiles that lack the MD5 signature in the profile header.
+
+Version 1.6.11beta06 [May 19, 2014]
+ Added PNG_SKIP_sRGB_CHECK_PROFILE choice for png_set_option().
+
+Version 1.6.11rc01 [May 27, 2014]
+ No changes.
+
+Version 1.6.11rc02 [June 3, 2014]
+ Test ZLIB_VERNUM instead of PNG_ZLIB_VERNUM in contrib/tools/pngfix.c
+
+Version 1.6.11 [June 5, 2014]
+ No changes.
+
+Version 1.6.12rc01 [June 6, 2014]
+ Relocated new code from 1.6.11beta06 in png.c to a point after the
+ declarations (Max Stepin).
+
+Version 1.6.12rc02 [June 7, 2014]
+ Changed file permissions of contrib/tools/intgamma.sh,
+ test-driver, and compile from 0644 to 0755 (Cosmin).
+
+Version 1.6.12rc03 [June 8, 2014]
+ Ensure "__has_attribute()" macro exists before trying to use it with
+ old clang compilers (MacPorts Ticket #43939).
+
+Version 1.6.12 [June 12, 2014]
+ No changes.
+
+Version 1.6.13beta01 [July 4, 2014]
+ Quieted -Wsign-compare and -Wclobber compiler warnings in
+ contrib/pngminus/*.c
+ Added "(void) png_ptr;" where needed in contrib/gregbook to quiet
+ compiler complaints about unused pointers.
+ Split a long output string in contrib/gregbook/rpng2-x.c.
+ Added "PNG_SET_OPTION" requirement for sRGB chunk support to pnglibconf.dfa,
+ Needed for write-only support (John Bowler).
+ Changed "if defined(__ARM_NEON__)" to
+ "if (defined(__ARM_NEON__) || defined(__ARM_NEON))" (James Wu).
+ Fixed clang no-warning builds: png_digit was defined but never used.
+
+Version 1.6.13beta02 [July 21, 2014]
+ Fixed an incorrect separator ("/" should be "\") in scripts/makefile.vcwin32
+ (bug report from Wolfgang S. Kechel). Bug was introduced in libpng-1.6.11.
+ Also fixed makefile.bc32, makefile.bor, makefile.msc, makefile.intel, and
+ makefile.tc3 similarly.
+
+Version 1.6.13beta03 [August 3, 2014]
+ Removed scripts/makefile.elf. It has not worked since libpng-1.5.0beta14
+ due to elimination of the PNG_FUNCTION_EXPORT and PNG_DATA_EXPORT
+ definitions from pngconf.h.
+ Ensure that CMakeLists.txt makes the target "lib" directory before making
+ symbolic link into it (SourceForge bug report #226 by Rolf Timmermans).
+
+Version 1.6.13beta04 [August 8, 2014]
+ Added opinion that the ECCN (Export Control Classification Number) for
+ libpng is EAR99 to the README file.
+ Eliminated use of "$<" in makefile explicit rules, when copying
+ $PNGLIBCONF_H_PREBUILT. This does not work on some versions of make;
+ bug introduced in libpng version 1.6.11.
+
+Version 1.6.13rc01 [August 14, 2014]
+ Made "ccopts" agree with "CFLAGS" in scripts/makefile.hp* and makefile.*sunu
+
+Version 1.6.13 [August 21, 2014]
+ No changes.
+
+Version 1.6.14beta01 [September 14, 2014]
+ Guard usage of png_ptr->options with #ifdef PNG_SET_OPTION_SUPPORTED.
+ Do not build contrib/tools/pngfix.c when PNG_SETJMP_NOT_SUPPORTED,
+ to allow "make" to complete without setjmp support (bug report by
+ Claudio Fontana)
+ Add "#include <setjmp.h>" to contrib/tools/pngfix.c (John Bowler)
+
+Version 1.6.14beta02 [September 18, 2014]
+ Use nanosleep() instead of usleep() in contrib/gregbook/rpng2-x.c
+ because usleep() is deprecated.
+ Define usleep() in contrib/gregbook/rpng2-x.c if not already defined
+ in unistd.h and nanosleep() is not available; fixes error introduced
+ in libpng-1.6.13.
+ Disable floating point exception handling in pngvalid.c when
+ PNG_FLOATING_ARITHMETIC is not supported (bug report by "zootus
+ at users.sourceforge.net").
+
+Version 1.6.14beta03 [September 19, 2014]
+ Define FE_DIVBYZERO, FE_INVALID, and FE_OVERFLOW in pngvalid.c if not
+ already defined. Revert floating point exception handling in pngvalid.c
+ to version 1.6.14beta01 behavior.
+
+Version 1.6.14beta04 [September 27, 2014]
+ Fixed incorrect handling of the iTXt compression flag in pngrutil.c
+ (bug report by Shunsaku Hirata). Bug was introduced in libpng-1.6.0.
+
+Version 1.6.14beta05 [October 1, 2014]
+ Added "option READ_iCCP enables READ_COMPRESSED_TEXT" to pnglibconf.dfa
+
+Version 1.6.14beta06 [October 5, 2014]
+ Removed unused "text_len" parameter from private function png_write_zTXt().
+ Conditionally compile some code in png_deflate_claim(), when
+ PNG_WARNINGS_SUPPORTED and PNG_ERROR_TEXT_SUPPORTED are disabled.
+ Replaced repeated code in pngpread.c with PNG_PUSH_SAVE_BUFFER_IF_FULL.
+ Added "chunk iTXt enables TEXT" and "chunk zTXt enables TEXT"
+ to pnglibconf.dfa.
+ Removed "option READ_COMPRESSED_TEXT enables READ_TEXT" from pnglibconf.dfa,
+ to make it possible to configure a libpng that supports iCCP but not TEXT.
+
+Version 1.6.14beta07 [October 7, 2014]
+ Removed "option WRITE_COMPRESSED_TEXT enables WRITE_TEXT" from pnglibconf.dfa
+ Only mark text chunks as written after successfully writing them.
+
+Version 1.6.14rc01 [October 15, 2014]
+ Fixed some typos in comments.
+
+Version 1.6.14rc02 [October 17, 2014]
+ Changed png_convert_to_rfc_1123() to png_convert_to_rfc_1123_buffer()
+ in the manual, to reflect the change made in libpng-1.6.0.
+ Updated README file to explain that direct access to the png_struct
+ and info_struct members has not been permitted since libpng-1.5.0.
+
+Version 1.6.14 [October 23, 2014]
+ No changes.
+
+Version 1.6.15beta01 [October 29, 2014]
+ Changed "if (!x)" to "if (x == 0)" and "if (x)" to "if (x != 0)"
+ Simplified png_free_data().
+ Added missing "ptr = NULL" after some instances of png_free().
+
+Version 1.6.15beta02 [November 1, 2014]
+ Changed remaining "if (!x)" to "if (x == 0)" and "if (x)" to "if (x != 0)"
+
+Version 1.6.15beta03 [November 3, 2014]
+ Added PNG_USE_ARM_NEON configuration flag (Marcin Juszkiewicz).
+
+Version 1.6.15beta04 [November 4, 2014]
+ Removed new PNG_USE_ARM_NEON configuration flag and made a one-line
+ revision to configure.ac to support ARM on aarch64 instead (John Bowler).
+
+Version 1.6.15beta05 [November 5, 2014]
+ Use png_get_libpng_ver(NULL) instead of PNG_LIBPNG_VER_STRING in
+ example.c, pngtest.c, and applications in the contrib directory.
+ Avoid out-of-bounds memory access in png_user_version_check().
+ Simplified and future-proofed png_user_version_check().
+ Fixed GCC unsigned int->float warnings. Various versions of GCC
+ seem to generate warnings when an unsigned value is implicitly
+ converted to double. This is probably a GCC bug but this change
+ avoids the issue by explicitly converting to (int) where safe.
+ Free all allocated memory in pngimage. The file buffer cache was left
+ allocated at the end of the program, harmless but it causes memory
+ leak reports from clang.
+ Fixed array size calculations to avoid warnings. At various points
+ in the code the number of elements in an array is calculated using
+ sizeof. This generates a compile time constant of type (size_t) which
+ is then typically assigned to an (unsigned int) or (int). Some versions
+ of GCC on 64-bit systems warn about the apparent narrowing, even though
+ the same compiler does apparently generate the correct, in-range,
+ numeric constant. This adds appropriate, safe, casts to make the
+ warnings go away.
+
+Version 1.6.15beta06 [November 6, 2014]
+ Reverted use png_get_libpng_ver(NULL) instead of PNG_LIBPNG_VER_STRING
+ in the manual, example.c, pngtest.c, and applications in the contrib
+ directory. It was incorrect advice.
+
+Version 1.6.15beta07 [November 7, 2014]
+ Removed #ifdef PNG_16BIT_SUPPORTED/#endif around png_product2(); it is
+ needed by png_reciprocal2().
+ Added #ifdef PNG_16BIT_SUPPORTED/#endif around png_log16bit() and
+ png_do_swap().
+ Changed all "#endif /* PNG_FEATURE_SUPPORTED */" to "#endif /* FEATURE */"
+
+Version 1.6.15beta08 [November 8, 2014]
+ More housecleaning in *.h
+
+Version 1.6.15rc01 [November 13, 2014]
+
+Version 1.6.15rc02 [November 14, 2014]
+ The macros passed in the command line to Borland make were ignored if
+ similarly-named macros were already defined in makefiles. This behavior
+ is different from POSIX make and other make programs. Surround the
+ macro definitions with ifndef guards (Cosmin).
+
+Version 1.6.15rc03 [November 16, 2014]
+ Added "-D_CRT_SECURE_NO_WARNINGS" to CFLAGS in scripts/makefile.vcwin32.
+ Removed the obsolete $ARCH variable from scripts/makefile.darwin.
+
+Version 1.6.15 [November 20, 2014]
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
@@ -4881,4 +5105,3 @@ to subscribe) or to glennrp at users.sourceforge.net
Glenn R-P
-#endif
diff --git a/plugins/AdvaImg/src/LibPNG/INSTALL b/plugins/AdvaImg/src/LibPNG/INSTALL index 8ed9b1d595..26852c4be3 100644 --- a/plugins/AdvaImg/src/LibPNG/INSTALL +++ b/plugins/AdvaImg/src/LibPNG/INSTALL @@ -1,13 +1,47 @@ Installing libpng
+Contents
+
+ I. Simple installation
+ II. Rebuilding the configure scripts
+ III. Using scripts/makefile*
+ IV. Using cmake
+ V. Directory structure
+ VI. Building with project files
+ VII. Building with makefiles
+VIII. Configuring libpng for 16-bit platforms
+ IX. Configuring for DOS
+ X. Configuring for Medium Model
+ XI. Prepending a prefix to exported symbols
+ XII. Configuring for compiler xxx:
+XIII. Removing unwanted object code
+ XIV. Changes to the build and configuration of libpng in libpng-1.5.x
+ XV. Configuring libpng for multiprocessing
+ XVI. Other sources of information about libpng
+
+I. Simple installation
+
On Unix/Linux and similar systems, you can simply type
./configure [--prefix=/path]
make check
make install
-and ignore the rest of this document.
+and ignore the rest of this document. "/path" is the path to the directory
+where you want to install the libpng "lib", "include", and "bin"
+subdirectories.
+
+If you downloaded a GIT clone, you will need to run ./autogen.sh before
+running ./configure, to create "configure" and "Makefile.in" which are
+not included in the GIT repository.
+
+Note that "configure" is only included in the "*.tar" distributions and not
+in the "*.zip" or "*.7z" distributions. If you downloaded one of those
+distributions, see "Building with project files" or "Building with makefiles",
+below.
+
+II. Rebuilding the configure scripts
If configure does not work on your system, or if you have a need to
change configure.ac or Makefile.am, and you have a reasonably
@@ -24,9 +58,12 @@ aren't using any of the included pre-built scripts, you can do this: make install
make check
+III. Using scripts/makefile*
+
Instead, you can use one of the custom-built makefiles in the
"scripts" directory
+ cp scripts/pnglibconf.h.prebuilt pnglibconf.h
cp scripts/makefile.system makefile
make test
make install
@@ -38,8 +75,8 @@ Or you can use one of the "projects" in the "projects" directory. Before installing libpng, you must first install zlib, if it
is not already on your system. zlib can usually be found
-wherever you got libpng. zlib can be placed in another directory,
-at the same level as libpng.
+wherever you got libpng; otherwise go to http://zlib.net. You can place
+zlib in in the same directory as libpng or in another directory.
If your system already has a preinstalled zlib you will still need
to have access to the zlib.h and zconf.h include files that
@@ -59,15 +96,23 @@ LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH If you are using one of the makefile scripts, put ZLIBLIB and ZLIBINC
in your environment and type "make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test".
+IV. Using cmake
+
If you want to use "cmake" (see www.cmake.org), type
cmake . -DCMAKE_INSTALL_PREFIX=/path
make
make install
+As when using the simple configure method described above, "/path" points to
+the installation directory where you want to put the libpng "lib", "include",
+and "bin" subdirectories.
+
+V. Directory structure
+
You can rename the directories that you downloaded (they
-might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.7"
-or "zlib127") so that you have directories called "zlib" and "libpng".
+might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.8"
+or "zlib128") so that you have directories called "zlib" and "libpng".
Your directory structure should look like this:
@@ -75,8 +120,7 @@ Your directory structure should look like this: libpng (this directory)
INSTALL (this file)
README
- *.h
- *.c
+ *.h, *.c => libpng source files
CMakeLists.txt => "cmake" script
configuration files:
configure.ac, configure, Makefile.am, Makefile.in,
@@ -84,15 +128,10 @@ Your directory structure should look like this: libpng-config.in, aclocal.m4, config.h.in, config.sub,
depcomp, install-sh, mkinstalldirs, test-pngtest.sh
contrib
- gregbook
- libtests
- pngminim
- pngminus
- pngsuite
- visupng
+ arm-neon, conftest, examples, gregbook, libtests, pngminim,
+ pngminus, pngsuite, tools, visupng
projects
- visualc71
- vstudio
+ cbuilder5, owatcom, visualc71, vstudio, xcode
scripts
makefile.*
*.def (module definition files)
@@ -100,29 +139,31 @@ Your directory structure should look like this: pngtest.png
etc.
zlib
- README
- *.h
- *.c
- contrib
- etc.
+ README, *.h, *.c contrib, etc.
If the line endings in the files look funny, you may wish to get the other
distribution of libpng. It is available in both tar.gz (UNIX style line
endings) and zip (DOS style line endings) formats.
+VI. Building with project files
+
If you are building libpng with MSVC, you can enter the
-libpng projects\visualc6 or visualc71 directory and follow the instructions
+libpng projects\visualc71 or vstudio directory and follow the instructions
in README.txt.
Otherwise enter the zlib directory and follow the instructions in zlib/README,
then come back here and run "configure" or choose the appropriate
makefile.sys in the scripts directory.
+VII. Building with makefiles
+
Copy the file (or files) that you need from the
scripts directory into this directory, for example
MSDOS example: copy scripts\makefile.msc makefile
- UNIX example: cp scripts/makefile.std makefile
+ copy scripts\pnglibconf.h.prebuilt pnglibconf.h
+ UNIX example: cp scripts/makefile.std makefile
+ cp scripts/pnglibconf.h.prebuilt pnglibconf.h
Read the makefile to see if you need to change any source or
target directories to match your preferences.
@@ -145,6 +186,197 @@ do that, run "make install" in the zlib directory first if necessary). Some also allow you to run "make test-installed" after you have
run "make install".
+VIII. Configuring libpng for 16-bit platforms
+
+You will want to look into zconf.h to tell zlib (and thus libpng) that
+it cannot allocate more then 64K at a time. Even if you can, the memory
+won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
+
+IX. Configuring for DOS
+
+For DOS users who only have access to the lower 640K, you will
+have to limit zlib's memory usage via a png_set_compression_mem_level()
+call. See zlib.h or zconf.h in the zlib library for more information.
+
+X. Configuring for Medium Model
+
+Libpng's support for medium model has been tested on most of the popular
+compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets
+defined, and FAR gets defined to far in pngconf.h, and you should be
+all set. Everything in the library (except for zlib's structure) is
+expecting far data. You must use the typedefs with the p or pp on
+the end for pointers (or at least look at them and be careful). Make
+note that the rows of data are defined as png_bytepp, which is
+an "unsigned char far * far *".
+
+XI. Prepending a prefix to exported symbols
+
+Starting with libpng-1.6.0, you can configure libpng (when using the
+"configure" script) to prefix all exported symbols by means of the
+configuration option "--with-libpng-prefix=FOO_", where FOO_ can be any
+string beginning with a letter and containing only uppercase
+and lowercase letters, digits, and the underscore (i.e., a C language
+identifier). This creates a set of macros in pnglibconf.h, so this is
+transparent to applications; their function calls get transformed by
+the macros to use the modified names.
+
+XII. Configuring for compiler xxx:
+
+All includes for libpng are in pngconf.h. If you need to add, change
+or delete an include, this is the place to do it.
+The includes that are not needed outside libpng are placed in pngpriv.h,
+which is only used by the routines inside libpng itself.
+The files in libpng proper only include pngpriv.h and png.h, which
+in turn includes pngconf.h and, as of libpng-1.5.0, pnglibconf.h.
+As of libpng-1.5.0, pngpriv.h also includes three other private header
+files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material
+that previously appeared in the public headers.
+
+XIII. Removing unwanted object code
+
+There are a bunch of #define's in pngconf.h that control what parts of
+libpng are compiled. All the defines end in _SUPPORTED. If you are
+never going to use a capability, you can change the #define to #undef
+before recompiling libpng and save yourself code and data space, or
+you can turn off individual capabilities with defines that begin with
+PNG_NO_.
+
+In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead.
+
+You can also turn all of the transforms and ancillary chunk capabilities
+off en masse with compiler directives that define
+PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
+or all four, along with directives to turn on any of the capabilities that
+you do want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable the
+extra transformations but still leave the library fully capable of reading
+and writing PNG files with all known public chunks. Use of the
+PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a library
+that is incapable of reading or writing ancillary chunks. If you are
+not using the progressive reading capability, you can turn that off
+with PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACING
+capability, which you'll still have).
+
+All the reading and writing specific code are in separate files, so the
+linker should only grab the files it needs. However, if you want to
+make sure, or if you are building a stand alone library, all the
+reading files start with "pngr" and all the writing files start with "pngw".
+The files that don't match either (like png.c, pngtrans.c, etc.)
+are used for both reading and writing, and always need to be included.
+The progressive reader is in pngpread.c
+
+If you are creating or distributing a dynamically linked library (a .so
+or DLL file), you should not remove or disable any parts of the library,
+as this will cause applications linked with different versions of the
+library to fail if they call functions not available in your library.
+The size of the library itself should not be an issue, because only
+those sections that are actually used will be loaded into memory.
+
+XIV. Changes to the build and configuration of libpng in libpng-1.5.x
+
+Details of internal changes to the library code can be found in the CHANGES
+file and in the GIT repository logs. These will be of no concern to the vast
+majority of library users or builders; however, the few who configure libpng
+to a non-default feature set may need to change how this is done.
+
+There should be no need for library builders to alter build scripts if
+these use the distributed build support - configure or the makefiles -
+however, users of the makefiles may care to update their build scripts
+to build pnglibconf.h where the corresponding makefile does not do so.
+
+Building libpng with a non-default configuration has changed completely.
+The old method using pngusr.h should still work correctly even though the
+way pngusr.h is used in the build has been changed; however, library
+builders will probably want to examine the changes to take advantage of
+new capabilities and to simplify their build system.
+
+A. Specific changes to library configuration capabilities
+
+The exact mechanism used to control attributes of API functions has
+changed. A single set of operating system independent macro definitions
+is used and operating system specific directives are defined in
+pnglibconf.h
+
+As part of this the mechanism used to choose procedure call standards on
+those systems that allow a choice has been changed. At present this only
+affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems
+running on Intel processors. As before, PNGAPI is defined where required
+to control the exported API functions; however, two new macros, PNGCBAPI
+and PNGCAPI, are used instead for callback functions (PNGCBAPI) and
+(PNGCAPI) for functions that must match a C library prototype (currently
+only png_longjmp_ptr, which must match the C longjmp function.) The new
+approach is documented in pngconf.h
+
+Despite these changes, libpng 1.5.0 only supports the native C function
+calling standard on those platforms tested so far (__cdecl on Microsoft
+Windows). This is because the support requirements for alternative
+calling conventions seem to no longer exist. Developers who find it
+necessary to set PNG_API_RULE to 1 should advise the mailing list
+(png-mng-implement) of this and library builders who use Openwatcom and
+therefore set PNG_API_RULE to 2 should also contact the mailing list.
+
+B. Changes to the configuration mechanism
+
+Prior to libpng-1.5.0 library builders who needed to configure libpng
+had either to modify the exported pngconf.h header file to add system
+specific configuration or had to write feature selection macros into
+pngusr.h and cause this to be included into pngconf.h by defining
+PNG_USER_CONFIG. The latter mechanism had the disadvantage that an
+application built without PNG_USER_CONFIG defined would see the
+unmodified, default, libpng API and thus would probably fail to link.
+
+These mechanisms still work in the configure build and in any makefile
+build that builds pnglibconf.h, although the feature selection macros
+have changed somewhat as described above. In 1.5.0, however, pngusr.h is
+processed only once, at the time the exported header file pnglibconf.h is
+built. pngconf.h no longer includes pngusr.h; therefore, pngusr.h is ignored
+after the build of pnglibconf.h and it is never included in an application
+build.
+
+The formerly used alternative of adding a list of feature macros to the
+CPPFLAGS setting in the build also still works; however, the macros will be
+copied to pnglibconf.h and this may produce macro redefinition warnings
+when the individual C files are compiled.
+
+All configuration now only works if pnglibconf.h is built from
+scripts/pnglibconf.dfa. This requires the program awk. Brian Kernighan
+(the original author of awk) maintains C source code of that awk and this
+and all known later implementations (often called by subtly different
+names - nawk and gawk for example) are adequate to build pnglibconf.h.
+The Sun Microsystems (now Oracle) program 'awk' is an earlier version
+and does not work; this may also apply to other systems that have a
+functioning awk called 'nawk'.
+
+Configuration options are now documented in scripts/pnglibconf.dfa. This
+file also includes dependency information that ensures a configuration is
+consistent; that is, if a feature is switched off, dependent features are
+also switched off. As a recommended alternative to using feature macros in
+pngusr.h a system builder may also define equivalent options in pngusr.dfa
+(or, indeed, any file) and add that to the configuration by setting
+DFA_XTRA to the file name. The makefiles in contrib/pngminim illustrate
+how to do this, and also illustrate a case where pngusr.h is still required.
+
+After you have built libpng, the definitions that were recorded in
+pnglibconf.h are available to your application (pnglibconf.h is included
+in png.h and gets installed alongside png.h and pngconf.h in your
+$PREFIX/include directory). Do not edit pnglibconf.h after you have built
+libpng, because than the settings would not accurately reflect the settings
+that were used to build libpng.
+
+XV. Configuring libpng for multiprocessing
+
+Libpng uses setjmp()/longjmp() for error handling. Unfortunately setjmp()
+is known to be not thread-safe on some platforms and we don't know of
+any platform where it is guaranteed to be thread-safe. Therefore, if
+your application is going to be using multiple threads, you should
+configure libpng with PNG_NO_SETJMP in your pngusr.dfa file, with
+-DPNG_NO_SETJMP on your compile line, or with
+
+ #undef PNG_SETJMP_SUPPORTED
+
+in your pnglibconf.h or pngusr.h.
+
+XVI. Other sources of information about libpng:
+
Further information can be found in the README and libpng-manual.txt
files, in the individual makefiles, in png.h, and the manual pages
libpng.3 and png.5.
diff --git a/plugins/AdvaImg/src/LibPNG/LICENSE b/plugins/AdvaImg/src/LibPNG/LICENSE index ea1841e479..1bd7e37d16 100644 --- a/plugins/AdvaImg/src/LibPNG/LICENSE +++ b/plugins/AdvaImg/src/LibPNG/LICENSE @@ -10,7 +10,7 @@ this sentence. This code is released under the libpng license.
-libpng versions 1.2.6, August 15, 2004, through 1.6.10, March 6, 2014, are
+libpng versions 1.2.6, August 15, 2004, through 1.6.15, November 20, 2014, are
Copyright (c) 2004, 2006-2014 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.2.5
with the following individual added to the list of Contributing Authors
@@ -108,4 +108,4 @@ certification mark of the Open Source Initiative. Glenn Randers-Pehrson
glennrp at users.sourceforge.net
-March 6, 2014
+November 20, 2014
diff --git a/plugins/AdvaImg/src/LibPNG/README b/plugins/AdvaImg/src/LibPNG/README index d7b19371f9..165cbeafe5 100644 --- a/plugins/AdvaImg/src/LibPNG/README +++ b/plugins/AdvaImg/src/LibPNG/README @@ -1,4 +1,4 @@ -README for libpng version 1.6.10 - March 6, 2014 (shared library 16.0)
+README for libpng version 1.6.15 - November 20, 2014 (shared library 16.0)
See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng.
@@ -23,18 +23,25 @@ earlier versions if you are using a shared library. The type of the png_uint_32, which will affect shared-library applications that use
this function.
-To avoid problems with changes to the internals of png_info_struct,
+To avoid problems with changes to the internals of png info_struct,
new APIs have been made available in 0.95 to avoid direct application
access to info_ptr. These functions are the png_set_<chunk> and
png_get_<chunk> functions. These functions should be used when
accessing/storing the info_struct data, rather than manipulating it
directly, to avoid such problems in the future.
-It is important to note that the APIs do not make current programs
+It is important to note that the APIs did not make current programs
that access the info struct directly incompatible with the new
-library. However, it is strongly suggested that new programs use
-the new APIs (as shown in example.c and pngtest.c), and older programs
-be converted to the new format, to facilitate upgrades in the future.
+library, through libpng-1.2.x. In libpng-1.4.x, which was meant to
+be a transitional release, members of the png_struct and the
+info_struct can still be accessed, but the compiler will issue a
+warning about deprecated usage. Since libpng-1.5.0, direct access
+to these structs is not allowed, and the definitions of the structs
+reside in private pngstruct.h and pnginfo.h header files that are not
+accessible to applications. It is strongly suggested that new
+programs use the new APIs (as shown in example.c and pngtest.c), and
+older programs be converted to the new format, to facilitate upgrades
+in the future.
****
Additions since 0.90 include the ability to compile libpng as a
@@ -87,6 +94,12 @@ This code is currently being archived at libpng.sf.net in the [DOWNLOAD] area, and at ftp://ftp.simplesystems.org. If you can't find it
in any of those places, e-mail me, and I'll help you find it.
+I am not a lawyer, but I believe that the Export Control Classification
+Number (ECCN) for libpng is EAR99, which means not subject to export
+controls or International Traffic in Arms Regulations (ITAR) because it
+is open source, publicly available software, that does not contain any
+encryption software. See the EAR, paragraphs 734.3(b)(3) and 734.7(b).
+
If you have any code changes, requests, problems, etc., please e-mail
them to me. Also, I'd appreciate any make files or project files,
and any modifications you needed to make to get libpng to compile,
@@ -177,7 +190,7 @@ Files in this distribution: pngminus => Simple pnm2png and png2pnm programs
pngsuite => Test images
tools => Various tools
- visupng => Contains a MSVC workspace for VisualPng
+ visupng => Contains a MSVC workspace for VisualPng
projects => Contains project files and workspaces for
building a DLL
owatcom => Contains a WATCOM project for building libpng
diff --git a/plugins/AdvaImg/src/LibPNG/TODO b/plugins/AdvaImg/src/LibPNG/TODO index 4659b70d81..fc18bba930 100644 --- a/plugins/AdvaImg/src/LibPNG/TODO +++ b/plugins/AdvaImg/src/LibPNG/TODO @@ -6,6 +6,7 @@ Better C++ wrapper/full C++ implementation? Fix problem with C++ and EXTERN "C".
cHRM transformation.
Remove setjmp/longjmp usage in favor of returning error codes.
+Palette creation.
Add "grayscale->palette" transformation and "palette->grayscale" detection.
Improved dithering.
Multi-lingual error and warning message support.
diff --git a/plugins/AdvaImg/src/LibPNG/configure b/plugins/AdvaImg/src/LibPNG/configure index 4dbd0267d7..df9cf05404 100644 --- a/plugins/AdvaImg/src/LibPNG/configure +++ b/plugins/AdvaImg/src/LibPNG/configure @@ -1,14 +1,14 @@ echo "
There is no \"configure\" script in this distribution (*.zip or *.7z) of
- libpng-1.6.10.
+ libpng-1.6.15.
Instead, please copy the appropriate makefile for your system from the
\"scripts\" directory. Read the INSTALL file for more details.
Update, July 2004: you can get a \"configure\" based distribution
from the libpng distribution sites. Download the file
- libpng-1.6.10.tar.gz, libpng-1.6.10.tar.xz, or libpng-1.6.10.tar.bz2
+ libpng-1.6.15.tar.gz, libpng-1.6.15.tar.xz, or libpng-1.6.15.tar.bz2
If the line endings in the files look funny, which is likely to be the
case if you were trying to run \"configure\" on a Linux machine, you may
diff --git a/plugins/AdvaImg/src/LibPNG/example.c b/plugins/AdvaImg/src/LibPNG/example.c index c43bc019b6..0337cdba7a 100644 --- a/plugins/AdvaImg/src/LibPNG/example.c +++ b/plugins/AdvaImg/src/LibPNG/example.c @@ -2,8 +2,8 @@ #if 0 /* in case someone actually tries to compile this */
/* example.c - an example of using libpng
- * Last changed in libpng 1.6.3 [July 18, 2013]
- * Maintained 1998-2013 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.15 [November 20, 2014]
+ * Maintained 1998-2014 Glenn Randers-Pehrson
* Maintained 1996, 1997 Andreas Dilger)
* Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* To the extent possible under law, the authors have waived
@@ -52,7 +52,7 @@ int main(int argc, const char **argv) image.version = PNG_IMAGE_VERSION;
/* The first argument is the file to read: */
- if (png_image_begin_read_from_file(&image, argv[1]))
+ if (png_image_begin_read_from_file(&image, argv[1]) != 0)
{
png_bytep buffer;
@@ -97,7 +97,7 @@ int main(int argc, const char **argv) */
if (buffer != NULL &&
png_image_finish_read(&image, NULL/*background*/, buffer,
- 0/*row_stride*/, NULL/*colormap*/))
+ 0/*row_stride*/, NULL/*colormap*/) != 0)
{
/* Now write the image out to the second argument. In the write
* call 'convert_to_8bit' allows 16-bit data to be squashed down to
@@ -105,7 +105,7 @@ int main(int argc, const char **argv) * to the 8-bit format.
*/
if (png_image_write_to_file(&image, argv[2], 0/*convert_to_8bit*/,
- buffer, 0/*row_stride*/, NULL/*colormap*/))
+ buffer, 0/*row_stride*/, NULL/*colormap*/) != 0)
{
/* The image has been written successfully. */
exit(0);
@@ -188,13 +188,13 @@ int main(int argc, const char **argv) *
* Don't repeatedly convert between the 8-bit and 16-bit forms. There is
* significant data loss when 16-bit data is converted to the 8-bit encoding and
- * the current libpng implementation of convertion to 16-bit is also
+ * the current libpng implementation of conversion to 16-bit is also
* significantly lossy. The latter will be fixed in the future, but the former
* is unavoidable - the 8-bit format just doesn't have enough resolution.
*/
/* If your program needs more information from the PNG data it reads, or if you
- * need to do more complex transformations, or minimise transformations, on the
+ * need to do more complex transformations, or minimize transformations, on the
* data you read, then you must use one of the several lower level libpng
* interfaces.
*
@@ -405,7 +405,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */ /* Expand paletted or RGB images with transparency to full alpha channels
* so the data will be available as RGBA quartets.
*/
- if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
+ if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) != 0)
png_set_tRNS_to_alpha(png_ptr);
/* Set the background color to draw transparent and alpha images over.
@@ -417,7 +417,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */ png_color_16 my_background, *image_background;
- if (png_get_bKGD(png_ptr, info_ptr, &image_background))
+ if (png_get_bKGD(png_ptr, info_ptr, &image_background) != 0)
png_set_background(png_ptr, image_background,
PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
else
@@ -454,12 +454,12 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */ int intent;
- if (png_get_sRGB(png_ptr, info_ptr, &intent))
+ if (png_get_sRGB(png_ptr, info_ptr, &intent) != 0)
png_set_gamma(png_ptr, screen_gamma, PNG_DEFAULT_sRGB);
else
{
double image_gamma;
- if (png_get_gAMA(png_ptr, info_ptr, &image_gamma))
+ if (png_get_gAMA(png_ptr, info_ptr, &image_gamma) != 0)
png_set_gamma(png_ptr, screen_gamma, image_gamma);
else
png_set_gamma(png_ptr, screen_gamma, 0.45455);
@@ -469,7 +469,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */ /* Quantize RGB files down to 8 bit palette or reduce palettes
* to the number of colors available on your screen.
*/
- if (color_type & PNG_COLOR_MASK_COLOR)
+ if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
{
int num_palette;
png_colorp palette;
@@ -484,7 +484,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */ MAX_SCREEN_COLORS, NULL, 0);
}
/* This reduces the image to the palette supplied in the file */
- else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette))
+ else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette) != 0)
{
png_uint_16p histogram = NULL;
@@ -494,7 +494,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */ max_screen_colors, histogram, 0);
}
}
-#endif /* PNG_READ_QUANTIZE_SUPPORTED */
+#endif /* READ_QUANTIZE */
/* Invert monochrome files to have 0 as white and 1 as black */
png_set_invert_mono(png_ptr);
@@ -503,7 +503,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */ * [0,65535] to the original [0,7] or [0,31], or whatever range the
* colors were originally in:
*/
- if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT))
+ if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT) != 0)
{
png_color_8p sig_bit_p;
@@ -512,7 +512,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */ }
/* Flip the RGB pixels to BGR (or RGBA to BGRA) */
- if (color_type & PNG_COLOR_MASK_COLOR)
+ if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
png_set_bgr(png_ptr);
/* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
@@ -532,7 +532,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */ number_passes = png_set_interlace_handling(png_ptr);
#else
number_passes = 1;
-#endif /* PNG_READ_INTERLACING_SUPPORTED */
+#endif /* READ_INTERLACING */
/* Optional call to gamma correct and add the background to the palette
@@ -744,7 +744,7 @@ row_callback(png_structp png_ptr, png_bytep new_row, * to pass the current row as new_row, and the function will combine
* the old row and the new row.
*/
-#endif /* PNG_READ_INTERLACING_SUPPORTED */
+#endif /* READ_INTERLACING */
}
end_callback(png_structp png_ptr, png_infop info)
@@ -932,7 +932,7 @@ void write_png(char *file_name /* , ... other image information ... */) */
/* Once we write out the header, the compression type on the text
- * chunks gets changed to PNG_TEXT_COMPRESSION_NONE_WR or
+ * chunk gets changed to PNG_TEXT_COMPRESSION_NONE_WR or
* PNG_TEXT_COMPRESSION_zTXt_WR, so it doesn't get written out again
* at the end.
*/
@@ -970,7 +970,7 @@ void write_png(char *file_name /* , ... other image information ... */) png_set_packswap(png_ptr);
/* Turn on interlace handling if you are not using png_write_image() */
- if (interlacing)
+ if (interlacing != 0)
number_passes = png_set_interlace_handling(png_ptr);
else
diff --git a/plugins/AdvaImg/src/LibPNG/libpng-manual.txt b/plugins/AdvaImg/src/LibPNG/libpng-manual.txt index c8cd50393e..cd867155bf 100644 --- a/plugins/AdvaImg/src/LibPNG/libpng-manual.txt +++ b/plugins/AdvaImg/src/LibPNG/libpng-manual.txt @@ -1,6 +1,6 @@ libpng-manual.txt - A description on how to use and modify libpng
- libpng version 1.6.10 - March 6, 2014
+ libpng version 1.6.15 - November 20, 2014
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2014 Glenn Randers-Pehrson
@@ -11,15 +11,15 @@ libpng-manual.txt - A description on how to use and modify libpng Based on:
- libpng versions 0.97, January 1998, through 1.6.10 - March 6, 2014
+ libpng versions 0.97, January 1998, through 1.6.15 - November 20, 2014
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2014 Glenn Randers-Pehrson
- libpng 1.0 beta 6 version 0.96 May 28, 1997
+ libpng 1.0 beta 6 - version 0.96 - May 28, 1997
Updated and distributed by Andreas Dilger
Copyright (c) 1996, 1997 Andreas Dilger
- libpng 1.0 beta 2 - version 0.88 January 26, 1996
+ libpng 1.0 beta 2 - version 0.88 - January 26, 1996
For conditions of distribution and use, see copyright
notice in png.h. Copyright (c) 1995, 1996 Guy Eric
Schalnat, Group 42, Inc.
@@ -54,7 +54,7 @@ This file describes how to use and modify the PNG reference library file, example.c is a good starting point for using the library, as
it is heavily commented and should include everything most people
will need. We assume that libpng is already installed; see the
-INSTALL file for instructions on how to install libpng.
+INSTALL file for instructions on how to configure and install libpng.
For examples of libpng usage, see the files "example.c", "pngtest.c",
and the files in the "contrib" directory, all of which are included in
@@ -2636,7 +2636,7 @@ png_infop info_ptr; png_progressive_combine_row(png_ptr, old_row,
new_row);
- /* where old_row is what was displayed for
+ /* where old_row is what was displayed
previously for the row. Note that the first
pass (pass == 0, really) will completely cover
the old row, so the rows do not have to be
@@ -3261,7 +3261,7 @@ tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"), although this isn't a requirement. Unlike the tIME chunk, the
"Creation Time" tEXt chunk is not expected to be automatically changed
by the software. To facilitate the use of RFC 1123 dates, a function
-png_convert_to_rfc1123_buffer(png_ptr, buffer, png_timep) is provided to
+png_convert_to_rfc1123_buffer(buffer, png_timep) is provided to
convert from PNG time to an RFC 1123 format string. The caller must provide
a writeable buffer of at least 29 bytes.
@@ -3793,8 +3793,9 @@ and matches the 8-bit format expected by typical display devices. The color/gray channels are not scaled (pre-multiplied) by the alpha
channel and are suitable for passing to color management software.
- b) As a value in the range 0..65535, contained in a 2-byte integer. All
-channels can be converted to the original value by dividing by 65535; all
+ b) As a value in the range 0..65535, contained in a 2-byte integer, in
+the native byte order of the platform on which the application is running.
+All channels can be converted to the original value by dividing by 65535; all
channels are linear. Color channels use the RGB encoding (RGB end-points) of
the sRGB specification. This encoding is identified by the
PNG_FORMAT_FLAG_LINEAR flag below.
@@ -3861,7 +3862,9 @@ First the single byte formats: Then the linear 2-byte formats. When naming these "Y" is used to
indicate a luminance (gray) channel. The component order within the pixel
is always the same - there is no provision for swapping the order of the
-components in the linear format.
+components in the linear format. The components are 16-bit integers in
+the native byte order for your platform, and there is no provision for
+swapping the bytes to a different endian condition.
PNG_FORMAT_LINEAR_Y PNG_FORMAT_FLAG_LINEAR
PNG_FORMAT_LINEAR_Y_ALPHA
@@ -3926,7 +3929,7 @@ First the information about the samples. *
* png_byte colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(sRGB_fmt)];
*
- * Alternatively use the PNG_IMAGE_COLORMAP_SIZE macro below to use the
+ * Alternatively, use the PNG_IMAGE_COLORMAP_SIZE macro below to use the
* information from one of the png_image_begin_read_ APIs and dynamically
* allocate the required memory.
*/
@@ -3955,9 +3958,16 @@ Information about the whole row, or whole image row. For a color-mapped image this is the minimum number of bytes in a
row.
+ If you need the stride measured in bytes, row_stride_bytes is
+ PNG_IMAGE_ROW_STRIDE(image) * PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)
+ plus any padding bytes that your application might need, for example
+ to start the next row on a 4-byte boundary.
+
PNG_IMAGE_BUFFER_SIZE(image, row_stride)
Returns the size, in bytes, of an image buffer given a png_image and a row
- stride - the number of components to leave space for in each row.
+ stride - the number of components to leave space for in each row. This
+ macro takes care of multiplying row_stride by PNG_IMAGE_PIXEL_COMONENT_SIZE
+ when the image has 2-byte components.
PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB == 0x01
This indicates the the RGB values of the in-memory bitmap do not
@@ -4086,14 +4096,11 @@ clears the newly allocated memory to zero; note that png_calloc(png_ptr, size) is not the same as the calloc(number, size) function provided by stdlib.h.
There is limited support for certain systems with segmented memory
architectures and the types of pointers declared by png.h match this; you
-will have to use appropriate pointers in your application. Since it is
-unlikely that the method of handling memory allocation on a platform
-will change between applications, these functions must be modified in
-the library at compile time. If you prefer to use a different method
-of allocating and freeing data, you can use png_create_read_struct_2() or
-png_create_write_struct_2() to register your own functions as described
-above. These functions also provide a void pointer that can be retrieved
-via
+will have to use appropriate pointers in your application. If you prefer
+to use a different method of allocating and freeing data, you can use
+png_create_read_struct_2() or png_create_write_struct_2() to register your
+own functions as described above. These functions also provide a void
+pointer that can be retrieved via
mem_ptr=png_get_mem_ptr(png_ptr);
@@ -4236,29 +4243,6 @@ the simpler ones to get an idea of how they work. Try to find a similar transformation to the one you want to add and copy off of it. More details
can be found in the comments inside the code itself.
-Configuring for 16-bit platforms
-
-You will want to look into zconf.h to tell zlib (and thus libpng) that
-it cannot allocate more then 64K at a time. Even if you can, the memory
-won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
-
-Configuring for DOS
-
-For DOS users who only have access to the lower 640K, you will
-have to limit zlib's memory usage via a png_set_compression_mem_level()
-call. See zlib.h or zconf.h in the zlib library for more information.
-
-Configuring for Medium Model
-
-Libpng's support for medium model has been tested on most of the popular
-compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets
-defined, and FAR gets defined to far in pngconf.h, and you should be
-all set. Everything in the library (except for zlib's structure) is
-expecting far data. You must use the typedefs with the p or pp on
-the end for pointers (or at least look at them and be careful). Make
-note that the rows of data are defined as png_bytepp, which is
-an "unsigned char far * far *".
-
Configuring for gui/windowing platforms:
You will need to write new error and warning functions that use the GUI
@@ -4268,18 +4252,6 @@ in order to have them available during the structure initialization. They can be changed later via png_set_error_fn(). On some compilers,
you may also have to change the memory allocators (png_malloc, etc.).
-Configuring for compiler xxx:
-
-All includes for libpng are in pngconf.h. If you need to add, change
-or delete an include, this is the place to do it.
-The includes that are not needed outside libpng are placed in pngpriv.h,
-which is only used by the routines inside libpng itself.
-The files in libpng proper only include pngpriv.h and png.h, which
-in turn includes pngconf.h and, as of libpng-1.5.0, pnglibconf.h.
-As of libpng-1.5.0, pngpriv.h also includes three other private header
-files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material
-that previously appeared in the public headers.
-
Configuring zlib:
There are special functions to configure the compression. Perhaps the
@@ -4321,6 +4293,8 @@ zlib.h for more information on what these mean. png_set_compression_method(png_ptr, method);
+This controls the size of the IDAT chunks (default 8192):
+
png_set_compression_buffer_size(png_ptr, size);
As of libpng version 1.5.4, additional APIs became
@@ -4419,46 +4393,6 @@ Note that the numbers above were invented purely for this example and are given only to help explain the function usage. Little testing has
been done to find optimum values for either the costs or the weights.
-Removing unwanted object code
-
-There are a bunch of #define's in pngconf.h that control what parts of
-libpng are compiled. All the defines end in _SUPPORTED. If you are
-never going to use a capability, you can change the #define to #undef
-before recompiling libpng and save yourself code and data space, or
-you can turn off individual capabilities with defines that begin with
-PNG_NO_.
-
-In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead.
-
-You can also turn all of the transforms and ancillary chunk capabilities
-off en masse with compiler directives that define
-PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
-or all four,
-along with directives to turn on any of the capabilities that you do
-want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable the extra
-transformations but still leave the library fully capable of reading
-and writing PNG files with all known public chunks. Use of the
-PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a library
-that is incapable of reading or writing ancillary chunks. If you are
-not using the progressive reading capability, you can turn that off
-with PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACING
-capability, which you'll still have).
-
-All the reading and writing specific code are in separate files, so the
-linker should only grab the files it needs. However, if you want to
-make sure, or if you are building a stand alone library, all the
-reading files start with "pngr" and all the writing files start with "pngw".
-The files that don't match either (like png.c, pngtrans.c, etc.)
-are used for both reading and writing, and always need to be included.
-The progressive reader is in pngpread.c
-
-If you are creating or distributing a dynamically linked library (a .so
-or DLL file), you should not remove or disable any parts of the library,
-as this will cause applications linked with different versions of the
-library to fail if they call functions not available in your library.
-The size of the library itself should not be an issue, because only
-those sections that are actually used will be loaded into memory.
-
Requesting debug printout
The macro definition PNG_DEBUG can be used to request debugging
@@ -4496,17 +4430,6 @@ When PNG_DEBUG = 1, the macros are defined, but only png_debug statements having level = 0 will be printed. There aren't any such statements in
this version of libpng, but if you insert some they will be printed.
-Prepending a prefix to exported symbols
-
-Starting with libpng-1.6.0, you can configure libpng (when using the
-"configure" script) to prefix all exported symbols by means of the
-configuration option "--with-libpng-prefix=FOO_", where FOO_ can be any
-string beginning with a letter and containing only uppercase
-and lowercase letters, digits, and the underscore (i.e., a C language
-identifier). This creates a set of macros in pnglibconf.h, so this is
-transparent to applications; their function calls get transformed by
-the macros to use the modified names.
-
VII. MNG support
The MNG specification (available at http://www.libpng.org/pub/mng) allows
@@ -4833,8 +4756,6 @@ does not account for any palette index used by ancillary chunks such as the bKGD chunk; you must check those separately to determine the maximum
palette index actually used.
-A. Changes that affect users of libpng
-
There are no substantial API changes between the non-deprecated parts of
the 1.4.5 API and the 1.5.0 API; however, the ability to directly access
members of the main libpng control structures, png_struct and png_info,
@@ -4973,26 +4894,6 @@ limits are now The png_set_option() function (and the "options" member of the png struct) was
added to libpng-1.5.15.
-B. Changes to the build and configuration of libpng
-
-Details of internal changes to the library code can be found in the CHANGES
-file and in the GIT repository logs. These will be of no concern to the vast
-majority of library users or builders; however, the few who configure libpng
-to a non-default feature set may need to change how this is done.
-
-There should be no need for library builders to alter build scripts if
-these use the distributed build support - configure or the makefiles -
-however, users of the makefiles may care to update their build scripts
-to build pnglibconf.h where the corresponding makefile does not do so.
-
-Building libpng with a non-default configuration has changed completely.
-The old method using pngusr.h should still work correctly even though the
-way pngusr.h is used in the build has been changed; however, library
-builders will probably want to examine the changes to take advantage of
-new capabilities and to simplify their build system.
-
-B.1 Specific changes to library configuration capabilities
-
The library now supports a complete fixed point implementation and can
thus be used on systems that have no floating point support or very
limited or slow support. Previously gamma correction, an essential part
@@ -5003,27 +4904,7 @@ independent of the choice of fixed versus floating point APIs and all the missing fixed point APIs have been implemented.
The exact mechanism used to control attributes of API functions has
-changed. A single set of operating system independent macro definitions
-is used and operating system specific directives are defined in
-pnglibconf.h
-
-As part of this the mechanism used to choose procedure call standards on
-those systems that allow a choice has been changed. At present this only
-affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems
-running on Intel processors. As before, PNGAPI is defined where required
-to control the exported API functions; however, two new macros, PNGCBAPI
-and PNGCAPI, are used instead for callback functions (PNGCBAPI) and
-(PNGCAPI) for functions that must match a C library prototype (currently
-only png_longjmp_ptr, which must match the C longjmp function.) The new
-approach is documented in pngconf.h
-
-Despite these changes, libpng 1.5.0 only supports the native C function
-calling standard on those platforms tested so far (__cdecl on Microsoft
-Windows). This is because the support requirements for alternative
-calling conventions seem to no longer exist. Developers who find it
-necessary to set PNG_API_RULE to 1 should advise the mailing list
-(png-mng-implement) of this and library builders who use Openwatcom and
-therefore set PNG_API_RULE to 2 should also contact the mailing list.
+changed, as described in the INSTALL file.
A new test program, pngvalid, is provided in addition to pngtest.
pngvalid validates the arithmetic accuracy of the gamma correction
@@ -5099,46 +4980,6 @@ even though the default is to use the macros - this allows applications to choose at app buildtime whether or not to use macros (previously
impossible because the functions weren't in the default build.)
-B.2 Changes to the configuration mechanism
-
-Prior to libpng-1.5.0 library builders who needed to configure libpng
-had either to modify the exported pngconf.h header file to add system
-specific configuration or had to write feature selection macros into
-pngusr.h and cause this to be included into pngconf.h by defining
-PNG_USER_CONFIG. The latter mechanism had the disadvantage that an
-application built without PNG_USER_CONFIG defined would see the
-unmodified, default, libpng API and thus would probably fail to link.
-
-These mechanisms still work in the configure build and in any makefile
-build that builds pnglibconf.h, although the feature selection macros
-have changed somewhat as described above. In 1.5.0, however, pngusr.h is
-processed only once, when the exported header file pnglibconf.h is built.
-pngconf.h no longer includes pngusr.h, therefore pngusr.h is ignored after the
-build of pnglibconf.h and it is never included in an application build.
-
-The rarely used alternative of adding a list of feature macros to the
-CPPFLAGS setting in the build also still works; however, the macros will be
-copied to pnglibconf.h and this may produce macro redefinition warnings
-when the individual C files are compiled.
-
-All configuration now only works if pnglibconf.h is built from
-scripts/pnglibconf.dfa. This requires the program awk. Brian Kernighan
-(the original author of awk) maintains C source code of that awk and this
-and all known later implementations (often called by subtly different
-names - nawk and gawk for example) are adequate to build pnglibconf.h.
-The Sun Microsystems (now Oracle) program 'awk' is an earlier version
-and does not work; this may also apply to other systems that have a
-functioning awk called 'nawk'.
-
-Configuration options are now documented in scripts/pnglibconf.dfa. This
-file also includes dependency information that ensures a configuration is
-consistent; that is, if a feature is switched off dependent features are
-also removed. As a recommended alternative to using feature macros in
-pngusr.h a system builder may also define equivalent options in pngusr.dfa
-(or, indeed, any file) and add that to the configuration by setting
-DFA_XTRA to the file name. The makefiles in contrib/pngminim illustrate
-how to do this, and a case where pngusr.h is still required.
-
XII. Changes to Libpng from version 1.5.x to 1.6.x
A "simplified API" has been added (see documentation in png.h and a simple
@@ -5197,11 +5038,26 @@ Error detection in some chunks has improved; in particular the iCCP chunk reader now does pretty complete validation of the basic format. Some bad
profiles that were previously accepted are now accepted with a warning or
rejected, depending upon the png_set_benign_errors() setting, in particular the
-very old broken Microsoft/HP 3144-byte sRGB profile. The PNG spec requirement
-that only grayscale profiles may appear in images with color type 0 or 4 and
-that even if the image only contains gray pixels, only RGB profiles may appear
-in images with color type 2, 3, or 6, is now enforced. The sRGB chunk
-is allowed to appear in images with any color type.
+very old broken Microsoft/HP 3144-byte sRGB profile. Starting with
+libpng-1.6.11, recognizing and checking sRGB profiles can be avoided by
+means of
+
+ #if defined(PNG_SKIP_sRGB_CHECK_PROFILE) && \
+ defined(PNG_SET_OPTION_SUPPORTED)
+ png_set_option(png_ptr, PNG_SKIP_sRGB_CHECK_PROFILE,
+ PNG_OPTION_ON);
+ #endif
+
+It's not a good idea to do this if you are using the "simplified API",
+which needs to be able to recognize an sRGB profile conveyed via the iCCP
+chunk.
+
+The PNG spec requirement that only grayscale profiles may appear in images
+with color type 0 or 4 and that even if the image only contains gray pixels,
+only RGB profiles may appear in images with color type 2, 3, or 6, is now
+enforced. The sRGB chunk is allowed to appear in images with any color type
+and is interpreted by libpng to convey a one-tracer-curve gray profile or a
+three-tracer-curve RGB profile as appropriate.
Prior to libpng-1.6.0 a warning would be issued if the iTXt chunk contained
an empty language field or an empty translated keyword. Both of these
@@ -5235,16 +5091,16 @@ Libpng-1.6.0 through 1.6.2 used the CMF bytes at the beginning of the IDAT stream to set the size of the sliding window for reading instead of using the
default 32-kbyte sliding window size. It was discovered that there are
hundreds of PNG files in the wild that have incorrect CMF bytes that caused
-libpng to issue a "too far back" error and reject the file. Libpng-1.6.3 and
-later calculate their own safe CMF from the image dimensions, provide a way
-to revert to the libpng-1.5.x behavior (ignoring the CMF bytes and using a
-32-kbyte sliding window), by using
+zlib to issue the "invalid distance too far back" error and reject the file.
+Libpng-1.6.3 and later calculate their own safe CMF from the image dimensions,
+provide a way to revert to the libpng-1.5.x behavior (ignoring the CMF bytes
+and using a 32-kbyte sliding window), by using
png_set_option(png_ptr, PNG_MAXIMUM_INFLATE_WINDOW,
PNG_OPTION_ON);
-and provide a tool (contrib/tools/pngfix) for optimizing the CMF bytes
-correctly.
+and provide a tool (contrib/tools/pngfix) for rewriting a PNG file while
+optimizing the CMF bytes in its IDAT chunk correctly.
Libpng-1.6.0 and libpng-1.6.1 wrote uncompressed iTXt chunks with the wrong
length, which resulted in PNG files that cannot be read beyond the bad iTXt
@@ -5286,7 +5142,8 @@ mailing list, or directly to glennrp. XV. Coding style
-Our coding style is similar to the "Allman" style, with curly
+Our coding style is similar to the "Allman" style
+(See http://en.wikipedia.org/wiki/Indent_style#Allman_style), with curly
braces on separate lines:
if (condition)
@@ -5366,12 +5223,15 @@ We mark all non-exported functions with "/* PRIVATE */"": }
The prototypes for non-exported functions (except for those in
-pngtest) appear in
-pngpriv.h
-above the comment that says
+pngtest) appear in pngpriv.h above the comment that says
/* Maintainer: Put new private prototypes here ^ */
+To avoid polluting the global namespace, the names of all exported
+functions and variables begin with "png_", and all publicly visible C
+preprocessor macros begin with "PNG". We request that applications that
+use libpng *not* begin any of their own symbols with either of these strings.
+
We put a space after the "sizeof" operator and we omit the
optional parentheses around its argument when the argument
is an expression, not a type name, and we always enclose the
@@ -5383,10 +5243,8 @@ sizeof operator, with its argument, in parentheses: Prior to libpng-1.6.0 we used a "png_sizeof()" macro, formatted as
though it were a function.
-To avoid polluting the global namespace, the names of all exported
-functions and variables begin with "png_", and all publicly visible C
-preprocessor macros begin with "PNG". We request that applications that
-use libpng *not* begin any of their own symbols with either of these strings.
+Control keywords if, for, while, and switch are always followed by a space
+to distinguish them from function calls, which have no trailing space.
We put a space after each comma and after each semicolon
in "for" statements, and we put spaces before and after each
@@ -5408,6 +5266,9 @@ with an even number of lower-case hex digits (e.g., 0x00, 0xff, 0x0100). We prefer to use underscores in variable names rather than camelCase, except
for a few type names that we inherit from zlib.h.
+We prefer "if (something != 0)" and "if (something == 0)"
+over "if (something)" and if "(!something)", respectively.
+
We do not use the TAB character for indentation in the C sources.
Lines do not exceed 80 characters.
@@ -5416,13 +5277,13 @@ Other rules can be inferred by inspecting the libpng source. XVI. Y2K Compliance in libpng
-March 6, 2014
+November 20, 2014
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.71 and
-upward through 1.6.10 are Y2K compliant. It is my belief that earlier
+upward through 1.6.15 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant.
Libpng only has two year fields. One is a 2-byte unsigned integer
@@ -5438,8 +5299,9 @@ in libpng-1.6.x and will be removed from libpng-1.7.0. There are seven time-related functions:
- png_convert_to_rfc_1123() in png.c
- (formerly png_convert_to_rfc_1152() in error)
+ png_convert_to_rfc_1123_buffer() in png.c
+ (formerly png_convert_to_rfc_1152() in error, and
+ also formerly png_convert_to_rfc_1123())
png_convert_from_struct_tm() in pngwrite.c, called
in pngwrite.c
png_convert_from_time_t() in pngwrite.c
diff --git a/plugins/AdvaImg/src/LibPNG/libpng.3 b/plugins/AdvaImg/src/LibPNG/libpng.3 index a84c3b6b7e..143bbc9bf1 100644 --- a/plugins/AdvaImg/src/LibPNG/libpng.3 +++ b/plugins/AdvaImg/src/LibPNG/libpng.3 @@ -1,6 +1,6 @@ -.TH LIBPNG 3 "March 6, 2014"
+.TH LIBPNG 3 "November 20, 2014"
.SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.6.10
+libpng \- Portable Network Graphics (PNG) Reference Library 1.6.15
.SH SYNOPSIS
\fB
#include <png.h>\fP
@@ -504,7 +504,7 @@ Following is a copy of the libpng-manual.txt file that accompanies libpng. .SH LIBPNG.TXT
libpng-manual.txt - A description on how to use and modify libpng
- libpng version 1.6.10 - March 6, 2014
+ libpng version 1.6.15 - November 20, 2014
Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net>
Copyright (c) 1998-2014 Glenn Randers-Pehrson
@@ -515,15 +515,15 @@ libpng-manual.txt - A description on how to use and modify libpng Based on:
- libpng versions 0.97, January 1998, through 1.6.10 - March 6, 2014
+ libpng versions 0.97, January 1998, through 1.6.15 - November 20, 2014
Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2014 Glenn Randers-Pehrson
- libpng 1.0 beta 6 version 0.96 May 28, 1997
+ libpng 1.0 beta 6 - version 0.96 - May 28, 1997
Updated and distributed by Andreas Dilger
Copyright (c) 1996, 1997 Andreas Dilger
- libpng 1.0 beta 2 - version 0.88 January 26, 1996
+ libpng 1.0 beta 2 - version 0.88 - January 26, 1996
For conditions of distribution and use, see copyright
notice in png.h. Copyright (c) 1995, 1996 Guy Eric
Schalnat, Group 42, Inc.
@@ -558,7 +558,7 @@ This file describes how to use and modify the PNG reference library file, example.c is a good starting point for using the library, as
it is heavily commented and should include everything most people
will need. We assume that libpng is already installed; see the
-INSTALL file for instructions on how to install libpng.
+INSTALL file for instructions on how to configure and install libpng.
For examples of libpng usage, see the files "example.c", "pngtest.c",
and the files in the "contrib" directory, all of which are included in
@@ -3140,7 +3140,7 @@ png_infop info_ptr; png_progressive_combine_row(png_ptr, old_row,
new_row);
- /* where old_row is what was displayed for
+ /* where old_row is what was displayed
previously for the row. Note that the first
pass (pass == 0, really) will completely cover
the old row, so the rows do not have to be
@@ -3765,7 +3765,7 @@ tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"), although this isn't a requirement. Unlike the tIME chunk, the
"Creation Time" tEXt chunk is not expected to be automatically changed
by the software. To facilitate the use of RFC 1123 dates, a function
-png_convert_to_rfc1123_buffer(png_ptr, buffer, png_timep) is provided to
+png_convert_to_rfc1123_buffer(buffer, png_timep) is provided to
convert from PNG time to an RFC 1123 format string. The caller must provide
a writeable buffer of at least 29 bytes.
@@ -4297,8 +4297,9 @@ and matches the 8-bit format expected by typical display devices. The color/gray channels are not scaled (pre-multiplied) by the alpha
channel and are suitable for passing to color management software.
- b) As a value in the range 0..65535, contained in a 2-byte integer. All
-channels can be converted to the original value by dividing by 65535; all
+ b) As a value in the range 0..65535, contained in a 2-byte integer, in
+the native byte order of the platform on which the application is running.
+All channels can be converted to the original value by dividing by 65535; all
channels are linear. Color channels use the RGB encoding (RGB end-points) of
the sRGB specification. This encoding is identified by the
PNG_FORMAT_FLAG_LINEAR flag below.
@@ -4365,7 +4366,9 @@ First the single byte formats: Then the linear 2-byte formats. When naming these "Y" is used to
indicate a luminance (gray) channel. The component order within the pixel
is always the same - there is no provision for swapping the order of the
-components in the linear format.
+components in the linear format. The components are 16-bit integers in
+the native byte order for your platform, and there is no provision for
+swapping the bytes to a different endian condition.
PNG_FORMAT_LINEAR_Y PNG_FORMAT_FLAG_LINEAR
PNG_FORMAT_LINEAR_Y_ALPHA
@@ -4430,7 +4433,7 @@ First the information about the samples. *
* png_byte colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(sRGB_fmt)];
*
- * Alternatively use the PNG_IMAGE_COLORMAP_SIZE macro below to use the
+ * Alternatively, use the PNG_IMAGE_COLORMAP_SIZE macro below to use the
* information from one of the png_image_begin_read_ APIs and dynamically
* allocate the required memory.
*/
@@ -4459,9 +4462,16 @@ Information about the whole row, or whole image row. For a color-mapped image this is the minimum number of bytes in a
row.
+ If you need the stride measured in bytes, row_stride_bytes is
+ PNG_IMAGE_ROW_STRIDE(image) * PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)
+ plus any padding bytes that your application might need, for example
+ to start the next row on a 4-byte boundary.
+
PNG_IMAGE_BUFFER_SIZE(image, row_stride)
Returns the size, in bytes, of an image buffer given a png_image and a row
- stride - the number of components to leave space for in each row.
+ stride - the number of components to leave space for in each row. This
+ macro takes care of multiplying row_stride by PNG_IMAGE_PIXEL_COMONENT_SIZE
+ when the image has 2-byte components.
PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB == 0x01
This indicates the the RGB values of the in-memory bitmap do not
@@ -4590,14 +4600,11 @@ clears the newly allocated memory to zero; note that png_calloc(png_ptr, size) is not the same as the calloc(number, size) function provided by stdlib.h.
There is limited support for certain systems with segmented memory
architectures and the types of pointers declared by png.h match this; you
-will have to use appropriate pointers in your application. Since it is
-unlikely that the method of handling memory allocation on a platform
-will change between applications, these functions must be modified in
-the library at compile time. If you prefer to use a different method
-of allocating and freeing data, you can use png_create_read_struct_2() or
-png_create_write_struct_2() to register your own functions as described
-above. These functions also provide a void pointer that can be retrieved
-via
+will have to use appropriate pointers in your application. If you prefer
+to use a different method of allocating and freeing data, you can use
+png_create_read_struct_2() or png_create_write_struct_2() to register your
+own functions as described above. These functions also provide a void
+pointer that can be retrieved via
mem_ptr=png_get_mem_ptr(png_ptr);
@@ -4740,29 +4747,6 @@ the simpler ones to get an idea of how they work. Try to find a similar transformation to the one you want to add and copy off of it. More details
can be found in the comments inside the code itself.
-.SS Configuring for 16-bit platforms
-
-You will want to look into zconf.h to tell zlib (and thus libpng) that
-it cannot allocate more then 64K at a time. Even if you can, the memory
-won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
-
-.SS Configuring for DOS
-
-For DOS users who only have access to the lower 640K, you will
-have to limit zlib's memory usage via a png_set_compression_mem_level()
-call. See zlib.h or zconf.h in the zlib library for more information.
-
-.SS Configuring for Medium Model
-
-Libpng's support for medium model has been tested on most of the popular
-compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets
-defined, and FAR gets defined to far in pngconf.h, and you should be
-all set. Everything in the library (except for zlib's structure) is
-expecting far data. You must use the typedefs with the p or pp on
-the end for pointers (or at least look at them and be careful). Make
-note that the rows of data are defined as png_bytepp, which is
-an "unsigned char far * far *".
-
.SS Configuring for gui/windowing platforms:
You will need to write new error and warning functions that use the GUI
@@ -4772,19 +4756,6 @@ in order to have them available during the structure initialization. They can be changed later via png_set_error_fn(). On some compilers,
you may also have to change the memory allocators (png_malloc, etc.).
-.SS Configuring for compiler xxx:
-
-All includes for libpng are in pngconf.h. If you need to add, change
-or delete an include, this is the place to do it.
-The includes that are not needed outside libpng are placed in pngpriv.h,
-which is only used by the routines inside libpng itself.
-The files in libpng proper only include pngpriv.h and png.h, which
-%14%in turn includes pngconf.h.
-in turn includes pngconf.h and, as of libpng-1.5.0, pnglibconf.h.
-As of libpng-1.5.0, pngpriv.h also includes three other private header
-files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material
-that previously appeared in the public headers.
-
.SS Configuring zlib:
There are special functions to configure the compression. Perhaps the
@@ -4826,6 +4797,8 @@ zlib.h for more information on what these mean. png_set_compression_method(png_ptr, method);
+This controls the size of the IDAT chunks (default 8192):
+
png_set_compression_buffer_size(png_ptr, size);
As of libpng version 1.5.4, additional APIs became
@@ -4924,46 +4897,6 @@ Note that the numbers above were invented purely for this example and are given only to help explain the function usage. Little testing has
been done to find optimum values for either the costs or the weights.
-.SS Removing unwanted object code
-
-There are a bunch of #define's in pngconf.h that control what parts of
-libpng are compiled. All the defines end in _SUPPORTED. If you are
-never going to use a capability, you can change the #define to #undef
-before recompiling libpng and save yourself code and data space, or
-you can turn off individual capabilities with defines that begin with
-PNG_NO_.
-
-In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead.
-
-You can also turn all of the transforms and ancillary chunk capabilities
-off en masse with compiler directives that define
-PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
-or all four,
-along with directives to turn on any of the capabilities that you do
-want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable the extra
-transformations but still leave the library fully capable of reading
-and writing PNG files with all known public chunks. Use of the
-PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a library
-that is incapable of reading or writing ancillary chunks. If you are
-not using the progressive reading capability, you can turn that off
-with PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACING
-capability, which you'll still have).
-
-All the reading and writing specific code are in separate files, so the
-linker should only grab the files it needs. However, if you want to
-make sure, or if you are building a stand alone library, all the
-reading files start with "pngr" and all the writing files start with "pngw".
-The files that don't match either (like png.c, pngtrans.c, etc.)
-are used for both reading and writing, and always need to be included.
-The progressive reader is in pngpread.c
-
-If you are creating or distributing a dynamically linked library (a .so
-or DLL file), you should not remove or disable any parts of the library,
-as this will cause applications linked with different versions of the
-library to fail if they call functions not available in your library.
-The size of the library itself should not be an issue, because only
-those sections that are actually used will be loaded into memory.
-
.SS Requesting debug printout
The macro definition PNG_DEBUG can be used to request debugging
@@ -5001,17 +4934,6 @@ When PNG_DEBUG = 1, the macros are defined, but only png_debug statements having level = 0 will be printed. There aren't any such statements in
this version of libpng, but if you insert some they will be printed.
-.SS Prepending a prefix to exported symbols
-
-Starting with libpng-1.6.0, you can configure libpng (when using the
-"configure" script) to prefix all exported symbols by means of the
-configuration option "\-\-with\-libpng\-prefix=FOO_", where FOO_ can be any
-string beginning with a letter and containing only uppercase
-and lowercase letters, digits, and the underscore (i.e., a C language
-identifier). This creates a set of macros in pnglibconf.h, so this is
-transparent to applications; their function calls get transformed by
-the macros to use the modified names.
-
.SH VII. MNG support
The MNG specification (available at http://www.libpng.org/pub/mng) allows
@@ -5338,8 +5260,6 @@ does not account for any palette index used by ancillary chunks such as the bKGD chunk; you must check those separately to determine the maximum
palette index actually used.
-A. Changes that affect users of libpng
-
There are no substantial API changes between the non-deprecated parts of
the 1.4.5 API and the 1.5.0 API; however, the ability to directly access
members of the main libpng control structures, png_struct and png_info,
@@ -5478,26 +5398,6 @@ limits are now The png_set_option() function (and the "options" member of the png struct) was
added to libpng-1.5.15.
-B. Changes to the build and configuration of libpng
-
-Details of internal changes to the library code can be found in the CHANGES
-file and in the GIT repository logs. These will be of no concern to the vast
-majority of library users or builders; however, the few who configure libpng
-to a non-default feature set may need to change how this is done.
-
-There should be no need for library builders to alter build scripts if
-these use the distributed build support - configure or the makefiles -
-however, users of the makefiles may care to update their build scripts
-to build pnglibconf.h where the corresponding makefile does not do so.
-
-Building libpng with a non-default configuration has changed completely.
-The old method using pngusr.h should still work correctly even though the
-way pngusr.h is used in the build has been changed; however, library
-builders will probably want to examine the changes to take advantage of
-new capabilities and to simplify their build system.
-
-B.1 Specific changes to library configuration capabilities
-
The library now supports a complete fixed point implementation and can
thus be used on systems that have no floating point support or very
limited or slow support. Previously gamma correction, an essential part
@@ -5508,27 +5408,7 @@ independent of the choice of fixed versus floating point APIs and all the missing fixed point APIs have been implemented.
The exact mechanism used to control attributes of API functions has
-changed. A single set of operating system independent macro definitions
-is used and operating system specific directives are defined in
-pnglibconf.h
-
-As part of this the mechanism used to choose procedure call standards on
-those systems that allow a choice has been changed. At present this only
-affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems
-running on Intel processors. As before, PNGAPI is defined where required
-to control the exported API functions; however, two new macros, PNGCBAPI
-and PNGCAPI, are used instead for callback functions (PNGCBAPI) and
-(PNGCAPI) for functions that must match a C library prototype (currently
-only png_longjmp_ptr, which must match the C longjmp function.) The new
-approach is documented in pngconf.h
-
-Despite these changes, libpng 1.5.0 only supports the native C function
-calling standard on those platforms tested so far (__cdecl on Microsoft
-Windows). This is because the support requirements for alternative
-calling conventions seem to no longer exist. Developers who find it
-necessary to set PNG_API_RULE to 1 should advise the mailing list
-(png-mng-implement) of this and library builders who use Openwatcom and
-therefore set PNG_API_RULE to 2 should also contact the mailing list.
+changed, as described in the INSTALL file.
A new test program, pngvalid, is provided in addition to pngtest.
pngvalid validates the arithmetic accuracy of the gamma correction
@@ -5604,46 +5484,6 @@ even though the default is to use the macros - this allows applications to choose at app buildtime whether or not to use macros (previously
impossible because the functions weren't in the default build.)
-B.2 Changes to the configuration mechanism
-
-Prior to libpng-1.5.0 library builders who needed to configure libpng
-had either to modify the exported pngconf.h header file to add system
-specific configuration or had to write feature selection macros into
-pngusr.h and cause this to be included into pngconf.h by defining
-PNG_USER_CONFIG. The latter mechanism had the disadvantage that an
-application built without PNG_USER_CONFIG defined would see the
-unmodified, default, libpng API and thus would probably fail to link.
-
-These mechanisms still work in the configure build and in any makefile
-build that builds pnglibconf.h, although the feature selection macros
-have changed somewhat as described above. In 1.5.0, however, pngusr.h is
-processed only once, when the exported header file pnglibconf.h is built.
-pngconf.h no longer includes pngusr.h, therefore pngusr.h is ignored after the
-build of pnglibconf.h and it is never included in an application build.
-
-The rarely used alternative of adding a list of feature macros to the
-CPPFLAGS setting in the build also still works; however, the macros will be
-copied to pnglibconf.h and this may produce macro redefinition warnings
-when the individual C files are compiled.
-
-All configuration now only works if pnglibconf.h is built from
-scripts/pnglibconf.dfa. This requires the program awk. Brian Kernighan
-(the original author of awk) maintains C source code of that awk and this
-and all known later implementations (often called by subtly different
-names - nawk and gawk for example) are adequate to build pnglibconf.h.
-The Sun Microsystems (now Oracle) program 'awk' is an earlier version
-and does not work; this may also apply to other systems that have a
-functioning awk called 'nawk'.
-
-Configuration options are now documented in scripts/pnglibconf.dfa. This
-file also includes dependency information that ensures a configuration is
-consistent; that is, if a feature is switched off dependent features are
-also removed. As a recommended alternative to using feature macros in
-pngusr.h a system builder may also define equivalent options in pngusr.dfa
-(or, indeed, any file) and add that to the configuration by setting
-DFA_XTRA to the file name. The makefiles in contrib/pngminim illustrate
-how to do this, and a case where pngusr.h is still required.
-
.SH XII. Changes to Libpng from version 1.5.x to 1.6.x
A "simplified API" has been added (see documentation in png.h and a simple
@@ -5702,11 +5542,26 @@ Error detection in some chunks has improved; in particular the iCCP chunk reader now does pretty complete validation of the basic format. Some bad
profiles that were previously accepted are now accepted with a warning or
rejected, depending upon the png_set_benign_errors() setting, in particular the
-very old broken Microsoft/HP 3144-byte sRGB profile. The PNG spec requirement
-that only grayscale profiles may appear in images with color type 0 or 4 and
-that even if the image only contains gray pixels, only RGB profiles may appear
-in images with color type 2, 3, or 6, is now enforced. The sRGB chunk
-is allowed to appear in images with any color type.
+very old broken Microsoft/HP 3144-byte sRGB profile. Starting with
+libpng-1.6.11, recognizing and checking sRGB profiles can be avoided by
+means of
+
+ #if defined(PNG_SKIP_sRGB_CHECK_PROFILE) && \
+ defined(PNG_SET_OPTION_SUPPORTED)
+ png_set_option(png_ptr, PNG_SKIP_sRGB_CHECK_PROFILE,
+ PNG_OPTION_ON);
+ #endif
+
+It's not a good idea to do this if you are using the "simplified API",
+which needs to be able to recognize an sRGB profile conveyed via the iCCP
+chunk.
+
+The PNG spec requirement that only grayscale profiles may appear in images
+with color type 0 or 4 and that even if the image only contains gray pixels,
+only RGB profiles may appear in images with color type 2, 3, or 6, is now
+enforced. The sRGB chunk is allowed to appear in images with any color type
+and is interpreted by libpng to convey a one-tracer-curve gray profile or a
+three-tracer-curve RGB profile as appropriate.
Prior to libpng-1.6.0 a warning would be issued if the iTXt chunk contained
an empty language field or an empty translated keyword. Both of these
@@ -5740,16 +5595,16 @@ Libpng-1.6.0 through 1.6.2 used the CMF bytes at the beginning of the IDAT stream to set the size of the sliding window for reading instead of using the
default 32-kbyte sliding window size. It was discovered that there are
hundreds of PNG files in the wild that have incorrect CMF bytes that caused
-libpng to issue a "too far back" error and reject the file. Libpng-1.6.3 and
-later calculate their own safe CMF from the image dimensions, provide a way
-to revert to the libpng-1.5.x behavior (ignoring the CMF bytes and using a
-32-kbyte sliding window), by using
+zlib to issue the "invalid distance too far back" error and reject the file.
+Libpng-1.6.3 and later calculate their own safe CMF from the image dimensions,
+provide a way to revert to the libpng-1.5.x behavior (ignoring the CMF bytes
+and using a 32-kbyte sliding window), by using
png_set_option(png_ptr, PNG_MAXIMUM_INFLATE_WINDOW,
PNG_OPTION_ON);
-and provide a tool (contrib/tools/pngfix) for optimizing the CMF bytes
-correctly.
+and provide a tool (contrib/tools/pngfix) for rewriting a PNG file while
+optimizing the CMF bytes in its IDAT chunk correctly.
Libpng-1.6.0 and libpng-1.6.1 wrote uncompressed iTXt chunks with the wrong
length, which resulted in PNG files that cannot be read beyond the bad iTXt
@@ -5791,7 +5646,8 @@ mailing list, or directly to glennrp. .SH XV. Coding style
-Our coding style is similar to the "Allman" style, with curly
+Our coding style is similar to the "Allman" style
+(See http://en.wikipedia.org/wiki/Indent_style#Allman_style), with curly
braces on separate lines:
if (condition)
@@ -5871,12 +5727,15 @@ We mark all non-exported functions with "/* PRIVATE */"": }
The prototypes for non-exported functions (except for those in
-pngtest) appear in
-pngpriv.h
-above the comment that says
+pngtest) appear in pngpriv.h above the comment that says
/* Maintainer: Put new private prototypes here ^ */
+To avoid polluting the global namespace, the names of all exported
+functions and variables begin with "png_", and all publicly visible C
+preprocessor macros begin with "PNG". We request that applications that
+use libpng *not* begin any of their own symbols with either of these strings.
+
We put a space after the "sizeof" operator and we omit the
optional parentheses around its argument when the argument
is an expression, not a type name, and we always enclose the
@@ -5888,10 +5747,8 @@ sizeof operator, with its argument, in parentheses: Prior to libpng-1.6.0 we used a "png_sizeof()" macro, formatted as
though it were a function.
-To avoid polluting the global namespace, the names of all exported
-functions and variables begin with "png_", and all publicly visible C
-preprocessor macros begin with "PNG". We request that applications that
-use libpng *not* begin any of their own symbols with either of these strings.
+Control keywords if, for, while, and switch are always followed by a space
+to distinguish them from function calls, which have no trailing space.
We put a space after each comma and after each semicolon
in "for" statements, and we put spaces before and after each
@@ -5913,6 +5770,9 @@ with an even number of lower-case hex digits (e.g., 0x00, 0xff, 0x0100). We prefer to use underscores in variable names rather than camelCase, except
for a few type names that we inherit from zlib.h.
+We prefer "if (something != 0)" and "if (something == 0)"
+over "if (something)" and if "(!something)", respectively.
+
We do not use the TAB character for indentation in the C sources.
Lines do not exceed 80 characters.
@@ -5921,13 +5781,13 @@ Other rules can be inferred by inspecting the libpng source. .SH XVI. Y2K Compliance in libpng
-March 6, 2014
+November 20, 2014
Since the PNG Development group is an ad-hoc body, we can't make
an official declaration.
This is your unofficial assurance that libpng from version 0.71 and
-upward through 1.6.10 are Y2K compliant. It is my belief that earlier
+upward through 1.6.15 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant.
Libpng only has two year fields. One is a 2-byte unsigned integer
@@ -5943,8 +5803,9 @@ in libpng-1.6.x and will be removed from libpng-1.7.0. There are seven time-related functions:
- png_convert_to_rfc_1123() in png.c
- (formerly png_convert_to_rfc_1152() in error)
+ png_convert_to_rfc_1123_buffer() in png.c
+ (formerly png_convert_to_rfc_1152() in error, and
+ also formerly png_convert_to_rfc_1123())
png_convert_from_struct_tm() in pngwrite.c, called
in pngwrite.c
png_convert_from_time_t() in pngwrite.c
@@ -6159,8 +6020,22 @@ the first widely used release: 1.6.9rc01-02 16 10609 16.so.16.9[.0]
1.6.9 16 10609 16.so.16.9[.0]
1.6.10beta01-03 16 10610 16.so.16.10[.0]
- 1.6.10rc01-04 16 10610 16.so.16.10[.0]
+ 1.6.10rc01-03 16 10610 16.so.16.10[.0]
1.6.10 16 10610 16.so.16.10[.0]
+ 1.6.11beta01-06 16 10611 16.so.16.11[.0]
+ 1.6.11rc01-02 16 10611 16.so.16.11[.0]
+ 1.6.11 16 10611 16.so.16.11[.0]
+ 1.6.12rc01 16 10612 16.so.16.12[.0]
+ 1.6.12 16 10612 16.so.16.12[.0]
+ 1.6.13beta01-04 16 10613 16.so.16.13[.0]
+ 1.6.13rc01-02 16 10613 16.so.16.13[.0]
+ 1.6.13 16 10613 16.so.16.13[.0]
+ 1.6.14beta01-07 16 10614 16.so.16.14[.0]
+ 1.6.14rc01-02 16 10614 16.so.16.14[.0]
+ 1.6.14 16 10614 16.so.16.14[.0]
+ 1.6.15beta01-08 16 10615 16.so.16.15[.0]
+ 1.6.15rc01-03 16 10615 16.so.16.15[.0]
+ 1.6.15 16 10615 16.so.16.15[.0]
Henceforth the source version will match the shared-library minor
and patch numbers; the shared-library major version number will be
@@ -6217,7 +6092,7 @@ possible without all of you. Thanks to Frank J. T. Wojcik for helping with the documentation.
-Libpng version 1.6.10 - March 6, 2014:
+Libpng version 1.6.15 - November 20, 2014:
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
@@ -6240,8 +6115,8 @@ this sentence. This code is released under the libpng license.
-libpng versions 1.2.6, August 15, 2004, through 1.6.10, March 6, 2014, are
-Copyright (c) 2004,2006-2007 Glenn Randers-Pehrson, and are
+libpng versions 1.2.6, August 15, 2004, through 1.6.15, November 20, 2014, are
+Copyright (c) 2004,2006-2014 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.2.5
with the following individual added to the list of Contributing Authors
@@ -6339,7 +6214,7 @@ certification mark of the Open Source Initiative. Glenn Randers-Pehrson
glennrp at users.sourceforge.net
-March 6, 2014
+November 20, 2014
.\" end of man page
diff --git a/plugins/AdvaImg/src/LibPNG/libpngpf.3 b/plugins/AdvaImg/src/LibPNG/libpngpf.3 index 62caa67efa..a77a08e20a 100644 --- a/plugins/AdvaImg/src/LibPNG/libpngpf.3 +++ b/plugins/AdvaImg/src/LibPNG/libpngpf.3 @@ -1,6 +1,6 @@ -.TH LIBPNGPF 3 "March 6, 2014"
+.TH LIBPNGPF 3 "November 20, 2014"
.SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.6.10
+libpng \- Portable Network Graphics (PNG) Reference Library 1.6.15
(private functions)
.SH SYNOPSIS
\fB#include \fI"pngpriv.h"
diff --git a/plugins/AdvaImg/src/LibPNG/png.5 b/plugins/AdvaImg/src/LibPNG/png.5 index 23e7c7f907..fa1e46985f 100644 --- a/plugins/AdvaImg/src/LibPNG/png.5 +++ b/plugins/AdvaImg/src/LibPNG/png.5 @@ -1,4 +1,4 @@ -.TH PNG 5 "March 6, 2014"
+.TH PNG 5 "November 20, 2014"
.SH NAME
png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION
diff --git a/plugins/AdvaImg/src/LibPNG/png.c b/plugins/AdvaImg/src/LibPNG/png.c index 7a67bd3026..f0f0f94c5c 100644 --- a/plugins/AdvaImg/src/LibPNG/png.c +++ b/plugins/AdvaImg/src/LibPNG/png.c @@ -1,7 +1,7 @@ /* png.c - location for general purpose libpng functions
*
- * Last changed in libpng 1.6.9 [February 6, 2014]
+ * Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -14,7 +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_10 Your_png_h_is_not_version_1_6_10;
+typedef png_libpng_version_1_6_15 Your_png_h_is_not_version_1_6_15;
/* 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
@@ -65,7 +65,7 @@ png_sig_cmp(png_const_bytep sig, png_size_t start, png_size_t num_to_check) return ((int)(memcmp(&sig[start], &png_signature[start], num_to_check)));
}
-#endif /* PNG_READ_SUPPORTED */
+#endif /* READ */
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
/* Function to allocate memory for zlib */
@@ -115,7 +115,7 @@ png_calculate_crc(png_structrp png_ptr, png_const_bytep ptr, png_size_t length) {
int need_crc = 1;
- if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name))
+ if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) != 0)
{
if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) ==
(PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))
@@ -124,7 +124,7 @@ png_calculate_crc(png_structrp png_ptr, png_const_bytep ptr, png_size_t length) else /* critical */
{
- if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE)
+ if ((png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) != 0)
need_crc = 0;
}
@@ -133,7 +133,7 @@ png_calculate_crc(png_structrp png_ptr, png_const_bytep ptr, png_size_t length) * following cast is safe. 'uInt' may be no more than 16 bits, so it is
* necessary to perform a loop here.
*/
- if (need_crc && length > 0)
+ if (need_crc != 0 && length > 0)
{
uLong crc = png_ptr->crc; /* Should never issue a warning */
@@ -165,53 +165,51 @@ png_calculate_crc(png_structrp png_ptr, png_const_bytep ptr, png_size_t length) int
png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver)
{
- if (user_png_ver)
+ /* Libpng versions 1.0.0 and later are binary compatible if the version
+ * string matches through the second '.'; we must recompile any
+ * applications that use any older library version.
+ */
+
+ if (user_png_ver != NULL)
{
- int i = 0;
+ int i = -1;
+ int found_dots = 0;
do
{
- if (user_png_ver[i] != png_libpng_ver[i])
+ i++;
+ if (user_png_ver[i] != PNG_LIBPNG_VER_STRING[i])
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
- } while (png_libpng_ver[i++]);
+ if (user_png_ver[i] == '.')
+ found_dots++;
+ } while (found_dots < 2 && user_png_ver[i] != 0 &&
+ PNG_LIBPNG_VER_STRING[i] != 0);
}
else
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
- if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
+ if ((png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) != 0)
{
- /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so
- * we must recompile any applications that use any older library version.
- * For versions after libpng 1.0, we will be compatible, so we need
- * only check the first and third digits (note that when we reach version
- * 1.10 we will need to check the fourth symbol, namely user_png_ver[3]).
- */
- if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
- (user_png_ver[0] == '1' && (user_png_ver[2] != png_libpng_ver[2] ||
- user_png_ver[3] != png_libpng_ver[3])) ||
- (user_png_ver[0] == '0' && user_png_ver[2] < '9'))
- {
#ifdef PNG_WARNINGS_SUPPORTED
- size_t pos = 0;
- char m[128];
+ size_t pos = 0;
+ char m[128];
- pos = png_safecat(m, (sizeof m), pos,
- "Application built with libpng-");
- pos = png_safecat(m, (sizeof m), pos, user_png_ver);
- pos = png_safecat(m, (sizeof m), pos, " but running with ");
- pos = png_safecat(m, (sizeof m), pos, png_libpng_ver);
- PNG_UNUSED(pos)
+ pos = png_safecat(m, (sizeof m), pos,
+ "Application built with libpng-");
+ pos = png_safecat(m, (sizeof m), pos, user_png_ver);
+ pos = png_safecat(m, (sizeof m), pos, " but running with ");
+ pos = png_safecat(m, (sizeof m), pos, PNG_LIBPNG_VER_STRING);
+ PNG_UNUSED(pos)
- png_warning(png_ptr, m);
+ png_warning(png_ptr, m);
#endif
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
- png_ptr->flags = 0;
+ png_ptr->flags = 0;
#endif
- return 0;
- }
+ return 0;
}
/* Success return. */
@@ -289,7 +287,7 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr, # endif
/* Call the general version checker (shared with read and write code):
*/
- if (png_user_version_check(&create_struct, user_png_ver))
+ if (png_user_version_check(&create_struct, user_png_ver) != 0)
{
png_structrp png_ptr = png_voidcast(png_structrp,
png_malloc_warn(&create_struct, (sizeof *png_ptr)));
@@ -451,32 +449,32 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, #ifdef PNG_TEXT_SUPPORTED
/* Free text item num or (if num == -1) all text items */
- if ((mask & PNG_FREE_TEXT) & info_ptr->free_me)
+ if (info_ptr->text != 0 &&
+ ((mask & PNG_FREE_TEXT) & info_ptr->free_me) != 0)
{
if (num != -1)
{
- if (info_ptr->text && info_ptr->text[num].key)
- {
- png_free(png_ptr, info_ptr->text[num].key);
- info_ptr->text[num].key = NULL;
- }
+ png_free(png_ptr, info_ptr->text[num].key);
+ info_ptr->text[num].key = NULL;
}
else
{
int i;
+
for (i = 0; i < info_ptr->num_text; i++)
- png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i);
+ png_free(png_ptr, info_ptr->text[i].key);
+
png_free(png_ptr, info_ptr->text);
info_ptr->text = NULL;
- info_ptr->num_text=0;
+ info_ptr->num_text = 0;
}
}
#endif
#ifdef PNG_tRNS_SUPPORTED
/* Free any tRNS entry */
- if ((mask & PNG_FREE_TRNS) & info_ptr->free_me)
+ if (((mask & PNG_FREE_TRNS) & info_ptr->free_me) != 0)
{
png_free(png_ptr, info_ptr->trans_alpha);
info_ptr->trans_alpha = NULL;
@@ -486,7 +484,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, #ifdef PNG_sCAL_SUPPORTED
/* Free any sCAL entry */
- if ((mask & PNG_FREE_SCAL) & info_ptr->free_me)
+ if (((mask & PNG_FREE_SCAL) & info_ptr->free_me) != 0)
{
png_free(png_ptr, info_ptr->scal_s_width);
png_free(png_ptr, info_ptr->scal_s_height);
@@ -498,20 +496,20 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, #ifdef PNG_pCAL_SUPPORTED
/* Free any pCAL entry */
- if ((mask & PNG_FREE_PCAL) & info_ptr->free_me)
+ if (((mask & PNG_FREE_PCAL) & info_ptr->free_me) != 0)
{
png_free(png_ptr, info_ptr->pcal_purpose);
png_free(png_ptr, info_ptr->pcal_units);
info_ptr->pcal_purpose = NULL;
info_ptr->pcal_units = NULL;
+
if (info_ptr->pcal_params != NULL)
{
- unsigned int i;
+ int i;
+
for (i = 0; i < info_ptr->pcal_nparams; i++)
- {
png_free(png_ptr, info_ptr->pcal_params[i]);
- info_ptr->pcal_params[i] = NULL;
- }
+
png_free(png_ptr, info_ptr->pcal_params);
info_ptr->pcal_params = NULL;
}
@@ -521,7 +519,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, #ifdef PNG_iCCP_SUPPORTED
/* Free any profile entry */
- if ((mask & PNG_FREE_ICCP) & info_ptr->free_me)
+ if (((mask & PNG_FREE_ICCP) & info_ptr->free_me) != 0)
{
png_free(png_ptr, info_ptr->iccp_name);
png_free(png_ptr, info_ptr->iccp_profile);
@@ -533,26 +531,28 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, #ifdef PNG_sPLT_SUPPORTED
/* Free a given sPLT entry, or (if num == -1) all sPLT entries */
- if ((mask & PNG_FREE_SPLT) & info_ptr->free_me)
+ if (info_ptr->splt_palettes != 0 &&
+ ((mask & PNG_FREE_SPLT) & info_ptr->free_me) != 0)
{
if (num != -1)
{
- if (info_ptr->splt_palettes)
- {
- png_free(png_ptr, info_ptr->splt_palettes[num].name);
- png_free(png_ptr, info_ptr->splt_palettes[num].entries);
- info_ptr->splt_palettes[num].name = NULL;
- info_ptr->splt_palettes[num].entries = NULL;
- }
+ png_free(png_ptr, info_ptr->splt_palettes[num].name);
+ png_free(png_ptr, info_ptr->splt_palettes[num].entries);
+ info_ptr->splt_palettes[num].name = NULL;
+ info_ptr->splt_palettes[num].entries = NULL;
}
else
{
- if (info_ptr->splt_palettes_num)
+ if (info_ptr->splt_palettes_num != 0)
{
int i;
+
for (i = 0; i < info_ptr->splt_palettes_num; i++)
- png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, (int)i);
+ {
+ png_free(png_ptr, info_ptr->splt_palettes[i].name);
+ png_free(png_ptr, info_ptr->splt_palettes[i].entries);
+ }
png_free(png_ptr, info_ptr->splt_palettes);
info_ptr->splt_palettes = NULL;
@@ -564,25 +564,23 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, #endif
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
- if ((mask & PNG_FREE_UNKN) & info_ptr->free_me)
+ if (info_ptr->unknown_chunks != 0 &&
+ ((mask & PNG_FREE_UNKN) & info_ptr->free_me) != 0)
{
if (num != -1)
{
- if (info_ptr->unknown_chunks)
- {
- png_free(png_ptr, info_ptr->unknown_chunks[num].data);
- info_ptr->unknown_chunks[num].data = NULL;
- }
+ png_free(png_ptr, info_ptr->unknown_chunks[num].data);
+ info_ptr->unknown_chunks[num].data = NULL;
}
else
{
int i;
- if (info_ptr->unknown_chunks_num)
+ if (info_ptr->unknown_chunks_num != 0)
{
for (i = 0; i < info_ptr->unknown_chunks_num; i++)
- png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, (int)i);
+ png_free(png_ptr, info_ptr->unknown_chunks[i].data);
png_free(png_ptr, info_ptr->unknown_chunks);
info_ptr->unknown_chunks = NULL;
@@ -594,7 +592,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, #ifdef PNG_hIST_SUPPORTED
/* Free any hIST entry */
- if ((mask & PNG_FREE_HIST) & info_ptr->free_me)
+ if (((mask & PNG_FREE_HIST) & info_ptr->free_me) != 0)
{
png_free(png_ptr, info_ptr->hist);
info_ptr->hist = NULL;
@@ -603,7 +601,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, #endif
/* Free any PLTE entry that was internally allocated */
- if ((mask & PNG_FREE_PLTE) & info_ptr->free_me)
+ if (((mask & PNG_FREE_PLTE) & info_ptr->free_me) != 0)
{
png_free(png_ptr, info_ptr->palette);
info_ptr->palette = NULL;
@@ -613,16 +611,14 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, #ifdef PNG_INFO_IMAGE_SUPPORTED
/* Free any image bits attached to the info structure */
- if ((mask & PNG_FREE_ROWS) & info_ptr->free_me)
+ if (((mask & PNG_FREE_ROWS) & info_ptr->free_me) != 0)
{
- if (info_ptr->row_pointers)
+ if (info_ptr->row_pointers != 0)
{
png_uint_32 row;
for (row = 0; row < info_ptr->height; row++)
- {
png_free(png_ptr, info_ptr->row_pointers[row]);
- info_ptr->row_pointers[row] = NULL;
- }
+
png_free(png_ptr, info_ptr->row_pointers);
info_ptr->row_pointers = NULL;
}
@@ -635,7 +631,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, info_ptr->free_me &= ~mask;
}
-#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
+#endif /* READ || WRITE */
/* This function returns a pointer to the io_ptr associated with the user
* functions. The application should free any memory associated with this
@@ -750,7 +746,7 @@ png_convert_to_rfc1123(png_structrp png_ptr, png_const_timep ptime) if (png_ptr != NULL)
{
/* The only failure above if png_ptr != NULL is from an invalid ptime */
- if (!png_convert_to_rfc1123_buffer(png_ptr->time_buffer, ptime))
+ if (png_convert_to_rfc1123_buffer(png_ptr->time_buffer, ptime) == 0)
png_warning(png_ptr, "Ignoring invalid time value");
else
@@ -760,9 +756,9 @@ png_convert_to_rfc1123(png_structrp png_ptr, png_const_timep ptime) return NULL;
}
# endif
-# endif /* PNG_TIME_RFC1123_SUPPORTED */
+# endif /* TIME_RFC1123 */
-#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
+#endif /* READ || WRITE */
png_const_charp PNGAPI
png_get_copyright(png_const_structrp png_ptr)
@@ -773,13 +769,13 @@ png_get_copyright(png_const_structrp png_ptr) #else
# ifdef __STDC__
return PNG_STRING_NEWLINE \
- "libpng version 1.6.10 - March 6, 2014" PNG_STRING_NEWLINE \
+ "libpng version 1.6.15 - November 20, 2014" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2014 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE;
# else
- return "libpng version 1.6.10 - March 6, 2014\
+ return "libpng version 1.6.15 - November 20, 2014\
Copyright (c) 1998-2014 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
@@ -904,7 +900,7 @@ png_handle_as_unknown(png_const_structrp png_ptr, png_const_bytep chunk_name) {
p -= 5;
- if (!memcmp(chunk_name, p, 4))
+ if (memcmp(chunk_name, p, 4) == 0)
return p[4];
}
while (p > p_end);
@@ -941,7 +937,7 @@ png_reset_zstream(png_structrp png_ptr) /* WARNING: this resets the window bits to the maximum! */
return (inflateReset(&png_ptr->zstream));
}
-#endif /* PNG_READ_SUPPORTED */
+#endif /* READ */
/* This function was added to libpng-1.0.7 */
png_uint_32 PNGAPI
@@ -1046,8 +1042,8 @@ png_colorspace_check_gamma(png_const_structrp png_ptr, png_fixed_point gtest;
if ((colorspace->flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
- (!png_muldiv(>est, colorspace->gamma, PNG_FP_1, gAMA) ||
- png_gamma_significant(gtest)))
+ (png_muldiv(>est, colorspace->gamma, PNG_FP_1, gAMA) == 0 ||
+ png_gamma_significant(gtest) != 0))
{
/* Either this is an sRGB image, in which case the calculated gamma
* approximation should match, or this is an image with a profile and the
@@ -1102,12 +1098,13 @@ png_colorspace_set_gamma(png_const_structrp png_ptr, # endif
/* Do nothing if the colorspace is already invalid */
- else if (colorspace->flags & PNG_COLORSPACE_INVALID)
+ else if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
return;
else
{
- if (png_colorspace_check_gamma(png_ptr, colorspace, gAMA, 1/*from gAMA*/))
+ if (png_colorspace_check_gamma(png_ptr, colorspace, gAMA,
+ 1/*from gAMA*/) != 0)
{
/* Store this gamma value. */
colorspace->gamma = gAMA;
@@ -1131,7 +1128,7 @@ png_colorspace_set_gamma(png_const_structrp png_ptr, void /* PRIVATE */
png_colorspace_sync_info(png_const_structrp png_ptr, png_inforp info_ptr)
{
- if (info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID)
+ if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) != 0)
{
/* Everything is invalid */
info_ptr->valid &= ~(PNG_INFO_gAMA|PNG_INFO_cHRM|PNG_INFO_sRGB|
@@ -1152,20 +1149,20 @@ png_colorspace_sync_info(png_const_structrp png_ptr, png_inforp info_ptr) * it; this allows a PNG to contain a profile which matches sRGB and
* yet still have that profile retrievable by the application.
*/
- if (info_ptr->colorspace.flags & PNG_COLORSPACE_MATCHES_sRGB)
+ if ((info_ptr->colorspace.flags & PNG_COLORSPACE_MATCHES_sRGB) != 0)
info_ptr->valid |= PNG_INFO_sRGB;
else
info_ptr->valid &= ~PNG_INFO_sRGB;
- if (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)
+ if ((info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
info_ptr->valid |= PNG_INFO_cHRM;
else
info_ptr->valid &= ~PNG_INFO_cHRM;
# endif
- if (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA)
+ if ((info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0)
info_ptr->valid |= PNG_INFO_gAMA;
else
@@ -1198,22 +1195,28 @@ png_xy_from_XYZ(png_xy *xy, const png_XYZ *XYZ) png_int_32 d, dwhite, whiteX, whiteY;
d = XYZ->red_X + XYZ->red_Y + XYZ->red_Z;
- if (!png_muldiv(&xy->redx, XYZ->red_X, PNG_FP_1, d)) return 1;
- if (!png_muldiv(&xy->redy, XYZ->red_Y, PNG_FP_1, d)) return 1;
+ if (png_muldiv(&xy->redx, XYZ->red_X, PNG_FP_1, d) == 0)
+ return 1;
+ if (png_muldiv(&xy->redy, XYZ->red_Y, PNG_FP_1, d) == 0)
+ return 1;
dwhite = d;
whiteX = XYZ->red_X;
whiteY = XYZ->red_Y;
d = XYZ->green_X + XYZ->green_Y + XYZ->green_Z;
- if (!png_muldiv(&xy->greenx, XYZ->green_X, PNG_FP_1, d)) return 1;
- if (!png_muldiv(&xy->greeny, XYZ->green_Y, PNG_FP_1, d)) return 1;
+ if (png_muldiv(&xy->greenx, XYZ->green_X, PNG_FP_1, d) == 0)
+ return 1;
+ if (png_muldiv(&xy->greeny, XYZ->green_Y, PNG_FP_1, d) == 0)
+ return 1;
dwhite += d;
whiteX += XYZ->green_X;
whiteY += XYZ->green_Y;
d = XYZ->blue_X + XYZ->blue_Y + XYZ->blue_Z;
- if (!png_muldiv(&xy->bluex, XYZ->blue_X, PNG_FP_1, d)) return 1;
- if (!png_muldiv(&xy->bluey, XYZ->blue_Y, PNG_FP_1, d)) return 1;
+ if (png_muldiv(&xy->bluex, XYZ->blue_X, PNG_FP_1, d) == 0)
+ return 1;
+ if (png_muldiv(&xy->bluey, XYZ->blue_Y, PNG_FP_1, d) == 0)
+ return 1;
dwhite += d;
whiteX += XYZ->blue_X;
whiteY += XYZ->blue_Y;
@@ -1221,8 +1224,10 @@ png_xy_from_XYZ(png_xy *xy, const png_XYZ *XYZ) /* The reference white is simply the sum of the end-point (X,Y,Z) vectors,
* thus:
*/
- if (!png_muldiv(&xy->whitex, whiteX, PNG_FP_1, dwhite)) return 1;
- if (!png_muldiv(&xy->whitey, whiteY, PNG_FP_1, dwhite)) return 1;
+ if (png_muldiv(&xy->whitex, whiteX, PNG_FP_1, dwhite) == 0)
+ return 1;
+ if (png_muldiv(&xy->whitey, whiteY, PNG_FP_1, dwhite) == 0)
+ return 1;
return 0;
}
@@ -1425,16 +1430,16 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy) /* By the argument, above overflow should be impossible here. The return
* value of 2 indicates an internal error to the caller.
*/
- if (!png_muldiv(&left, xy->greenx-xy->bluex, xy->redy - xy->bluey, 7))
+ if (png_muldiv(&left, xy->greenx-xy->bluex, xy->redy - xy->bluey, 7) == 0)
return 2;
- if (!png_muldiv(&right, xy->greeny-xy->bluey, xy->redx - xy->bluex, 7))
+ if (png_muldiv(&right, xy->greeny-xy->bluey, xy->redx - xy->bluex, 7) == 0)
return 2;
denominator = left - right;
/* Now find the red numerator. */
- if (!png_muldiv(&left, xy->greenx-xy->bluex, xy->whitey-xy->bluey, 7))
+ if (png_muldiv(&left, xy->greenx-xy->bluex, xy->whitey-xy->bluey, 7) == 0)
return 2;
- if (!png_muldiv(&right, xy->greeny-xy->bluey, xy->whitex-xy->bluex, 7))
+ if (png_muldiv(&right, xy->greeny-xy->bluey, xy->whitex-xy->bluex, 7) == 0)
return 2;
/* Overflow is possible here and it indicates an extreme set of PNG cHRM
@@ -1442,16 +1447,16 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy) * scale value because this allows us to delay the multiplication of white-y
* into the denominator, which tends to produce a small number.
*/
- if (!png_muldiv(&red_inverse, xy->whitey, denominator, left-right) ||
+ if (png_muldiv(&red_inverse, xy->whitey, denominator, left-right) == 0 ||
red_inverse <= xy->whitey /* r+g+b scales = white scale */)
return 1;
/* Similarly for green_inverse: */
- if (!png_muldiv(&left, xy->redy-xy->bluey, xy->whitex-xy->bluex, 7))
+ if (png_muldiv(&left, xy->redy-xy->bluey, xy->whitex-xy->bluex, 7) == 0)
return 2;
- if (!png_muldiv(&right, xy->redx-xy->bluex, xy->whitey-xy->bluey, 7))
+ if (png_muldiv(&right, xy->redx-xy->bluex, xy->whitey-xy->bluey, 7) == 0)
return 2;
- if (!png_muldiv(&green_inverse, xy->whitey, denominator, left-right) ||
+ if (png_muldiv(&green_inverse, xy->whitey, denominator, left-right) == 0 ||
green_inverse <= xy->whitey)
return 1;
@@ -1459,29 +1464,34 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy) * can still produce 0 for extreme cHRM values.
*/
blue_scale = png_reciprocal(xy->whitey) - png_reciprocal(red_inverse) -
- png_reciprocal(green_inverse);
- if (blue_scale <= 0) return 1;
+ png_reciprocal(green_inverse);
+ if (blue_scale <= 0)
+ return 1;
/* And fill in the png_XYZ: */
- if (!png_muldiv(&XYZ->red_X, xy->redx, PNG_FP_1, red_inverse)) return 1;
- if (!png_muldiv(&XYZ->red_Y, xy->redy, PNG_FP_1, red_inverse)) return 1;
- if (!png_muldiv(&XYZ->red_Z, PNG_FP_1 - xy->redx - xy->redy, PNG_FP_1,
- red_inverse))
+ if (png_muldiv(&XYZ->red_X, xy->redx, PNG_FP_1, red_inverse) == 0)
+ return 1;
+ if (png_muldiv(&XYZ->red_Y, xy->redy, PNG_FP_1, red_inverse) == 0)
+ return 1;
+ if (png_muldiv(&XYZ->red_Z, PNG_FP_1 - xy->redx - xy->redy, PNG_FP_1,
+ red_inverse) == 0)
return 1;
- if (!png_muldiv(&XYZ->green_X, xy->greenx, PNG_FP_1, green_inverse))
+ if (png_muldiv(&XYZ->green_X, xy->greenx, PNG_FP_1, green_inverse) == 0)
return 1;
- if (!png_muldiv(&XYZ->green_Y, xy->greeny, PNG_FP_1, green_inverse))
+ if (png_muldiv(&XYZ->green_Y, xy->greeny, PNG_FP_1, green_inverse) == 0)
return 1;
- if (!png_muldiv(&XYZ->green_Z, PNG_FP_1 - xy->greenx - xy->greeny, PNG_FP_1,
- green_inverse))
+ if (png_muldiv(&XYZ->green_Z, PNG_FP_1 - xy->greenx - xy->greeny, PNG_FP_1,
+ green_inverse) == 0)
return 1;
- if (!png_muldiv(&XYZ->blue_X, xy->bluex, blue_scale, PNG_FP_1)) return 1;
- if (!png_muldiv(&XYZ->blue_Y, xy->bluey, blue_scale, PNG_FP_1)) return 1;
- if (!png_muldiv(&XYZ->blue_Z, PNG_FP_1 - xy->bluex - xy->bluey, blue_scale,
- PNG_FP_1))
+ if (png_muldiv(&XYZ->blue_X, xy->bluex, blue_scale, PNG_FP_1) == 0)
+ return 1;
+ if (png_muldiv(&XYZ->blue_Y, xy->bluey, blue_scale, PNG_FP_1) == 0)
+ return 1;
+ if (png_muldiv(&XYZ->blue_Z, PNG_FP_1 - xy->bluex - xy->bluey, blue_scale,
+ PNG_FP_1) == 0)
return 1;
return 0; /*success*/
@@ -1503,24 +1513,35 @@ png_XYZ_normalize(png_XYZ *XYZ) * safe.
*/
Y = XYZ->red_Y;
- if (0x7fffffff - Y < XYZ->green_X) return 1;
+ if (0x7fffffff - Y < XYZ->green_X)
+ return 1;
Y += XYZ->green_Y;
- if (0x7fffffff - Y < XYZ->blue_X) return 1;
+ if (0x7fffffff - Y < XYZ->blue_X)
+ return 1;
Y += XYZ->blue_Y;
if (Y != PNG_FP_1)
{
- if (!png_muldiv(&XYZ->red_X, XYZ->red_X, PNG_FP_1, Y)) return 1;
- if (!png_muldiv(&XYZ->red_Y, XYZ->red_Y, PNG_FP_1, Y)) return 1;
- if (!png_muldiv(&XYZ->red_Z, XYZ->red_Z, PNG_FP_1, Y)) return 1;
+ if (png_muldiv(&XYZ->red_X, XYZ->red_X, PNG_FP_1, Y) == 0)
+ return 1;
+ if (png_muldiv(&XYZ->red_Y, XYZ->red_Y, PNG_FP_1, Y) == 0)
+ return 1;
+ if (png_muldiv(&XYZ->red_Z, XYZ->red_Z, PNG_FP_1, Y) == 0)
+ return 1;
- if (!png_muldiv(&XYZ->green_X, XYZ->green_X, PNG_FP_1, Y)) return 1;
- if (!png_muldiv(&XYZ->green_Y, XYZ->green_Y, PNG_FP_1, Y)) return 1;
- if (!png_muldiv(&XYZ->green_Z, XYZ->green_Z, PNG_FP_1, Y)) return 1;
+ if (png_muldiv(&XYZ->green_X, XYZ->green_X, PNG_FP_1, Y) == 0)
+ return 1;
+ if (png_muldiv(&XYZ->green_Y, XYZ->green_Y, PNG_FP_1, Y) == 0)
+ return 1;
+ if (png_muldiv(&XYZ->green_Z, XYZ->green_Z, PNG_FP_1, Y) == 0)
+ return 1;
- if (!png_muldiv(&XYZ->blue_X, XYZ->blue_X, PNG_FP_1, Y)) return 1;
- if (!png_muldiv(&XYZ->blue_Y, XYZ->blue_Y, PNG_FP_1, Y)) return 1;
- if (!png_muldiv(&XYZ->blue_Z, XYZ->blue_Z, PNG_FP_1, Y)) return 1;
+ if (png_muldiv(&XYZ->blue_X, XYZ->blue_X, PNG_FP_1, Y) == 0)
+ return 1;
+ if (png_muldiv(&XYZ->blue_Y, XYZ->blue_Y, PNG_FP_1, Y) == 0)
+ return 1;
+ if (png_muldiv(&XYZ->blue_Z, XYZ->blue_Z, PNG_FP_1, Y) == 0)
+ return 1;
}
return 0;
@@ -1530,14 +1551,16 @@ static int png_colorspace_endpoints_match(const png_xy *xy1, const png_xy *xy2, int delta)
{
/* Allow an error of +/-0.01 (absolute value) on each chromaticity */
- return !(PNG_OUT_OF_RANGE(xy1->whitex, xy2->whitex,delta) ||
- PNG_OUT_OF_RANGE(xy1->whitey, xy2->whitey,delta) ||
- PNG_OUT_OF_RANGE(xy1->redx, xy2->redx, delta) ||
- PNG_OUT_OF_RANGE(xy1->redy, xy2->redy, delta) ||
- PNG_OUT_OF_RANGE(xy1->greenx, xy2->greenx,delta) ||
- PNG_OUT_OF_RANGE(xy1->greeny, xy2->greeny,delta) ||
- PNG_OUT_OF_RANGE(xy1->bluex, xy2->bluex, delta) ||
- PNG_OUT_OF_RANGE(xy1->bluey, xy2->bluey, delta));
+ if (PNG_OUT_OF_RANGE(xy1->whitex, xy2->whitex,delta) ||
+ PNG_OUT_OF_RANGE(xy1->whitey, xy2->whitey,delta) ||
+ PNG_OUT_OF_RANGE(xy1->redx, xy2->redx, delta) ||
+ PNG_OUT_OF_RANGE(xy1->redy, xy2->redy, delta) ||
+ PNG_OUT_OF_RANGE(xy1->greenx, xy2->greenx,delta) ||
+ PNG_OUT_OF_RANGE(xy1->greeny, xy2->greeny,delta) ||
+ PNG_OUT_OF_RANGE(xy1->bluex, xy2->bluex, delta) ||
+ PNG_OUT_OF_RANGE(xy1->bluey, xy2->bluey, delta))
+ return 0;
+ return 1;
}
/* Added in libpng-1.6.0, a different check for the validity of a set of cHRM
@@ -1558,13 +1581,15 @@ png_colorspace_check_xy(png_XYZ *XYZ, const png_xy *xy) /* As a side-effect this routine also returns the XYZ endpoints. */
result = png_XYZ_from_xy(XYZ, xy);
- if (result) return result;
+ if (result != 0)
+ return result;
result = png_xy_from_XYZ(&xy_test, XYZ);
- if (result) return result;
+ if (result != 0)
+ return result;
if (png_colorspace_endpoints_match(xy, &xy_test,
- 5/*actually, the math is pretty accurate*/))
+ 5/*actually, the math is pretty accurate*/) != 0)
return 0;
/* Too much slip */
@@ -1581,10 +1606,12 @@ png_colorspace_check_XYZ(png_xy *xy, png_XYZ *XYZ) png_XYZ XYZtemp;
result = png_XYZ_normalize(XYZ);
- if (result) return result;
+ if (result != 0)
+ return result;
result = png_xy_from_XYZ(xy, XYZ);
- if (result) return result;
+ if (result != 0)
+ return result;
XYZtemp = *XYZ;
return png_colorspace_check_xy(&XYZtemp, xy);
@@ -1605,19 +1632,21 @@ png_colorspace_set_xy_and_XYZ(png_const_structrp png_ptr, png_colorspacerp colorspace, const png_xy *xy, const png_XYZ *XYZ,
int preferred)
{
- if (colorspace->flags & PNG_COLORSPACE_INVALID)
+ if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
return 0;
/* The consistency check is performed on the chromaticities; this factors out
* variations because of the normalization (or not) of the end point Y
* values.
*/
- if (preferred < 2 && (colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
+ if (preferred < 2 &&
+ (colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
{
/* The end points must be reasonably close to any we already have. The
* following allows an error of up to +/-.001
*/
- if (!png_colorspace_endpoints_match(xy, &colorspace->end_points_xy, 100))
+ if (png_colorspace_endpoints_match(xy, &colorspace->end_points_xy,
+ 100) == 0)
{
colorspace->flags |= PNG_COLORSPACE_INVALID;
png_benign_error(png_ptr, "inconsistent chromaticities");
@@ -1625,7 +1654,7 @@ png_colorspace_set_xy_and_XYZ(png_const_structrp png_ptr, }
/* Only overwrite with preferred values */
- if (!preferred)
+ if (preferred == 0)
return 1; /* ok, but no change */
}
@@ -1636,7 +1665,7 @@ png_colorspace_set_xy_and_XYZ(png_const_structrp png_ptr, /* The end points are normally quoted to two decimal digits, so allow +/-0.01
* on this test.
*/
- if (png_colorspace_endpoints_match(xy, &sRGB_xy, 1000))
+ if (png_colorspace_endpoints_match(xy, &sRGB_xy, 1000) != 0)
colorspace->flags |= PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB;
else
@@ -1764,7 +1793,7 @@ png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace, pos = png_safecat(message, (sizeof message), 0, "profile '"); /* 9 chars */
pos = png_safecat(message, pos+79, pos, name); /* Truncate to 79 chars */
pos = png_safecat(message, (sizeof message), pos, "': "); /* +2 = 90 */
- if (is_ICC_signature(value))
+ if (is_ICC_signature(value) != 0)
{
/* So 'value' is at most 4 bytes and the following cast is safe */
png_icc_tag_name(message+pos, (png_uint_32)value);
@@ -1825,7 +1854,7 @@ png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace, };
/* Do nothing if the colorspace is already invalidated. */
- if (colorspace->flags & PNG_COLORSPACE_INVALID)
+ if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
return 0;
/* Check the intent, then check for existing settings. It is valid for the
@@ -1906,10 +1935,6 @@ png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace, return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
"too short");
- if (profile_length & 3)
- return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
- "invalid length");
-
return 1;
}
@@ -1930,6 +1955,11 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, return png_icc_profile_error(png_ptr, colorspace, name, temp,
"length does not match profile");
+ temp = (png_uint_32) (*(profile+8));
+ if (temp > 3 && (profile_length & 3))
+ return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
+ "invalid length");
+
temp = png_get_uint_32(profile+128); /* tag count: 12 bytes/tag */
if (temp > 357913930 || /* (2^32-4-132)/12: maximum possible tag count */
profile_length < 132+12*temp) /* truncated tag table */
@@ -2003,13 +2033,13 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, switch (temp)
{
case 0x52474220: /* 'RGB ' */
- if (!(color_type & PNG_COLOR_MASK_COLOR))
+ if ((color_type & PNG_COLOR_MASK_COLOR) == 0)
return png_icc_profile_error(png_ptr, colorspace, name, temp,
"RGB color space not permitted on grayscale PNG");
break;
case 0x47524159: /* 'GRAY' */
- if (color_type & PNG_COLOR_MASK_COLOR)
+ if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
return png_icc_profile_error(png_ptr, colorspace, name, temp,
"Gray color space not permitted on RGB PNG");
break;
@@ -2044,7 +2074,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, "invalid embedded Abstract ICC profile");
case 0x6C696E6B: /* 'link' */
- /* DeviceLink profiles cannnot be interpreted in a non-device specific
+ /* DeviceLink profiles cannot be interpreted in a non-device specific
* fashion, if an app uses the AToB0Tag in the profile the results are
* undefined unless the result is sent to the intended device,
* therefore a DeviceLink profile should not be found embedded in a
@@ -2055,7 +2085,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, case 0x6E6D636C: /* 'nmcl' */
/* A NamedColor profile is also device specific, however it doesn't
- * contain an AToB0 tag that is open to misintrepretation. Almost
+ * contain an AToB0 tag that is open to misinterpretation. Almost
* certainly it will fail the tests below.
*/
(void)png_icc_profile_error(png_ptr, NULL, name, temp,
@@ -2136,7 +2166,7 @@ png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace, return 1; /* success, maybe with warnings */
}
-#ifdef PNG_sRGB_SUPPORTED
+#if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0
/* Information about the known ICC sRGB profiles */
static const struct
{
@@ -2210,6 +2240,7 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr, * by sRGB (but maybe defined by a later ICC specification) the read of
* the profile will fail at that point.
*/
+
png_uint_32 length = 0;
png_uint_32 intent = 0x10000; /* invalid */
#if PNG_sRGB_PROFILE_CHECKS > 1
@@ -2217,6 +2248,13 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr, #endif
unsigned int i;
+#ifdef PNG_SET_OPTION_SUPPORTED
+ /* First see if PNG_SKIP_sRGB_CHECK_PROFILE has been set to "on" */
+ if (((png_ptr->options >> PNG_SKIP_sRGB_CHECK_PROFILE) & 3) ==
+ PNG_OPTION_ON)
+ return 0;
+#endif
+
for (i=0; i < (sizeof png_sRGB_checks) / (sizeof png_sRGB_checks[0]); ++i)
{
if (png_get_uint_32(profile+84) == png_sRGB_checks[i].md5[0] &&
@@ -2229,7 +2267,7 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr, * are not used by default if there is an MD5!)
*/
# if PNG_sRGB_PROFILE_CHECKS == 0
- if (png_sRGB_checks[i].have_md5)
+ if (png_sRGB_checks[i].have_md5 != 0)
return 1+png_sRGB_checks[i].is_broken;
# endif
@@ -2269,7 +2307,7 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr, if (crc == png_sRGB_checks[i].crc)
# endif
{
- if (png_sRGB_checks[i].is_broken)
+ if (png_sRGB_checks[i].is_broken != 0)
{
/* These profiles are known to have bad data that may cause
* problems if they are used, therefore attempt to
@@ -2284,28 +2322,28 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr, * the profile is perfectly valid, but it would be nice if
* people used the up-to-date ones.
*/
- else if (!png_sRGB_checks[i].have_md5)
+ else if (png_sRGB_checks[i].have_md5 == 0)
{
- png_chunk_report(png_ptr,
- "out-of-date sRGB profile with no signature",
+ png_chunk_report(png_ptr, "out-of-date sRGB profile with"
+ " no signature",
PNG_CHUNK_WARNING);
}
return 1+png_sRGB_checks[i].is_broken;
}
}
- }
# if PNG_sRGB_PROFILE_CHECKS > 0
/* The signature matched, but the profile had been changed in some
* way. This probably indicates a data error or uninformed hacking.
* Fall through to "no match".
*/
- png_chunk_report(png_ptr,
- "Not recognizing known sRGB profile that has been edited",
+ png_chunk_report(png_ptr, "Not recognizing known sRGB profile that"
+ " has been edited",
PNG_CHUNK_WARNING);
break;
# endif
+ }
}
}
@@ -2321,25 +2359,27 @@ png_icc_set_sRGB(png_const_structrp png_ptr, /* Is this profile one of the known ICC sRGB profiles? If it is, just set
* the sRGB information.
*/
- if (png_compare_ICC_profile_with_sRGB(png_ptr, profile, adler))
+#if PNG_sRGB_PROFILE_CHECKS >= 0
+ if (png_compare_ICC_profile_with_sRGB(png_ptr, profile, adler) != 0)
+#endif
(void)png_colorspace_set_sRGB(png_ptr, colorspace,
(int)/*already checked*/png_get_uint_32(profile+64));
}
-#endif /* PNG_READ_sRGB_SUPPORTED */
+#endif /* READ_sRGB */
int /* PRIVATE */
png_colorspace_set_ICC(png_const_structrp png_ptr, png_colorspacerp colorspace,
png_const_charp name, png_uint_32 profile_length, png_const_bytep profile,
int color_type)
{
- if (colorspace->flags & PNG_COLORSPACE_INVALID)
+ if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
return 0;
- if (png_icc_check_length(png_ptr, colorspace, name, profile_length) &&
- png_icc_check_header(png_ptr, colorspace, name, profile_length, profile,
- color_type) &&
- png_icc_check_tag_table(png_ptr, colorspace, name, profile_length,
- profile))
+ if (png_icc_check_length(png_ptr, colorspace, name, profile_length) != 0 &&
+ png_icc_check_header(png_ptr, colorspace, name, profile_length, profile,
+ color_type) != 0 &&
+ png_icc_check_tag_table(png_ptr, colorspace, name, profile_length,
+ profile) != 0)
{
# ifdef PNG_sRGB_SUPPORTED
/* If no sRGB support, don't try storing sRGB information */
@@ -2358,7 +2398,7 @@ void /* PRIVATE */ png_colorspace_set_rgb_coefficients(png_structrp png_ptr)
{
/* Set the rgb_to_gray coefficients from the colorspace. */
- if (!png_ptr->rgb_to_gray_coefficients_set &&
+ if (png_ptr->rgb_to_gray_coefficients_set == 0 &&
(png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
{
/* png_set_background has not been called, get the coefficients from the Y
@@ -2435,44 +2475,45 @@ png_check_IHDR(png_const_structrp png_ptr, png_warning(png_ptr, "Image width is zero in IHDR");
error = 1;
}
-
- if (height == 0)
+ else if (width > PNG_UINT_31_MAX)
{
- png_warning(png_ptr, "Image height is zero in IHDR");
+ png_warning(png_ptr, "Invalid image width in IHDR");
error = 1;
}
-
-# ifdef PNG_SET_USER_LIMITS_SUPPORTED
- if (width > png_ptr->user_width_max)
-
-# else
- if (width > PNG_USER_WIDTH_MAX)
-# endif
+ else
{
- png_warning(png_ptr, "Image width exceeds user limit in IHDR");
- error = 1;
+# ifdef PNG_SET_USER_LIMITS_SUPPORTED
+ if (width > png_ptr->user_width_max)
+# else
+ if (width > PNG_USER_WIDTH_MAX)
+# endif
+ {
+ png_warning(png_ptr, "Image width exceeds user limit in IHDR");
+ error = 1;
+ }
}
-# ifdef PNG_SET_USER_LIMITS_SUPPORTED
- if (height > png_ptr->user_height_max)
-# else
- if (height > PNG_USER_HEIGHT_MAX)
-# endif
+ if (height == 0)
{
- png_warning(png_ptr, "Image height exceeds user limit in IHDR");
+ png_warning(png_ptr, "Image height is zero in IHDR");
error = 1;
}
-
- if (width > PNG_UINT_31_MAX)
+ else if (height > PNG_UINT_31_MAX)
{
- png_warning(png_ptr, "Invalid image width in IHDR");
+ png_warning(png_ptr, "Invalid image height in IHDR");
error = 1;
}
-
- if (height > PNG_UINT_31_MAX)
+ else
{
- png_warning(png_ptr, "Invalid image height in IHDR");
- error = 1;
+# ifdef PNG_SET_USER_LIMITS_SUPPORTED
+ if (height > png_ptr->user_height_max)
+# else
+ if (height > PNG_USER_HEIGHT_MAX)
+# endif
+ {
+ png_warning(png_ptr, "Image height exceeds user limit in IHDR");
+ error = 1;
+ }
}
/* Check other values */
@@ -2521,13 +2562,13 @@ png_check_IHDR(png_const_structrp png_ptr, * 4. The filter_method is 64 and
* 5. The color_type is RGB or RGBA
*/
- if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) &&
- png_ptr->mng_features_permitted)
+ if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) != 0 &&
+ png_ptr->mng_features_permitted != 0)
png_warning(png_ptr, "MNG features are not allowed in a PNG datastream");
if (filter_type != PNG_FILTER_TYPE_BASE)
{
- if (!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
+ if (!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
(filter_type == PNG_INTRAPIXEL_DIFFERENCING) &&
((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) == 0) &&
(color_type == PNG_COLOR_TYPE_RGB ||
@@ -2537,7 +2578,7 @@ png_check_IHDR(png_const_structrp png_ptr, error = 1;
}
- if (png_ptr->mode & PNG_HAVE_PNG_SIGNATURE)
+ if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) != 0)
{
png_warning(png_ptr, "Invalid filter method in IHDR");
error = 1;
@@ -2597,7 +2638,7 @@ png_check_fp_number(png_const_charp string, png_size_t size, int *statep, switch ((state & PNG_FP_STATE) + (type & PNG_FP_SAW_ANY))
{
case PNG_FP_INTEGER + PNG_FP_SAW_SIGN:
- if (state & PNG_FP_SAW_ANY)
+ if ((state & PNG_FP_SAW_ANY) != 0)
goto PNG_FP_End; /* not a part of the number */
png_fp_add(state, type);
@@ -2605,10 +2646,10 @@ png_check_fp_number(png_const_charp string, png_size_t size, int *statep, case PNG_FP_INTEGER + PNG_FP_SAW_DOT:
/* Ok as trailer, ok as lead of fraction. */
- if (state & PNG_FP_SAW_DOT) /* two dots */
+ if ((state & PNG_FP_SAW_DOT) != 0) /* two dots */
goto PNG_FP_End;
- else if (state & PNG_FP_SAW_DIGIT) /* trailing dot? */
+ else if ((state & PNG_FP_SAW_DIGIT) != 0) /* trailing dot? */
png_fp_add(state, type);
else
@@ -2617,7 +2658,7 @@ png_check_fp_number(png_const_charp string, png_size_t size, int *statep, break;
case PNG_FP_INTEGER + PNG_FP_SAW_DIGIT:
- if (state & PNG_FP_SAW_DOT) /* delayed fraction */
+ if ((state & PNG_FP_SAW_DOT) != 0) /* delayed fraction */
png_fp_set(state, PNG_FP_FRACTION | PNG_FP_SAW_DOT);
png_fp_add(state, type | PNG_FP_WAS_VALID);
@@ -2655,7 +2696,7 @@ png_check_fp_number(png_const_charp string, png_size_t size, int *statep, break;
case PNG_FP_EXPONENT + PNG_FP_SAW_SIGN:
- if (state & PNG_FP_SAW_ANY)
+ if ((state & PNG_FP_SAW_ANY) != 0)
goto PNG_FP_End; /* not a part of the number */
png_fp_add(state, PNG_FP_SAW_SIGN);
@@ -2698,13 +2739,13 @@ png_check_fp_string(png_const_charp string, png_size_t size) int state=0;
png_size_t char_index=0;
- if (png_check_fp_number(string, size, &state, &char_index) &&
+ if (png_check_fp_number(string, size, &state, &char_index) != 0 &&
(char_index == size || string[char_index] == 0))
return state /* must be non-zero - see above */;
return 0; /* i.e. fail */
}
-#endif /* pCAL or sCAL */
+#endif /* pCAL || sCAL */
#ifdef PNG_sCAL_SUPPORTED
# ifdef PNG_FLOATING_POINT_SUPPORTED
@@ -2738,7 +2779,7 @@ png_pow10(int power) }
while (power > 0);
- if (recip) d = 1/d;
+ if (recip != 0) d = 1/d;
}
/* else power is 0 and d is 1 */
@@ -2952,8 +2993,9 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size, if (exp_b10 != (-1))
{
- if (exp_b10 == 0) *ascii++ = 46, --size; /* counted
- above */
+ if (exp_b10 == 0)
+ *ascii++ = 46, --size; /* counted above */
+
--exp_b10;
}
*ascii++ = (char)(48 + (int)d), ++cdigits;
@@ -3261,11 +3303,12 @@ png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times, if (s00 >= (D >> 1))
++result;
- if (negative)
+ if (negative != 0)
result = -result;
/* Check for overflow. */
- if ((negative && result <= 0) || (!negative && result >= 0))
+ if ((negative != 0 && result <= 0) ||
+ (negative == 0 && result >= 0))
{
*res = result;
return 1;
@@ -3289,7 +3332,7 @@ png_muldiv_warn(png_const_structrp png_ptr, png_fixed_point a, png_int_32 times, {
png_fixed_point result;
- if (png_muldiv(&result, a, times, divisor))
+ if (png_muldiv(&result, a, times, divisor) != 0)
return result;
png_warning(png_ptr, "fixed point overflow ignored");
@@ -3310,7 +3353,7 @@ png_reciprocal(png_fixed_point a) #else
png_fixed_point res;
- if (png_muldiv(&res, 100000, 100000, a))
+ if (png_muldiv(&res, 100000, 100000, a) != 0)
return res;
#endif
@@ -3329,7 +3372,7 @@ png_gamma_significant(png_fixed_point gamma_val) #endif
#ifdef PNG_READ_GAMMA_SUPPORTED
-# ifdef PNG_16BIT_SUPPORTED
+#if defined(PNG_16BIT_SUPPORTED) || !defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)
/* A local convenience routine. */
static png_fixed_point
png_product2(png_fixed_point a, png_fixed_point b)
@@ -3345,13 +3388,13 @@ png_product2(png_fixed_point a, png_fixed_point b) # else
png_fixed_point res;
- if (png_muldiv(&res, a, b, 100000))
+ if (png_muldiv(&res, a, b, 100000) != 0)
return res;
# endif
return 0; /* overflow */
}
-# endif /* 16BIT */
+#endif /* 16BIT || !FLOATING_ARITHMETIC */
/* The inverse of the above. */
png_fixed_point
@@ -3503,6 +3546,7 @@ png_log8bit(unsigned int x) * Zero (257): 0
* End (258): 23499
*/
+#ifdef PNG_16BIT_SUPPORTED
static png_int_32
png_log16bit(png_uint_32 x)
{
@@ -3553,14 +3597,15 @@ png_log16bit(png_uint_32 x) /* Safe, because the result can't have more than 20 bits: */
return (png_int_32)((lg2 + 2048) >> 12);
}
+#endif /* 16BIT */
/* The 'exp()' case must invert the above, taking a 20-bit fixed point
* logarithmic value and returning a 16 or 8-bit number as appropriate. In
* each case only the low 16 bits are relevant - the fraction - since the
* integer bits (the top 4) simply determine a shift.
*
- * The worst case is the 16-bit distinction between 65535 and 65534, this
- * requires perhaps spurious accuracty in the decoding of the logarithm to
+ * The worst case is the 16-bit distinction between 65535 and 65534. This
+ * requires perhaps spurious accuracy in the decoding of the logarithm to
* distinguish log2(65535/65534.5) - 10^-5 or 17 bits. There is little chance
* of getting this accuracy in practice.
*
@@ -3648,7 +3693,7 @@ png_exp8bit(png_fixed_point lg2) /* Get a 32-bit value: */
png_uint_32 x = png_exp(lg2);
- /* Convert the 32-bit value to 0..255 by multiplying by 256-1, note that the
+ /* Convert the 32-bit value to 0..255 by multiplying by 256-1. Note that the
* second, rounding, step can't overflow because of the first, subtraction,
* step.
*/
@@ -3676,13 +3721,37 @@ png_gamma_8bit_correct(unsigned int value, png_fixed_point gamma_val) if (value > 0 && value < 255)
{
# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
- double r = floor(255*pow(value/255.,gamma_val*.00001)+.5);
+ /* 'value' is unsigned, ANSI-C90 requires the compiler to correctly
+ * convert this to a floating point value. This includes values that
+ * would overflow if 'value' were to be converted to 'int'.
+ *
+ * Apparently GCC, however, does an intermediate conversion to (int)
+ * on some (ARM) but not all (x86) platforms, possibly because of
+ * hardware FP limitations. (E.g. if the hardware conversion always
+ * assumes the integer register contains a signed value.) This results
+ * in ANSI-C undefined behavior for large values.
+ *
+ * Other implementations on the same machine might actually be ANSI-C90
+ * conformant and therefore compile spurious extra code for the large
+ * values.
+ *
+ * We can be reasonably sure that an unsigned to float conversion
+ * won't be faster than an int to float one. Therefore this code
+ * assumes responsibility for the undefined behavior, which it knows
+ * can't happen because of the check above.
+ *
+ * Note the argument to this routine is an (unsigned int) because, on
+ * 16-bit platforms, it is assigned a value which might be out of
+ * range for an (int); that would result in undefined behavior in the
+ * caller if the *argument* ('value') were to be declared (int).
+ */
+ double r = floor(255*pow((int)/*SAFE*/value/255.,gamma_val*.00001)+.5);
return (png_byte)r;
# else
png_int_32 lg2 = png_log8bit(value);
png_fixed_point res;
- if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1))
+ if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1) != 0)
return png_exp8bit(res);
/* Overflow. */
@@ -3700,13 +3769,19 @@ png_gamma_16bit_correct(unsigned int value, png_fixed_point gamma_val) if (value > 0 && value < 65535)
{
# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
- double r = floor(65535*pow(value/65535.,gamma_val*.00001)+.5);
+ /* The same (unsigned int)->(double) constraints apply here as above,
+ * however in this case the (unsigned int) to (int) conversion can
+ * overflow on an ANSI-C90 compliant system so the cast needs to ensure
+ * that this is not possible.
+ */
+ double r = floor(65535*pow((png_int_32)value/65535.,
+ gamma_val*.00001)+.5);
return (png_uint_16)r;
# else
png_int_32 lg2 = png_log16bit(value);
png_fixed_point res;
- if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1))
+ if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1) != 0)
return png_exp16bit(res);
/* Overflow. */
@@ -3754,6 +3829,12 @@ png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable, {
/* Various values derived from 'shift': */
PNG_CONST unsigned int num = 1U << (8U - shift);
+#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
+ /* CSE the division and work round wacky GCC warnings (see the comments
+ * in png_gamma_8bit_correct for where these come from.)
+ */
+ PNG_CONST double fmax = 1./(((png_int_32)1 << (16U - shift))-1);
+#endif
PNG_CONST unsigned int max = (1U << (16U - shift))-1U;
PNG_CONST unsigned int max_by_2 = 1U << (15U-shift);
unsigned int i;
@@ -3769,7 +3850,7 @@ png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable, /* The 'threshold' test is repeated here because it can arise for one of
* the 16-bit tables even if the others don't hit it.
*/
- if (png_gamma_significant(gamma_val))
+ if (png_gamma_significant(gamma_val) != 0)
{
/* The old code would overflow at the end and this would cause the
* 'pow' function to return a result >1, resulting in an
@@ -3785,10 +3866,13 @@ png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable, png_uint_32 ig = (j << (8-shift)) + i;
# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
/* Inline the 'max' scaling operation: */
- double d = floor(65535*pow(ig/(double)max, gamma_val*.00001)+.5);
+ /* See png_gamma_8bit_correct for why the cast to (int) is
+ * required here.
+ */
+ double d = floor(65535.*pow(ig*fmax, gamma_val*.00001)+.5);
sub_table[j] = (png_uint_16)d;
# else
- if (shift)
+ if (shift != 0)
ig = (ig * 65535U + max_by_2)/max;
sub_table[j] = png_gamma_16bit_correct(ig, gamma_val);
@@ -3804,7 +3888,7 @@ png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable, {
png_uint_32 ig = (j << (8-shift)) + i;
- if (shift)
+ if (shift != 0)
ig = (ig * 65535U + max_by_2)/max;
sub_table[j] = (png_uint_16)ig;
@@ -3830,7 +3914,7 @@ png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable, /* 'num' is the number of tables and also the number of low bits of low
* bits of the input 16-bit value used to select a table. Each table is
- * itself index by the high 8 bits of the value.
+ * itself indexed by the high 8 bits of the value.
*/
for (i = 0; i < num; i++)
table[i] = (png_uint_16p)png_malloc(png_ptr,
@@ -3882,7 +3966,7 @@ png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable, /* Build a single 8-bit table: same as the 16-bit case but much simpler (and
* typically much faster). Note that libpng currently does no sBIT processing
- * (apparently contrary to the spec) so a 256 entry table is always generated.
+ * (apparently contrary to the spec) so a 256-entry table is always generated.
*/
static void
png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable,
@@ -3891,11 +3975,13 @@ png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable, unsigned int i;
png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256);
- if (png_gamma_significant(gamma_val)) for (i=0; i<256; i++)
- table[i] = png_gamma_8bit_correct(i, gamma_val);
+ if (png_gamma_significant(gamma_val) != 0)
+ for (i=0; i<256; i++)
+ table[i] = png_gamma_8bit_correct(i, gamma_val);
- else for (i=0; i<256; ++i)
- table[i] = (png_byte)i;
+ else
+ for (i=0; i<256; ++i)
+ table[i] = (png_byte)i;
}
/* Used from png_read_destroy and below to release the memory used by the gamma
@@ -3987,7 +4073,7 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth) #if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
- if (png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY))
+ if ((png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) != 0)
{
png_build_8bit_table(png_ptr, &png_ptr->gamma_to_1,
png_reciprocal(png_ptr->colorspace.gamma));
@@ -4003,7 +4089,7 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth) {
png_byte shift, sig_bit;
- if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)
+ if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
{
sig_bit = png_ptr->sig_bit.red;
@@ -4023,7 +4109,7 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth) * Where 'iv' is the input color value and 'ov' is the output value -
* pow(iv, gamma).
*
- * Thus the gamma table consists of up to 256 256 entry tables. The table
+ * Thus the gamma table consists of up to 256 256-entry tables. The table
* is selected by the (8-gamma_shift) most significant of the low 8 bits of
* the color value then indexed by the upper 8 bits:
*
@@ -4040,7 +4126,7 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth) else
shift = 0; /* keep all 16 bits */
- if (png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8))
+ if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) != 0)
{
/* PNG_MAX_GAMMA_8 is the number of bits to keep - effectively
* the significant bits in the *input* when the output will
@@ -4060,7 +4146,7 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth) * 16-bit output because the 8-bit table assumes the result will be reduced
* to 8 bits.
*/
- if (png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8))
+ if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) != 0)
png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift,
png_ptr->screen_gamma > 0 ? png_product2(png_ptr->colorspace.gamma,
png_ptr->screen_gamma) : PNG_FP_1);
@@ -4073,7 +4159,7 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth) #if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
- if (png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY))
+ if ((png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) != 0)
{
png_build_16bit_table(png_ptr, &png_ptr->gamma_16_to_1, shift,
png_reciprocal(png_ptr->colorspace.gamma));
@@ -4092,7 +4178,7 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth) }
#endif /* READ_GAMMA */
-/* HARDWARE OPTION SUPPORT */
+/* HARDWARE OR SOFTWARE OPTION SUPPORT */
#ifdef PNG_SET_OPTION_SUPPORTED
int PNGAPI
png_set_option(png_structrp png_ptr, int option, int onoff)
@@ -4131,7 +4217,7 @@ png_set_option(png_structrp png_ptr, int option, int onoff) *
* error: -0.513727 - 0.607759, 308 (0.469978%) of readings inexact
*
- * In all cases the inexact readings are off by one.
+ * In all cases the inexact readings are only off by one.
*/
#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
@@ -4171,8 +4257,7 @@ const png_uint_16 png_sRGB_table[256] = 57105,57646,58190,58737,59287,59840,60396,60955,
61517,62082,62650,63221,63795,64372,64952,65535
};
-
-#endif /* simplified read only */
+#endif /* SIMPLIFIED_READ */
/* The base/delta tables are required for both read and write (but currently
* only the simplified versions.)
@@ -4300,7 +4385,7 @@ png_image_free_function(png_voidp argument) /* First free any data held in the control structure. */
# ifdef PNG_STDIO_SUPPORTED
- if (cp->owned_file)
+ if (cp->owned_file != 0)
{
FILE *fp = png_voidcast(FILE*, cp->png_ptr->io_ptr);
cp->owned_file = 0;
@@ -4324,7 +4409,7 @@ png_image_free_function(png_voidp argument) png_free(c.png_ptr, cp);
/* Then the structures, calling the correct API. */
- if (c.for_write)
+ if (c.for_write != 0)
{
# ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
png_destroy_write_struct(&c.png_ptr, &c.info_ptr);
@@ -4372,4 +4457,4 @@ png_image_error(png_imagep image, png_const_charp error_message) }
#endif /* SIMPLIFIED READ/WRITE */
-#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
+#endif /* READ || WRITE */
diff --git a/plugins/AdvaImg/src/LibPNG/png.h b/plugins/AdvaImg/src/LibPNG/png.h index 77bffe6b40..731816665e 100644 --- a/plugins/AdvaImg/src/LibPNG/png.h +++ b/plugins/AdvaImg/src/LibPNG/png.h @@ -1,7 +1,7 @@ /* png.h - header file for PNG reference library
*
- * libpng version 1.6.10 - March 6, 2014
+ * libpng version 1.6.15, November 20, 2014
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -11,7 +11,7 @@ * Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
- * libpng versions 0.97, January 1998, through 1.6.10 - March 6, 2014: Glenn
+ * libpng versions 0.97, January 1998, through 1.6.15, November 20, 2014: Glenn
* See also "Contributing Authors", below.
*
* Note about libpng version numbers:
@@ -193,8 +193,22 @@ * 1.6.9rc01-02 16 10609 16.so.16.9[.0]
* 1.6.9 16 10609 16.so.16.9[.0]
* 1.6.10beta01-03 16 10610 16.so.16.10[.0]
- * 1.6.10betarc01-04 16 10610 16.so.16.10[.0]
- * 1.6.10beta 16 10610 16.so.16.10[.0]
+ * 1.6.10rc01-03 16 10610 16.so.16.10[.0]
+ * 1.6.10 16 10610 16.so.16.10[.0]
+ * 1.6.11beta01-06 16 10611 16.so.16.11[.0]
+ * 1.6.11rc01-02 16 10611 16.so.16.11[.0]
+ * 1.6.11 16 10611 16.so.16.11[.0]
+ * 1.6.12rc01-03 16 10612 16.so.16.12[.0]
+ * 1.6.12 16 10612 16.so.16.12[.0]
+ * 1.6.13beta01-04 16 10613 16.so.16.13[.0]
+ * 1.6.13rc01-02 16 10613 16.so.16.13[.0]
+ * 1.6.13 16 10613 16.so.16.13[.0]
+ * 1.6.14beta01-07 16 10614 16.so.16.14[.0]
+ * 1.6.14rc01-02 16 10614 16.so.16.14[.0]
+ * 1.6.14 16 10614 16.so.16.14[.0]
+ * 1.6.15beta01-08 16 10615 16.so.16.15[.0]
+ * 1.6.15rc01-03 16 10615 16.so.16.15[.0]
+ * 1.6.15 16 10615 16.so.16.15[.0]
*
* Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be
@@ -226,8 +240,8 @@ *
* This code is released under the libpng license.
*
- * libpng versions 1.2.6, August 15, 2004, through 1.6.10, March 6, 2014, are
- * Copyright (c) 2004, 2006-2013 Glenn Randers-Pehrson, and are
+ * libpng versions 1.2.6, August 15, 2004, through 1.6.15, November 20, 2014, are
+ * Copyright (c) 2004, 2006-2014 Glenn Randers-Pehrson, and are
* distributed according to the same disclaimer and license as libpng-1.2.5
* with the following individual added to the list of Contributing Authors:
*
@@ -338,13 +352,13 @@ * Y2K compliance in libpng:
* =========================
*
- * March 6, 2014
+ * November 20, 2014
*
* Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration.
*
* This is your unofficial assurance that libpng from version 0.71 and
- * upward through 1.6.10 are Y2K compliant. It is my belief that
+ * upward through 1.6.15 are Y2K compliant. It is my belief that
* earlier versions were also Y2K compliant.
*
* Libpng only has two year fields. One is a 2-byte unsigned integer
@@ -397,16 +411,18 @@ /* This is not the place to learn how to use libpng. The file libpng-manual.txt
* describes how to use libpng, and the file example.c summarizes it
* with some code on which to build. This file is useful for looking
- * at the actual function definitions and structure components.
+ * at the actual function definitions and structure components. If that
+ * file has been stripped from your copy of libpng, you can find it at
+ * <http://www.libpng.org/pub/png/libpng-manual.txt>
*
* If you just need to read a PNG file and don't want to read the documentation
* skip to the end of this file and read the section entitled 'simplified API'.
*/
/* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.6.10"
+#define PNG_LIBPNG_VER_STRING "1.6.15"
#define PNG_HEADER_VERSION_STRING \
- " libpng version 1.6.10 - March 6, 2014\n"
+ " libpng version 1.6.15 - November 20, 2014\n"
#define PNG_LIBPNG_VER_SONUM 16
#define PNG_LIBPNG_VER_DLLNUM 16
@@ -414,7 +430,7 @@ /* 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 10
+#define PNG_LIBPNG_VER_RELEASE 15
/* This should match the numeric part of the final component of
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
@@ -445,7 +461,7 @@ * version 1.0.0 was mis-numbered 100 instead of 10000). From
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
*/
-#define PNG_LIBPNG_VER 10610 /* 1.6.10 */
+#define PNG_LIBPNG_VER 10615 /* 1.6.15 */
/* Library configuration: these options cannot be changed after
* the library has been built.
@@ -550,7 +566,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_10;
+typedef char* png_libpng_version_1_6_15;
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
*
@@ -1163,7 +1179,7 @@ PNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime, /* Convert from time_t to png_time. Uses gmtime() */
PNG_EXPORT(25, void, png_convert_from_time_t, (png_timep ptime, time_t ttime));
-#endif /* PNG_CONVERT_tIME_SUPPORTED */
+#endif /* CONVERT_tIME */
#ifdef PNG_READ_EXPAND_SUPPORTED
/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */
@@ -1369,7 +1385,7 @@ PNG_EXPORT(39, void, png_set_filler, (png_structrp png_ptr, png_uint_32 filler, /* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */
PNG_EXPORT(40, void, png_set_add_alpha, (png_structrp png_ptr,
png_uint_32 filler, int flags));
-#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */
+#endif /* READ_FILLER || WRITE_FILLER */
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
/* Swap bytes in 16-bit depth files. */
@@ -1633,7 +1649,7 @@ PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed, (png_structrp png_ptr, int heuristic_method, int num_weights,
png_const_fixed_point_p filter_weights,
png_const_fixed_point_p filter_costs))
-#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
+#endif /* WRITE_WEIGHTED_FILTER */
/* Heuristic used for row filter selection. These defines should NOT be
* changed.
@@ -1689,7 +1705,7 @@ PNG_EXPORT(225, void, png_set_text_compression_window_bits, PNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr,
int method));
-#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */
+#endif /* WRITE_CUSTOMIZE_ZTXT_COMPRESSION */
/* These next functions are called for input/output, memory, and error
* handling. They are in the file pngrio.c, pngwio.c, and pngerror.c,
@@ -1849,7 +1865,6 @@ PNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structrp, int save)); */
PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structrp));
-#ifdef PNG_READ_INTERLACING_SUPPORTED
/* Function that combines rows. 'new_row' is a flag that should come from
* the callback and be non-NULL if anything needs to be done; the library
* stores its own version of the new data internally and ignores the passed
@@ -1857,8 +1872,7 @@ PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structrp)); */
PNG_EXPORT(93, void, png_progressive_combine_row, (png_const_structrp png_ptr,
png_bytep old_row, png_const_bytep new_row));
-#endif /* PNG_READ_INTERLACING_SUPPORTED */
-#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
+#endif /* PROGRESSIVE_READ */
PNG_EXPORTA(94, png_voidp, png_malloc, (png_const_structrp png_ptr,
png_alloc_size_t size), PNG_ALLOCATED);
@@ -2059,7 +2073,7 @@ PNG_EXPORT(128, png_int_32, png_get_x_offset_microns, PNG_EXPORT(129, png_int_32, png_get_y_offset_microns,
(png_const_structrp png_ptr, png_const_inforp info_ptr));
-#endif /* PNG_EASY_ACCESS_SUPPORTED */
+#endif /* EASY_ACCESS */
#ifdef PNG_READ_SUPPORTED
/* Returns pointer to signature string read from PNG header */
@@ -2311,7 +2325,7 @@ PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr, PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr,
png_inforp info_ptr, int unit,
png_const_charp swidth, png_const_charp sheight));
-#endif /* PNG_sCAL_SUPPORTED */
+#endif /* sCAL */
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
/* Provide the default handling for all unknown chunks or, optionally, for
@@ -2539,8 +2553,8 @@ PNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed, PNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structrp png_ptr,
png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y,
int *unit_type));
-# endif /* PNG_pHYs_SUPPORTED */
-#endif /* PNG_INCH_CONVERSIONS_SUPPORTED */
+# endif /* pHYs */
+#endif /* INCH_CONVERSIONS */
/* Added in libpng-1.4.0 */
#ifdef PNG_IO_STATE_SUPPORTED
@@ -2563,7 +2577,7 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type, # define PNG_IO_CHUNK_CRC 0x0080 /* currently at the chunk crc */
# define PNG_IO_MASK_OP 0x000f /* current operation: reading/writing */
# define PNG_IO_MASK_LOC 0x00f0 /* current location: sig/hdr/data/crc */
-#endif /* ?PNG_IO_STATE_SUPPORTED */
+#endif /* IO_STATE */
/* Interlace support. The following macros are always defined so that if
* libpng interlace handling is turned off the macros may be used to handle
@@ -2667,7 +2681,7 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type, (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \
(png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \
32767) / 65535)
-#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
+#endif /* READ_COMPOSITE_NODIV */
#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf));
@@ -2737,6 +2751,8 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i)); # endif
#endif
+#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) || \
+ defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
/*******************************************************************************
* SIMPLIFIED API
*******************************************************************************
@@ -2808,7 +2824,7 @@ typedef struct # define PNG_IMAGE_WARNING 1
# define PNG_IMAGE_ERROR 2
/*
- * The result is a two bit code such that a value more than 1 indicates
+ * The result is a two-bit code such that a value more than 1 indicates
* a failure in the API just called:
*
* 0 - no warning or error
@@ -3093,7 +3109,7 @@ PNG_EXPORT(234, int, png_image_begin_read_from_file, (png_imagep image, PNG_EXPORT(235, int, png_image_begin_read_from_stdio, (png_imagep image,
FILE* file));
/* The PNG header is read from the stdio FILE object. */
-#endif /* PNG_STDIO_SUPPORTED */
+#endif /* STDIO */
PNG_EXPORT(236, int, png_image_begin_read_from_memory, (png_imagep image,
png_const_voidp memory, png_size_t size));
@@ -3138,7 +3154,7 @@ PNG_EXPORT(238, void, png_image_free, (png_imagep image)); /* Free any data allocated by libpng in image->opaque, setting the pointer to
* NULL. May be called at any time after the structure is initialized.
*/
-#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */
+#endif /* SIMPLIFIED_READ */
#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
#ifdef PNG_STDIO_SUPPORTED
@@ -3184,11 +3200,12 @@ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file, *
* Note that the write API does not support interlacing or sub-8-bit pixels.
*/
-#endif /* PNG_STDIO_SUPPORTED */
-#endif /* PNG_SIMPLIFIED_WRITE_SUPPORTED */
+#endif /* STDIO */
+#endif /* SIMPLIFIED_WRITE */
/*******************************************************************************
* END OF SIMPLIFIED API
******************************************************************************/
+#endif /* SIMPLIFIED_{READ|WRITE} */
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
PNG_EXPORT(242, void, png_set_check_for_invalid_index,
@@ -3225,7 +3242,8 @@ PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr, # define PNG_ARM_NEON 0 /* HARDWARE: ARM Neon SIMD instructions supported */
#endif
#define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */
-#define PNG_OPTION_NEXT 4 /* Next option - numbers must be even */
+#define PNG_SKIP_sRGB_CHECK_PROFILE 4 /* SOFTWARE: Check ICC profile for sRGB */
+#define PNG_OPTION_NEXT 6 /* 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 */
@@ -3235,19 +3253,18 @@ PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr, PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,
int onoff));
-#endif
+#endif /* SET_OPTION */
/*******************************************************************************
- * END OF HARDWARE OPTIONS
+ * END OF HARDWARE AND SOFTWARE OPTIONS
******************************************************************************/
-/* Maintainer: Put new public prototypes here ^, in libpng.3, and project
- * defs, scripts/pnglibconf.h, and scripts/pnglibconf.h.prebuilt
+/* Maintainer: Put new public prototypes here ^, in libpng.3, in project
+ * defs, and in scripts/symbols.def.
*/
/* The last ordinal number (this is the *last* one already used; the next
- * one to use is one more than this.) Maintainer, remember to add an entry to
- * scripts/symbols.def as well.
+ * one to use is one more than this.)
*/
#ifdef PNG_EXPORT_LAST_ORDINAL
PNG_EXPORT_LAST_ORDINAL(244);
diff --git a/plugins/AdvaImg/src/LibPNG/pngconf.h b/plugins/AdvaImg/src/LibPNG/pngconf.h index f11192fa70..db9ed4839d 100644 --- a/plugins/AdvaImg/src/LibPNG/pngconf.h +++ b/plugins/AdvaImg/src/LibPNG/pngconf.h @@ -1,9 +1,9 @@ /* pngconf.h - machine configurable file for libpng
*
- * libpng version 1.6.10 - March 6, 2014
+ * libpng version 1.6.15,November 20, 2014
*
- * Copyright (c) 1998-2013 Glenn Randers-Pehrson
+ * Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@@ -361,7 +361,7 @@ * version 1.2.41. Disabling these removes the warnings but may also produce
* less efficient code.
*/
-# if defined(__clang__)
+# if defined(__clang__) && defined(__has_attribute)
/* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */
# if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__)
# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
diff --git a/plugins/AdvaImg/src/LibPNG/pngerror.c b/plugins/AdvaImg/src/LibPNG/pngerror.c index 7e155cf2d3..9977049272 100644 --- a/plugins/AdvaImg/src/LibPNG/pngerror.c +++ b/plugins/AdvaImg/src/LibPNG/pngerror.c @@ -1,7 +1,7 @@ /* pngerror.c - stub functions for i/o and memory allocation
*
- * Last changed in libpng 1.6.10 [March 6, 2014]
+ * Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -27,7 +27,7 @@ static PNG_FUNCTION(void, png_default_error,PNGARG((png_const_structrp png_ptr, static void /* PRIVATE */
png_default_warning PNGARG((png_const_structrp png_ptr,
png_const_charp warning_message));
-#endif /* PNG_WARNINGS_SUPPORTED */
+#endif /* WARNINGS */
/* This function is called whenever there is a fatal error. This function
* should not be changed. If there is a need to handle errors differently,
@@ -43,8 +43,8 @@ png_error,(png_const_structrp png_ptr, png_const_charp error_message), char msg[16];
if (png_ptr != NULL)
{
- if (png_ptr->flags&
- (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
+ if ((png_ptr->flags &
+ (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0
{
if (*error_message == PNG_LITERAL_SHARP)
{
@@ -54,7 +54,7 @@ png_error,(png_const_structrp png_ptr, png_const_charp error_message), if (error_message[offset] == ' ')
break;
- if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
+ if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
{
int i;
for (i = 0; i < offset - 1; i++)
@@ -69,7 +69,7 @@ png_error,(png_const_structrp png_ptr, png_const_charp error_message), else
{
- if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
+ if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
{
msg[0] = '0';
msg[1] = '\0';
@@ -103,7 +103,7 @@ png_err,(png_const_structrp png_ptr),PNG_NORETURN) use the default handler, which will not return. */
png_default_error(png_ptr, "");
}
-#endif /* PNG_ERROR_TEXT_SUPPORTED */
+#endif /* ERROR_TEXT */
/* Utility to safely appends strings to a buffer. This never errors out so
* error checking is not required in the caller.
@@ -152,7 +152,7 @@ png_format_number(png_const_charp start, png_charp end, int format, case PNG_NUMBER_FORMAT_fixed:
/* Needs five digits (the fraction) */
mincount = 5;
- if (output || number % 10 != 0)
+ if (output != 0 || number % 10 != 0)
{
*--end = digits[number % 10];
output = 1;
@@ -189,13 +189,13 @@ png_format_number(png_const_charp start, png_charp end, int format, ++count;
/* Float a fixed number here: */
- if (format == PNG_NUMBER_FORMAT_fixed) if (count == 5) if (end > start)
+ if ((format == PNG_NUMBER_FORMAT_fixed) && (count == 5) && (end > start))
{
/* End of the fraction, but maybe nothing was output? In that case
* drop the decimal point. If the number is a true zero handle that
* here.
*/
- if (output)
+ if (output != 0)
*--end = '.';
else if (number == 0) /* and !output */
*--end = '0';
@@ -219,8 +219,8 @@ png_warning(png_const_structrp png_ptr, png_const_charp warning_message) if (png_ptr != NULL)
{
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
- if (png_ptr->flags&
- (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
+ if ((png_ptr->flags &
+ (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0)
#endif
{
if (*warning_message == PNG_LITERAL_SHARP)
@@ -355,13 +355,13 @@ png_formatted_warning(png_const_structrp png_ptr, png_warning_parameters p, */
png_warning(png_ptr, msg);
}
-#endif /* PNG_WARNINGS_SUPPORTED */
+#endif /* WARNINGS */
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
void PNGAPI
png_benign_error(png_const_structrp png_ptr, png_const_charp error_message)
{
- if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
+ if ((png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) != 0)
{
# ifdef PNG_READ_SUPPORTED
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
@@ -391,7 +391,7 @@ png_benign_error(png_const_structrp png_ptr, png_const_charp error_message) void /* PRIVATE */
png_app_warning(png_const_structrp png_ptr, png_const_charp error_message)
{
- if (png_ptr->flags & PNG_FLAG_APP_WARNINGS_WARN)
+ if ((png_ptr->flags & PNG_FLAG_APP_WARNINGS_WARN) != 0)
png_warning(png_ptr, error_message);
else
png_error(png_ptr, error_message);
@@ -404,7 +404,7 @@ png_app_warning(png_const_structrp png_ptr, png_const_charp error_message) void /* PRIVATE */
png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
{
- if (png_ptr->flags & PNG_FLAG_APP_ERRORS_WARN)
+ if ((png_ptr->flags & PNG_FLAG_APP_ERRORS_WARN) != 0)
png_warning(png_ptr, error_message);
else
png_error(png_ptr, error_message);
@@ -415,10 +415,13 @@ png_app_error(png_const_structrp png_ptr, png_const_charp error_message) }
#endif /* BENIGN_ERRORS */
+#define PNG_MAX_ERROR_TEXT 196 /* Currently limited by profile_error in png.c */
+#if defined(PNG_WARNINGS_SUPPORTED) || \
+ (defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED))
/* These utilities are used internally to build an error message that relates
* to the current chunk. The chunk name comes from png_ptr->chunk_name,
- * this is used to prefix the message. The message is limited in length
- * to 63 bytes, the name characters are output as hex digits wrapped in []
+ * which is used to prefix the message. The message is limited in length
+ * to 63 bytes. The name characters are output as hex digits wrapped in []
* if the character is invalid.
*/
#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
@@ -427,9 +430,6 @@ static PNG_CONST char png_digit[16] = { 'A', 'B', 'C', 'D', 'E', 'F'
};
-#define PNG_MAX_ERROR_TEXT 196 /* Currently limited be profile_error in png.c */
-#if defined(PNG_WARNINGS_SUPPORTED) || \
- (defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED))
static void /* PRIVATE */
png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp
error_message)
@@ -442,7 +442,7 @@ png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp int c = (int)(chunk_name >> ishift) & 0xff;
ishift -= 8;
- if (isnonalpha(c))
+ if (isnonalpha(c) != 0)
{
buffer[iout++] = PNG_LITERAL_LEFT_SQUARE_BRACKET;
buffer[iout++] = png_digit[(c & 0xf0) >> 4];
@@ -473,7 +473,7 @@ png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp buffer[iout] = '\0';
}
}
-#endif /* PNG_WARNINGS_SUPPORTED || PNG_ERROR_TEXT_SUPPORTED */
+#endif /* WARNINGS || ERROR_TEXT */
#if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)
PNG_FUNCTION(void,PNGAPI
@@ -490,7 +490,7 @@ png_chunk_error,(png_const_structrp png_ptr, png_const_charp error_message), png_error(png_ptr, msg);
}
}
-#endif /* PNG_READ_SUPPORTED && PNG_ERROR_TEXT_SUPPORTED */
+#endif /* READ && ERROR_TEXT */
#ifdef PNG_WARNINGS_SUPPORTED
void PNGAPI
@@ -506,7 +506,7 @@ png_chunk_warning(png_const_structrp png_ptr, png_const_charp warning_message) png_warning(png_ptr, msg);
}
}
-#endif /* PNG_WARNINGS_SUPPORTED */
+#endif /* WARNINGS */
#ifdef PNG_READ_SUPPORTED
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
@@ -514,7 +514,7 @@ void PNGAPI png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp
error_message)
{
- if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)
+ if ((png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) != 0)
png_chunk_warning(png_ptr, error_message);
else
@@ -525,7 +525,7 @@ png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp # endif
}
#endif
-#endif /* PNG_READ_SUPPORTED */
+#endif /* READ */
void /* PRIVATE */
png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error)
@@ -538,7 +538,7 @@ png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error) * unconditionally does the right thing.
*/
# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED)
- if (png_ptr->mode & PNG_IS_READ_STRUCT)
+ if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
# endif
# ifdef PNG_READ_SUPPORTED
@@ -552,7 +552,7 @@ png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error) # endif
# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED)
- else if (!(png_ptr->mode & PNG_IS_READ_STRUCT))
+ else if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
# endif
# ifdef PNG_WRITE_SUPPORTED
@@ -577,11 +577,12 @@ png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN) char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT];
memcpy(msg, fixed_message, fixed_message_ln);
iin = 0;
- if (name != NULL) while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0)
- {
- msg[fixed_message_ln + iin] = name[iin];
- ++iin;
- }
+ if (name != NULL)
+ while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0)
+ {
+ msg[fixed_message_ln + iin] = name[iin];
+ ++iin;
+ }
msg[fixed_message_ln + iin] = 0;
png_error(png_ptr, msg);
}
@@ -757,8 +758,12 @@ PNG_FUNCTION(void,PNGAPI png_longjmp,(png_const_structrp png_ptr, int val),PNG_NORETURN)
{
#ifdef PNG_SETJMP_SUPPORTED
- if (png_ptr && png_ptr->longjmp_fn && png_ptr->jmp_buf_ptr)
+ if (png_ptr != NULL && png_ptr->longjmp_fn != NULL &&
+ png_ptr->jmp_buf_ptr != NULL)
png_ptr->longjmp_fn(*png_ptr->jmp_buf_ptr, val);
+#else
+ PNG_UNUSED(png_ptr)
+ PNG_UNUSED(val)
#endif
/* If control reaches this point, png_longjmp() must not return. The only
@@ -819,7 +824,7 @@ png_default_warning(png_const_structrp png_ptr, png_const_charp warning_message) #endif
PNG_UNUSED(png_ptr) /* Make compiler happy */
}
-#endif /* PNG_WARNINGS_SUPPORTED */
+#endif /* WARNINGS */
/* This function is called when the application wants to use another method
* of handling errors and warnings. Note that the error function MUST NOT
@@ -939,7 +944,7 @@ png_safe_execute(png_imagep image_in, int (*function)(png_voidp), png_voidp arg) saved_error_buf = image->opaque->error_buf;
result = setjmp(safe_jmpbuf) == 0;
- if (result)
+ if (result != 0)
{
image->opaque->error_buf = safe_jmpbuf;
@@ -949,10 +954,10 @@ png_safe_execute(png_imagep image_in, int (*function)(png_voidp), png_voidp arg) image->opaque->error_buf = saved_error_buf;
/* And do the cleanup prior to any failure return. */
- if (!result)
+ if (result == 0)
png_image_free(image);
return result;
}
-#endif /* SIMPLIFIED READ/WRITE */
-#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
+#endif /* SIMPLIFIED READ || SIMPLIFIED_WRITE */
+#endif /* READ || WRITE */
diff --git a/plugins/AdvaImg/src/LibPNG/pngget.c b/plugins/AdvaImg/src/LibPNG/pngget.c index 80ab055dca..13418317be 100644 --- a/plugins/AdvaImg/src/LibPNG/pngget.c +++ b/plugins/AdvaImg/src/LibPNG/pngget.c @@ -1,8 +1,8 @@ /* pngget.c - retrieval of values from info struct
*
- * Last changed in libpng 1.6.1 [March 28, 2013]
- * Copyright (c) 1998-2013 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.15 [November 20, 2014]
+ * Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@@ -116,7 +116,8 @@ png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
#ifdef PNG_pHYs_SUPPORTED
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_pHYs) != 0)
{
png_debug1(1, "in %s retrieval function",
"png_get_x_pixels_per_meter");
@@ -124,6 +125,9 @@ png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
return (info_ptr->x_pixels_per_unit);
}
+#else
+ PNG_UNUSED(png_ptr)
+ PNG_UNUSED(info_ptr)
#endif
return (0);
@@ -134,7 +138,8 @@ png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
#ifdef PNG_pHYs_SUPPORTED
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_pHYs) != 0)
{
png_debug1(1, "in %s retrieval function",
"png_get_y_pixels_per_meter");
@@ -142,6 +147,9 @@ png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
return (info_ptr->y_pixels_per_unit);
}
+#else
+ PNG_UNUSED(png_ptr)
+ PNG_UNUSED(info_ptr)
#endif
return (0);
@@ -151,7 +159,8 @@ png_uint_32 PNGAPI png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
#ifdef PNG_pHYs_SUPPORTED
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_pHYs) != 0)
{
png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
@@ -159,6 +168,9 @@ png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr) info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit)
return (info_ptr->x_pixels_per_unit);
}
+#else
+ PNG_UNUSED(png_ptr)
+ PNG_UNUSED(info_ptr)
#endif
return (0);
@@ -170,7 +182,8 @@ png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
#ifdef PNG_READ_pHYs_SUPPORTED
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_pHYs) != 0)
{
png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
@@ -193,10 +206,11 @@ png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
#ifdef PNG_READ_pHYs_SUPPORTED
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)
- && info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0
- && info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX
- && info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX)
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_pHYs) != 0 &&
+ info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0 &&
+ info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX &&
+ info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX)
{
png_fixed_point res;
@@ -206,7 +220,7 @@ png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr, * range of 0..2^31-1; otherwise the cast might overflow.
*/
if (png_muldiv(&res, (png_int_32)info_ptr->y_pixels_per_unit, PNG_FP_1,
- (png_int_32)info_ptr->x_pixels_per_unit))
+ (png_int_32)info_ptr->x_pixels_per_unit) != 0)
return res;
}
#else
@@ -222,13 +236,17 @@ png_int_32 PNGAPI png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
#ifdef PNG_oFFs_SUPPORTED
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_oFFs) != 0)
{
png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
return (info_ptr->x_offset);
}
+#else
+ PNG_UNUSED(png_ptr)
+ PNG_UNUSED(info_ptr)
#endif
return (0);
@@ -238,13 +256,17 @@ png_int_32 PNGAPI png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
#ifdef PNG_oFFs_SUPPORTED
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_oFFs) != 0)
{
png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
return (info_ptr->y_offset);
}
+#else
+ PNG_UNUSED(png_ptr)
+ PNG_UNUSED(info_ptr)
#endif
return (0);
@@ -254,13 +276,17 @@ png_int_32 PNGAPI png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
#ifdef PNG_oFFs_SUPPORTED
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_oFFs) != 0)
{
png_debug1(1, "in %s retrieval function", "png_get_x_offset_pixels");
if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
return (info_ptr->x_offset);
}
+#else
+ PNG_UNUSED(png_ptr)
+ PNG_UNUSED(info_ptr)
#endif
return (0);
@@ -270,13 +296,17 @@ png_int_32 PNGAPI png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
#ifdef PNG_oFFs_SUPPORTED
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_oFFs) != 0)
{
png_debug1(1, "in %s retrieval function", "png_get_y_offset_pixels");
if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
return (info_ptr->y_offset);
}
+#else
+ PNG_UNUSED(png_ptr)
+ PNG_UNUSED(info_ptr)
#endif
return (0);
@@ -307,7 +337,7 @@ ppi_from_ppm(png_uint_32 ppm) */
png_fixed_point result;
if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127,
- 5000))
+ 5000) != 0)
return result;
/* Overflow. */
@@ -393,7 +423,8 @@ png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr, {
png_uint_32 retval = 0;
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_pHYs) != 0)
{
png_debug1(1, "in %s retrieval function", "pHYs");
@@ -424,12 +455,12 @@ png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr, return (retval);
}
-#endif /* PNG_pHYs_SUPPORTED */
-#endif /* PNG_INCH_CONVERSIONS_SUPPORTED */
+#endif /* pHYs */
+#endif /* INCH_CONVERSIONS */
/* png_get_channels really belongs in here, too, but it's been around longer */
-#endif /* PNG_EASY_ACCESS_SUPPORTED */
+#endif /* EASY_ACCESS */
png_byte PNGAPI
@@ -457,8 +488,9 @@ png_uint_32 PNGAPI png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
png_color_16p *background)
{
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
- && background != NULL)
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_bKGD) != 0 &&
+ background != NULL)
{
png_debug1(1, "in %s retrieval function", "bKGD");
@@ -488,7 +520,7 @@ png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr, * consistent.
*/
if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
+ (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
{
png_debug1(1, "in %s retrieval function", "cHRM");
@@ -529,7 +561,7 @@ png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr, double *blue_Z)
{
if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
+ (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
{
png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
@@ -577,7 +609,7 @@ png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, png_fixed_point *int_blue_Z)
{
if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
+ (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
{
png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
@@ -614,7 +646,7 @@ png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, png_debug1(1, "in %s retrieval function", "cHRM");
if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))
+ (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
{
if (white_x != NULL)
*white_x = info_ptr->colorspace.end_points_xy.whitex;
@@ -649,7 +681,7 @@ png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, png_debug1(1, "in %s retrieval function", "gAMA");
if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) &&
+ (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
file_gamma != NULL)
{
*file_gamma = info_ptr->colorspace.gamma;
@@ -668,7 +700,7 @@ png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr, png_debug1(1, "in %s retrieval function", "gAMA(float)");
if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) &&
+ (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
file_gamma != NULL)
{
*file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma,
@@ -688,8 +720,8 @@ png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr, {
png_debug1(1, "in %s retrieval function", "sRGB");
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
- && file_srgb_intent != NULL)
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_sRGB) != 0 && file_srgb_intent != NULL)
{
*file_srgb_intent = info_ptr->colorspace.rendering_intent;
return (PNG_INFO_sRGB);
@@ -707,9 +739,10 @@ png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, {
png_debug1(1, "in %s retrieval function", "iCCP");
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
- && name != NULL && compression_type != NULL && profile != NULL &&
- proflen != NULL)
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_iCCP) != 0 &&
+ name != NULL && compression_type != NULL && profile != NULL &&
+ proflen != NULL)
{
*name = info_ptr->iccp_name;
*profile = info_ptr->iccp_profile;
@@ -747,8 +780,8 @@ png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr, {
png_debug1(1, "in %s retrieval function", "hIST");
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
- && hist != NULL)
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_hIST) != 0 && hist != NULL)
{
*hist = info_ptr->hist;
return (PNG_INFO_hIST);
@@ -803,8 +836,9 @@ png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr, {
png_debug1(1, "in %s retrieval function", "oFFs");
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
- && offset_x != NULL && offset_y != NULL && unit_type != NULL)
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_oFFs) != 0 &&
+ offset_x != NULL && offset_y != NULL && unit_type != NULL)
{
*offset_x = info_ptr->x_offset;
*offset_y = info_ptr->y_offset;
@@ -824,8 +858,9 @@ png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, {
png_debug1(1, "in %s retrieval function", "pCAL");
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
- && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_pCAL) != 0 &&
+ purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
nparams != NULL && units != NULL && params != NULL)
{
*purpose = info_ptr->pcal_purpose;
@@ -851,7 +886,7 @@ png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, png_fixed_point *width, png_fixed_point *height)
{
if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_sCAL))
+ (info_ptr->valid & PNG_INFO_sCAL) != 0)
{
*unit = info_ptr->scal_unit;
/*TODO: make this work without FP support; the API is currently eliminated
@@ -874,7 +909,7 @@ png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, double *width, double *height)
{
if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_sCAL))
+ (info_ptr->valid & PNG_INFO_sCAL) != 0)
{
*unit = info_ptr->scal_unit;
*width = atof(info_ptr->scal_s_width);
@@ -890,7 +925,7 @@ png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, png_charpp width, png_charpp height)
{
if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_sCAL))
+ (info_ptr->valid & PNG_INFO_sCAL) != 0)
{
*unit = info_ptr->scal_unit;
*width = info_ptr->scal_s_width;
@@ -912,7 +947,7 @@ png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr, png_debug1(1, "in %s retrieval function", "pHYs");
if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_pHYs))
+ (info_ptr->valid & PNG_INFO_pHYs) != 0)
{
if (res_x != NULL)
{
@@ -943,8 +978,8 @@ png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr, {
png_debug1(1, "in %s retrieval function", "PLTE");
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
- && palette != NULL)
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_PLTE) != 0 && palette != NULL)
{
*palette = info_ptr->palette;
*num_palette = info_ptr->num_palette;
@@ -962,8 +997,8 @@ png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr, {
png_debug1(1, "in %s retrieval function", "sBIT");
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
- && sig_bit != NULL)
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_sBIT) != 0 && sig_bit != NULL)
{
*sig_bit = &(info_ptr->sig_bit);
return (PNG_INFO_sBIT);
@@ -1006,8 +1041,8 @@ png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr, {
png_debug1(1, "in %s retrieval function", "tIME");
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
- && mod_time != NULL)
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_tIME) != 0 && mod_time != NULL)
{
*mod_time = &(info_ptr->mod_time);
return (PNG_INFO_tIME);
@@ -1023,7 +1058,8 @@ png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr, png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
{
png_uint_32 retval = 0;
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_tRNS) != 0)
{
png_debug1(1, "in %s retrieval function", "tRNS");
@@ -1100,7 +1136,7 @@ png_get_compression_buffer_size(png_const_structrp png_ptr) return 0;
# ifdef PNG_WRITE_SUPPORTED
- if (png_ptr->mode & PNG_IS_READ_STRUCT)
+ if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
# endif
{
# ifdef PNG_SEQUENTIAL_READ_SUPPORTED
@@ -1144,7 +1180,7 @@ png_get_chunk_malloc_max (png_const_structrp png_ptr) {
return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);
}
-#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
+#endif /* SET_USER_LIMITS */
/* These functions were added to libpng 1.4.0 */
#ifdef PNG_IO_STATE_SUPPORTED
@@ -1159,7 +1195,7 @@ png_get_io_chunk_type (png_const_structrp png_ptr) {
return png_ptr->chunk_name;
}
-#endif /* ?PNG_IO_STATE_SUPPORTED */
+#endif /* IO_STATE */
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
# ifdef PNG_GET_PALETTE_MAX_SUPPORTED
@@ -1174,4 +1210,4 @@ png_get_palette_max(png_const_structp png_ptr, png_const_infop info_ptr) # endif
#endif
-#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
+#endif /* READ || WRITE */
diff --git a/plugins/AdvaImg/src/LibPNG/pnginfo.h b/plugins/AdvaImg/src/LibPNG/pnginfo.h index 683b7ea177..8ae23b9a25 100644 --- a/plugins/AdvaImg/src/LibPNG/pnginfo.h +++ b/plugins/AdvaImg/src/LibPNG/pnginfo.h @@ -121,7 +121,7 @@ struct png_info_def int num_text; /* number of comments read or comments to write */
int max_text; /* current size of text array */
png_textp text; /* array of comments read or comments to write */
-#endif /* PNG_TEXT_SUPPORTED */
+#endif /* TEXT */
#ifdef PNG_tIME_SUPPORTED
/* The tIME chunk holds the last time the displayed image data was
diff --git a/plugins/AdvaImg/src/LibPNG/pngmem.c b/plugins/AdvaImg/src/LibPNG/pngmem.c index ba643a9fb1..56330098e2 100644 --- a/plugins/AdvaImg/src/LibPNG/pngmem.c +++ b/plugins/AdvaImg/src/LibPNG/pngmem.c @@ -1,8 +1,8 @@ /* pngmem.c - stub functions for memory allocation
*
- * Last changed in libpng 1.6.8 [December 19, 2013]
- * Copyright (c) 1998-2013 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.15 [November 20, 2014]
+ * Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@@ -199,7 +199,7 @@ png_malloc_default,(png_const_structrp png_ptr, png_alloc_size_t size), return ret;
}
-#endif /* PNG_USER_MEM_SUPPORTED */
+#endif /* USER_MEM */
/* This function was added at libpng version 1.2.3. The png_malloc_warn()
* function will issue a png_warning and return NULL instead of issuing a
@@ -244,7 +244,7 @@ png_free_default,(png_const_structrp png_ptr, png_voidp ptr),PNG_DEPRECATED) {
if (png_ptr == NULL || ptr == NULL)
return;
-#endif /* PNG_USER_MEM_SUPPORTED */
+#endif /* USER_MEM */
free(ptr);
}
@@ -277,5 +277,5 @@ png_get_mem_ptr(png_const_structrp png_ptr) return png_ptr->mem_ptr;
}
-#endif /* PNG_USER_MEM_SUPPORTED */
-#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
+#endif /* USER_MEM */
+#endif /* READ || WRITE */
diff --git a/plugins/AdvaImg/src/LibPNG/pngpread.c b/plugins/AdvaImg/src/LibPNG/pngpread.c index eec5983833..77c3873734 100644 --- a/plugins/AdvaImg/src/LibPNG/pngpread.c +++ b/plugins/AdvaImg/src/LibPNG/pngpread.c @@ -1,7 +1,7 @@ /* pngpread.c - read a png file in push mode
*
- * Last changed in libpng 1.6.10 [March 6, 2014]
+ * Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -26,6 +26,13 @@ #define PNG_READ_iTXt_MODE 7
#define PNG_ERROR_MODE 8
+#define PNG_PUSH_SAVE_BUFFER_IF_FULL \
+if (png_ptr->push_length + 4 > png_ptr->buffer_size) \
+ { png_push_save_buffer(png_ptr); return; }
+#define PNG_PUSH_SAVE_BUFFER_IF_LT(N) \
+if (png_ptr->buffer_size < N) \
+ { png_push_save_buffer(png_ptr); return; }
+
void PNGAPI
png_process_data(png_structrp png_ptr, png_inforp info_ptr,
png_bytep buffer, png_size_t buffer_size)
@@ -46,10 +53,10 @@ png_process_data_pause(png_structrp png_ptr, int save) {
if (png_ptr != NULL)
{
- /* It's easiest for the caller if we do the save, then the caller doesn't
+ /* It's easiest for the caller if we do the save; then the caller doesn't
* have to supply the same data again:
*/
- if (save)
+ if (save != 0)
png_push_save_buffer(png_ptr);
else
{
@@ -189,23 +196,18 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) int keep; /* unknown handling method */
#endif
- /* First we make sure we have enough data for the 4 byte chunk name
- * and the 4 byte chunk length before proceeding with decoding the
+ /* First we make sure we have enough data for the 4-byte chunk name
+ * and the 4-byte chunk length before proceeding with decoding the
* chunk data. To fully decode each of these chunks, we also make
- * sure we have enough data in the buffer for the 4 byte CRC at the
+ * sure we have enough data in the buffer for the 4-byte CRC at the
* end of every chunk (except IDAT, which is handled separately).
*/
- if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
+ if ((png_ptr->mode & PNG_HAVE_CHUNK_HEADER) == 0)
{
png_byte chunk_length[4];
png_byte chunk_tag[4];
- if (png_ptr->buffer_size < 8)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_LT(8)
png_push_fill_buffer(png_ptr, chunk_length, 4);
png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
png_reset_crc(png_ptr);
@@ -219,28 +221,28 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) if (chunk_name == png_IDAT)
{
- if (png_ptr->mode & PNG_AFTER_IDAT)
+ if ((png_ptr->mode & PNG_AFTER_IDAT) != 0)
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
/* If we reach an IDAT chunk, this means we have read all of the
* header chunks, and we can start reading the image (or if this
* is called after the image has been read - we have an error).
*/
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
png_error(png_ptr, "Missing IHDR before IDAT");
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
- !(png_ptr->mode & PNG_HAVE_PLTE))
+ (png_ptr->mode & PNG_HAVE_PLTE) == 0)
png_error(png_ptr, "Missing PLTE before IDAT");
png_ptr->mode |= PNG_HAVE_IDAT;
png_ptr->process_mode = PNG_READ_IDAT_MODE;
- if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
+ if ((png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) == 0)
if (png_ptr->push_length == 0)
return;
- if (png_ptr->mode & PNG_AFTER_IDAT)
+ if ((png_ptr->mode & PNG_AFTER_IDAT) != 0)
png_benign_error(png_ptr, "Too many IDATs found");
}
@@ -249,23 +251,13 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) if (png_ptr->push_length != 13)
png_error(png_ptr, "Invalid IHDR length");
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length);
}
else if (chunk_name == png_IEND)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length);
png_ptr->process_mode = PNG_READ_DONE_MODE;
@@ -275,12 +267,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length, keep);
if (chunk_name == png_PLTE)
@@ -290,11 +277,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) else if (chunk_name == png_PLTE)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -313,12 +296,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) #ifdef PNG_READ_gAMA_SUPPORTED
else if (png_ptr->chunk_name == png_gAMA)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -326,12 +304,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) #ifdef PNG_READ_sBIT_SUPPORTED
else if (png_ptr->chunk_name == png_sBIT)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -339,12 +312,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) #ifdef PNG_READ_cHRM_SUPPORTED
else if (png_ptr->chunk_name == png_cHRM)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -352,12 +320,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) #ifdef PNG_READ_sRGB_SUPPORTED
else if (chunk_name == png_sRGB)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -365,12 +328,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) #ifdef PNG_READ_iCCP_SUPPORTED
else if (png_ptr->chunk_name == png_iCCP)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -378,12 +336,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) #ifdef PNG_READ_sPLT_SUPPORTED
else if (chunk_name == png_sPLT)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -391,12 +344,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) #ifdef PNG_READ_tRNS_SUPPORTED
else if (chunk_name == png_tRNS)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -404,12 +352,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) #ifdef PNG_READ_bKGD_SUPPORTED
else if (chunk_name == png_bKGD)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -417,12 +360,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) #ifdef PNG_READ_hIST_SUPPORTED
else if (chunk_name == png_hIST)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -430,12 +368,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) #ifdef PNG_READ_pHYs_SUPPORTED
else if (chunk_name == png_pHYs)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -443,12 +376,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) #ifdef PNG_READ_oFFs_SUPPORTED
else if (chunk_name == png_oFFs)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length);
}
#endif
@@ -456,12 +384,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) #ifdef PNG_READ_pCAL_SUPPORTED
else if (chunk_name == png_pCAL)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -469,12 +392,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) #ifdef PNG_READ_sCAL_SUPPORTED
else if (chunk_name == png_sCAL)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -482,12 +400,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) #ifdef PNG_READ_tIME_SUPPORTED
else if (chunk_name == png_tIME)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -495,12 +408,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) #ifdef PNG_READ_tEXt_SUPPORTED
else if (chunk_name == png_tEXt)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -508,12 +416,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) #ifdef PNG_READ_zTXt_SUPPORTED
else if (chunk_name == png_zTXt)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -521,23 +424,14 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) #ifdef PNG_READ_iTXt_SUPPORTED
else if (chunk_name == png_iTXt)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
}
#endif
else
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length,
PNG_HANDLE_CHUNK_AS_DEFAULT);
}
@@ -555,7 +449,7 @@ png_push_crc_skip(png_structrp png_ptr, png_uint_32 skip) void /* PRIVATE */
png_push_crc_finish(png_structrp png_ptr)
{
- if (png_ptr->skip_length && png_ptr->save_buffer_size)
+ if (png_ptr->skip_length != 0 && png_ptr->save_buffer_size != 0)
{
png_size_t save_size = png_ptr->save_buffer_size;
png_uint_32 skip_length = png_ptr->skip_length;
@@ -579,7 +473,7 @@ png_push_crc_finish(png_structrp png_ptr) png_ptr->save_buffer_size -= save_size;
png_ptr->save_buffer_ptr += save_size;
}
- if (png_ptr->skip_length && png_ptr->current_buffer_size)
+ if (png_ptr->skip_length != 0 && png_ptr->current_buffer_size != 0)
{
png_size_t save_size = png_ptr->current_buffer_size;
png_uint_32 skip_length = png_ptr->skip_length;
@@ -600,14 +494,9 @@ png_push_crc_finish(png_structrp png_ptr) png_ptr->current_buffer_size -= save_size;
png_ptr->current_buffer_ptr += save_size;
}
- if (!png_ptr->skip_length)
+ if (png_ptr->skip_length == 0)
{
- if (png_ptr->buffer_size < 4)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_LT(4)
png_crc_finish(png_ptr, 0);
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
}
@@ -622,7 +511,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) return;
ptr = buffer;
- if (png_ptr->save_buffer_size)
+ if (png_ptr->save_buffer_size != 0)
{
png_size_t save_size;
@@ -639,7 +528,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) png_ptr->save_buffer_size -= save_size;
png_ptr->save_buffer_ptr += save_size;
}
- if (length && png_ptr->current_buffer_size)
+ if (length != 0 && png_ptr->current_buffer_size != 0)
{
png_size_t save_size;
@@ -659,7 +548,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) void /* PRIVATE */
png_push_save_buffer(png_structrp png_ptr)
{
- if (png_ptr->save_buffer_size)
+ if (png_ptr->save_buffer_size != 0)
{
if (png_ptr->save_buffer_ptr != png_ptr->save_buffer)
{
@@ -695,11 +584,13 @@ png_push_save_buffer(png_structrp png_ptr) if (png_ptr->save_buffer == NULL)
{
png_free(png_ptr, old_buffer);
+ old_buffer = NULL;
png_error(png_ptr, "Insufficient memory for save_buffer");
}
memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
png_free(png_ptr, old_buffer);
+ old_buffer = NULL;
png_ptr->save_buffer_max = new_max;
}
if (png_ptr->current_buffer_size)
@@ -726,18 +617,13 @@ png_push_restore_buffer(png_structrp png_ptr, png_bytep buffer, void /* PRIVATE */
png_push_read_IDAT(png_structrp png_ptr)
{
- if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
+ if ((png_ptr->mode & PNG_HAVE_CHUNK_HEADER) == 0)
{
png_byte chunk_length[4];
png_byte chunk_tag[4];
/* TODO: this code can be commoned up with the same code in push_read */
- if (png_ptr->buffer_size < 8)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_LT(8)
png_push_fill_buffer(png_ptr, chunk_length, 4);
png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
png_reset_crc(png_ptr);
@@ -749,7 +635,7 @@ png_push_read_IDAT(png_structrp png_ptr) {
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
- if (!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
+ if ((png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0)
png_error(png_ptr, "Not enough compressed data");
return;
@@ -758,7 +644,7 @@ png_push_read_IDAT(png_structrp png_ptr) png_ptr->idat_size = png_ptr->push_length;
}
- if (png_ptr->idat_size && png_ptr->save_buffer_size)
+ if (png_ptr->idat_size != 0 && png_ptr->save_buffer_size != 0)
{
png_size_t save_size = png_ptr->save_buffer_size;
png_uint_32 idat_size = png_ptr->idat_size;
@@ -785,7 +671,7 @@ png_push_read_IDAT(png_structrp png_ptr) png_ptr->save_buffer_ptr += save_size;
}
- if (png_ptr->idat_size && png_ptr->current_buffer_size)
+ if (png_ptr->idat_size != 0 && png_ptr->current_buffer_size != 0)
{
png_size_t save_size = png_ptr->current_buffer_size;
png_uint_32 idat_size = png_ptr->idat_size;
@@ -810,14 +696,9 @@ png_push_read_IDAT(png_structrp png_ptr) png_ptr->current_buffer_size -= save_size;
png_ptr->current_buffer_ptr += save_size;
}
- if (!png_ptr->idat_size)
+ if (png_ptr->idat_size == 0)
{
- if (png_ptr->buffer_size < 4)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_LT(4)
png_crc_finish(png_ptr, 0);
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
png_ptr->mode |= PNG_AFTER_IDAT;
@@ -962,7 +843,7 @@ png_push_process_row(png_structrp png_ptr) memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
- if (png_ptr->transformations)
+ if (png_ptr->transformations != 0)
png_do_read_transformations(png_ptr, &row_info);
#endif
@@ -979,15 +860,16 @@ png_push_process_row(png_structrp png_ptr) #ifdef PNG_READ_INTERLACING_SUPPORTED
- /* Blow up interlaced rows to full size */
- if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
+ /* Expand interlaced rows to full size */
+ if (png_ptr->interlaced != 0 &&
+ (png_ptr->transformations & PNG_INTERLACE) != 0)
{
if (png_ptr->pass < 6)
png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass,
png_ptr->transformations);
- switch (png_ptr->pass)
- {
+ switch (png_ptr->pass)
+ {
case 0:
{
int i;
@@ -1154,7 +1036,6 @@ png_push_process_row(png_structrp png_ptr) }
}
else
-#endif
{
png_push_have_row(png_ptr, png_ptr->row_buf + 1);
png_read_push_finish_row(png_ptr);
@@ -1164,7 +1045,6 @@ png_push_process_row(png_structrp png_ptr) void /* PRIVATE */
png_read_push_finish_row(png_structrp png_ptr)
{
-#ifdef PNG_READ_INTERLACING_SUPPORTED
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* Start of interlace block */
@@ -1189,8 +1069,7 @@ png_read_push_finish_row(png_structrp png_ptr) if (png_ptr->row_number < png_ptr->num_rows)
return;
-#ifdef PNG_READ_INTERLACING_SUPPORTED
- if (png_ptr->interlaced)
+ if (png_ptr->interlaced != 0)
{
png_ptr->row_number = 0;
memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
@@ -1214,7 +1093,7 @@ png_read_push_finish_row(png_structrp png_ptr) png_pass_start[png_ptr->pass]) /
png_pass_inc[png_ptr->pass];
- if (png_ptr->transformations & PNG_INTERLACE)
+ if ((png_ptr->transformations & PNG_INTERLACE) != 0)
break;
png_ptr->num_rows = (png_ptr->height +
@@ -1224,7 +1103,6 @@ png_read_push_finish_row(png_structrp png_ptr) } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0);
}
-#endif /* PNG_READ_INTERLACING_SUPPORTED */
}
void /* PRIVATE */
@@ -1249,7 +1127,6 @@ png_push_have_row(png_structrp png_ptr, png_bytep row) (int)png_ptr->pass);
}
-#ifdef PNG_READ_INTERLACING_SUPPORTED
void PNGAPI
png_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row,
png_const_bytep new_row)
@@ -1262,9 +1139,8 @@ png_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row, * it must be png_ptr->row_buf+1
*/
if (new_row != NULL)
- png_combine_row(png_ptr, old_row, 1/*display*/);
+ png_combine_row(png_ptr, old_row, 1/*blocky display*/);
}
-#endif /* PNG_READ_INTERLACING_SUPPORTED */
void PNGAPI
png_set_progressive_read_fn(png_structrp png_ptr, png_voidp progressive_ptr,
@@ -1289,4 +1165,4 @@ png_get_progressive_ptr(png_const_structrp png_ptr) return png_ptr->io_ptr;
}
-#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
+#endif /* PROGRESSIVE_READ */
diff --git a/plugins/AdvaImg/src/LibPNG/pngpriv.h b/plugins/AdvaImg/src/LibPNG/pngpriv.h index db8f33c37b..16ba43344c 100644 --- a/plugins/AdvaImg/src/LibPNG/pngpriv.h +++ b/plugins/AdvaImg/src/LibPNG/pngpriv.h @@ -6,7 +6,7 @@ * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
- * Last changed in libpng 1.6.10 [March 6, 2014]
+ * Last changed in libpng 1.6.10 [March 6, 1014]]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -119,8 +119,12 @@ * PNG_ARM_NEON_OPT is set in CPPFLAGS (to >0) then arm/arm_init.c will fail
* to compile with an appropriate #error if ALIGNED_MEMORY has been turned
* off.
+ *
+ * Note that gcc-4.9 defines __ARM_NEON instead of __ARM_NEON__, so we
+ * check both variants.
*/
-# if defined(__ARM_NEON__) && defined(PNG_ALIGNED_MEMORY_SUPPORTED)
+# if (defined(__ARM_NEON__) || defined(__ARM_NEON)) && \
+ defined(PNG_ALIGNED_MEMORY_SUPPORTED)
# define PNG_ARM_NEON_OPT 2
# else
# define PNG_ARM_NEON_OPT 0
@@ -148,7 +152,7 @@ * libpng implementation list for incorporation in the next minor release.
*/
# ifndef PNG_ARM_NEON_IMPLEMENTATION
-# ifdef __ARM_NEON__
+# if defined(__ARM_NEON__) || defined(__ARM_NEON)
# if defined(__clang__)
/* At present it is unknown by the libpng developers which versions
* of clang support the intrinsics, however some or perhaps all
@@ -168,7 +172,7 @@ */
# define PNG_ARM_NEON_IMPLEMENTATION 2
# endif /* __ARM_NEON__ */
-# endif /* !defined PNG_ARM_NEON_IMPLEMENTATION */
+# endif /* !PNG_ARM_NEON_IMPLEMENTATION */
# ifndef PNG_ARM_NEON_IMPLEMENTATION
/* Use the intrinsics code by default. */
@@ -822,7 +826,7 @@ * zlib version number and because this affects handling of certain broken
* PNG files the -I directives must match.
*
- * The most likely explanation is that you passed a -I in CFLAGS, this will
+ * The most likely explanation is that you passed a -I in CFLAGS. This will
* not work; all the preprocessor directories and in particular all the -I
* directives must be in CPPFLAGS.
*/
@@ -851,7 +855,7 @@ PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]); /* Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB
* encoded value with maximum error 0.646365. Note that the input is not a
* 16-bit value; it has been multiplied by 255! */
-#endif /* PNG_SIMPLIFIED_READ/WRITE */
+#endif /* SIMPLIFIED_READ/WRITE */
/* Inhibit C++ name-mangling for libpng functions but not for system calls. */
@@ -1086,7 +1090,7 @@ PNG_INTERNAL_FUNCTION(void,png_write_tEXt,(png_structrp png_ptr, #ifdef PNG_WRITE_zTXt_SUPPORTED
PNG_INTERNAL_FUNCTION(void,png_write_zTXt,(png_structrp png_ptr, png_const_charp
- key, png_const_charp text, png_size_t text_len, int compression),PNG_EMPTY);
+ key, png_const_charp text, int compression),PNG_EMPTY);
#endif
#ifdef PNG_WRITE_iTXt_SUPPORTED
@@ -1225,7 +1229,7 @@ PNG_INTERNAL_FUNCTION(void,png_read_finish_IDAT,(png_structrp png_ptr), PNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr),
PNG_EMPTY);
/* Finish a row while reading, dealing with interlacing passes, etc. */
-#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
+#endif /* SEQUENTIAL_READ */
/* Initialize the row buffers, etc. */
PNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY);
@@ -1301,7 +1305,7 @@ PNG_INTERNAL_FUNCTION(void,png_handle_hIST,(png_structrp png_ptr, #ifdef PNG_READ_iCCP_SUPPORTED
PNG_INTERNAL_FUNCTION(void,png_handle_iCCP,(png_structrp png_ptr,
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif /* PNG_READ_iCCP_SUPPORTED */
+#endif /* READ_iCCP */
#ifdef PNG_READ_iTXt_SUPPORTED
PNG_INTERNAL_FUNCTION(void,png_handle_iTXt,(png_structrp png_ptr,
@@ -1336,7 +1340,7 @@ PNG_INTERNAL_FUNCTION(void,png_handle_sCAL,(png_structrp png_ptr, #ifdef PNG_READ_sPLT_SUPPORTED
PNG_INTERNAL_FUNCTION(void,png_handle_sPLT,(png_structrp png_ptr,
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif /* PNG_READ_sPLT_SUPPORTED */
+#endif /* READ_sPLT */
#ifdef PNG_READ_sRGB_SUPPORTED
PNG_INTERNAL_FUNCTION(void,png_handle_sRGB,(png_structrp png_ptr,
@@ -1450,7 +1454,7 @@ PNG_INTERNAL_FUNCTION(void,png_push_read_iTXt,(png_structrp png_ptr, png_inforp info_ptr),PNG_EMPTY);
# endif
-#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
+#endif /* PROGRESSIVE_READ */
/* Added at libpng version 1.6.0 */
#ifdef PNG_GAMMA_SUPPORTED
diff --git a/plugins/AdvaImg/src/LibPNG/pngread.c b/plugins/AdvaImg/src/LibPNG/pngread.c index 4b80ef2d46..1fe928f37f 100644 --- a/plugins/AdvaImg/src/LibPNG/pngread.c +++ b/plugins/AdvaImg/src/LibPNG/pngread.c @@ -1,7 +1,7 @@ /* pngread.c - read a PNG file
*
- * Last changed in libpng 1.6.10 [March 6, 2014]
+ * Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -44,7 +44,7 @@ png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr, {
png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);
-#endif /* PNG_USER_MEM_SUPPORTED */
+#endif /* USER_MEM */
if (png_ptr != NULL)
{
@@ -113,20 +113,20 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr) */
if (chunk_name == png_IDAT)
{
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
png_chunk_error(png_ptr, "Missing IHDR before IDAT");
else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
- !(png_ptr->mode & PNG_HAVE_PLTE))
+ (png_ptr->mode & PNG_HAVE_PLTE) == 0)
png_chunk_error(png_ptr, "Missing PLTE before IDAT");
- else if (png_ptr->mode & PNG_AFTER_IDAT)
+ else if ((png_ptr->mode & PNG_AFTER_IDAT) != 0)
png_chunk_benign_error(png_ptr, "Too many IDATs found");
png_ptr->mode |= PNG_HAVE_IDAT;
}
- else if (png_ptr->mode & PNG_HAVE_IDAT)
+ else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
png_ptr->mode |= PNG_AFTER_IDAT;
/* This should be a binary subdivision search or a hash for
@@ -252,7 +252,7 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr) PNG_HANDLE_CHUNK_AS_DEFAULT);
}
}
-#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
+#endif /* SEQUENTIAL_READ */
/* Optional call to update the users info_ptr structure */
void PNGAPI
@@ -302,7 +302,7 @@ png_start_read_image(png_structrp png_ptr) "png_start_read_image/png_read_update_info: duplicate call");
}
}
-#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
+#endif /* SEQUENTIAL_READ */
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
#ifdef PNG_MNG_FEATURES_SUPPORTED
@@ -315,7 +315,7 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row) png_debug(1, "in png_do_read_intrapixel");
if (
- (row_info->color_type & PNG_COLOR_MASK_COLOR))
+ (row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
{
int bytes_per_pixel;
png_uint_32 row_width = row_info->width;
@@ -369,7 +369,7 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row) }
}
}
-#endif /* PNG_MNG_FEATURES_SUPPORTED */
+#endif /* MNG_FEATURES */
void PNGAPI
png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
@@ -385,7 +385,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) /* png_read_start_row sets the information (in particular iwidth) for this
* interlace pass.
*/
- if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
+ if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0)
png_read_start_row(png_ptr);
/* 1.5.6: row_info moved out of png_struct to a local here. */
@@ -396,45 +396,47 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) row_info.pixel_depth = png_ptr->pixel_depth;
row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width);
+#ifdef PNG_WARNINGS_SUPPORTED
if (png_ptr->row_number == 0 && png_ptr->pass == 0)
{
/* Check for transforms that have been set but were defined out */
#if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED)
- if (png_ptr->transformations & PNG_INVERT_MONO)
+ if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined");
#endif
#if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED)
- if (png_ptr->transformations & PNG_FILLER)
+ if ((png_ptr->transformations & PNG_FILLER) != 0)
png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined");
#endif
#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \
!defined(PNG_READ_PACKSWAP_SUPPORTED)
- if (png_ptr->transformations & PNG_PACKSWAP)
+ if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined");
#endif
#if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED)
- if (png_ptr->transformations & PNG_PACK)
+ if ((png_ptr->transformations & PNG_PACK) != 0)
png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined");
#endif
#if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED)
- if (png_ptr->transformations & PNG_SHIFT)
+ if ((png_ptr->transformations & PNG_SHIFT) != 0)
png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined");
#endif
#if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED)
- if (png_ptr->transformations & PNG_BGR)
+ if ((png_ptr->transformations & PNG_BGR) != 0)
png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined");
#endif
#if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED)
- if (png_ptr->transformations & PNG_SWAP_BYTES)
+ if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined");
#endif
}
+#endif /* WARNINGS */
#ifdef PNG_READ_INTERLACING_SUPPORTED
/* If interlaced and we do not need a new row, combine row and return.
@@ -443,7 +445,8 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) * untransformed) and, because of the libpng API for interlaced images, this
* means we must transform before de-interlacing.
*/
- if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
+ if (png_ptr->interlaced != 0 &&
+ (png_ptr->transformations & PNG_INTERLACE) != 0)
{
switch (png_ptr->pass)
{
@@ -514,7 +517,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) default:
case 6:
- if (!(png_ptr->row_number & 1))
+ if ((png_ptr->row_number & 1) == 0)
{
png_read_finish_row(png_ptr);
return;
@@ -524,7 +527,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) }
#endif
- if (!(png_ptr->mode & PNG_HAVE_IDAT))
+ if ((png_ptr->mode & PNG_HAVE_IDAT) == 0)
png_error(png_ptr, "Invalid attempt to read row data");
/* Fill the row with IDAT data: */
@@ -547,7 +550,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);
#ifdef PNG_MNG_FEATURES_SUPPORTED
- if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
+ if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
(png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
{
/* Intrapixel differencing */
@@ -572,9 +575,9 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) png_error(png_ptr, "internal sequential row size calculation error");
#ifdef PNG_READ_INTERLACING_SUPPORTED
- /* Blow up interlaced rows to full size */
- if (png_ptr->interlaced &&
- (png_ptr->transformations & PNG_INTERLACE))
+ /* Expand interlaced rows to full size */
+ if (png_ptr->interlaced != 0 &&
+ (png_ptr->transformations & PNG_INTERLACE) != 0)
{
if (png_ptr->pass < 6)
png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass,
@@ -602,7 +605,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) (*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);
}
-#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
+#endif /* SEQUENTIAL_READ */
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
/* Read one or more rows of image data. If the image is interlaced,
@@ -669,7 +672,7 @@ png_read_rows(png_structrp png_ptr, png_bytepp row, dp++;
}
}
-#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
+#endif /* SEQUENTIAL_READ */
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
/* Read the entire image. If the image has an alpha channel or a tRNS
@@ -697,7 +700,7 @@ png_read_image(png_structrp png_ptr, png_bytepp image) return;
#ifdef PNG_READ_INTERLACING_SUPPORTED
- if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
+ if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0)
{
pass = png_set_interlace_handling(png_ptr);
/* And make sure transforms are initialized. */
@@ -705,7 +708,8 @@ png_read_image(png_structrp png_ptr, png_bytepp image) }
else
{
- if (png_ptr->interlaced && !(png_ptr->transformations & PNG_INTERLACE))
+ if (png_ptr->interlaced != 0 &&
+ (png_ptr->transformations & PNG_INTERLACE) == 0)
{
/* Caller called png_start_read_image or png_read_update_info without
* first turning on the PNG_INTERLACE transform. We can fix this here,
@@ -742,7 +746,7 @@ png_read_image(png_structrp png_ptr, png_bytepp image) }
}
}
-#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
+#endif /* SEQUENTIAL_READ */
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
/* Read the end of the PNG file. Will not read past the end of the
@@ -765,7 +769,7 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr) * still be pending IDAT data and an owned zstream. Deal with this here.
*/
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
- if (!png_chunk_unknown_handling(png_ptr, png_IDAT))
+ if (png_chunk_unknown_handling(png_ptr, png_IDAT) == 0)
#endif
png_read_finish_IDAT(png_ptr);
@@ -795,7 +799,8 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr) {
if (chunk_name == png_IDAT)
{
- if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
+ if ((length > 0) ||
+ (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
png_benign_error(png_ptr, "Too many IDATs found");
}
png_handle_unknown(png_ptr, info_ptr, length, keep);
@@ -809,7 +814,8 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr) /* Zero length IDATs are legal after the last IDAT has been
* read, but not after other chunks have been read.
*/
- if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
+ if ((length > 0) ||
+ (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
png_benign_error(png_ptr, "Too many IDATs found");
png_crc_finish(png_ptr, length);
@@ -905,9 +911,9 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr) else
png_handle_unknown(png_ptr, info_ptr, length,
PNG_HANDLE_CHUNK_AS_DEFAULT);
- } while (!(png_ptr->mode & PNG_HAVE_IEND));
+ } while ((png_ptr->mode & PNG_HAVE_IEND) == 0);
}
-#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
+#endif /* SEQUENTIAL_READ */
/* Free all memory used in the read struct */
static void
@@ -920,22 +926,33 @@ png_read_destroy(png_structrp png_ptr) #endif
png_free(png_ptr, png_ptr->big_row_buf);
+ png_ptr->big_row_buf = NULL;
png_free(png_ptr, png_ptr->big_prev_row);
+ png_ptr->big_prev_row = NULL;
png_free(png_ptr, png_ptr->read_buffer);
+ png_ptr->read_buffer = NULL;
#ifdef PNG_READ_QUANTIZE_SUPPORTED
png_free(png_ptr, png_ptr->palette_lookup);
+ png_ptr->palette_lookup = NULL;
png_free(png_ptr, png_ptr->quantize_index);
+ png_ptr->quantize_index = NULL;
#endif
- if (png_ptr->free_me & PNG_FREE_PLTE)
+ if ((png_ptr->free_me & PNG_FREE_PLTE) != 0)
+ {
png_zfree(png_ptr, png_ptr->palette);
+ png_ptr->palette = NULL;
+ }
png_ptr->free_me &= ~PNG_FREE_PLTE;
#if defined(PNG_tRNS_SUPPORTED) || \
defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
- if (png_ptr->free_me & PNG_FREE_TRNS)
+ if ((png_ptr->free_me & PNG_FREE_TRNS) != 0)
+ {
png_free(png_ptr, png_ptr->trans_alpha);
+ png_ptr->trans_alpha = NULL;
+ }
png_ptr->free_me &= ~PNG_FREE_TRNS;
#endif
@@ -943,15 +960,18 @@ png_read_destroy(png_structrp png_ptr) #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
png_free(png_ptr, png_ptr->save_buffer);
+ png_ptr->save_buffer = NULL;
#endif
-#if defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) &&\
+#if defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) && \
defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
png_free(png_ptr, png_ptr->unknown_chunk.data);
+ png_ptr->unknown_chunk.data = NULL;
#endif
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
png_free(png_ptr, png_ptr->chunk_list);
+ png_ptr->chunk_list = NULL;
#endif
/* NOTE: the 'setjmp' buffer may still be allocated and the memory and error
@@ -1023,7 +1043,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr, /* Tell libpng to strip 16-bit/color files down to 8 bits per color.
*/
- if (transforms & PNG_TRANSFORM_SCALE_16)
+ if ((transforms & PNG_TRANSFORM_SCALE_16) != 0)
/* Added at libpng-1.5.4. "strip_16" produces the same result that it
* did in earlier versions, while "scale_16" is now more accurate.
*/
@@ -1037,7 +1057,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr, * latter by doing SCALE first. This is ok and allows apps not to check for
* which is supported to get the right answer.
*/
- if (transforms & PNG_TRANSFORM_STRIP_16)
+ if ((transforms & PNG_TRANSFORM_STRIP_16) != 0)
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
png_set_strip_16(png_ptr);
#else
@@ -1047,7 +1067,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr, /* Strip alpha bytes from the input data without combining with
* the background (not recommended).
*/
- if (transforms & PNG_TRANSFORM_STRIP_ALPHA)
+ if ((transforms & PNG_TRANSFORM_STRIP_ALPHA) != 0)
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
png_set_strip_alpha(png_ptr);
#else
@@ -1057,7 +1077,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr, /* Extract multiple pixels with bit depths of 1, 2, or 4 from a single
* byte into separate bytes (useful for paletted and grayscale images).
*/
- if (transforms & PNG_TRANSFORM_PACKING)
+ if ((transforms & PNG_TRANSFORM_PACKING) != 0)
#ifdef PNG_READ_PACK_SUPPORTED
png_set_packing(png_ptr);
#else
@@ -1067,7 +1087,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr, /* Change the order of packed pixels to least significant bit first
* (not useful if you are using png_set_packing).
*/
- if (transforms & PNG_TRANSFORM_PACKSWAP)
+ if ((transforms & PNG_TRANSFORM_PACKSWAP) != 0)
#ifdef PNG_READ_PACKSWAP_SUPPORTED
png_set_packswap(png_ptr);
#else
@@ -1079,7 +1099,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr, * Expand paletted or RGB images with transparency to full alpha
* channels so the data will be available as RGBA quartets.
*/
- if (transforms & PNG_TRANSFORM_EXPAND)
+ if ((transforms & PNG_TRANSFORM_EXPAND) != 0)
#ifdef PNG_READ_EXPAND_SUPPORTED
png_set_expand(png_ptr);
#else
@@ -1091,7 +1111,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr, /* Invert monochrome files to have 0 as white and 1 as black
*/
- if (transforms & PNG_TRANSFORM_INVERT_MONO)
+ if ((transforms & PNG_TRANSFORM_INVERT_MONO) != 0)
#ifdef PNG_READ_INVERT_SUPPORTED
png_set_invert_mono(png_ptr);
#else
@@ -1102,16 +1122,16 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr, * [0,65535] to the original [0,7] or [0,31], or whatever range the
* colors were originally in:
*/
- if (transforms & PNG_TRANSFORM_SHIFT)
+ if ((transforms & PNG_TRANSFORM_SHIFT) != 0)
#ifdef PNG_READ_SHIFT_SUPPORTED
- if (info_ptr->valid & PNG_INFO_sBIT)
+ if ((info_ptr->valid & PNG_INFO_sBIT) != 0)
png_set_shift(png_ptr, &info_ptr->sig_bit);
#else
png_app_error(png_ptr, "PNG_TRANSFORM_SHIFT not supported");
#endif
/* Flip the RGB pixels to BGR (or RGBA to BGRA) */
- if (transforms & PNG_TRANSFORM_BGR)
+ if ((transforms & PNG_TRANSFORM_BGR) != 0)
#ifdef PNG_READ_BGR_SUPPORTED
png_set_bgr(png_ptr);
#else
@@ -1119,7 +1139,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr, #endif
/* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
- if (transforms & PNG_TRANSFORM_SWAP_ALPHA)
+ if ((transforms & PNG_TRANSFORM_SWAP_ALPHA) != 0)
#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED
png_set_swap_alpha(png_ptr);
#else
@@ -1127,7 +1147,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr, #endif
/* Swap bytes of 16-bit files to least significant byte first */
- if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
+ if ((transforms & PNG_TRANSFORM_SWAP_ENDIAN) != 0)
#ifdef PNG_READ_SWAP_SUPPORTED
png_set_swap(png_ptr);
#else
@@ -1136,7 +1156,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr, /* Added at libpng-1.2.41 */
/* Invert the alpha channel from opacity to transparency */
- if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
+ if ((transforms & PNG_TRANSFORM_INVERT_ALPHA) != 0)
#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
png_set_invert_alpha(png_ptr);
#else
@@ -1145,7 +1165,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr, /* Added at libpng-1.2.41 */
/* Expand grayscale image to RGB */
- if (transforms & PNG_TRANSFORM_GRAY_TO_RGB)
+ if ((transforms & PNG_TRANSFORM_GRAY_TO_RGB) != 0)
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
png_set_gray_to_rgb(png_ptr);
#else
@@ -1153,7 +1173,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr, #endif
/* Added at libpng-1.5.4 */
- if (transforms & PNG_TRANSFORM_EXPAND_16)
+ if ((transforms & PNG_TRANSFORM_EXPAND_16) != 0)
#ifdef PNG_READ_EXPAND_16_SUPPORTED
png_set_expand_16(png_ptr);
#else
@@ -1201,8 +1221,8 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr, PNG_UNUSED(params)
}
-#endif /* PNG_INFO_IMAGE_SUPPORTED */
-#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
+#endif /* INFO_IMAGE */
+#endif /* SEQUENTIAL_READ */
#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
/* SIMPLIFIED READ
@@ -1220,7 +1240,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr, # define P_LINEAR8 4 /* 8-bit linear: only from a file value */
/* Color-map processing: after libpng has run on the PNG image further
- * processing may be needed to conver the data to color-map indicies.
+ * processing may be needed to convert the data to color-map indices.
*/
#define PNG_CMAP_NONE 0
#define PNG_CMAP_GA 1 /* Process GA data to a color-map with alpha */
@@ -1311,10 +1331,10 @@ png_image_format(png_structrp png_ptr) {
png_uint_32 format = 0;
- if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)
+ if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
format |= PNG_FORMAT_FLAG_COLOR;
- if (png_ptr->color_type & PNG_COLOR_MASK_ALPHA)
+ if ((png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)
format |= PNG_FORMAT_FLAG_ALPHA;
/* Use png_ptr here, not info_ptr, because by examination png_handle_tRNS
@@ -1328,7 +1348,7 @@ png_image_format(png_structrp png_ptr) if (png_ptr->bit_depth == 16)
format |= PNG_FORMAT_FLAG_LINEAR;
- if (png_ptr->color_type & PNG_COLOR_MASK_PALETTE)
+ if ((png_ptr->color_type & PNG_COLOR_MASK_PALETTE) != 0)
format |= PNG_FORMAT_FLAG_COLORMAP;
return format;
@@ -1428,7 +1448,7 @@ png_image_begin_read_from_stdio(png_imagep image, FILE* file) {
if (file != NULL)
{
- if (png_image_read_init(image))
+ if (png_image_read_init(image) != 0)
{
/* This is slightly evil, but png_init_io doesn't do anything other
* than this and we haven't changed the standard IO functions so
@@ -1462,7 +1482,7 @@ png_image_begin_read_from_file(png_imagep image, const char *file_name) if (fp != NULL)
{
- if (png_image_read_init(image))
+ if (png_image_read_init(image) != 0)
{
image->opaque->png_ptr->io_ptr = fp;
image->opaque->owned_file = 1;
@@ -1488,7 +1508,7 @@ png_image_begin_read_from_file(png_imagep image, const char *file_name) return 0;
}
-#endif /* PNG_STDIO_SUPPORTED */
+#endif /* STDIO */
static void PNGCBAPI
png_image_memory_read(png_structp png_ptr, png_bytep out, png_size_t need)
@@ -1527,7 +1547,7 @@ int PNGAPI png_image_begin_read_from_memory(png_imagep image, {
if (memory != NULL && size > 0)
{
- if (png_image_read_init(image))
+ if (png_image_read_init(image) != 0)
{
/* Now set the IO functions to read from the memory buffer and
* store it into io_ptr. Again do this in-place to avoid calling a
@@ -1599,14 +1619,14 @@ png_image_skip_unused_chunks(png_structrp png_ptr) /* But do not ignore image data handling chunks */
png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_AS_DEFAULT,
- chunks_to_process, (sizeof chunks_to_process)/5);
+ chunks_to_process, (int)/*SAFE*/(sizeof chunks_to_process)/5);
}
}
# define PNG_SKIP_CHUNKS(p) png_image_skip_unused_chunks(p)
#else
# define PNG_SKIP_CHUNKS(p) ((void)0)
-#endif /* PNG_HANDLE_AS_UNKNOWN_SUPPORTED */
+#endif /* HANDLE_AS_UNKNOWN */
/* The following macro gives the exact rounded answer for all values in the
* range 0..255 (it actually divides by 51.2, but the rounding still generates
@@ -1619,9 +1639,9 @@ static void set_file_encoding(png_image_read_control *display)
{
png_fixed_point g = display->image->opaque->png_ptr->colorspace.gamma;
- if (png_gamma_significant(g))
+ if (png_gamma_significant(g) != 0)
{
- if (png_gamma_not_sRGB(g))
+ if (png_gamma_not_sRGB(g) != 0)
{
display->file_encoding = P_FILE;
display->gamma_to_linear = png_reciprocal(g);
@@ -1716,7 +1736,7 @@ png_create_colormap_entry(png_image_read_control *display, png_uint_32 alpha, int encoding)
{
png_imagep image = display->image;
- const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) ?
+ const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
P_LINEAR : P_sRGB;
const int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 &&
(red != green || green != blue);
@@ -1746,7 +1766,7 @@ png_create_colormap_entry(png_image_read_control *display, green = png_gamma_16bit_correct(green*257, g);
blue = png_gamma_16bit_correct(blue*257, g);
- if (convert_to_Y || output_encoding == P_LINEAR)
+ if (convert_to_Y != 0 || output_encoding == P_LINEAR)
{
alpha *= 257;
encoding = P_LINEAR;
@@ -1773,7 +1793,8 @@ png_create_colormap_entry(png_image_read_control *display, encoding = P_LINEAR;
}
- else if (encoding == P_sRGB && (convert_to_Y || output_encoding == P_LINEAR))
+ else if (encoding == P_sRGB &&
+ (convert_to_Y != 0 || output_encoding == P_LINEAR))
{
/* The values are 8-bit sRGB values, but must be converted to 16-bit
* linear.
@@ -1788,7 +1809,7 @@ png_create_colormap_entry(png_image_read_control *display, /* This is set if the color isn't gray but the output is. */
if (encoding == P_LINEAR)
{
- if (convert_to_Y)
+ if (convert_to_Y != 0)
{
/* NOTE: these values are copied from png_do_rgb_to_gray */
png_uint_32 y = (png_uint_32)6968 * red + (png_uint_32)23434 * green +
@@ -1831,7 +1852,7 @@ png_create_colormap_entry(png_image_read_control *display, # define afirst 0
# endif
# ifdef PNG_FORMAT_BGR_SUPPORTED
- const int bgr = (image->format & PNG_FORMAT_FLAG_BGR) ? 2 : 0;
+ const int bgr = (image->format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
# else
# define bgr 0
# endif
@@ -2043,7 +2064,7 @@ png_image_read_colormap(png_voidp argument) const png_structrp png_ptr = image->opaque->png_ptr;
const png_uint_32 output_format = image->format;
- const int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) ?
+ const int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
P_LINEAR : P_sRGB;
unsigned int cmap_entries;
@@ -2082,7 +2103,7 @@ png_image_read_colormap(png_voidp argument) else
{
back_g = display->background->green;
- if (output_format & PNG_FORMAT_FLAG_COLOR)
+ if ((output_format & PNG_FORMAT_FLAG_COLOR) != 0)
{
back_r = display->background->red;
back_b = display->background->blue;
@@ -2187,7 +2208,7 @@ png_image_read_colormap(png_voidp argument) data_encoding = P_FILE;
/* The rows from libpng, while technically gray values, are now also
- * color-map indicies; however, they may need to be expanded to 1
+ * color-map indices; however, they may need to be expanded to 1
* byte per pixel. This is what png_set_packing does (i.e., it
* unpacks the bit values into bytes.)
*/
@@ -2224,7 +2245,7 @@ png_image_read_colormap(png_voidp argument) {
unsigned int back_alpha;
- if (output_format & PNG_FORMAT_FLAG_ALPHA)
+ if ((output_format & PNG_FORMAT_FLAG_ALPHA) != 0)
back_alpha = 0;
else
@@ -2273,8 +2294,8 @@ png_image_read_colormap(png_voidp argument) * 8-bit GA and it has to be processing to single byte color-map
* values. Entry 254 is replaced by either a completely
* transparent entry or by the background color at full
- * precision (and the background color is not a simple gray leve
- * in this case.)
+ * precision (and the background color is not a simple gray
+ * level in this case.)
*/
expand_tRNS = 1;
output_processing = PNG_CMAP_TRANS;
@@ -2305,7 +2326,7 @@ png_image_read_colormap(png_voidp argument) */
data_encoding = P_sRGB;
- if (output_format & PNG_FORMAT_FLAG_ALPHA)
+ if ((output_format & PNG_FORMAT_FLAG_ALPHA) != 0)
{
if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries)
png_error(png_ptr, "gray+alpha color-map: too few entries");
@@ -2500,7 +2521,7 @@ png_image_read_colormap(png_voidp argument) */
if ((png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
png_ptr->num_trans > 0) &&
- png_gamma_not_sRGB(png_ptr->colorspace.gamma))
+ png_gamma_not_sRGB(png_ptr->colorspace.gamma) != 0)
{
cmap_entries = make_gray_file_colormap(display);
data_encoding = P_FILE;
@@ -2588,7 +2609,7 @@ png_image_read_colormap(png_voidp argument) /* Is there alpha in the output too? If so all four channels are
* processed into a special RGB cube with alpha support.
*/
- if (output_format & PNG_FORMAT_FLAG_ALPHA)
+ if ((output_format & PNG_FORMAT_FLAG_ALPHA) != 0)
{
png_uint_32 r;
@@ -2752,7 +2773,7 @@ png_image_read_colormap(png_voidp argument) num_trans = 0;
output_processing = PNG_CMAP_NONE;
- data_encoding = P_FILE; /* Don't change from color-map indicies */
+ data_encoding = P_FILE; /* Don't change from color-map indices */
cmap_entries = png_ptr->num_palette;
if (cmap_entries > 256)
cmap_entries = 256;
@@ -2762,7 +2783,7 @@ png_image_read_colormap(png_voidp argument) for (i=0; i < cmap_entries; ++i)
{
- if (do_background && i < num_trans && trans[i] < 255)
+ if (do_background != 0 && i < num_trans && trans[i] < 255)
{
if (trans[i] == 0)
png_create_colormap_entry(display, i, back_r, back_g,
@@ -2792,7 +2813,7 @@ png_image_read_colormap(png_voidp argument) i < num_trans ? trans[i] : 255U, P_FILE/*8-bit*/);
}
- /* The PNG data may have indicies packed in fewer than 8 bits, it
+ /* The PNG data may have indices packed in fewer than 8 bits, it
* must be expanded if so.
*/
if (png_ptr->bit_depth < 8)
@@ -2807,8 +2828,8 @@ png_image_read_colormap(png_voidp argument) }
/* Now deal with the output processing */
- if (expand_tRNS && png_ptr->num_trans > 0 &&
- (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) == 0)
+ if (expand_tRNS != 0 && png_ptr->num_trans > 0 &&
+ (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) == 0)
png_set_tRNS_to_alpha(png_ptr);
switch (data_encoding)
@@ -3224,7 +3245,8 @@ png_image_read_composite(png_voidp argument) png_uint_32 height = image->height;
png_uint_32 width = image->width;
ptrdiff_t step_row = display->row_bytes;
- unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1;
+ unsigned int channels =
+ (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
int pass;
for (pass = 0; pass < passes; ++pass)
@@ -3317,11 +3339,11 @@ png_image_read_composite(png_voidp argument) * PNG_COMPOSITE
* PNG_GAMMA
*
- * This is a work-round for the fact that both the PNG_RGB_TO_GRAY and
+ * This is a work-around for the fact that both the PNG_RGB_TO_GRAY and
* PNG_COMPOSITE code performs gamma correction, so we get double gamma
- * correction. The fix-up is to prevent the PNG_COMPOSITE operation happening
- * inside libpng, so this routine sees an 8 or 16-bit gray+alpha row and handles
- * the removal or pre-multiplication of the alpha channel.
+ * correction. The fix-up is to prevent the PNG_COMPOSITE operation from
+ * happening inside libpng, so this routine sees an 8 or 16-bit gray+alpha
+ * row and handles the removal or pre-multiplication of the alpha channel.
*/
static int
png_image_read_background(png_voidp argument)
@@ -3522,7 +3544,8 @@ png_image_read_background(png_voidp argument) int swap_alpha = 0;
# ifdef PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED
- if (preserve_alpha && (image->format & PNG_FORMAT_FLAG_AFIRST))
+ if (preserve_alpha != 0 &&
+ (image->format & PNG_FORMAT_FLAG_AFIRST) != 0)
swap_alpha = 1;
# endif
@@ -3586,7 +3609,7 @@ png_image_read_background(png_voidp argument) component = 0;
outrow[swap_alpha] = (png_uint_16)component;
- if (preserve_alpha)
+ if (preserve_alpha != 0)
outrow[1 ^ swap_alpha] = alpha;
inrow += 2; /* components and alpha channel */
@@ -3631,10 +3654,10 @@ png_image_read_direct(png_voidp argument) int mode; /* alpha mode */
/* Do this first so that we have a record if rgb to gray is happening. */
- if (change & PNG_FORMAT_FLAG_COLOR)
+ if ((change & PNG_FORMAT_FLAG_COLOR) != 0)
{
/* gray<->color transformation required. */
- if (format & PNG_FORMAT_FLAG_COLOR)
+ if ((format & PNG_FORMAT_FLAG_COLOR) != 0)
png_set_gray_to_rgb(png_ptr);
else
@@ -3652,7 +3675,7 @@ png_image_read_direct(png_voidp argument) * enormous change) 'do_local_background' is used to indicate that
* the problem exists.
*/
- if (base_format & PNG_FORMAT_FLAG_ALPHA)
+ if ((base_format & PNG_FORMAT_FLAG_ALPHA) != 0)
do_local_background = 1/*maybe*/;
png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE,
@@ -3667,8 +3690,8 @@ png_image_read_direct(png_voidp argument) {
png_fixed_point input_gamma_default;
- if ((base_format & PNG_FORMAT_FLAG_LINEAR) &&
- (image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0)
+ if ((base_format & PNG_FORMAT_FLAG_LINEAR) != 0 &&
+ (image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0)
input_gamma_default = PNG_GAMMA_LINEAR;
else
input_gamma_default = PNG_DEFAULT_sRGB;
@@ -3679,12 +3702,12 @@ png_image_read_direct(png_voidp argument) png_set_alpha_mode_fixed(png_ptr, PNG_ALPHA_PNG, input_gamma_default);
}
- if (linear)
+ if (linear != 0)
{
/* If there *is* an alpha channel in the input it must be multiplied
* out; use PNG_ALPHA_STANDARD, otherwise just use PNG_ALPHA_PNG.
*/
- if (base_format & PNG_FORMAT_FLAG_ALPHA)
+ if ((base_format & PNG_FORMAT_FLAG_ALPHA) != 0)
mode = PNG_ALPHA_STANDARD; /* associated alpha */
else
@@ -3705,7 +3728,7 @@ png_image_read_direct(png_voidp argument) *
* TODO: fix libpng and remove this.
*/
- if (do_local_background)
+ if (do_local_background != 0)
{
png_fixed_point gtest;
@@ -3715,7 +3738,7 @@ png_image_read_direct(png_voidp argument) * final value.
*/
if (png_muldiv(>est, output_gamma, png_ptr->colorspace.gamma,
- PNG_FP_1) && !png_gamma_significant(gtest))
+ PNG_FP_1) != 0 && png_gamma_significant(gtest) == 0)
do_local_background = 0;
else if (mode == PNG_ALPHA_STANDARD)
@@ -3728,9 +3751,9 @@ png_image_read_direct(png_voidp argument) }
/* If the bit-depth changes then handle that here. */
- if (change & PNG_FORMAT_FLAG_LINEAR)
+ if ((change & PNG_FORMAT_FLAG_LINEAR) != 0)
{
- if (linear /*16-bit output*/)
+ if (linear != 0 /*16-bit output*/)
png_set_expand_16(png_ptr);
else /* 8-bit output */
@@ -3740,24 +3763,24 @@ png_image_read_direct(png_voidp argument) }
/* Now the background/alpha channel changes. */
- if (change & PNG_FORMAT_FLAG_ALPHA)
+ if ((change & PNG_FORMAT_FLAG_ALPHA) != 0)
{
/* Removing an alpha channel requires composition for the 8-bit
* formats; for the 16-bit it is already done, above, by the
* pre-multiplication and the channel just needs to be stripped.
*/
- if (base_format & PNG_FORMAT_FLAG_ALPHA)
+ if ((base_format & PNG_FORMAT_FLAG_ALPHA) != 0)
{
/* If RGB->gray is happening the alpha channel must be left and the
* operation completed locally.
*
* TODO: fix libpng and remove this.
*/
- if (do_local_background)
+ if (do_local_background != 0)
do_local_background = 2/*required*/;
/* 16-bit output: just remove the channel */
- else if (linear) /* compose on black (well, pre-multiply) */
+ else if (linear != 0) /* compose on black (well, pre-multiply) */
png_set_strip_alpha(png_ptr);
/* 8-bit output: do an appropriate compose */
@@ -3804,14 +3827,14 @@ png_image_read_direct(png_voidp argument) png_uint_32 filler; /* opaque filler */
int where;
- if (linear)
+ if (linear != 0)
filler = 65535;
else
filler = 255;
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
- if (format & PNG_FORMAT_FLAG_AFIRST)
+ if ((format & PNG_FORMAT_FLAG_AFIRST) != 0)
{
where = PNG_FILLER_BEFORE;
change &= ~PNG_FORMAT_FLAG_AFIRST;
@@ -3835,12 +3858,12 @@ png_image_read_direct(png_voidp argument) png_set_alpha_mode_fixed(png_ptr, mode, output_gamma);
# ifdef PNG_FORMAT_BGR_SUPPORTED
- if (change & PNG_FORMAT_FLAG_BGR)
+ if ((change & PNG_FORMAT_FLAG_BGR) != 0)
{
/* Check only the output format; PNG is never BGR; don't do this if
* the output is gray, but fix up the 'format' value in that case.
*/
- if (format & PNG_FORMAT_FLAG_COLOR)
+ if ((format & PNG_FORMAT_FLAG_COLOR) != 0)
png_set_bgr(png_ptr);
else
@@ -3851,14 +3874,14 @@ png_image_read_direct(png_voidp argument) # endif
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
- if (change & PNG_FORMAT_FLAG_AFIRST)
+ if ((change & PNG_FORMAT_FLAG_AFIRST) != 0)
{
/* Only relevant if there is an alpha channel - it's particularly
* important to handle this correctly because do_local_compose may
* be set above and then libpng will keep the alpha channel for this
* code to remove.
*/
- if (format & PNG_FORMAT_FLAG_ALPHA)
+ if ((format & PNG_FORMAT_FLAG_ALPHA) != 0)
{
/* Disable this if doing a local background,
* TODO: remove this when local background is no longer required.
@@ -3877,16 +3900,16 @@ png_image_read_direct(png_voidp argument) /* If the *output* is 16-bit then we need to check for a byte-swap on this
* architecture.
*/
- if (linear)
+ if (linear != 0)
{
PNG_CONST png_uint_16 le = 0x0001;
- if (*(png_const_bytep)&le)
+ if ((*(png_const_bytep) & le) != 0)
png_set_swap(png_ptr);
}
/* If change is not now 0 some transformation is missing - error out. */
- if (change)
+ if (change != 0)
png_error(png_ptr, "png_read_image: unsupported transformation");
}
@@ -3898,7 +3921,7 @@ png_image_read_direct(png_voidp argument) *
* TODO: remove the do_local_background fixup below.
*/
- if (!do_local_compose && do_local_background != 2)
+ if (do_local_compose == 0 && do_local_background != 2)
passes = png_set_interlace_handling(png_ptr);
png_read_update_info(png_ptr, info_ptr);
@@ -3906,13 +3929,13 @@ png_image_read_direct(png_voidp argument) {
png_uint_32 info_format = 0;
- if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)
+ if ((info_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
info_format |= PNG_FORMAT_FLAG_COLOR;
- if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
+ if ((info_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)
{
/* do_local_compose removes this channel below. */
- if (!do_local_compose)
+ if (do_local_compose == 0)
{
/* do_local_background does the same if required. */
if (do_local_background != 2 ||
@@ -3921,21 +3944,21 @@ png_image_read_direct(png_voidp argument) }
}
- else if (do_local_compose) /* internal error */
+ else if (do_local_compose != 0) /* internal error */
png_error(png_ptr, "png_image_read: alpha channel lost");
if (info_ptr->bit_depth == 16)
info_format |= PNG_FORMAT_FLAG_LINEAR;
# ifdef PNG_FORMAT_BGR_SUPPORTED
- if (png_ptr->transformations & PNG_BGR)
+ if ((png_ptr->transformations & PNG_BGR) != 0)
info_format |= PNG_FORMAT_FLAG_BGR;
# endif
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
if (do_local_background == 2)
{
- if (format & PNG_FORMAT_FLAG_AFIRST)
+ if ((format & PNG_FORMAT_FLAG_AFIRST) != 0)
info_format |= PNG_FORMAT_FLAG_AFIRST;
}
@@ -3964,7 +3987,7 @@ png_image_read_direct(png_voidp argument) png_voidp first_row = display->buffer;
ptrdiff_t row_bytes = display->row_stride;
- if (linear)
+ if (linear != 0)
row_bytes *= 2;
/* The following expression is designed to work correctly whether it gives
@@ -3981,7 +4004,7 @@ png_image_read_direct(png_voidp argument) display->row_bytes = row_bytes;
}
- if (do_local_compose)
+ if (do_local_compose != 0)
{
int result;
png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr));
@@ -4064,7 +4087,7 @@ png_image_finish_read(png_imagep image, png_const_colorp background, /* Choose the correct 'end' routine; for the color-map case all the
* setup has already been done.
*/
- if (image->format & PNG_FORMAT_FLAG_COLORMAP)
+ if ((image->format & PNG_FORMAT_FLAG_COLORMAP) != 0)
result =
png_safe_execute(image, png_image_read_colormap, &display) &&
png_safe_execute(image, png_image_read_colormapped, &display);
@@ -4094,5 +4117,5 @@ png_image_finish_read(png_imagep image, png_const_colorp background, return 0;
}
-#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */
-#endif /* PNG_READ_SUPPORTED */
+#endif /* SIMPLIFIED_READ */
+#endif /* READ */
diff --git a/plugins/AdvaImg/src/LibPNG/pngrio.c b/plugins/AdvaImg/src/LibPNG/pngrio.c index 6c02457a0c..9667004c86 100644 --- a/plugins/AdvaImg/src/LibPNG/pngrio.c +++ b/plugins/AdvaImg/src/LibPNG/pngrio.c @@ -1,7 +1,7 @@ /* pngrio.c - functions for data input
*
- * Last changed in libpng 1.6.9 [February 6, 2014]
+ * Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -117,4 +117,4 @@ png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr, png_ptr->output_flush_fn = NULL;
#endif
}
-#endif /* PNG_READ_SUPPORTED */
+#endif /* READ */
diff --git a/plugins/AdvaImg/src/LibPNG/pngrtran.c b/plugins/AdvaImg/src/LibPNG/pngrtran.c index ae5deaeacc..c4dba7f686 100644 --- a/plugins/AdvaImg/src/LibPNG/pngrtran.c +++ b/plugins/AdvaImg/src/LibPNG/pngrtran.c @@ -1,7 +1,7 @@ /* pngrtran.c - transforms the data in a row for PNG readers
*
- * Last changed in libpng 1.6.10 [March 6, 2014]
+ * Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -91,14 +91,15 @@ png_set_crc_action(png_structrp png_ptr, int crit_action, int ancil_action) #ifdef PNG_READ_TRANSFORMS_SUPPORTED
/* Is it OK to set a transformation now? Only if png_start_read_image or
* png_read_update_info have not been called. It is not necessary for the IHDR
- * to have been read in all cases, the parameter allows for this check too.
+ * to have been read in all cases; the need_IHDR parameter allows for this
+ * check too.
*/
static int
png_rtran_ok(png_structrp png_ptr, int need_IHDR)
{
if (png_ptr != NULL)
{
- if (png_ptr->flags & PNG_FLAG_ROW_INIT)
+ if ((png_ptr->flags & PNG_FLAG_ROW_INIT) != 0)
png_app_error(png_ptr,
"invalid after png_start_read_image or png_read_update_info");
@@ -127,7 +128,7 @@ png_set_background_fixed(png_structrp png_ptr, {
png_debug(1, "in png_set_background_fixed");
- if (!png_rtran_ok(png_ptr, 0) || background_color == NULL)
+ if (png_rtran_ok(png_ptr, 0) == 0 || background_color == NULL)
return;
if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN)
@@ -143,7 +144,7 @@ png_set_background_fixed(png_structrp png_ptr, png_ptr->background = *background_color;
png_ptr->background_gamma = background_gamma;
png_ptr->background_gamma_type = (png_byte)(background_gamma_code);
- if (need_expand)
+ if (need_expand != 0)
png_ptr->transformations |= PNG_BACKGROUND_EXPAND;
else
png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND;
@@ -171,7 +172,7 @@ png_set_scale_16(png_structrp png_ptr) {
png_debug(1, "in png_set_scale_16");
- if (!png_rtran_ok(png_ptr, 0))
+ if (png_rtran_ok(png_ptr, 0) == 0)
return;
png_ptr->transformations |= PNG_SCALE_16_TO_8;
@@ -185,7 +186,7 @@ png_set_strip_16(png_structrp png_ptr) {
png_debug(1, "in png_set_strip_16");
- if (!png_rtran_ok(png_ptr, 0))
+ if (png_rtran_ok(png_ptr, 0) == 0)
return;
png_ptr->transformations |= PNG_16_TO_8;
@@ -198,7 +199,7 @@ png_set_strip_alpha(png_structrp png_ptr) {
png_debug(1, "in png_set_strip_alpha");
- if (!png_rtran_ok(png_ptr, 0))
+ if (png_rtran_ok(png_ptr, 0) == 0)
return;
png_ptr->transformations |= PNG_STRIP_ALPHA;
@@ -226,7 +227,7 @@ translate_gamma_flags(png_structrp png_ptr, png_fixed_point output_gamma, # else
PNG_UNUSED(png_ptr)
# endif
- if (is_screen)
+ if (is_screen != 0)
output_gamma = PNG_GAMMA_sRGB;
else
output_gamma = PNG_GAMMA_sRGB_INVERSE;
@@ -235,7 +236,7 @@ translate_gamma_flags(png_structrp png_ptr, png_fixed_point output_gamma, else if (output_gamma == PNG_GAMMA_MAC_18 ||
output_gamma == PNG_FP_1 / PNG_GAMMA_MAC_18)
{
- if (is_screen)
+ if (is_screen != 0)
output_gamma = PNG_GAMMA_MAC_OLD;
else
output_gamma = PNG_GAMMA_MAC_INVERSE;
@@ -279,7 +280,7 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode, png_debug(1, "in png_set_alpha_mode");
- if (!png_rtran_ok(png_ptr, 0))
+ if (png_rtran_ok(png_ptr, 0) == 0)
return;
output_gamma = translate_gamma_flags(png_ptr, output_gamma, 1/*screen*/);
@@ -363,7 +364,7 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode, /* Finally, if pre-multiplying, set the background fields to achieve the
* desired result.
*/
- if (compose)
+ if (compose != 0)
{
/* And obtain alpha pre-multiplication by composing on black: */
memset(&png_ptr->background, 0, (sizeof png_ptr->background));
@@ -371,7 +372,7 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode, png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_FILE;
png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND;
- if (png_ptr->transformations & PNG_COMPOSE)
+ if ((png_ptr->transformations & PNG_COMPOSE) != 0)
png_error(png_ptr,
"conflicting calls to set alpha mode and background");
@@ -415,12 +416,12 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, {
png_debug(1, "in png_set_quantize");
- if (!png_rtran_ok(png_ptr, 0))
+ if (png_rtran_ok(png_ptr, 0) == 0)
return;
png_ptr->transformations |= PNG_QUANTIZE;
- if (!full_quantize)
+ if (full_quantize == 0)
{
int i;
@@ -475,12 +476,12 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, }
}
- if (done)
+ if (done != 0)
break;
}
/* Swap the palette around, and set up a table, if necessary */
- if (full_quantize)
+ if (full_quantize != 0)
{
int j = num_palette;
@@ -663,7 +664,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, num_new_palette--;
palette[png_ptr->index_to_palette[j]]
= palette[num_new_palette];
- if (!full_quantize)
+ if (full_quantize == 0)
{
int k;
@@ -731,7 +732,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, }
png_ptr->num_palette = (png_uint_16)num_palette;
- if (full_quantize)
+ if (full_quantize != 0)
{
int i;
png_bytep distance;
@@ -793,7 +794,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, png_free(png_ptr, distance);
}
}
-#endif /* PNG_READ_QUANTIZE_SUPPORTED */
+#endif /* READ_QUANTIZE */
#ifdef PNG_READ_GAMMA_SUPPORTED
void PNGFAPI
@@ -802,7 +803,7 @@ png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma, {
png_debug(1, "in png_set_gamma_fixed");
- if (!png_rtran_ok(png_ptr, 0))
+ if (png_rtran_ok(png_ptr, 0) == 0)
return;
/* New in libpng-1.5.4 - reserve particular negative values as flags. */
@@ -842,7 +843,7 @@ png_set_gamma(png_structrp png_ptr, double scrn_gamma, double file_gamma) png_set_gamma_fixed(png_ptr, convert_gamma_value(png_ptr, scrn_gamma),
convert_gamma_value(png_ptr, file_gamma));
}
-# endif /* FLOATING_POINT_SUPPORTED */
+# endif /* FLOATING_POINT */
#endif /* READ_GAMMA */
#ifdef PNG_READ_EXPAND_SUPPORTED
@@ -855,7 +856,7 @@ png_set_expand(png_structrp png_ptr) {
png_debug(1, "in png_set_expand");
- if (!png_rtran_ok(png_ptr, 0))
+ if (png_rtran_ok(png_ptr, 0) == 0)
return;
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
@@ -885,7 +886,7 @@ png_set_palette_to_rgb(png_structrp png_ptr) {
png_debug(1, "in png_set_palette_to_rgb");
- if (!png_rtran_ok(png_ptr, 0))
+ if (png_rtran_ok(png_ptr, 0) == 0)
return;
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
@@ -897,7 +898,7 @@ png_set_expand_gray_1_2_4_to_8(png_structrp png_ptr) {
png_debug(1, "in png_set_expand_gray_1_2_4_to_8");
- if (!png_rtran_ok(png_ptr, 0))
+ if (png_rtran_ok(png_ptr, 0) == 0)
return;
png_ptr->transformations |= PNG_EXPAND;
@@ -909,12 +910,12 @@ png_set_tRNS_to_alpha(png_structrp png_ptr) {
png_debug(1, "in png_set_tRNS_to_alpha");
- if (!png_rtran_ok(png_ptr, 0))
+ if (png_rtran_ok(png_ptr, 0) == 0)
return;
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
}
-#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */
+#endif /* READ_EXPAND */
#ifdef PNG_READ_EXPAND_16_SUPPORTED
/* Expand to 16-bit channels, expand the tRNS chunk too (because otherwise
@@ -925,7 +926,7 @@ png_set_expand_16(png_structrp png_ptr) {
png_debug(1, "in png_set_expand_16");
- if (!png_rtran_ok(png_ptr, 0))
+ if (png_rtran_ok(png_ptr, 0) == 0)
return;
png_ptr->transformations |= (PNG_EXPAND_16 | PNG_EXPAND | PNG_EXPAND_tRNS);
@@ -938,7 +939,7 @@ png_set_gray_to_rgb(png_structrp png_ptr) {
png_debug(1, "in png_set_gray_to_rgb");
- if (!png_rtran_ok(png_ptr, 0))
+ if (png_rtran_ok(png_ptr, 0) == 0)
return;
/* Because rgb must be 8 bits or more: */
@@ -956,10 +957,10 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action, /* Need the IHDR here because of the check on color_type below. */
/* TODO: fix this */
- if (!png_rtran_ok(png_ptr, 1))
+ if (png_rtran_ok(png_ptr, 1) == 0)
return;
- switch(error_action)
+ switch (error_action)
{
case PNG_ERROR_ACTION_NONE:
png_ptr->transformations |= PNG_RGB_TO_GRAY;
@@ -998,7 +999,7 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action, png_uint_16 red_int, green_int;
/* NOTE: this calculation does not round, but this behavior is retained
- * for consistency, the inaccuracy is very small. The code here always
+ * for consistency; the inaccuracy is very small. The code here always
* overwrites the coefficients, regardless of whether they have been
* defaulted or set already.
*/
@@ -1091,7 +1092,7 @@ png_gamma_threshold(png_fixed_point screen_gamma, png_fixed_point file_gamma) * the palette.
*/
-/*For the moment 'png_init_palette_transformations' and
+/* For the moment 'png_init_palette_transformations' and
* 'png_init_rgb_transformations' only do some flag canceling optimizations.
* The intent is that these two routines should have palette or rgb operations
* extracted from 'png_init_read_transformations'.
@@ -1131,7 +1132,7 @@ png_init_palette_transformations(png_structrp png_ptr) }
/* If no alpha we can optimize. */
- if (!input_has_alpha)
+ if (input_has_alpha == 0)
{
/* Any alpha means background and associative alpha processing is
* required, however if the alpha is 0 or 1 throughout OPTIMIZE_ALPHA
@@ -1140,7 +1141,7 @@ png_init_palette_transformations(png_structrp png_ptr) png_ptr->transformations &= ~PNG_ENCODE_ALPHA;
png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
- if (!input_has_transparency)
+ if (input_has_transparency == 0)
png_ptr->transformations &= ~(PNG_COMPOSE | PNG_BACKGROUND_EXPAND);
}
@@ -1153,8 +1154,8 @@ png_init_palette_transformations(png_structrp png_ptr) /* The following code cannot be entered in the alpha pre-multiplication case
* because PNG_BACKGROUND_EXPAND is cancelled below.
*/
- if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
- (png_ptr->transformations & PNG_EXPAND))
+ if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) != 0 &&
+ (png_ptr->transformations & PNG_EXPAND) != 0)
{
{
png_ptr->background.red =
@@ -1165,9 +1166,9 @@ png_init_palette_transformations(png_structrp png_ptr) png_ptr->palette[png_ptr->background.index].blue;
#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
- if (png_ptr->transformations & PNG_INVERT_ALPHA)
+ if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0)
{
- if (!(png_ptr->transformations & PNG_EXPAND_tRNS))
+ if ((png_ptr->transformations & PNG_EXPAND_tRNS) == 0)
{
/* Invert the alpha channel (in tRNS) unless the pixels are
* going to be expanded, in which case leave it for later
@@ -1179,10 +1180,10 @@ png_init_palette_transformations(png_structrp png_ptr) png_ptr->trans_alpha[i]);
}
}
-#endif /* PNG_READ_INVERT_ALPHA_SUPPORTED */
+#endif /* READ_INVERT_ALPHA */
}
} /* background expand and (therefore) no alpha association. */
-#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */
+#endif /* READ_EXPAND && READ_BACKGROUND */
}
static void /* PRIVATE */
@@ -1196,7 +1197,7 @@ png_init_rgb_transformations(png_structrp png_ptr) int input_has_transparency = png_ptr->num_trans > 0;
/* If no alpha we can optimize. */
- if (!input_has_alpha)
+ if (input_has_alpha == 0)
{
/* Any alpha means background and associative alpha processing is
* required, however if the alpha is 0 or 1 throughout OPTIMIZE_ALPHA
@@ -1207,7 +1208,7 @@ png_init_rgb_transformations(png_structrp png_ptr) png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
# endif
- if (!input_has_transparency)
+ if (input_has_transparency == 0)
png_ptr->transformations &= ~(PNG_COMPOSE | PNG_BACKGROUND_EXPAND);
}
@@ -1220,9 +1221,9 @@ png_init_rgb_transformations(png_structrp png_ptr) /* The following code cannot be entered in the alpha pre-multiplication case
* because PNG_BACKGROUND_EXPAND is cancelled below.
*/
- if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
- (png_ptr->transformations & PNG_EXPAND) &&
- !(png_ptr->color_type & PNG_COLOR_MASK_COLOR))
+ if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) != 0 &&
+ (png_ptr->transformations & PNG_EXPAND) != 0 &&
+ (png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0)
/* i.e., GRAY or GRAY_ALPHA */
{
{
@@ -1260,14 +1261,14 @@ png_init_rgb_transformations(png_structrp png_ptr) png_ptr->background.red = png_ptr->background.green =
png_ptr->background.blue = (png_uint_16)gray;
- if (!(png_ptr->transformations & PNG_EXPAND_tRNS))
+ if ((png_ptr->transformations & PNG_EXPAND_tRNS) == 0)
{
png_ptr->trans_color.red = png_ptr->trans_color.green =
png_ptr->trans_color.blue = (png_uint_16)trans_gray;
}
}
} /* background expand and (therefore) no alpha association. */
-#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */
+#endif /* READ_EXPAND && READ_BACKGROUND */
}
void /* PRIVATE */
@@ -1336,7 +1337,7 @@ png_init_read_transformations(png_structrp png_ptr) * the code immediately below if the transform can be handled outside the
* row loop.
*/
- if (gamma_correction)
+ if (gamma_correction != 0)
png_ptr->transformations |= PNG_GAMMA;
else
@@ -1345,7 +1346,7 @@ png_init_read_transformations(png_structrp png_ptr) #endif
/* Certain transformations have the effect of preventing other
- * transformations that happen afterward in png_do_read_transformations,
+ * transformations that happen afterward in png_do_read_transformations;
* resolve the interdependencies here. From the code of
* png_do_read_transformations the order is:
*
@@ -1374,8 +1375,8 @@ png_init_read_transformations(png_structrp png_ptr) * 23) PNG_USER_TRANSFORM [must be last]
*/
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
- if ((png_ptr->transformations & PNG_STRIP_ALPHA) &&
- !(png_ptr->transformations & PNG_COMPOSE))
+ if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0 &&
+ (png_ptr->transformations & PNG_COMPOSE) == 0)
{
/* Stripping the alpha channel happens immediately after the 'expand'
* transformations, before all other transformation, so it cancels out
@@ -1401,7 +1402,7 @@ png_init_read_transformations(png_structrp png_ptr) /* If the screen gamma is about 1.0 then the OPTIMIZE_ALPHA and ENCODE_ALPHA
* settings will have no effect.
*/
- if (!png_gamma_significant(png_ptr->screen_gamma))
+ if (png_gamma_significant(png_ptr->screen_gamma) == 0)
{
png_ptr->transformations &= ~PNG_ENCODE_ALPHA;
png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
@@ -1412,7 +1413,7 @@ png_init_read_transformations(png_structrp png_ptr) /* Make sure the coefficients for the rgb to gray conversion are set
* appropriately.
*/
- if (png_ptr->transformations & PNG_RGB_TO_GRAY)
+ if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0)
png_colorspace_set_rgb_coefficients(png_ptr);
#endif
@@ -1433,23 +1434,23 @@ png_init_read_transformations(png_structrp png_ptr) * png_set_background, along with the bit depth, then the code has a record
* of exactly what color space the background is currently in.
*/
- if (png_ptr->transformations & PNG_BACKGROUND_EXPAND)
+ if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) != 0)
{
/* PNG_BACKGROUND_EXPAND: the background is in the file color space, so if
* the file was grayscale the background value is gray.
*/
- if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR))
+ if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0)
png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;
}
- else if (png_ptr->transformations & PNG_COMPOSE)
+ else if ((png_ptr->transformations & PNG_COMPOSE) != 0)
{
/* PNG_COMPOSE: png_set_background was called with need_expand false,
* so the color is in the color space of the output or png_set_alpha_mode
* was called and the color is black. Ignore RGB_TO_GRAY because that
* happens before GRAY_TO_RGB.
*/
- if (png_ptr->transformations & PNG_GRAY_TO_RGB)
+ if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0)
{
if (png_ptr->background.red == png_ptr->background.green &&
png_ptr->background.red == png_ptr->background.blue)
@@ -1459,8 +1460,8 @@ png_init_read_transformations(png_structrp png_ptr) }
}
}
-#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */
-#endif /* PNG_READ_GRAY_TO_RGB_SUPPORTED */
+#endif /* READ_EXPAND && READ_BACKGROUND */
+#endif /* READ_GRAY_TO_RGB */
/* For indexed PNG data (PNG_COLOR_TYPE_PALETTE) many of the transformations
* can be performed directly on the palette, and some (such as rgb to gray)
@@ -1481,10 +1482,10 @@ png_init_read_transformations(png_structrp png_ptr) #if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
defined(PNG_READ_EXPAND_16_SUPPORTED)
- if ((png_ptr->transformations & PNG_EXPAND_16) &&
- (png_ptr->transformations & PNG_COMPOSE) &&
- !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
- png_ptr->bit_depth != 16)
+ if ((png_ptr->transformations & PNG_EXPAND_16) != 0 &&
+ (png_ptr->transformations & PNG_COMPOSE) != 0 &&
+ (png_ptr->transformations & PNG_BACKGROUND_EXPAND) == 0 &&
+ png_ptr->bit_depth != 16)
{
/* TODO: fix this. Because the expand_16 operation is after the compose
* handling the background color must be 8, not 16, bits deep, but the
@@ -1503,15 +1504,15 @@ png_init_read_transformations(png_structrp png_ptr) CHOP(png_ptr->background.gray);
# undef CHOP
}
-#endif /* PNG_READ_BACKGROUND_SUPPORTED && PNG_READ_EXPAND_16_SUPPORTED */
+#endif /* READ_BACKGROUND && READ_EXPAND_16 */
#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
(defined(PNG_READ_SCALE_16_TO_8_SUPPORTED) || \
defined(PNG_READ_STRIP_16_TO_8_SUPPORTED))
- if ((png_ptr->transformations & (PNG_16_TO_8|PNG_SCALE_16_TO_8)) &&
- (png_ptr->transformations & PNG_COMPOSE) &&
- !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
- png_ptr->bit_depth == 16)
+ if ((png_ptr->transformations & (PNG_16_TO_8|PNG_SCALE_16_TO_8)) != 0 &&
+ (png_ptr->transformations & PNG_COMPOSE) != 0 &&
+ (png_ptr->transformations & PNG_BACKGROUND_EXPAND) == 0 &&
+ png_ptr->bit_depth == 16)
{
/* On the other hand, if a 16-bit file is to be reduced to 8-bits per
* component this will also happen after PNG_COMPOSE and so the background
@@ -1554,25 +1555,24 @@ png_init_read_transformations(png_structrp png_ptr) * file gamma - if it is not 1.0 both RGB_TO_GRAY and COMPOSE need the
* tables.
*/
- if ((png_ptr->transformations & PNG_GAMMA)
- || ((png_ptr->transformations & PNG_RGB_TO_GRAY)
- && (png_gamma_significant(png_ptr->colorspace.gamma) ||
- png_gamma_significant(png_ptr->screen_gamma)))
- || ((png_ptr->transformations & PNG_COMPOSE)
- && (png_gamma_significant(png_ptr->colorspace.gamma)
- || png_gamma_significant(png_ptr->screen_gamma)
+ if ((png_ptr->transformations & PNG_GAMMA) != 0 ||
+ ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0 &&
+ (png_gamma_significant(png_ptr->colorspace.gamma) != 0 ||
+ png_gamma_significant(png_ptr->screen_gamma) != 0)) ||
+ ((png_ptr->transformations & PNG_COMPOSE) != 0 &&
+ (png_gamma_significant(png_ptr->colorspace.gamma) != 0 ||
+ png_gamma_significant(png_ptr->screen_gamma) != 0
# ifdef PNG_READ_BACKGROUND_SUPPORTED
- || (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_UNIQUE
- && png_gamma_significant(png_ptr->background_gamma))
+ || (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_UNIQUE &&
+ png_gamma_significant(png_ptr->background_gamma) != 0)
# endif
- )) || ((png_ptr->transformations & PNG_ENCODE_ALPHA)
- && png_gamma_significant(png_ptr->screen_gamma))
- )
+ )) || ((png_ptr->transformations & PNG_ENCODE_ALPHA) != 0 &&
+ png_gamma_significant(png_ptr->screen_gamma) != 0))
{
png_build_gamma_table(png_ptr, png_ptr->bit_depth);
#ifdef PNG_READ_BACKGROUND_SUPPORTED
- if (png_ptr->transformations & PNG_COMPOSE)
+ if ((png_ptr->transformations & PNG_COMPOSE) != 0)
{
/* Issue a warning about this combination: because RGB_TO_GRAY is
* optimized to do the gamma transform if present yet do_background has
@@ -1580,11 +1580,11 @@ png_init_read_transformations(png_structrp png_ptr) * double-gamma-correction happens. This is true in all versions of
* libpng to date.
*/
- if (png_ptr->transformations & PNG_RGB_TO_GRAY)
+ if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0)
png_warning(png_ptr,
"libpng does not support gamma+background+rgb_to_gray");
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
+ if ((png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) != 0)
{
/* We don't get to here unless there is a tRNS chunk with non-opaque
* entries - see the checking code at the start of this function.
@@ -1632,7 +1632,7 @@ png_init_read_transformations(png_structrp png_ptr) break;
}
- if (png_gamma_significant(gs))
+ if (png_gamma_significant(gs) != 0)
{
back.red = png_gamma_8bit_correct(png_ptr->background.red,
gs);
@@ -1649,7 +1649,7 @@ png_init_read_transformations(png_structrp png_ptr) back.blue = (png_byte)png_ptr->background.blue;
}
- if (png_gamma_significant(g))
+ if (png_gamma_significant(g) != 0)
{
back_1.red = png_gamma_8bit_correct(png_ptr->background.red,
g);
@@ -1743,11 +1743,11 @@ png_init_read_transformations(png_structrp png_ptr) g_sig = png_gamma_significant(g);
gs_sig = png_gamma_significant(gs);
- if (g_sig)
+ if (g_sig != 0)
png_ptr->background_1.gray = png_gamma_correct(png_ptr,
png_ptr->background.gray, g);
- if (gs_sig)
+ if (gs_sig != 0)
png_ptr->background.gray = png_gamma_correct(png_ptr,
png_ptr->background.gray, gs);
@@ -1756,7 +1756,7 @@ png_init_read_transformations(png_structrp png_ptr) (png_ptr->background.red != png_ptr->background.gray))
{
/* RGB or RGBA with color background */
- if (g_sig)
+ if (g_sig != 0)
{
png_ptr->background_1.red = png_gamma_correct(png_ptr,
png_ptr->background.red, g);
@@ -1768,7 +1768,7 @@ png_init_read_transformations(png_structrp png_ptr) png_ptr->background.blue, g);
}
- if (gs_sig)
+ if (gs_sig != 0)
{
png_ptr->background.red = png_gamma_correct(png_ptr,
png_ptr->background.red, gs);
@@ -1798,7 +1798,7 @@ png_init_read_transformations(png_structrp png_ptr) else
/* Transformation does not include PNG_BACKGROUND */
-#endif /* PNG_READ_BACKGROUND_SUPPORTED */
+#endif /* READ_BACKGROUND */
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
/* RGB_TO_GRAY needs to have non-gamma-corrected values! */
@@ -1828,11 +1828,11 @@ png_init_read_transformations(png_structrp png_ptr) #ifdef PNG_READ_BACKGROUND_SUPPORTED
else
#endif
-#endif /* PNG_READ_GAMMA_SUPPORTED */
+#endif /* READ_GAMMA */
#ifdef PNG_READ_BACKGROUND_SUPPORTED
/* No GAMMA transformation (see the hanging else 4 lines above) */
- if ((png_ptr->transformations & PNG_COMPOSE) &&
+ if ((png_ptr->transformations & PNG_COMPOSE) != 0 &&
(png_ptr->color_type == PNG_COLOR_TYPE_PALETTE))
{
int i;
@@ -1867,11 +1867,11 @@ png_init_read_transformations(png_structrp png_ptr) png_ptr->transformations &= ~PNG_COMPOSE;
}
-#endif /* PNG_READ_BACKGROUND_SUPPORTED */
+#endif /* READ_BACKGROUND */
#ifdef PNG_READ_SHIFT_SUPPORTED
- if ((png_ptr->transformations & PNG_SHIFT) &&
- !(png_ptr->transformations & PNG_EXPAND) &&
+ if ((png_ptr->transformations & PNG_SHIFT) != 0 &&
+ (png_ptr->transformations & PNG_EXPAND) == 0 &&
(png_ptr->color_type == PNG_COLOR_TYPE_PALETTE))
{
int i;
@@ -1913,7 +1913,7 @@ png_init_read_transformations(png_structrp png_ptr) png_ptr->palette[i].blue = (png_byte)component;
}
}
-#endif /* PNG_READ_SHIFT_SUPPORTED */
+#endif /* READ_SHIFT */
}
/* Modify the info structure to reflect the transformations. The
@@ -1926,7 +1926,7 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr) png_debug(1, "in png_read_transform_info");
#ifdef PNG_READ_EXPAND_SUPPORTED
- if (png_ptr->transformations & PNG_EXPAND)
+ if ((png_ptr->transformations & PNG_EXPAND) != 0)
{
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
@@ -1948,9 +1948,9 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr) }
else
{
- if (png_ptr->num_trans)
+ if (png_ptr->num_trans != 0)
{
- if (png_ptr->transformations & PNG_EXPAND_tRNS)
+ if ((png_ptr->transformations & PNG_EXPAND_tRNS) != 0)
info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
}
if (info_ptr->bit_depth < 8)
@@ -1966,7 +1966,7 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr) /* The following is almost certainly wrong unless the background value is in
* the screen space!
*/
- if (png_ptr->transformations & PNG_COMPOSE)
+ if ((png_ptr->transformations & PNG_COMPOSE) != 0)
info_ptr->background = png_ptr->background;
#endif
@@ -1987,12 +1987,12 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr) {
# ifdef PNG_READ_16BIT_SUPPORTED
# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
- if (png_ptr->transformations & PNG_SCALE_16_TO_8)
+ if ((png_ptr->transformations & PNG_SCALE_16_TO_8) != 0)
info_ptr->bit_depth = 8;
# endif
# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
- if (png_ptr->transformations & PNG_16_TO_8)
+ if ((png_ptr->transformations & PNG_16_TO_8) != 0)
info_ptr->bit_depth = 8;
# endif
@@ -2018,27 +2018,27 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr) CONFIGURATION ERROR: you must enable at least one 16 to 8 method
# endif
# endif
-#endif /* !READ_16BIT_SUPPORTED */
+#endif /* !READ_16BIT */
}
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
- if (png_ptr->transformations & PNG_GRAY_TO_RGB)
+ if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0)
info_ptr->color_type = (png_byte)(info_ptr->color_type |
PNG_COLOR_MASK_COLOR);
#endif
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
- if (png_ptr->transformations & PNG_RGB_TO_GRAY)
+ if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0)
info_ptr->color_type = (png_byte)(info_ptr->color_type &
~PNG_COLOR_MASK_COLOR);
#endif
#ifdef PNG_READ_QUANTIZE_SUPPORTED
- if (png_ptr->transformations & PNG_QUANTIZE)
+ if ((png_ptr->transformations & PNG_QUANTIZE) != 0)
{
if (((info_ptr->color_type == PNG_COLOR_TYPE_RGB) ||
(info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) &&
- png_ptr->palette_lookup && info_ptr->bit_depth == 8)
+ png_ptr->palette_lookup != 0 && info_ptr->bit_depth == 8)
{
info_ptr->color_type = PNG_COLOR_TYPE_PALETTE;
}
@@ -2046,29 +2046,31 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr) #endif
#ifdef PNG_READ_EXPAND_16_SUPPORTED
- if (png_ptr->transformations & PNG_EXPAND_16 && info_ptr->bit_depth == 8 &&
- info_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
+ if ((png_ptr->transformations & PNG_EXPAND_16) != 0 &&
+ info_ptr->bit_depth == 8 &&
+ info_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
{
info_ptr->bit_depth = 16;
}
#endif
#ifdef PNG_READ_PACK_SUPPORTED
- if ((png_ptr->transformations & PNG_PACK) && (info_ptr->bit_depth < 8))
+ if ((png_ptr->transformations & PNG_PACK) != 0 &&
+ (info_ptr->bit_depth < 8))
info_ptr->bit_depth = 8;
#endif
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
info_ptr->channels = 1;
- else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)
+ else if ((info_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
info_ptr->channels = 3;
else
info_ptr->channels = 1;
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
- if (png_ptr->transformations & PNG_STRIP_ALPHA)
+ if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0)
{
info_ptr->color_type = (png_byte)(info_ptr->color_type &
~PNG_COLOR_MASK_ALPHA);
@@ -2076,25 +2078,25 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr) }
#endif
- if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
+ if ((info_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)
info_ptr->channels++;
#ifdef PNG_READ_FILLER_SUPPORTED
/* STRIP_ALPHA and FILLER allowed: MASK_ALPHA bit stripped above */
- if ((png_ptr->transformations & PNG_FILLER) &&
- ((info_ptr->color_type == PNG_COLOR_TYPE_RGB) ||
- (info_ptr->color_type == PNG_COLOR_TYPE_GRAY)))
+ if ((png_ptr->transformations & PNG_FILLER) != 0 &&
+ (info_ptr->color_type == PNG_COLOR_TYPE_RGB ||
+ info_ptr->color_type == PNG_COLOR_TYPE_GRAY))
{
info_ptr->channels++;
/* If adding a true alpha channel not just filler */
- if (png_ptr->transformations & PNG_ADD_ALPHA)
+ if ((png_ptr->transformations & PNG_ADD_ALPHA) != 0)
info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
}
#endif
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \
defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
- if (png_ptr->transformations & PNG_USER_TRANSFORM)
+ if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
{
if (info_ptr->bit_depth < png_ptr->user_transform_depth)
info_ptr->bit_depth = png_ptr->user_transform_depth;
@@ -2118,7 +2120,7 @@ defined(PNG_READ_USER_TRANSFORM_SUPPORTED) png_ptr->info_rowbytes = info_ptr->rowbytes;
#ifndef PNG_READ_EXPAND_SUPPORTED
- if (png_ptr)
+ if (png_ptr != NULL)
return;
#endif
}
@@ -2245,7 +2247,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row, int channels = 0;
int bit_depth = row_info->bit_depth;
- if (color_type & PNG_COLOR_MASK_COLOR)
+ if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
{
shift[channels++] = bit_depth - sig_bits->red;
shift[channels++] = bit_depth - sig_bits->green;
@@ -2257,7 +2259,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row, shift[channels++] = bit_depth - sig_bits->gray;
}
- if (color_type & PNG_COLOR_MASK_ALPHA)
+ if ((color_type & PNG_COLOR_MASK_ALPHA) != 0)
{
shift[channels++] = bit_depth - sig_bits->alpha;
}
@@ -2277,7 +2279,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row, have_shift = 1;
}
- if (!have_shift)
+ if (have_shift == 0)
return;
}
@@ -2671,7 +2673,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, {
if (row_info->bit_depth == 8)
{
- if (flags & PNG_FLAG_FILLER_AFTER)
+ if ((flags & PNG_FLAG_FILLER_AFTER) != 0)
{
/* This changes the data from G to GX */
png_bytep sp = row + (png_size_t)row_width;
@@ -2706,7 +2708,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, #ifdef PNG_READ_16BIT_SUPPORTED
else if (row_info->bit_depth == 16)
{
- if (flags & PNG_FLAG_FILLER_AFTER)
+ if ((flags & PNG_FLAG_FILLER_AFTER) != 0)
{
/* This changes the data from GG to GGXX */
png_bytep sp = row + (png_size_t)row_width * 2;
@@ -2748,7 +2750,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, {
if (row_info->bit_depth == 8)
{
- if (flags & PNG_FLAG_FILLER_AFTER)
+ if ((flags & PNG_FLAG_FILLER_AFTER) != 0)
{
/* This changes the data from RGB to RGBX */
png_bytep sp = row + (png_size_t)row_width * 3;
@@ -2787,7 +2789,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, #ifdef PNG_READ_16BIT_SUPPORTED
else if (row_info->bit_depth == 16)
{
- if (flags & PNG_FLAG_FILLER_AFTER)
+ if ((flags & PNG_FLAG_FILLER_AFTER) != 0)
{
/* This changes the data from RRGGBB to RRGGBBXX */
png_bytep sp = row + (png_size_t)row_width * 6;
@@ -2848,7 +2850,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) png_debug(1, "in png_do_gray_to_rgb");
if (row_info->bit_depth >= 8 &&
- !(row_info->color_type & PNG_COLOR_MASK_COLOR))
+ (row_info->color_type & PNG_COLOR_MASK_COLOR) == 0)
{
if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
{
@@ -2986,8 +2988,8 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row) png_debug(1, "in png_do_rgb_to_gray");
- if (!(row_info->color_type & PNG_COLOR_MASK_PALETTE) &&
- (row_info->color_type & PNG_COLOR_MASK_COLOR))
+ if ((row_info->color_type & PNG_COLOR_MASK_PALETTE) == 0 &&
+ (row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
{
PNG_CONST png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
PNG_CONST png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;
@@ -3038,7 +3040,7 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row) *(dp++) = red;
}
- if (have_alpha)
+ if (have_alpha != 0)
*(dp++) = *(sp++);
}
}
@@ -3067,7 +3069,7 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row) else
*(dp++) = red;
- if (have_alpha)
+ if (have_alpha != 0)
*(dp++) = *(sp++);
}
}
@@ -3086,15 +3088,15 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row) {
png_uint_16 red, green, blue, w;
- red = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
- green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
- blue = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
+ red = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
+ green = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
+ blue = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
if (red == green && red == blue)
{
if (png_ptr->gamma_16_table != NULL)
- w = png_ptr->gamma_16_table[(red&0xff)
- >> png_ptr->gamma_shift][red>>8];
+ w = png_ptr->gamma_16_table[(red & 0xff)
+ >> png_ptr->gamma_shift][red >> 8];
else
w = red;
@@ -3119,7 +3121,7 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row) *(dp++) = (png_byte)((w>>8) & 0xff);
*(dp++) = (png_byte)(w & 0xff);
- if (have_alpha)
+ if (have_alpha != 0)
{
*(dp++) = *(sp++);
*(dp++) = *(sp++);
@@ -3137,9 +3139,9 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row) {
png_uint_16 red, green, blue, gray16;
- red = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
- green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
- blue = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;
+ red = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
+ green = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
+ blue = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
if (red != green || red != blue)
rgb_error |= 1;
@@ -3150,10 +3152,10 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row) */
gray16 = (png_uint_16)((rc*red + gc*green + bc*blue + 16384) >>
15);
- *(dp++) = (png_byte)((gray16>>8) & 0xff);
+ *(dp++) = (png_byte)((gray16 >> 8) & 0xff);
*(dp++) = (png_byte)(gray16 & 0xff);
- if (have_alpha)
+ if (have_alpha != 0)
{
*(dp++) = *(sp++);
*(dp++) = *(sp++);
@@ -3221,7 +3223,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) *sp = (png_byte)(tmp & 0xff);
}
- if (!shift)
+ if (shift == 0)
{
shift = 7;
sp++;
@@ -3260,7 +3262,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) *sp = (png_byte)(tmp & 0xff);
}
- if (!shift)
+ if (shift == 0)
{
shift = 6;
sp++;
@@ -3286,7 +3288,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) *sp = (png_byte)(tmp & 0xff);
}
- if (!shift)
+ if (shift == 0)
{
shift = 6;
sp++;
@@ -3326,7 +3328,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) *sp = (png_byte)(tmp & 0xff);
}
- if (!shift)
+ if (shift == 0)
{
shift = 4;
sp++;
@@ -3352,7 +3354,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) *sp = (png_byte)(tmp & 0xff);
}
- if (!shift)
+ if (shift == 0)
{
shift = 4;
sp++;
@@ -3605,7 +3607,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) v = gamma_to_1[*sp];
png_composite(w, v, a, png_ptr->background_1.gray);
- if (!optimize)
+ if (optimize == 0)
w = gamma_from_1[w];
*sp = w;
}
@@ -3662,7 +3664,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) g = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];
png_composite_16(v, g, a, png_ptr->background_1.gray);
- if (optimize)
+ if (optimize != 0)
w = v;
else
w = gamma_16_from_1[(v&0xff) >> gamma_shift][v >> 8];
@@ -3736,17 +3738,17 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) v = gamma_to_1[*sp];
png_composite(w, v, a, png_ptr->background_1.red);
- if (!optimize) w = gamma_from_1[w];
+ if (optimize == 0) w = gamma_from_1[w];
*sp = w;
v = gamma_to_1[*(sp + 1)];
png_composite(w, v, a, png_ptr->background_1.green);
- if (!optimize) w = gamma_from_1[w];
+ if (optimize == 0) w = gamma_from_1[w];
*(sp + 1) = w;
v = gamma_to_1[*(sp + 2)];
png_composite(w, v, a, png_ptr->background_1.blue);
- if (!optimize) w = gamma_from_1[w];
+ if (optimize == 0) w = gamma_from_1[w];
*(sp + 2) = w;
}
}
@@ -3828,7 +3830,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];
png_composite_16(w, v, a, png_ptr->background_1.red);
- if (!optimize)
+ if (optimize == 0)
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
8];
*sp = (png_byte)((w >> 8) & 0xff);
@@ -3836,7 +3838,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)];
png_composite_16(w, v, a, png_ptr->background_1.green);
- if (!optimize)
+ if (optimize == 0)
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
8];
@@ -3845,7 +3847,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)];
png_composite_16(w, v, a, png_ptr->background_1.blue);
- if (!optimize)
+ if (optimize == 0)
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
8];
@@ -3910,7 +3912,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) }
}
}
-#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_READ_ALPHA_MODE_SUPPORTED */
+#endif /* READ_BACKGROUND || READ_ALPHA_MODE */
#ifdef PNG_READ_GAMMA_SUPPORTED
/* Gamma correct the image, avoiding the alpha channel. Make sure
@@ -4127,7 +4129,7 @@ png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr) png_debug(1, "in png_do_encode_alpha");
- if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
+ if ((row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0)
{
if (row_info->bit_depth == 8)
{
@@ -4353,7 +4355,7 @@ png_do_expand(png_row_infop row_info, png_bytep row, {
if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
{
- unsigned int gray = trans_color ? trans_color->gray : 0;
+ unsigned int gray = trans_color != NULL ? trans_color->gray : 0;
if (row_info->bit_depth < 8)
{
@@ -4497,7 +4499,8 @@ png_do_expand(png_row_infop row_info, png_bytep row, row_width);
}
}
- else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_color)
+ else if (row_info->color_type == PNG_COLOR_TYPE_RGB &&
+ trans_color != NULL)
{
if (row_info->bit_depth == 8)
{
@@ -4688,7 +4691,7 @@ png_do_quantize(png_row_infop row_info, png_bytep row, }
}
}
-#endif /* PNG_READ_QUANTIZE_SUPPORTED */
+#endif /* READ_QUANTIZE */
/* Transform the row. The order of transformations is significant,
* and is very touchy. If you add a transformation, take care to
@@ -4715,7 +4718,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) * demand, if necessary.
*/
if ((png_ptr->flags & PNG_FLAG_DETECT_UNINITIALIZED) != 0 &&
- !(png_ptr->flags & PNG_FLAG_ROW_INIT))
+ (png_ptr->flags & PNG_FLAG_ROW_INIT) == 0)
{
/* Application has failed to call either png_read_start_image() or
* png_read_update_info() after setting transforms that expand pixels.
@@ -4725,7 +4728,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) }
#ifdef PNG_READ_EXPAND_SUPPORTED
- if (png_ptr->transformations & PNG_EXPAND)
+ if ((png_ptr->transformations & PNG_EXPAND) != 0)
{
if (row_info->color_type == PNG_COLOR_TYPE_PALETTE)
{
@@ -4735,8 +4738,8 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) else
{
- if (png_ptr->num_trans &&
- (png_ptr->transformations & PNG_EXPAND_tRNS))
+ if (png_ptr->num_trans != 0 &&
+ (png_ptr->transformations & PNG_EXPAND_tRNS) != 0)
png_do_expand(row_info, png_ptr->row_buf + 1,
&(png_ptr->trans_color));
@@ -4748,22 +4751,22 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) #endif
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
- if ((png_ptr->transformations & PNG_STRIP_ALPHA) &&
- !(png_ptr->transformations & PNG_COMPOSE) &&
- (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
- row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA))
+ if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0 &&
+ (png_ptr->transformations & PNG_COMPOSE) == 0 &&
+ (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
+ row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA))
png_do_strip_channel(row_info, png_ptr->row_buf + 1,
0 /* at_start == false, because SWAP_ALPHA happens later */);
#endif
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
- if (png_ptr->transformations & PNG_RGB_TO_GRAY)
+ if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0)
{
int rgb_error =
png_do_rgb_to_gray(png_ptr, row_info,
png_ptr->row_buf + 1);
- if (rgb_error)
+ if (rgb_error != 0)
{
png_ptr->rgb_to_gray_status=1;
if ((png_ptr->transformations & PNG_RGB_TO_GRAY) ==
@@ -4812,22 +4815,22 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) /* If gray -> RGB, do so now only if background is non-gray; else do later
* for performance reasons
*/
- if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
- !(png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
+ if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0 &&
+ (png_ptr->mode & PNG_BACKGROUND_IS_GRAY) == 0)
png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1);
#endif
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
- if (png_ptr->transformations & PNG_COMPOSE)
+ if ((png_ptr->transformations & PNG_COMPOSE) != 0)
png_do_compose(row_info, png_ptr->row_buf + 1, png_ptr);
#endif
#ifdef PNG_READ_GAMMA_SUPPORTED
- if ((png_ptr->transformations & PNG_GAMMA) &&
+ if ((png_ptr->transformations & PNG_GAMMA) != 0 &&
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
/* Because RGB_TO_GRAY does the gamma transform. */
- !(png_ptr->transformations & PNG_RGB_TO_GRAY) &&
+ (png_ptr->transformations & PNG_RGB_TO_GRAY) == 0 &&
#endif
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
@@ -4836,7 +4839,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) */
!((png_ptr->transformations & PNG_COMPOSE) &&
((png_ptr->num_trans != 0) ||
- (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) &&
+ (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)) &&
#endif
/* Because png_init_read_transformations transforms the palette, unless
* RGB_TO_GRAY will do the transform.
@@ -4846,22 +4849,22 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) #endif
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
- if ((png_ptr->transformations & PNG_STRIP_ALPHA) &&
- (png_ptr->transformations & PNG_COMPOSE) &&
- (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
- row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA))
+ if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0 &&
+ (png_ptr->transformations & PNG_COMPOSE) != 0 &&
+ (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
+ row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA))
png_do_strip_channel(row_info, png_ptr->row_buf + 1,
- 0 /* at_start == false, because SWAP_ALPHA happens later */);
+ 0 /* at_start == false, because SWAP_ALPHA happens later */);
#endif
#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
- if ((png_ptr->transformations & PNG_ENCODE_ALPHA) &&
- (row_info->color_type & PNG_COLOR_MASK_ALPHA))
+ if ((png_ptr->transformations & PNG_ENCODE_ALPHA) != 0 &&
+ (row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0)
png_do_encode_alpha(row_info, png_ptr->row_buf + 1, png_ptr);
#endif
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
- if (png_ptr->transformations & PNG_SCALE_16_TO_8)
+ if ((png_ptr->transformations & PNG_SCALE_16_TO_8) != 0)
png_do_scale_16_to_8(row_info, png_ptr->row_buf + 1);
#endif
@@ -4870,12 +4873,12 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) * by putting the 'scale' option first if the app asks for scale (either by
* calling the API or in a TRANSFORM flag) this is what happens.
*/
- if (png_ptr->transformations & PNG_16_TO_8)
+ if ((png_ptr->transformations & PNG_16_TO_8) != 0)
png_do_chop(row_info, png_ptr->row_buf + 1);
#endif
#ifdef PNG_READ_QUANTIZE_SUPPORTED
- if (png_ptr->transformations & PNG_QUANTIZE)
+ if ((png_ptr->transformations & PNG_QUANTIZE) != 0)
{
png_do_quantize(row_info, png_ptr->row_buf + 1,
png_ptr->palette_lookup, png_ptr->quantize_index);
@@ -4883,7 +4886,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) if (row_info->rowbytes == 0)
png_error(png_ptr, "png_do_quantize returned rowbytes=0");
}
-#endif /* PNG_READ_QUANTIZE_SUPPORTED */
+#endif /* READ_QUANTIZE */
#ifdef PNG_READ_EXPAND_16_SUPPORTED
/* Do the expansion now, after all the arithmetic has been done. Notice
@@ -4891,35 +4894,35 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) * is efficient (particularly true in the case of gamma correction, where
* better accuracy results faster!)
*/
- if (png_ptr->transformations & PNG_EXPAND_16)
+ if ((png_ptr->transformations & PNG_EXPAND_16) != 0)
png_do_expand_16(row_info, png_ptr->row_buf + 1);
#endif
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
/* NOTE: moved here in 1.5.4 (from much later in this list.) */
- if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
- (png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
+ if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0 &&
+ (png_ptr->mode & PNG_BACKGROUND_IS_GRAY) != 0)
png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1);
#endif
#ifdef PNG_READ_INVERT_SUPPORTED
- if (png_ptr->transformations & PNG_INVERT_MONO)
+ if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
png_do_invert(row_info, png_ptr->row_buf + 1);
#endif
#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
- if (png_ptr->transformations & PNG_INVERT_ALPHA)
+ if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0)
png_do_read_invert_alpha(row_info, png_ptr->row_buf + 1);
#endif
#ifdef PNG_READ_SHIFT_SUPPORTED
- if (png_ptr->transformations & PNG_SHIFT)
+ if ((png_ptr->transformations & PNG_SHIFT) != 0)
png_do_unshift(row_info, png_ptr->row_buf + 1,
&(png_ptr->shift));
#endif
#ifdef PNG_READ_PACK_SUPPORTED
- if (png_ptr->transformations & PNG_PACK)
+ if ((png_ptr->transformations & PNG_PACK) != 0)
png_do_unpack(row_info, png_ptr->row_buf + 1);
#endif
@@ -4931,36 +4934,36 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) #endif
#ifdef PNG_READ_BGR_SUPPORTED
- if (png_ptr->transformations & PNG_BGR)
+ if ((png_ptr->transformations & PNG_BGR) != 0)
png_do_bgr(row_info, png_ptr->row_buf + 1);
#endif
#ifdef PNG_READ_PACKSWAP_SUPPORTED
- if (png_ptr->transformations & PNG_PACKSWAP)
+ if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
png_do_packswap(row_info, png_ptr->row_buf + 1);
#endif
#ifdef PNG_READ_FILLER_SUPPORTED
- if (png_ptr->transformations & PNG_FILLER)
+ if ((png_ptr->transformations & PNG_FILLER) != 0)
png_do_read_filler(row_info, png_ptr->row_buf + 1,
(png_uint_32)png_ptr->filler, png_ptr->flags);
#endif
#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED
- if (png_ptr->transformations & PNG_SWAP_ALPHA)
+ if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0)
png_do_read_swap_alpha(row_info, png_ptr->row_buf + 1);
#endif
#ifdef PNG_READ_16BIT_SUPPORTED
#ifdef PNG_READ_SWAP_SUPPORTED
- if (png_ptr->transformations & PNG_SWAP_BYTES)
+ if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
png_do_swap(row_info, png_ptr->row_buf + 1);
#endif
#endif
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
- if (png_ptr->transformations & PNG_USER_TRANSFORM)
- {
+ if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
+ {
if (png_ptr->read_user_transform_fn != NULL)
(*(png_ptr->read_user_transform_fn)) /* User read transform function */
(png_ptr, /* png_ptr */
@@ -4973,10 +4976,10 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) /* png_byte pixel_depth; bits per pixel (depth*channels) */
png_ptr->row_buf + 1); /* start of pixel data for row */
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
- if (png_ptr->user_transform_depth)
+ if (png_ptr->user_transform_depth != 0)
row_info->bit_depth = png_ptr->user_transform_depth;
- if (png_ptr->user_transform_channels)
+ if (png_ptr->user_transform_channels != 0)
row_info->channels = png_ptr->user_transform_channels;
#endif
row_info->pixel_depth = (png_byte)(row_info->bit_depth *
@@ -4987,5 +4990,5 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) #endif
}
-#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
-#endif /* PNG_READ_SUPPORTED */
+#endif /* READ_TRANSFORMS */
+#endif /* READ */
diff --git a/plugins/AdvaImg/src/LibPNG/pngrutil.c b/plugins/AdvaImg/src/LibPNG/pngrutil.c index 2079db54f7..4e9fbe7ce2 100644 --- a/plugins/AdvaImg/src/LibPNG/pngrutil.c +++ b/plugins/AdvaImg/src/LibPNG/pngrutil.c @@ -1,7 +1,7 @@ /* pngrutil.c - utilities to read a PNG file
*
- * Last changed in libpng 1.6.10 [March 6, 2014]
+ * Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -108,7 +108,7 @@ png_get_uint_16)(png_const_bytep buf) return (png_uint_16)val;
}
-#endif /* PNG_READ_INT_FUNCTIONS_SUPPORTED */
+#endif /* READ_INT_FUNCTIONS */
/* Read and check the PNG file signature */
void /* PRIVATE */
@@ -131,7 +131,7 @@ png_read_sig(png_structrp png_ptr, png_inforp info_ptr) png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check);
png_ptr->sig_bytes = 8;
- if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check))
+ if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check) != 0)
{
if (num_checked < 4 &&
png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4))
@@ -217,11 +217,11 @@ png_crc_finish(png_structrp png_ptr, png_uint_32 skip) png_crc_read(png_ptr, tmpbuf, len);
}
- if (png_crc_error(png_ptr))
+ if (png_crc_error(png_ptr) != 0)
{
- if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) ?
- !(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) :
- (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE))
+ if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) != 0 ?
+ (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) == 0 :
+ (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE) != 0)
{
png_chunk_warning(png_ptr, "CRC error");
}
@@ -245,7 +245,7 @@ png_crc_error(png_structrp png_ptr) png_uint_32 crc;
int need_crc = 1;
- if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name))
+ if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) != 0)
{
if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) ==
(PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))
@@ -254,7 +254,7 @@ png_crc_error(png_structrp png_ptr) else /* critical */
{
- if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE)
+ if ((png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) != 0)
need_crc = 0;
}
@@ -265,7 +265,7 @@ png_crc_error(png_structrp png_ptr) /* The chunk CRC must be serialized in a single I/O call. */
png_read_data(png_ptr, crc_bytes, 4);
- if (need_crc)
+ if (need_crc != 0)
{
crc = png_get_uint_32(crc_bytes);
return ((int)(crc != png_ptr->crc));
@@ -311,7 +311,7 @@ png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn) else if (warn < 2) /* else silent */
{
- if (warn)
+ if (warn != 0)
png_chunk_warning(png_ptr, "insufficient memory to read chunk");
else
@@ -321,7 +321,7 @@ png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn) return buffer;
}
-#endif /* PNG_READ_iCCP|iTXt|pCAL|sCAL|sPLT|tEXt|zTXt|SEQUENTIAL_READ */
+#endif /* READ_iCCP|iTXt|pCAL|sCAL|sPLT|tEXt|zTXt|SEQUENTIAL_READ */
/* png_inflate_claim: claim the zstream for some nefarious purpose that involves
* decompression. Returns Z_OK on success, else a zlib error code. It checks
@@ -341,12 +341,12 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner) * are minimal.
*/
(void)png_safecat(msg, (sizeof msg), 4, " using zstream");
-# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
- png_chunk_warning(png_ptr, msg);
- png_ptr->zowner = 0;
-# else
- png_chunk_error(png_ptr, msg);
-# endif
+#if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
+ png_chunk_warning(png_ptr, msg);
+ png_ptr->zowner = 0;
+#else
+ png_chunk_error(png_ptr, msg);
+#endif
}
/* Implementation note: unlike 'png_deflate_claim' this internal function
@@ -364,22 +364,21 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner) */
{
int ret; /* zlib return code */
-# if PNG_ZLIB_VERNUM >= 0x1240
+#if PNG_ZLIB_VERNUM >= 0x1240
-# if defined(PNG_SET_OPTION_SUPPORTED) && \
- defined(PNG_MAXIMUM_INFLATE_WINDOW)
- int window_bits;
+# if defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_MAXIMUM_INFLATE_WINDOW)
+ int window_bits;
- if (((png_ptr->options >> PNG_MAXIMUM_INFLATE_WINDOW) & 3) ==
- PNG_OPTION_ON)
- window_bits = 15;
+ if (((png_ptr->options >> PNG_MAXIMUM_INFLATE_WINDOW) & 3) ==
+ PNG_OPTION_ON)
+ window_bits = 15;
- else
- window_bits = 0;
-# else
-# define window_bits 0
-# endif
-# endif
+ else
+ window_bits = 0;
+# else
+# define window_bits 0
+# endif
+#endif
/* Set this for safety, just in case the previous owner left pointers to
* memory allocations.
@@ -389,22 +388,22 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner) png_ptr->zstream.next_out = NULL;
png_ptr->zstream.avail_out = 0;
- if (png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED)
+ if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0)
{
-# if PNG_ZLIB_VERNUM < 0x1240
- ret = inflateReset(&png_ptr->zstream);
-# else
- ret = inflateReset2(&png_ptr->zstream, window_bits);
-# endif
+#if PNG_ZLIB_VERNUM < 0x1240
+ ret = inflateReset(&png_ptr->zstream);
+#else
+ ret = inflateReset2(&png_ptr->zstream, window_bits);
+#endif
}
else
{
-# if PNG_ZLIB_VERNUM < 0x1240
- ret = inflateInit(&png_ptr->zstream);
-# else
- ret = inflateInit2(&png_ptr->zstream, window_bits);
-# endif
+#if PNG_ZLIB_VERNUM < 0x1240
+ ret = inflateInit(&png_ptr->zstream);
+#else
+ ret = inflateInit2(&png_ptr->zstream, window_bits);
+#endif
if (ret == Z_OK)
png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED;
@@ -419,9 +418,9 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner) return ret;
}
-# ifdef window_bits
-# undef window_bits
-# endif
+#ifdef window_bits
+# undef window_bits
+#endif
}
#ifdef PNG_READ_COMPRESSED_TEXT_SUPPORTED
@@ -518,7 +517,7 @@ png_inflate(png_structrp png_ptr, png_uint_32 owner, int finish, * end of the output buffer.
*/
ret = inflate(&png_ptr->zstream, avail_out > 0 ? Z_NO_FLUSH :
- (finish ? Z_FINISH : Z_SYNC_FLUSH));
+ (finish ? Z_FINISH : Z_SYNC_FLUSH));
} while (ret == Z_OK);
/* For safety kill the local buffer pointer now */
@@ -576,14 +575,14 @@ png_decompress_chunk(png_structrp png_ptr, */
png_alloc_size_t limit = PNG_SIZE_MAX;
-# ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
- if (png_ptr->user_chunk_malloc_max > 0 &&
- png_ptr->user_chunk_malloc_max < limit)
- limit = png_ptr->user_chunk_malloc_max;
-# elif PNG_USER_CHUNK_MALLOC_MAX > 0
- if (PNG_USER_CHUNK_MALLOC_MAX < limit)
- limit = PNG_USER_CHUNK_MALLOC_MAX;
-# endif
+# ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
+ if (png_ptr->user_chunk_malloc_max > 0 &&
+ png_ptr->user_chunk_malloc_max < limit)
+ limit = png_ptr->user_chunk_malloc_max;
+# elif PNG_USER_CHUNK_MALLOC_MAX > 0
+ if (PNG_USER_CHUNK_MALLOC_MAX < limit)
+ limit = PNG_USER_CHUNK_MALLOC_MAX;
+# endif
if (limit >= prefix_size + (terminate != 0))
{
@@ -637,7 +636,7 @@ png_decompress_chunk(png_structrp png_ptr, {
if (new_size == *newlength)
{
- if (terminate)
+ if (terminate != 0)
text[prefix_size + *newlength] = 0;
if (prefix_size > 0)
@@ -671,6 +670,7 @@ png_decompress_chunk(png_structrp png_ptr, * success)
*/
png_free(png_ptr, text);
+ text = NULL;
/* This really is very benign, but it's still an error because
* the extra space may otherwise be used as a Trojan Horse.
@@ -718,7 +718,7 @@ png_decompress_chunk(png_structrp png_ptr, return Z_MEM_ERROR;
}
}
-#endif /* PNG_READ_COMPRESSED_TEXT_SUPPORTED */
+#endif /* READ_COMPRESSED_TEXT */
#ifdef PNG_READ_iCCP_SUPPORTED
/* Perform a partial read and decompress, producing 'avail_out' bytes and
@@ -798,7 +798,7 @@ png_handle_IHDR(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_debug(1, "in png_handle_IHDR");
- if (png_ptr->mode & PNG_HAVE_IHDR)
+ if ((png_ptr->mode & PNG_HAVE_IHDR) != 0)
png_chunk_error(png_ptr, "out of place");
/* Check the length */
@@ -874,7 +874,7 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_debug(1, "in png_handle_PLTE");
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
png_chunk_error(png_ptr, "missing IHDR");
/* Moved to before the 'after IDAT' check below because otherwise duplicate
@@ -882,10 +882,10 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) * than one PLTE, the error is not treated as benign, so this check trumps
* the requirement that PLTE appears before IDAT.)
*/
- else if (png_ptr->mode & PNG_HAVE_PLTE)
+ else if ((png_ptr->mode & PNG_HAVE_PLTE) != 0)
png_chunk_error(png_ptr, "duplicate");
- else if (png_ptr->mode & PNG_HAVE_IDAT)
+ else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
{
/* This is benign because the non-benign error happened before, when an
* IDAT was encountered in a color-mapped image with no PLTE.
@@ -897,7 +897,7 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_ptr->mode |= PNG_HAVE_PLTE;
- if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR))
+ if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "ignored in grayscale PNG");
@@ -964,7 +964,7 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) }
#ifndef PNG_READ_OPT_PLTE_SUPPORTED
- else if (png_crc_error(png_ptr)) /* Only if we have a CRC error */
+ else if (png_crc_error(png_ptr) != 0) /* Only if we have a CRC error */
{
/* If we don't want to use the data from an ancillary chunk,
* we have two options: an error abort, or a warning and we
@@ -975,9 +975,9 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) * chunk type to determine whether to check the ancillary or the critical
* flags.
*/
- if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE))
+ if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE) == 0)
{
- if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)
+ if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) != 0)
return;
else
@@ -985,7 +985,7 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) }
/* Otherwise, we (optionally) emit a warning and use the chunk. */
- else if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN))
+ else if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) == 0)
png_chunk_warning(png_ptr, "CRC error");
}
#endif
@@ -1011,7 +1011,7 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) */
#ifdef PNG_READ_tRNS_SUPPORTED
if (png_ptr->num_trans > 0 ||
- (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS) != 0))
+ (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS) != 0))
{
/* Cancel this because otherwise it would be used if the transforms
* require it. Don't cancel the 'valid' flag because this would prevent
@@ -1042,7 +1042,8 @@ png_handle_IEND(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) {
png_debug(1, "in png_handle_IEND");
- if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT))
+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0 ||
+ (png_ptr->mode & PNG_HAVE_IDAT) == 0)
png_chunk_error(png_ptr, "out of place");
png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND);
@@ -1064,10 +1065,10 @@ png_handle_gAMA(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_debug(1, "in png_handle_gAMA");
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
png_chunk_error(png_ptr, "missing IHDR");
- else if (png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE))
+ else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "out of place");
@@ -1083,7 +1084,7 @@ png_handle_gAMA(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_crc_read(png_ptr, buf, 4);
- if (png_crc_finish(png_ptr, 0))
+ if (png_crc_finish(png_ptr, 0) != 0)
return;
igamma = png_get_fixed_point(NULL, buf);
@@ -1103,17 +1104,17 @@ png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_debug(1, "in png_handle_sBIT");
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
png_chunk_error(png_ptr, "missing IHDR");
- else if (png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE))
+ else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "out of place");
return;
}
- if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT))
+ if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) != 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "duplicate");
@@ -1142,7 +1143,7 @@ png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) buf[0] = buf[1] = buf[2] = buf[3] = sample_depth;
png_crc_read(png_ptr, buf, truelen);
- if (png_crc_finish(png_ptr, 0))
+ if (png_crc_finish(png_ptr, 0) != 0)
return;
for (i=0; i<truelen; ++i)
@@ -1152,7 +1153,7 @@ png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) return;
}
- if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)
+ if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
{
png_ptr->sig_bit.red = buf[0];
png_ptr->sig_bit.green = buf[1];
@@ -1182,10 +1183,10 @@ png_handle_cHRM(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_debug(1, "in png_handle_cHRM");
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
png_chunk_error(png_ptr, "missing IHDR");
- else if (png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE))
+ else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "out of place");
@@ -1201,7 +1202,7 @@ png_handle_cHRM(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_crc_read(png_ptr, buf, 32);
- if (png_crc_finish(png_ptr, 0))
+ if (png_crc_finish(png_ptr, 0) != 0)
return;
xy.whitex = png_get_fixed_point(NULL, buf);
@@ -1227,10 +1228,10 @@ png_handle_cHRM(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) }
/* If a colorspace error has already been output skip this chunk */
- if (png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID)
+ if ((png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) != 0)
return;
- if (png_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM)
+ if ((png_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) != 0)
{
png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID;
png_colorspace_sync(png_ptr, info_ptr);
@@ -1253,10 +1254,10 @@ png_handle_sRGB(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_debug(1, "in png_handle_sRGB");
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
png_chunk_error(png_ptr, "missing IHDR");
- else if (png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE))
+ else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "out of place");
@@ -1272,17 +1273,17 @@ png_handle_sRGB(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_crc_read(png_ptr, &intent, 1);
- if (png_crc_finish(png_ptr, 0))
+ if (png_crc_finish(png_ptr, 0) != 0)
return;
/* If a colorspace error has already been output skip this chunk */
- if (png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID)
+ if ((png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) != 0)
return;
/* Only one sRGB or iCCP chunk is allowed, use the HAVE_INTENT flag to detect
* this.
*/
- if (png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_INTENT)
+ if ((png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_INTENT) != 0)
{
png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID;
png_colorspace_sync(png_ptr, info_ptr);
@@ -1293,7 +1294,7 @@ png_handle_sRGB(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) (void)png_colorspace_set_sRGB(png_ptr, &png_ptr->colorspace, intent);
png_colorspace_sync(png_ptr, info_ptr);
}
-#endif /* PNG_READ_sRGB_SUPPORTED */
+#endif /* READ_sRGB */
#ifdef PNG_READ_iCCP_SUPPORTED
void /* PRIVATE */
@@ -1305,10 +1306,10 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_debug(1, "in png_handle_iCCP");
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
png_chunk_error(png_ptr, "missing IHDR");
- else if (png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE))
+ else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "out of place");
@@ -1319,9 +1320,9 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) * chunk is just ignored, so does not invalidate the color space. An
* alternative is to set the 'invalid' flags at the start of this routine
* and only clear them in they were not set before and all the tests pass.
- * The minimum 'deflate' stream is assumed to be just the 2 byte header and 4
- * byte checksum. The keyword must be one character and there is a
- * terminator (0) byte and the compression method.
+ * The minimum 'deflate' stream is assumed to be just the 2 byte header and
+ * 4 byte checksum. The keyword must be at least one character and there is
+ * a terminator (0) byte and the compression method.
*/
if (length < 9)
{
@@ -1331,7 +1332,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) }
/* If a colorspace error has already been output skip this chunk */
- if (png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID)
+ if ((png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) != 0)
{
png_crc_finish(png_ptr, length);
return;
@@ -1391,14 +1392,14 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_get_uint_32(profile_header);
if (png_icc_check_length(png_ptr, &png_ptr->colorspace,
- keyword, profile_length))
+ keyword, profile_length) != 0)
{
/* The length is apparently ok, so we can check the 132
* byte header.
*/
if (png_icc_check_header(png_ptr, &png_ptr->colorspace,
keyword, profile_length, profile_header,
- png_ptr->color_type))
+ png_ptr->color_type) != 0)
{
/* Now read the tag table; a variable size buffer is
* needed at this point, allocate one for the whole
@@ -1428,7 +1429,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) {
if (png_icc_check_tag_table(png_ptr,
&png_ptr->colorspace, keyword, profile_length,
- profile))
+ profile) != 0)
{
/* The profile has been validated for basic
* security issues, so read the whole thing in.
@@ -1558,7 +1559,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) errmsg = "too many profiles";
/* Failure: the reason is in 'errmsg' */
- if (!finished)
+ if (finished == 0)
png_crc_finish(png_ptr, length);
png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID;
@@ -1566,7 +1567,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) if (errmsg != NULL) /* else already output */
png_chunk_benign_error(png_ptr, errmsg);
}
-#endif /* PNG_READ_iCCP_SUPPORTED */
+#endif /* READ_iCCP */
#ifdef PNG_READ_sPLT_SUPPORTED
void /* PRIVATE */
@@ -1602,10 +1603,10 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) }
#endif
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
png_chunk_error(png_ptr, "missing IHDR");
- else if (png_ptr->mode & PNG_HAVE_IDAT)
+ else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "out of place");
@@ -1636,7 +1637,7 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) */
png_crc_read(png_ptr, buffer, length);
- if (png_crc_finish(png_ptr, skip))
+ if (png_crc_finish(png_ptr, skip) != 0)
return;
buffer[length] = 0;
@@ -1661,7 +1662,7 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) data_length = length - (png_uint_32)(entry_start - buffer);
/* Integrity-check the data length */
- if (data_length % entry_size)
+ if ((data_length % entry_size) != 0)
{
png_warning(png_ptr, "sPLT chunk has bad length");
return;
@@ -1743,7 +1744,7 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_free(png_ptr, new_palette.entries);
}
-#endif /* PNG_READ_sPLT_SUPPORTED */
+#endif /* READ_sPLT */
#ifdef PNG_READ_tRNS_SUPPORTED
void /* PRIVATE */
@@ -1753,17 +1754,17 @@ png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_debug(1, "in png_handle_tRNS");
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
png_chunk_error(png_ptr, "missing IHDR");
- else if (png_ptr->mode & PNG_HAVE_IDAT)
+ else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "out of place");
return;
}
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
+ else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS) != 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "duplicate");
@@ -1806,7 +1807,7 @@ png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
- if (!(png_ptr->mode & PNG_HAVE_PLTE))
+ if ((png_ptr->mode & PNG_HAVE_PLTE) == 0)
{
/* TODO: is this actually an error in the ISO spec? */
png_crc_finish(png_ptr, length);
@@ -1833,7 +1834,7 @@ png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) return;
}
- if (png_crc_finish(png_ptr, 0))
+ if (png_crc_finish(png_ptr, 0) != 0)
{
png_ptr->num_trans = 0;
return;
@@ -1858,19 +1859,19 @@ png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_debug(1, "in png_handle_bKGD");
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
png_chunk_error(png_ptr, "missing IHDR");
- else if ((png_ptr->mode & PNG_HAVE_IDAT) ||
- (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
- !(png_ptr->mode & PNG_HAVE_PLTE)))
+ else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0 ||
+ (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
+ (png_ptr->mode & PNG_HAVE_PLTE) == 0))
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "out of place");
return;
}
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD))
+ else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) != 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "duplicate");
@@ -1880,7 +1881,7 @@ png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
truelen = 1;
- else if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)
+ else if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
truelen = 6;
else
@@ -1895,7 +1896,7 @@ png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_crc_read(png_ptr, buf, truelen);
- if (png_crc_finish(png_ptr, 0))
+ if (png_crc_finish(png_ptr, 0) != 0)
return;
/* We convert the index value into RGB components so that we can allow
@@ -1907,7 +1908,7 @@ png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) {
background.index = buf[0];
- if (info_ptr && info_ptr->num_palette)
+ if (info_ptr != NULL && info_ptr->num_palette != 0)
{
if (buf[0] >= info_ptr->num_palette)
{
@@ -1926,7 +1927,7 @@ png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) background.gray = 0;
}
- else if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) /* GRAY */
+ else if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0) /* GRAY */
{
background.index = 0;
background.red =
@@ -1957,17 +1958,18 @@ png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_debug(1, "in png_handle_hIST");
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
png_chunk_error(png_ptr, "missing IHDR");
- else if ((png_ptr->mode & PNG_HAVE_IDAT) || !(png_ptr->mode & PNG_HAVE_PLTE))
+ else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0 ||
+ (png_ptr->mode & PNG_HAVE_PLTE) == 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "out of place");
return;
}
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST))
+ else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) != 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "duplicate");
@@ -1991,7 +1993,7 @@ png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) readbuf[i] = png_get_uint_16(buf);
}
- if (png_crc_finish(png_ptr, 0))
+ if (png_crc_finish(png_ptr, 0) != 0)
return;
png_set_hIST(png_ptr, info_ptr, readbuf);
@@ -2008,17 +2010,17 @@ png_handle_pHYs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_debug(1, "in png_handle_pHYs");
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
png_chunk_error(png_ptr, "missing IHDR");
- else if (png_ptr->mode & PNG_HAVE_IDAT)
+ else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "out of place");
return;
}
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
+ else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs) != 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "duplicate");
@@ -2034,7 +2036,7 @@ png_handle_pHYs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_crc_read(png_ptr, buf, 9);
- if (png_crc_finish(png_ptr, 0))
+ if (png_crc_finish(png_ptr, 0) != 0)
return;
res_x = png_get_uint_32(buf);
@@ -2054,17 +2056,17 @@ png_handle_oFFs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_debug(1, "in png_handle_oFFs");
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
png_chunk_error(png_ptr, "missing IHDR");
- else if (png_ptr->mode & PNG_HAVE_IDAT)
+ else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "out of place");
return;
}
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
+ else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) != 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "duplicate");
@@ -2080,7 +2082,7 @@ png_handle_oFFs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_crc_read(png_ptr, buf, 9);
- if (png_crc_finish(png_ptr, 0))
+ if (png_crc_finish(png_ptr, 0) != 0)
return;
offset_x = png_get_int_32(buf);
@@ -2103,17 +2105,17 @@ png_handle_pCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_debug(1, "in png_handle_pCAL");
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
png_chunk_error(png_ptr, "missing IHDR");
- else if (png_ptr->mode & PNG_HAVE_IDAT)
+ else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "out of place");
return;
}
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL))
+ else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) != 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "duplicate");
@@ -2134,7 +2136,7 @@ png_handle_pCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_crc_read(png_ptr, buffer, length);
- if (png_crc_finish(png_ptr, 0))
+ if (png_crc_finish(png_ptr, 0) != 0)
return;
buffer[length] = 0; /* Null terminate the last string */
@@ -2230,17 +2232,17 @@ png_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_debug(1, "in png_handle_sCAL");
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
png_chunk_error(png_ptr, "missing IHDR");
- else if (png_ptr->mode & PNG_HAVE_IDAT)
+ else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "out of place");
return;
}
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL))
+ else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL) != 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "duplicate");
@@ -2270,7 +2272,7 @@ png_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_crc_read(png_ptr, buffer, length);
buffer[length] = 0; /* Null terminate the last string */
- if (png_crc_finish(png_ptr, 0))
+ if (png_crc_finish(png_ptr, 0) != 0)
return;
/* Validate the unit. */
@@ -2286,11 +2288,11 @@ png_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) i = 1;
state = 0;
- if (!png_check_fp_number((png_const_charp)buffer, length, &state, &i) ||
+ if (png_check_fp_number((png_const_charp)buffer, length, &state, &i) == 0 ||
i >= length || buffer[i++] != 0)
png_chunk_benign_error(png_ptr, "bad width format");
- else if (!PNG_FP_IS_POSITIVE(state))
+ else if (PNG_FP_IS_POSITIVE(state) == 0)
png_chunk_benign_error(png_ptr, "non-positive width");
else
@@ -2298,11 +2300,11 @@ png_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_size_t heighti = i;
state = 0;
- if (!png_check_fp_number((png_const_charp)buffer, length, &state, &i) ||
- i != length)
+ if (png_check_fp_number((png_const_charp)buffer, length,
+ &state, &i) == 0 || i != length)
png_chunk_benign_error(png_ptr, "bad height format");
- else if (!PNG_FP_IS_POSITIVE(state))
+ else if (PNG_FP_IS_POSITIVE(state) == 0)
png_chunk_benign_error(png_ptr, "non-positive height");
else
@@ -2322,17 +2324,17 @@ png_handle_tIME(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_debug(1, "in png_handle_tIME");
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
png_chunk_error(png_ptr, "missing IHDR");
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME))
+ else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) != 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "duplicate");
return;
}
- if (png_ptr->mode & PNG_HAVE_IDAT)
+ if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
png_ptr->mode |= PNG_AFTER_IDAT;
if (length != 7)
@@ -2344,7 +2346,7 @@ png_handle_tIME(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_crc_read(png_ptr, buf, 7);
- if (png_crc_finish(png_ptr, 0))
+ if (png_crc_finish(png_ptr, 0) != 0)
return;
mod_time.second = buf[6];
@@ -2389,10 +2391,10 @@ png_handle_tEXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) }
#endif
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
png_chunk_error(png_ptr, "missing IHDR");
- if (png_ptr->mode & PNG_HAVE_IDAT)
+ if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
png_ptr->mode |= PNG_AFTER_IDAT;
#ifdef PNG_MAX_MALLOC_64K
@@ -2414,7 +2416,7 @@ png_handle_tEXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_crc_read(png_ptr, buffer, length);
- if (png_crc_finish(png_ptr, skip))
+ if (png_crc_finish(png_ptr, skip) != 0)
return;
key = (png_charp)buffer;
@@ -2434,7 +2436,7 @@ png_handle_tEXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) text_info.text = text;
text_info.text_length = strlen(text);
- if (png_set_text_2(png_ptr, info_ptr, &text_info, 1))
+ if (png_set_text_2(png_ptr, info_ptr, &text_info, 1) != 0)
png_warning(png_ptr, "Insufficient memory to process text chunk");
}
#endif
@@ -2468,10 +2470,10 @@ png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) }
#endif
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
png_chunk_error(png_ptr, "missing IHDR");
- if (png_ptr->mode & PNG_HAVE_IDAT)
+ if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
png_ptr->mode |= PNG_AFTER_IDAT;
buffer = png_read_buffer(png_ptr, length, 2/*silent*/);
@@ -2485,7 +2487,7 @@ png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_crc_read(png_ptr, buffer, length);
- if (png_crc_finish(png_ptr, 0))
+ if (png_crc_finish(png_ptr, 0) != 0)
return;
/* TODO: also check that the keyword contents match the spec! */
@@ -2535,7 +2537,7 @@ png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) text.lang = NULL;
text.lang_key = NULL;
- if (png_set_text_2(png_ptr, info_ptr, &text, 1))
+ if (png_set_text_2(png_ptr, info_ptr, &text, 1) != 0)
errmsg = "insufficient memory";
}
@@ -2577,10 +2579,10 @@ png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) }
#endif
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
+ if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
png_chunk_error(png_ptr, "missing IHDR");
- if (png_ptr->mode & PNG_HAVE_IDAT)
+ if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
png_ptr->mode |= PNG_AFTER_IDAT;
buffer = png_read_buffer(png_ptr, length+1, 1/*warn*/);
@@ -2594,7 +2596,7 @@ png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_crc_read(png_ptr, buffer, length);
- if (png_crc_finish(png_ptr, 0))
+ if (png_crc_finish(png_ptr, 0) != 0)
return;
/* First the keyword. */
@@ -2640,14 +2642,14 @@ png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) /* prefix_length should now be at the trailing '\0' of the translated
* keyword, but it may already be over the end. None of this arithmetic
* can overflow because chunks are at most 2^31 bytes long, but on 16-bit
- * systems the available allocaton may overflow.
+ * systems the available allocation may overflow.
*/
++prefix_length;
- if (!compressed && prefix_length <= length)
+ if (compressed == 0 && prefix_length <= length)
uncompressed_length = length - prefix_length;
- else if (compressed && prefix_length < length)
+ else if (compressed != 0 && prefix_length < length)
{
uncompressed_length = PNG_SIZE_MAX;
@@ -2672,7 +2674,7 @@ png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) buffer[uncompressed_length+prefix_length] = 0;
- if (compressed)
+ if (compressed == 0)
text.compression = PNG_ITXT_COMPRESSION_NONE;
else
@@ -2685,7 +2687,7 @@ png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) text.text_length = 0;
text.itxt_length = uncompressed_length;
- if (png_set_text_2(png_ptr, info_ptr, &text, 1))
+ if (png_set_text_2(png_ptr, info_ptr, &text, 1) != 0)
errmsg = "insufficient memory";
}
}
@@ -2713,7 +2715,7 @@ png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length) # ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
if (png_ptr->user_chunk_malloc_max > 0 &&
- png_ptr->user_chunk_malloc_max < limit)
+ png_ptr->user_chunk_malloc_max < limit)
limit = png_ptr->user_chunk_malloc_max;
# elif PNG_USER_CHUNK_MALLOC_MAX > 0
@@ -2756,7 +2758,7 @@ png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length) return 1;
}
}
-#endif /* PNG_READ_UNKNOWN_CHUNKS_SUPPORTED */
+#endif /* READ_UNKNOWN_CHUNKS */
/* Handle an unknown, or known but disabled, chunk */
void /* PRIVATE */
@@ -2795,7 +2797,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, */
if (png_ptr->read_user_chunk_fn != NULL)
{
- if (png_cache_unknown_chunk(png_ptr, length))
+ if (png_cache_unknown_chunk(png_ptr, length) != 0)
{
/* Callback to user unknown chunk handler */
int ret = (*(png_ptr->read_user_chunk_fn))(png_ptr,
@@ -2856,7 +2858,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, else
/* Use the SAVE_UNKNOWN_CHUNKS code or skip the chunk */
-# endif /* PNG_READ_USER_CHUNKS_SUPPORTED */
+# endif /* READ_USER_CHUNKS */
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
{
@@ -2872,7 +2874,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, (keep == PNG_HANDLE_CHUNK_IF_SAFE &&
PNG_CHUNK_ANCILLARY(png_ptr->chunk_name)))
{
- if (!png_cache_unknown_chunk(png_ptr, length))
+ if (png_cache_unknown_chunk(png_ptr, length) == 0)
keep = PNG_HANDLE_CHUNK_NEVER;
}
@@ -2923,7 +2925,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, --(png_ptr->user_chunk_cache_max);
/* FALL THROUGH */
case 0: /* no limit */
-# endif /* PNG_USER_LIMITS_SUPPORTED */
+# endif /* USER_LIMITS */
/* Here when the limit isn't reached or when limits are compiled
* out; store the chunk.
*/
@@ -2952,10 +2954,10 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, png_crc_finish(png_ptr, length);
PNG_UNUSED(info_ptr)
PNG_UNUSED(keep)
-#endif /* !PNG_READ_UNKNOWN_CHUNKS_SUPPORTED */
+#endif /* !READ_UNKNOWN_CHUNKS */
/* Check for unhandled critical chunks */
- if (!handled && PNG_CHUNK_CRITICAL(png_ptr->chunk_name))
+ if (handled == 0 && PNG_CHUNK_CRITICAL(png_ptr->chunk_name))
png_chunk_error(png_ptr, "unhandled critical chunk");
}
@@ -3038,7 +3040,8 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) end_ptr = dp + PNG_ROWBYTES(pixel_depth, row_width) - 1;
end_byte = *end_ptr;
# ifdef PNG_READ_PACKSWAP_SUPPORTED
- if (png_ptr->transformations & PNG_PACKSWAP) /* little-endian byte */
+ if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
+ /* little-endian byte */
end_mask = 0xff << end_mask;
else /* big-endian byte */
@@ -3054,10 +3057,11 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) * pass.
*/
#ifdef PNG_READ_INTERLACING_SUPPORTED
- if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE) &&
- pass < 6 && (display == 0 ||
- /* The following copies everything for 'display' on passes 0, 2 and 4. */
- (display == 1 && (pass & 1) != 0)))
+ if (png_ptr->interlaced != 0 &&
+ (png_ptr->transformations & PNG_INTERLACE) != 0 &&
+ pass < 6 && (display == 0 ||
+ /* The following copies everything for 'display' on passes 0, 2 and 4. */
+ (display == 1 && (pass & 1) != 0)))
{
/* Narrow images may have no bits in a pass; the caller should handle
* this, but this test is cheap:
@@ -3153,7 +3157,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) # define S_MASKS(d,s) { S_MASK(0,d,s), S_MASK(1,d,s), S_MASK(2,d,s),\
S_MASK(3,d,s), S_MASK(4,d,s), S_MASK(5,d,s) }
-# define B_MASKS(d,s) { B_MASK(1,d,s), S_MASK(3,d,s), S_MASK(5,d,s) }
+# define B_MASKS(d,s) { B_MASK(1,d,s), B_MASK(3,d,s), B_MASK(5,d,s) }
# define DEPTH_INDEX(d) ((d)==1?0:((d)==2?1:2))
@@ -3189,10 +3193,10 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) */
# define MASK(pass,depth,display,png)\
((display)?B_MASK(pass,depth,png):S_MASK(pass,depth,png))
-#endif /* !PNG_USE_COMPILE_TIME_MASKS */
+#endif /* !USE_COMPILE_TIME_MASKS */
/* Use the appropriate mask to copy the required bits. In some cases
- * the byte mask will be 0 or 0xff, optimize these cases. row_width is
+ * the byte mask will be 0 or 0xff; optimize these cases. row_width is
* the number of pixels, but the code copies bytes, so it is necessary
* to special case the end.
*/
@@ -3200,7 +3204,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) png_uint_32 mask;
# ifdef PNG_READ_PACKSWAP_SUPPORTED
- if (png_ptr->transformations & PNG_PACKSWAP)
+ if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
mask = MASK(pass, pixel_depth, display, 0);
else
@@ -3264,7 +3268,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) }
/* Work out the bytes to copy. */
- if (display)
+ if (display != 0)
{
/* When doing the 'block' algorithm the pixel in the pass gets
* replicated to adjacent pixels. This is why the even (0,2,4,6)
@@ -3331,7 +3335,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) /* This can only be the RGB case, so each copy is exactly one
* pixel and it is not necessary to check for a partial copy.
*/
- for(;;)
+ for (;;)
{
dp[0] = sp[0], dp[1] = sp[1], dp[2] = sp[2];
@@ -3351,24 +3355,24 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) * wide bytes_to_copy either - use the memcpy there.
*/
if (bytes_to_copy < 16 /*else use memcpy*/ &&
- png_isaligned(dp, png_uint_16) &&
- png_isaligned(sp, png_uint_16) &&
- bytes_to_copy % (sizeof (png_uint_16)) == 0 &&
- bytes_to_jump % (sizeof (png_uint_16)) == 0)
+ png_isaligned(dp, png_uint_16) &&
+ png_isaligned(sp, png_uint_16) &&
+ bytes_to_copy % (sizeof (png_uint_16)) == 0 &&
+ bytes_to_jump % (sizeof (png_uint_16)) == 0)
{
/* Everything is aligned for png_uint_16 copies, but try for
* png_uint_32 first.
*/
- if (png_isaligned(dp, png_uint_32) &&
- png_isaligned(sp, png_uint_32) &&
- bytes_to_copy % (sizeof (png_uint_32)) == 0 &&
- bytes_to_jump % (sizeof (png_uint_32)) == 0)
+ if (png_isaligned(dp, png_uint_32) != 0 &&
+ png_isaligned(sp, png_uint_32) != 0 &&
+ bytes_to_copy % (sizeof (png_uint_32)) == 0 &&
+ bytes_to_jump % (sizeof (png_uint_32)) == 0)
{
png_uint_32p dp32 = png_aligncast(png_uint_32p,dp);
png_const_uint_32p sp32 = png_aligncastconst(
- png_const_uint_32p, sp);
+ png_const_uint_32p, sp);
size_t skip = (bytes_to_jump-bytes_to_copy) /
- (sizeof (png_uint_32));
+ (sizeof (png_uint_32));
do
{
@@ -3440,7 +3444,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) return;
}
}
-#endif /* PNG_ALIGN_ code */
+#endif /* ALIGN_TYPE code */
/* The true default - use a memcpy: */
for (;;)
@@ -3464,7 +3468,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) /* Here if pixel_depth < 8 to check 'end_ptr' below. */
}
else
-#endif
+#endif /* READ_INTERLACING */
/* If here then the switch above wasn't used so just memcpy the whole row
* from the temporary row buffer (notice that this overwrites the end of the
@@ -3507,7 +3511,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, int j;
#ifdef PNG_READ_PACKSWAP_SUPPORTED
- if (transformations & PNG_PACKSWAP)
+ if ((transformations & PNG_PACKSWAP) != 0)
{
sshift = (int)((row_info->width + 7) & 0x07);
dshift = (int)((final_width + 7) & 0x07);
@@ -3567,7 +3571,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, png_uint_32 i;
#ifdef PNG_READ_PACKSWAP_SUPPORTED
- if (transformations & PNG_PACKSWAP)
+ if ((transformations & PNG_PACKSWAP) != 0)
{
sshift = (int)(((row_info->width + 3) & 0x03) << 1);
dshift = (int)(((final_width + 3) & 0x03) << 1);
@@ -3630,7 +3634,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, int jstop = png_pass_inc[pass];
#ifdef PNG_READ_PACKSWAP_SUPPORTED
- if (transformations & PNG_PACKSWAP)
+ if ((transformations & PNG_PACKSWAP) != 0)
{
sshift = (int)(((row_info->width + 1) & 0x01) << 2);
dshift = (int)(((final_width + 1) & 0x01) << 2);
@@ -3720,7 +3724,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, PNG_UNUSED(transformations) /* Silence compiler warning */
#endif
}
-#endif /* PNG_READ_INTERLACING_SUPPORTED */
+#endif /* READ_INTERLACING */
static void
png_read_filter_row_sub(png_row_infop row_info, png_bytep row,
@@ -4071,7 +4075,7 @@ png_read_finish_IDAT(png_structrp png_ptr) * read it otherwise stray unread IDAT data or, more likely, an IDAT chunk
* may still remain to be consumed.
*/
- if (!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
+ if ((png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0)
{
/* The NULL causes png_read_IDAT_data to swallow any remaining bytes in
* the compressed stream, but the stream may be damaged too, so even after
@@ -4083,7 +4087,7 @@ png_read_finish_IDAT(png_structrp png_ptr) /* Now clear everything out for safety; the following may not have been
* done.
*/
- if (!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
+ if ((png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0)
{
png_ptr->mode |= PNG_AFTER_IDAT;
png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
@@ -4114,7 +4118,6 @@ png_read_finish_IDAT(png_structrp png_ptr) void /* PRIVATE */
png_read_finish_row(png_structrp png_ptr)
{
-#ifdef PNG_READ_INTERLACING_SUPPORTED
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* Start of interlace block */
@@ -4128,15 +4131,13 @@ png_read_finish_row(png_structrp png_ptr) /* Offset to next interlace block in the y direction */
static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
-#endif /* PNG_READ_INTERLACING_SUPPORTED */
png_debug(1, "in png_read_finish_row");
png_ptr->row_number++;
if (png_ptr->row_number < png_ptr->num_rows)
return;
-#ifdef PNG_READ_INTERLACING_SUPPORTED
- if (png_ptr->interlaced)
+ if (png_ptr->interlaced != 0)
{
png_ptr->row_number = 0;
@@ -4157,7 +4158,7 @@ png_read_finish_row(png_structrp png_ptr) png_pass_start[png_ptr->pass]) /
png_pass_inc[png_ptr->pass];
- if (!(png_ptr->transformations & PNG_INTERLACE))
+ if ((png_ptr->transformations & PNG_INTERLACE) == 0)
{
png_ptr->num_rows = (png_ptr->height +
png_pass_yinc[png_ptr->pass] - 1 -
@@ -4173,17 +4174,15 @@ png_read_finish_row(png_structrp png_ptr) if (png_ptr->pass < 7)
return;
}
-#endif /* PNG_READ_INTERLACING_SUPPORTED */
/* Here after at the end of the last row of the last pass. */
png_read_finish_IDAT(png_ptr);
}
-#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
+#endif /* SEQUENTIAL_READ */
void /* PRIVATE */
png_read_start_row(png_structrp png_ptr)
{
-#ifdef PNG_READ_INTERLACING_SUPPORTED
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* Start of interlace block */
@@ -4197,7 +4196,6 @@ png_read_start_row(png_structrp png_ptr) /* Offset to next interlace block in the y direction */
static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
-#endif
int max_pixel_depth;
png_size_t row_bytes;
@@ -4207,10 +4205,9 @@ png_read_start_row(png_structrp png_ptr) #ifdef PNG_READ_TRANSFORMS_SUPPORTED
png_init_read_transformations(png_ptr);
#endif
-#ifdef PNG_READ_INTERLACING_SUPPORTED
- if (png_ptr->interlaced)
+ if (png_ptr->interlaced != 0)
{
- if (!(png_ptr->transformations & PNG_INTERLACE))
+ if ((png_ptr->transformations & PNG_INTERLACE) == 0)
png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 -
png_pass_ystart[0]) / png_pass_yinc[0];
@@ -4224,7 +4221,6 @@ png_read_start_row(png_structrp png_ptr) }
else
-#endif /* PNG_READ_INTERLACING_SUPPORTED */
{
png_ptr->num_rows = png_ptr->height;
png_ptr->iwidth = png_ptr->width;
@@ -4243,16 +4239,16 @@ png_read_start_row(png_structrp png_ptr) * TODO: fix this.
*/
#ifdef PNG_READ_PACK_SUPPORTED
- if ((png_ptr->transformations & PNG_PACK) && png_ptr->bit_depth < 8)
+ if ((png_ptr->transformations & PNG_PACK) != 0 && png_ptr->bit_depth < 8)
max_pixel_depth = 8;
#endif
#ifdef PNG_READ_EXPAND_SUPPORTED
- if (png_ptr->transformations & PNG_EXPAND)
+ if ((png_ptr->transformations & PNG_EXPAND) != 0)
{
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
- if (png_ptr->num_trans)
+ if (png_ptr->num_trans != 0)
max_pixel_depth = 32;
else
@@ -4264,13 +4260,13 @@ png_read_start_row(png_structrp png_ptr) if (max_pixel_depth < 8)
max_pixel_depth = 8;
- if (png_ptr->num_trans)
+ if (png_ptr->num_trans != 0)
max_pixel_depth *= 2;
}
else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)
{
- if (png_ptr->num_trans)
+ if (png_ptr->num_trans != 0)
{
max_pixel_depth *= 4;
max_pixel_depth /= 3;
@@ -4280,13 +4276,13 @@ png_read_start_row(png_structrp png_ptr) #endif
#ifdef PNG_READ_EXPAND_16_SUPPORTED
- if (png_ptr->transformations & PNG_EXPAND_16)
+ if ((png_ptr->transformations & PNG_EXPAND_16) != 0)
{
# ifdef PNG_READ_EXPAND_SUPPORTED
/* In fact it is an error if it isn't supported, but checking is
* the safe way.
*/
- if (png_ptr->transformations & PNG_EXPAND)
+ if ((png_ptr->transformations & PNG_EXPAND) != 0)
{
if (png_ptr->bit_depth < 16)
max_pixel_depth *= 2;
@@ -4298,7 +4294,7 @@ png_read_start_row(png_structrp png_ptr) #endif
#ifdef PNG_READ_FILLER_SUPPORTED
- if (png_ptr->transformations & (PNG_FILLER))
+ if ((png_ptr->transformations & (PNG_FILLER)) != 0)
{
if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY)
{
@@ -4322,14 +4318,15 @@ png_read_start_row(png_structrp png_ptr) #endif
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
- if (png_ptr->transformations & PNG_GRAY_TO_RGB)
+ if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0)
{
if (
#ifdef PNG_READ_EXPAND_SUPPORTED
- (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND)) ||
+ (png_ptr->num_trans != 0 &&
+ (png_ptr->transformations & PNG_EXPAND) != 0) ||
#endif
#ifdef PNG_READ_FILLER_SUPPORTED
- (png_ptr->transformations & (PNG_FILLER)) ||
+ (png_ptr->transformations & (PNG_FILLER)) != 0 ||
#endif
png_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
{
@@ -4362,7 +4359,7 @@ png_read_start_row(png_structrp png_ptr) #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \
defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
- if (png_ptr->transformations & PNG_USER_TRANSFORM)
+ if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
{
int user_pixel_depth = png_ptr->user_transform_depth *
png_ptr->user_transform_channels;
@@ -4398,7 +4395,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) png_free(png_ptr, png_ptr->big_row_buf);
png_free(png_ptr, png_ptr->big_prev_row);
- if (png_ptr->interlaced)
+ if (png_ptr->interlaced != 0)
png_ptr->big_row_buf = (png_bytep)png_calloc(png_ptr,
row_bytes + 48);
@@ -4455,7 +4452,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) * does not, so free the read buffer now regardless; the sequential reader
* reallocates it on demand.
*/
- if (png_ptr->read_buffer)
+ if (png_ptr->read_buffer != 0)
{
png_bytep buffer = png_ptr->read_buffer;
@@ -4474,4 +4471,4 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) png_ptr->flags |= PNG_FLAG_ROW_INIT;
}
-#endif /* PNG_READ_SUPPORTED */
+#endif /* READ */
diff --git a/plugins/AdvaImg/src/LibPNG/pngset.c b/plugins/AdvaImg/src/LibPNG/pngset.c index 6a7417a39c..cfeda8d63b 100644 --- a/plugins/AdvaImg/src/LibPNG/pngset.c +++ b/plugins/AdvaImg/src/LibPNG/pngset.c @@ -1,8 +1,8 @@ /* pngset.c - storage of image information into info struct
*
- * Last changed in libpng 1.6.8 [December 19, 2013]
- * Copyright (c) 1998-2013 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.15 [November 20, 2014]
+ * Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@@ -59,7 +59,7 @@ png_set_cHRM_fixed(png_const_structrp png_ptr, png_inforp info_ptr, xy.whitey = white_y;
if (png_colorspace_set_chromaticities(png_ptr, &info_ptr->colorspace, &xy,
- 2/* override with app values*/))
+ 2/* override with app values*/) != 0)
info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM;
png_colorspace_sync_info(png_ptr, info_ptr);
@@ -90,7 +90,8 @@ png_set_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_inforp info_ptr, XYZ.blue_Y = int_blue_Y;
XYZ.blue_Z = int_blue_Z;
- if (png_colorspace_set_endpoints(png_ptr, &info_ptr->colorspace, &XYZ, 2))
+ if (png_colorspace_set_endpoints(png_ptr, &info_ptr->colorspace,
+ &XYZ, 2) != 0)
info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM;
png_colorspace_sync_info(png_ptr, info_ptr);
@@ -129,9 +130,9 @@ png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X, png_fixed(png_ptr, blue_Y, "cHRM Red Y"),
png_fixed(png_ptr, blue_Z, "cHRM Red Z"));
}
-# endif /* PNG_FLOATING_POINT_SUPPORTED */
+# endif /* FLOATING_POINT */
-#endif /* PNG_cHRM_SUPPORTED */
+#endif /* cHRM */
#ifdef PNG_gAMA_SUPPORTED
void PNGFAPI
@@ -227,13 +228,13 @@ png_set_IHDR(png_const_structrp png_ptr, png_inforp info_ptr, if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
info_ptr->channels = 1;
- else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)
+ else if ((info_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
info_ptr->channels = 3;
else
info_ptr->channels = 1;
- if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
+ if ((info_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)
info_ptr->channels++;
info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
@@ -288,12 +289,14 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, /* Validate params[nparams] */
for (i=0; i<nparams; ++i)
+ {
if (params[i] == NULL ||
- !png_check_fp_string(params[i], strlen(params[i])))
+ !png_check_fp_string(params[i], strlen(params[i])))
png_error(png_ptr, "Invalid format for pCAL parameter");
+ }
info_ptr->pcal_purpose = png_voidcast(png_charp,
- png_malloc_warn(png_ptr, length));
+ png_malloc_warn(png_ptr, length));
if (info_ptr->pcal_purpose == NULL)
{
@@ -594,7 +597,8 @@ png_set_sRGB_gAMA_and_cHRM(png_const_structrp png_ptr, png_inforp info_ptr, if (png_ptr == NULL || info_ptr == NULL)
return;
- if (png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace, srgb_intent))
+ if (png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace,
+ srgb_intent) != 0)
{
/* This causes the gAMA and cHRM to be written too */
info_ptr->colorspace.flags |=
@@ -637,7 +641,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, png_colorspace_sync_info(png_ptr, info_ptr);
/* Don't do any of the copying if the profile was bad, or inconsistent. */
- if (!result)
+ if (result == 0)
return;
/* But do write the gAMA and cHRM chunks from the profile. */
@@ -661,6 +665,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, if (new_iccp_profile == NULL)
{
png_free(png_ptr, new_iccp_name);
+ new_iccp_name = NULL;
png_benign_error(png_ptr,
"Insufficient memory to process iCCP profile");
return;
@@ -686,7 +691,7 @@ png_set_text(png_const_structrp png_ptr, png_inforp info_ptr, int ret;
ret = png_set_text_2(png_ptr, info_ptr, text_ptr, num_text);
- if (ret)
+ if (ret != 0)
png_error(png_ptr, "Insufficient memory to store text");
}
@@ -726,7 +731,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr, else
max_text = INT_MAX;
- /* Now allocate a new array and copy the old members in, this does all
+ /* Now allocate a new array and copy the old members in; this does all
* the overflow checks.
*/
new_text = png_voidcast(png_textp,png_realloc_array(png_ptr,
@@ -855,7 +860,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr, textp->text = textp->key + key_len + 1;
}
- if (text_length)
+ if (text_length != 0)
memcpy(textp->text, text_ptr[i].text, text_length);
*(textp->text + text_length) = '\0';
@@ -890,7 +895,7 @@ png_set_tIME(png_const_structrp png_ptr, png_inforp info_ptr, png_debug1(1, "in %s storage function", "tIME");
if (png_ptr == NULL || info_ptr == NULL || mod_time == NULL ||
- (png_ptr->mode & PNG_WROTE_tIME))
+ (png_ptr->mode & PNG_WROTE_tIME) != 0)
return;
if (mod_time->month == 0 || mod_time->month > 12 ||
@@ -1020,8 +1025,8 @@ png_set_sPLT(png_const_structrp png_ptr, np->depth = entries->depth;
- /* In the even of out-of-memory just return - there's no point keeping on
- * trying to add sPLT chunks.
+ /* In the event of out-of-memory just return - there's no point keeping
+ * on trying to add sPLT chunks.
*/
length = strlen(entries->name) + 1;
np->name = png_voidcast(png_charp, png_malloc_base(png_ptr, length));
@@ -1032,8 +1037,8 @@ png_set_sPLT(png_const_structrp png_ptr, memcpy(np->name, entries->name, length);
/* IMPORTANT: we have memory now that won't get freed if something else
- * goes wrong, this code must free it. png_malloc_array produces no
- * warnings, use a png_chunk_report (below) if there is an error.
+ * goes wrong; this code must free it. png_malloc_array produces no
+ * warnings; use a png_chunk_report (below) if there is an error.
*/
np->entries = png_voidcast(png_sPLT_entryp, png_malloc_array(png_ptr,
entries->nentries, sizeof (png_sPLT_entry)));
@@ -1041,6 +1046,7 @@ png_set_sPLT(png_const_structrp png_ptr, if (np->entries == NULL)
{
png_free(png_ptr, np->name);
+ np->name = NULL;
break;
}
@@ -1063,7 +1069,7 @@ png_set_sPLT(png_const_structrp png_ptr, if (nentries > 0)
png_chunk_report(png_ptr, "sPLT out of memory", PNG_CHUNK_WRITE_ERROR);
}
-#endif /* PNG_sPLT_SUPPORTED */
+#endif /* sPLT */
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
static png_byte
@@ -1072,10 +1078,10 @@ check_location(png_const_structrp png_ptr, int location) location &= (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT);
/* New in 1.6.0; copy the location and check it. This is an API
- * change, previously the app had to use the
+ * change; previously the app had to use the
* png_set_unknown_chunk_location API below for each chunk.
*/
- if (location == 0 && !(png_ptr->mode & PNG_IS_READ_STRUCT))
+ if (location == 0 && (png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
{
/* Write struct, so unknown chunks come from the app */
png_app_warning(png_ptr,
@@ -1121,7 +1127,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr, */
# if !defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) && \
defined(PNG_READ_SUPPORTED)
- if (png_ptr->mode & PNG_IS_READ_STRUCT)
+ if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
{
png_app_error(png_ptr, "no unknown chunk support on read");
return;
@@ -1129,7 +1135,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr, # endif
# if !defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) && \
defined(PNG_WRITE_SUPPORTED)
- if (!(png_ptr->mode & PNG_IS_READ_STRUCT))
+ if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
{
png_app_error(png_ptr, "no unknown chunk support on write");
return;
@@ -1215,7 +1221,7 @@ png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr, {
png_app_error(png_ptr, "invalid unknown chunk location");
/* Fake out the pre 1.6.0 behavior: */
- if ((location & PNG_HAVE_IDAT)) /* undocumented! */
+ if ((location & PNG_HAVE_IDAT) != 0) /* undocumented! */
location = PNG_AFTER_IDAT;
else
@@ -1253,10 +1259,13 @@ add_one_chunk(png_bytep list, unsigned int count, png_const_bytep add, int keep) /* Utility function: update the 'keep' state of a chunk if it is already in
* the list, otherwise add it to the list.
*/
- for (i=0; i<count; ++i, list += 5) if (memcmp(list, add, 4) == 0)
+ for (i=0; i<count; ++i, list += 5)
{
- list[4] = (png_byte)keep;
- return count;
+ if (memcmp(list, add, 4) == 0)
+ {
+ list[4] = (png_byte)keep;
+ return count;
+ }
}
if (keep != PNG_HANDLE_CHUNK_AS_DEFAULT)
@@ -1320,7 +1329,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep, };
chunk_list = chunks_to_ignore;
- num_chunks = (sizeof chunks_to_ignore)/5;
+ num_chunks = (unsigned int)/*SAFE*/(sizeof chunks_to_ignore)/5U;
}
else /* num_chunks_in > 0 */
@@ -1353,7 +1362,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep, * required because add_one_chunk above doesn't extend the list if the 'keep'
* parameter is the default.
*/
- if (keep)
+ if (keep != 0)
{
new_list = png_voidcast(png_bytep, png_malloc(png_ptr,
5 * (num_chunks + old_num_chunks)));
@@ -1380,12 +1389,15 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep, unsigned int i;
for (i=0; i<num_chunks; ++i)
+ {
old_num_chunks = add_one_chunk(new_list, old_num_chunks,
chunk_list+5*i, keep);
+ }
/* Now remove any spurious 'default' entries. */
num_chunks = 0;
for (i=0, inlist=outlist=new_list; i<old_num_chunks; ++i, inlist += 5)
+ {
if (inlist[4])
{
if (outlist != inlist)
@@ -1393,6 +1405,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep, outlist += 5;
++num_chunks;
}
+ }
/* This means the application has removed all the specialized handling. */
if (num_chunks == 0)
@@ -1444,12 +1457,13 @@ png_set_rows(png_const_structrp png_ptr, png_inforp info_ptr, if (png_ptr == NULL || info_ptr == NULL)
return;
- if (info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers))
+ if (info_ptr->row_pointers != NULL &&
+ (info_ptr->row_pointers != row_pointers))
png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
info_ptr->row_pointers = row_pointers;
- if (row_pointers)
+ if (row_pointers != NULL)
info_ptr->valid |= PNG_INFO_IDAT;
}
#endif
@@ -1464,7 +1478,7 @@ png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size) png_error(png_ptr, "invalid compression buffer size");
# ifdef PNG_SEQUENTIAL_READ_SUPPORTED
- if (png_ptr->mode & PNG_IS_READ_STRUCT)
+ if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
{
png_ptr->IDAT_read_size = (png_uint_32)size; /* checked above */
return;
@@ -1472,7 +1486,7 @@ png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size) # endif
# ifdef PNG_WRITE_SUPPORTED
- if (!(png_ptr->mode & PNG_IS_READ_STRUCT))
+ if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
{
if (png_ptr->zowner != 0)
{
@@ -1510,7 +1524,7 @@ png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size) void PNGAPI
png_set_invalid(png_const_structrp png_ptr, png_inforp info_ptr, int mask)
{
- if (png_ptr && info_ptr)
+ if (png_ptr != NULL && info_ptr != NULL)
info_ptr->valid &= ~mask;
}
@@ -1536,7 +1550,7 @@ png_set_user_limits (png_structrp png_ptr, png_uint_32 user_width_max, void PNGAPI
png_set_chunk_cache_max (png_structrp png_ptr, png_uint_32 user_chunk_cache_max)
{
- if (png_ptr)
+ if (png_ptr != NULL)
png_ptr->user_chunk_cache_max = user_chunk_cache_max;
}
@@ -1545,10 +1559,10 @@ void PNGAPI png_set_chunk_malloc_max (png_structrp png_ptr,
png_alloc_size_t user_chunk_malloc_max)
{
- if (png_ptr)
+ if (png_ptr != NULL)
png_ptr->user_chunk_malloc_max = user_chunk_malloc_max;
}
-#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
+#endif /* ?SET_USER_LIMITS */
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
@@ -1563,7 +1577,7 @@ png_set_benign_errors(png_structrp png_ptr, int allowed) * is the default behavior if png_set_benign_errors() is not called).
*/
- if (allowed)
+ if (allowed != 0)
png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN |
PNG_FLAG_APP_WARNINGS_WARN | PNG_FLAG_APP_ERRORS_WARN;
@@ -1571,14 +1585,14 @@ png_set_benign_errors(png_structrp png_ptr, int allowed) png_ptr->flags &= ~(PNG_FLAG_BENIGN_ERRORS_WARN |
PNG_FLAG_APP_WARNINGS_WARN | PNG_FLAG_APP_ERRORS_WARN);
}
-#endif /* PNG_BENIGN_ERRORS_SUPPORTED */
+#endif /* BENIGN_ERRORS */
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
/* Whether to report invalid palette index; added at libng-1.5.10.
* It is possible for an indexed (color-type==3) PNG file to contain
* pixels with invalid (out-of-range) indexes if the PLTE chunk has
* fewer entries than the image's bit-depth would allow. We recover
- * from this gracefully by filling any incomplete palette with zeroes
+ * from this gracefully by filling any incomplete palette with zeros
* (opaque black). By default, when this occurs libpng will issue
* a benign error. This API can be used to override that behavior.
*/
@@ -1594,4 +1608,4 @@ png_set_check_for_invalid_index(png_structrp png_ptr, int allowed) png_ptr->num_palette_max = -1;
}
#endif
-#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
+#endif /* READ || WRITE */
diff --git a/plugins/AdvaImg/src/LibPNG/pngstruct.h b/plugins/AdvaImg/src/LibPNG/pngstruct.h index b6935534c5..039ddd409e 100644 --- a/plugins/AdvaImg/src/LibPNG/pngstruct.h +++ b/plugins/AdvaImg/src/LibPNG/pngstruct.h @@ -274,7 +274,7 @@ struct png_struct_def #ifdef PNG_READ_GAMMA_SUPPORTED
png_color_16 background_1; /* background normalized to gamma 1.0 */
#endif
-#endif /* PNG_bKGD_SUPPORTED */
+#endif /* bKGD */
#ifdef PNG_WRITE_FLUSH_SUPPORTED
png_flush_ptr output_flush_fn; /* Function for flushing output */
@@ -331,7 +331,7 @@ struct png_struct_def int process_mode; /* what push library is currently doing */
int cur_palette; /* current push library palette index */
-#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
+#endif /* PROGRESSIVE_READ */
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
/* For the Borland special 64K segment handler */
diff --git a/plugins/AdvaImg/src/LibPNG/pngtest.c b/plugins/AdvaImg/src/LibPNG/pngtest.c index 7eeb0b8839..0064064eb2 100644 --- a/plugins/AdvaImg/src/LibPNG/pngtest.c +++ b/plugins/AdvaImg/src/LibPNG/pngtest.c @@ -1,7 +1,7 @@ /* pngtest.c - a simple test program to test libpng
*
- * Last changed in libpng 1.6.9 [February 6, 2014]
+ * Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -283,7 +283,8 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data) png_uint_32 n, nstop;
int channel;
int color_channels = row_info->channels;
- if (row_info->color_type > 3)color_channels--;
+ if (row_info->color_type > 3)
+ color_channels--;
for (n = 0, nstop=row_info->width; n<nstop; n++)
{
@@ -310,7 +311,7 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data) }
}
}
-#endif /* PNG_WRITE_USER_TRANSFORM_SUPPORTED */
+#endif /* WRITE_USER_TRANSFORM */
#ifndef PNG_STDIO_SUPPORTED
/* START of code to validate stdio-free compilation */
@@ -359,7 +360,7 @@ pngtest_check_io_state(png_structp png_ptr, png_size_t data_length, default:
err = 1; /* uninitialized */
}
- if (err)
+ if (err != 0)
png_error(png_ptr, "Bad I/O state or buffer size");
}
#endif
@@ -419,7 +420,7 @@ pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length) pngtest_check_io_state(png_ptr, length, PNG_IO_WRITING);
#endif
}
-#endif /* !PNG_STDIO_SUPPORTED */
+#endif /* !STDIO */
/* This function is called when there is a warning, but the library thinks
* it can continue anyway. Replacement functions don't have to do anything
@@ -540,7 +541,7 @@ PNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size) /* Make sure the caller isn't assuming zeroed memory. */
memset(pinfo->pointer, 0xdd, pinfo->size);
- if (verbose)
+ if (verbose != 0)
printf("png_malloc %lu bytes at %p\n", (unsigned long)size,
pinfo->pointer);
@@ -580,7 +581,7 @@ png_debug_free(png_structp png_ptr, png_voidp ptr) /* We must free the list element too, but first kill
the memory that is to be freed. */
memset(ptr, 0x55, pinfo->size);
- if (pinfo)
+ if (pinfo != NULL)
free(pinfo);
pinfo = NULL;
break;
@@ -588,7 +589,7 @@ png_debug_free(png_structp png_ptr, png_voidp ptr) if (pinfo->next == NULL)
{
- fprintf(STDERR, "Pointer %x not found\n", (unsigned int)ptr);
+ fprintf(STDERR, "Pointer %p not found\n", ptr);
break;
}
@@ -597,14 +598,14 @@ png_debug_free(png_structp png_ptr, png_voidp ptr) }
/* Finally free the data. */
- if (verbose)
+ if (verbose != 0)
printf("Freeing %p\n", ptr);
- if (ptr)
+ if (ptr != NULL)
free(ptr);
ptr = NULL;
}
-#endif /* PNG_USER_MEM_SUPPORTED && PNG_DEBUG */
+#endif /* USER_MEM && DEBUG */
/* END of code to test memory allocation/deallocation */
@@ -643,16 +644,16 @@ set_location(png_structp png_ptr, struct user_chunk_data *data, int what) {
int location;
- if ((data->location[0] & what) || (data->location[1] & what))
+ if ((data->location[0] & what) != 0 || (data->location[1] & what) != 0)
return 0; /* already have one of these */
- /* Find where we are (the code below zeros info_ptr to indicate that the
+ /* Find where we are (the code below zeroes info_ptr to indicate that the
* chunks before the first IDAT have been read.)
*/
if (data->info_ptr == NULL) /* after IDAT */
location = what | after_IDAT;
- else if (png_get_valid(png_ptr, data->info_ptr, PNG_INFO_PLTE))
+ else if (png_get_valid(png_ptr, data->info_ptr, PNG_INFO_PLTE) != 0)
location = what | before_IDAT;
else
@@ -699,7 +700,7 @@ read_user_chunk_callback(png_struct *png_ptr, png_unknown_chunkp chunk) if (chunk->data[0] != 0 && chunk->data[0] != 1)
return (-1); /* Invalid mode */
- if (set_location(png_ptr, my_user_chunk_data, have_sTER))
+ if (set_location(png_ptr, my_user_chunk_data, have_sTER) != 0)
{
my_user_chunk_data->sTER_mode=chunk->data[0];
return (1);
@@ -718,7 +719,7 @@ read_user_chunk_callback(png_struct *png_ptr, png_unknown_chunkp chunk) if (chunk->size != 9)
return (-1); /* Error return */
- if (!set_location(png_ptr, my_user_chunk_data, have_vpAg))
+ if (set_location(png_ptr, my_user_chunk_data, have_vpAg) == 0)
return (0); /* duplicate vpAg */
my_user_chunk_data->vpAg_width = png_get_uint_31(png_ptr, chunk->data);
@@ -734,7 +735,7 @@ write_sTER_chunk(png_structp write_ptr) {
png_byte sTER[5] = {115, 84, 69, 82, '\0'};
- if (verbose)
+ if (verbose != 0)
fprintf(STDERR, "\n stereo mode = %d\n", user_chunk_data.sTER_mode);
png_write_chunk(write_ptr, sTER, &user_chunk_data.sTER_mode, 1);
@@ -747,7 +748,7 @@ write_vpAg_chunk(png_structp write_ptr) png_byte vpag_chunk_data[9];
- if (verbose)
+ if (verbose != 0)
fprintf(STDERR, " vpAg = %lu x %lu, units = %d\n",
(unsigned long)user_chunk_data.vpAg_width,
(unsigned long)user_chunk_data.vpAg_height,
@@ -779,8 +780,8 @@ write_chunks(png_structp write_ptr, int location) write_vpAg_chunk(write_ptr);
}
}
-#endif /* PNG_WRITE_SUPPORTED */
-#else /* !PNG_READ_USER_CHUNKS_SUPPORTED */
+#endif /* WRITE */
+#else /* !READ_USER_CHUNKS */
# define write_chunks(pp,loc) ((void)0)
#endif
/* END of code to demonstrate user chunk support */
@@ -938,7 +939,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) #endif
#endif
- if (strict)
+ if (strict != 0)
{
/* Treat png_benign_error() as errors on read */
png_set_benign_errors(read_ptr, 0);
@@ -954,7 +955,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) */
}
- else if (relaxed)
+ else if (relaxed != 0)
{
/* Allow application (pngtest) errors and warnings to pass */
png_set_benign_errors(read_ptr, 1);
@@ -1049,7 +1050,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) int interlace_type, compression_type, filter_type;
if (png_get_IHDR(read_ptr, read_info_ptr, &width, &height, &bit_depth,
- &color_type, &interlace_type, &compression_type, &filter_type))
+ &color_type, &interlace_type, &compression_type, &filter_type) != 0)
{
png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth,
color_type, interlace_type, compression_type, filter_type);
@@ -1082,7 +1083,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) blue_y;
if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y,
- &red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y))
+ &red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y) != 0)
{
png_set_cHRM_fixed(write_ptr, write_info_ptr, white_x, white_y, red_x,
red_y, green_x, green_y, blue_x, blue_y);
@@ -1093,7 +1094,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) {
png_fixed_point gamma;
- if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma))
+ if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma) != 0)
png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma);
}
#endif
@@ -1105,7 +1106,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) blue_y;
if (png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x,
- &red_y, &green_x, &green_y, &blue_x, &blue_y))
+ &red_y, &green_x, &green_y, &blue_x, &blue_y) != 0)
{
png_set_cHRM(write_ptr, write_info_ptr, white_x, white_y, red_x,
red_y, green_x, green_y, blue_x, blue_y);
@@ -1116,7 +1117,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) {
double gamma;
- if (png_get_gAMA(read_ptr, read_info_ptr, &gamma))
+ if (png_get_gAMA(read_ptr, read_info_ptr, &gamma) != 0)
png_set_gAMA(write_ptr, write_info_ptr, gamma);
}
#endif
@@ -1130,7 +1131,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) int compression_type;
if (png_get_iCCP(read_ptr, read_info_ptr, &name, &compression_type,
- &profile, &proflen))
+ &profile, &proflen) != 0)
{
png_set_iCCP(write_ptr, write_info_ptr, name, compression_type,
profile, proflen);
@@ -1141,7 +1142,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) {
int intent;
- if (png_get_sRGB(read_ptr, read_info_ptr, &intent))
+ if (png_get_sRGB(read_ptr, read_info_ptr, &intent) != 0)
png_set_sRGB(write_ptr, write_info_ptr, intent);
}
#endif
@@ -1149,14 +1150,14 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) png_colorp palette;
int num_palette;
- if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette))
+ if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette) != 0)
png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette);
}
#ifdef PNG_bKGD_SUPPORTED
{
png_color_16p background;
- if (png_get_bKGD(read_ptr, read_info_ptr, &background))
+ if (png_get_bKGD(read_ptr, read_info_ptr, &background) != 0)
{
png_set_bKGD(write_ptr, write_info_ptr, background);
}
@@ -1166,7 +1167,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) {
png_uint_16p hist;
- if (png_get_hIST(read_ptr, read_info_ptr, &hist))
+ if (png_get_hIST(read_ptr, read_info_ptr, &hist) != 0)
png_set_hIST(write_ptr, write_info_ptr, hist);
}
#endif
@@ -1176,7 +1177,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) int unit_type;
if (png_get_oFFs(read_ptr, read_info_ptr, &offset_x, &offset_y,
- &unit_type))
+ &unit_type) != 0)
{
png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type);
}
@@ -1190,7 +1191,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) int type, nparams;
if (png_get_pCAL(read_ptr, read_info_ptr, &purpose, &X0, &X1, &type,
- &nparams, &units, ¶ms))
+ &nparams, &units, ¶ms) != 0)
{
png_set_pCAL(write_ptr, write_info_ptr, purpose, X0, X1, type,
nparams, units, params);
@@ -1202,7 +1203,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) png_uint_32 res_x, res_y;
int unit_type;
- if (png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y, &unit_type))
+ if (png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y,
+ &unit_type) != 0)
png_set_pHYs(write_ptr, write_info_ptr, res_x, res_y, unit_type);
}
#endif
@@ -1210,7 +1212,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) {
png_color_8p sig_bit;
- if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit))
+ if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit) != 0)
png_set_sBIT(write_ptr, write_info_ptr, sig_bit);
}
#endif
@@ -1222,7 +1224,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) double scal_width, scal_height;
if (png_get_sCAL(read_ptr, read_info_ptr, &unit, &scal_width,
- &scal_height))
+ &scal_height) != 0)
{
png_set_sCAL(write_ptr, write_info_ptr, unit, scal_width, scal_height);
}
@@ -1234,7 +1236,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) png_charp scal_width, scal_height;
if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &scal_width,
- &scal_height))
+ &scal_height) != 0)
{
png_set_sCAL_s(write_ptr, write_info_ptr, unit, scal_width,
scal_height);
@@ -1254,7 +1256,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) pngtest_check_text_support(read_ptr, text_ptr, num_text);
- if (verbose)
+ if (verbose != 0)
{
int i;
@@ -1274,11 +1276,11 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) {
png_timep mod_time;
- if (png_get_tIME(read_ptr, read_info_ptr, &mod_time))
+ if (png_get_tIME(read_ptr, read_info_ptr, &mod_time) != 0)
{
png_set_tIME(write_ptr, write_info_ptr, mod_time);
#ifdef PNG_TIME_RFC1123_SUPPORTED
- if (png_convert_to_rfc1123_buffer(tIME_string, mod_time))
+ if (png_convert_to_rfc1123_buffer(tIME_string, mod_time) != 0)
tIME_string[(sizeof tIME_string) - 1] = '\0';
else
@@ -1288,7 +1290,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) }
tIME_chunk_present++;
-#endif /* PNG_TIME_RFC1123_SUPPORTED */
+#endif /* TIME_RFC1123 */
}
}
#endif
@@ -1299,7 +1301,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) png_color_16p trans_color;
if (png_get_tRNS(read_ptr, read_info_ptr, &trans_alpha, &num_trans,
- &trans_color))
+ &trans_color) != 0)
{
int sample_max = (1 << bit_depth);
/* libpng doesn't reject a tRNS chunk with out-of-range samples */
@@ -1320,7 +1322,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) int num_unknowns = png_get_unknown_chunks(read_ptr, read_info_ptr,
&unknowns);
- if (num_unknowns)
+ if (num_unknowns != 0)
{
png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns,
num_unknowns);
@@ -1382,11 +1384,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) {
#ifndef SINGLE_ROWBUF_ALLOC
pngtest_debug2("Allocating row buffer (pass %d, y = %u)...", pass, y);
+
row_buf = (png_bytep)png_malloc(read_ptr,
png_get_rowbytes(read_ptr, read_info_ptr));
- pngtest_debug2("\t0x%08lx (%u bytes)", (unsigned long)row_buf,
- png_get_rowbytes(read_ptr, read_info_ptr));
+ pngtest_debug2("\t0x%08lx (%lu bytes)", (unsigned long)row_buf,
+ (unsigned long)png_get_rowbytes(read_ptr, read_info_ptr));
#endif /* !SINGLE_ROWBUF_ALLOC */
png_read_rows(read_ptr, (png_bytepp)&row_buf, NULL, 1);
@@ -1403,7 +1406,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) t_encode += (t_stop - t_start);
t_start = t_stop;
#endif
-#endif /* PNG_WRITE_SUPPORTED */
+#endif /* WRITE */
#ifndef SINGLE_ROWBUF_ALLOC
pngtest_debug2("Freeing row buffer (pass %d, y = %u)", pass, y);
@@ -1436,7 +1439,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) pngtest_check_text_support(read_ptr, text_ptr, num_text);
- if (verbose)
+ if (verbose != 0)
{
int i;
@@ -1456,11 +1459,11 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) {
png_timep mod_time;
- if (png_get_tIME(read_ptr, end_info_ptr, &mod_time))
+ if (png_get_tIME(read_ptr, end_info_ptr, &mod_time) != 0)
{
png_set_tIME(write_ptr, write_end_info_ptr, mod_time);
#ifdef PNG_TIME_RFC1123_SUPPORTED
- if (png_convert_to_rfc1123_buffer(tIME_string, mod_time))
+ if (png_convert_to_rfc1123_buffer(tIME_string, mod_time) != 0)
tIME_string[(sizeof tIME_string) - 1] = '\0';
else
@@ -1470,7 +1473,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) }
tIME_chunk_present++;
-#endif /* PNG_TIME_RFC1123_SUPPORTED */
+#endif /* TIME_RFC1123 */
}
}
#endif
@@ -1480,7 +1483,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) int num_unknowns = png_get_unknown_chunks(read_ptr, end_info_ptr,
&unknowns);
- if (num_unknowns)
+ if (num_unknowns != 0)
{
png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns,
num_unknowns);
@@ -1521,7 +1524,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) #endif
#ifdef PNG_EASY_ACCESS_SUPPORTED
- if (verbose)
+ if (verbose != 0)
{
png_uint_32 iwidth, iheight;
iwidth = png_get_image_width(write_ptr, write_info_ptr);
@@ -1599,7 +1602,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) }
#ifdef PNG_WRITE_SUPPORTED /* else nothing was written */
- if (interlace_preserved) /* else the files will be changed */
+ if (interlace_preserved != 0) /* else the files will be changed */
{
for (;;)
{
@@ -1638,7 +1641,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) return (0);
}
- if (!num_in)
+ if (num_in == 0)
break;
if (memcmp(inbuf, outbuf, num_in))
@@ -1675,7 +1678,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) }
}
}
-#endif /* PNG_WRITE_SUPPORTED */
+#endif /* WRITE */
FCLOSE(fpin);
FCLOSE(fpout);
@@ -1780,10 +1783,11 @@ main(int argc, char *argv[]) }
}
- if (!multiple && argc == 3 + verbose)
+ if (multiple == 0 && argc == 3 + verbose)
outname = argv[2 + verbose];
- if ((!multiple && argc > 3 + verbose) || (multiple && argc < 2))
+ if ((multiple == 0 && argc > 3 + verbose) ||
+ (multiple != 0 && argc < 2))
{
fprintf(STDERR,
"usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n",
@@ -1795,7 +1799,7 @@ main(int argc, char *argv[]) exit(1);
}
- if (multiple)
+ if (multiple != 0)
{
int i;
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
@@ -1805,6 +1809,9 @@ main(int argc, char *argv[]) {
int kerror;
fprintf(STDERR, "\n Testing %s:", argv[i]);
+#if PNG_DEBUG > 0
+ fprintf(STDERR, "\n");
+#endif
kerror = test_one_file(argv[i], outname);
if (kerror == 0)
{
@@ -1819,7 +1826,7 @@ main(int argc, char *argv[]) #endif
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
for (k = 0; k<256; k++)
- if (filters_used[k])
+ if (filters_used[k] != 0)
fprintf(STDERR, " Filter %d was used %lu times\n",
k, (unsigned long)filters_used[k]);
#endif
@@ -1828,7 +1835,7 @@ main(int argc, char *argv[]) fprintf(STDERR, " tIME = %s\n", tIME_string);
tIME_chunk_present = 0;
-#endif /* PNG_TIME_RFC1123_SUPPORTED */
+#endif /* TIME_RFC1123 */
}
else
@@ -1850,9 +1857,9 @@ main(int argc, char *argv[]) while (pinfo != NULL)
{
- fprintf(STDERR, " %lu bytes at %x\n",
+ fprintf(STDERR, " %lu bytes at %p\n",
(unsigned long)pinfo->size,
- (unsigned int)pinfo->pointer);
+ pinfo->pointer);
pinfo = pinfo->next;
}
}
@@ -1886,7 +1893,12 @@ main(int argc, char *argv[]) status_dots_requested = 0;
if (i == 0 || verbose == 1 || ierror != 0)
+ {
fprintf(STDERR, "\n Testing %s:", inname);
+#if PNG_DEBUG > 0
+ fprintf(STDERR, "\n");
+#endif
+ }
kerror = test_one_file(inname, outname);
@@ -1905,21 +1917,26 @@ main(int argc, char *argv[]) #endif
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
for (k = 0; k<256; k++)
- if (filters_used[k])
+ if (filters_used[k] != 0)
fprintf(STDERR, " Filter %d was used %lu times\n",
k, (unsigned long)filters_used[k]);
#endif
#ifdef PNG_TIME_RFC1123_SUPPORTED
if (tIME_chunk_present != 0)
fprintf(STDERR, " tIME = %s\n", tIME_string);
-#endif /* PNG_TIME_RFC1123_SUPPORTED */
+#endif /* TIME_RFC1123 */
}
}
else
{
if (verbose == 0 && i != 2)
+ {
fprintf(STDERR, "\n Testing %s:", inname);
+#if PNG_DEBUG > 0
+ fprintf(STDERR, "\n");
+#endif
+ }
fprintf(STDERR, " FAIL\n");
ierror += kerror;
@@ -1938,8 +1955,8 @@ main(int argc, char *argv[]) while (pinfo != NULL)
{
- fprintf(STDERR, " %lu bytes at %x\n",
- (unsigned long)pinfo->size, (unsigned int)pinfo->pointer);
+ fprintf(STDERR, " %lu bytes at %p\n",
+ (unsigned long)pinfo->size, pinfo->pointer);
pinfo = pinfo->next;
}
}
@@ -1991,4 +2008,4 @@ main(void) #endif
/* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_6_10 Your_png_h_is_not_version_1_6_10;
+typedef png_libpng_version_1_6_15 Your_png_h_is_not_version_1_6_15;
diff --git a/plugins/AdvaImg/src/LibPNG/pngtrans.c b/plugins/AdvaImg/src/LibPNG/pngtrans.c index 4c88708a52..4fbbf7f4ab 100644 --- a/plugins/AdvaImg/src/LibPNG/pngtrans.c +++ b/plugins/AdvaImg/src/LibPNG/pngtrans.c @@ -1,7 +1,7 @@ /* pngtrans.c - transforms the data in a row (used by both readers and writers)
*
- * Last changed in libpng 1.6.9 [February 6, 2014]
+ * Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -100,7 +100,7 @@ png_set_interlace_handling(png_structrp png_ptr) {
png_debug(1, "in png_set_interlace handling");
- if (png_ptr && png_ptr->interlaced)
+ if (png_ptr != 0 && png_ptr->interlaced != 0)
{
png_ptr->transformations |= PNG_INTERLACE;
return (7);
@@ -127,7 +127,7 @@ png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc) /* In libpng 1.6 it is possible to determine whether this is a read or write
* operation and therefore to do more checking here for a valid call.
*/
- if (png_ptr->mode & PNG_IS_READ_STRUCT)
+ if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
{
# ifdef PNG_READ_FILLER_SUPPORTED
/* On read png_set_filler is always valid, regardless of the base PNG
@@ -210,7 +210,7 @@ png_set_add_alpha(png_structrp png_ptr, png_uint_32 filler, int filler_loc) png_set_filler(png_ptr, filler, filler_loc);
/* The above may fail to do anything. */
- if (png_ptr->transformations & PNG_FILLER)
+ if ((png_ptr->transformations & PNG_FILLER) != 0)
png_ptr->transformations |= PNG_ADD_ALPHA;
}
@@ -327,9 +327,16 @@ png_do_swap(png_row_infop row_info, png_bytep row) for (i = 0; i < istop; i++, rp += 2)
{
+#ifdef PNG_BUILTIN_BSWAP16_SUPPORTED
+ /* Feature added to libpng-1.6.11 for testing purposes, not
+ * enabled by default.
+ */
+ *(png_uint_16*)rp = __builtin_bswap16(*(png_uint_16*)rp);
+#else
png_byte t = *rp;
*rp = *(rp + 1);
*(rp + 1) = t;
+#endif
}
}
}
@@ -471,7 +478,7 @@ png_do_packswap(png_row_infop row_info, png_bytep row) *rp = table[*rp];
}
}
-#endif /* PNG_READ_PACKSWAP_SUPPORTED or PNG_WRITE_PACKSWAP_SUPPORTED */
+#endif /* PACKSWAP || WRITE_PACKSWAP */
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
@@ -503,7 +510,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start) {
if (row_info->bit_depth == 8)
{
- if (at_start) /* Skip initial filler */
+ if (at_start != 0) /* Skip initial filler */
++sp;
else /* Skip initial channel and, for sp, the filler */
sp += 2, ++dp;
@@ -517,7 +524,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start) else if (row_info->bit_depth == 16)
{
- if (at_start) /* Skip initial filler */
+ if (at_start != 0) /* Skip initial filler */
sp += 2;
else /* Skip initial channel and, for sp, the filler */
sp += 4, dp += 2;
@@ -543,7 +550,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start) {
if (row_info->bit_depth == 8)
{
- if (at_start) /* Skip initial filler */
+ if (at_start != 0) /* Skip initial filler */
++sp;
else /* Skip initial channels and, for sp, the filler */
sp += 4, dp += 3;
@@ -557,7 +564,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start) else if (row_info->bit_depth == 16)
{
- if (at_start) /* Skip initial filler */
+ if (at_start != 0) /* Skip initial filler */
sp += 2;
else /* Skip initial channels and, for sp, the filler */
sp += 8, dp += 6;
@@ -598,7 +605,7 @@ png_do_bgr(png_row_infop row_info, png_bytep row) {
png_debug(1, "in png_do_bgr");
- if ((row_info->color_type & PNG_COLOR_MASK_COLOR))
+ if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
{
png_uint_32 row_width = row_info->width;
if (row_info->bit_depth == 8)
@@ -668,7 +675,7 @@ png_do_bgr(png_row_infop row_info, png_bytep row) #endif
}
}
-#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */
+#endif /* READ_BGR || WRITE_BGR */
#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \
defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)
@@ -771,7 +778,7 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info) }
}
}
-#endif /* PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED */
+#endif /* CHECK_FOR_INVALID_INDEX */
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
@@ -821,7 +828,7 @@ png_get_user_transform_ptr(png_const_structrp png_ptr) png_uint_32 PNGAPI
png_get_current_row_number(png_const_structrp png_ptr)
{
- /* See the comments in png.h - this is the sub-image row when reading and
+ /* See the comments in png.h - this is the sub-image row when reading an
* interlaced image.
*/
if (png_ptr != NULL)
@@ -837,7 +844,6 @@ png_get_current_pass_number(png_const_structrp png_ptr) return png_ptr->pass;
return 8; /* invalid */
}
-#endif /* PNG_USER_TRANSFORM_INFO_SUPPORTED */
-#endif /* PNG_READ_USER_TRANSFORM_SUPPORTED ||
- PNG_WRITE_USER_TRANSFORM_SUPPORTED */
-#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
+#endif /* USER_TRANSFORM_INFO */
+#endif /* READ_USER_TRANSFORM || WRITE_USER_TRANSFORM */
+#endif /* READ || WRITE */
diff --git a/plugins/AdvaImg/src/LibPNG/pngwio.c b/plugins/AdvaImg/src/LibPNG/pngwio.c index 5bc813832d..858faebc87 100644 --- a/plugins/AdvaImg/src/LibPNG/pngwio.c +++ b/plugins/AdvaImg/src/LibPNG/pngwio.c @@ -1,7 +1,7 @@ /* pngwio.c - functions for data output
*
- * Last changed in libpng 1.6.9 [February 6, 2014]
+ * Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -151,7 +151,7 @@ png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr, # endif
#else
PNG_UNUSED(output_flush_fn)
-#endif /* PNG_WRITE_FLUSH_SUPPORTED */
+#endif /* WRITE_FLUSH */
#ifdef PNG_READ_SUPPORTED
/* It is an error to read while writing a png file */
@@ -165,4 +165,4 @@ png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr, }
#endif
}
-#endif /* PNG_WRITE_SUPPORTED */
+#endif /* WRITE */
diff --git a/plugins/AdvaImg/src/LibPNG/pngwrite.c b/plugins/AdvaImg/src/LibPNG/pngwrite.c index a75d6fd2be..027d025798 100644 --- a/plugins/AdvaImg/src/LibPNG/pngwrite.c +++ b/plugins/AdvaImg/src/LibPNG/pngwrite.c @@ -1,7 +1,7 @@ /* pngwrite.c - general routines to write a PNG file
*
- * Last changed in libpng 1.6.10 [March 6, 2014]
+ * Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -24,7 +24,7 @@ static void write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr,
unsigned int where)
{
- if (info_ptr->unknown_chunks_num)
+ if (info_ptr->unknown_chunks_num != 0)
{
png_const_unknown_chunkp up;
@@ -33,7 +33,7 @@ write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr, for (up = info_ptr->unknown_chunks;
up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;
++up)
- if (up->location & where)
+ if ((up->location & where) != 0)
{
/* If per-chunk unknown chunk handling is enabled use it, otherwise
* just write the chunks the application has set.
@@ -69,7 +69,7 @@ write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr, }
}
}
-#endif /* PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED */
+#endif /* WRITE_UNKNOWN_CHUNKS */
/* Writes all the PNG information. This is the suggested way to use the
* library. If you have a new chunk to add, make a function to write it,
@@ -88,14 +88,14 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr) if (png_ptr == NULL || info_ptr == NULL)
return;
- if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))
+ if ((png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE) == 0)
{
/* Write PNG signature */
png_write_sig(png_ptr);
#ifdef PNG_MNG_FEATURES_SUPPORTED
- if ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) && \
- (png_ptr->mng_features_permitted))
+ if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) != 0 && \
+ png_ptr->mng_features_permitted != 0)
{
png_warning(png_ptr, "MNG features are not allowed in a PNG datastream");
png_ptr->mng_features_permitted = 0;
@@ -129,9 +129,9 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr) */
#ifdef PNG_GAMMA_SUPPORTED
# ifdef PNG_WRITE_gAMA_SUPPORTED
- if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) &&
- (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_gAMA) &&
- (info_ptr->valid & PNG_INFO_gAMA))
+ if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
+ (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_gAMA) != 0 &&
+ (info_ptr->valid & PNG_INFO_gAMA) != 0)
png_write_gAMA_fixed(png_ptr, info_ptr->colorspace.gamma);
# endif
#endif
@@ -141,11 +141,11 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr) * and it matches one of the known sRGB ones issue a warning.
*/
# ifdef PNG_WRITE_iCCP_SUPPORTED
- if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) &&
- (info_ptr->valid & PNG_INFO_iCCP))
+ if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
+ (info_ptr->valid & PNG_INFO_iCCP) != 0)
{
# ifdef PNG_WRITE_sRGB_SUPPORTED
- if (info_ptr->valid & PNG_INFO_sRGB)
+ if ((info_ptr->valid & PNG_INFO_sRGB) != 0)
png_app_warning(png_ptr,
"profile matches sRGB but writing iCCP instead");
# endif
@@ -159,22 +159,22 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr) # endif
# ifdef PNG_WRITE_sRGB_SUPPORTED
- if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) &&
- (info_ptr->valid & PNG_INFO_sRGB))
+ if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
+ (info_ptr->valid & PNG_INFO_sRGB) != 0)
png_write_sRGB(png_ptr, info_ptr->colorspace.rendering_intent);
# endif /* WRITE_sRGB */
#endif /* COLORSPACE */
#ifdef PNG_WRITE_sBIT_SUPPORTED
- if (info_ptr->valid & PNG_INFO_sBIT)
+ if ((info_ptr->valid & PNG_INFO_sBIT) != 0)
png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type);
#endif
#ifdef PNG_COLORSPACE_SUPPORTED
# ifdef PNG_WRITE_cHRM_SUPPORTED
- if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) &&
- (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) &&
- (info_ptr->valid & PNG_INFO_cHRM))
+ if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
+ (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) != 0 &&
+ (info_ptr->valid & PNG_INFO_cHRM) != 0)
png_write_cHRM_fixed(png_ptr, &info_ptr->colorspace.end_points_xy);
# endif
#endif
@@ -201,19 +201,19 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr) png_write_info_before_PLTE(png_ptr, info_ptr);
- if (info_ptr->valid & PNG_INFO_PLTE)
+ if ((info_ptr->valid & PNG_INFO_PLTE) != 0)
png_write_PLTE(png_ptr, info_ptr->palette,
(png_uint_32)info_ptr->num_palette);
- else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
+ else if ((info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) !=0)
png_error(png_ptr, "Valid palette required for paletted images");
#ifdef PNG_WRITE_tRNS_SUPPORTED
- if (info_ptr->valid & PNG_INFO_tRNS)
+ if ((info_ptr->valid & PNG_INFO_tRNS) !=0)
{
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
/* Invert the alpha channel (in tRNS) */
- if ((png_ptr->transformations & PNG_INVERT_ALPHA) &&
+ if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0 &&
info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
int j;
@@ -227,42 +227,42 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr) }
#endif
#ifdef PNG_WRITE_bKGD_SUPPORTED
- if (info_ptr->valid & PNG_INFO_bKGD)
+ if ((info_ptr->valid & PNG_INFO_bKGD) != 0)
png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type);
#endif
#ifdef PNG_WRITE_hIST_SUPPORTED
- if (info_ptr->valid & PNG_INFO_hIST)
+ if ((info_ptr->valid & PNG_INFO_hIST) != 0)
png_write_hIST(png_ptr, info_ptr->hist, info_ptr->num_palette);
#endif
#ifdef PNG_WRITE_oFFs_SUPPORTED
- if (info_ptr->valid & PNG_INFO_oFFs)
+ if ((info_ptr->valid & PNG_INFO_oFFs) != 0)
png_write_oFFs(png_ptr, info_ptr->x_offset, info_ptr->y_offset,
info_ptr->offset_unit_type);
#endif
#ifdef PNG_WRITE_pCAL_SUPPORTED
- if (info_ptr->valid & PNG_INFO_pCAL)
+ if ((info_ptr->valid & PNG_INFO_pCAL) != 0)
png_write_pCAL(png_ptr, info_ptr->pcal_purpose, info_ptr->pcal_X0,
info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams,
info_ptr->pcal_units, info_ptr->pcal_params);
#endif
#ifdef PNG_WRITE_sCAL_SUPPORTED
- if (info_ptr->valid & PNG_INFO_sCAL)
+ if ((info_ptr->valid & PNG_INFO_sCAL) != 0)
png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit,
info_ptr->scal_s_width, info_ptr->scal_s_height);
#endif /* sCAL */
#ifdef PNG_WRITE_pHYs_SUPPORTED
- if (info_ptr->valid & PNG_INFO_pHYs)
+ if ((info_ptr->valid & PNG_INFO_pHYs) != 0)
png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit,
info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type);
#endif /* pHYs */
#ifdef PNG_WRITE_tIME_SUPPORTED
- if (info_ptr->valid & PNG_INFO_tIME)
+ if ((info_ptr->valid & PNG_INFO_tIME) != 0)
{
png_write_tIME(png_ptr, &(info_ptr->mod_time));
png_ptr->mode |= PNG_WROTE_tIME;
@@ -270,7 +270,7 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr) #endif /* tIME */
#ifdef PNG_WRITE_sPLT_SUPPORTED
- if (info_ptr->valid & PNG_INFO_sPLT)
+ if ((info_ptr->valid & PNG_INFO_sPLT) != 0)
for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)
png_write_sPLT(png_ptr, info_ptr->splt_palettes + i);
#endif /* sPLT */
@@ -292,11 +292,14 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr) info_ptr->text[i].lang,
info_ptr->text[i].lang_key,
info_ptr->text[i].text);
+ /* Mark this chunk as written */
+ if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)
+ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
+ else
+ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
#else
- png_warning(png_ptr, "Unable to write international text");
+ png_warning(png_ptr, "Unable to write international text");
#endif
- /* Mark this chunk as written */
- info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
}
/* If we want a compressed text chunk */
@@ -305,13 +308,12 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr) #ifdef PNG_WRITE_zTXt_SUPPORTED
/* Write compressed chunk */
png_write_zTXt(png_ptr, info_ptr->text[i].key,
- info_ptr->text[i].text, 0,
- info_ptr->text[i].compression);
+ info_ptr->text[i].text, info_ptr->text[i].compression);
+ /* Mark this chunk as written */
+ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
#else
png_warning(png_ptr, "Unable to write compressed text");
#endif
- /* Mark this chunk as written */
- info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
}
else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)
@@ -349,7 +351,7 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr) if (png_ptr == NULL)
return;
- if (!(png_ptr->mode & PNG_HAVE_IDAT))
+ if ((png_ptr->mode & PNG_HAVE_IDAT) == 0)
png_error(png_ptr, "No IDATs written into file");
#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
@@ -365,8 +367,8 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr) #endif
#ifdef PNG_WRITE_tIME_SUPPORTED
/* Check to see if user has supplied a time chunk */
- if ((info_ptr->valid & PNG_INFO_tIME) &&
- !(png_ptr->mode & PNG_WROTE_tIME))
+ if ((info_ptr->valid & PNG_INFO_tIME) != 0 &&
+ (png_ptr->mode & PNG_WROTE_tIME) == 0)
png_write_tIME(png_ptr, &(info_ptr->mod_time));
#endif
@@ -387,11 +389,14 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr) info_ptr->text[i].lang,
info_ptr->text[i].lang_key,
info_ptr->text[i].text);
+ /* Mark this chunk as written */
+ if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)
+ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
+ else
+ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
#else
png_warning(png_ptr, "Unable to write international text");
#endif
- /* Mark this chunk as written */
- info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
}
else if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt)
@@ -399,13 +404,12 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr) #ifdef PNG_WRITE_zTXt_SUPPORTED
/* Write compressed chunk */
png_write_zTXt(png_ptr, info_ptr->text[i].key,
- info_ptr->text[i].text, 0,
- info_ptr->text[i].compression);
+ info_ptr->text[i].text, info_ptr->text[i].compression);
+ /* Mark this chunk as written */
+ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
#else
png_warning(png_ptr, "Unable to write compressed text");
#endif
- /* Mark this chunk as written */
- info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
}
else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)
@@ -414,12 +418,11 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr) /* Write uncompressed chunk */
png_write_tEXt(png_ptr, info_ptr->text[i].key,
info_ptr->text[i].text, 0);
+ /* Mark this chunk as written */
+ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
#else
png_warning(png_ptr, "Unable to write uncompressed text");
#endif
-
- /* Mark this chunk as written */
- info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
}
}
#endif
@@ -432,6 +435,7 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr) /* Write end of PNG file */
png_write_IEND(png_ptr);
+
/* This flush, added in libpng-1.0.8, removed from libpng-1.0.9beta03,
* and restored again in libpng-1.2.30, may cause some applications that
* do not set png_ptr->output_flush_fn to crash. If your application
@@ -479,7 +483,7 @@ png_create_write_struct,(png_const_charp user_png_ver, png_voidp error_ptr, {
#ifndef PNG_USER_MEM_SUPPORTED
png_structrp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
- error_fn, warn_fn, NULL, NULL, NULL);
+ error_fn, warn_fn, NULL, NULL, NULL);
#else
return png_create_write_struct_2(user_png_ver, error_ptr, error_fn,
warn_fn, NULL, NULL, NULL);
@@ -492,8 +496,8 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED)
{
png_structrp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
- error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);
-#endif /* PNG_USER_MEM_SUPPORTED */
+ error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);
+#endif /* USER_MEM */
if (png_ptr != NULL)
{
/* Set the zlib control values to defaults; they can be overridden by the
@@ -517,7 +521,7 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr, png_ptr->zlib_text_mem_level = 8;
png_ptr->zlib_text_window_bits = 15;
png_ptr->zlib_text_method = 8;
-#endif /* PNG_WRITE_COMPRESSED_TEXT_SUPPORTED */
+#endif /* WRITE_COMPRESSED_TEXT */
/* This is a highly dubious configuration option; by default it is off,
* but it may be appropriate for private builds that are testing
@@ -525,10 +529,10 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr, * applications that must not fail to write at all costs!
*/
#ifdef PNG_BENIGN_WRITE_ERRORS_SUPPORTED
- png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN;
/* In stable builds only warn if an application error can be completely
* handled.
*/
+ png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN;
#endif
/* App warnings are warnings in release (or release candidate) builds but
@@ -614,7 +618,7 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row) {
png_debug(1, "in png_do_write_intrapixel");
- if ((row_info->color_type & PNG_COLOR_MASK_COLOR))
+ if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
{
int bytes_per_pixel;
png_uint_32 row_width = row_info->width;
@@ -667,10 +671,10 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row) *(rp + 5) = (png_byte)(blue & 0xff);
}
}
-#endif /* PNG_WRITE_16BIT_SUPPORTED */
+#endif /* WRITE_16BIT */
}
}
-#endif /* PNG_MNG_FEATURES_SUPPORTED */
+#endif /* MNG_FEATURES */
/* Called by user to write a row of image data */
void PNGAPI
@@ -689,44 +693,44 @@ png_write_row(png_structrp png_ptr, png_const_bytep row) if (png_ptr->row_number == 0 && png_ptr->pass == 0)
{
/* Make sure we wrote the header info */
- if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))
+ if ((png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE) == 0)
png_error(png_ptr,
"png_write_info was never called before png_write_row");
/* Check for transforms that have been set but were defined out */
#if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED)
- if (png_ptr->transformations & PNG_INVERT_MONO)
+ if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined");
#endif
#if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED)
- if (png_ptr->transformations & PNG_FILLER)
+ if ((png_ptr->transformations & PNG_FILLER) != 0)
png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined");
#endif
#if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \
defined(PNG_READ_PACKSWAP_SUPPORTED)
- if (png_ptr->transformations & PNG_PACKSWAP)
+ if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
png_warning(png_ptr,
"PNG_WRITE_PACKSWAP_SUPPORTED is not defined");
#endif
#if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED)
- if (png_ptr->transformations & PNG_PACK)
+ if ((png_ptr->transformations & PNG_PACK) != 0)
png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined");
#endif
#if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED)
- if (png_ptr->transformations & PNG_SHIFT)
+ if ((png_ptr->transformations & PNG_SHIFT) != 0)
png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined");
#endif
#if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED)
- if (png_ptr->transformations & PNG_BGR)
+ if ((png_ptr->transformations & PNG_BGR) != 0)
png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined");
#endif
#if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED)
- if (png_ptr->transformations & PNG_SWAP_BYTES)
+ if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined");
#endif
@@ -735,12 +739,13 @@ png_write_row(png_structrp png_ptr, png_const_bytep row) #ifdef PNG_WRITE_INTERLACING_SUPPORTED
/* If interlaced and not interested in row, return */
- if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
+ if (png_ptr->interlaced != 0 &&
+ (png_ptr->transformations & PNG_INTERLACE) != 0)
{
switch (png_ptr->pass)
{
case 0:
- if (png_ptr->row_number & 0x07)
+ if ((png_ptr->row_number & 0x07) != 0)
{
png_write_finish_row(png_ptr);
return;
@@ -748,7 +753,7 @@ png_write_row(png_structrp png_ptr, png_const_bytep row) break;
case 1:
- if ((png_ptr->row_number & 0x07) || png_ptr->width < 5)
+ if ((png_ptr->row_number & 0x07) != 0 || png_ptr->width < 5)
{
png_write_finish_row(png_ptr);
return;
@@ -764,7 +769,7 @@ png_write_row(png_structrp png_ptr, png_const_bytep row) break;
case 3:
- if ((png_ptr->row_number & 0x03) || png_ptr->width < 3)
+ if ((png_ptr->row_number & 0x03) != 0 || png_ptr->width < 3)
{
png_write_finish_row(png_ptr);
return;
@@ -780,7 +785,7 @@ png_write_row(png_structrp png_ptr, png_const_bytep row) break;
case 5:
- if ((png_ptr->row_number & 0x01) || png_ptr->width < 2)
+ if ((png_ptr->row_number & 0x01) != 0 || png_ptr->width < 2)
{
png_write_finish_row(png_ptr);
return;
@@ -788,7 +793,7 @@ png_write_row(png_structrp png_ptr, png_const_bytep row) break;
case 6:
- if (!(png_ptr->row_number & 0x01))
+ if ((png_ptr->row_number & 0x01) == 0)
{
png_write_finish_row(png_ptr);
return;
@@ -822,11 +827,11 @@ png_write_row(png_structrp png_ptr, png_const_bytep row) #ifdef PNG_WRITE_INTERLACING_SUPPORTED
/* Handle interlacing */
if (png_ptr->interlaced && png_ptr->pass < 6 &&
- (png_ptr->transformations & PNG_INTERLACE))
+ (png_ptr->transformations & PNG_INTERLACE) != 0)
{
png_do_write_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass);
/* This should always get caught above, but still ... */
- if (!(row_info.width))
+ if (row_info.width == 0)
{
png_write_finish_row(png_ptr);
return;
@@ -836,7 +841,7 @@ png_write_row(png_structrp png_ptr, png_const_bytep row) #ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
/* Handle other transformations */
- if (png_ptr->transformations)
+ if (png_ptr->transformations != 0)
png_do_write_transformations(png_ptr, &row_info);
#endif
@@ -857,7 +862,7 @@ png_write_row(png_structrp png_ptr, png_const_bytep row) * 4. The filter_method is 64 and
* 5. The color_type is RGB or RGBA
*/
- if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
+ if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
(png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
{
/* Intrapixel differencing */
@@ -910,7 +915,7 @@ png_write_flush(png_structrp png_ptr) png_ptr->flush_rows = 0;
png_flush(png_ptr);
}
-#endif /* PNG_WRITE_FLUSH_SUPPORTED */
+#endif /* WRITE_FLUSH */
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
static void png_reset_filter_heuristics(png_structrp png_ptr);/* forward decl */
@@ -923,18 +928,24 @@ png_write_destroy(png_structrp png_ptr) png_debug(1, "in png_write_destroy");
/* Free any memory zlib uses */
- if (png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED)
+ if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0)
deflateEnd(&png_ptr->zstream);
/* Free our memory. png_free checks NULL for us. */
png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list);
png_free(png_ptr, png_ptr->row_buf);
+ png_ptr->row_buf = NULL;
#ifdef PNG_WRITE_FILTER_SUPPORTED
png_free(png_ptr, png_ptr->prev_row);
png_free(png_ptr, png_ptr->sub_row);
png_free(png_ptr, png_ptr->up_row);
png_free(png_ptr, png_ptr->avg_row);
png_free(png_ptr, png_ptr->paeth_row);
+ png_ptr->prev_row = NULL;
+ png_ptr->sub_row = NULL;
+ png_ptr->up_row = NULL;
+ png_ptr->avg_row = NULL;
+ png_ptr->paeth_row = NULL;
#endif
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
@@ -942,10 +953,13 @@ png_write_destroy(png_structrp png_ptr) png_reset_filter_heuristics(png_ptr);
png_free(png_ptr, png_ptr->filter_costs);
png_free(png_ptr, png_ptr->inv_filter_costs);
+ png_ptr->filter_costs = NULL;
+ png_ptr->inv_filter_costs = NULL;
#endif
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
png_free(png_ptr, png_ptr->chunk_list);
+ png_ptr->chunk_list = NULL;
#endif
/* The error handling and memory handling information is left intact at this
@@ -991,7 +1005,7 @@ png_set_filter(png_structrp png_ptr, int method, int filters) return;
#ifdef PNG_MNG_FEATURES_SUPPORTED
- if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
+ if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
(method == PNG_INTRAPIXEL_DIFFERENCING))
method = PNG_FILTER_TYPE_BASE;
@@ -1005,7 +1019,7 @@ png_set_filter(png_structrp png_ptr, int method, int filters) case 6:
case 7: png_app_error(png_ptr, "Unknown row filter for method 0");
/* FALL THROUGH */
-#endif /* PNG_WRITE_FILTER_SUPPORTED */
+#endif /* WRITE_FILTER */
case PNG_FILTER_VALUE_NONE:
png_ptr->do_filter = PNG_FILTER_NONE; break;
@@ -1027,7 +1041,7 @@ png_set_filter(png_structrp png_ptr, int method, int filters) #else
default:
png_app_error(png_ptr, "Unknown row filter for method 0");
-#endif /* PNG_WRITE_FILTER_SUPPORTED */
+#endif /* WRITE_FILTER */
}
/* If we have allocated the row_buf, this means we have already started
@@ -1042,14 +1056,16 @@ png_set_filter(png_structrp png_ptr, int method, int filters) if (png_ptr->row_buf != NULL)
{
#ifdef PNG_WRITE_FILTER_SUPPORTED
- if ((png_ptr->do_filter & PNG_FILTER_SUB) && png_ptr->sub_row == NULL)
+ if ((png_ptr->do_filter & PNG_FILTER_SUB) != 0 &&
+ png_ptr->sub_row == NULL)
{
png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,
(png_ptr->rowbytes + 1));
png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
}
- if ((png_ptr->do_filter & PNG_FILTER_UP) && png_ptr->up_row == NULL)
+ if ((png_ptr->do_filter & PNG_FILTER_UP) != 0 &&
+ png_ptr->up_row == NULL)
{
if (png_ptr->prev_row == NULL)
{
@@ -1066,7 +1082,8 @@ png_set_filter(png_structrp png_ptr, int method, int filters) }
}
- if ((png_ptr->do_filter & PNG_FILTER_AVG) && png_ptr->avg_row == NULL)
+ if ((png_ptr->do_filter & PNG_FILTER_AVG) != 0 &&
+ png_ptr->avg_row == NULL)
{
if (png_ptr->prev_row == NULL)
{
@@ -1083,7 +1100,7 @@ png_set_filter(png_structrp png_ptr, int method, int filters) }
}
- if ((png_ptr->do_filter & PNG_FILTER_PAETH) &&
+ if ((png_ptr->do_filter & PNG_FILTER_PAETH) != 0 &&
png_ptr->paeth_row == NULL)
{
if (png_ptr->prev_row == NULL)
@@ -1101,7 +1118,7 @@ png_set_filter(png_structrp png_ptr, int method, int filters) }
if (png_ptr->do_filter == PNG_NO_FILTERS)
-#endif /* PNG_WRITE_FILTER_SUPPORTED */
+#endif /* WRITE_FILTER */
png_ptr->do_filter = PNG_FILTER_NONE;
}
}
@@ -1244,7 +1261,7 @@ png_set_filter_heuristics(png_structrp png_ptr, int heuristic_method, /* The internal API allocates all the arrays and ensures that the elements of
* those arrays are set to the default value.
*/
- if (!png_init_filter_heuristics(png_ptr, heuristic_method, num_weights))
+ if (png_init_filter_heuristics(png_ptr, heuristic_method, num_weights) == 0)
return;
/* If using the weighted method copy in the weights. */
@@ -1299,7 +1316,7 @@ png_set_filter_heuristics_fixed(png_structrp png_ptr, int heuristic_method, /* The internal API allocates all the arrays and ensures that the elements of
* those arrays are set to the default value.
*/
- if (!png_init_filter_heuristics(png_ptr, heuristic_method, num_weights))
+ if (png_init_filter_heuristics(png_ptr, heuristic_method, num_weights) == 0)
return;
/* If using the weighted method copy in the weights. */
@@ -1353,7 +1370,7 @@ png_set_filter_heuristics_fixed(png_structrp png_ptr, int heuristic_method, }
}
#endif /* FIXED_POINT */
-#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
+#endif /* WRITE_WEIGHTED_FILTER */
void PNGAPI
png_set_compression_level(png_structrp png_ptr, int level)
@@ -1510,7 +1527,7 @@ png_set_text_compression_method(png_structrp png_ptr, int method) png_ptr->zlib_text_method = method;
}
-#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */
+#endif /* WRITE_CUSTOMIZE_ZTXT_COMPRESSION */
/* end of API added to libpng-1.5.4 */
void PNGAPI
@@ -1558,7 +1575,7 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr, /* ------ these transformations don't touch the info structure ------- */
/* Invert monochrome pixels */
- if (transforms & PNG_TRANSFORM_INVERT_MONO)
+ if ((transforms & PNG_TRANSFORM_INVERT_MONO) != 0)
#ifdef PNG_WRITE_INVERT_SUPPORTED
png_set_invert_mono(png_ptr);
#else
@@ -1568,16 +1585,16 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr, /* Shift the pixels up to a legal bit depth and fill in
* as appropriate to correctly scale the image.
*/
- if (transforms & PNG_TRANSFORM_SHIFT)
+ if ((transforms & PNG_TRANSFORM_SHIFT) != 0)
#ifdef PNG_WRITE_SHIFT_SUPPORTED
- if (info_ptr->valid & PNG_INFO_sBIT)
+ if ((info_ptr->valid & PNG_INFO_sBIT) != 0)
png_set_shift(png_ptr, &info_ptr->sig_bit);
#else
png_app_error(png_ptr, "PNG_TRANSFORM_SHIFT not supported");
#endif
/* Pack pixels into bytes */
- if (transforms & PNG_TRANSFORM_PACKING)
+ if ((transforms & PNG_TRANSFORM_PACKING) != 0)
#ifdef PNG_WRITE_PACK_SUPPORTED
png_set_packing(png_ptr);
#else
@@ -1585,7 +1602,7 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr, #endif
/* Swap location of alpha bytes from ARGB to RGBA */
- if (transforms & PNG_TRANSFORM_SWAP_ALPHA)
+ if ((transforms & PNG_TRANSFORM_SWAP_ALPHA) != 0)
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
png_set_swap_alpha(png_ptr);
#else
@@ -1596,13 +1613,13 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr, * RGB, note that the code expects the input color type to be G or RGB; no
* alpha channel.
*/
- if (transforms &
- (PNG_TRANSFORM_STRIP_FILLER_AFTER|PNG_TRANSFORM_STRIP_FILLER_BEFORE))
+ if ((transforms & (PNG_TRANSFORM_STRIP_FILLER_AFTER|
+ PNG_TRANSFORM_STRIP_FILLER_BEFORE)) != 0)
{
#ifdef PNG_WRITE_FILLER_SUPPORTED
- if (transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER)
+ if ((transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER) != 0)
{
- if (transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE)
+ if ((transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE) != 0)
png_app_error(png_ptr,
"PNG_TRANSFORM_STRIP_FILLER: BEFORE+AFTER not supported");
@@ -1610,7 +1627,7 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr, png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
}
- else if (transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE)
+ else if ((transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE) != 0)
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
#else
png_app_error(png_ptr, "PNG_TRANSFORM_STRIP_FILLER not supported");
@@ -1618,7 +1635,7 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr, }
/* Flip BGR pixels to RGB */
- if (transforms & PNG_TRANSFORM_BGR)
+ if ((transforms & PNG_TRANSFORM_BGR) != 0)
#ifdef PNG_WRITE_BGR_SUPPORTED
png_set_bgr(png_ptr);
#else
@@ -1626,7 +1643,7 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr, #endif
/* Swap bytes of 16-bit files to most significant byte first */
- if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
+ if ((transforms & PNG_TRANSFORM_SWAP_ENDIAN) != 0)
#ifdef PNG_WRITE_SWAP_SUPPORTED
png_set_swap(png_ptr);
#else
@@ -1634,7 +1651,7 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr, #endif
/* Swap bits of 1, 2, 4 bit packed pixel formats */
- if (transforms & PNG_TRANSFORM_PACKSWAP)
+ if ((transforms & PNG_TRANSFORM_PACKSWAP) != 0)
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
png_set_packswap(png_ptr);
#else
@@ -1642,7 +1659,7 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr, #endif
/* Invert the alpha channel from opacity to transparency */
- if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
+ if ((transforms & PNG_TRANSFORM_INVERT_ALPHA) != 0)
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
png_set_invert_alpha(png_ptr);
#else
@@ -1733,14 +1750,14 @@ png_write_image_16bit(png_voidp argument) display->first_row);
png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row);
png_uint_16p row_end;
- const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1;
+ const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
int aindex = 0;
png_uint_32 y = image->height;
- if (image->format & PNG_FORMAT_FLAG_ALPHA)
+ if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0)
{
# ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
- if (image->format & PNG_FORMAT_FLAG_AFIRST)
+ if ((image->format & PNG_FORMAT_FLAG_AFIRST) != 0)
{
aindex = -1;
++input_row; /* To point to the first component */
@@ -1890,15 +1907,15 @@ png_write_image_8bit(png_voidp argument) display->first_row);
png_bytep output_row = png_voidcast(png_bytep, display->local_row);
png_uint_32 y = image->height;
- const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1;
+ const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
- if (image->format & PNG_FORMAT_FLAG_ALPHA)
+ if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0)
{
png_bytep row_end;
int aindex;
# ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
- if (image->format & PNG_FORMAT_FLAG_AFIRST)
+ if ((image->format & PNG_FORMAT_FLAG_AFIRST) != 0)
{
aindex = -1;
++input_row; /* To point to the first component */
@@ -1995,7 +2012,7 @@ png_image_set_PLTE(png_image_write_control *display) # endif
# ifdef PNG_FORMAT_BGR_SUPPORTED
- const int bgr = (format & PNG_FORMAT_FLAG_BGR) ? 2 : 0;
+ const int bgr = (format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
# else
# define bgr 0
# endif
@@ -2012,13 +2029,13 @@ png_image_set_PLTE(png_image_write_control *display) /* This gets automatically converted to sRGB with reversal of the
* pre-multiplication if the color-map has an alpha channel.
*/
- if (format & PNG_FORMAT_FLAG_LINEAR)
+ if ((format & PNG_FORMAT_FLAG_LINEAR) != 0)
{
png_const_uint_16p entry = png_voidcast(png_const_uint_16p, cmap);
entry += i * channels;
- if (channels & 1) /* no alpha */
+ if ((channels & 1) != 0) /* no alpha */
{
if (channels >= 3) /* RGB */
{
@@ -2130,10 +2147,11 @@ png_image_write_main(png_voidp argument) png_inforp info_ptr = image->opaque->info_ptr;
png_uint_32 format = image->format;
- int colormap = (format & PNG_FORMAT_FLAG_COLORMAP) != 0;
- int linear = !colormap && (format & PNG_FORMAT_FLAG_LINEAR) != 0; /* input */
- int alpha = !colormap && (format & PNG_FORMAT_FLAG_ALPHA) != 0;
- int write_16bit = linear && !colormap && !display->convert_to_8bit;
+ /* The following four ints are actually booleans */
+ int colormap = (format & PNG_FORMAT_FLAG_COLORMAP);
+ int linear = !colormap && (format & PNG_FORMAT_FLAG_LINEAR); /* input */
+ int alpha = !colormap && (format & PNG_FORMAT_FLAG_ALPHA);
+ int write_16bit = linear && !colormap && (display->convert_to_8bit == 0);
# ifdef PNG_BENIGN_ERRORS_SUPPORTED
/* Make sure we error out on any bad situation */
@@ -2145,7 +2163,7 @@ png_image_write_main(png_voidp argument) display->row_stride = PNG_IMAGE_ROW_STRIDE(*image);
/* Set the required transforms then write the rows in the correct order. */
- if (format & PNG_FORMAT_FLAG_COLORMAP)
+ if ((format & PNG_FORMAT_FLAG_COLORMAP) != 0)
{
if (display->colormap != NULL && image->colormap_entries > 0)
{
@@ -2177,12 +2195,12 @@ png_image_write_main(png_voidp argument) * write an interlaced image.
*/
- if (write_16bit)
+ if (write_16bit != 0)
{
/* The gamma here is 1.0 (linear) and the cHRM chunk matches sRGB. */
png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_LINEAR);
- if (!(image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB))
+ if ((image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB) == 0)
png_set_cHRM_fixed(png_ptr, info_ptr,
/* color x y */
/* white */ 31270, 32900,
@@ -2192,7 +2210,7 @@ png_image_write_main(png_voidp argument) );
}
- else if (!(image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB))
+ else if ((image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB) == 0)
png_set_sRGB(png_ptr, info_ptr, PNG_sRGB_INTENT_PERCEPTUAL);
/* Else writing an 8-bit file and the *colors* aren't sRGB, but the 8-bit
@@ -2209,27 +2227,27 @@ png_image_write_main(png_voidp argument) *
* First check for a little endian system if writing 16 bit files.
*/
- if (write_16bit)
+ if (write_16bit != 0)
{
PNG_CONST png_uint_16 le = 0x0001;
- if (*(png_const_bytep)&le)
+ if ((*(png_const_bytep) & le) != 0)
png_set_swap(png_ptr);
}
# ifdef PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED
- if (format & PNG_FORMAT_FLAG_BGR)
+ if ((format & PNG_FORMAT_FLAG_BGR) != 0)
{
- if (!colormap && (format & PNG_FORMAT_FLAG_COLOR) != 0)
+ if (colormap == 0 && (format & PNG_FORMAT_FLAG_COLOR) != 0)
png_set_bgr(png_ptr);
format &= ~PNG_FORMAT_FLAG_BGR;
}
# endif
# ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
- if (format & PNG_FORMAT_FLAG_AFIRST)
+ if ((format & PNG_FORMAT_FLAG_AFIRST) != 0)
{
- if (!colormap && (format & PNG_FORMAT_FLAG_ALPHA) != 0)
+ if (colormap == 0 && (format & PNG_FORMAT_FLAG_ALPHA) != 0)
png_set_swap_alpha(png_ptr);
format &= ~PNG_FORMAT_FLAG_AFIRST;
}
@@ -2238,7 +2256,7 @@ png_image_write_main(png_voidp argument) /* If there are 16 or fewer color-map entries we wrote a lower bit depth
* above, but the application data is still byte packed.
*/
- if (colormap && image->colormap_entries <= 16)
+ if (colormap != 0 && image->colormap_entries <= 16)
png_set_packing(png_ptr);
/* That should have handled all (both) the transforms. */
@@ -2250,7 +2268,7 @@ png_image_write_main(png_voidp argument) png_const_bytep row = png_voidcast(png_const_bytep, display->buffer);
ptrdiff_t row_bytes = display->row_stride;
- if (linear)
+ if (linear != 0)
row_bytes *= (sizeof (png_uint_16));
if (row_bytes < 0)
@@ -2276,14 +2294,15 @@ png_image_write_main(png_voidp argument) * before it is written. This only applies when the input is 16-bit and
* either there is an alpha channel or it is converted to 8-bit.
*/
- if ((linear && alpha) || (!colormap && display->convert_to_8bit))
+ if ((linear != 0 && alpha != 0 ) ||
+ (colormap == 0 && display->convert_to_8bit != 0))
{
png_bytep row = png_voidcast(png_bytep, png_malloc(png_ptr,
png_get_rowbytes(png_ptr, info_ptr)));
int result;
display->local_row = row;
- if (write_16bit)
+ if (write_16bit != 0)
result = png_safe_execute(image, png_write_image_16bit, display);
else
result = png_safe_execute(image, png_write_image_8bit, display);
@@ -2292,7 +2311,7 @@ png_image_write_main(png_voidp argument) png_free(png_ptr, row);
/* Skip the 'write_end' on error: */
- if (!result)
+ if (result == 0)
return 0;
}
@@ -2325,7 +2344,7 @@ png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit, {
if (file != NULL)
{
- if (png_image_write_init(image))
+ if (png_image_write_init(image) != 0)
{
png_image_write_control display;
int result;
@@ -2380,7 +2399,7 @@ png_image_write_to_file(png_imagep image, const char *file_name, if (fp != NULL)
{
if (png_image_write_to_stdio(image, fp, convert_to_8bit, buffer,
- row_stride, colormap))
+ row_stride, colormap) != 0)
{
int error; /* from fflush/fclose */
@@ -2431,6 +2450,6 @@ png_image_write_to_file(png_imagep image, const char *file_name, else
return 0;
}
-#endif /* PNG_STDIO_SUPPORTED */
+#endif /* STDIO */
#endif /* SIMPLIFIED_WRITE */
-#endif /* PNG_WRITE_SUPPORTED */
+#endif /* WRITE */
diff --git a/plugins/AdvaImg/src/LibPNG/pngwtran.c b/plugins/AdvaImg/src/LibPNG/pngwtran.c index 03eabf0b0b..1ab9893ec0 100644 --- a/plugins/AdvaImg/src/LibPNG/pngwtran.c +++ b/plugins/AdvaImg/src/LibPNG/pngwtran.c @@ -1,7 +1,7 @@ /* pngwtran.c - transforms the data in a row for PNG writers
*
- * Last changed in libpng 1.6.9 [February 6, 2014]
+ * Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -177,7 +177,7 @@ png_do_shift(png_row_infop row_info, png_bytep row, int shift_start[4], shift_dec[4];
int channels = 0;
- if (row_info->color_type & PNG_COLOR_MASK_COLOR)
+ if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
{
shift_start[channels] = row_info->bit_depth - bit_depth->red;
shift_dec[channels] = bit_depth->red;
@@ -199,7 +199,7 @@ png_do_shift(png_row_infop row_info, png_bytep row, channels++;
}
- if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
+ if ((row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0)
{
shift_start[channels] = row_info->bit_depth - bit_depth->alpha;
shift_dec[channels] = bit_depth->alpha;
@@ -353,7 +353,7 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) *(dp++) = save[1];
}
}
-#endif /* PNG_WRITE_16BIT_SUPPORTED */
+#endif /* WRITE_16BIT */
}
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
@@ -392,7 +392,7 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) *(dp++) = save[1];
}
}
-#endif /* PNG_WRITE_16BIT_SUPPORTED */
+#endif /* WRITE_16BIT */
}
}
}
@@ -449,7 +449,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) *(dp++) = (png_byte)(255 - *(sp++));
}
}
-#endif /* PNG_WRITE_16BIT_SUPPORTED */
+#endif /* WRITE_16BIT */
}
else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
@@ -487,7 +487,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) *(dp++) = (png_byte)(255 - *(sp++));
}
}
-#endif /* PNG_WRITE_16BIT_SUPPORTED */
+#endif /* WRITE_16BIT */
}
}
}
@@ -505,7 +505,7 @@ png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info) return;
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
- if (png_ptr->transformations & PNG_USER_TRANSFORM)
+ if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
if (png_ptr->write_user_transform_fn != NULL)
(*(png_ptr->write_user_transform_fn)) /* User write transform
function */
@@ -521,52 +521,54 @@ png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info) #endif
#ifdef PNG_WRITE_FILLER_SUPPORTED
- if (png_ptr->transformations & PNG_FILLER)
+ if ((png_ptr->transformations & PNG_FILLER) != 0)
png_do_strip_channel(row_info, png_ptr->row_buf + 1,
!(png_ptr->flags & PNG_FLAG_FILLER_AFTER));
#endif
#ifdef PNG_WRITE_PACKSWAP_SUPPORTED
- if (png_ptr->transformations & PNG_PACKSWAP)
+ if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
png_do_packswap(row_info, png_ptr->row_buf + 1);
#endif
#ifdef PNG_WRITE_PACK_SUPPORTED
- if (png_ptr->transformations & PNG_PACK)
+ if ((png_ptr->transformations & PNG_PACK) != 0)
png_do_pack(row_info, png_ptr->row_buf + 1,
(png_uint_32)png_ptr->bit_depth);
#endif
#ifdef PNG_WRITE_SWAP_SUPPORTED
- if (png_ptr->transformations & PNG_SWAP_BYTES)
+# ifdef PNG_16BIT_SUPPORTED
+ if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0)
png_do_swap(row_info, png_ptr->row_buf + 1);
+# endif
#endif
#ifdef PNG_WRITE_SHIFT_SUPPORTED
- if (png_ptr->transformations & PNG_SHIFT)
+ if ((png_ptr->transformations & PNG_SHIFT) != 0)
png_do_shift(row_info, png_ptr->row_buf + 1,
&(png_ptr->shift));
#endif
#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED
- if (png_ptr->transformations & PNG_SWAP_ALPHA)
+ if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0)
png_do_write_swap_alpha(row_info, png_ptr->row_buf + 1);
#endif
#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED
- if (png_ptr->transformations & PNG_INVERT_ALPHA)
+ if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0)
png_do_write_invert_alpha(row_info, png_ptr->row_buf + 1);
#endif
#ifdef PNG_WRITE_BGR_SUPPORTED
- if (png_ptr->transformations & PNG_BGR)
+ if ((png_ptr->transformations & PNG_BGR) != 0)
png_do_bgr(row_info, png_ptr->row_buf + 1);
#endif
#ifdef PNG_WRITE_INVERT_SUPPORTED
- if (png_ptr->transformations & PNG_INVERT_MONO)
+ if ((png_ptr->transformations & PNG_INVERT_MONO) != 0)
png_do_invert(row_info, png_ptr->row_buf + 1);
#endif
}
-#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
-#endif /* PNG_WRITE_SUPPORTED */
+#endif /* WRITE_TRANSFORMS */
+#endif /* WRITE */
diff --git a/plugins/AdvaImg/src/LibPNG/pngwutil.c b/plugins/AdvaImg/src/LibPNG/pngwutil.c index da4ec20dd8..7d46505359 100644 --- a/plugins/AdvaImg/src/LibPNG/pngwutil.c +++ b/plugins/AdvaImg/src/LibPNG/pngwutil.c @@ -1,8 +1,8 @@ /* pngwutil.c - utilities to write a PNG file
*
- * Last changed in libpng 1.6.2 [April 25, 2013]
- * Copyright (c) 1998-2013 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.15 [November 20, 2014]
+ * Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@@ -136,7 +136,7 @@ png_write_chunk_data(png_structrp png_ptr, png_const_bytep data, png_write_data(png_ptr, data, length);
/* Update the CRC after writing the data,
- * in case that the user I/O routine alters it.
+ * in case the user I/O routine alters it.
*/
png_calculate_crc(png_ptr, data, length);
}
@@ -181,7 +181,7 @@ png_write_complete_chunk(png_structrp png_ptr, png_uint_32 chunk_name, /* On 64 bit architectures 'length' may not fit in a png_uint_32. */
if (length > PNG_UINT_31_MAX)
- png_error(png_ptr, "length exceeds PNG maxima");
+ png_error(png_ptr, "length exceeds PNG maximum");
png_write_chunk_header(png_ptr, chunk_name, (png_uint_32)length);
png_write_chunk_data(png_ptr, data, length);
@@ -204,14 +204,14 @@ png_write_chunk(png_structrp png_ptr, png_const_bytep chunk_string, static png_alloc_size_t
png_image_size(png_structrp png_ptr)
{
- /* Only return sizes up to the maximum of a png_uint_32, do this by limiting
+ /* Only return sizes up to the maximum of a png_uint_32; do this by limiting
* the width and height used to 15 bits.
*/
png_uint_32 h = png_ptr->height;
if (png_ptr->rowbytes < 32768 && h < 32768)
{
- if (png_ptr->interlaced)
+ if (png_ptr->interlaced != 0)
{
/* Interlacing makes the image larger because of the replication of
* both the filter byte and the padding to a byte boundary.
@@ -286,9 +286,7 @@ optimize_cmf(png_bytep data, png_alloc_size_t data_size) }
}
}
-#else
-# define optimize_cmf(dp,dl) ((void)0)
-#endif /* PNG_WRITE_OPTIMIZE_CMF_SUPPORTED */
+#endif /* WRITE_OPTIMIZE_CMF */
/* Initialize the compressor for the appropriate type of compression. */
static int
@@ -297,6 +295,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner, {
if (png_ptr->zowner != 0)
{
+#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
char msg[64];
PNG_STRING_FROM_CHUNK(msg, owner);
@@ -308,7 +307,8 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner, * are minimal.
*/
(void)png_safecat(msg, (sizeof msg), 10, " using zstream");
-# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
+#endif
+#if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
png_warning(png_ptr, msg);
/* Attempt sane error recovery */
@@ -319,9 +319,9 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner, }
png_ptr->zowner = 0;
-# else
+#else
png_error(png_ptr, msg);
-# endif
+#endif
}
{
@@ -334,7 +334,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner, if (owner == png_IDAT)
{
- if (png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_STRATEGY)
+ if ((png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_STRATEGY) != 0)
strategy = png_ptr->zlib_strategy;
else if (png_ptr->do_filter != PNG_FILTER_NONE)
@@ -346,20 +346,20 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner, else
{
-# ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
+#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
level = png_ptr->zlib_text_level;
method = png_ptr->zlib_text_method;
windowBits = png_ptr->zlib_text_window_bits;
memLevel = png_ptr->zlib_text_mem_level;
strategy = png_ptr->zlib_text_strategy;
-# else
+#else
/* If customization is not supported the values all come from the
* IDAT values except for the strategy, which is fixed to the
* default. (This is the pre-1.6.0 behavior too, although it was
* implemented in a very different way.)
*/
strategy = Z_DEFAULT_STRATEGY;
-# endif
+#endif
}
/* Adjust 'windowBits' down if larger than 'data_size'; to stop this
@@ -386,7 +386,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner, }
/* Check against the previous initialized values, if any. */
- if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) &&
+ if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0 &&
(png_ptr->zlib_set_level != level ||
png_ptr->zlib_set_method != method ||
png_ptr->zlib_set_window_bits != windowBits ||
@@ -410,7 +410,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner, /* Now initialize if required, setting the new parameters, otherwise just
* to a simple reset to the previous parameters.
*/
- if (png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED)
+ if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0)
ret = deflateReset(&png_ptr->zstream);
else
@@ -492,7 +492,7 @@ png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name, int ret;
/* To find the length of the output it is necessary to first compress the
- * input, the result is buffered rather than using the two-pass algorithm
+ * input. The result is buffered rather than using the two-pass algorithm
* that is used on the inflate side; deflate is assumed to be slower and a
* PNG writer is assumed to have more memory available than a PNG reader.
*
@@ -589,7 +589,7 @@ png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name, }
while (ret == Z_OK);
- /* There may be some space left in the last output buffer, this needs to
+ /* There may be some space left in the last output buffer. This needs to
* be subtracted from output_len.
*/
output_len -= png_ptr->zstream.avail_out;
@@ -612,14 +612,15 @@ png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name, /* Reset zlib for another zTXt/iTXt or image data */
png_ptr->zowner = 0;
- /* The only success case is Z_STREAM_END, input_len must be 0, if not this
+ /* The only success case is Z_STREAM_END, input_len must be 0; if not this
* is an internal error.
*/
if (ret == Z_STREAM_END && input_len == 0)
{
+#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
/* Fix up the deflate header, if required */
optimize_cmf(comp->output, comp->input_len);
-
+#endif
/* But Z_OK is returned, not Z_STREAM_END; this allows the claim
* function above to return Z_STREAM_END on an error (though it never
* does in the current versions of zlib.)
@@ -662,7 +663,7 @@ png_write_compressed_data_out(png_structrp png_ptr, compression_state *comp) if (output_len > 0)
png_error(png_ptr, "error writing ancillary chunked compressed data");
}
-#endif /* PNG_WRITE_COMPRESSED_TEXT_SUPPORTED */
+#endif /* WRITE_COMPRESSED_TEXT */
#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \
defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)
@@ -699,7 +700,7 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key) if ((ch > 32 && ch <= 126) || (ch >= 161 /*&& ch <= 255*/))
*new_key++ = ch, ++key_len, space = 0;
- else if (!space)
+ else if (space == 0)
{
/* A space or an invalid character when one wasn't seen immediately
* before; output just a space.
@@ -711,14 +712,14 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key) bad_character = ch;
}
- else if (!bad_character)
+ else if (bad_character == 0)
bad_character = ch; /* just skip it, record the first error */
}
- if (key_len > 0 && space) /* trailing space */
+ if (key_len > 0 && space != 0) /* trailing space */
{
--key_len, --new_key;
- if (!bad_character)
+ if (bad_character == 0)
bad_character = 32;
}
@@ -728,11 +729,12 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key) if (key_len == 0)
return 0;
+#ifdef PNG_WARNINGS_SUPPORTED
/* Try to only output one warning per keyword: */
- if (*key) /* keyword too long */
+ if (*key != 0) /* keyword too long */
png_warning(png_ptr, "keyword truncated");
- else if (bad_character)
+ else if (bad_character != 0)
{
PNG_WARNING_PARAMETERS(p)
@@ -741,10 +743,11 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key) png_formatted_warning(png_ptr, p, "keyword \"@1\": bad character '0x@2'");
}
+#endif /* WARNINGS */
return key_len;
}
-#endif
+#endif /* WRITE_TEXT || WRITE_pCAL || WRITE_iCCP || WRITE_sPLT */
/* Write the IHDR chunk, and update the png_struct with the necessary
* information. Note that the rest of this code depends upon this
@@ -845,8 +848,8 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height, */
if (
#ifdef PNG_MNG_FEATURES_SUPPORTED
- !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
- ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) &&
+ !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 &&
+ ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) == 0) &&
(color_type == PNG_COLOR_TYPE_RGB ||
color_type == PNG_COLOR_TYPE_RGB_ALPHA) &&
(filter_type == PNG_INTRAPIXEL_DIFFERENCING)) &&
@@ -898,7 +901,7 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height, /* Write the chunk */
png_write_complete_chunk(png_ptr, png_IHDR, buf, (png_size_t)13);
- if (!(png_ptr->do_filter))
+ if ((png_ptr->do_filter) == PNG_NO_FILTERS)
{
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE ||
png_ptr->bit_depth < 8)
@@ -927,7 +930,7 @@ png_write_PLTE(png_structrp png_ptr, png_const_colorp palette, if ((
#ifdef PNG_MNG_FEATURES_SUPPORTED
- !(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) &&
+ (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0 &&
#endif
num_pal == 0) || num_pal > 256)
{
@@ -943,7 +946,7 @@ png_write_PLTE(png_structrp png_ptr, png_const_colorp palette, }
}
- if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR))
+ if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0)
{
png_warning(png_ptr,
"Ignoring request to write a PLTE chunk in grayscale PNG");
@@ -998,7 +1001,7 @@ png_write_PLTE(png_structrp png_ptr, png_const_colorp palette, * Z_FINISH: this is the end of the input, do a Z_FINISH and clean up
*
* The routine manages the acquire and release of the png_ptr->zstream by
- * checking and (at the end) clearing png_ptr->zowner, it does some sanity
+ * checking and (at the end) clearing png_ptr->zowner; it does some sanity
* checks on the 'mode' flags while doing this.
*/
void /* PRIVATE */
@@ -1058,7 +1061,7 @@ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input, input_len += png_ptr->zstream.avail_in;
png_ptr->zstream.avail_in = 0;
- /* OUTPUT: write complete IDAT chunks when avail_out drops to zero, note
+ /* OUTPUT: write complete IDAT chunks when avail_out drops to zero. Note
* that these two zstream fields are preserved across the calls, therefore
* there is no need to set these up on entry to the loop.
*/
@@ -1070,11 +1073,11 @@ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input, /* Write an IDAT containing the data then reset the buffer. The
* first IDAT may need deflate header optimization.
*/
-# ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
- if (!(png_ptr->mode & PNG_HAVE_IDAT) &&
- png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE)
+#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
+ if ((png_ptr->mode & PNG_HAVE_IDAT) == 0 &&
+ png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE)
optimize_cmf(data, png_image_size(png_ptr));
-# endif
+#endif
png_write_complete_chunk(png_ptr, png_IDAT, data, size);
png_ptr->mode |= PNG_HAVE_IDAT;
@@ -1090,7 +1093,7 @@ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input, continue;
}
- /* The order of these checks doesn't matter much; it just effect which
+ /* The order of these checks doesn't matter much; it just affects which
* possible error might be detected if multiple things go wrong at once.
*/
if (ret == Z_OK) /* most likely return code! */
@@ -1116,11 +1119,11 @@ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input, png_bytep data = png_ptr->zbuffer_list->output;
uInt size = png_ptr->zbuffer_size - png_ptr->zstream.avail_out;
-# ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
- if (!(png_ptr->mode & PNG_HAVE_IDAT) &&
- png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE)
- optimize_cmf(data, png_image_size(png_ptr));
-# endif
+#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
+ if ((png_ptr->mode & PNG_HAVE_IDAT) == 0 &&
+ png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE)
+ optimize_cmf(data, png_image_size(png_ptr));
+#endif
png_write_complete_chunk(png_ptr, png_IDAT, data, size);
png_ptr->zstream.avail_out = 0;
@@ -1193,6 +1196,7 @@ png_write_iCCP(png_structrp png_ptr, png_const_charp name, png_uint_32 profile_len;
png_byte new_name[81]; /* 1 byte for the compression byte */
compression_state comp;
+ png_uint_32 temp;
png_debug(1, "in png_write_iCCP");
@@ -1207,7 +1211,8 @@ png_write_iCCP(png_structrp png_ptr, png_const_charp name, if (profile_len < 132)
png_error(png_ptr, "ICC profile too short");
- if (profile_len & 0x03)
+ temp = (png_uint_32) (*(profile+8));
+ if (temp > 3 && (profile_len & 0x03))
png_error(png_ptr, "ICC profile length invalid (not a multiple of 4)");
{
@@ -1339,7 +1344,7 @@ png_write_sBIT(png_structrp png_ptr, png_const_color_8p sbit, int color_type) png_debug(1, "in png_write_sBIT");
/* Make sure we don't depend upon the order of PNG_COLOR_8 */
- if (color_type & PNG_COLOR_MASK_COLOR)
+ if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
{
png_byte maxbits;
@@ -1372,7 +1377,7 @@ png_write_sBIT(png_structrp png_ptr, png_const_color_8p sbit, int color_type) size = 1;
}
- if (color_type & PNG_COLOR_MASK_ALPHA)
+ if ((color_type & PNG_COLOR_MASK_ALPHA) != 0)
{
if (sbit->alpha == 0 || sbit->alpha > png_ptr->usr_bit_depth)
{
@@ -1459,9 +1464,9 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha, png_save_uint_16(buf + 2, tran->green);
png_save_uint_16(buf + 4, tran->blue);
#ifdef PNG_WRITE_16BIT_SUPPORTED
- if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))
+ if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]) != 0)
#else
- if (buf[0] | buf[2] | buf[4])
+ if ((buf[0] | buf[2] | buf[4]) != 0)
#endif
{
png_app_warning(png_ptr,
@@ -1492,8 +1497,8 @@ png_write_bKGD(png_structrp png_ptr, png_const_color_16p back, int color_type) {
if (
#ifdef PNG_MNG_FEATURES_SUPPORTED
- (png_ptr->num_palette ||
- (!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) &&
+ (png_ptr->num_palette != 0 ||
+ (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0) &&
#endif
back->index >= png_ptr->num_palette)
{
@@ -1505,15 +1510,15 @@ png_write_bKGD(png_structrp png_ptr, png_const_color_16p back, int color_type) png_write_complete_chunk(png_ptr, png_bKGD, buf, (png_size_t)1);
}
- else if (color_type & PNG_COLOR_MASK_COLOR)
+ else if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
{
png_save_uint_16(buf, back->red);
png_save_uint_16(buf + 2, back->green);
png_save_uint_16(buf + 4, back->blue);
#ifdef PNG_WRITE_16BIT_SUPPORTED
- if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))
+ if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]) != 0)
#else
- if (buf[0] | buf[2] | buf[4])
+ if ((buf[0] | buf[2] | buf[4]) != 0)
#endif
{
png_warning(png_ptr,
@@ -1608,7 +1613,7 @@ png_write_tEXt(png_structrp png_ptr, png_const_charp key, png_const_charp text, */
png_write_chunk_data(png_ptr, new_key, key_len + 1);
- if (text_len)
+ if (text_len != 0)
png_write_chunk_data(png_ptr, (png_const_bytep)text, text_len);
png_write_chunk_end(png_ptr);
@@ -1619,14 +1624,13 @@ png_write_tEXt(png_structrp png_ptr, png_const_charp key, png_const_charp text, /* Write a compressed text chunk */
void /* PRIVATE */
png_write_zTXt(png_structrp png_ptr, png_const_charp key, png_const_charp text,
- png_size_t text_len, int compression)
+ int compression)
{
png_uint_32 key_len;
png_byte new_key[81];
compression_state comp;
png_debug(1, "in png_write_zTXt");
- PNG_UNUSED(text_len) /* Always use strlen */
if (compression == PNG_TEXT_COMPRESSION_NONE)
{
@@ -1734,7 +1738,7 @@ png_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key, png_text_compress_init(&comp, (png_const_bytep)text, strlen(text));
- if (compression)
+ if (compression != 0)
{
if (png_text_compress(png_ptr, png_iTXt, &comp, prefix_len) != Z_OK)
png_error(png_ptr, png_ptr->zstream.msg);
@@ -1757,7 +1761,7 @@ png_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key, png_write_chunk_data(png_ptr, (png_const_bytep)lang_key, lang_key_len);
- if (compression)
+ if (compression != 0)
png_write_compressed_data_out(png_ptr, &comp);
else
@@ -1981,12 +1985,13 @@ png_write_start_row(png_structrp png_ptr) }
/* We only need to keep the previous row if we are using one of these. */
- if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH))
+ if ((png_ptr->do_filter &
+ (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) != 0)
{
/* Set up previous row buffer */
png_ptr->prev_row = (png_bytep)png_calloc(png_ptr, buf_size);
- if (png_ptr->do_filter & PNG_FILTER_UP)
+ if ((png_ptr->do_filter & PNG_FILTER_UP) != 0)
{
png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
png_ptr->rowbytes + 1);
@@ -1994,7 +1999,7 @@ png_write_start_row(png_structrp png_ptr) png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
}
- if (png_ptr->do_filter & PNG_FILTER_AVG)
+ if ((png_ptr->do_filter & PNG_FILTER_AVG) != 0)
{
png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
png_ptr->rowbytes + 1);
@@ -2002,7 +2007,7 @@ png_write_start_row(png_structrp png_ptr) png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
}
- if (png_ptr->do_filter & PNG_FILTER_PAETH)
+ if ((png_ptr->do_filter & PNG_FILTER_PAETH) != 0)
{
png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,
png_ptr->rowbytes + 1);
@@ -2010,13 +2015,13 @@ png_write_start_row(png_structrp png_ptr) png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
}
}
-#endif /* PNG_WRITE_FILTER_SUPPORTED */
+#endif /* WRITE_FILTER */
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
/* If interlaced, we need to set up width and height of pass */
- if (png_ptr->interlaced)
+ if (png_ptr->interlaced != 0)
{
- if (!(png_ptr->transformations & PNG_INTERLACE))
+ if ((png_ptr->transformations & PNG_INTERLACE) == 0)
{
png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 -
png_pass_ystart[0]) / png_pass_yinc[0];
@@ -2071,10 +2076,10 @@ png_write_finish_row(png_structrp png_ptr) #ifdef PNG_WRITE_INTERLACING_SUPPORTED
/* If interlaced, go to next pass */
- if (png_ptr->interlaced)
+ if (png_ptr->interlaced != 0)
{
png_ptr->row_number = 0;
- if (png_ptr->transformations & PNG_INTERLACE)
+ if ((png_ptr->transformations & PNG_INTERLACE) != 0)
{
png_ptr->pass++;
}
@@ -2099,7 +2104,7 @@ png_write_finish_row(png_structrp png_ptr) png_pass_ystart[png_ptr->pass]) /
png_pass_yinc[png_ptr->pass];
- if (png_ptr->transformations & PNG_INTERLACE)
+ if ((png_ptr->transformations & PNG_INTERLACE) != 0)
break;
} while (png_ptr->usr_width == 0 || png_ptr->num_rows == 0);
@@ -2378,7 +2383,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) /* We don't need to test the 'no filter' case if this is the only filter
* that has been chosen, as it doesn't actually do anything to the data.
*/
- if ((filter_to_do & PNG_FILTER_NONE) && filter_to_do != PNG_FILTER_NONE)
+ if ((filter_to_do & PNG_FILTER_NONE) != 0 && filter_to_do != PNG_FILTER_NONE)
{
png_bytep rp;
png_uint_32 sum = 0;
@@ -2454,7 +2459,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) best_row = png_ptr->sub_row;
}
- else if (filter_to_do & PNG_FILTER_SUB)
+ else if ((filter_to_do & PNG_FILTER_SUB) != 0)
{
png_bytep rp, dp, lp;
png_uint_32 sum = 0, lmins = mins;
@@ -2575,7 +2580,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) best_row = png_ptr->up_row;
}
- else if (filter_to_do & PNG_FILTER_UP)
+ else if ((filter_to_do & PNG_FILTER_UP) != 0)
{
png_bytep rp, dp, pp;
png_uint_32 sum = 0, lmins = mins;
@@ -2689,7 +2694,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) best_row = png_ptr->avg_row;
}
- else if (filter_to_do & PNG_FILTER_AVG)
+ else if ((filter_to_do & PNG_FILTER_AVG) != 0)
{
png_bytep rp, dp, pp, lp;
png_uint_32 sum = 0, lmins = mins;
@@ -2791,7 +2796,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) }
/* Paeth filter */
- if (filter_to_do == PNG_FILTER_PAETH)
+ if ((filter_to_do == PNG_FILTER_PAETH) != 0)
{
png_bytep rp, dp, pp, cp, lp;
png_size_t i;
@@ -2830,7 +2835,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) best_row = png_ptr->paeth_row;
}
- else if (filter_to_do & PNG_FILTER_PAETH)
+ else if ((filter_to_do & PNG_FILTER_PAETH) != 0)
{
png_bytep rp, dp, pp, cp, lp;
png_uint_32 sum = 0, lmins = mins;
@@ -2900,7 +2905,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) pc = (p + pc) < 0 ? -(p + pc) : p + pc;
#endif
p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;
-#else /* PNG_SLOW_PAETH */
+#else /* SLOW_PAETH */
p = a + b - c;
pa = abs(p - a);
pb = abs(p - b);
@@ -2914,7 +2919,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) else
p = c;
-#endif /* PNG_SLOW_PAETH */
+#endif /* SLOW_PAETH */
v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);
@@ -2963,7 +2968,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) best_row = png_ptr->paeth_row;
}
}
-#endif /* PNG_WRITE_FILTER_SUPPORTED */
+#endif /* WRITE_FILTER */
/* Do the actual writing of the filtered row data from the chosen filter. */
png_write_filtered_row(png_ptr, best_row, row_info->rowbytes+1);
@@ -2983,7 +2988,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) png_ptr->prev_filters[j] = best_row[0];
}
#endif
-#endif /* PNG_WRITE_FILTER_SUPPORTED */
+#endif /* WRITE_FILTER */
}
@@ -3019,6 +3024,6 @@ png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row, {
png_write_flush(png_ptr);
}
-#endif
+#endif /* WRITE_FLUSH */
}
-#endif /* PNG_WRITE_SUPPORTED */
+#endif /* WRITE */
|