[libpng15] Port ARM support changes from libpng-1.6.3beta07.

This commit is contained in:
John Bowler 2013-06-08 13:52:00 -05:00 committed by Glenn Randers-Pehrson
parent ea216228f3
commit ffeb8f0d09
9 changed files with 128 additions and 67 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.5.17beta01 - June 6, 2013
Libpng 1.5.17beta01 - June 8, 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.
@ -26,13 +26,29 @@ Other information:
Changes since the last public release (1.5.16):
Version 1.5.17beta01 [June 6, 2013]
Version 1.5.17beta01 [June 8, 2013]
Removed a redundant test from png_set_IHDR().
Added set(CMAKE_CONFIGURATION_TYPES ...) to CMakeLists.txt (Andrew Hundt)
Deleted set(CMAKE_BUILD_TYPE) block from CMakeLists.txt
Make ARM NEON support work at compile time (not just configure time).
This moves the test on __ARM_NEON__ into pngconf.h to avoid issues when
using a compiler that compiles for multiple architectures at one time.
Removed PNG_FILTER_OPTIMIZATIONS and PNG_ARM_NEON_SUPPORTED from
pnglibconf.h, allowing more of the decisions to be made internally
(pngpriv.h) during the compile. Without this, symbol prefixing is broken
under certain circumstances on ARM platforms. Now only the API parts of
the optimizations ('check' vs 'api') are exposed in the public header files
except that the new setting PNG_ARM_NEON_OPT documents how libpng makes the
decision about whether or not to use the optimizations.
Protect symbol prefixing against CC/CPPFLAGS/CFLAGS useage.
Previous iOS/Xcode fixes for the ARM NEON optimizations moved the test
on __ARM_NEON__ from configure time to compile time. This breaks symbol
prefixing because the definition of the special png_init_filter_functions
call was hidden at configure time if the relevant compiler arguments are
passed in CFLAGS as opposed to CC. This change attempts to avoid all
the confusion that would result by declaring the init function even when
it is not used, so that it will always get prefixed.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

17
CHANGES
View File

@ -4113,13 +4113,28 @@ Version 1.5.16rc01 [May 16, 2013]
Version 1.5.16 [May 23, 2013]
No changes.
Version 1.5.17beta01 [June 6, 2013]
Version 1.5.17beta01 [June 8, 2013]
Removed a redundant test from png_set_IHDR().
Added set(CMAKE_CONFIGURATION_TYPES ...) to CMakeLists.txt (Andrew Hundt)
Deleted set(CMAKE_BUILD_TYPE) block from CMakeLists.txt
Make ARM NEON support work at compile time (not just configure time).
This moves the test on __ARM_NEON__ into pngconf.h to avoid issues when
using a compiler that compiles for multiple architectures at one time.
Removed PNG_FILTER_OPTIMIZATIONS and PNG_ARM_NEON_SUPPORTED from
pnglibconf.h, allowing more of the decisions to be made internally
(pngpriv.h) during the compile. Without this, symbol prefixing is broken
under certain circumstances on ARM platforms. Now only the API parts of
the optimizations ('check' vs 'api') are exposed in the public header files
except that the new setting PNG_ARM_NEON_OPT documents how libpng makes the
decision about whether or not to use the optimizations.
Protect symbol prefixing against CC/CPPFLAGS/CFLAGS useage.
Previous iOS/Xcode fixes for the ARM NEON optimizations moved the test
on __ARM_NEON__ from configure time to compile time. This breaks symbol
prefixing because the definition of the special png_init_filter_functions
call was hidden at configure time if the relevant compiler arguments are
passed in CFLAGS as opposed to CC. This change attempts to avoid all
the confusion that would result by declaring the init function even when
it is not used, so that it will always get prefixed.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

View File

@ -16,7 +16,7 @@
#include "../pngpriv.h"
#ifdef PNG_ARM_NEON_SUPPORTED
#if PNG_ARM_NEON_OPT > 0
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED /* Do run-time checks */
#include <signal.h> /* for sig_atomic_t */
@ -216,4 +216,4 @@ png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
png_read_filter_row_paeth4_neon;
}
}
#endif /* PNG_ARM_NEON_SUPPORTED */
#endif /* PNG_ARM_NEON_OPT > 0 */

View File

@ -11,7 +11,7 @@
*/
/* This is required to get the symbol renames, which are #defines, and also
* includes the definition (or not) of PNG_ARM_NEON_SUPPORTED.
* includes the definition (or not) of PNG_ARM_NEON_OPT.
*/
#define PNG_VERSION_INFO_ONLY
#include "../pngpriv.h"
@ -20,7 +20,7 @@
.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
#endif
#ifdef PNG_ARM_NEON_SUPPORTED
#if PNG_ARM_NEON_OPT > 0
#ifdef __ELF__
# define ELF
@ -232,4 +232,4 @@ func png_read_filter_row_paeth3_neon, export=1
pop {r4,pc}
endfunc
#endif /* PNG_ARM_NEON_SUPPORTED */
#endif /* PNG_ARM_NEON_OPT > 0 */

View File

@ -184,7 +184,7 @@ AC_ARG_ENABLE([arm-neon],
[case "$enableval" in
no|off)
# disable the default enabling on __ARM_NEON__ systems:
AC_DEFINE([PNG_ARM_NEON_NOT_SUPPORTED], [],
AC_DEFINE([PNG_ARM_NEON_OPT], [0],
[Disable ARM Neon optimizations])
# Prevent inclusion of the assembler files below:
enable_arm_neon=no;;
@ -195,8 +195,11 @@ AC_ARG_ENABLE([arm-neon],
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_DEFINE([PNG_ARM_NEON_OPT], [2],
[Enable ARM Neon optimizations])
AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api', if]
[you want the optimizations unconditionally pass -mfpu=neon]
[to the compiler.]);;
*)
AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}: invalid value])
esac])

View File

@ -1,7 +1,7 @@
/* pngconf.h - machine configurable file for libpng
*
* libpng version 1.5.17beta01 - June 6, 2013
* libpng version 1.5.17beta01 - June 8, 2013
*
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -173,30 +173,6 @@
* PNG_USE_DLL is set.
*/
/* Compile time options.
* =====================
* In a multi-arch build the compiler may compile the code several times for the
* same object module, producing different codes for different architectures.
* When this happens configure-time setting of the target host options cannot be
* done and this interferes with the handling of the ARM NEON optimizations, and
* possibly other similiar optimizations. Put additional tests here; in general
* this is needed when the same option can be changed at both compile time and
* run time depending on the target OS (i.e. iOS vs Android.)
*/
#ifdef __ARM_NEON__
/* If the default below causes problems set PNG_ARM_NEON_NOT_SUPPORTED either
* by passing --enable-arm-neon=no to configure or setting it in some other
* way when pnglibconf.h is built.
*/
# if (!defined PNG_ARM_NEON_SUPPORTED) && (!defined PNG_ARM_NEON_NOT_SUPPORTED)
# define PNG_ARM_NEON_SUPPORTED
# endif
#endif
#if (defined PNG_ARM_NEON_SUPPORTED) && (defined PNG_ARM_NEON_NOT_SUPPORTED)
# error configuration: ARM_NEON cannot both be supported and disabled
#endif
/* System specific discovery.
* ==========================
* This code is used at build time to find PNG_IMPEXP, the API settings

View File

@ -62,6 +62,46 @@
# endif
#endif
/* Compile time options.
* =====================
* In a multi-arch build the compiler may compile the code several times for the
* same object module, producing different binaries for different architectures.
* When this happens configure-time setting of the target host options cannot be
* done and this interferes with the handling of the ARM NEON optimizations, and
* possibly other similiar optimizations. Put additional tests here; in general
* this is needed when the same option can be changed at both compile time and
* run time depending on the target OS (i.e. iOS vs Android.)
*
* NOTE: symbol prefixing does not pass $(CFLAGS) to the preprocessor, because
* this is not possible with certain compilers (Oracle SUN OS CC), as a result
* it is necessary to ensure that all extern functions that *might* be used
* regardless of $(CFLAGS) get declared in this file. The test on __ARM_NEON__
* below is one example of this behavior because it is controlled by the
* presence or not of -mfpu=neon on the GCC command line, it is possible to do
* this in $(CC), e.g. "CC=gcc -mfpu=neon", but people who build libpng rarely
* do this.
*/
#ifndef PNG_ARM_NEON_OPT
/* ARM NEON optimizations are being controlled by the compiler settings,
* typically the target FPU. If the FPU has been set to NEON (-mfpu=neon
* with GCC) then the compiler will define __ARM_NEON__ and we can rely
* unconditionally on NEON instructions not crashing, otherwise we must
* disable use of NEON instructions:
*/
# ifdef __ARM_NEON__
# define PNG_ARM_NEON_OPT 2
# else
# define PNG_ARM_NEON_OPT 0
# endif
#endif
#if PNG_ARM_NEON_OPT > 0
/* NEON optimizations are to be at least considered by libpng, so enable the
* callbacks to do this.
*/
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_neon
#endif
/* Is this a build of a DLL where compilation of the object modules requires
* different preprocessor settings to those required for a simple library? If
* so PNG_BUILD_DLL must be set.
@ -1728,13 +1768,21 @@ PNG_EXTERN void png_set_rgb_to_gray_fixed PNGARG((png_structp png_ptr,
#endif
#endif /* FIX MISSING !FIXED_POINT DECLARATIONS */
/* These are initialization functions for hardware specific PNG filter
* optimizations; list these here then select the appropriate one at compile
* time using the macro PNG_FILTER_OPTIMIZATIONS. If the macro is not defined
* the generic code is used.
*/
#ifdef PNG_FILTER_OPTIMIZATIONS
PNG_EXTERN void PNG_FILTER_OPTIMIZATIONS(png_structp png_ptr, unsigned int bpp);
/* 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
* if not.
/* Just declare the optimization that will be used */
#else
/* List *all* the possible optimizations here - this branch is required if
* the builder of libpng passes the definition of PNG_FILTER_OPTIMIZATIONS in
* CFLAGS in place of CPPFLAGS *and* uses symbol prefixing.
*/
PNG_EXTERN void png_init_filter_functions_neon(png_structp png_ptr,
unsigned int bpp);
#endif
/* Maintainer: Put new private prototypes here ^ */

View File

@ -110,7 +110,7 @@ logunsupported = 1
#
# If you create a private DLL you need to define the following
# macros in the file 'pngusr.h' and set -DPNG_USER_CONFIG for
# compilation (i.e. in CFLAGS.)
# compilation (i.e. in CPPFLAGS.)
# #define PNG_USER_PRIVATEBUILD \
# <Describes by whom and why this version of the DLL was built>
# e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons."
@ -185,29 +185,39 @@ option READ_INT_FUNCTIONS requires READ
option WRITE_INT_FUNCTIONS disabled
option WRITE enables WRITE_INT_FUNCTIONS
# This setting allows a hardware or configuration specific filter optimization
# function to be specified, the argument is the name of the filter initializaion
# function to use.
setting FILTER_OPTIMIZATIONS
# Implementation specific control of the optimizations, enabled by those
# hardware or software options that need it (typically when run-time choices
# must be made by the user)
option SET_OPTION disabled
# These options are specific to the ARM NEON hardware optimizations:
# These options are specific to the ARM NEON hardware optimizations. At present
# these optimizations depend on GCC specific pre-processing of an assembler (.S)
# file so they probably won't work with other compilers.
#
# ARM_NEON: the optimization itself
# ARM_NEON_API: allow the optimization to be switched on with png_set_hardware
# ARM_NEON_CHECK: compile a run-time check to see if Neon extensions are
# supported, this is poorly supported and deprectated - use the
# png_set_hardware API.
option ARM_NEON disabled,
sets FILTER_OPTIMIZATIONS png_init_filter_functions_neon
option ARM_NEON_API disabled enables SET_OPTION ARM_NEON
option ARM_NEON_CHECK disabled enables ARM_NEON
# ARM_NEON_OPT: unset: check at compile time (__ARM_NEON__ must be defined by
# the compiler, typically as a result of specifying
# CC="gcc -mfpu=neon".)
# 0: disable (even if the CPU has a NEON FPU.)
# 1: check at run time (via ARM_NEON_{API,CHECK})
# 2: switch on unconditionally (inadvisable - instead pass
# -mfpu=neon to GCC in CC)
# When building libpng avoid using any setting other than '0'; '1' is
# set automatically when either 'API' or 'CHECK' are configured in,
# '2' should not be necessary as -mfpu=neon will achieve the same
# effect as well as applying NEON optimizations to the rest of the
# libpng code.
# NOTE: any setting other than '0' requires ALIGNED_MEMORY
# ARM_NEON_API: (PNG_ARM_NEON == 1) allow the optimization to be switched on
# with png_set_option
# ARM_NEON_CHECK: (PNG_ARM_NEON == 1) compile a run-time check to see if Neon
# extensions are supported, this is poorly supported and
# deprectated - use the png_set_option API.
setting ARM_NEON_OPT
option ARM_NEON_API disabled requires ALIGNED_MEMORY enables SET_OPTION,
sets ARM_NEON_OPT 1
option ARM_NEON_CHECK disabled requires ALIGNED_MEMORY,
sets ARM_NEON_OPT 1
# Generic options - affect both read and write.
option WARNINGS
@ -380,12 +390,6 @@ option INCH_CONVERSIONS
option BUILD_GRAYSCALE_PALETTE
# This changes the default for the ARM NEON optimizations according to
# __ARM_NEON__
@#ifdef __ARM_NEON__
@# define PNG_ARM_NEON_SUPPORTED
@#endif
# IN DEVELOPMENT
# These are currently experimental features; define them if you want

View File

@ -1,7 +1,7 @@
/* 1.5.17beta01 STANDARD API DEFINITION */
/* pnglibconf.h - library build configuration */
/* libpng version 1.5.17beta01 - May 23, 2013 */
/* libpng version 1.5.17beta01 - June 8, 2013 */
/* Copyright (c) 1998-2013 Glenn Randers-Pehrson */
@ -19,7 +19,6 @@
#define PNG_ALIGNED_MEMORY_SUPPORTED
/*#undef PNG_ARM_NEON_API_SUPPORTED*/
/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/
/*#undef PNG_ARM_NEON_SUPPORTED*/
#define PNG_BENIGN_ERRORS_SUPPORTED
#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED