mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng16] Fixed 'minimal' builds. Various obviously useful minimal
configurations don't build because of missing contrib/libtests test programs and overly complex dependencies in scripts/pnglibconf.dfa. This change adds contrib/conftest/*.dfa files that can be used in automatic build scripts to ensure that these configurations continue to build.
This commit is contained in:
49
contrib/conftest/README
Normal file
49
contrib/conftest/README
Normal file
@@ -0,0 +1,49 @@
|
||||
This directory contains test configuration files, currently always '.dfa' files
|
||||
intended to be used in the build by setting the make macro DFA_XTRA to the name
|
||||
of the file.
|
||||
|
||||
These files are used in release validation of the 'configure' builds of libpng
|
||||
by building 'make check', or 'make all-am' for cross-builds, with each .dfa
|
||||
file.
|
||||
|
||||
The files in this directory may change between minor releases, however
|
||||
contributions describing specific builds of libpng are welcomed. There is no
|
||||
guarantee that libpng will continue to build with such configurations; support
|
||||
for given configurations can be, and has been, dropped between successive minor
|
||||
releases. However if a .dfa file describing a configuration is not in this
|
||||
directory it is very unlikely that it will be tested before a minor release!
|
||||
|
||||
You can use these .dfa files as the basis of new configurations. Files in this
|
||||
directory should not have any use restrictions or restrictive licenses.
|
||||
|
||||
This directory is not included in the .zip and .7z distributions, which do
|
||||
not contain 'configure' scripts.
|
||||
|
||||
DOCUMENTATION
|
||||
=============
|
||||
|
||||
Examples:
|
||||
${srcdir}/pngusr.dfa
|
||||
${srcdir}/contrib/pngminim/*/pngusr.dfa
|
||||
|
||||
Documentation of the options:
|
||||
${srcdir}/scripts/pnglibconf.dfa
|
||||
|
||||
Documentation of the file format:
|
||||
${srcdir}/scripts/options.awk
|
||||
|
||||
FILE NAMING
|
||||
===========
|
||||
|
||||
File names in this directory may NOT contain any of the five characters:
|
||||
|
||||
- , + * ?
|
||||
|
||||
Neither may they contain any space character.
|
||||
|
||||
While other characters may be used it is strongly suggested that file names be
|
||||
limited to lower case Latiin alphabetic characters (a-z), digits (0-9) and, if
|
||||
necessary the underscore (_) character. File names should be about 8 characters
|
||||
long (excluding the .dfa extension). Submitted .dfa files should have names
|
||||
between 7 and 16 characters long, shorter names (6 characters or less) are
|
||||
reserved for standard tests.
|
||||
58
contrib/conftest/read.dfa
Normal file
58
contrib/conftest/read.dfa
Normal file
@@ -0,0 +1,58 @@
|
||||
# read.dfa
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Author: John Bowler
|
||||
# Copyright: (c) John Bowler, 2013
|
||||
# Usage rights:
|
||||
# To the extent possible under law, the author has waived all copyright and
|
||||
# related or neighboring rights to this work. This work is published from:
|
||||
# United States.
|
||||
#
|
||||
# Build libpng with basic read support. This enables the lowest level libpng
|
||||
# read API - the one where the calling code has to use a loop to read each row.
|
||||
# At present this is the API used by most programs.
|
||||
#
|
||||
# Support is enabled only for those chunks and transformations that are
|
||||
# typically required - others can be added easily.
|
||||
#
|
||||
|
||||
everything = off
|
||||
|
||||
# The sequential read code is enabled here; the progressive code can be used
|
||||
# instead but there is no point enabling both.
|
||||
|
||||
option SEQUENTIAL_READ on
|
||||
|
||||
# Likewise it is pointless enabling both fixed and floating point APIs. Choose
|
||||
# one or the other for both the API and the internal math.
|
||||
|
||||
#Fixed point:
|
||||
#option FIXED_POINT on
|
||||
#option FLOATING_ARITHMETIC off
|
||||
|
||||
#Floating point:
|
||||
option FLOATING_POINT on
|
||||
option FLOATING_ARITHMETIC on
|
||||
|
||||
# Basic error handling, IO and user memory support. The latter allows the
|
||||
# application program to provide its own implementations of 'malloc' and 'free'.
|
||||
option SETJMP on
|
||||
option STDIO on
|
||||
option USER_MEM on
|
||||
|
||||
# To read the full set of PNG images correctly interlace, transparency and
|
||||
# 16-bit support is required. The application can implement interlace itself,
|
||||
# but very few do and it's no longer possible to disable it when READ is
|
||||
# enabled.
|
||||
option READ_tRNS on
|
||||
option READ_16BIT on
|
||||
|
||||
# Everything else is application dependent. This file assumes the app handles
|
||||
# all the native PNG bit layouts, so it doesn't need any of layout change
|
||||
# transforms, but needs libpng to perform gamma correction. It doesn't do any
|
||||
# colorspace stuff and ignores the 'significant bit' information.
|
||||
#
|
||||
# If your app always expands the image to a limited set of bit layouts you
|
||||
# probably want to consider using the simplified API instead of the low level
|
||||
# one - see png.h and s_read.dfa.
|
||||
option READ_GAMMA on
|
||||
35
contrib/conftest/s_read.dfa
Normal file
35
contrib/conftest/s_read.dfa
Normal file
@@ -0,0 +1,35 @@
|
||||
# s_read.dfa
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Author: John Bowler
|
||||
# Copyright: (c) John Bowler, 2013
|
||||
# Usage rights:
|
||||
# To the extent possible under law, the author has waived all copyright and
|
||||
# related or neighboring rights to this work. This work is published from:
|
||||
# United States.
|
||||
#
|
||||
# Build libpng with simplified read support (only). This builds a minimal
|
||||
# libpng able to read all PNG formats and convert them into a small number of
|
||||
# well understood memory formats.
|
||||
#
|
||||
|
||||
everything = off
|
||||
|
||||
option SIMPLIFIED_READ on
|
||||
|
||||
# It isn't necessary to chose fixed or floating point for the APIs because the
|
||||
# simplified API doesn't need fixed or floating point numbers. It is necessary
|
||||
# to chose an internal math implementation. The default (because of 'everything
|
||||
# = off') is fixed point - turn the floating point implementation on if you have
|
||||
# hardware floating point or prefer your software floating point implementation.
|
||||
option FLOATING_ARITHMETIC on
|
||||
|
||||
# This is not strictly necessary, but without it the message strings in the API
|
||||
# will not be filled in
|
||||
option ERROR_TEXT on
|
||||
|
||||
# Switching these options on enables the 'AFIRST' and 'BGR' formats - you don't
|
||||
# need this if you don't use them, they just allow the in-memory layout to be
|
||||
# changed to match common hardware formats.
|
||||
option SIMPLIFIED_READ_AFIRST on
|
||||
option SIMPLIFIED_READ_BGR on
|
||||
33
contrib/conftest/s_write.dfa
Normal file
33
contrib/conftest/s_write.dfa
Normal file
@@ -0,0 +1,33 @@
|
||||
# s_write.dfa
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Author: John Bowler
|
||||
# Copyright: (c) John Bowler, 2013
|
||||
# Usage rights:
|
||||
# To the extent possible under law, the author has waived all copyright and
|
||||
# related or neighboring rights to this work. This work is published from:
|
||||
# United States.
|
||||
#
|
||||
# Build libpng with (just) simplified write support
|
||||
#
|
||||
|
||||
everything = off
|
||||
|
||||
option SIMPLIFIED_WRITE on
|
||||
|
||||
# It isn't necessary to chose fixed or floating point for the APIs because the
|
||||
# simplified API doesn't need fixed or floating point numbers. It is necessary
|
||||
# to chose an internal math implementation. The default (because of 'everything
|
||||
# = off') is fixed point - turn the floating point implementation on if you have
|
||||
# hardware floating point or prefer your software floating point implementation.
|
||||
option FLOATING_ARITHMETIC on
|
||||
|
||||
# This is not strictly necessary, but without it the message strings in the API
|
||||
# will not be filled in
|
||||
option ERROR_TEXT on
|
||||
|
||||
# Switching these options on enables the 'AFIRST' and 'BGR' formats - you don't
|
||||
# need this if you don't use them, they just allow the in-memory layout to be
|
||||
# changed to match common hardware formats.
|
||||
option SIMPLIFIED_WRITE_AFIRST on
|
||||
option SIMPLIFIED_WRITE_BGR on
|
||||
36
contrib/conftest/simple.dfa
Normal file
36
contrib/conftest/simple.dfa
Normal file
@@ -0,0 +1,36 @@
|
||||
# simple.dfa
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Author: John Bowler
|
||||
# Copyright: (c) John Bowler, 2013
|
||||
# Usage rights:
|
||||
# To the extent possible under law, the author has waived all copyright and
|
||||
# related or neighboring rights to this work. This work is published from:
|
||||
# United States.
|
||||
#
|
||||
# Build libpng with just the simplified APIs (read and write).
|
||||
#
|
||||
|
||||
everything = off
|
||||
|
||||
option SIMPLIFIED_WRITE on
|
||||
option SIMPLIFIED_READ on
|
||||
|
||||
# It isn't necessary to chose fixed or floating point for the APIs because the
|
||||
# simplified API doesn't need fixed or floating point numbers. It is necessary
|
||||
# to chose an internal math implementation. The default (because of 'everything
|
||||
# = off') is fixed point - turn the floating point implementation on if you have
|
||||
# hardware floating point or prefer your software floating point implementation.
|
||||
option FLOATING_ARITHMETIC on
|
||||
|
||||
# This is not strictly necessary, but without it the message strings in the API
|
||||
# will not be filled in
|
||||
option ERROR_TEXT on
|
||||
|
||||
# Switching these options on enables the 'AFIRST' and 'BGR' formats - you don't
|
||||
# need this if you don't use them, they just allow the in-memory layout to be
|
||||
# changed to match common hardware formats.
|
||||
option SIMPLIFIED_READ_AFIRST on
|
||||
option SIMPLIFIED_READ_BGR on
|
||||
option SIMPLIFIED_WRITE_AFIRST on
|
||||
option SIMPLIFIED_WRITE_BGR on
|
||||
45
contrib/conftest/write.dfa
Normal file
45
contrib/conftest/write.dfa
Normal file
@@ -0,0 +1,45 @@
|
||||
# write.dfa
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Author: John Bowler
|
||||
# Copyright: (c) John Bowler, 2013
|
||||
# Usage rights:
|
||||
# To the extent possible under law, the author has waived all copyright and
|
||||
# related or neighboring rights to this work. This work is published from:
|
||||
# United States.
|
||||
#
|
||||
# Build libpng with no read support and minimal write support.
|
||||
#
|
||||
|
||||
everything = off
|
||||
|
||||
# Switch on the write code - this makes a minimalist encoder
|
||||
|
||||
option WRITE on
|
||||
|
||||
# Choose fixed or floating point APIs and arithmetic. The choices are
|
||||
# independent but normally they will match. It is typically better to use the
|
||||
# floating point if you have floating point hardware. If you don't know, or
|
||||
# (perhaps) to make libpng smaller used fixed point throughout.
|
||||
|
||||
#Fixed point:
|
||||
#option FIXED_POINT on
|
||||
#option FLOATING_ARITHMETIC off
|
||||
|
||||
#Floating point:
|
||||
option FLOATING_POINT on
|
||||
option FLOATING_ARITHMETIC on
|
||||
|
||||
# Basic error handling, IO and user memory support. The latter allows the
|
||||
# application program to provide its own implementations of 'malloc' and 'free'.
|
||||
option SETJMP on
|
||||
option STDIO on
|
||||
option USER_MEM on
|
||||
|
||||
# Everything else is optional. Unlike the read code in libpng the write code
|
||||
# does not need to deal with arbitrary formats, so only add support for things
|
||||
# you really do write! For example you might only write sRGB images, sometimes
|
||||
# with transparency and never write 16 bit images, so:
|
||||
option WRITE_sRGB on
|
||||
option WRITE_tRNS on
|
||||
#option WRITE_16BIT off (this is the default with 'everything = off')
|
||||
@@ -517,14 +517,23 @@ static void format_default(format_list *pf, int redundant)
|
||||
|
||||
for (f=0; f<FORMAT_COUNT; ++f)
|
||||
{
|
||||
/* Eliminate redundant settings. */
|
||||
/* BGR is meaningless if no color: */
|
||||
if ((f & PNG_FORMAT_FLAG_COLOR) == 0 && (f & PNG_FORMAT_FLAG_BGR) != 0)
|
||||
/* Eliminate redundant and unsupported settings. */
|
||||
# ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
/* BGR is meaningless if no color: */
|
||||
if ((f & PNG_FORMAT_FLAG_COLOR) == 0 &&
|
||||
(f & PNG_FORMAT_FLAG_BGR) != 0)
|
||||
# else
|
||||
if ((f & 0x10U/*HACK: fixed value*/) != 0)
|
||||
# endif
|
||||
continue;
|
||||
|
||||
/* AFIRST is meaningless if no alpha: */
|
||||
if ((f & PNG_FORMAT_FLAG_ALPHA) == 0 &&
|
||||
(f & PNG_FORMAT_FLAG_AFIRST) != 0)
|
||||
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
if ((f & PNG_FORMAT_FLAG_ALPHA) == 0 &&
|
||||
(f & PNG_FORMAT_FLAG_AFIRST) != 0)
|
||||
# else
|
||||
if ((f & 0x20U/*HACK: fixed value*/) != 0)
|
||||
# endif
|
||||
continue;
|
||||
|
||||
format_set(pf, f);
|
||||
@@ -786,6 +795,7 @@ gp_ga8(Pixel *p, png_const_voidp pb)
|
||||
p->a = pp[1];
|
||||
}
|
||||
|
||||
#ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
static void
|
||||
gp_ag8(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
@@ -794,6 +804,7 @@ gp_ag8(Pixel *p, png_const_voidp pb)
|
||||
p->r = p->g = p->b = pp[1];
|
||||
p->a = pp[0];
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
gp_rgb8(Pixel *p, png_const_voidp pb)
|
||||
@@ -806,6 +817,7 @@ gp_rgb8(Pixel *p, png_const_voidp pb)
|
||||
p->a = 255;
|
||||
}
|
||||
|
||||
#ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
static void
|
||||
gp_bgr8(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
@@ -816,6 +828,7 @@ gp_bgr8(Pixel *p, png_const_voidp pb)
|
||||
p->b = pp[0];
|
||||
p->a = 255;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
gp_rgba8(Pixel *p, png_const_voidp pb)
|
||||
@@ -828,6 +841,7 @@ gp_rgba8(Pixel *p, png_const_voidp pb)
|
||||
p->a = pp[3];
|
||||
}
|
||||
|
||||
#ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
static void
|
||||
gp_bgra8(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
@@ -838,7 +852,9 @@ gp_bgra8(Pixel *p, png_const_voidp pb)
|
||||
p->b = pp[0];
|
||||
p->a = pp[3];
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
static void
|
||||
gp_argb8(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
@@ -849,7 +865,9 @@ gp_argb8(Pixel *p, png_const_voidp pb)
|
||||
p->b = pp[3];
|
||||
p->a = pp[0];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_FORMAT_AFIRST_SUPPORTED) && defined(PNG_FORMAT_BGR_SUPPORTED)
|
||||
static void
|
||||
gp_abgr8(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
@@ -860,6 +878,7 @@ gp_abgr8(Pixel *p, png_const_voidp pb)
|
||||
p->b = pp[1];
|
||||
p->a = pp[0];
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
gp_g16(Pixel *p, png_const_voidp pb)
|
||||
@@ -879,6 +898,7 @@ gp_ga16(Pixel *p, png_const_voidp pb)
|
||||
p->a = pp[1];
|
||||
}
|
||||
|
||||
#ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
static void
|
||||
gp_ag16(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
@@ -887,6 +907,7 @@ gp_ag16(Pixel *p, png_const_voidp pb)
|
||||
p->r = p->g = p->b = pp[1];
|
||||
p->a = pp[0];
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
gp_rgb16(Pixel *p, png_const_voidp pb)
|
||||
@@ -899,6 +920,7 @@ gp_rgb16(Pixel *p, png_const_voidp pb)
|
||||
p->a = 65535;
|
||||
}
|
||||
|
||||
#ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
static void
|
||||
gp_bgr16(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
@@ -909,6 +931,7 @@ gp_bgr16(Pixel *p, png_const_voidp pb)
|
||||
p->b = pp[0];
|
||||
p->a = 65535;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
gp_rgba16(Pixel *p, png_const_voidp pb)
|
||||
@@ -921,6 +944,7 @@ gp_rgba16(Pixel *p, png_const_voidp pb)
|
||||
p->a = pp[3];
|
||||
}
|
||||
|
||||
#ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
static void
|
||||
gp_bgra16(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
@@ -931,7 +955,9 @@ gp_bgra16(Pixel *p, png_const_voidp pb)
|
||||
p->b = pp[0];
|
||||
p->a = pp[3];
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
static void
|
||||
gp_argb16(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
@@ -942,7 +968,9 @@ gp_argb16(Pixel *p, png_const_voidp pb)
|
||||
p->b = pp[3];
|
||||
p->a = pp[0];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_FORMAT_AFIRST_SUPPORTED) && defined(PNG_FORMAT_BGR_SUPPORTED)
|
||||
static void
|
||||
gp_abgr16(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
@@ -953,6 +981,7 @@ gp_abgr16(Pixel *p, png_const_voidp pb)
|
||||
p->b = pp[1];
|
||||
p->a = pp[0];
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Given a format, return the correct one of the above functions. */
|
||||
static void (*
|
||||
@@ -966,29 +995,35 @@ get_pixel(png_uint_32 format))(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_COLOR)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_BGR)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_ALPHA)
|
||||
# ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
if (format & PNG_FORMAT_FLAG_BGR)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
return gp_abgr16;
|
||||
if (format & PNG_FORMAT_FLAG_ALPHA)
|
||||
{
|
||||
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
return gp_abgr16;
|
||||
|
||||
else
|
||||
# endif
|
||||
return gp_bgra16;
|
||||
}
|
||||
|
||||
else
|
||||
return gp_bgra16;
|
||||
return gp_bgr16;
|
||||
}
|
||||
|
||||
else
|
||||
return gp_bgr16;
|
||||
}
|
||||
|
||||
else
|
||||
# endif
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_ALPHA)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
return gp_argb16;
|
||||
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
return gp_argb16;
|
||||
|
||||
else
|
||||
else
|
||||
# endif
|
||||
return gp_rgba16;
|
||||
}
|
||||
|
||||
@@ -1001,10 +1036,12 @@ get_pixel(png_uint_32 format))(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_ALPHA)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
return gp_ag16;
|
||||
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
return gp_ag16;
|
||||
|
||||
else
|
||||
else
|
||||
# endif
|
||||
return gp_ga16;
|
||||
}
|
||||
|
||||
@@ -1017,29 +1054,35 @@ get_pixel(png_uint_32 format))(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_COLOR)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_BGR)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_ALPHA)
|
||||
# ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
if (format & PNG_FORMAT_FLAG_BGR)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
return gp_abgr8;
|
||||
if (format & PNG_FORMAT_FLAG_ALPHA)
|
||||
{
|
||||
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
return gp_abgr8;
|
||||
|
||||
else
|
||||
# endif
|
||||
return gp_bgra8;
|
||||
}
|
||||
|
||||
else
|
||||
return gp_bgra8;
|
||||
return gp_bgr8;
|
||||
}
|
||||
|
||||
else
|
||||
return gp_bgr8;
|
||||
}
|
||||
|
||||
else
|
||||
# endif
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_ALPHA)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
return gp_argb8;
|
||||
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
return gp_argb8;
|
||||
|
||||
else
|
||||
else
|
||||
# endif
|
||||
return gp_rgba8;
|
||||
}
|
||||
|
||||
@@ -1052,10 +1095,12 @@ get_pixel(png_uint_32 format))(Pixel *p, png_const_voidp pb)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_ALPHA)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
return gp_ag8;
|
||||
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
return gp_ag8;
|
||||
|
||||
else
|
||||
else
|
||||
# endif
|
||||
return gp_ga8;
|
||||
}
|
||||
|
||||
@@ -2618,13 +2663,15 @@ component_loc(png_byte loc[4], png_uint_32 format)
|
||||
|
||||
loc[2] = 1;
|
||||
|
||||
if (format & PNG_FORMAT_FLAG_BGR)
|
||||
{
|
||||
loc[1] = 2;
|
||||
loc[3] = 0;
|
||||
}
|
||||
# ifdef PNG_FORMAT_BGR_SUPPORTED
|
||||
if (format & PNG_FORMAT_FLAG_BGR)
|
||||
{
|
||||
loc[1] = 2;
|
||||
loc[3] = 0;
|
||||
}
|
||||
|
||||
else
|
||||
else
|
||||
# endif
|
||||
{
|
||||
loc[1] = 0;
|
||||
loc[3] = 2;
|
||||
@@ -2639,15 +2686,17 @@ component_loc(png_byte loc[4], png_uint_32 format)
|
||||
|
||||
if (format & PNG_FORMAT_FLAG_ALPHA)
|
||||
{
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
{
|
||||
loc[0] = 0;
|
||||
++loc[1];
|
||||
++loc[2];
|
||||
++loc[3];
|
||||
}
|
||||
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
|
||||
if (format & PNG_FORMAT_FLAG_AFIRST)
|
||||
{
|
||||
loc[0] = 0;
|
||||
++loc[1];
|
||||
++loc[2];
|
||||
++loc[3];
|
||||
}
|
||||
|
||||
else
|
||||
else
|
||||
# endif
|
||||
loc[0] = channels;
|
||||
|
||||
++channels;
|
||||
@@ -3017,17 +3066,25 @@ read_file(Image *image, png_uint_32 format, png_const_colorp background)
|
||||
return logerror(image, "memory init: ", image->file_name, "");
|
||||
}
|
||||
|
||||
else if (image->input_file != NULL)
|
||||
{
|
||||
if (!png_image_begin_read_from_stdio(&image->image, image->input_file))
|
||||
return logerror(image, "stdio init: ", image->file_name, "");
|
||||
}
|
||||
# ifdef PNG_STDIO_SUPPORTED
|
||||
else if (image->input_file != NULL)
|
||||
{
|
||||
if (!png_image_begin_read_from_stdio(&image->image, image->input_file))
|
||||
return logerror(image, "stdio init: ", image->file_name, "");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (!png_image_begin_read_from_file(&image->image, image->file_name))
|
||||
return logerror(image, "file init: ", image->file_name, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!png_image_begin_read_from_file(&image->image, image->file_name))
|
||||
return logerror(image, "file init: ", image->file_name, "");
|
||||
}
|
||||
# else
|
||||
else
|
||||
{
|
||||
return logerror(image, "unsupported file/stdio init: ",
|
||||
image->file_name, "");
|
||||
}
|
||||
# endif
|
||||
|
||||
/* This must be set after the begin_read call: */
|
||||
if (image->opts & sRGB_16BIT)
|
||||
@@ -3466,11 +3523,19 @@ main(int argc, char **argv)
|
||||
memset(gpc_error_via_linear, 0, sizeof gpc_error_via_linear);
|
||||
}
|
||||
else if (strcmp(arg, "--file") == 0)
|
||||
opts |= READ_FILE;
|
||||
# ifdef PNG_STDIO_SUPPORTED
|
||||
opts |= READ_FILE;
|
||||
# else
|
||||
return 77; /* skipped: no support */
|
||||
# endif
|
||||
else if (strcmp(arg, "--memory") == 0)
|
||||
opts &= ~READ_FILE;
|
||||
else if (strcmp(arg, "--stdio") == 0)
|
||||
opts |= USE_STDIO;
|
||||
# ifdef PNG_STDIO_SUPPORTED
|
||||
opts |= USE_STDIO;
|
||||
# else
|
||||
return 77; /* skipped: no support */
|
||||
# endif
|
||||
else if (strcmp(arg, "--name") == 0)
|
||||
opts &= ~USE_STDIO;
|
||||
else if (strcmp(arg, "--verbose") == 0)
|
||||
|
||||
@@ -43,7 +43,10 @@
|
||||
# include "../../png.h"
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED /* else pngvalid can do nothing */
|
||||
/* pngvalid requires write support and one of the fixed or floating point APIs.
|
||||
*/
|
||||
#if defined(PNG_WRITE_SUPPORTED) &&\
|
||||
(defined(PNG_FIXED_POINT_SUPPORTED) || defined(PNG_FLOATING_POINT_SUPPORTED))
|
||||
|
||||
#if PNG_LIBPNG_VER < 10500
|
||||
/* This deliberately lacks the PNG_CONST. */
|
||||
@@ -106,6 +109,11 @@ typedef png_byte *png_const_bytep;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Fixups for various minimal builds */
|
||||
#ifndef PNG_ERROR_TEXT_SUPPORTED
|
||||
# define png_error(a,b) png_err(a)
|
||||
#endif
|
||||
|
||||
/***************************** EXCEPTION HANDLING *****************************/
|
||||
#ifdef PNG_FREESTANDING_TESTS
|
||||
# include <cexcept.h>
|
||||
@@ -1263,6 +1271,7 @@ store_current_palette(png_store *ps, int *npalette)
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
/***************************** MEMORY MANAGEMENT*** ***************************/
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
/* A store_memory is simply the header for an allocated block of memory. The
|
||||
* pointer returned to libpng is just after the end of the header block, the
|
||||
* allocated memory is followed by a second copy of the 'mark'.
|
||||
@@ -1463,6 +1472,7 @@ store_free(png_structp ppIn, png_voidp memory)
|
||||
this->next = NULL;
|
||||
store_memory_free(pp, pool, this);
|
||||
}
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
/* Setup functions. */
|
||||
/* Cleanup when aborting a write or after storing the new file. */
|
||||
@@ -1488,7 +1498,9 @@ store_write_reset(png_store *ps)
|
||||
/* And make sure that all the memory has been freed - this will output
|
||||
* spurious errors in the case of memory corruption above, but this is safe.
|
||||
*/
|
||||
store_pool_delete(ps, &ps->write_memory_pool);
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
store_pool_delete(ps, &ps->write_memory_pool);
|
||||
# endif
|
||||
|
||||
store_freenew(ps);
|
||||
}
|
||||
@@ -1512,16 +1524,20 @@ set_store_for_write(png_store *ps, png_infopp ppi,
|
||||
store_write_reset(ps);
|
||||
safecat(ps->wname, sizeof ps->wname, 0, name);
|
||||
|
||||
/* Don't do the slow memory checks if doing a speed test. */
|
||||
if (ps->speed)
|
||||
/* Don't do the slow memory checks if doing a speed test, also if user
|
||||
* memory is not supported we can't do it anyway.
|
||||
*/
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (!ps->speed)
|
||||
ps->pwrite = png_create_write_struct_2(PNG_LIBPNG_VER_STRING,
|
||||
ps, store_error, store_warning, &ps->write_memory_pool,
|
||||
store_malloc, store_free);
|
||||
|
||||
else
|
||||
# endif
|
||||
ps->pwrite = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
||||
ps, store_error, store_warning);
|
||||
|
||||
else
|
||||
ps->pwrite = png_create_write_struct_2(PNG_LIBPNG_VER_STRING,
|
||||
ps, store_error, store_warning, &ps->write_memory_pool,
|
||||
store_malloc, store_free);
|
||||
|
||||
png_set_write_fn(ps->pwrite, ps, store_write, store_flush);
|
||||
|
||||
# ifdef PNG_SET_OPTION_SUPPORTED
|
||||
@@ -1569,8 +1585,10 @@ store_read_reset(png_store *ps)
|
||||
}
|
||||
# endif
|
||||
|
||||
/* Always do this to be safe. */
|
||||
store_pool_delete(ps, &ps->read_memory_pool);
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
/* Always do this to be safe. */
|
||||
store_pool_delete(ps, &ps->read_memory_pool);
|
||||
# endif
|
||||
|
||||
ps->current = NULL;
|
||||
ps->next = NULL;
|
||||
@@ -1630,14 +1648,16 @@ set_store_for_read(png_store *ps, png_infopp ppi, png_uint_32 id,
|
||||
* However, given that store_error works correctly in these circumstances
|
||||
* we don't ever expect NULL in this program.
|
||||
*/
|
||||
if (ps->speed)
|
||||
ps->pread = png_create_read_struct(PNG_LIBPNG_VER_STRING, ps,
|
||||
store_error, store_warning);
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (!ps->speed)
|
||||
ps->pread = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, ps,
|
||||
store_error, store_warning, &ps->read_memory_pool, store_malloc,
|
||||
store_free);
|
||||
|
||||
else
|
||||
ps->pread = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, ps,
|
||||
store_error, store_warning, &ps->read_memory_pool, store_malloc,
|
||||
store_free);
|
||||
else
|
||||
# endif
|
||||
ps->pread = png_create_read_struct(PNG_LIBPNG_VER_STRING, ps, store_error,
|
||||
store_warning);
|
||||
|
||||
if (ps->pread == NULL)
|
||||
{
|
||||
@@ -1933,9 +1953,11 @@ typedef struct png_modifier
|
||||
} png_modifier;
|
||||
|
||||
/* This returns true if the test should be stopped now because it has already
|
||||
* failed and it is running silently.
|
||||
* failed and it is running silently. It is not static simply to avoid having
|
||||
* to special case it on all the #ifdefs on which it depends.
|
||||
*/
|
||||
static int fail(png_modifier *pm)
|
||||
extern int fail(png_modifier *pm);
|
||||
/*static*/ int fail(png_modifier *pm)
|
||||
{
|
||||
return !pm->log && !pm->this.verbose && (pm->this.nerrors > 0 ||
|
||||
(pm->this.treat_warnings_as_errors && pm->this.nwarnings > 0));
|
||||
@@ -3109,8 +3131,10 @@ init_standard_palette(png_store *ps, png_structp pp, png_infop pi, int npalette,
|
||||
for (; i<256; ++i)
|
||||
tRNS[i] = 24;
|
||||
|
||||
if (j > 0)
|
||||
png_set_tRNS(pp, pi, tRNS, j, 0/*color*/);
|
||||
# ifdef PNG_WRITE_tRNS_SUPPORTED
|
||||
if (j > 0)
|
||||
png_set_tRNS(pp, pi, tRNS, j, 0/*color*/);
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3356,6 +3380,13 @@ transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX],
|
||||
*/
|
||||
#define DEPTH(bd) ((png_byte)(1U << (bd)))
|
||||
|
||||
/* This is just a helper for compiling on minimal systems with no write
|
||||
* interlacing support.
|
||||
*/
|
||||
#ifndef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
# define png_set_interlace_handling(a) (1)
|
||||
#endif
|
||||
|
||||
/* Make a standardized image given a an image colour type, bit depth and
|
||||
* interlace type. The standard images have a very restricted range of
|
||||
* rows and heights and are used for testing transforms rather than image
|
||||
@@ -3509,8 +3540,12 @@ make_transform_images(png_store *ps)
|
||||
{
|
||||
int interlace_type;
|
||||
|
||||
for (interlace_type = PNG_INTERLACE_NONE;
|
||||
interlace_type < PNG_INTERLACE_LAST; ++interlace_type)
|
||||
# ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
for (interlace_type = PNG_INTERLACE_NONE;
|
||||
interlace_type < PNG_INTERLACE_LAST; ++interlace_type)
|
||||
# else
|
||||
interlace_type = PNG_INTERLACE_NONE;
|
||||
# endif
|
||||
{
|
||||
char name[FILE_NAME_SIZE];
|
||||
|
||||
@@ -3666,7 +3701,9 @@ make_size_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
|
||||
int npasses = npasses_from_interlace_type(pp, interlace_type);
|
||||
png_uint_32 y;
|
||||
int pass;
|
||||
int nfilter = PNG_FILTER_VALUE_LAST;
|
||||
# ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
int nfilter = PNG_FILTER_VALUE_LAST;
|
||||
# endif
|
||||
png_byte image[16][SIZE_ROWMAX];
|
||||
|
||||
/* To help consistent error detection make the parts of this buffer
|
||||
@@ -3720,6 +3757,7 @@ make_size_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
|
||||
continue;
|
||||
}
|
||||
|
||||
# ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
/* Only get to here if the row has some pixels in it, set the
|
||||
* filters to 'all' for the very first row and thereafter to a
|
||||
* single filter. It isn't well documented, but png_set_filter
|
||||
@@ -3735,6 +3773,7 @@ make_size_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
|
||||
|
||||
if (nfilter-- == 0)
|
||||
nfilter = PNG_FILTER_VALUE_LAST-1;
|
||||
# endif
|
||||
|
||||
png_write_row(pp, row);
|
||||
}
|
||||
@@ -3802,8 +3841,10 @@ make_size(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type, int bdlo,
|
||||
width, height, 0);
|
||||
make_size_image(ps, colour_type, DEPTH(bdlo), PNG_INTERLACE_NONE,
|
||||
width, height, 1);
|
||||
# ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
make_size_image(ps, colour_type, DEPTH(bdlo), PNG_INTERLACE_ADAM7,
|
||||
width, height, 0);
|
||||
# endif
|
||||
make_size_image(ps, colour_type, DEPTH(bdlo), PNG_INTERLACE_ADAM7,
|
||||
width, height, 1);
|
||||
}
|
||||
@@ -3998,8 +4039,12 @@ make_errors(png_modifier* PNG_CONST pm, png_byte PNG_CONST colour_type,
|
||||
{
|
||||
int interlace_type;
|
||||
|
||||
for (interlace_type = PNG_INTERLACE_NONE;
|
||||
interlace_type < PNG_INTERLACE_LAST; ++interlace_type)
|
||||
# ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
for (interlace_type = PNG_INTERLACE_NONE;
|
||||
interlace_type < PNG_INTERLACE_LAST; ++interlace_type)
|
||||
# else
|
||||
interlace_type = PNG_INTERLACE_NONE;
|
||||
# endif
|
||||
{
|
||||
unsigned int test;
|
||||
char name[FILE_NAME_SIZE];
|
||||
@@ -4020,7 +4065,7 @@ make_errors(png_modifier* PNG_CONST pm, png_byte PNG_CONST colour_type,
|
||||
|
||||
return 1; /* keep going */
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_WARNINGS_SUPPORTED */
|
||||
|
||||
static void
|
||||
perform_error_test(png_modifier *pm)
|
||||
@@ -10224,10 +10269,11 @@ int main(int argc, char **argv)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else /* write not supported */
|
||||
#else /* write or low level APIs not supported */
|
||||
int main(void)
|
||||
{
|
||||
fprintf(stderr, "pngvalid: no write support in libpng, all tests skipped\n");
|
||||
fprintf(stderr,
|
||||
"pngvalid: no low level write support in libpng, all tests skipped\n");
|
||||
/* So the test is skipped: */
|
||||
return 77;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user