diff --git a/ANNOUNCE b/ANNOUNCE index b719f6683..cc2064ec7 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,5 +1,5 @@ -Libpng 1.6.0 - February 14, 2013 +Libpng 1.6.1 - March 28, 2013 This is a public release of libpng, intended for use in production codes. @@ -8,452 +8,89 @@ Files available for download: Source files with LF line endings (for Unix/Linux) and with a "configure" script - libpng-1.6.0.tar.xz (LZMA-compressed, recommended) - libpng-1.6.0.tar.gz + libpng-1.6.1.tar.xz (LZMA-compressed, recommended) + libpng-1.6.1.tar.gz Source files with CRLF line endings (for Windows), without the "configure" script - lpng160.7z (LZMA-compressed, recommended) - lpng160.zip + lpng161.7z (LZMA-compressed, recommended) + lpng161.zip Other information: - libpng-1.6.0-README.txt - libpng-1.6.0-LICENSE.txt + libpng-1.6.1-README.txt + libpng-1.6.1-LICENSE.txt -Changes since the last public release (1.5.7): +Changes since the last public release (1.6.0): - Removed machine-generated configure files from the GIT repository (they will - continue to appear in the tarball distributions and in the libpng15 and - earlier GIT branches). - Restored the new 'simplified' API, which was started in libpng-1.5.7beta02 - but later deleted from libpng-1.5.7beta05. - Added example programs and test program pngstest for the new 'simplified' API. - Added ANSI-C (C90) headers and require them, and take advantage of the - change. Also fixed some of the projects/* and contrib/* files that needed - updates for libpng16 and the move of pngvalid.c. - With this change the required ANSI-C header files are assumed to exist: the - implementation must provide float.h, limits.h, stdarg.h and stddef.h and - libpng relies on limits.h and stddef.h existing and behaving as defined - (the other two required headers aren't used). Non-ANSI systems that don't - have stddef.h or limits.h will have to provide an appropriate fake - containing the relevant types and #defines. - The use of FAR/far has been eliminated and the definition of png_alloc_size_t - is now controlled by a flag so that 'small size_t' systems can select it - if necessary. Libpng 1.6 may not currently work on such systems -- it - seems likely that it will ask 'malloc' for more than 65535 bytes with any - image that has a sufficiently large row size (rather than simply failing - to read such images). - New tools directory containing tools used to generate libpng code. - Fixed race conditions in parallel make builds. With higher degrees of - parallelism during 'make' the use of the same temporary file names such - as 'dfn*' can result in a race where a temporary file from one arm of the - build is deleted or overwritten in another arm. This changes the - temporary files for suffix rules to always use $* and ensures that the - non-suffix rules use unique file names. - Correct configure builds where build and source directories are separate. - The include path of 'config.h' was erroneously made relative in pngvalid.c - in libpng 1.5.7. - Start-up code size improvements, error handler flexibility. These changes - alter how the tricky allocation of the initial png_struct and png_info - structures are handled. png_info is now handled in pretty much the same - way as everything else, except that the allocations handle NULL return - silently. png_struct is changed in a similar way on allocation and on - deallocation a 'safety' error handler is put in place (which should never - be required). The error handler itself is changed to permit mismatches - in the application and libpng error buffer size; however, this means a - silent change to the API to return the jmp_buf if the size doesn't match - the size from the libpng compilation; libpng now allocates the memory and - this may fail. Overall these changes result in slight code size - reductions; however, this is a reduction in code that is always executed - so is particularly valuable. Overall on a 64-bit system the libpng DLL - decreases in code size by 1733 bytes. pngerror.o increases in size by - about 465 bytes because of the new functionality. - Added png_convert_to_rfc1123_buffer() and deprecated png_convert_to_rfc1123() - to avoid including a spurious buffer in the png_struct. - Regenerated configure scripts with automake-1.11.2 - Eliminated png_info_destroy(). It is now used only in png.c and only calls - one other internal function and memset(). - Enabled png_get_sCAL_fixed() if floating point APIs are enabled. Previously - it was disabled whenever internal fixed point arithmetic was selected, - which meant it didn't exist even on systems where FP was available but not - preferred. - Added pngvalid.c compile time checks for const APIs. - Implemented 'restrict' for png_info and png_struct. Because of the way - libpng works both png_info and png_struct are always accessed via a - single pointer. This means adding C99 'restrict' to the pointer gives - the compiler some opportunity to optimize the code. This change allows - that. - Moved AC_MSG_CHECKING([if libraries can be versioned]) later to the proper - location in configure.ac (Gilles Espinasse). - Changed png_memcpy to C assignment where appropriate. Changed all those - uses of png_memcpy that were doing a simple assignment to assignments - (all those cases where the thing being copied is a non-array C L-value). - Added some error checking to png_set_*() routines. - Removed the reference to the non-exported function png_memcpy() from - example.c. - Fixed the Visual C 64-bit build - it requires jmp_buf to be aligned, but - it had become misaligned. - Revised contrib/pngminus/pnm2png.c to avoid warnings when png_uint_32 - and unsigned long are of different sizes. - Updated manual with description of the simplified API. - Fix bug in pngerror.c: some long warnings were being improperly truncated - (CVE-2011-3464, bug introduced in libpng-1.5.4). - Increased the formatted warning buffer to 192 bytes. - Fixed Min/GW uninstall to remove libpng.dll.a - Eliminated Intel icc/icl compiler warnings. The Intel (GCC derived) - compiler issues slightly different warnings from those issued by the - current vesions of GCC. This eliminates those warnings by - adding/removing casts and small code rewrites. - Updated configure.ac from autoupdate: added --enable-werror option. - Also some layout regularization and removal of introduced tab characters - (replaced with 3-character indentation). Obsolete macros identified by - autoupdate have been removed; the replacements are all in 2.59 so - the pre-req hasn't been changed. --enable-werror checks for support - for -Werror (or the given argument) in the compiler. This mimics the - gcc configure option by allowing -Werror to be turned on safely; without - the option the tests written in configure itself fail compilation because - they cause compiler warnings. - Rewrote autogen.sh to run autoreconf instead of running tools one-by-one. - Conditionalize the install rules for MINGW and CYGWIN in CMakeLists.txt and - set CMAKE_LIBRARY_OUTPUT_DIRECTORY to "lib" on all platforms (C. Yapp). - Freeze libtool files in the 'scripts' directory. This version of autogen.sh - attempts to dissuade people from running it when it is not, or should not, - be necessary. In fact, autogen.sh does not work when run in a libpng - directory extracted from a tar distribution anymore. You must run it in - a GIT clone instead. - Added two images to contrib/pngsuite (1-bit and 2-bit transparent grayscale), - and renamed three whose names were inconsistent with those in - pngsuite/README.txt. - Check libtool/libtoolize version number (2.4.2) in configure.ac - Moved automake options to AM_INIT_AUTOMAKE in configure.ac - Added color-tests, silent-rules (Not yet implemented in Makefile.am) and - version checking to configure.ac - Cleaned up pngpriv.h to consistently declare all functions and data. - Also eliminated PNG_CONST_DATA, which is apparently not needed but we - can't be sure until it is gone. - Added symbol prefixing that allows all the libpng external symbols - to be prefixed (suggested by Reuben Hawkins). - Updated "ftbb*.png" list in the owatcom and vstudio projects. - Added Z_SOLO for zlib-1.2.6+ and correct pngstest tests - Revised INSTALL information about autogen.sh. - Updated list of test images in CMakeLists.txt - Corrected estimate of error in libpng png_set_rgb_to_gray API. The API is - extremely inaccurate for sRGB conversions because it uses an 8-bit - intermediate linear value and it does not use the sRGB transform, so it - suffers from the known instability in gamma transforms for values close - to 0 (see Poynton). The net result is that the calculation has a maximum - error of 14.99/255; 0.5/255^(1/2.2). pngstest now uses 15 for the - permitted 8-bit error. This may still not be enough because of arithmetic - error. - Removed some unused arrays (with #ifdef) from png_read_push_finish_row(). - Fixed a memory overwrite bug in simplified read of RGB PNG with - non-linear gamma Also bugs in the error checking in pngread.c and changed - quite a lot of the checks in pngstest.c to be correct; either correctly - written or not over-optimistic. The pngstest changes are insufficient to - allow all possible RGB transforms to be passed; pngstest cmppixel needs - to be rewritten to make it clearer which errors it allows and then changed - to permit known inaccuracies. - Removed tests for no-longer-used *_EMPTY_PLTE_SUPPORTED from pngstruct.h - Fixed fixed/float API export conditionals. 1) If FIXED_POINT or - FLOATING_POINT options were switched off, png.h ended up with lone ';' - characters. This is not valid ANSI-C outside a function. The ';' - characters have been moved inside the definition of PNG_FP_EXPORT and - PNG_FIXED_EXPORT. 2) If either option was switched off, the declaration - of the corresponding functions were completely omitted, even though some - of them are still used internally. The result is still valid, but - produces warnings from gcc with some warning options (including -Wall). The - fix is to cause png.h to declare the functions with PNG_INTERNAL_FUNCTION - when png.h is included from pngpriv.h. - Check for invalid palette index while reading paletted PNG. When one is - found, issue a warning. - Fixed CVE-2011-3026 buffer overrun bug. Deal more correctly with the test - on iCCP chunk length. Also removed spurious casts that may hide problems - on 16-bit systems. - Eliminated redundant png_push_read_tEXt|zTXt|iTXt|unknown code from - pngpread.c and use the sequential png_handle_tEXt, etc., in pngrutil.c; - now that png_ptr->buffer is inaccessible to applications, the special - handling is no longer useful. - Added PNG_SAFE_LIMITS feature to pnglibconf.dfa, pngpriv.h, and new - pngusr.dfa to reset the user limits to safe ones if PNG_SAFE_LIMITS is - defined. To enable, use "CPPFLAGS=-DPNG_SAFE_LIMITS_SUPPORTED=1" on the - configure command or put #define PNG_SAFE_LIMITS_SUPPORTED in - pnglibconf.h.prebuilt and pnglibconf.h. - Added information about the new limits in the manual. - Removed unused "current_text" members of png_struct and the png_free() - of png_ptr->current_text from pngread.c - Added PNG_IMAGE_FLAG_FAST for the benefit of applications that store - intermediate files, or intermediate in-memory data, while processing - image data with the simplified API. The option makes the files larger - but faster to write and read. pngstest now uses this by default; this - can be disabled with the --slow option. - Improved pngstest fine tuning of error numbers, new test file generator. - The generator generates images that test the full range of sample values, - allow the error numbers in pngstest to be tuned and checked. makepng - also allows generation of images with extra chunks, although this is - still work-in-progress. - Fixed some bugs in ICC profile writing. The code should now accept - all potentially valid ICC profiles and reject obviously invalid ones. - It now uses png_error() to do so rather than casually writing a PNG - without the necessary color data. - Removed whitespace from the end of lines in all source files and scripts. - Added tests for invalid palette index while reading and writing. - Changed png_inflate() and calling routines to avoid overflow problems. - This is an intermediate check-in that solves the immediate problems and - introduces one performance improvement (avoiding a copy via png_ptr->zbuf.) - Further changes will be made to make ICC profile handling more secure. - Added contrib/libtests/tarith.c to test internal arithmetic functions from - png.c. This is a libpng maintainer program used to validate changes to the - internal arithmetic functions. - Made read 'inflate' handling like write 'deflate' handling. The read - code now claims and releases png_ptr->zstream, like the write code. - The bug whereby the progressive reader failed to release the zstream - is now fixed, all initialization is delayed, and the code checks for - changed parameters on deflate rather than always calling - deflatedEnd/deflateInit. - Validate the zTXt strings in pngvalid. - Added code to validate the windowBits value passed to deflateInit2(). - If the call to deflateInit2() is wrong a png_warning will be issued - (in fact this is harmless, but the PNG data produced may be sub-optimal). - Fixed PNG_LIBPNG_BUILD_BASE_TYPE definition. - Reject all iCCP chunks after the first, even if the first one is invalid. - Deflate/inflate was reworked to move common zlib calls into single - functions [rw]util.c. A new shared keyword check routine was also added - and the 'zbuf' is no longer allocated on progressive read. It is now - possible to call png_inflate() incrementally. - If benign errors are disabled use maximum window on ancilliary inflate. - This works round a bug introduced in 1.5.4 where compressed ancillary - chunks could end up with a too-small windowBits value in the deflate - header. - Issue a png_benign_error() instead of png_warning() about bad palette index. - In pngtest, treat benign errors as errors if "-strict" is present. - Fixed a compiler warning under Cygwin (Windows-7, 32-bit system) - Revised example.c to put text strings in a temporary character array - instead of directly assigning string constants to png_textp members. - This avoids compiler warnings when -Wwrite-strings is enabled. - Added output flushing to aid debugging under Visual Studio. Unfortunately - this is necessary because the VS2010 output window otherwise simply loses - the error messages on error (they weren't flushed to the window before - the process exited, apparently!) - Added configuration support for benign errors and changed the read - default. Also changed some warnings in the iCCP and sRGB handling - from to benign errors. Configuration now makes read benign - errors warnings and write benign errors to errors by default (thus - changing the behavior on read). The simplified API always forces - read benign errors to warnings (regardless of the system default, unless - this is disabled in which case the simplified API can't be built.) - Work around for duplicate row start calls; added warning messages. - This turns on PNG_FLAG_DETECT_UNINITIALIZED to detect app code that - fails to call one of the 'start' routines (not enabled in libpng-1.5 - because it is technically an API change, since it did normally work - before.) It also makes duplicate calls to png_read_start_row (an - internal function called at the start of the image read) benign, as - they were before changes to use png_inflate_claim. Somehow webkit is - causing this to happen; this is probably a mis-feature in the zlib - changes so this commit is only a work-round. - Removed erroneous setting of DETECT_UNINITIALIZED and added more - checks. The code now does a png_error if an attempt is made to do the - row initialization twice; this is an application error and it has - serious consequences because the transform data in png_struct is - changed by each call. - Added application error reporting and added chunk names to read - benign errors; also added --strict to pngstest - not enabled - yet because a warning is produced. - Avoid the double gamma correction warning in the simplified API. - This allows the --strict option to pass in the pngstest checks - Changed chunk handler warnings into benign errors, incrementally load iCCP - Added checksum-icc.c to contrib/tools - Prevent PNG_EXPAND+PNG_SHIFT doing the shift twice. - Recognize known sRGB ICC profiles while reading; prefer writing the - iCCP profile over writing the sRGB chunk, controlled by the - PNG_sRGB_PROFILE_CHECKS option. - Revised png_set_text_2() to avoid potential memory corruption (fixes - CVE-2011-3048). - Revised scripts/makefile.darwin: use system zlib; remove quotes around - architecture list; add missing ppc architecture; add architecture options - to shared library link; don't try to create a shared lib based on missing - RELEASE variable. - Enable png_set_check_for_invalid_index() for both read and write. - Removed #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED in pngpriv.h around - declaration of png_handle_unknown(). - Added -lssp_nonshared in a comment in scripts/makefile.freebsd - and changed deprecated NOOBJ and NOPROFILE to NO_OBJ and NO_PROFILE. - Removed need for -Wno-cast-align with clang. clang correctly warns on - alignment increasing pointer casts when -Wcast-align is passed. This - fixes the cases that clang warns about either by eliminating the - casts from png_bytep to png_uint_16p (pngread.c), or, for pngrutil.c - where the cast is previously verified or pngstest.c where it is OK, by - introducing new png_aligncast macros to do the cast in a way that clang - accepts. - Revised CMakeLists.txt to not attempt to make a symlink under mingw. - Made fixes for new optimization warnings from gcc 4.7.0. The compiler - performs an optimization which is safe; however it then warns about it. - Changing the type of 'palette_number' in pngvalid.c removes the warning. - Do not depend upon a GCC feature macro being available for use in generating - the linker mapfile symbol prefix. - Improved performance of new do_check_palette_indexes() function (only - update the value when it actually increases, move test for whether - the check is wanted out of the function. - Don't check palette indexes if num_palette is 0 (as it can be in MNG files). - Revised png_set_keep_unknown_chunks() so num_chunks < 0 means ignore all - unknown chunks and all known chunks except for IHDR, PLTE, tRNS, IDAT, - and IEND. Previously it only meant ignore all unknown chunks, the - same as num_chunks == 0. Revised png_image_skip_unused_chunks() to - provide a list of chunks to be processed instead of a list of chunks to - ignore. Revised contrib/gregbook/readpng2.c accordingly. - Removed scripts/makefile.cegcc from the *.zip and *.7z distributions; it - depends on configure, which is not included in those archives. - Moved scripts/chkfmt to contrib/tools. - Changed "a+w" to "u+w" in Makefile.in to fix CVE-2012-3386. - Do not compile PNG_DEPRECATED, PNG_ALLOC and PNG_PRIVATE when __GNUC__ < 3. - Do not use __restrict when GNUC is <= 3.1 - Removed references to png_zalloc() and png_zfree() from the manual. - Fixed configurations where floating point is completely disabled. Because - of the changes to support symbol prefixing PNG_INTERNAL_FUNCTION declares - floating point APIs during libpng builds even if they are completely - disabled. This requires the png floating point types (png_double*) to be - declared even though the functions are never actually defined. This - change provides a dummy definition so that the declarations work, yet any - implementation will fail to compile because of an incomplete type. - Re-eliminated the use of strcpy() in pngtest.c. An unncessary use of - strcpy() was accidentally re-introduced in libpng16; this change replaces - it with strncpy(). - Eliminated use of png_sizeof(); use sizeof() instead. - Use a consistent style for (sizeof type) and (sizeof (array)) - Cleanup of png_set_filler(). This function does very different things on - read and write. In libpng 1.6 the two cases can be distinguished and - considerable code cleanup, and extra error checking, is possible. This - makes calls on the write side that have no effect be ignored with a - png_app_error(), which can be disabled in the app using - png_set_benign_errors(), and removes the spurious use of usr_channels - on the read side. - Insist on autotools 1.12.1 for git builds because there are security issues - with 1.12 and insisting on anything less would allow 1.12 to be used. - Removed info_ptr->signature[8] from WRITE-only builds. - Add some conditions for compiling png_fixed(). This is a small function - but it requires "-lm" on some platforms. - Cause pngtest --strict to fail on any warning from libpng (not just errors) - and cause it not to fail at the comparison step if libpng lacks support - for writing chunks that it reads from the input (currently only implemented - for compressed text chunks). - Make all three "make check" test programs work without READ or WRITE support. - Now "make check" will succeed even if libpng is compiled with -DPNG_NO_READ - or -DPNG_NO_WRITE. The tests performed are reduced, but the basic reading - and writing of a PNG file is always tested by one or more of the tests. - Consistently use strlen(), memset(), memcpy(), and memcmp() instead of the - png_strlen(), png_memset(), png_memcpy(), and png_memcmp() macros. - Removed the png_sizeof(), png_strlen(), png_memset(), png_memcpy(), and - png_memcmp() macros. - Work around gcc 3.x and Microsoft Visual Studio 2010 complaints. Both object - to the split initialization of num_chunks. - Unknown handling fixes and clean up. This adds more correct option - control of the unknown handling, corrects the pre-existing bug where - the per-chunk 'keep' setting is ignored and makes it possible to skip - IDAT chunks in the sequential reader (broken in earlier 1.6 versions). - There is a new test program, test-unknown.c, which is a work in progress - (not currently part of the test suite). Comments in the header files now - explain how the unknown handling works. - Allow fine grain control of unknown chunk APIs. This change allows - png_set_keep_unknown_chunks() to be turned off if not required and causes - both read and write to behave appropriately (on read this is only possible - if the user callback is used to handle unknown chunks). The change - also removes the support for storing unknown chunks in the info_struct - if the only unknown handling enabled is via the callback, allowing libpng - to be configured with callback reading and none of the unnecessary code. - Corrected fix for unknown handling in pngtest. This reinstates the - libpng handling of unknown chunks other than vpAg and sTER (including - unsafe-to-copy chunks which were dropped before) and eliminates the - repositioning of vpAg and sTER in pngtest.png by changing pngtest.png - (so the chunks are where libpng would put them). - Added "tunknown" test and corrected a logic error in png_handle_unknown() - when SAVE support is absent. Moved the shell test scripts for - contrib/libtests from the libpng top directory to contrib/libtests. - png_handle_unknown() must always read or skip the chunk, if - SAVE_UNKNOWN_CHUNKS is turned off *and* the application does not set - a user callback an unknown chunk will not be read, leading to a read - error, which was revealed by the "tunknown" test. - Cleaned up and corrected ICC profile handling. - contrib/libtests/makepng: corrected 'rgb' and 'gray' cases. profile_error - messages could be truncated; made a correct buffer size calculation and - adjusted pngerror.c appropriately. png_icc_check_* checking improved; - changed the functions to receive the correct color type of the PNG on read - or write and check that it matches the color space of the profile (despite - what the comments said before, there is danger in assuming the app will - cope correctly with an RGB profile on a grayscale image and, since it - violates the PNG spec, allowing it is certain to produce inconsistent - app behavior and might even cause app crashes.) Check that profiles - contain the tags needed to process the PNG (tags all required by the ICC - spec). Removed unused PNG_STATIC from pngpriv.h. - Fixed the simplified API example programs and improved the error message - if the version field is not set. - Updated simplified API synopses and description of the png_image structure - in the manual. - Made makepng and pngtest produce identical PNGs, add "--relaxed" option - to pngtest. The "--relaxed" option turns off the benign errors that are - enabled by default in pre-RC builds. makepng can now write ICC profiles - where the length has not been extended to a multiple of 4, and pngtest - now intercepts all libpng errors, allowing the previously-introduced - "--strict test" on no warnings to actually work. - Added a work around for GCC 4.2 optimization bug. - Marked the broken (bad white point) original HP sRGB profiles correctly and - correct comments. - Added -DZ_SOLO to contrib/pngminim/*/makefile to work with zlib-1.2.7 - Use /MDd for vstudio debug builds. Also added pngunkown to the vstudio - builds, fixed build errors and corrected a minor exit code error in - pngvalid if the 'touch' file name is invalid. - Add updated WARNING file to projects/vstudio from libpng 1.5/vstudio - Fixed build when using #define PNG_NO_READ_GAMMA in png_do_compose() in - pngrtran.c (Domani Hannes). - Made pngvalid so that it will build outside the libpng source tree. - Made PNG_NO_READ_GAMMA switch off interfaces that depend on READ_GAMMA. - Prior to 1.6.0 switching off READ_GAMMA did unpredictable things to the - interfaces that use it (specifically, png_do_background in 1.4 would - simply display composite for grayscale images but do composition - with the incorrect arithmetic for color ones). In 1.6 the semantic - of -DPNG_NO_READ_GAMMA is changed to simply disable any interface that - depends on it; this obliges people who set it to consider whether they - really want it off if they happen to use any of the interfaces in - question (typically most users who disable it won't). - Added the ability for contrib/libtests/makepng.c to make a PNG with just one - color. This is useful for debugging pngstest color inaccuracy reports. - Made png_user_version_check() ok to use with libpng version 1.10.x and later. - Fixed typo in png.c (PNG_SET_CHUNK_MALLOC_MAX should be PNG_CHUNK_MALLOC_MAX) - that causes the MALLOC_MAX limit not to work (John Bowler) - Change png_warning() to png_app_error() in pngwrite.c and comment the - fall-through condition. - Change png_warning() to png_app_warning() in png_write_tRNS(). - Rearranged the ARM-NEON optimizations: Isolated the machine specific code - to the hardware subdirectory and added comments to pngrutil.c so that - implementors of other optimizations know what to do. - Fixed cases of unquoted DESTDIR in Makefile.am - Cleaned up whitespace in the synopsis portion of the manpage "libpng.3" - Disassembled the version number in scripts/options.awk (necessary for - building on SunOs). - Made default Zlib compression settings be configurable. This adds #defines to - pnglibconf.h to control the defaults. - Fixed Windows build issues, enabled ARM compilation. Various warnings issued - by earlier versions of GCC fixed for Cygwin and Min/GW (which both use old - GCCs.) ARM support is enabled by default in zlib.props (unsupported by - Microsoft) and ARM compilation is made possible by deleting the check for - x86. The test programs cannot be run because they are not signed. - Discontinued distributing libpng-1.x.x.tar.bz2. - Discontinued distributing libpng-1.7.0-1.6.0-diff.txt and similar. - Rebuilt Makefile.in, configure, etc., with autoconf-2.69 and automake-1.12.5. - Fixed 'make distcheck' on SUN OS - libpng.so was not being removed - Fixed conceivable but difficult to repro overflow. Also added two test - programs to generate and test a PNG which should have the problem. - Added overflow detection in png_set_sPLT() and png_set_text_2(). - Use consistent handling of overflows in text, sPLT and unknown png_set_* APIs - Added png_get_palette_max() function. - Fixed missing dependency in --prefix builds The intermediate - internal 'prefix.h' file can only be generated correctly after - pnglibconf.h, however the dependency was not in Makefile.am. The - symptoms are unpredictable depending on the order make chooses to - build pngprefix.h and pnglibconf.h, often the error goes unnoticed - because there is a system pnglibconf.h to use instead. - Enclosed the new png_get_palette_max in #ifdef PNG_GET_PALETTE_MAX_SUPPORTED - block, and revised pnglibconf.h and pnglibconf.h.prebuilt accordingly. + Made symbol prefixing work with the ARM neon optimizations. Also allow + pngpriv.h to be included for preprocessor definitions only, so it can + be used in non-C/C++ files. Back ported from libpng 1.7. + Made sRGB check numbers consistent. + Ported libpng 1.5 options.awk/dfn file handling to 1.6, fixed one bug. + Removed cc -E workround, corrected png_get_palette_max API Tested on + SUN OS cc 5.9, which demonstrates the tokenization problem previously + avoided by using /lib/cpp. Since all .dfn output is now protected in + double quotes unless it is to be macro substituted the fix should + work everywhere. + Enabled parallel tests - back ported from libpng-1.7. + scripts/pnglibconf.dfa formatting improvements back ported from libpng17. + Fixed a race condition in the creation of the build 'scripts' directory + while building with a parallel make. + Use approved/supported Android method to check for NEON, use Linux/POSIX + 1003.1 API to check /proc/self/auxv avoiding buffer allocation and other + library calls (ported from libpng15). + Use parentheses more consistently in "#if defined(MACRO)" tests. + Folded long lines. + Reenabled code to allow zero length PLTE chunks for MNG. + Fixed ALIGNED_MEMORY support. + Allow run-time ARM NEON checking to be disabled. A new configure option: + --enable-arm-neon=always will stop the run-time checks. New checks + within arm/arm_init.c will cause the code not to be compiled unless + __ARM_NEON__ is set. This should make it fail safe (if someone asks + for it on then the build will fail if it can't be done.) + Updated the INSTALL document. + Revised INSTALL to recommend using CPPFLAGS instead of INCLUDES. + Revised scripts/makefile.freebsd to respect ZLIBLIB and ZLIBINC. + Revised scripts/dfn.awk to work with the buggy MSYS awk that has trouble + with CRLF line endings. + Avoid a possible memory leak in contrib/gregbook/readpng.c + 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, + 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. + The order of settings vs options in pnglibconf.h is reversed to allow + settings to depend on options and options can now set (or override) the + defaults for settings. + Corrected simplified API default gamma for color-mapped output, added + a flag to change default. In 1.6.0 when the simplified API was used + to produce color-mapped output from an input image with no gamma + information the gamma assumed for the input could be different from + that assumed for non-color-mapped output. In particular 16-bit depth + input files were assumed to be sRGB encoded, whereas in the 'direct' + case they were assumed to have linear data. This was an error. The + fix makes the simplified API treat all input files the same way and + adds a new flag to the png_image::flags member to allow the + application/user to specify that 16-bit files contain sRGB data + rather than the default linear. + Fixed bugs in the pngpixel and makepng test programs. + Fixed CMakelists.txt to allow building a single variant of the library + (Claudio Bley): + Introduced a PNG_LIB_TARGETS variable that lists all activated library + targets. It is an error if this variable ends up empty, ie. you have + to build at least one library variant. + Made the *_COPY targets only depend on library targets actually being build. + Use PNG_LIB_TARGETS to unify a code path. + Changed the CREATE_SYMLINK macro to expect the full path to a file as the + first argument. When symlinking the filename component of that path is + determined and used as the link target. + Use copy_if_different in the CREATE_SYMLINK macro. + Eliminated two warnings from the Intel C compiler. The warnings are + technically valid, although a reasonable treatment of division would + show it to be incorrect. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CHANGES b/CHANGES index b7e8cca51..382540817 100644 --- a/CHANGES +++ b/CHANGES @@ -3672,7 +3672,8 @@ Version 1.5.6 [November 3, 2011] No changes. Version 1.5.7beta01 [November 4, 2011] - Added support for ARM processor (Mans Rullgard) + Added support for ARM processor, when decoding all PNG up-filtered rows + and any other-filtered rows with 3 or 4 bytes per pixel (Mans Rullgard). Fixed bug in pngvalid on early allocation failure; fixed type cast in pngmem.c; pngvalid would attempt to call png_error() if the allocation of a png_struct or png_info failed. This would probably have led to a @@ -4381,6 +4382,97 @@ Version 1.6.0rc08 [February 10, 2013] Version 1.6.0 [February 14, 2013] No changes. +Version 1.6.1beta01 [February 16, 2013] + Made symbol prefixing work with the ARM neon optimizations. Also allow + pngpriv.h to be included for preprocessor definitions only, so it can + be used in non-C/C++ files. Back ported from libpng 1.7. + Made sRGB check numbers consistent. + Ported libpng 1.5 options.awk/dfn file handling to 1.6, fixed one bug. + Removed cc -E workround, corrected png_get_palette_max API Tested on + SUN OS cc 5.9, which demonstrates the tokenization problem previously + avoided by using /lib/cpp. Since all .dfn output is now protected in + double quotes unless it is to be macro substituted the fix should + work everywhere. + Enabled parallel tests - back ported from libpng-1.7. + scripts/pnglibconf.dfa formatting improvements back ported from libpng17. + Fixed a race condition in the creation of the build 'scripts' directory + while building with a parallel make. + Use approved/supported Android method to check for NEON, use Linux/POSIX + 1003.1 API to check /proc/self/auxv avoiding buffer allocation and other + library calls (ported from libpng15). + +Version 1.6.1beta02 [February 19, 2013] + Use parentheses more consistently in "#if defined(MACRO)" tests. + Folded long lines. + Reenabled code to allow zero length PLTE chunks for MNG. + +Version 1.6.1beta03 [February 22, 2013] + Fixed ALIGNED_MEMORY support. + Allow run-time ARM NEON checking to be disabled. A new configure option: + --enable-arm-neon=always will stop the run-time checks. New checks + within arm/arm_init.c will cause the code not to be compiled unless + __ARM_NEON__ is set. This should make it fail safe (if someone asks + for it on then the build will fail if it can't be done.) + Updated the INSTALL document. + +Version 1.6.1beta04 [February 27, 2013] + Revised INSTALL to recommend using CPPFLAGS instead of INCLUDES. + Revised scripts/makefile.freebsd to respect ZLIBLIB and ZLIBINC. + Revised scripts/dfn.awk to work with the buggy MSYS awk that has trouble + with CRLF line endings. + +Version 1.6.1beta05 [March 1, 2013] + Avoid a possible memory leak in contrib/gregbook/readpng.c + +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, + 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. + The order of settings vs options in pnglibconf.h is reversed to allow + settings to depend on options and options can now set (or override) the + defaults for settings. + +Version 1.6.1beta07 [March 7, 2013] + Corrected simplified API default gamma for color-mapped output, added + a flag to change default. In 1.6.0 when the simplified API was used + to produce color-mapped output from an input image with no gamma + information the gamma assumed for the input could be different from + that assumed for non-color-mapped output. In particular 16-bit depth + input files were assumed to be sRGB encoded, whereas in the 'direct' + case they were assumed to have linear data. This was an error. The + fix makes the simplified API treat all input files the same way and + adds a new flag to the png_image::flags member to allow the + application/user to specify that 16-bit files contain sRGB data + rather than the default linear. + Fixed bugs in the pngpixel and makepng test programs. + +Version 1.6.1beta08 [March 7, 2013] + Fixed CMakelists.txt to allow building a single variant of the library + (Claudio Bley): + Introduced a PNG_LIB_TARGETS variable that lists all activated library + targets. It is an error if this variable ends up empty, ie. you have + to build at least one library variant. + Made the *_COPY targets only depend on library targets actually being build. + Use PNG_LIB_TARGETS to unify a code path. + Changed the CREATE_SYMLINK macro to expect the full path to a file as the + first argument. When symlinking the filename component of that path is + determined and used as the link target. + Use copy_if_different in the CREATE_SYMLINK macro. + +Version 1.6.1beta09 [March 13, 2013] + Eliminated two warnings from the Intel C compiler. The warnings are + technically valid, although a reasonable treatment of division would + show it to be incorrect. + +Version 1.6.1rc01 [March 21, 2013] + No changes. + +Version 1.6.1 [March 28, 2013] + No changes. + Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement diff --git a/CMakeLists.txt b/CMakeLists.txt index 728a419e3..1ebf0da86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ enable_testing() set(PNGLIB_MAJOR 1) set(PNGLIB_MINOR 6) -set(PNGLIB_RELEASE 0) +set(PNGLIB_RELEASE 1) set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR}) set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE}) @@ -139,8 +139,11 @@ endif() # NOW BUILD OUR TARGET include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR}) +unset(PNG_LIB_TARGETS) + if(PNG_SHARED) add_library(${PNG_LIB_NAME} SHARED ${libpng_sources}) + set(PNG_LIB_TARGETS ${PNG_LIB_NAME}) if(MSVC) # msvc does not append 'lib' - do it here to have consistent name set_target_properties(${PNG_LIB_NAME} PROPERTIES PREFIX "lib") @@ -153,6 +156,7 @@ if(PNG_STATIC) # does not work without changing name set(PNG_LIB_NAME_STATIC ${PNG_LIB_NAME}_static) add_library(${PNG_LIB_NAME_STATIC} STATIC ${libpng_sources}) + list(APPEND PNG_LIB_TARGETS ${PNG_LIB_NAME_STATIC}) if(MSVC) # msvc does not append 'lib' - do it here to have consistent name set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES PREFIX "lib") @@ -160,6 +164,12 @@ if(PNG_STATIC) target_link_libraries(${PNG_LIB_NAME_STATIC} ${ZLIB_LIBRARY} ${M_LIBRARY}) endif() +if(NOT PNG_LIB_TARGETS) + message(SEND_ERROR + "No library variant selected to build. " + "Please enable at least one of the following options: PNG_STATIC, PNG_SHARED") +endif() + if(PNG_SHARED AND WIN32) set_target_properties(${PNG_LIB_NAME} PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL) endif() @@ -222,14 +232,15 @@ macro(CREATE_SYMLINK SRC_FILE DEST_FILE) if(WIN32 AND NOT CYGWIN AND NOT MSYS) ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE} - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE} - DEPENDS ${PNG_LIB_NAME} ${PNG_LIB_NAME_STATIC} + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_FILE}" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_FILE}" ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE} + DEPENDS ${PNG_LIB_TARGETS} ) ADD_CUSTOM_TARGET(${DEST_FILE}_COPY ALL DEPENDS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE}) else(WIN32 AND NOT CYGWIN AND NOT MSYS) - execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SRC_FILE} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SRC_FILE} ${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + get_filename_component(LINK_TARGET "${SRC_FILE}" NAME) + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${LINK_TARGET}" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${LINK_TARGET}" ${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) endif(WIN32 AND NOT CYGWIN AND NOT MSYS) endmacro() @@ -260,7 +271,7 @@ endif(NOT WIN32 OR CYGWIN OR MINGW) # SET UP LINKS if(PNG_SHARED) set_target_properties(${PNG_LIB_NAME} PROPERTIES -# VERSION 16.${PNGLIB_RELEASE}.1.6.0 +# VERSION 16.${PNGLIB_RELEASE}.1.6.1 VERSION 16.${PNGLIB_RELEASE}.0 SOVERSION 16 CLEAN_DIRECT_OUTPUT 1) @@ -287,40 +298,33 @@ endif() # INSTALL if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) - if(PNG_SHARED) - install(TARGETS ${PNG_LIB_NAME} - ${PNG_EXPORT_RULE} - RUNTIME DESTINATION bin - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS ${PNG_LIB_TARGETS} + ${PNG_EXPORT_RULE} + RUNTIME DESTINATION bin + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + if(PNG_SHARED) # Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin if(CYGWIN OR MINGW) get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE}) - get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME) - CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_IMPORT_LIBRARY_SUFFIX}) + CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_IMPORT_LIBRARY_SUFFIX}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif(CYGWIN OR MINGW) if(NOT WIN32) get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE}) - get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME) - CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_SHARED_LIBRARY_SUFFIX}) + CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_SHARED_LIBRARY_SUFFIX}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif(NOT WIN32) endif(PNG_SHARED) if(PNG_STATIC) - install(TARGETS ${PNG_LIB_NAME_STATIC} - ${PNG_EXPORT_RULE} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) if(NOT WIN32 OR CYGWIN OR MINGW) get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME_STATIC} LOCATION_${CMAKE_BUILD_TYPE}) - get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME) - CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_STATIC_LIBRARY_SUFFIX}) + CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_STATIC_LIBRARY_SUFFIX}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif(NOT WIN32 OR CYGWIN OR MINGW) diff --git a/INSTALL b/INSTALL index 2644c7a4f..f98737800 100644 --- a/INSTALL +++ b/INSTALL @@ -41,19 +41,33 @@ 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. +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 +correspond to the version of zlib that's installed. + +If you wish to test with a particular zlib that is not first in the +standard library search path, put ZLIBLIB, ZLIBINC, CPPFLAGS, LDFLAGS, +and LD_LIBRARY_PATH in your environment before running "make test" +or "make distcheck": + +ZLIBLIB=/path/to/lib export ZLIBLIB +ZLIBINC=/path/to/include export ZLIBINC +CPPFLAGS="-I$ZLIBINC" export CPPFLAGS +LDFLAGS="-L$ZLIBLIB" export LDFLAGS +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". + If you want to use "cmake" (see www.cmake.org), type cmake . -DCMAKE_INSTALL_PREFIX=/path make make install -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 -correspond to the version of zlib that's installed. - You can rename the directories that you downloaded (they -might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.5" -or "zlib125") so that you have directories called "zlib" and "libpng". +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". Your directory structure should look like this: @@ -71,6 +85,7 @@ Your directory structure should look like this: depcomp, install-sh, mkinstalldirs, test-pngtest.sh contrib gregbook + libtests pngminim pngminus pngsuite diff --git a/LICENSE b/LICENSE index e95d3598b..d86a7da26 100644 --- a/LICENSE +++ b/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.0, February 14, 2013, are +libpng versions 1.2.6, August 15, 2004, through 1.6.1, March 28, 2013, are Copyright (c) 2004, 2006-2012 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 -February 14, 2013 +March 28, 2013 diff --git a/Makefile.am b/Makefile.am index ca44c68d4..a2cd2c10b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,24 +7,44 @@ PNGLIB_BASENAME= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ ACLOCAL_AMFLAGS = -I scripts # test programs - run on make check, make distcheck -TESTS_ENVIRONMENT= srcdir=$(srcdir) -check_PROGRAMS= pngtest +check_PROGRAMS= pngtest pngunknown pngstest pngvalid + pngtest_SOURCES = pngtest.c pngtest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la -TESTS = test-pngtest.sh -# Only do the following if the contrib directory is present. -check_PROGRAMS+= pngvalid pngstest pngunknown pngvalid_SOURCES = contrib/libtests/pngvalid.c -pngstest_SOURCES = contrib/libtests/pngstest.c -pngunknown_SOURCES = contrib/libtests/pngunknown.c pngvalid_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la + +pngstest_SOURCES = contrib/libtests/pngstest.c pngstest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la + +pngunknown_SOURCES = contrib/libtests/pngunknown.c pngunknown_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la -TESTS += contrib/libtests/test-pngunknown.sh\ - contrib/libtests/test-pngvalid-simple.sh\ - contrib/libtests/test-pngvalid-full.sh\ - contrib/libtests/test-pngstest.sh + +# Generally these are single line shell scripts to run a test with a particular +# set of parameters: +TESTS =\ + tests/pngtest\ + tests/pngvalid-gamma-16-to-8 tests/pngvalid-gamma-alpha-mode\ + tests/pngvalid-gamma-background tests/pngvalid-gamma-expand16-alpha-mode\ + tests/pngvalid-gamma-expand16-background\ + tests/pngvalid-gamma-expand16-transform tests/pngvalid-gamma-sbit\ + tests/pngvalid-gamma-threshold tests/pngvalid-gamma-transform\ + tests/pngvalid-progressive-interlace-size\ + tests/pngvalid-progressive-interlace-standard\ + tests/pngvalid-progressive-interlace-transform\ + tests/pngvalid-progressive-standard tests/pngvalid-standard\ + tests/pngstest-0g01 tests/pngstest-0g02 tests/pngstest-0g04\ + tests/pngstest-0g08 tests/pngstest-0g16 tests/pngstest-2c08\ + tests/pngstest-2c16 tests/pngstest-3p01 tests/pngstest-3p02\ + tests/pngstest-3p04 tests/pngstest-3p08 tests/pngstest-4a08\ + tests/pngstest-4a16 tests/pngstest-6a08 tests/pngstest-6a16\ + tests/pngstest-error tests/pngunknown-IDAT\ + tests/pngunknown-discard tests/pngunknown-if-safe tests/pngunknown-sAPI\ + tests/pngunknown-sTER tests/pngunknown-save tests/pngunknown-vpAg + +# These tests are expected, and required, to fail: +XFAIL_TESTS = tests/pngstest-error # man pages dist_man_MANS= libpng.3 libpngpf.3 png.5 @@ -77,12 +97,14 @@ nodist_pkginclude_HEADERS= pnglibconf.h pkgconfigdir = @pkgconfigdir@ pkgconfig_DATA = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc -#extra source distribution files. +# Extra source distribution files, '${srcdir}' is used below to stop build files +# from those directories being included. This only works if the configure is +# not done in the source directory! EXTRA_DIST= \ ANNOUNCE CHANGES INSTALL LICENSE README TODO \ pngtest.png pngbar.png pngnow.png pngbar.jpg autogen.sh \ ${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \ - $(TESTS) \ + $(TESTS) $(XFAIL_TESTS) tests/pngstest \ CMakeLists.txt example.c libpng-manual.txt SCRIPT_CLEANFILES=scripts/*.out scripts/*.chk scripts/pnglibconf.dfn @@ -180,16 +202,14 @@ SYMBOL_CFLAGS += -DPNG_PREFIX='@PNG_PREFIX@' endif .dfn.out: - rm -f $@ $*.c $*.tf[123] - test -d scripts || mkdir scripts + rm -f $@ $*.c $*.tf[12] + test -d scripts || mkdir scripts || test -d scripts echo '#include "$<"' >$*.c $(DFNCPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)\ $(CPPFLAGS) $(SYMBOL_CFLAGS) $*.c > $*.tf1 - $(SED) -n -e 's|^.*PNG_DEFN_MAGIC *-\(.*\)- *PNG_DEFN_END.*$$|\1|p'\ - $*.tf1 >$*.tf2 - $(SED) -e 's| *PNG_JOIN *||g' -e 's| *$$||' $*.tf2 >$*.tf3 - rm -f $*.c $*.tf[12] - mv $*.tf3 $@ + $(AWK) -f "${srcdir}/scripts/dfn.awk" out="$*.tf2" $*.tf1 1>&2 + rm -f $*.c $*.tf1 + mv $*.tf2 $@ # The .dfn file for pnglibconf.h is machine generated pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h pngusr.dfa $(DFA_XTRA) diff --git a/README b/README index 295ee1f82..fcf8f3fae 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -README for libpng version 1.6.0 - February 14, 2013 (shared library 16.0) +README for libpng version 1.6.1 - March 28, 2013 (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. diff --git a/arm/arm_init.c b/arm/arm_init.c index 8925f352f..795dd4938 100644 --- a/arm/arm_init.c +++ b/arm/arm_init.c @@ -1,54 +1,190 @@ /* arm_init.c - NEON optimised filter functions * - * Copyright (c) 2012 Glenn Randers-Pehrson + * Copyright (c) 2013 Glenn Randers-Pehrson * Written by Mans Rullgard, 2011. - * Last changed in libpng 1.5.14 [(PENDING RELEASE)] + * Last changed in libpng 1.5.15 [March 28, 2013] * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer * and license in png.h */ +/* Below, after checking __linux__, various non-C90 POSIX 1003.1 functions are + * called. + */ +#define _POSIX_SOURCE 1 + #include "../pngpriv.h" -/* __arm__ is defined by GCC, MSVC defines _M_ARM to the ARM version number */ -#if defined __linux__ && defined __arm__ -#include +#ifdef PNG_ARM_NEON_SUPPORTED +#ifdef PNG_ARM_NEON_CHECK_SUPPORTED /* Do run-time checks */ +#include /* for sig_atomic_t */ + +#ifdef __ANDROID__ +/* Linux provides access to information about CPU capabilites via + * /proc/self/auxv, however Android blocks this while still claiming to be + * Linux. The Andoid NDK, however, provides appropriate support. + * + * Documentation: http://www.kandroid.org/ndk/docs/CPU-ARM-NEON.html + */ +#include + +static int +png_have_neon(png_structp png_ptr) +{ + /* This is a whole lot easier than the mess below, however it is probably + * implemented as below, therefore it is better to cache the result (these + * function calls may be slow!) + */ + PNG_UNUSED(png_ptr) + return android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && + (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0; +} +#elif defined(__linux__) +/* The generic __linux__ implementation requires reading /proc/self/auxv and + * looking at each element for one that records NEON capabilities. + */ +#include /* for POSIX 1003.1 */ +#include /* for EINTR */ + +#include +#include +#include #include #include -static int png_have_hwcap(unsigned cap) +/* A read call may be interrupted, in which case it returns -1 and sets errno to + * EINTR if nothing was done, otherwise (if something was done) a partial read + * may result. + */ +static size_t +safe_read(png_structp png_ptr, int fd, void *buffer_in, size_t nbytes) { - FILE *f = fopen("/proc/self/auxv", "r"); - Elf32_auxv_t aux; - int have_cap = 0; + size_t ntotal = 0; + char *buffer = png_voidcast(char*, buffer_in); - if (!f) - return 0; - - while (fread(&aux, sizeof(aux), 1, f) > 0) + while (nbytes > 0) { - if (aux.a_type == AT_HWCAP && - aux.a_un.a_val & cap) + unsigned int nread; + int iread; + + /* Passing nread > INT_MAX to read is implementation defined in POSIX + * 1003.1, therefore despite the unsigned argument portable code must + * limit the value to INT_MAX! + */ + if (nbytes > INT_MAX) + nread = INT_MAX; + + else + nread = (unsigned int)/*SAFE*/nbytes; + + iread = read(fd, buffer, nread); + + if (iread == -1) { - have_cap = 1; - break; + /* This is the devil in the details, a read can terminate early with 0 + * bytes read because of EINTR, yet it still returns -1 otherwise end + * of file cannot be distinguished. + */ + if (errno != EINTR) + { + png_warning(png_ptr, "/proc read failed"); + return 0; /* I.e. a permanent failure */ + } + } + + else if (iread < 0) + { + /* Not a valid 'read' result: */ + png_warning(png_ptr, "OS /proc read bug"); + return 0; + } + + else if (iread > 0) + { + /* Continue reading until a permanent failure, or EOF */ + buffer += iread; + nbytes -= (unsigned int)/*SAFE*/iread; + ntotal += (unsigned int)/*SAFE*/iread; + } + + else + return ntotal; + } + + return ntotal; /* nbytes == 0 */ +} + +static int +png_have_neon(png_structp png_ptr) +{ + int fd = open("/proc/self/auxv", O_RDONLY); + Elf32_auxv_t aux; + + /* Failsafe: failure to open means no NEON */ + if (fd == -1) + { + png_warning(png_ptr, "/proc/self/auxv open failed"); + return 0; + } + + while (safe_read(png_ptr, fd, &aux, sizeof aux) == sizeof aux) + { + if (aux.a_type == AT_HWCAP && (aux.a_un.a_val & HWCAP_NEON) != 0) + { + close(fd); + return 1; } } - fclose(f); - - return have_cap; + close(fd); + return 0; } -#endif /* __linux__ && __arm__ */ +#else + /* We don't know how to do a run-time check on this system */ +# error "no support for run-time ARM NEON checks" +#endif /* OS checks */ +#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */ + +#ifndef PNG_ALIGNED_MEMORY_SUPPORTED +# error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED" +#endif void png_init_filter_functions_neon(png_structp pp, unsigned int bpp) { -#ifdef __arm__ -#ifdef __linux__ - if (!png_have_hwcap(HWCAP_NEON)) - return; +#ifdef PNG_ARM_NEON_API_SUPPORTED + switch ((pp->options >> PNG_ARM_NEON) & 3) + { + case PNG_OPTION_UNSET: + /* Allow the run-time check to execute if it has been enabled - + * thus both API and CHECK can be turned on. If it isn't supported + * this case will fall through to the 'default' below, which just + * returns. + */ +#endif /* PNG_ARM_NEON_API_SUPPORTED */ +#ifdef PNG_ARM_NEON_CHECK_SUPPORTED + { + static volatile sig_atomic_t no_neon = -1; /* not checked */ + + if (no_neon < 0) + no_neon = !png_have_neon(pp); + + if (no_neon) + return; + } +#ifdef PNG_ARM_NEON_API_SUPPORTED + break; +#endif +#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */ +#ifdef PNG_ARM_NEON_API_SUPPORTED + case PNG_OPTION_ON: + /* Option turned on */ + break; + + default: /* OFF or INVALID */ + return; + } #endif /* IMPORTANT: any new external functions used here must be declared using @@ -79,8 +215,5 @@ png_init_filter_functions_neon(png_structp pp, unsigned int bpp) pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth4_neon; } -#else - PNG_UNUSED(pp) - PNG_UNUSED(bpp) -#endif } +#endif /* FILTER_OPTIMIZATIONS && __arm__ && __ARM_NEON__ */ diff --git a/arm/filter_neon.S b/arm/filter_neon.S index 4aa500cd7..72420a9e3 100644 --- a/arm/filter_neon.S +++ b/arm/filter_neon.S @@ -10,7 +10,14 @@ * and license in png.h */ -#ifdef __arm__ +/* This is required to get the symbol renames, which are #defines, and also + * includes the value of PNG_FILTER_OPTIMIZATIONS. + */ +#define PNG_VERSION_INFO_ONLY +#include "../pngpriv.h" + +#if defined(PNG_FILTER_OPTIMIZATIONS) && defined(__arm__) && \ + defined(__ARM_NEON__) #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits /* mark stack as non-executable */ #endif @@ -225,4 +232,4 @@ func png_read_filter_row_paeth3_neon, export=1 pop {r4,pc} endfunc -#endif +#endif /* FILTER_OPTIMIZATIONS && __arm__ && __ARM_NEON__ */ diff --git a/autogen.sh b/autogen.sh index b6db4eb1c..decf0f56f 100755 --- a/autogen.sh +++ b/autogen.sh @@ -74,7 +74,7 @@ done # # The autotools generated files: libpng_autotools_files="Makefile.in aclocal.m4 config.guess config.h.in\ - config.sub configure depcomp install-sh ltmain.sh missing" + config.sub configure depcomp install-sh ltmain.sh missing test-driver" # # These are separate because 'maintainer-clean' does not remove them. libpng_libtool_files="scripts/libtool.m4 scripts/ltoptions.m4\ diff --git a/configure.ac b/configure.ac index e6ff077da..1745d3178 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ AC_PREREQ([2.68]) dnl Version number stuff here: -AC_INIT([libpng],[1.6.0],[png-mng-implement@lists.sourceforge.net]) +AC_INIT([libpng],[1.6.1],[png-mng-implement@lists.sourceforge.net]) AC_CONFIG_MACRO_DIR([scripts]) # libpng does not follow GNU file name conventions (hence 'foreign') @@ -26,9 +26,11 @@ AC_CONFIG_MACRO_DIR([scripts]) # silent-rules requires automake 1.11 or later # dist-xz requires automake 1.11 or later # 1.12.2 fixes a security issue in 1.11.2 and 1.12.1 -AM_INIT_AUTOMAKE([1.12.2 foreign dist-xz color-tests silent-rules serial-tests]) -# was: -# AM_INIT_AUTOMAKE +# 1.13 is required for parallel tests +AM_INIT_AUTOMAKE([1.13 foreign dist-xz color-tests silent-rules]) +# The following line causes --disable-maintainer-mode to be the default to +# configure, this is necessary because libpng distributions cannot rely on the +# time stamps of the autotools generated files being correct AM_MAINTAINER_MODE dnl configure.ac and Makefile.am expect automake 1.11.2 or a compatible later @@ -37,10 +39,10 @@ dnl automake, so the following is not necessary (and is not defined anyway): dnl AM_PREREQ([1.11.2]) dnl stop configure from automagically running automake -PNGLIB_VERSION=1.6.0 +PNGLIB_VERSION=1.6.1 PNGLIB_MAJOR=1 PNGLIB_MINOR=6 -PNGLIB_RELEASE=0 +PNGLIB_RELEASE=1 dnl End of version number stuff @@ -53,8 +55,7 @@ AC_PROG_CC AM_PROG_AS LT_PATH_LD AC_PROG_CPP -AC_CHECK_TOOL(SED, sed, :) -AC_CHECK_TOOL(AWK, awk, :) +AC_PROG_AWK AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET @@ -64,30 +65,23 @@ dnl compatible later version may be used LT_INIT([win32-dll]) LT_PREREQ([2.4.2]) -# On Solaris 10 and 12 CPP gets set to cc -E, however this still -# does some input parsing. We need strict ANSI-C style tokenization, -# check this: -AC_REQUIRE_CPP -AC_MSG_CHECKING([for a C preprocessor that does not parse its input]) -AC_PREPROC_IFELSE([AC_LANG_SOURCE([[1.1.1 16BIT]])], - [DFNCPP="$CPP"], - [ DFNCPP="" - sav_CPP="$CPP" - for CPP in "${CC-cc} -E" "${CC-cc} -E -traditional-cpp" "/lib/cpp" "cpp" - do - AC_PREPROC_IFELSE([AC_LANG_SOURCE([[1.1.1 16BIT]])], - [DFNCPP="$CPP"] - [break],,) - done - CPP="$sav_CPP" - ]) -if test -n "$DFNCPP"; then - AC_MSG_RESULT([$DFNCPP]) - AC_SUBST(DFNCPP) +# Some awks crash when confronted with pnglibconf.dfa, do a test run now +# to make sure this doesn't happen +AC_MSG_CHECKING([that AWK works]) +if ${AWK} -f ${srcdir}/scripts/options.awk out="/dev/null" version=search\ + ${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\ + ${srcdir}/pngusr.dfa 1>&2 +then + AC_MSG_RESULT([ok]) else - AC_MSG_FAILURE([not found], 1) + AC_MSG_FAILURE([failed], 1) fi +# This is a remnant of the old cc -E validation, where it may have been +# necessary to use a different preprocessor for .dfn files +DFNCPP="$CPP" +AC_SUBST(DFNCPP) + # -Werror cannot be passed to GCC in CFLAGS because configure will fail (it # checks the compiler with a program that generates a warning), add the # following option to deal with this @@ -115,7 +109,6 @@ AC_ARG_ENABLE(werror, # Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS([malloc.h stdlib.h string.h strings.h]) # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST @@ -239,15 +232,29 @@ AM_CONDITIONAL([DO_PNG_PREFIX], [test "${with_libpng_prefix:-no}" != "no"]) AC_SUBST([AM_CCASFLAGS], [-Wa,--noexecstack]) AC_ARG_ENABLE([arm-neon], - AS_HELP_STRING([[[--enable-arm-neon]]], [Enable ARM NEON optimizations]), - [if test "${enableval}" = "yes"; then - AC_DEFINE([PNG_FILTER_OPTIMIZATIONS], - [png_init_filter_functions_neon], - [ARM NEON filter initialization function]) - AC_DEFINE([PNG_ALIGNED_MEMORY_SUPPORTED], [1], - [Align row buffers]) - fi]) -AM_CONDITIONAL([PNG_ARM_NEON], [test "${enable_arm_neon:-no}" = yes]) + AS_HELP_STRING([[[--enable-arm-neon]]], + [Enable ARM NEON optimizations: =off, check, api, on:] + [off: disable the optimizations; check: use internal checking code] + [(deprecated and poorly supported); api: disable by default, enable by] + [a call to png_set_option; on: turn on unconditionally. The] + [default is 'on' if __ARM_NEON__ is defined, otherwise 'off'.]), + [case "$enableval" in + off) + AC_DEFINE([PNG_NO_ARM_NEON], [], + [Disable ARM Neon optimizations]);; + check) + AC_DEFINE([PNG_ARM_NEON_CHECK_SUPPORTED], [], + [Check for ARM Neon support at run-time]);; + api) + AC_DEFINE([PNG_ARM_NEON_API_SUPPORTED], [], + [Turn on ARM Neon optimizations at run-time]);; + on) + AC_DEFINE([PNG_ARM_NEON_SUPPORTED], [], + [Enable ARM Neon optimizations]);; + *) + AC_MSG_ERROR([arm-neon: option value required (off/check/api/on)]);; + esac]) +AM_CONDITIONAL([PNG_ARM_NEON], [test "${enable_arm_neon:-no}" != "no"]) AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]]) diff --git a/contrib/examples/pngpixel.c b/contrib/examples/pngpixel.c index d82ef83d0..410476031 100644 --- a/contrib/examples/pngpixel.c +++ b/contrib/examples/pngpixel.c @@ -37,7 +37,7 @@ component(png_const_bytep row, png_uint_32 x, unsigned int c, * bytes wide. Since the row fitted into memory, however, the following must * work: */ - png_uint_32 bit_offset_hi = bit_depth * ((x >> 6) * channels + c); + png_uint_32 bit_offset_hi = bit_depth * ((x >> 6) * channels); png_uint_32 bit_offset_lo = bit_depth * ((x & 0x3f) * channels + c); row = (png_const_bytep)(((PNG_CONST png_byte (*)[8])row) + bit_offset_hi); diff --git a/contrib/gregbook/readpng.c b/contrib/gregbook/readpng.c index 0b75fac6d..f5e1fb1a4 100644 --- a/contrib/gregbook/readpng.c +++ b/contrib/gregbook/readpng.c @@ -215,6 +215,10 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes) * libpng function */ if (setjmp(png_jmpbuf(png_ptr))) { + free(image_data); + image_data = NULL; + free(row_pointers); + row_pointers = NULL; png_destroy_read_struct(&png_ptr, &info_ptr, NULL); return NULL; } diff --git a/contrib/libtests/makepng.c b/contrib/libtests/makepng.c index 7f85db923..9f11b2964 100644 --- a/contrib/libtests/makepng.c +++ b/contrib/libtests/makepng.c @@ -2,7 +2,7 @@ * * Copyright (c) 2013 John Cunningham Bowler * - * Last changed in libpng 1.6.0 [February 14, 2013] + * Last changed in libpng 1.6.1 [March 28, 2013] * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer @@ -83,7 +83,7 @@ #include #include -#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H) +#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H) # include #endif @@ -440,7 +440,7 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type, /* Palette with fixed color: the image rows are all 0 and the image width * is 16. */ - memset(row, rowbytes, 0); + memset(row, 0, rowbytes); } else if (colors[0] == channels_of_type(color_type)) @@ -624,8 +624,8 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth, gamma_table[0] = 0; - for (i=0; i<255; ++i) - gamma_table[i] = (png_byte)floor(pow(i/255.,conv) * 255 + 127.5); + for (i=1; i<255; ++i) + gamma_table[i] = (png_byte)floor(pow(i/255.,conv) * 255 + .5); gamma_table[255] = 255; } diff --git a/contrib/libtests/pngstest.c b/contrib/libtests/pngstest.c index c2a2b2b0d..35e7c8779 100644 --- a/contrib/libtests/pngstest.c +++ b/contrib/libtests/pngstest.c @@ -3,7 +3,7 @@ * * Copyright (c) 2013 John Cunningham Bowler * - * Last changed in libpng 1.6.0 [February 14, 2013] + * Last changed in libpng 1.6.1 [March 28, 2013] * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer @@ -22,7 +22,7 @@ #include #include -#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H) +#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H) # include #endif @@ -62,6 +62,12 @@ # define aligncastconst(type, value) ((const void*)(value)) #endif /* __cplusplus */ +/* During parallel runs of pngstest each temporary file needs a unique name, + * this is used to permit uniqueness using a command line argument which can be + * up to 22 characters long. + */ +static char tmpf[23] = "TMP"; + /* Generate random bytes. This uses a boring repeatable algorithm and it * is implemented here so that it gives the same set of numbers on every * architecture. It's a linear congruential generator (Knuth or Sedgewick @@ -309,6 +315,7 @@ compare_16bit(int v1, int v2, int error_limit, int multiple_algorithms) #define KEEP_GOING 32 #define ACCUMULATE 64 #define FAST_WRITE 128 +#define sRGB_16BIT 256 static void print_opts(png_uint_32 opts) @@ -329,6 +336,8 @@ print_opts(png_uint_32 opts) printf(" --accumulate"); if (!(opts & FAST_WRITE)) /* --fast is currently the default */ printf(" --slow"); + if (opts & sRGB_16BIT) + printf(" --sRGB-16bit"); } #define FORMAT_NO_CHANGE 0x80000000 /* additional flag */ @@ -3020,6 +3029,10 @@ read_file(Image *image, png_uint_32 format, png_const_colorp background) return logerror(image, "file init: ", image->file_name, ""); } + /* This must be set after the begin_read call: */ + if (image->opts & sRGB_16BIT) + image->image.flags |= PNG_IMAGE_FLAG_16BIT_sRGB; + /* Have an initialized image with all the data we need plus, maybe, an * allocated file (myfile) or buffer (mybuffer) that need to be freed. */ @@ -3198,7 +3211,7 @@ write_one_file(Image *output, Image *image, int convert_to_8bit) static int counter = 0; char name[32]; - sprintf(name, "TMP%d.png", ++counter); + sprintf(name, "%s%d.png", tmpf, ++counter); if (png_image_write_to_file(&image->image, name, convert_to_8bit, image->buffer+16, (png_int_32)image->stride, image->colormap)) @@ -3482,6 +3495,34 @@ main(int argc, char **argv) opts &= ~KEEP_GOING; else if (strcmp(arg, "--strict") == 0) opts |= STRICT; + else if (strcmp(arg, "--sRGB-16bit") == 0) + opts |= sRGB_16BIT; + else if (strcmp(arg, "--linear-16bit") == 0) + opts &= ~sRGB_16BIT; + else if (strcmp(arg, "--tmpfile") == 0) + { + if (c+1 < argc) + { + if (strlen(argv[++c]) >= sizeof tmpf) + { + fflush(stdout); + fprintf(stderr, "%s: %s is too long for a temp file prefix\n", + argv[0], argv[c]); + exit(99); + } + + /* Safe: checked above */ + strcpy(tmpf, argv[c]); + } + + else + { + fflush(stdout); + fprintf(stderr, "%s: %s requires a temporary file prefix\n", + argv[0], arg); + exit(99); + } + } else if (strcmp(arg, "--touch") == 0) { if (c+1 < argc) @@ -3492,7 +3533,7 @@ main(int argc, char **argv) fflush(stdout); fprintf(stderr, "%s: %s requires a file name argument\n", argv[0], arg); - exit(1); + exit(99); } } else if (arg[0] == '+') @@ -3500,7 +3541,7 @@ main(int argc, char **argv) png_uint_32 format = formatof(arg+1); if (format > FORMAT_COUNT) - exit(1); + exit(99); format_set(&formats, format); } @@ -3508,7 +3549,7 @@ main(int argc, char **argv) { fflush(stdout); fprintf(stderr, "%s: unknown option: %s\n", argv[0], arg); - exit(1); + exit(99); } else { @@ -3557,7 +3598,7 @@ main(int argc, char **argv) buffer[4095] = 0; fprintf(stderr, "%s...%s: file name too long\n", buffer, buffer+(4096-32)); - exit(1); + exit(99); } } @@ -3676,7 +3717,7 @@ main(int argc, char **argv) { fflush(stdout); fprintf(stderr, "%s: write failed\n", touch); - exit(1); + exit(99); } } @@ -3684,7 +3725,7 @@ main(int argc, char **argv) { fflush(stdout); fprintf(stderr, "%s: open failed\n", touch); - exit(1); + exit(99); } } @@ -3695,6 +3736,7 @@ main(int argc, char **argv) int main(void) { fprintf(stderr, "pngstest: no read support in libpng, test skipped\n"); - return 0; + /* So the test is skipped: */ + return 77; } #endif /* PNG_SIMPLIFIED_READ_SUPPORTED */ diff --git a/contrib/libtests/pngunknown.c b/contrib/libtests/pngunknown.c index 9d9acc0f7..9b8de34b4 100644 --- a/contrib/libtests/pngunknown.c +++ b/contrib/libtests/pngunknown.c @@ -1,7 +1,7 @@ /* pngunknown.c - test the read side unknown chunk handling * - * Last changed in libpng 1.6.0 [(PENDING RELEASE)] + * Last changed in libpng 1.6.0 [February 14, 2013] * Copyright (c) 2013 Glenn Randers-Pehrson * Written by John Cunningham Bowler * diff --git a/contrib/libtests/pngvalid.c b/contrib/libtests/pngvalid.c index fae8e6f78..f36b1f8be 100644 --- a/contrib/libtests/pngvalid.c +++ b/contrib/libtests/pngvalid.c @@ -1,7 +1,7 @@ /* pngvalid.c - validate libpng by constructing then reading png files. * - * Last changed in libpng 1.6.0 [February 14, 2013] + * Last changed in libpng 1.6.1 [March 28, 2013] * Copyright (c) 2013 Glenn Randers-Pehrson * Written by John Cunningham Bowler * @@ -26,7 +26,7 @@ #include #include -#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H) +#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H) # include #endif @@ -1999,8 +1999,8 @@ static double digitize(PNG_CONST png_modifier *pm, double value, } #endif -#if (defined PNG_READ_GAMMA_SUPPORTED) ||\ - (defined PNG_READ_RGB_TO_GRAY_SUPPORTED) +#if defined(PNG_READ_GAMMA_SUPPORTED) ||\ + defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) static double abserr(PNG_CONST png_modifier *pm, int in_depth, int out_depth) { /* Absolute error permitted in linear values - affected by the bit depth of @@ -3357,7 +3357,7 @@ make_transform_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); #ifdef PNG_TEXT_SUPPORTED -# if (defined PNG_READ_zTXt_SUPPORTED) && (defined PNG_WRITE_zTXt_SUPPORTED) +# if defined(PNG_READ_zTXt_SUPPORTED) && defined(PNG_WRITE_zTXt_SUPPORTED) # define TEXT_COMPRESSION PNG_TEXT_COMPRESSION_zTXt # else # define TEXT_COMPRESSION PNG_TEXT_COMPRESSION_NONE @@ -8895,8 +8895,8 @@ static void perform_gamma_scale16_tests(png_modifier *pm) } #endif /* 16 to 8 bit conversion */ -#if defined PNG_READ_BACKGROUND_SUPPORTED ||\ - defined PNG_READ_ALPHA_MODE_SUPPORTED +#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) static void gamma_composition_test(png_modifier *pm, PNG_CONST png_byte colour_type, PNG_CONST png_byte bit_depth, PNG_CONST int palette_number, diff --git a/contrib/libtests/readpng.c b/contrib/libtests/readpng.c index 631325766..7ba46d0b9 100644 --- a/contrib/libtests/readpng.c +++ b/contrib/libtests/readpng.c @@ -2,7 +2,7 @@ * * Copyright (c) 2013 John Cunningham Bowler * - * Last changed in libpng 1.6.0 [(PENDING RELEASE)] + * Last changed in libpng 1.6.1 [March 28, 2013] * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer @@ -18,7 +18,7 @@ #include #include -#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H) +#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H) # include #endif diff --git a/contrib/libtests/test-pngstest.sh b/contrib/libtests/test-pngstest.sh deleted file mode 100755 index e977a5b50..000000000 --- a/contrib/libtests/test-pngstest.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# -# Run the simplified API tests -err=0 - -echo >> pngtest-log.txt -echo "============ pngstest.sh ==============" >> pngtest-log.txt - -echo "Running test-pngstest.sh" -for image in ${srcdir}/contrib/pngsuite/*.png -do - for opts in "" - do - if ./pngstest --strict --log "$@" $opts $image >>pngtest-log.txt 2>&1 - then - echo " PASS: pngstest $opts $image" - else - echo " FAIL: pngstest $opts $image" - err=1 - fi - done -done - -exit $err diff --git a/contrib/libtests/test-pngunknown.sh b/contrib/libtests/test-pngunknown.sh deleted file mode 100755 index 1a31864ae..000000000 --- a/contrib/libtests/test-pngunknown.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# -# Run the unknown API tests -err=0 -image="${srcdir}/pngtest.png" -# -# stream 4 is used for the output of the shell, pngtest-log.txt gets all the -# normal program output. -exec 4>&1 1>>pngtest-log.txt 2>&1 - -echo -echo "============ test-pngunknown.sh ==============" - -echo "Running test-pngunknown.sh" >&4 - -for tests in \ - "discard default=discard"\ - "save default=save"\ - "if-safe default=if-safe"\ - "vpAg vpAg=if-safe"\ - "sTER sTER=if-safe"\ - "IDAT default=discard IDAT=save"\ - "sAPI bKGD=save cHRM=save gAMA=save all=discard iCCP=save sBIT=save sRGB=save" -do - set $tests - test="$1" - shift - - if ./pngunknown "$@" "$image" 4>&- - then - echo " PASS: test-pngunknown $test" >&4 - else - echo " FAIL: test-pngunknown $test" >&4 - err=1 - fi -done - -exit $err diff --git a/contrib/libtests/test-pngvalid-full.sh b/contrib/libtests/test-pngvalid-full.sh deleted file mode 100755 index f7d1b2b5d..000000000 --- a/contrib/libtests/test-pngvalid-full.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# -# Run a sequence of gamma tests quietly -err=0 - -echo >> pngtest-log.txt -echo "============ pngvalid-full.sh ==============" >> pngtest-log.txt - -echo "Running test-pngvalid-full.sh" -for gamma in threshold transform sbit 16-to-8 background alpha-mode "transform --expand16" "background --expand16" "alpha-mode --expand16" -do - if ./pngvalid "$@" --gamma-$gamma >> pngtest-log.txt 2>&1 - then - echo " PASS: pngvalid" "$@" "--gamma-$gamma" - else - echo " FAIL: pngvalid" "$@" "--gamma-$gamma" - err=1 - fi -done - -exit $err diff --git a/contrib/libtests/test-pngvalid-simple.sh b/contrib/libtests/test-pngvalid-simple.sh deleted file mode 100755 index 7d4d9d83c..000000000 --- a/contrib/libtests/test-pngvalid-simple.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -# -# Run a sequence of tests quietly, without the slow -# gamma tests -err=0 - -echo >> pngtest-log.txt -echo "============ pngvalid-simple.sh ==============" >> pngtest-log.txt -echo "Running test-pngvalid-simple.sh" -# The options to test are: -# -# standard tests with and without progressive reading and interlace -# size images with and without progressive reading -# transform tests (standard, non-interlaced only) -# -for opts in "--standard" "--standard --progressive-read" \ - "--standard --interlace" "--standard --progressive-read --interlace" \ - "--size" "--size --progressive-read" \ - "--transform" -do - if ./pngvalid "$@" $opts >> pngtest-log.txt 2>&1 - then - echo " PASS: pngvalid" "$@" $opts - else - echo " FAIL: pngvalid" "$@" $opts - err=1 - fi -done - -exit $err diff --git a/contrib/libtests/timepng.c b/contrib/libtests/timepng.c index 1222708f8..523627f38 100644 --- a/contrib/libtests/timepng.c +++ b/contrib/libtests/timepng.c @@ -2,7 +2,7 @@ * * Copyright (c) 2013 John Cunningham Bowler * - * Last changed in libpng 1.6.0 [February 14, 2013] + * Last changed in libpng 1.6.1 [March 28, 2013] * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer @@ -22,7 +22,7 @@ #include -#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H) +#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H) # include #endif diff --git a/contrib/tools/cvtcolor.c b/contrib/tools/cvtcolor.c index 285325467..e6793c7d5 100644 --- a/contrib/tools/cvtcolor.c +++ b/contrib/tools/cvtcolor.c @@ -3,7 +3,7 @@ * * Last changed in libpng 1.6.0 [February 14, 2013] * - * COPYRIGHT: Written by John Cunningham Bowler, 2012. + * COPYRIGHT: Written by John Cunningham Bowler, 2013. * To the extent possible under law, the author has waived all copyright and * related or neighboring rights to this work. This work is published from: * United States. diff --git a/contrib/tools/intgamma.sh b/contrib/tools/intgamma.sh index e3219473f..41c5d6dd2 100644 --- a/contrib/tools/intgamma.sh +++ b/contrib/tools/intgamma.sh @@ -4,7 +4,7 @@ # # Last changed in libpng 1.6.0 [February 14, 2013] # -# COPYRIGHT: Written by John Cunningham Bowler, 2012. +# COPYRIGHT: Written by John Cunningham Bowler, 2013. # To the extent possible under law, the author has waived all copyright and # related or neighboring rights to this work. This work is published from: # United States. diff --git a/contrib/tools/makesRGB.c b/contrib/tools/makesRGB.c index de9191e1d..e66c9f157 100644 --- a/contrib/tools/makesRGB.c +++ b/contrib/tools/makesRGB.c @@ -2,7 +2,7 @@ * * Last changed in libpng 1.6.0 [February 14, 2013] * - * COPYRIGHT: Written by John Cunningham Bowler, 2012. + * COPYRIGHT: Written by John Cunningham Bowler, 2013. * To the extent possible under law, the author has waived all copyright and * related or neighboring rights to this work. This work is published from: * United States. diff --git a/contrib/tools/sRGB.h b/contrib/tools/sRGB.h index 833f2305f..22c8f7c0e 100644 --- a/contrib/tools/sRGB.h +++ b/contrib/tools/sRGB.h @@ -3,7 +3,7 @@ * * Last changed in libpng 1.6.0 [February 14, 2013] * - * COPYRIGHT: Written by John Cunningham Bowler, 2012. + * COPYRIGHT: Written by John Cunningham Bowler, 2013. * To the extent possible under law, the author has waived all copyright and * related or neighboring rights to this work. This work is published from: * United States. diff --git a/libpng-manual.txt b/libpng-manual.txt index 63fa15b43..4b91d865a 100644 --- a/libpng-manual.txt +++ b/libpng-manual.txt @@ -1,6 +1,6 @@ libpng-manual.txt - A description on how to use and modify libpng - libpng version 1.6.0 - February 14, 2013 + libpng version 1.6.1 - March 28, 2013 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2013 Glenn Randers-Pehrson @@ -11,7 +11,7 @@ libpng-manual.txt - A description on how to use and modify libpng Based on: - libpng versions 0.97, January 1998, through 1.6.0 - February 14, 2013 + libpng versions 0.97, January 1998, through 1.6.1 - March 28, 2013 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2013 Glenn Randers-Pehrson @@ -527,9 +527,14 @@ you can retrieve with png_get_user_chunk_ptr(png_ptr); If you call the png_set_read_user_chunk_fn() function, then all unknown -chunks will be saved when read, in case your callback function will need -one or more of them. This behavior can be changed with the -png_set_keep_unknown_chunks() function, described below. +chunks which the callback does not handle will be saved when read. You can +cause them to be discarded by returning '1' ("handled") instead of '0'. This +behavior will change in libpng 1.7 and the default handling set by the +png_set_keep_unknown_chunks() function, described below, will be used when the +callback returns 0. If you want the existing behavior you should set the global +default to PNG_HANDLE_CHUNK_IF_SAFE now; this is compatible with all current +versions of libpng and with 1.7. Libpng 1.6 issues a warning if you keep the +default, or PNG_HANDLE_CHUNK_NEVER, and the callback returns 0. At this point, you can set up a callback function that will be called after each row has been read, which you can use to control @@ -628,15 +633,17 @@ callback function: ... #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - /* ignore all unknown chunks: */ - png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0); + /* ignore all unknown chunks + * (use global setting "2" for libpng16 and earlier): + */ + png_set_keep_unknown_chunks(read_ptr, 2, NULL, 0); /* except for vpAg: */ png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1); /* also ignore unused known chunks: */ png_set_keep_unknown_chunks(read_ptr, 1, unused_chunks, - (int)sizeof(unused_chunks)/5); + (int)(sizeof unused_chunks)/5); #endif User limits @@ -988,7 +995,7 @@ where row_pointers is an array of pointers to the pixel data for each row: If you know your image size and pixel size ahead of time, you can allocate row_pointers prior to calling png_read_png() with - if (height > PNG_UINT_32_MAX/png_sizeof(png_byte)) + if (height > PNG_UINT_32_MAX/(sizeof (png_byte))) png_error (png_ptr, "Image is too tall to process in memory"); @@ -997,7 +1004,7 @@ row_pointers prior to calling png_read_png() with "Image is too wide to process in memory"); row_pointers = png_malloc(png_ptr, - height*png_sizeof(png_bytep)); + height*(sizeof (png_bytep))); for (int i=0; i\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.0 - February 14, 2013 + libpng version 1.6.1 - March 28, 2013 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2013 Glenn Randers-Pehrson @@ -515,7 +515,7 @@ libpng-manual.txt - A description on how to use and modify libpng Based on: - libpng versions 0.97, January 1998, through 1.6.0 - February 14, 2013 + libpng versions 0.97, January 1998, through 1.6.1 - March 28, 2013 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2013 Glenn Randers-Pehrson @@ -1031,9 +1031,14 @@ you can retrieve with png_get_user_chunk_ptr(png_ptr); If you call the png_set_read_user_chunk_fn() function, then all unknown -chunks will be saved when read, in case your callback function will need -one or more of them. This behavior can be changed with the -png_set_keep_unknown_chunks() function, described below. +chunks which the callback does not handle will be saved when read. You can +cause them to be discarded by returning '1' ("handled") instead of '0'. This +behavior will change in libpng 1.7 and the default handling set by the +png_set_keep_unknown_chunks() function, described below, will be used when the +callback returns 0. If you want the existing behavior you should set the global +default to PNG_HANDLE_CHUNK_IF_SAFE now; this is compatible with all current +versions of libpng and with 1.7. Libpng 1.6 issues a warning if you keep the +default, or PNG_HANDLE_CHUNK_NEVER, and the callback returns 0. At this point, you can set up a callback function that will be called after each row has been read, which you can use to control @@ -1132,15 +1137,17 @@ callback function: ... #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - /* ignore all unknown chunks: */ - png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0); + /* ignore all unknown chunks + * (use global setting "2" for libpng16 and earlier): + */ + png_set_keep_unknown_chunks(read_ptr, 2, NULL, 0); /* except for vpAg: */ png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1); /* also ignore unused known chunks: */ png_set_keep_unknown_chunks(read_ptr, 1, unused_chunks, - (int)sizeof(unused_chunks)/5); + (int)(sizeof unused_chunks)/5); #endif .SS User limits @@ -1492,7 +1499,7 @@ where row_pointers is an array of pointers to the pixel data for each row: If you know your image size and pixel size ahead of time, you can allocate row_pointers prior to calling png_read_png() with - if (height > PNG_UINT_32_MAX/png_sizeof(png_byte)) + if (height > PNG_UINT_32_MAX/(sizeof (png_byte))) png_error (png_ptr, "Image is too tall to process in memory"); @@ -1501,7 +1508,7 @@ row_pointers prior to calling png_read_png() with "Image is too wide to process in memory"); row_pointers = png_malloc(png_ptr, - height*png_sizeof(png_bytep)); + height*(sizeof (png_bytep))); for (int i=0; igreen_X, xy->greenx, PNG_FP_1, green_inverse)) return 1; - if (!png_muldiv(&XYZ->green_Y, xy->greeny, PNG_FP_1, green_inverse)) return 1; + if (!png_muldiv(&XYZ->green_X, xy->greenx, PNG_FP_1, green_inverse)) + return 1; + if (!png_muldiv(&XYZ->green_Y, xy->greeny, PNG_FP_1, green_inverse)) + return 1; if (!png_muldiv(&XYZ->green_Z, PNG_FP_1 - xy->greenx - xy->greeny, PNG_FP_1, green_inverse)) return 1; @@ -1647,7 +1649,7 @@ png_colorspace_set_endpoints(png_const_structrp png_ptr, return 0; /* failed */ } -#if defined PNG_sRGB_SUPPORTED || defined PNG_iCCP_SUPPORTED +#if defined(PNG_sRGB_SUPPORTED) || defined(PNG_iCCP_SUPPORTED) /* Error message generation */ static char png_icc_tag_char(png_uint_32 byte) @@ -2127,7 +2129,7 @@ static const struct PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 0, 1/*broken*/, "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 perceptual") - PNG_ICC_CHECKSUM(0x0398f3fcUL, 0xf29e526dUL, + PNG_ICC_CHECKSUM(0x0398f3fc, 0xf29e526d, PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 1/*broken*/, "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 media-relative") }; @@ -2177,7 +2179,7 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr, if (length == png_sRGB_checks[i].length && intent == png_sRGB_checks[i].intent) { - /* Now calculate the alder32 if not done already. */ + /* Now calculate the adler32 if not done already. */ if (adler == 0) { adler = adler32(0, NULL, 0); @@ -3090,7 +3092,7 @@ png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text) #endif #if defined(PNG_READ_GAMMA_SUPPORTED) || \ - defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG__READ_pHYs_SUPPORTED) + defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED) /* muldiv functions */ /* This API takes signed arguments and rounds the result to the nearest * integer (or, for a fixed point number - the standard argument - to @@ -4010,9 +4012,30 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth) } #endif /* READ_GAMMA */ +/* HARDWARE OPTION SUPPORT */ +#ifdef PNG_SET_OPTION_SUPPORTED +int PNGAPI +png_set_option(png_structrp png_ptr, int option, int onoff) +{ + if (png_ptr != NULL && option >= 0 && option < PNG_OPTION_NEXT && + (option & 1) == 0) + { + int mask = 3 << option; + int setting = (2 + (onoff != 0)) << option; + int current = png_ptr->options; + + png_ptr->options = (png_byte)((current & ~mask) | setting); + + return (current & mask) >> option; + } + + return PNG_OPTION_INVALID; +} +#endif + /* sRGB support */ -#if defined PNG_SIMPLIFIED_READ_SUPPORTED ||\ - defined PNG_SIMPLIFIED_WRITE_SUPPORTED +#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ + defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) /* sRGB conversion tables; these are machine generated with the code in * contrib/tools/makesRGB.c. The actual sRGB transfer curve defined in the * specification (see the article at http://en.wikipedia.org/wiki/SRGB) @@ -4180,8 +4203,8 @@ const png_byte png_sRGB_delta[512] = #endif /* SIMPLIFIED READ/WRITE sRGB support */ /* SIMPLIFIED READ/WRITE SUPPORT */ -#if defined PNG_SIMPLIFIED_READ_SUPPORTED ||\ - defined PNG_SIMPLIFIED_WRITE_SUPPORTED +#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ + defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) static int png_image_free_function(png_voidp argument) { diff --git a/png.h b/png.h index 448fe88cd..0ad09eb6b 100644 --- a/png.h +++ b/png.h @@ -1,7 +1,7 @@ /* png.h - header file for PNG reference library * - * libpng version 1.6.0 - February 14, 2013 + * libpng version 1.6.1 - March 28, 2013 * Copyright (c) 1998-2013 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.0 - February 14, 2013: Glenn + * libpng versions 0.97, January 1998, through 1.6.1 - March 28, 2013: Glenn * See also "Contributing Authors", below. * * Note about libpng version numbers: @@ -169,6 +169,9 @@ * 1.6.0beta01-40 16 10600 16.so.16.0[.0] * 1.6.0rc01-08 16 10600 16.so.16.0[.0] * 1.6.0 16 10600 16.so.16.0[.0] + * 1.6.1beta01-10 16 10601 16.so.16.1[.0] + * 1.6.1rc01 16 10601 16.so.16.1[.0] + * 1.6.1 16 10601 16.so.16.1[.0] * * Henceforth the source version will match the shared-library major * and minor numbers; the shared-library major version number will be @@ -200,7 +203,7 @@ * * This code is released under the libpng license. * - * libpng versions 1.2.6, August 15, 2004, through 1.6.0, February 14, 2013, are + * libpng versions 1.2.6, August 15, 2004, through 1.6.1, March 28, 2013, are * Copyright (c) 2004, 2006-2013 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: @@ -312,13 +315,13 @@ * Y2K compliance in libpng: * ========================= * - * February 14, 2013 + * March 28, 2013 * * 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.0 are Y2K compliant. It is my belief that + * upward through 1.6.1 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 @@ -378,9 +381,9 @@ */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.6.0" +#define PNG_LIBPNG_VER_STRING "1.6.1" #define PNG_HEADER_VERSION_STRING \ - " libpng version 1.6.0 - February 14, 2013\n" + " libpng version 1.6.1 - March 28, 2013\n" #define PNG_LIBPNG_VER_SONUM 16 #define PNG_LIBPNG_VER_DLLNUM 16 @@ -388,7 +391,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 0 +#define PNG_LIBPNG_VER_RELEASE 1 /* This should match the numeric part of the final component of * PNG_LIBPNG_VER_STRING, omitting any leading zero: @@ -419,7 +422,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 10600 /* 1.6.0 */ +#define PNG_LIBPNG_VER 10601 /* 1.6.1 */ /* Library configuration: these options cannot be changed after * the library has been built. @@ -524,7 +527,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_0; +typedef char* png_libpng_version_1_6_1; /* Basic control structions. Read libpng-manual.txt or libpng.3 for more info. * @@ -1837,7 +1840,7 @@ PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp)); #endif #ifdef PNG_READ_USER_CHUNKS_SUPPORTED -/* This callback is called only for *unknown* chunks, if +/* This callback is called only for *unknown* chunks. If * PNG_HANDLE_AS_UNKNOWN_SUPPORTED is set then it is possible to set known * chunks to be treated as unknown, however in this case the callback must do * any processing required by the chunk (e.g. by calling the appropriate @@ -1849,12 +1852,12 @@ PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp)); * The integer return from the callback function is interpreted thus: * * negative: An error occured, png_chunk_error will be called. - * zero: The chunk was not handled, the chunk will be discarded unless - * png_set_keep_unknown_chunks has been used to set a 'keep' behavior - * for this particular chunk, in which case that will be used. A - * critical chunk will cause an error at this point unless it is to be - * saved. + * zero: The chunk was not handled, the chunk will be saved. A critical + * chunk will cause an error at this point unless it is to be saved. * positive: The chunk was handled, libpng will ignore/discard it. + * + * See "INTERACTION WTIH USER CHUNK CALLBACKS" below for important notes about + * how this behavior will change in libpng 1.7 */ PNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structrp png_ptr, png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); @@ -2331,8 +2334,8 @@ PNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr, #ifdef PNG_sCAL_SUPPORTED PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, double *width, double *height)) -#if (defined PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ - (defined PNG_FLOATING_POINT_SUPPORTED) +#if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ + defined(PNG_FLOATING_POINT_SUPPORTED) /* NOTE: this API is currently implemented using floating point arithmetic, * consequently it can only be used on systems with floating point support. * In any case the range of values supported by png_fixed_point is small and it @@ -2372,7 +2375,7 @@ PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr, * READ: * PNG_HANDLE_CHUNK_AS_DEFAULT: * Known chunks: do normal libpng processing, do not keep the chunk (but - * set the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED) + * see the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED) * Unknown chunks: for a specific chunk use the global default, when used * as the default discard the chunk data. * PNG_HANDLE_CHUNK_NEVER: @@ -2388,12 +2391,21 @@ PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr, * to specifying "NEVER", however when "AS_DEFAULT" is used for specific chunks * it simply resets the behavior to the libpng default. * + * INTERACTION WTIH USER CHUNK CALLBACKS: * The per-chunk handling is always used when there is a png_user_chunk_ptr * callback and the callback returns 0; the chunk is then always stored *unless* * it is critical and the per-chunk setting is other than ALWAYS. Notice that * the global default is *not* used in this case. (In effect the per-chunk * value is incremented to at least IF_SAFE.) * + * IMPORTANT NOTE: this behavior will change in libpng 1.7 - the global and + * per-chunk defaults will be honored. If you want to preserve the current + * behavior when your callback returns 0 you must set PNG_HANDLE_CHUNK_IF_SAFE + * as the default - if you don't do this libpng 1.6 will issue a warning. + * + * If you want unhandled unknown chunks to be discarded in libpng 1.6 and + * earlier simply return '1' (handled). + * * PNG_HANDLE_AS_UNKNOWN_SUPPORTED: * If this is *not* set known chunks will always be handled by libpng and * will never be stored in the unknown chunk list. Known chunks listed to @@ -3088,6 +3100,24 @@ typedef struct * slight speed gain. */ +#define PNG_IMAGE_FLAG_16BIT_sRGB 0x04 + /* On read if the image is a 16-bit per component image and there is no gAMA + * or sRGB chunk assume that the components are sRGB encoded. Notice that + * images output by the simplified API always have gamma information; setting + * this flag only affects the interpretation of 16-bit images from an + * external source. It is recommended that the application expose this flag + * to the user; the user can normally easily recognize the difference between + * linear and sRGB encoding. This flag has no effect on write - the data + * passed to the write APIs must have the correct encoding (as defined + * above.) + * + * If the flag is not set (the default) input 16-bit per component data is + * assumed to be linear. + * + * NOTE: the flag can only be set after the png_image_begin_read_ call, + * because that call initializes the 'flags' field. + */ + #ifdef PNG_SIMPLIFIED_READ_SUPPORTED /* READ APIs * --------- @@ -3138,7 +3168,7 @@ PNG_EXPORT(237, int, png_image_finish_read, (png_imagep image, * PNG_FORMAT_FLAG_LINEAR *not* set. * * For linear output removing the alpha channel is always done by compositing - * on black and background is ignored.: + * on black and background is ignored. * * colormap must be supplied when PNG_FORMAT_FLAG_COLORMAP is set. It must * be at least the size (in bytes) returned by PNG_IMAGE_COLORMAP_SIZE. @@ -3209,6 +3239,47 @@ PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr, # endif #endif /* CHECK_FOR_INVALID_INDEX */ +/******************************************************************************* + * IMPLEMENTATION OPTIONS + ******************************************************************************* + * + * Support for arbitrary implementation-specific optimizations. The API allows + * particular options to be turned on or off. 'Option' is the number of the + * option and 'onoff' is 0 (off) or non-0 (on). The value returned is given + * by the PNG_OPTION_ defines below. + * + * HARDWARE: normally hardware capabilites, such as the Intel SSE instructions, + * are detected at run time, however sometimes it may be impossible + * to do this in user mode, in which case it is necessary to discover + * the capabilities in an OS specific way. Such capabilities are + * listed here when libpng has support for them and must be turned + * ON by the application if present. + * + * SOFTWARE: sometimes software optimizations actually result in performance + * decrease on some architectures or systems, or with some sets of + * PNG images. 'Software' options allow such optimizations to be + * selected at run time. + */ +#ifdef PNG_SET_OPTION_SUPPORTED +#ifdef PNG_ARM_NEON_API_SUPPORTED +# define PNG_ARM_NEON 0 /* HARDWARE: ARM Neon SIMD instructions supported */ +#endif +#define PNG_OPTION_NEXT 2 /* 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 */ +#define PNG_OPTION_INVALID 1 /* Option number out of range */ +#define PNG_OPTION_OFF 2 +#define PNG_OPTION_ON 3 + +PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option, + int onoff)); +#endif + +/******************************************************************************* + * END OF HARDWARE OPTIONS + ******************************************************************************/ + /* Maintainer: Put new public prototypes here ^, in libpng.3, and project * defs, scripts/pnglibconf.h, and scripts/pnglibconf.h.prebuilt */ @@ -3218,7 +3289,7 @@ PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr, * scripts/symbols.def as well. */ #ifdef PNG_EXPORT_LAST_ORDINAL - PNG_EXPORT_LAST_ORDINAL(243); + PNG_EXPORT_LAST_ORDINAL(244); #endif #ifdef __cplusplus diff --git a/pngconf.h b/pngconf.h index cbfd517dd..d9dbff085 100644 --- a/pngconf.h +++ b/pngconf.h @@ -1,7 +1,7 @@ /* pngconf.h - machine configurable file for libpng * - * libpng version 1.6.0 - February 14, 2013 + * libpng version 1.6.1 - March 28, 2013 * * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -218,7 +218,7 @@ # define PNGCAPI __watcall # endif -# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) +# if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800)) # define PNGCAPI __cdecl # if PNG_API_RULE == 1 /* If this line results in an error __stdcall is not understood and diff --git a/pngerror.c b/pngerror.c index 18152d96c..f469206ee 100644 --- a/pngerror.c +++ b/pngerror.c @@ -1,7 +1,7 @@ /* pngerror.c - stub functions for i/o and memory allocation * - * Last changed in libpng 1.6.0 [February 14, 2013] + * Last changed in libpng 1.6.1 [March 28, 2013] * Copyright (c) 1998-2013 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.) @@ -516,7 +516,7 @@ png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error) /* This is always supported, but for just read or just write it * unconditionally does the right thing. */ -# if (defined PNG_READ_SUPPORTED) && (defined PNG_WRITE_SUPPORTED) +# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED) if (png_ptr->mode & PNG_IS_READ_STRUCT) # endif @@ -530,7 +530,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) +# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED) else if (!(png_ptr->mode & PNG_IS_READ_STRUCT)) # endif @@ -844,8 +844,8 @@ png_set_strip_error_numbers(png_structrp png_ptr, png_uint_32 strip_mode) } #endif -#if defined PNG_SIMPLIFIED_READ_SUPPORTED ||\ - defined PNG_SIMPLIFIED_WRITE_SUPPORTED +#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ + defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) /* Currently the above both depend on SETJMP_SUPPORTED, however it would be * possible to implement without setjmp support just so long as there is some * way to handle the error return here: diff --git a/pngget.c b/pngget.c index 03c8c1046..aca63a958 100644 --- a/pngget.c +++ b/pngget.c @@ -1,7 +1,7 @@ /* pngget.c - retrieval of values from info struct * - * Last changed in libpng 1.6.0 [February 14, 2013] + * Last changed in libpng 1.6.1 [March 28, 2013] * Copyright (c) 1998-2013 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.) @@ -552,14 +552,14 @@ png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr, *green_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z"); if (blue_X != NULL) - *blue_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.blue_X, - "cHRM blue X"); + *blue_X = png_float(png_ptr, + info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X"); if (blue_Y != NULL) - *blue_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.blue_Y, - "cHRM blue Y"); + *blue_Y = png_float(png_ptr, + info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y"); if (blue_Z != NULL) - *blue_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.blue_Z, - "cHRM blue Z"); + *blue_Z = png_float(png_ptr, + info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z"); return (PNG_INFO_cHRM); } @@ -844,8 +844,8 @@ png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, #ifdef PNG_sCAL_SUPPORTED # ifdef PNG_FIXED_POINT_SUPPORTED -# if (defined PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ - (defined PNG_FLOATING_POINT_SUPPORTED) +# if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ + defined(PNG_FLOATING_POINT_SUPPORTED) png_uint_32 PNGAPI png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, png_fixed_point *width, png_fixed_point *height) diff --git a/pnginfo.h b/pnginfo.h index 90f11dabb..26bf26502 100644 --- a/pnginfo.h +++ b/pnginfo.h @@ -1,11 +1,11 @@ /* pnginfo.h - header file for PNG reference library * - * Copyright (c) 1998-2011 Glenn Randers-Pehrson + * Copyright (c) 1998-2013 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.) * - * Last changed in libpng 1.5.0 [January 6, 2011] + * Last changed in libpng 1.6.1 [March 28, 2013] * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer @@ -88,7 +88,7 @@ struct png_info_def * and initialize the appropriate fields below. */ -#if defined PNG_COLORSPACE_SUPPORTED || defined PNG_GAMMA_SUPPORTED +#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED) /* png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are * defined. When COLORSPACE is switched on all the colorspace-defining * chunks should be enabled, when GAMMA is switched on all the gamma-defining diff --git a/pngpriv.h b/pngpriv.h index 22f1919b0..35e7eddd3 100644 --- a/pngpriv.h +++ b/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.0 [February 14, 2013] + * Last changed in libpng 1.6.1 [March 28, 2013] * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer @@ -39,9 +39,11 @@ */ #define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */ +#ifndef PNG_VERSION_INFO_ONLY /* Standard library headers not required by png.h: */ -#include -#include +# include +# include +#endif #define PNGLIB_BUILD /*libpng is being built, not used*/ @@ -54,7 +56,7 @@ * configure generated config.h. Libpng is expected to compile without *any* * special build system support on a reasonably ANSI-C compliant system. */ -#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H) +#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H) # include /* Pick up the definition of 'restrict' from config.h if it was read: */ @@ -71,7 +73,7 @@ #endif /* Local renames may change non-exported API functions from png.h */ -#if defined PNG_PREFIX && !defined PNGPREFIX_H +#if defined(PNG_PREFIX) && !defined(PNGPREFIX_H) # include "pngprefix.h" #endif @@ -177,10 +179,12 @@ # ifndef PNG_FLOATING_POINT_SUPPORTED # define PNG_FP_EXPORT(ordinal, type, name, args)\ PNG_INTERNAL_FUNCTION(type, name, args, PNG_EMPTY); - typedef struct png_incomplete png_double; - typedef png_double* png_doublep; - typedef const png_double* png_const_doublep; - typedef png_double** png_doublepp; +# ifndef PNG_VERSION_INFO_ONLY + typedef struct png_incomplete png_double; + typedef png_double* png_doublep; + typedef const png_double* png_const_doublep; + typedef png_double** png_doublepp; +# endif # endif #endif #ifndef PNG_FIXED_EXPORT @@ -191,8 +195,6 @@ #endif #include "png.h" -#include "pngstruct.h" -#include "pnginfo.h" /* pngconf.h does not set PNG_DLL_EXPORT unless it is required, so: */ #ifndef PNG_DLL_EXPORT @@ -238,11 +240,6 @@ # endif #endif -/* This is used for 16 bit gamma tables -- only the top level pointers are - * const; this could be changed: - */ -typedef const png_uint_16p * png_const_uint_16pp; - /* Moved to pngpriv.h at libpng-1.5.0 */ /* NOTE: some of these may have been used in external applications as * these definitions were exposed in pngconf.h prior to 1.5. @@ -331,6 +328,7 @@ typedef const png_uint_16p * png_const_uint_16pp; # define PNGFAPI /* PRIVATE */ #endif +#ifndef PNG_VERSION_INFO_ONLY /* Other defines specific to compilers can go here. Try to keep * them inside an appropriate ifdef/endif pair for portability. */ @@ -375,6 +373,7 @@ typedef const png_uint_16p * png_const_uint_16pp; defined(_WIN32) || defined(__WIN32__) # include /* defines _WINDOWS_ macro */ #endif +#endif /* PNG_VERSION_INFO_ONLY */ /* Moved here around 1.5.0beta36 from pngconf.h */ /* Users may want to use these so they are not private. Any library @@ -553,26 +552,6 @@ typedef const png_uint_16p * png_const_uint_16pp; abs((int)((c1).green) - (int)((c2).green)) + \ abs((int)((c1).blue) - (int)((c2).blue))) -/* Added to libpng-1.5.7: sRGB conversion tables */ -#if defined PNG_SIMPLIFIED_READ_SUPPORTED ||\ - defined PNG_SIMPLIFIED_WRITE_SUPPORTED -#ifdef PNG_SIMPLIFIED_READ_SUPPORTED -PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_table, [256]); - /* Convert from an sRGB encoded value 0..255 to a 16-bit linear value, - * 0..65535. This table gives the closest 16-bit answers (no errors). - */ -#endif - -PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_base, [512]); -PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]); - -#define PNG_sRGB_FROM_LINEAR(linear) ((png_byte)((png_sRGB_base[(linear)>>15] +\ - ((((linear)&0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8)) - /* 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 */ - /* Added to libpng-1.6.0: scale a 16-bit value in the range 0..65535 to 0..255 * by dividing by 257 *with rounding*. This macro is exact for the given range. * See the discourse in pngrtran.c png_do_scale_16_to_8. The values in the @@ -707,6 +686,39 @@ PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]); #define PNG_GAMMA_MAC_INVERSE 65909 #define PNG_GAMMA_sRGB_INVERSE 45455 +/* Almost everything below is C specific; the #defines above can be used in + * non-C code (so long as it is C-preprocessed) the rest of this stuff cannot. + */ +#ifndef PNG_VERSION_INFO_ONLY + +#include "pngstruct.h" +#include "pnginfo.h" + +/* This is used for 16 bit gamma tables -- only the top level pointers are + * const; this could be changed: + */ +typedef const png_uint_16p * png_const_uint_16pp; + +/* Added to libpng-1.5.7: sRGB conversion tables */ +#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ + defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) +#ifdef PNG_SIMPLIFIED_READ_SUPPORTED +PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_table, [256]); + /* Convert from an sRGB encoded value 0..255 to a 16-bit linear value, + * 0..65535. This table gives the closest 16-bit answers (no errors). + */ +#endif + +PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_base, [512]); +PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]); + +#define PNG_sRGB_FROM_LINEAR(linear) ((png_byte)((png_sRGB_base[(linear)>>15] +\ + ((((linear)&0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8)) + /* 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 */ + /* Inhibit C++ name-mangling for libpng functions but not for system calls. */ #ifdef __cplusplus @@ -757,8 +769,8 @@ PNG_INTERNAL_FUNCTION(int,png_user_version_check,(png_structrp png_ptr, PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED); -#if defined PNG_TEXT_SUPPORTED || defined PNG_sPLT_SUPPORTED ||\ - defined PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED +#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\ + defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) /* Internal array allocator, outputs no error or warning messages on failure, * just returns NULL. */ @@ -1824,8 +1836,8 @@ PNG_INTERNAL_FUNCTION(void,png_build_gamma_table,(png_structrp png_ptr, #endif /* SIMPLIFIED READ/WRITE SUPPORT */ -#if defined PNG_SIMPLIFIED_READ_SUPPORTED ||\ - defined PNG_SIMPLIFIED_WRITE_SUPPORTED +#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ + defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) /* The internal structure that png_image::opaque points to. */ typedef struct png_control { @@ -1880,7 +1892,8 @@ PNG_INTERNAL_FUNCTION(void, png_image_free, (png_imagep image), PNG_EMPTY); #endif /* SIMPLIFIED READ/WRITE */ #ifdef PNG_FILTER_OPTIMIZATIONS -PNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr, unsigned int bpp), PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr, + unsigned int bpp), PNG_EMPTY); /* This is the initialization function for hardware specific optimizations, * one implementation (for ARM NEON machines) is contained in * arm/filter_neon.c. It need not be defined - the generic code will be used @@ -1896,4 +1909,5 @@ PNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr, unsi } #endif +#endif /* PNG_VERSION_INFO_ONLY */ #endif /* PNGPRIV_H */ diff --git a/pngread.c b/pngread.c index 5cd20e8c3..e32f31d54 100644 --- a/pngread.c +++ b/pngread.c @@ -1,7 +1,7 @@ /* pngread.c - read a PNG file * - * Last changed in libpng 1.6.0 [February 14, 2013] + * Last changed in libpng 1.6.1 [March 28, 2013] * Copyright (c) 1998-2013 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.) @@ -15,7 +15,7 @@ */ #include "pngpriv.h" -#if defined PNG_SIMPLIFIED_READ_SUPPORTED && defined PNG_STDIO_SUPPORTED +#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) && defined(PNG_STDIO_SUPPORTED) # include #endif @@ -877,8 +877,8 @@ png_read_destroy(png_structrp png_ptr) png_free(png_ptr, png_ptr->save_buffer); #endif -#if (defined PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) &&\ - (defined PNG_READ_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); #endif @@ -2004,6 +2004,28 @@ png_image_read_colormap(png_voidp argument) else back_b = back_r = back_g = 255; + /* Default the input file gamma if required - this is necessary because + * libpng assumes that if no gamma information is present the data is in the + * output format, but the simplified API deduces the gamma from the input + * format. + */ + if ((png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) == 0) + { + /* Do this directly, not using the png_colorspace functions, to ensure + * that it happens even if the colorspace is invalid (though probably if + * it is the setting will be ignored) Note that the same thing can be + * achieved at the application interface with png_set_gAMA. + */ + if (png_ptr->bit_depth == 16 && + (image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0) + png_ptr->colorspace.gamma = PNG_GAMMA_LINEAR; + + else + png_ptr->colorspace.gamma = PNG_GAMMA_sRGB_INVERSE; + + png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA; + } + /* Decide what to do based on the PNG color type of the input data. The * utility function png_create_colormap_entry deals with most aspects of the * output transformations; this code works out how to produce bytes of @@ -3547,7 +3569,8 @@ png_image_read_direct(png_voidp argument) { png_fixed_point input_gamma_default; - if (base_format & PNG_FORMAT_FLAG_LINEAR) + if ((base_format & PNG_FORMAT_FLAG_LINEAR) && + (image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0) input_gamma_default = PNG_GAMMA_LINEAR; else input_gamma_default = PNG_DEFAULT_sRGB; diff --git a/pngrtran.c b/pngrtran.c index a485cacc4..626f3b0ec 100644 --- a/pngrtran.c +++ b/pngrtran.c @@ -1,7 +1,7 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * Last changed in libpng 1.6.0 [February 14, 2013] + * Last changed in libpng 1.6.1 [March 28, 2013] * Copyright (c) 1998-2013 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.) @@ -1412,7 +1412,7 @@ png_init_read_transformations(png_structrp png_ptr) #endif #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED -#if defined PNG_READ_EXPAND_SUPPORTED && defined PNG_READ_BACKGROUND_SUPPORTED +#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) /* Detect gray background and attempt to enable optimization for * gray --> RGB case. * @@ -2239,8 +2239,8 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) 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 defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) if (png_ptr->transformations & PNG_COMPOSE) png_do_compose(row_info, png_ptr->row_buf + 1, png_ptr); #endif @@ -2251,8 +2251,8 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) /* Because RGB_TO_GRAY does the gamma transform. */ !(png_ptr->transformations & PNG_RGB_TO_GRAY) && #endif -#if (defined PNG_READ_BACKGROUND_SUPPORTED) ||\ - (defined PNG_READ_ALPHA_MODE_SUPPORTED) +#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) /* Because PNG_COMPOSE does the gamma transform if there is something to * do (if there is an alpha channel or transparency.) */ @@ -3518,8 +3518,8 @@ png_build_grayscale_palette(int bit_depth, png_colorp palette) #ifdef PNG_READ_TRANSFORMS_SUPPORTED -#if (defined PNG_READ_BACKGROUND_SUPPORTED) ||\ - (defined PNG_READ_ALPHA_MODE_SUPPORTED) +#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) /* Replace any alpha or transparency with the supplied background color. * "background" is already in the screen gamma, while "background_1" is * at a gamma of 1.0. Paletted files have already been taken care of. diff --git a/pngrutil.c b/pngrutil.c index e66075786..3f4474c9b 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -1,8 +1,8 @@ /* pngrutil.c - utilities to read a PNG file * - * Last changed in libpng 1.6.0 [(PENDING RELEASE)] - * Copyright (c) 1998-2012 Glenn Randers-Pehrson + * Last changed in libpng 1.6.1 [March 28, 2013] + * Copyright (c) 1998-2013 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.) * @@ -2804,21 +2804,26 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, { /* If the keep value is 'default' or 'never' override it, but * still error out on critical chunks unless the keep value is - * 'always' While this is weird it is the behavior in 1.4.12. A - * possible improvement would be to obey the value set for the + * 'always' While this is weird it is the behavior in 1.4.12. + * A possible improvement would be to obey the value set for the * chunk, but this would be an API change that would probably * damage some applications. * * The png_app_warning below catches the case that matters, where - * the application has neither set specific save for this chunk - * or global save. + * the application has not set specific save or ignore for this + * chunk or global save or ignore. */ if (keep < PNG_HANDLE_CHUNK_IF_SAFE) { # ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED if (png_ptr->unknown_default < PNG_HANDLE_CHUNK_IF_SAFE) + { + png_chunk_warning(png_ptr, "Saving unknown chunk:"); png_app_warning(png_ptr, - "forcing save of an unhandled chunk; please call png_set_keep_unknown_chunks"); + "forcing save of an unhandled chunk;" + " please call png_set_keep_unknown_chunks"); + /* with keep = PNG_HANDLE_CHUNK_IF_SAFE */ + } # endif keep = PNG_HANDLE_CHUNK_IF_SAFE; } @@ -3350,7 +3355,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) png_uint_32p dp32 = png_aligncast(png_uint_32p,dp); png_const_uint_32p sp32 = png_aligncastconst( png_const_uint_32p, sp); - unsigned int skip = (bytes_to_jump-bytes_to_copy) / + size_t skip = (bytes_to_jump-bytes_to_copy) / (sizeof (png_uint_32)); do @@ -3392,7 +3397,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) png_uint_16p dp16 = png_aligncast(png_uint_16p, dp); png_const_uint_16p sp16 = png_aligncastconst( png_const_uint_16p, sp); - unsigned int skip = (bytes_to_jump-bytes_to_copy) / + size_t skip = (bytes_to_jump-bytes_to_copy) / (sizeof (png_uint_16)); do diff --git a/pngset.c b/pngset.c index 84973f5ff..c88d62153 100644 --- a/pngset.c +++ b/pngset.c @@ -1,7 +1,7 @@ /* pngset.c - storage of image information into info struct * - * Last changed in libpng 1.6.0 [February 14, 2013] + * Last changed in libpng 1.6.1 [March 28, 2013] * Copyright (c) 1998-2013 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.) @@ -514,7 +514,7 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_debug1(1, "in %s storage function", "PLTE"); - if (png_ptr == NULL || info_ptr == NULL || palette == NULL) + if (png_ptr == NULL || info_ptr == NULL) return; if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH) @@ -529,6 +529,17 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr, } } + if ((num_palette > 0 && palette == NULL) || + (num_palette == 0 +# ifdef PNG_MNG_FEATURES_SUPPORTED + && (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0 +# endif + )) + { + png_chunk_report(png_ptr, "Invalid palette", PNG_CHUNK_ERROR); + return; + } + /* It may not actually be necessary to set png_ptr->palette here; * we do it for backward compatibility with the way the png_handle_tRNS * function used to do the allocation. @@ -545,7 +556,8 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_ptr->palette = png_voidcast(png_colorp, png_calloc(png_ptr, PNG_MAX_PALETTE_LENGTH * (sizeof (png_color)))); - memcpy(png_ptr->palette, palette, num_palette * (sizeof (png_color))); + if (num_palette > 0) + memcpy(png_ptr->palette, palette, num_palette * (sizeof (png_color))); info_ptr->palette = png_ptr->palette; info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; @@ -1116,16 +1128,16 @@ png_set_unknown_chunks(png_const_structrp png_ptr, * code) but may be meaningless if the read or write handling of unknown * chunks is not compiled in. */ -# if !(defined PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) && \ - (defined PNG_READ_SUPPORTED) +# if !defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) && \ + defined(PNG_READ_SUPPORTED) if (png_ptr->mode & PNG_IS_READ_STRUCT) { png_app_error(png_ptr, "no unknown chunk support on read"); return; } # endif -# if !(defined PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) && \ - (defined PNG_WRITE_SUPPORTED) +# if !defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) && \ + defined(PNG_WRITE_SUPPORTED) if (!(png_ptr->mode & PNG_IS_READ_STRUCT)) { png_app_error(png_ptr, "no unknown chunk support on write"); diff --git a/pngstruct.h b/pngstruct.h index b8202d13a..d58c02884 100644 --- a/pngstruct.h +++ b/pngstruct.h @@ -5,7 +5,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.0 [February 14, 2013] + * Last changed in libpng 1.6.1 [March 28, 2013] * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer @@ -100,7 +100,7 @@ typedef struct png_XYZ } png_XYZ; #endif /* COLORSPACE */ -#if defined PNG_COLORSPACE_SUPPORTED || defined PNG_GAMMA_SUPPORTED +#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED) /* A colorspace is all the above plus, potentially, profile information, * however at present libpng does not use the profile internally so it is only * stored in the png_info struct (if iCCP is supported.) The rendering intent @@ -357,6 +357,11 @@ struct png_struct_def png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */ #endif + /* Options */ +#ifdef PNG_SET_OPTION_SUPPORTED + png_byte options; /* On/off state (up to 4 options) */ +#endif + #if PNG_LIBPNG_VER < 10700 /* To do: remove this from libpng-1.7 */ #ifdef PNG_TIME_RFC1123_SUPPORTED @@ -471,11 +476,12 @@ struct png_struct_def /* New member added in libpng-1.5.6 */ png_bytep big_prev_row; +/* New member added in libpng-1.5.7 */ void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info, png_bytep row, png_const_bytep prev_row); #ifdef PNG_READ_SUPPORTED -#if defined PNG_COLORSPACE_SUPPORTED || defined PNG_GAMMA_SUPPORTED +#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED) png_colorspace colorspace; #endif #endif diff --git a/pngtest.c b/pngtest.c index 4787a246d..fd0e8174d 100644 --- a/pngtest.c +++ b/pngtest.c @@ -1,7 +1,7 @@ /* pngtest.c - a simple test program to test libpng * - * Last changed in libpng 1.6.0 [February 14, 2013] + * Last changed in libpng 1.6.1 [March 28, 2013] * Copyright (c) 1998-2013 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.) @@ -1470,7 +1470,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) /* When the unknown vpAg/sTER chunks are written by pngtest the only way to * do it is to write them *before* calling png_write_end. When unknown - * chunks are written by libpng, however, they are written just before IEND. * There seems to be no way round this, however vpAg/sTER are not expected + * chunks are written by libpng, however, they are written just before IEND. + * There seems to be no way round this, however vpAg/sTER are not expected * after IDAT. */ write_chunks(write_ptr, after_IDAT); @@ -1949,4 +1950,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_0 Your_png_h_is_not_version_1_6_0; +typedef png_libpng_version_1_6_1 Your_png_h_is_not_version_1_6_1; diff --git a/pngwrite.c b/pngwrite.c index aa18712fb..b0887bd75 100644 --- a/pngwrite.c +++ b/pngwrite.c @@ -1,7 +1,7 @@ /* pngwrite.c - general routines to write a PNG file * - * Last changed in libpng 1.6.0 [February 14, 2013] + * Last changed in libpng 1.6.1 [March 28, 2013] * Copyright (c) 1998-2013 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.) @@ -12,7 +12,7 @@ */ #include "pngpriv.h" -#if defined PNG_SIMPLIFIED_WRITE_SUPPORTED && defined PNG_STDIO_SUPPORTED +#if defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) && defined(PNG_STDIO_SUPPORTED) # include #endif diff --git a/projects/vstudio/readme.txt b/projects/vstudio/readme.txt index 556a85ab2..bc16eb12f 100644 --- a/projects/vstudio/readme.txt +++ b/projects/vstudio/readme.txt @@ -1,7 +1,7 @@ VisualStudio instructions -libpng version 1.6.0 - February 14, 2013 +libpng version 1.6.1 - March 28, 2013 Copyright (c) 1998-2010 Glenn Randers-Pehrson diff --git a/projects/vstudio/zlib.props b/projects/vstudio/zlib.props index c88e7ba17..8e92fdc8b 100644 --- a/projects/vstudio/zlib.props +++ b/projects/vstudio/zlib.props @@ -2,7 +2,7 @@