From bc92887b2d4852ea0631ad5daa78b32c406b7743 Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Sun, 12 May 2013 12:01:18 -0500 Subject: [PATCH] [libpng15] Imported from libpng-1.5.16beta06.tar --- ANNOUNCE | 79 +++--- CHANGES | 93 ++++++- CMakeLists.txt | 50 ++-- INSTALL | 11 +- LICENSE | 4 +- Makefile.am | 2 +- Makefile.in | 3 +- README | 2 +- arm/arm_init.c | 52 ++-- arm/filter_neon.S | 12 +- config.h.in | 15 +- configure | 84 ++++--- configure.ac | 66 +++-- contrib/gregbook/readpng.c | 4 + contrib/libtests/pngvalid.c | 12 +- contrib/pngminim/decoder/makefile | 9 +- contrib/pngminim/encoder/makefile | 9 +- contrib/pngminim/encoder/pngusr.dfa | 5 +- contrib/pngminim/preader/makefile | 9 +- contrib/pngminus/pnm2png.c | 154 ++++++++---- libpng-manual.txt | 71 ++++-- libpng.3 | 88 +++++-- libpngpf.3 | 4 +- png.5 | 2 +- png.c | 29 ++- png.h | 68 +++++- pngconf.h | 2 +- pngget.c | 2 +- pngpriv.h | 2 +- pngrtran.c | 4 +- pngrutil.c | 8 +- pngset.c | 2 +- pngstruct.h | 7 +- pngtest.c | 19 +- pngwrite.c | 2 +- projects/vstudio/readme.txt | 2 +- projects/vstudio/zlib.props | 2 +- scripts/README.txt | 12 +- scripts/checksym.awk | 20 +- scripts/dfn.awk | 180 +++++++++----- scripts/libpng-config-head.in | 2 +- scripts/libpng.pc.in | 2 +- scripts/makefile.cegcc | 2 +- scripts/makefile.freebsd | 13 +- scripts/makefile.linux | 2 +- scripts/makefile.msys | 2 +- scripts/makefile.ne12bsd | 2 +- scripts/makefile.netbsd | 2 +- scripts/makefile.openbsd | 2 +- scripts/options.awk | 362 +++++++++++++++++----------- scripts/pnglibconf.dfa | 31 ++- scripts/pnglibconf.h.prebuilt | 325 +++++++++++++------------ scripts/symbols.def | 3 +- scripts/symbols.dfn | 3 +- 54 files changed, 1264 insertions(+), 690 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index ed58821ac..875c382cd 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,5 +1,5 @@ -Libpng 1.5.15beta06 - February 22, 2013 +Libpng 1.5.16beta06 - May 12, 2013 This is not intended to be a public release. It will be replaced within a few weeks by a public version or by another test version. @@ -9,58 +9,59 @@ Files available for download: Source files with LF line endings (for Unix/Linux) and with a "configure" script - 1.5.15beta06.tar.xz (LZMA-compressed, recommended) - 1.5.15beta06.tar.gz - 1.5.15beta06.tar.bz2 + 1.5.16beta06.tar.xz (LZMA-compressed, recommended) + 1.5.16beta06.tar.gz + 1.5.16beta06.tar.bz2 Source files with CRLF line endings (for Windows), without the "configure" script - lp1515b06.7z (LZMA-compressed, recommended) - lp1515b06.zip + lp1516b06.7z (LZMA-compressed, recommended) + lp1516b06.zip Other information: - 1.5.15beta06-README.txt - 1.5.15beta06-LICENSE.txt + 1.5.16beta06-README.txt + 1.5.16beta06-LICENSE.txt -Changes since the last public release (1.5.14): +Changes since the last public release (1.5.15): -Version 1.5.15beta01 [February 4, 2013] - Enabled renaming of the extern (but not DLL exported) ARM filter functions. - Also enabled inclusion of pngpriv.h in non-C files by preventing C/C++ - specific definitions if PNG_VERSION_INFO_ONLY is defined. - Added png_get_palette_max() function. +Version 1.5.16beta01 [April 25, 2013] + Corrected a misplaced closing bracket in contrib/libtests/pngvalid.c + (Flavio Medeiros). + Revised stack marking in arm/filter_neon.S and configure.ac + Ensure that NEON filter stuff is completely disabled when switched 'off'. + Previously the ARM NEON specific files were still built if the option + was switched 'off' as opposed to being explicitly disabled. + Avoid a compiler warning about unused png_ptr in translate_gamma_flags() -Version 1.5.15beta02 [February 5, 2013] - Made a probably general fix for the preprocessing used to generate source - files. This change might make the check for a special C preprocessor - unnecessary, and it also eliminates the requirement for sed in the - configure build process. - Fix typo in Makefile.am, fix scripts/pnglibconf.mak and makefile.std - Rebuilt Makefile.in, configure, etc., with autoconf-2.69 and automake-1.13 - Fix 'setting' handling in options.awk and fixed palette_max API +Version 1.5.16beta02 [April 26, 2013] + Revise pngtest.c to skip tests of unsupported features. + Regenerated configure files. -Version 1.5.15beta03 [February 7, 2013] - Remove SUN OS cc -E workround - no longer required - Turn serial tests back on (recently turned off by autotools upgrade). +Version 1.5.16beta03 [April 26, 2013] + Test for 'arm*' not just 'arm' in the host_cpu configure variable. -Version 1.5.15beta04 [February 15, 2013] - Enclosed the new png_get_palette_max in #ifdef PNG_GET_PALETTE_MAX_SUPPORTED - block, and revised pnglibconf.h and pnglibconf.h.prebuilt accordingly. +Version 1.5.16beta04 [May 1, 2013] + Expanded manual paragraph about writing private chunks, particularly + the need to call png_set_keep_unknown_chunks() when writing them. -Version 1.5.15beta05 [February 17, 2013] - 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. - Fixed a race condition in the creation of the build 'scripts' directory - while building with a parallel make. - Use parentheses more consistently in "#if defined(MACRO)" tests. +Version 1.5.16beta05 [May 9, 2013] + Updated contrib/pngminus/pnm2png.c (Paul Stewart): + Check for EOF + Ignore "#" delimited comments in input file to pnm2png.c. + Fixed whitespace handling + Added a call to png_set_packing() + Initialize dimension values so if sscanf fails at least we have known + invalid values. -Version 1.5.15beta06 [February 22, 2013] - Fixed PNG_ALIGN(ED)_MEMORY and add ability to turn off ARM_NEON - runtime checks - Updated INSTALL. +Version 1.5.16beta06 [May 12, 2013] + Allow contrib/pnminus/pnm2png.c to compile without WRITE_INVERT and WRITE_PACK + supported (writes error message that it can't read P1 or P4 PBM files). + Revised contrib/pngminim/*/makefile to separate CPPFLAGS and CPFLAGS, and + to generate pnglibconf.h with the right zlib header files. + Ported contrib/pngminus/pnm2png.c changes back from libpng-1.6.3beta06, + to use unsigned long, not png_uint_32 arguments to sscanf(). Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CHANGES b/CHANGES index a8661378e..0d45ec59c 100644 --- a/CHANGES +++ b/CHANGES @@ -4018,13 +4018,94 @@ Version 1.5.15beta05 [February 17, 2013] Version 1.5.15beta06 [February 22, 2013] Fixed PNG_ALIGN(ED)_MEMORY and add ability to turn off ARM_NEON runtime checks - Updated INSTALL. + Updated the INSTALL document. - =========================================================================== - NOTICE November 17, 2012: - The location of the git repository at SourceForge has changed. - Visit http://libpng.sf.net/ for details. - =========================================================================== +Version 1.5.15beta07 [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.5.15beta08 [March 5, 2013] + Avoid a possible memory leak in contrib/gregbook/readpng.c + Made the _SUPPORTED macro definitions consistent. The change made in + libpng15 to #define *_SUPPORTED 1, to match the use of -D*_SUPPORTED + (which means -D*_SUPPORTED=1) and avoid compiler warnings from GCC was made + inconsistently and causes problems as a result, also some additions in + pnglibconf.h.prebuilt were inconsistent (omitting the 1). This changes 1.5 + back to the scheme used both before (1.4) and after (1.6). This might cause + some build scripts to issue warnings, and might, in the extreme, cause some + applications to fail (but they would fail anyway against 1.6). It seems + safer to go for consistency, given the change in 1.6, not correctness here, + particularly as 'make check' currently warns anyway on the symbols.dfn check + because of the inconsistencies. + 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.5.15beta09 [March 13, 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. + 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.5.15rc01 [March 21, 2013] + No changes. + +Version 1.5.15 [March 28, 2013] + No changes. + +Version 1.5.16beta01 [April 25, 2013] + Corrected a misplaced closing bracket in contrib/libtests/pngvalid.c + (Flavio Medeiros). + Revised stack marking in arm/filter_neon.S and configure.ac. + Ensure that NEON filter stuff is completely disabled when switched 'off'. + Previously the ARM NEON specific files were still built if the option + was switched 'off' as opposed to being explicitly disabled. + Avoid a compiler warning about unused png_ptr in translate_gamma_flags() + +Version 1.5.16beta02 [April 26, 2013] + Revise pngtest.c to skip tests of unsupported features. + Regenerated configure files. + +Version 1.5.16beta03 [April 26, 2013] + Test for 'arm*' not just 'arm' in the host_cpu configure variable. + +Version 1.5.16beta04 [May 1, 2013] + Expanded manual paragraph about writing private chunks, particularly + the need to call png_set_keep_unknown_chunks() when writing them. + +Version 1.5.16beta05 [May 9, 2013] + Updated contrib/pngminus/pnm2png.c (Paul Stewart): + Check for EOF + Ignore "#" delimited comments in input file to pnm2png.c. + Fixed whitespace handling + Added a call to png_set_packing() + Initialize dimension values so if sscanf fails at least we have known + invalid values. + +Version 1.5.16beta06 [May 12, 2013] + Allow contrib/pnminus/pnm2png.c to compile without WRITE_INVERT and WRITE_PACK + supported (writes error message that it can't read P1 or P4 PBM files). + Revised contrib/pngminim/*/makefile to separate CPPFLAGS and CPFLAGS, and + to generate pnglibconf.h with the right zlib header files. + Ported contrib/pngminus/pnm2png.c changes back from libpng-1.6.3beta06, + to use unsigned long, not png_uint_32 arguments to sscanf(). Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CMakeLists.txt b/CMakeLists.txt index 91d93004d..ae64bab52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ enable_testing() set(PNGLIB_MAJOR 1) set(PNGLIB_MINOR 5) -set(PNGLIB_RELEASE 15) +set(PNGLIB_RELEASE 16) set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR}) set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE}) @@ -138,8 +138,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") @@ -152,6 +155,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") @@ -159,6 +163,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() @@ -187,14 +197,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() @@ -225,7 +236,7 @@ endif(NOT WIN32 OR CYGWIN OR MINGW) # SET UP LINKS if(PNG_SHARED) set_target_properties(${PNG_LIB_NAME} PROPERTIES -# VERSION 15.${PNGLIB_RELEASE}.1.5.15beta06 +# VERSION 15.${PNGLIB_RELEASE}.1.5.16beta06 VERSION 15.${PNGLIB_RELEASE}.0 SOVERSION 15 CLEAN_DIRECT_OUTPUT 1) @@ -252,40 +263,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 => libpng15.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 972a4727e..f98737800 100644 --- a/INSTALL +++ b/INSTALL @@ -46,15 +46,14 @@ 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, INCLUDES, LDFLAGS, -LIBS, and LD_LIBRARY_PATH in your environment before running "make test" +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 -INCLUDES="-I$ZLIBINC" export INCLUDES +CPPFLAGS="-I$ZLIBINC" export CPPFLAGS LDFLAGS="-L$ZLIBLIB" export LDFLAGS -LIBS=$ZLIBLIB/libz.a export LIBS LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH If you are using one of the makefile scripts, put ZLIBLIB and ZLIBINC @@ -67,8 +66,8 @@ If you want to use "cmake" (see www.cmake.org), type make install 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: diff --git a/LICENSE b/LICENSE index ab824cae7..9c8aac252 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.5.15beta06, February 22, 2013, are +libpng versions 1.2.6, August 15, 2004, through 1.5.16beta06, May 12, 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 22, 2013 +May 12, 2013 diff --git a/Makefile.am b/Makefile.am index 9ea9707e1..c3fb718de 100644 --- a/Makefile.am +++ b/Makefile.am @@ -174,7 +174,7 @@ scripts/pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h rm -f $@ dfn?.out test -z "$(CPPFLAGS)" echo "com @PNGLIB_VERSION@ STANDARD API DEFINITION" |\ - $(AWK) -f ${srcdir}/scripts/options.awk out=dfn1.out logunsupported=1 + $(AWK) -f ${srcdir}/scripts/options.awk out=dfn1.out logunsupported=1\ version=search ${srcdir}/pngconf.h -\ ${srcdir}/scripts/pnglibconf.dfa 1>&2 $(AWK) -f ${srcdir}/scripts/options.awk out=dfn2.out dfn1.out 1>&2 diff --git a/Makefile.in b/Makefile.in index bc1c9549a..e5a9b8e7e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -288,7 +288,6 @@ distcleancheck_listfiles = find . -type f -print pkgincludedir = $(includedir)/$(PNGLIB_BASENAME) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ -AM_CCASFLAGS = @AM_CCASFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ @@ -1526,7 +1525,7 @@ scripts/pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h rm -f $@ dfn?.out test -z "$(CPPFLAGS)" echo "com @PNGLIB_VERSION@ STANDARD API DEFINITION" |\ - $(AWK) -f ${srcdir}/scripts/options.awk out=dfn1.out logunsupported=1 + $(AWK) -f ${srcdir}/scripts/options.awk out=dfn1.out logunsupported=1\ version=search ${srcdir}/pngconf.h -\ ${srcdir}/scripts/pnglibconf.dfa 1>&2 $(AWK) -f ${srcdir}/scripts/options.awk out=dfn2.out dfn1.out 1>&2 diff --git a/README b/README index 5d9a229e9..ba2e12a5b 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -README for libpng version 1.5.15beta06 - February 22, 2013 (shared library 15.0) +README for libpng version 1.5.16beta06 - May 12, 2013 (shared library 15.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 78750d6a4..c24b2a083 100644 --- a/arm/arm_init.c +++ b/arm/arm_init.c @@ -3,7 +3,7 @@ * * Copyright (c) 2013 Glenn Randers-Pehrson * Written by Mans Rullgard, 2011. - * Last changed in libpng 1.5.15 [%RDATE%] + * Last changed in libpng 1.5.16 [(PENDING RELEASE)] * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer @@ -16,16 +16,7 @@ #include "../pngpriv.h" -#if defined(PNG_FILTER_OPTIMIZATIONS) && defined(__arm__) && \ - defined(__ARM_NEON__) -/* __arm__ is defined by GCC, MSVC defines _M_ARM to the ARM version number, - * Andoid intends to define __ANDROID__, however there are bugs in their - * toolchain; use -D__ANDROID__ to work round this. - * - * __ARM_NEON__ is used to ensure that the compiler has the appropriate ARM - * NEON support - */ - +#ifdef PNG_ARM_NEON_SUPPORTED #ifdef PNG_ARM_NEON_CHECK_SUPPORTED /* Do run-time checks */ #include /* for sig_atomic_t */ @@ -45,7 +36,8 @@ png_have_neon(png_structp png_ptr) * implemented as below, therefore it is better to cache the result (these * function calls may be slow!) */ - return andoid_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && + PNG_UNUSED(png_ptr) + return android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0; } #elif defined(__linux__) @@ -161,15 +153,39 @@ png_have_neon(png_structp png_ptr) void png_init_filter_functions_neon(png_structp pp, unsigned int bpp) { +#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 */ + { + static volatile sig_atomic_t no_neon = -1; /* not checked */ - if (no_neon < 0) - no_neon = !png_have_neon(pp); + if (no_neon < 0) + no_neon = !png_have_neon(pp); - if (no_neon) - return; + 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 * PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the @@ -200,4 +216,4 @@ png_init_filter_functions_neon(png_structp pp, unsigned int bpp) png_read_filter_row_paeth4_neon; } } -#endif /* FILTER_OPTIMIZATIONS && __arm__ && __ARM_NEON__ */ +#endif /* PNG_ARM_NEON_SUPPORTED */ diff --git a/arm/filter_neon.S b/arm/filter_neon.S index 72420a9e3..827d1a390 100644 --- a/arm/filter_neon.S +++ b/arm/filter_neon.S @@ -1,9 +1,9 @@ /* filter_neon.S - NEON optimised filter functions * - * Copyright (c) 2011 Glenn Randers-Pehrson + * Copyright (c) 2013 Glenn Randers-Pehrson * Written by Mans Rullgard, 2011. - * Last changed in libpng 1.5.7 [December 15, 2011] + * Last changed in libpng 1.5.16 [(PENDING RELEASE)] * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer @@ -11,17 +11,17 @@ */ /* This is required to get the symbol renames, which are #defines, and also - * includes the value of PNG_FILTER_OPTIMIZATIONS. + * includes the definition (or not) of PNG_ARM_NEON_SUPPORTED. */ #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 +#ifdef PNG_ARM_NEON_SUPPORTED + #ifdef __ELF__ # define ELF #else @@ -232,4 +232,4 @@ func png_read_filter_row_paeth3_neon, export=1 pop {r4,pc} endfunc -#endif /* FILTER_OPTIMIZATIONS && __arm__ && __ARM_NEON__ */ +#endif /* PNG_ARM_NEON_SUPPORTED */ diff --git a/config.h.in b/config.h.in index 8905c19a8..cad335d49 100644 --- a/config.h.in +++ b/config.h.in @@ -73,14 +73,17 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION -/* Align row buffers */ -#undef PNG_ALIGNED_MEMORY_SUPPORTED +/* Turn on ARM Neon optimizations at run-time */ +#undef PNG_ARM_NEON_API_SUPPORTED -/* ARM NEON filter initialization function */ -#undef PNG_FILTER_OPTIMIZATIONS +/* Check for ARM Neon support at run-time */ +#undef PNG_ARM_NEON_CHECK_SUPPORTED -/* Turn off run-time checking for ARM NEON support */ -#undef PNG_NO_ARM_NEON_CHECK +/* Enable ARM Neon optimizations */ +#undef PNG_ARM_NEON_SUPPORTED + +/* Disable ARM Neon optimizations */ +#undef PNG_NO_ARM_NEON /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS diff --git a/configure b/configure index 3c7d78cb7..7bc89f501 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for libpng 1.5.15beta06. +# Generated by GNU Autoconf 2.69 for libpng 1.5.16beta06. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='libpng' PACKAGE_TARNAME='libpng' -PACKAGE_VERSION='1.5.15beta06' -PACKAGE_STRING='libpng 1.5.15beta06' +PACKAGE_VERSION='1.5.16beta06' +PACKAGE_STRING='libpng 1.5.16beta06' PACKAGE_BUGREPORT='png-mng-implement@lists.sourceforge.net' PACKAGE_URL='' @@ -637,7 +637,6 @@ am__EXEEXT_TRUE LTLIBOBJS PNG_ARM_NEON_FALSE PNG_ARM_NEON_TRUE -AM_CCASFLAGS binconfigs pkgconfigdir PNGLIB_RELEASE @@ -1343,7 +1342,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures libpng 1.5.15beta06 to adapt to many kinds of systems. +\`configure' configures libpng 1.5.16beta06 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1413,7 +1412,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libpng 1.5.15beta06:";; + short | recursive ) echo "Configuration of libpng 1.5.16beta06:";; esac cat <<\_ACEOF @@ -1435,8 +1434,12 @@ Optional Features: --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) - --enable-arm-neon Enable ARM NEON optimizations: use 'always' to turn - off run-time checks + --enable-arm-neon Enable ARM NEON optimizations: =no/off, check, api, + yes/on: no/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; yes/on: turn on + unconditionally. Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -1530,7 +1533,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libpng configure 1.5.15beta06 +libpng configure 1.5.16beta06 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1953,7 +1956,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libpng $as_me 1.5.15beta06, which was +It was created by libpng $as_me 1.5.16beta06, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2816,7 +2819,7 @@ fi # Define the identity of the package. PACKAGE='libpng' - VERSION='1.5.15beta06' + VERSION='1.5.16beta06' cat >>confdefs.h <<_ACEOF @@ -2886,10 +2889,10 @@ fi -PNGLIB_VERSION=1.5.15beta06 +PNGLIB_VERSION=1.5.16beta06 PNGLIB_MAJOR=1 PNGLIB_MINOR=5 -PNGLIB_RELEASE=15 +PNGLIB_RELEASE=16 @@ -12804,30 +12807,51 @@ fi -# Because GCC by default assembles code with an executable stack, even though it -# compiles C code with a non-executable stack, it is necessary to do a fixup -# here (this may by GCC specific) -AM_CCASFLAGS=-Wa,--noexecstack - +# HOST SPECIFIC OPTIONS +# ===================== +# +# ARM +# === +# +# ARM NEON (SIMD) support. # Check whether --enable-arm-neon was given. if test "${enable_arm_neon+set}" = set; then : - enableval=$enable_arm_neon; if test "${enableval}" = "yes" -o "${enableval}" = "always"; then + enableval=$enable_arm_neon; case "$enableval" in + no|off) + # disable the default enabling on __ARM_NEON__ systems: -$as_echo "#define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_neon" >>confdefs.h +$as_echo "#define PNG_NO_ARM_NEON /**/" >>confdefs.h + # Prevent inclusion of the assembler files below: + enable_arm_neon=no;; + check) -$as_echo "#define PNG_ALIGNED_MEMORY_SUPPORTED 1" >>confdefs.h +$as_echo "#define PNG_ARM_NEON_CHECK_SUPPORTED /**/" >>confdefs.h +;; + api) - if test "${enableval}" = "always"; then +$as_echo "#define PNG_ARM_NEON_API_SUPPORTED /**/" >>confdefs.h +;; + yes|on) -$as_echo "#define PNG_NO_ARM_NEON_CHECK /**/" >>confdefs.h - - fi - fi +$as_echo "#define PNG_ARM_NEON_SUPPORTED /**/" >>confdefs.h +;; + *) + as_fn_error $? "--enable-arm-neon=${enable_arm_neon}: invalid value" "$LINENO" 5 + esac fi - if test "${enable_arm_neon:-no}" != "no"; then + +# Add ARM specific files to all builds where the host_cpu is arm ('arm*') or +# where ARM optimizations were explicitly requested (this allows a fallback if a +# future host CPU does not match 'arm*') + + if test "$enable_arm_neon" != 'no' && + case "$host_cpu" in + arm*) :;; + *) test "$enable_arm_neon" != '';; + esac; then PNG_ARM_NEON_TRUE= PNG_ARM_NEON_FALSE='#' else @@ -12836,7 +12860,7 @@ else fi - { $as_echo "$as_me:${as_lineno-$LINENO}: Extra options for compiler: $PNG_COPTS" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: Extra options for compiler: $PNG_COPTS" >&5 $as_echo "$as_me: Extra options for compiler: $PNG_COPTS" >&6;} # Config files, substituting as above @@ -13395,7 +13419,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by libpng $as_me 1.5.15beta06, which was +This file was extended by libpng $as_me 1.5.16beta06, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -13461,7 +13485,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -libpng config.status 1.5.15beta06 +libpng config.status 1.5.16beta06 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index f2d864506..b104750d8 100644 --- a/configure.ac +++ b/configure.ac @@ -18,15 +18,15 @@ AC_PREREQ(2.59) dnl Version number stuff here: -AC_INIT([libpng], [1.5.15beta06], [png-mng-implement@lists.sourceforge.net]) +AC_INIT([libpng], [1.5.16beta06], [png-mng-implement@lists.sourceforge.net]) AM_INIT_AUTOMAKE([serial-tests]) dnl stop configure from automagically running automake AM_MAINTAINER_MODE -PNGLIB_VERSION=1.5.15beta06 +PNGLIB_VERSION=1.5.16beta06 PNGLIB_MAJOR=1 PNGLIB_MINOR=5 -PNGLIB_RELEASE=15 +PNGLIB_RELEASE=16 dnl End of version number stuff @@ -166,28 +166,52 @@ AC_ARG_WITH(binconfigs, [binconfigs='${binconfigs}']) AC_SUBST([binconfigs]) -# Because GCC by default assembles code with an executable stack, even though it -# compiles C code with a non-executable stack, it is necessary to do a fixup -# here (this may by GCC specific) -AC_SUBST([AM_CCASFLAGS], [-Wa,--noexecstack]) +# HOST SPECIFIC OPTIONS +# ===================== +# +# ARM +# === +# +# ARM NEON (SIMD) support. AC_ARG_ENABLE([arm-neon], AS_HELP_STRING([[[--enable-arm-neon]]], - [Enable ARM NEON optimizations: use 'always' to turn off run-time checks]), - [if test "${enableval}" = "yes" -o "${enableval}" = "always"; 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]) - if test "${enableval}" = "always"; then - AC_DEFINE([PNG_NO_ARM_NEON_CHECK], [], - [Turn off run-time checking for ARM NEON support]) - fi - fi]) -AM_CONDITIONAL([PNG_ARM_NEON], [test "${enable_arm_neon:-no}" != "no"]) + [Enable ARM NEON optimizations: =no/off, check, api, yes/on:] + [no/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; yes/on: turn on unconditionally.]), + [case "$enableval" in + no|off) + # disable the default enabling on __ARM_NEON__ systems: + AC_DEFINE([PNG_NO_ARM_NEON], [], + [Disable ARM Neon optimizations]) + # Prevent inclusion of the assembler files below: + enable_arm_neon=no;; + 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]);; + yes|on) + AC_DEFINE([PNG_ARM_NEON_SUPPORTED], [], + [Enable ARM Neon optimizations]);; + *) + AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}: invalid value]) + esac]) + +# Add ARM specific files to all builds where the host_cpu is arm ('arm*') or +# where ARM optimizations were explicitly requested (this allows a fallback if a +# future host CPU does not match 'arm*') + +AM_CONDITIONAL([PNG_ARM_NEON], + [test "$enable_arm_neon" != 'no' && + case "$host_cpu" in + arm*) :;; + *) test "$enable_arm_neon" != '';; + esac]) - AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]]) +AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]]) # Config files, substituting as above AC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in]) 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/pngvalid.c b/contrib/libtests/pngvalid.c index c436d23e3..71545a3ff 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.5.14 [%RDATE%] + * Last changed in libpng 1.5.15 [March 28, 2013] * Copyright (c) 2013 Glenn Randers-Pehrson * Written by John Cunningham Bowler * @@ -4599,9 +4599,13 @@ progressive_row(png_structp ppIn, png_bytep new_row, png_uint_32 y, int pass) } else png_progressive_combine_row(pp, row, new_row); - } else if (dp->interlace_type == PNG_INTERLACE_ADAM7 && - PNG_ROW_IN_INTERLACE_PASS(y, pass) && - PNG_PASS_COLS(dp->w, pass) > 0) +#endif /* PNG_READ_INTERLACING_SUPPORTED */ + } + +#ifdef PNG_READ_INTERLACING_SUPPORTED + else if (dp->interlace_type == PNG_INTERLACE_ADAM7 && + PNG_ROW_IN_INTERLACE_PASS(y, pass) && + PNG_PASS_COLS(dp->w, pass) > 0) png_error(pp, "missing row in progressive de-interlacing"); #endif /* PNG_READ_INTERLACING_SUPPORTED */ } diff --git a/contrib/pngminim/decoder/makefile b/contrib/pngminim/decoder/makefile index dafba64b7..25e2ee0c9 100644 --- a/contrib/pngminim/decoder/makefile +++ b/contrib/pngminim/decoder/makefile @@ -14,7 +14,8 @@ LD=$(CC) RM=rm -f COPY=cp -CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP -I. -O1 +CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP +CFLAGS=-O1 C=.c O=.o @@ -81,7 +82,7 @@ OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS) # note: dependencies do not work on implicit rule lines .c$(O): - $(CC) -c $(CFLAGS) $< + $(CC) $(CPPFLAGS) -c $(CFLAGS) $< # dependencies @@ -95,12 +96,12 @@ pngm2pnm$(E): $(OBJS) # The CPP_FLAGS setting causes pngusr.h to be included in # both the build of pnglibconf.h and, subsequently, when # building libpng itself. -$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\ +$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\ $(PNGSRC)/scripts/pnglibconf.dfa \ $(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa $(RM) pnglibconf.h pnglibconf.dfn $(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\ - srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\ + srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\ DFA_XTRA="pngusr.dfa" $@ clean: diff --git a/contrib/pngminim/encoder/makefile b/contrib/pngminim/encoder/makefile index 810b8c8fa..e2ccbbc28 100644 --- a/contrib/pngminim/encoder/makefile +++ b/contrib/pngminim/encoder/makefile @@ -14,7 +14,8 @@ LD=$(CC) RM=rm -f COPY=cp -CFLAGS=-DPNG_USER_CONFIG -DZ_SOLO -DNO_GZIP -I. -O1 +CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP +CFLAGS=-O1 C=.c O=.o @@ -80,7 +81,7 @@ OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS) # implicit make rules ------------------------------------------------------- .c$(O): - $(CC) -c $(CFLAGS) $< + $(CC) $(CPPFLAGS) -c $(CFLAGS) $< # dependencies @@ -94,12 +95,12 @@ pnm2pngm$(E): $(OBJS) # The CPP_FLAGS setting causes pngusr.h to be included in # both the build of pnglibconf.h and, subsequently, when # building libpng itself. -$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\ +$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\ $(PNGSRC)/scripts/pnglibconf.dfa \ $(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa $(RM) pnglibconf.h pnglibconf.dfn $(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\ - srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\ + srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\ DFA_XTRA="pngusr.dfa" $@ clean: diff --git a/contrib/pngminim/encoder/pngusr.dfa b/contrib/pngminim/encoder/pngusr.dfa index ee88443c9..334d5e349 100644 --- a/contrib/pngminim/encoder/pngusr.dfa +++ b/contrib/pngminim/encoder/pngusr.dfa @@ -1,6 +1,6 @@ # pngminim/encoder/pngusr.dfa # -# Copyright (c) 2010-2011 Glenn Randers-Pehrson +# Copyright (c) 2010-2013 Glenn Randers-Pehrson # # This code is released under the libpng license. # For conditions of distribution and use, see the disclaimer @@ -13,6 +13,9 @@ everything = off # Switch on the write code - this makes a minimalist encoder option WRITE on +# These 2 options are required if you need to read PGM (P1 or P4) PGM files. +# option WRITE_INVERT on +# option WRITE_PACK on # You must choose fixed or floating point arithmetic: # option FLOATING_POINT on diff --git a/contrib/pngminim/preader/makefile b/contrib/pngminim/preader/makefile index ecc05c7bf..e9bb303e8 100644 --- a/contrib/pngminim/preader/makefile +++ b/contrib/pngminim/preader/makefile @@ -30,7 +30,8 @@ XLIB = -L/usr/X11R6/lib -lX11 #LIBS = $(XLIB) LIBS = $(XLIB) -lm #platforms that need libm -CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP -I. $(XINC) -O1 +CPPFLAGS=-I. $(XINC) -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP +CFLAGS=-O1 C=.c O=.o @@ -96,7 +97,7 @@ OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS) # implicit make rules ------------------------------------------------------- .c$(O): - $(CC) -c $(CFLAGS) $< + $(CC) $(CPPFLAGS) -c $(CFLAGS) $< # dependencies @@ -110,12 +111,12 @@ rpng2-x$(E): $(OBJS) # The CPP_FLAGS setting causes pngusr.h to be included in # both the build of pnglibconf.h and, subsequently, when # building libpng itself. -$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\ +$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\ $(PNGSRC)/scripts/pnglibconf.dfa \ $(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa $(RM) pnglibconf.h pnglibconf.dfn $(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\ - srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\ + srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\ DFA_XTRA="pngusr.dfa" $@ clean: diff --git a/contrib/pngminus/pnm2png.c b/contrib/pngminus/pnm2png.c index 4cdfad831..f9903dd32 100644 --- a/contrib/pngminus/pnm2png.c +++ b/contrib/pngminus/pnm2png.c @@ -18,6 +18,7 @@ #include #include #endif +#include #ifndef BOOL #define BOOL unsigned char @@ -197,6 +198,9 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, char height_token[16]; char maxval_token[16]; int color_type; + unsigned long ul_width=0, ul_alpha_width=0; + unsigned long ul_height=0, ul_alpha_height=0; + unsigned long ul_maxval=0; png_uint_32 width, alpha_width; png_uint_32 height, alpha_height; png_uint_32 maxval; @@ -206,6 +210,9 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, int alpha_present; int row, col; BOOL raw, alpha_raw = FALSE; +#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) + BOOL packed_bitmap = FALSE; +#endif png_uint_32 tmp16; int i; @@ -218,20 +225,36 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, } else if ((type_token[1] == '1') || (type_token[1] == '4')) { +#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) raw = (type_token[1] == '4'); color_type = PNG_COLOR_TYPE_GRAY; + get_token(pnm_file, width_token); + sscanf (width_token, "%lu", &ul_width); + width = (png_uint_32) ul_width; + get_token(pnm_file, height_token); + sscanf (height_token, "%lu", &ul_height); + height = (png_uint_32) ul_height; bit_depth = 1; + packed_bitmap = TRUE; +#else + fprintf (stderr, "PNM2PNG built without PNG_WRITE_INVERT_SUPPORTED and \n"); + fprintf (stderr, "PNG_WRITE_PACK_SUPPORTED can't read PBM (P1,P4) files\n"); +#endif } else if ((type_token[1] == '2') || (type_token[1] == '5')) { raw = (type_token[1] == '5'); color_type = PNG_COLOR_TYPE_GRAY; get_token(pnm_file, width_token); - sscanf (width_token, "%lu", &width); + sscanf (width_token, "%lu", &ul_width); + width = (png_uint_32) ul_width; get_token(pnm_file, height_token); - sscanf (height_token, "%lu", &height); + sscanf (height_token, "%lu", &ul_height); + height = (png_uint_32) ul_height; get_token(pnm_file, maxval_token); - sscanf (maxval_token, "%lu", &maxval); + sscanf (maxval_token, "%lu", &ul_maxval); + maxval = (png_uint_32) ul_maxval; + if (maxval <= 1) bit_depth = 1; else if (maxval <= 3) @@ -248,11 +271,14 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, raw = (type_token[1] == '6'); color_type = PNG_COLOR_TYPE_RGB; get_token(pnm_file, width_token); - sscanf (width_token, "%lu", &width); + sscanf (width_token, "%lu", &ul_width); + width = (png_uint_32) ul_width; get_token(pnm_file, height_token); - sscanf (height_token, "%lu", &height); + sscanf (height_token, "%lu", &ul_height); + height = (png_uint_32) ul_height; get_token(pnm_file, maxval_token); - sscanf (maxval_token, "%lu", &maxval); + sscanf (maxval_token, "%lu", &ul_maxval); + maxval = (png_uint_32) ul_maxval; if (maxval <= 1) bit_depth = 1; else if (maxval <= 3) @@ -287,15 +313,18 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, { alpha_raw = (type_token[1] == '5'); get_token(alpha_file, width_token); - sscanf (width_token, "%lu", &alpha_width); + sscanf (width_token, "%lu", &ul_alpha_width); + alpha_width=(png_uint_32) ul_alpha_width; if (alpha_width != width) return FALSE; get_token(alpha_file, height_token); - sscanf (height_token, "%lu", &alpha_height); + sscanf (height_token, "%lu", &ul_alpha_height); + alpha_height = (png_uint_32) ul_alpha_height; if (alpha_height != height) return FALSE; get_token(alpha_file, maxval_token); - sscanf (maxval_token, "%lu", &maxval); + sscanf (maxval_token, "%lu", &ul_maxval); + maxval = (png_uint_32) ul_maxval; if (maxval <= 1) alpha_depth = 1; else if (maxval <= 3) @@ -329,8 +358,14 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, alpha_present = (channels - 1) % 2; - /* row_bytes is the width x number of channels x (bit-depth / 8) */ - row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2); +#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) + if (packed_bitmap) + /* row data is as many bytes as can fit width x channels x bit_depth */ + row_bytes = (width * channels * bit_depth + 7) / 8; + else +#endif + /* row_bytes is the width x number of channels x (bit-depth / 8) */ + row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2); if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL) return FALSE; @@ -340,40 +375,48 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, for (row = 0; row < height; row++) { - for (col = 0; col < width; col++) +#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) + if (packed_bitmap) { + for (i = 0; i < row_bytes; i++) + /* png supports this format natively so no conversion is needed */ + *pix_ptr++ = get_data (pnm_file, 8); + } else +#endif { - for (i = 0; i < (channels - alpha_present); i++) + for (col = 0; col < width; col++) { - if (raw) - *pix_ptr++ = get_data (pnm_file, bit_depth); - else - if (bit_depth <= 8) - *pix_ptr++ = get_value (pnm_file, bit_depth); + for (i = 0; i < (channels - alpha_present); i++) + { + if (raw) + *pix_ptr++ = get_data (pnm_file, bit_depth); else - { - tmp16 = get_value (pnm_file, bit_depth); - *pix_ptr = (png_byte) ((tmp16 >> 8) & 0xFF); - pix_ptr++; - *pix_ptr = (png_byte) (tmp16 & 0xFF); - pix_ptr++; - } - } + if (bit_depth <= 8) + *pix_ptr++ = get_value (pnm_file, bit_depth); + else + { + tmp16 = get_value (pnm_file, bit_depth); + *pix_ptr = (png_byte) ((tmp16 >> 8) & 0xFF); + pix_ptr++; + *pix_ptr = (png_byte) (tmp16 & 0xFF); + pix_ptr++; + } + } - if (alpha) /* read alpha-channel from pgm file */ - { - if (alpha_raw) - *pix_ptr++ = get_data (alpha_file, alpha_depth); - else - if (alpha_depth <= 8) - *pix_ptr++ = get_value (alpha_file, bit_depth); + if (alpha) /* read alpha-channel from pgm file */ + { + if (alpha_raw) + *pix_ptr++ = get_data (alpha_file, alpha_depth); else - { - tmp16 = get_value (alpha_file, bit_depth); - *pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF); - *pix_ptr++ = (png_byte) (tmp16 & 0xFF); - } - } /* if alpha */ - + if (alpha_depth <= 8) + *pix_ptr++ = get_value (alpha_file, bit_depth); + else + { + tmp16 = get_value (alpha_file, bit_depth); + *pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF); + *pix_ptr++ = (png_byte) (tmp16 & 0xFF); + } + } /* if alpha */ + } /* if packed_bitmap */ } /* end for col */ } /* end for row */ @@ -390,6 +433,14 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, return FALSE; } +#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) + if (packed_bitmap == TRUE) + { + png_set_packing (png_ptr); + png_set_invert_mono (png_ptr); + } +#endif + /* setjmp() must be called in every function that calls a PNG-reading libpng function */ if (setjmp (png_jmpbuf(png_ptr))) { @@ -446,19 +497,32 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, void get_token(FILE *pnm_file, char *token) { int i = 0; + int ret; - /* remove white-space */ + /* remove white-space and comment lines */ do { - token[i] = (unsigned char) fgetc (pnm_file); + ret = fgetc(pnm_file); + if (ret == '#') { + /* the rest of this line is a comment */ + do + { + ret = fgetc(pnm_file); + } + while ((ret != '\n') && (ret != '\r') && (ret != EOF)); + } + if (ret == EOF) break; + token[i] = (unsigned char) ret; } while ((token[i] == '\n') || (token[i] == '\r') || (token[i] == ' ')); /* read string */ do { + ret = fgetc(pnm_file); + if (ret == EOF) break; i++; - token[i] = (unsigned char) fgetc (pnm_file); + token[i] = (unsigned char) ret; } while ((token[i] != '\n') && (token[i] != '\r') && (token[i] != ' ')); @@ -510,6 +574,7 @@ png_uint_32 get_value (FILE *pnm_file, int depth) { static png_uint_32 mask = 0; png_byte token[16]; + unsigned long ul_ret_value; png_uint_32 ret_value; int i = 0; @@ -518,7 +583,8 @@ png_uint_32 get_value (FILE *pnm_file, int depth) mask = (mask << 1) | 0x01; get_token (pnm_file, (char *) token); - sscanf ((const char *) token, "%lu", &ret_value); + sscanf ((const char *) token, "%lu", &ul_ret_value); + ret_value = (png_uint_32) ul_ret_value; ret_value &= mask; diff --git a/libpng-manual.txt b/libpng-manual.txt index ac7705d9c..8a5e525b3 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.5.15beta06 - February 22, 2013 + libpng version 1.5.16beta06 - May 12, 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.5.15beta06 - February 22, 2013 + libpng versions 0.97, January 1998, through 1.5.16beta06 - May 12, 2013 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2013 Glenn Randers-Pehrson @@ -31,9 +31,7 @@ Libpng-manual.txt - A description on how to use and modify libpng I. Introduction This file describes how to use and modify the PNG reference library -(known as libpng) for your own use. There are five sections to this -file: introduction, structures, reading, writing, and modification and -configuration notes for various special platforms. In addition to this +(known as libpng) for your own use. In addition to this file, example.c is a good starting point for using the library, as it is heavily commented and should include everything most people will need. We assume that libpng is already installed; see the @@ -509,8 +507,7 @@ you can retrieve with 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. +one or more of them. 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 @@ -604,7 +601,11 @@ callback function: #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) /* ignore all unknown chunks: */ + # if PNG_LIBPNG_VER < 10700 + png_set_keep_unknown_chunks(read_ptr, 2, NULL, 0); + # else png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0); + # endif /* except for vpAg: */ png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1); @@ -3034,13 +3035,45 @@ from PNG time to an RFC 1123 format string. Writing unknown chunks -You can use the png_set_unknown_chunks function to queue up chunks -for writing. You give it a chunk name, raw data, and a size; that's -all there is to it. The chunks will be written by the next following -png_write_info_before_PLTE, png_write_info, or png_write_end function. -Any chunks previously read into the info structure's unknown-chunk -list will also be written out in a sequence that satisfies the PNG -specification's ordering rules. +You can use the png_set_unknown_chunks function to queue up private chunks +for writing. You give it a chunk name, location, raw data, and a size. You +also must use png_set_keep_unknown_chunks() to ensure that libpng will +handle them. That's all there is to it. The chunks will be written by the +next following png_write_info_before_PLTE, png_write_info, or png_write_end +function, depending upon the specified location. Any chunks previously +read into the info structure's unknown-chunk list will also be written out +in a sequence that satisfies the PNG specification's ordering rules. + +Here is an example of writing two private chunks, prVt and miNE: + + #ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED + /* Set unknown chunk data */ + png_unknown_chunk unk_chunk[2]; + strcpy((char *) unk_chunk[0].name, "prVt"; + unk_chunk[0].data = (unsigned char *) "PRIVATE DATA"; + unk_chunk[0].size = strlen(unk_chunk[0].data)+1; + unk_chunk[0].location = PNG_HAVE_IHDR; + strcpy((char *) unk_chunk[1].name, "miNE"; + unk_chunk[1].data = (unsigned char *) "MY CHUNK DATA"; + unk_chunk[1].size = strlen(unk_chunk[0].data)+1; + unk_chunk[1].location = PNG_AFTER_IDAT; + png_set_unknown_chunks(write_ptr, write_info_ptr, + unk_chunk, 2); + /* Needed because miNE is not safe-to-copy */ + png_set_keep_unknown_chunks(png, PNG_HANDLE_CHUNK_ALWAYS, + (png_bytep) "miNE", 1); + /* Deal with unknown chunk location bug in 1.5.x and earlier */ + png_set_unknown_chunk_location(png, info, 0, PNG_HAVE_IHDR); + png_set_unknown_chunk_location(png, info, 1, PNG_AFTER_IDAT); + # if PNG_LIBPNG_VER < 10500 + /* PNG_AFTER_IDAT writes two copies of the chunk prior to libpng-1.5.0, + * one before IDAT and another after IDAT, so don't use it; only use + * PNG_HAVE_IHDR location. This call resets the location previously + * set by assignment and png_set_unknown_chunk_location() for chunk 1. + */ + png_set_unknown_chunk_location(png, info, 1, PNG_HAVE_IHDR); + # endif + #endif The high-level write interface @@ -4490,11 +4523,11 @@ control. The git repository was built from old libpng-x.y.z.tar.gz files going back to version 0.70. You can access the git repository (read only) at - git://libpng.git.sourceforge.net/gitroot/libpng + git://git.code.sf.net/p/libpng/code -or you can browse it via "gitweb" at +or you can browse it with a web browser by selecting the "code" button at - http://libpng.git.sourceforge.net/git/gitweb.cgi?p=libpng + https://sourceforge.net/projects/libpng/ Patches can be sent to glennrp at users.sourceforge.net or to png-mng-implement at lists.sourceforge.net or you can upload them to @@ -4622,13 +4655,13 @@ Other rules can be inferred by inspecting the libpng source. XIV. Y2K Compliance in libpng -February 22, 2013 +May 12, 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.5.15beta06 are Y2K compliant. It is my belief that earlier +upward through 1.5.16beta06 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 that diff --git a/libpng.3 b/libpng.3 index 12d80f592..6e1241d70 100644 --- a/libpng.3 +++ b/libpng.3 @@ -1,6 +1,6 @@ -.TH LIBPNG 3 "February 22, 2013" +.TH LIBPNG 3 "May 12, 2013" .SH NAME -libpng \- Portable Network Graphics (PNG) Reference Library 1.5.15beta06 +libpng \- Portable Network Graphics (PNG) Reference Library 1.5.16beta06 .SH SYNOPSIS \fB #include \fP @@ -277,7 +277,7 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.5.15beta06 \fBvoid png_set_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fIbackground\fP\fB);\fP -\fBvoid png_set_check_for_invalid_index(png_structrp \fP\fIpng_ptr\fP\fB, int \fIallowed\fP\fB);\fP +\fBvoid png_set_check_for_invalid_index(png_structp \fP\fIpng_ptr\fP\fB, int \fIallowed\fP\fB);\fP \fBvoid png_set_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fIwhite_x\fP\fB, double \fP\fIwhite_y\fP\fB, double \fP\fIred_x\fP\fB, double \fP\fIred_y\fP\fB, double \fP\fIgreen_x\fP\fB, double \fP\fIgreen_y\fP\fB, double \fP\fIblue_x\fP\fB, double \fIblue_y\fP\fB);\fP @@ -492,7 +492,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.5.15beta06 - February 22, 2013 + libpng version 1.5.16beta06 - May 12, 2013 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2013 Glenn Randers-Pehrson @@ -503,7 +503,7 @@ Libpng-manual.txt - A description on how to use and modify libpng Based on: - libpng versions 0.97, January 1998, through 1.5.15beta06 - February 22, 2013 + libpng versions 0.97, January 1998, through 1.5.16beta06 - May 12, 2013 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2013 Glenn Randers-Pehrson @@ -523,9 +523,7 @@ Libpng-manual.txt - A description on how to use and modify libpng .SH I. Introduction This file describes how to use and modify the PNG reference library -(known as libpng) for your own use. There are five sections to this -file: introduction, structures, reading, writing, and modification and -configuration notes for various special platforms. In addition to this +(known as libpng) for your own use. In addition to this file, example.c is a good starting point for using the library, as it is heavily commented and should include everything most people will need. We assume that libpng is already installed; see the @@ -1001,8 +999,7 @@ you can retrieve with 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. +one or more of them. 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 @@ -1096,7 +1093,11 @@ callback function: #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) /* ignore all unknown chunks: */ + # if PNG_LIBPNG_VER < 10700 + png_set_keep_unknown_chunks(read_ptr, 2, NULL, 0); + # else png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0); + # endif /* except for vpAg: */ png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1); @@ -3526,13 +3527,45 @@ from PNG time to an RFC 1123 format string. .SS Writing unknown chunks -You can use the png_set_unknown_chunks function to queue up chunks -for writing. You give it a chunk name, raw data, and a size; that's -all there is to it. The chunks will be written by the next following -png_write_info_before_PLTE, png_write_info, or png_write_end function. -Any chunks previously read into the info structure's unknown-chunk -list will also be written out in a sequence that satisfies the PNG -specification's ordering rules. +You can use the png_set_unknown_chunks function to queue up private chunks +for writing. You give it a chunk name, location, raw data, and a size. You +also must use png_set_keep_unknown_chunks() to ensure that libpng will +handle them. That's all there is to it. The chunks will be written by the +next following png_write_info_before_PLTE, png_write_info, or png_write_end +function, depending upon the specified location. Any chunks previously +read into the info structure's unknown-chunk list will also be written out +in a sequence that satisfies the PNG specification's ordering rules. + +Here is an example of writing two private chunks, prVt and miNE: + + #ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED + /* Set unknown chunk data */ + png_unknown_chunk unk_chunk[2]; + strcpy((char *) unk_chunk[0].name, "prVt"; + unk_chunk[0].data = (unsigned char *) "PRIVATE DATA"; + unk_chunk[0].size = strlen(unk_chunk[0].data)+1; + unk_chunk[0].location = PNG_HAVE_IHDR; + strcpy((char *) unk_chunk[1].name, "miNE"; + unk_chunk[1].data = (unsigned char *) "MY CHUNK DATA"; + unk_chunk[1].size = strlen(unk_chunk[0].data)+1; + unk_chunk[1].location = PNG_AFTER_IDAT; + png_set_unknown_chunks(write_ptr, write_info_ptr, + unk_chunk, 2); + /* Needed because miNE is not safe-to-copy */ + png_set_keep_unknown_chunks(png, PNG_HANDLE_CHUNK_ALWAYS, + (png_bytep) "miNE", 1); + /* Deal with unknown chunk location bug in 1.5.x and earlier */ + png_set_unknown_chunk_location(png, info, 0, PNG_HAVE_IHDR); + png_set_unknown_chunk_location(png, info, 1, PNG_AFTER_IDAT); + # if PNG_LIBPNG_VER < 10500 + /* PNG_AFTER_IDAT writes two copies of the chunk prior to libpng-1.5.0, + * one before IDAT and another after IDAT, so don't use it; only use + * PNG_HAVE_IHDR location. This call resets the location previously + * set by assignment and png_set_unknown_chunk_location() for chunk 1. + */ + png_set_unknown_chunk_location(png, info, 1, PNG_HAVE_IHDR); + # endif + #endif .SS The high-level write interface @@ -4983,11 +5016,11 @@ control. The git repository was built from old libpng-x.y.z.tar.gz files going back to version 0.70. You can access the git repository (read only) at - git://libpng.git.sourceforge.net/gitroot/libpng + git://git.code.sf.net/p/libpng/code -or you can browse it via "gitweb" at +or you can browse it with a web browser by selecting the "code" button at - http://libpng.git.sourceforge.net/git/gitweb.cgi?p=libpng + https://sourceforge.net/projects/libpng/ Patches can be sent to glennrp at users.sourceforge.net or to png-mng-implement at lists.sourceforge.net or you can upload them to @@ -5115,13 +5148,13 @@ Other rules can be inferred by inspecting the libpng source. .SH XIV. Y2K Compliance in libpng -February 22, 2013 +May 12, 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.5.15beta06 are Y2K compliant. It is my belief that earlier +upward through 1.5.16beta06 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 that @@ -5344,7 +5377,10 @@ the first widely used release: 1.5.14beta01-08 15 10514 15.so.15.14[.0] 1.5.14rc01-03 15 10514 15.so.15.14[.0] 1.5.14 15 10514 15.so.15.14[.0] - 1.5.15beta01-06 15 10515 15.so.15.15[.0] + 1.5.15beta01-09 15 10515 15.so.15.15[.0] + 1.5.15rc01 15 10515 15.so.15.15[.0] + 1.5.15 15 10515 15.so.15.15[.0] + 1.5.16beta01-06 15 10516 15.so.15.16[.0] Henceforth the source version will match the shared-library minor and patch numbers; the shared-library major version number will be @@ -5401,7 +5437,7 @@ possible without all of you. Thanks to Frank J. T. Wojcik for helping with the documentation. -Libpng version 1.5.15beta06 - February 22, 2013: +Libpng version 1.5.16beta06 - May 12, 2013: Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc. Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net). @@ -5424,7 +5460,7 @@ this sentence. This code is released under the libpng license. -libpng versions 1.2.6, August 15, 2004, through 1.5.15beta06, February 22, 2013, are +libpng versions 1.2.6, August 15, 2004, through 1.5.16beta06, May 12, 2013, are Copyright (c) 2004,2006-2007 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 @@ -5523,7 +5559,7 @@ certification mark of the Open Source Initiative. Glenn Randers-Pehrson glennrp at users.sourceforge.net -February 22, 2013 +May 12, 2013 .\" end of man page diff --git a/libpngpf.3 b/libpngpf.3 index b8ae147bb..d421d26ca 100644 --- a/libpngpf.3 +++ b/libpngpf.3 @@ -1,6 +1,6 @@ -.TH LIBPNGPF 3 "February 22, 2013" +.TH LIBPNGPF 3 "May 12, 2013" .SH NAME -libpng \- Portable Network Graphics (PNG) Reference Library 1.5.15beta06 +libpng \- Portable Network Graphics (PNG) Reference Library 1.5.16beta06 (private functions) .SH SYNOPSIS \fB#include \fI"pngpriv.h" diff --git a/png.5 b/png.5 index a644a15d3..4ee4e1f76 100644 --- a/png.5 +++ b/png.5 @@ -1,4 +1,4 @@ -.TH PNG 5 "February 22, 2013" +.TH PNG 5 "May 12, 2013" .SH NAME png \- Portable Network Graphics (PNG) format .SH DESCRIPTION diff --git a/png.c b/png.c index 8b9424dee..2019f53d2 100644 --- a/png.c +++ b/png.c @@ -1,7 +1,7 @@ /* png.c - location for general purpose libpng functions * - * Last changed in libpng 1.5.15 [(PENDING RELEASE)] + * Last changed in libpng 1.5.15 [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.) @@ -14,7 +14,7 @@ #include "pngpriv.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_5_15beta06 Your_png_h_is_not_version_1_5_15beta06; +typedef png_libpng_version_1_5_16beta06 Your_png_h_is_not_version_1_5_16beta06; /* Tells libpng that we have already handled the first "num_bytes" bytes * of the PNG file signature. If the PNG data is embedded into another @@ -658,13 +658,13 @@ png_get_copyright(png_const_structp png_ptr) #else # ifdef __STDC__ return PNG_STRING_NEWLINE \ - "libpng version 1.5.15beta06 - February 22, 2013" PNG_STRING_NEWLINE \ + "libpng version 1.5.16beta06 - May 12, 2013" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2013 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ PNG_STRING_NEWLINE; # else - return "libpng version 1.5.15beta06 - February 22, 2013\ + return "libpng version 1.5.16beta06 - May 12, 2013\ Copyright (c) 1998-2013 Glenn Randers-Pehrson\ Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; @@ -2878,3 +2878,24 @@ png_build_gamma_table(png_structp png_ptr, int bit_depth) } #endif /* READ_GAMMA */ #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ + +/* HARDWARE OPTION SUPPORT */ +#ifdef PNG_SET_OPTION_SUPPORTED +int PNGAPI +png_set_option(png_structp 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 diff --git a/png.h b/png.h index 38e432174..9064def81 100644 --- a/png.h +++ b/png.h @@ -1,7 +1,7 @@ /* png.h - header file for PNG reference library * - * libpng version 1.5.15beta06 - February 22, 2013 + * libpng version 1.5.16beta06 - May 12, 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.5.15beta06 - February 22, 2013: Glenn + * libpng versions 0.97, January 1998, through 1.5.16beta06 - May 12, 2013: Glenn * See also "Contributing Authors", below. * * Note about libpng version numbers: @@ -184,7 +184,10 @@ * 1.5.14beta01-08 15 10514 15.so.15.14[.0] * 1.5.14rc01-03 15 10514 15.so.15.14[.0] * 1.5.14 15 10514 15.so.15.14[.0] - * 1.5.15beta01-06 15 10515 15.so.15.15[.0] + * 1.5.15beta01-09 15 10515 15.so.15.15[.0] + * 1.5.15rc01 15 10515 15.so.15.15[.0] + * 1.5.15 15 10515 15.so.15.15[.0] + * 1.5.16beta01-06 15 10516 15.so.15.16[.0] * * Henceforth the source version will match the shared-library major * and minor numbers; the shared-library major version number will be @@ -216,7 +219,7 @@ * * This code is released under the libpng license. * - * libpng versions 1.2.6, August 15, 2004, through 1.5.15beta06, February 22, 2013, are + * libpng versions 1.2.6, August 15, 2004, through 1.5.16beta06, May 12, 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: @@ -328,13 +331,13 @@ * Y2K compliance in libpng: * ========================= * - * February 22, 2013 + * May 12, 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.5.15beta06 are Y2K compliant. It is my belief that + * upward through 1.5.16beta06 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 @@ -393,9 +396,9 @@ */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.5.15beta06" +#define PNG_LIBPNG_VER_STRING "1.5.16beta06" #define PNG_HEADER_VERSION_STRING \ - " libpng version 1.5.15beta06 - February 22, 2013\n" + " libpng version 1.5.16beta06 - May 12, 2013\n" #define PNG_LIBPNG_VER_SONUM 15 #define PNG_LIBPNG_VER_DLLNUM 15 @@ -403,7 +406,7 @@ /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ #define PNG_LIBPNG_VER_MAJOR 1 #define PNG_LIBPNG_VER_MINOR 5 -#define PNG_LIBPNG_VER_RELEASE 15 +#define PNG_LIBPNG_VER_RELEASE 16 /* This should match the numeric part of the final component of * PNG_LIBPNG_VER_STRING, omitting any leading zero: @@ -434,7 +437,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 10515 /* 1.5.15 */ +#define PNG_LIBPNG_VER 10516 /* 1.5.16 */ /* Library configuration: these options cannot be changed after * the library has been built. @@ -556,7 +559,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_5_15beta06; +typedef char* png_libpng_version_1_5_16beta06; /* Three color definitions. The order of the red, green, and blue, (and the * exact size) is not important, although the size of the fields need to @@ -2660,6 +2663,47 @@ PNG_EXPORT(235, 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(236, int, png_set_option, (png_structp png_ptr, int option, + int onoff)); +#endif + +/******************************************************************************* + * END OF HARDWARE OPTIONS + ******************************************************************************/ + /* Maintainer: Put new public prototypes here ^, in libpng.3, and project * defs */ @@ -2669,7 +2713,7 @@ PNG_EXPORT(235, int, png_get_palette_max, (png_const_structp png_ptr, * scripts/symbols.def as well. */ #ifdef PNG_EXPORT_LAST_ORDINAL - PNG_EXPORT_LAST_ORDINAL(235); + PNG_EXPORT_LAST_ORDINAL(236); #endif #ifdef __cplusplus diff --git a/pngconf.h b/pngconf.h index 78321cac5..23fee0eeb 100644 --- a/pngconf.h +++ b/pngconf.h @@ -1,7 +1,7 @@ /* pngconf.h - machine configurable file for libpng * - * libpng version 1.5.15beta06 - February 22, 2013 + * libpng version 1.5.16beta06 - May 12, 2013 * * Copyright (c) 1998-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/pngget.c b/pngget.c index 025db2ece..1eafae030 100644 --- a/pngget.c +++ b/pngget.c @@ -1,7 +1,7 @@ /* pngget.c - retrieval of values from info struct * - * Last changed in libpng 1.5.15 [(PENDING RELEASE)] + * Last changed in libpng 1.5.15 [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.) diff --git a/pngpriv.h b/pngpriv.h index 7785bdbed..ad40225a0 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.5.15 [(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 diff --git a/pngrtran.c b/pngrtran.c index bca3b68fb..6a464417b 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.5.15 [(PENDING RELEASE)] + * Last changed in libpng 1.5.15 [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.) @@ -194,6 +194,8 @@ translate_gamma_flags(png_structp png_ptr, png_fixed_point output_gamma, */ # ifdef PNG_READ_sRGB_SUPPORTED png_ptr->flags |= PNG_FLAG_ASSUME_sRGB; +# else + PNG_UNUSED(png_ptr) # endif if (is_screen) output_gamma = PNG_GAMMA_sRGB; diff --git a/pngrutil.c b/pngrutil.c index 5ee452d57..844c6d8b0 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -1,7 +1,7 @@ /* pngrutil.c - utilities to read a PNG file * - * Last changed in libpng 1.5.14 [January 24, 2013] + * Last changed in libpng 1.5.15 [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.) @@ -18,8 +18,6 @@ #ifdef PNG_READ_SUPPORTED -#define png_strtod(p,a,b) strtod(a,b) - png_uint_32 PNGAPI png_get_uint_31(png_structp png_ptr, png_const_bytep buf) { @@ -3161,7 +3159,7 @@ png_combine_row(png_structp png_ptr, png_bytep dp, int display) { png_uint_32p dp32 = (png_uint_32p)dp; png_const_uint_32p sp32 = (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 @@ -3202,7 +3200,7 @@ png_combine_row(png_structp png_ptr, png_bytep dp, int display) { png_uint_16p dp16 = (png_uint_16p)dp; png_const_uint_16p sp16 = (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 9fe476e49..6e9358b28 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.5.15 [(PENDING RELEASE)] + * Last changed in libpng 1.5.14 [January 24, 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.) diff --git a/pngstruct.h b/pngstruct.h index 684e6306c..21911de13 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.5.15 [(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 @@ -355,5 +355,10 @@ struct png_struct_def /* 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); + + /* Options */ +#ifdef PNG_SET_OPTION_SUPPORTED + png_byte options; /* On/off state (up to 4 options) */ +#endif }; #endif /* PNGSTRUCT_H */ diff --git a/pngtest.c b/pngtest.c index 8625dea4b..4c445d62a 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.5.15 [(PENDING RELEASE)] + * Last changed in libpng 1.5.15 [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.) @@ -43,7 +43,20 @@ #include "png.h" -#ifdef PNG_READ_SUPPORTED /* else nothing can be done */ +#if defined PNG_READ_SUPPORTED && /* else nothing can be done */\ + defined PNG_READ_bKGD_SUPPORTED &&\ + defined PNG_READ_cHRM_SUPPORTED &&\ + defined PNG_READ_gAMA_SUPPORTED &&\ + defined PNG_READ_oFFs_SUPPORTED &&\ + defined PNG_READ_pCAL_SUPPORTED &&\ + defined PNG_READ_pHYs_SUPPORTED &&\ + defined PNG_READ_sBIT_SUPPORTED &&\ + defined PNG_READ_sCAL_SUPPORTED &&\ + defined PNG_READ_sRGB_SUPPORTED &&\ + defined PNG_READ_tEXt_SUPPORTED &&\ + defined PNG_READ_tIME_SUPPORTED &&\ + defined PNG_READ_zTXt_SUPPORTED + #include "zlib.h" /* Copied from pngpriv.h but only used in error messages below. */ #ifndef PNG_ZBUF_SIZE @@ -1949,4 +1962,4 @@ main(void) #endif /* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_5_15beta06 Your_png_h_is_not_version_1_5_15beta06; +typedef png_libpng_version_1_5_16beta06 Your_png_h_is_not_version_1_5_16beta06; diff --git a/pngwrite.c b/pngwrite.c index 402e4fc6d..680878d94 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.5.15 [(PENDING RELEASE)] + * Last changed in libpng 1.5.15 [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.) diff --git a/projects/vstudio/readme.txt b/projects/vstudio/readme.txt index a99ab3781..537fbcd2b 100644 --- a/projects/vstudio/readme.txt +++ b/projects/vstudio/readme.txt @@ -1,7 +1,7 @@ VisualStudio instructions -libpng version 1.5.15beta06 - February 22, 2013 +libpng version 1.5.16beta06 - May 12, 2013 Copyright (c) 1998-2010 Glenn Randers-Pehrson diff --git a/projects/vstudio/zlib.props b/projects/vstudio/zlib.props index a048f2efc..9547c51f2 100644 --- a/projects/vstudio/zlib.props +++ b/projects/vstudio/zlib.props @@ -2,7 +2,7 @@