Skip to content

Commit

Permalink
[libpng18] Review updates for target-specific code changes
Browse files Browse the repository at this point in the history
Signed-off-by: John Bowler <[email protected]>
  • Loading branch information
jbowler committed Oct 9, 2024
1 parent ea696ef commit e76bceb
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion mips/msacheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* This code has been moved from the original in pngpriv.h.
*/
/* MIPS MSA checks: */
#if defined(__mips_msa) && (__mips_isa_rev >= 2)
#if defined(__mips_msa) && (__mips_isa_rev >= 5)
/* MIPS MSA support requires gcc >= 4.7: */
# ifdef __GNUC__
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
Expand Down
28 changes: 16 additions & 12 deletions pngsimd.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/* pngsimd.c - hardware (cpu/arch) specific code
*
* Copyright (c) 2018-2024 Cosmin Truta
Expand All @@ -8,8 +9,6 @@
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*
* NOTE: this code is copied from libpng1.6 pngpriv.h.
*/
#include "pngpriv.h"

Expand Down Expand Up @@ -59,41 +58,46 @@
#include PNG_TARGET_CODE_IMPLEMENTATION

#ifndef png_target_impl
# error HARDWARE: PNG_TARGET_CODE_IMPLEMENTATION is defined but\
# error TARGET SPECIFIC CODE: PNG_TARGET_CODE_IMPLEMENTATION is defined but\
png_hareware_impl is not
#endif

#if defined(PNG_TARGET_STORES_DATA) != defined(png_target_free_data_impl)
# error HARDWARE: png_target_free_data_impl unexpected setting
# error TARGET SPECIFIC CODE: png_target_free_data_impl unexpected setting
#endif

#if defined(PNG_TARGET_IMPLEMENTS_FILTERS) !=\
defined(png_target_init_filter_functions_impl)
# error HARDWARE: png_target_init_filter_functions_impl unexpected setting
# error TARGET SPECIFIC CODE: png_target_init_filter_functions_impl unexpected\
setting
#endif

#if defined(PNG_TARGET_IMPLEMENTS_EXPAND_PALETTE) !=\
defined(png_target_do_expand_palette_impl)
# error HARDWARE: png_target_do_expand_palette_impl unexpected setting
# error TARGET SPECIFIC CODE: png_target_do_expand_palette_impl unexpected\
setting
#endif

void
png_target_init(png_structrp pp)
{
/* Initialize png_struct::target_state if required. */
# ifdef png_target_init_filter_functions_impl
# define F png_target_filters
# define PNG_TARGET_FILTER_SUPPORT png_target_filters
# else
# define F 0U
# define PNG_TARGET_FILTER_SUPPORT 0U
# endif
# ifdef png_target_do_expand_palette_impl
# define P png_target_expand_palette
# define PNG_TARGET_EXPAND_PALETTE_SUPPORT png_target_expand_palette
# else
# define P 0U
# define PNG_TARGET_EXPAND_PALETTE_SUPPORT 0U
# endif

# if F|P
pp->target_state = F|P;
# define PNG_TARGET_SUPPORT (PNG_TARGET_FILTER_SUPPORT |\
PNG_TARGET_EXPAND_PALETTE_SUPPORT)

# if PNG_TARGET_SUPPORT != 0U
pp->target_state = PNG_TARGET_SUPPORT;
# else
PNG_UNUSED(pp);
# endif
Expand Down
1 change: 0 additions & 1 deletion pngstruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,6 @@ struct png_struct_def
#endif
#endif

/* New member added in libpng-1.6.36 */
/* NOTE: prior to libpng-1.8 this also checked that PNG_ARM_NEON_IMPLEMENTATION
* is defined, however it was always defined... The code also checked that
* READ_EXPAND is supported but that will lead to bugs when some hardware
Expand Down
5 changes: 3 additions & 2 deletions pngtarget.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/* pngtarget.h - target configuration file for libpng
*
* libpng version 1.6.44.git
Expand Down Expand Up @@ -79,10 +80,10 @@

#ifdef PNG_TARGET_SPECIFIC_CODE_SUPPORTED /* from pnglibconf.h */
# ifdef PNG_READ_SUPPORTED /* checked here as a convenience */
# include "arm/check.h"
# include "intel/check.h"
# include "mips/check.h"
# include "powerpc/check.h"
# include "intel/check.h"
# include "arm/check.h"
#endif
#endif /* PNG_TARGET_SPECIFIC_CODE_SUPPORTED */

Expand Down
2 changes: 1 addition & 1 deletion scripts/pnglibconf.h.prebuilt
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
#define PNG_USER_HEIGHT_MAX 1000000
#define PNG_USER_WIDTH_MAX 1000000
#define PNG_ZBUF_SIZE 8192
#define PNG_ZLIB_VERNUM 0
#define PNG_ZLIB_VERNUM 0 /* unknown */
#define PNG_Z_DEFAULT_COMPRESSION (-1)
#define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0
#define PNG_Z_DEFAULT_STRATEGY 1
Expand Down

0 comments on commit e76bceb

Please sign in to comment.