summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/examples/pngpixel.c2
-rw-r--r--contrib/gregbook/readpng.c4
-rw-r--r--contrib/libtests/makepng.c10
-rw-r--r--contrib/libtests/pngstest.c62
-rw-r--r--contrib/libtests/pngunknown.c2
-rw-r--r--contrib/libtests/pngvalid.c14
-rw-r--r--contrib/libtests/readpng.c4
-rwxr-xr-xcontrib/libtests/test-pngstest.sh24
-rwxr-xr-xcontrib/libtests/test-pngunknown.sh38
-rwxr-xr-xcontrib/libtests/test-pngvalid-full.sh21
-rwxr-xr-xcontrib/libtests/test-pngvalid-simple.sh30
-rw-r--r--contrib/libtests/timepng.c4
-rw-r--r--contrib/tools/cvtcolor.c2
-rw-r--r--contrib/tools/intgamma.sh2
-rw-r--r--contrib/tools/makesRGB.c2
-rw-r--r--contrib/tools/sRGB.h2
16 files changed, 78 insertions, 145 deletions
diff --git a/contrib/examples/pngpixel.c b/contrib/examples/pngpixel.c
index d82ef83d0..410476031 100644
--- a/contrib/examples/pngpixel.c
+++ b/contrib/examples/pngpixel.c
@@ -37,7 +37,7 @@ component(png_const_bytep row, png_uint_32 x, unsigned int c,
* bytes wide. Since the row fitted into memory, however, the following must
* work:
*/
- png_uint_32 bit_offset_hi = bit_depth * ((x >> 6) * channels + c);
+ png_uint_32 bit_offset_hi = bit_depth * ((x >> 6) * channels);
png_uint_32 bit_offset_lo = bit_depth * ((x & 0x3f) * channels + c);
row = (png_const_bytep)(((PNG_CONST png_byte (*)[8])row) + bit_offset_hi);
diff --git a/contrib/gregbook/readpng.c b/contrib/gregbook/readpng.c
index 0b75fac6d..f5e1fb1a4 100644
--- a/contrib/gregbook/readpng.c
+++ b/contrib/gregbook/readpng.c
@@ -215,6 +215,10 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
* libpng function */
if (setjmp(png_jmpbuf(png_ptr))) {
+ free(image_data);
+ image_data = NULL;
+ free(row_pointers);
+ row_pointers = NULL;
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return NULL;
}
diff --git a/contrib/libtests/makepng.c b/contrib/libtests/makepng.c
index 7f85db923..9f11b2964 100644
--- a/contrib/libtests/makepng.c
+++ b/contrib/libtests/makepng.c
@@ -2,7 +2,7 @@
*
* Copyright (c) 2013 John Cunningham Bowler
*
- * Last changed in libpng 1.6.0 [February 14, 2013]
+ * Last changed in libpng 1.6.1 [March 28, 2013]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -83,7 +83,7 @@
#include <math.h>
#include <errno.h>
-#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H)
+#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
# include <config.h>
#endif
@@ -440,7 +440,7 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
/* Palette with fixed color: the image rows are all 0 and the image width
* is 16.
*/
- memset(row, rowbytes, 0);
+ memset(row, 0, rowbytes);
}
else if (colors[0] == channels_of_type(color_type))
@@ -624,8 +624,8 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
gamma_table[0] = 0;
- for (i=0; i<255; ++i)
- gamma_table[i] = (png_byte)floor(pow(i/255.,conv) * 255 + 127.5);
+ for (i=1; i<255; ++i)
+ gamma_table[i] = (png_byte)floor(pow(i/255.,conv) * 255 + .5);
gamma_table[255] = 255;
}
diff --git a/contrib/libtests/pngstest.c b/contrib/libtests/pngstest.c
index c2a2b2b0d..35e7c8779 100644
--- a/contrib/libtests/pngstest.c
+++ b/contrib/libtests/pngstest.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2013 John Cunningham Bowler
*
- * Last changed in libpng 1.6.0 [February 14, 2013]
+ * Last changed in libpng 1.6.1 [March 28, 2013]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -22,7 +22,7 @@
#include <ctype.h>
#include <math.h>
-#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H)
+#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
# include <config.h>
#endif
@@ -62,6 +62,12 @@
# define aligncastconst(type, value) ((const void*)(value))
#endif /* __cplusplus */
+/* During parallel runs of pngstest each temporary file needs a unique name,
+ * this is used to permit uniqueness using a command line argument which can be
+ * up to 22 characters long.
+ */
+static char tmpf[23] = "TMP";
+
/* Generate random bytes. This uses a boring repeatable algorithm and it
* is implemented here so that it gives the same set of numbers on every
* architecture. It's a linear congruential generator (Knuth or Sedgewick
@@ -309,6 +315,7 @@ compare_16bit(int v1, int v2, int error_limit, int multiple_algorithms)
#define KEEP_GOING 32
#define ACCUMULATE 64
#define FAST_WRITE 128
+#define sRGB_16BIT 256
static void
print_opts(png_uint_32 opts)
@@ -329,6 +336,8 @@ print_opts(png_uint_32 opts)
printf(" --accumulate");
if (!(opts & FAST_WRITE)) /* --fast is currently the default */
printf(" --slow");
+ if (opts & sRGB_16BIT)
+ printf(" --sRGB-16bit");
}
#define FORMAT_NO_CHANGE 0x80000000 /* additional flag */
@@ -3020,6 +3029,10 @@ read_file(Image *image, png_uint_32 format, png_const_colorp background)
return logerror(image, "file init: ", image->file_name, "");
}
+ /* This must be set after the begin_read call: */
+ if (image->opts & sRGB_16BIT)
+ image->image.flags |= PNG_IMAGE_FLAG_16BIT_sRGB;
+
/* Have an initialized image with all the data we need plus, maybe, an
* allocated file (myfile) or buffer (mybuffer) that need to be freed.
*/
@@ -3198,7 +3211,7 @@ write_one_file(Image *output, Image *image, int convert_to_8bit)
static int counter = 0;
char name[32];
- sprintf(name, "TMP%d.png", ++counter);
+ sprintf(name, "%s%d.png", tmpf, ++counter);
if (png_image_write_to_file(&image->image, name, convert_to_8bit,
image->buffer+16, (png_int_32)image->stride, image->colormap))
@@ -3482,6 +3495,34 @@ main(int argc, char **argv)
opts &= ~KEEP_GOING;
else if (strcmp(arg, "--strict") == 0)
opts |= STRICT;
+ else if (strcmp(arg, "--sRGB-16bit") == 0)
+ opts |= sRGB_16BIT;
+ else if (strcmp(arg, "--linear-16bit") == 0)
+ opts &= ~sRGB_16BIT;
+ else if (strcmp(arg, "--tmpfile") == 0)
+ {
+ if (c+1 < argc)
+ {
+ if (strlen(argv[++c]) >= sizeof tmpf)
+ {
+ fflush(stdout);
+ fprintf(stderr, "%s: %s is too long for a temp file prefix\n",
+ argv[0], argv[c]);
+ exit(99);
+ }
+
+ /* Safe: checked above */
+ strcpy(tmpf, argv[c]);
+ }
+
+ else
+ {
+ fflush(stdout);
+ fprintf(stderr, "%s: %s requires a temporary file prefix\n",
+ argv[0], arg);
+ exit(99);
+ }
+ }
else if (strcmp(arg, "--touch") == 0)
{
if (c+1 < argc)
@@ -3492,7 +3533,7 @@ main(int argc, char **argv)
fflush(stdout);
fprintf(stderr, "%s: %s requires a file name argument\n",
argv[0], arg);
- exit(1);
+ exit(99);
}
}
else if (arg[0] == '+')
@@ -3500,7 +3541,7 @@ main(int argc, char **argv)
png_uint_32 format = formatof(arg+1);
if (format > FORMAT_COUNT)
- exit(1);
+ exit(99);
format_set(&formats, format);
}
@@ -3508,7 +3549,7 @@ main(int argc, char **argv)
{
fflush(stdout);
fprintf(stderr, "%s: unknown option: %s\n", argv[0], arg);
- exit(1);
+ exit(99);
}
else
{
@@ -3557,7 +3598,7 @@ main(int argc, char **argv)
buffer[4095] = 0;
fprintf(stderr, "%s...%s: file name too long\n", buffer,
buffer+(4096-32));
- exit(1);
+ exit(99);
}
}
@@ -3676,7 +3717,7 @@ main(int argc, char **argv)
{
fflush(stdout);
fprintf(stderr, "%s: write failed\n", touch);
- exit(1);
+ exit(99);
}
}
@@ -3684,7 +3725,7 @@ main(int argc, char **argv)
{
fflush(stdout);
fprintf(stderr, "%s: open failed\n", touch);
- exit(1);
+ exit(99);
}
}
@@ -3695,6 +3736,7 @@ main(int argc, char **argv)
int main(void)
{
fprintf(stderr, "pngstest: no read support in libpng, test skipped\n");
- return 0;
+ /* So the test is skipped: */
+ return 77;
}
#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */
diff --git a/contrib/libtests/pngunknown.c b/contrib/libtests/pngunknown.c
index 9d9acc0f7..9b8de34b4 100644
--- a/contrib/libtests/pngunknown.c
+++ b/contrib/libtests/pngunknown.c
@@ -1,7 +1,7 @@
/* pngunknown.c - test the read side unknown chunk handling
*
- * Last changed in libpng 1.6.0 [(PENDING RELEASE)]
+ * Last changed in libpng 1.6.0 [February 14, 2013]
* Copyright (c) 2013 Glenn Randers-Pehrson
* Written by John Cunningham Bowler
*
diff --git a/contrib/libtests/pngvalid.c b/contrib/libtests/pngvalid.c
index fae8e6f78..f36b1f8be 100644
--- a/contrib/libtests/pngvalid.c
+++ b/contrib/libtests/pngvalid.c
@@ -1,7 +1,7 @@
/* pngvalid.c - validate libpng by constructing then reading png files.
*
- * Last changed in libpng 1.6.0 [February 14, 2013]
+ * Last changed in libpng 1.6.1 [March 28, 2013]
* Copyright (c) 2013 Glenn Randers-Pehrson
* Written by John Cunningham Bowler
*
@@ -26,7 +26,7 @@
#include <signal.h>
#include <stdio.h>
-#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H)
+#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
# include <config.h>
#endif
@@ -1999,8 +1999,8 @@ static double digitize(PNG_CONST png_modifier *pm, double value,
}
#endif
-#if (defined PNG_READ_GAMMA_SUPPORTED) ||\
- (defined PNG_READ_RGB_TO_GRAY_SUPPORTED)
+#if defined(PNG_READ_GAMMA_SUPPORTED) ||\
+ defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
static double abserr(PNG_CONST png_modifier *pm, int in_depth, int out_depth)
{
/* Absolute error permitted in linear values - affected by the bit depth of
@@ -3357,7 +3357,7 @@ make_transform_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
#ifdef PNG_TEXT_SUPPORTED
-# if (defined PNG_READ_zTXt_SUPPORTED) && (defined PNG_WRITE_zTXt_SUPPORTED)
+# if defined(PNG_READ_zTXt_SUPPORTED) && defined(PNG_WRITE_zTXt_SUPPORTED)
# define TEXT_COMPRESSION PNG_TEXT_COMPRESSION_zTXt
# else
# define TEXT_COMPRESSION PNG_TEXT_COMPRESSION_NONE
@@ -8895,8 +8895,8 @@ static void perform_gamma_scale16_tests(png_modifier *pm)
}
#endif /* 16 to 8 bit conversion */
-#if defined PNG_READ_BACKGROUND_SUPPORTED ||\
- defined PNG_READ_ALPHA_MODE_SUPPORTED
+#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
+ defined(PNG_READ_ALPHA_MODE_SUPPORTED)
static void gamma_composition_test(png_modifier *pm,
PNG_CONST png_byte colour_type, PNG_CONST png_byte bit_depth,
PNG_CONST int palette_number,
diff --git a/contrib/libtests/readpng.c b/contrib/libtests/readpng.c
index 631325766..7ba46d0b9 100644
--- a/contrib/libtests/readpng.c
+++ b/contrib/libtests/readpng.c
@@ -2,7 +2,7 @@
*
* Copyright (c) 2013 John Cunningham Bowler
*
- * Last changed in libpng 1.6.0 [(PENDING RELEASE)]
+ * Last changed in libpng 1.6.1 [March 28, 2013]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -18,7 +18,7 @@
#include <stdio.h>
#include <string.h>
-#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H)
+#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
# include <config.h>
#endif
diff --git a/contrib/libtests/test-pngstest.sh b/contrib/libtests/test-pngstest.sh
deleted file mode 100755
index e977a5b50..000000000
--- a/contrib/libtests/test-pngstest.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh
-#
-# Run the simplified API tests
-err=0
-
-echo >> pngtest-log.txt
-echo "============ pngstest.sh ==============" >> pngtest-log.txt
-
-echo "Running test-pngstest.sh"
-for image in ${srcdir}/contrib/pngsuite/*.png
-do
- for opts in ""
- do
- if ./pngstest --strict --log "$@" $opts $image >>pngtest-log.txt 2>&1
- then
- echo " PASS: pngstest $opts $image"
- else
- echo " FAIL: pngstest $opts $image"
- err=1
- fi
- done
-done
-
-exit $err
diff --git a/contrib/libtests/test-pngunknown.sh b/contrib/libtests/test-pngunknown.sh
deleted file mode 100755
index 1a31864ae..000000000
--- a/contrib/libtests/test-pngunknown.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-#
-# Run the unknown API tests
-err=0
-image="${srcdir}/pngtest.png"
-#
-# stream 4 is used for the output of the shell, pngtest-log.txt gets all the
-# normal program output.
-exec 4>&1 1>>pngtest-log.txt 2>&1
-
-echo
-echo "============ test-pngunknown.sh =============="
-
-echo "Running test-pngunknown.sh" >&4
-
-for tests in \
- "discard default=discard"\
- "save default=save"\
- "if-safe default=if-safe"\
- "vpAg vpAg=if-safe"\
- "sTER sTER=if-safe"\
- "IDAT default=discard IDAT=save"\
- "sAPI bKGD=save cHRM=save gAMA=save all=discard iCCP=save sBIT=save sRGB=save"
-do
- set $tests
- test="$1"
- shift
-
- if ./pngunknown "$@" "$image" 4>&-
- then
- echo " PASS: test-pngunknown $test" >&4
- else
- echo " FAIL: test-pngunknown $test" >&4
- err=1
- fi
-done
-
-exit $err
diff --git a/contrib/libtests/test-pngvalid-full.sh b/contrib/libtests/test-pngvalid-full.sh
deleted file mode 100755
index f7d1b2b5d..000000000
--- a/contrib/libtests/test-pngvalid-full.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/sh
-#
-# Run a sequence of gamma tests quietly
-err=0
-
-echo >> pngtest-log.txt
-echo "============ pngvalid-full.sh ==============" >> pngtest-log.txt
-
-echo "Running test-pngvalid-full.sh"
-for gamma in threshold transform sbit 16-to-8 background alpha-mode "transform --expand16" "background --expand16" "alpha-mode --expand16"
-do
- if ./pngvalid "$@" --gamma-$gamma >> pngtest-log.txt 2>&1
- then
- echo " PASS: pngvalid" "$@" "--gamma-$gamma"
- else
- echo " FAIL: pngvalid" "$@" "--gamma-$gamma"
- err=1
- fi
-done
-
-exit $err
diff --git a/contrib/libtests/test-pngvalid-simple.sh b/contrib/libtests/test-pngvalid-simple.sh
deleted file mode 100755
index 7d4d9d83c..000000000
--- a/contrib/libtests/test-pngvalid-simple.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/sh
-#
-# Run a sequence of tests quietly, without the slow
-# gamma tests
-err=0
-
-echo >> pngtest-log.txt
-echo "============ pngvalid-simple.sh ==============" >> pngtest-log.txt
-echo "Running test-pngvalid-simple.sh"
-# The options to test are:
-#
-# standard tests with and without progressive reading and interlace
-# size images with and without progressive reading
-# transform tests (standard, non-interlaced only)
-#
-for opts in "--standard" "--standard --progressive-read" \
- "--standard --interlace" "--standard --progressive-read --interlace" \
- "--size" "--size --progressive-read" \
- "--transform"
-do
- if ./pngvalid "$@" $opts >> pngtest-log.txt 2>&1
- then
- echo " PASS: pngvalid" "$@" $opts
- else
- echo " FAIL: pngvalid" "$@" $opts
- err=1
- fi
-done
-
-exit $err
diff --git a/contrib/libtests/timepng.c b/contrib/libtests/timepng.c
index 1222708f8..523627f38 100644
--- a/contrib/libtests/timepng.c
+++ b/contrib/libtests/timepng.c
@@ -2,7 +2,7 @@
*
* Copyright (c) 2013 John Cunningham Bowler
*
- * Last changed in libpng 1.6.0 [February 14, 2013]
+ * Last changed in libpng 1.6.1 [March 28, 2013]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -22,7 +22,7 @@
#include <time.h>
-#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H)
+#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
# include <config.h>
#endif
diff --git a/contrib/tools/cvtcolor.c b/contrib/tools/cvtcolor.c
index 285325467..e6793c7d5 100644
--- a/contrib/tools/cvtcolor.c
+++ b/contrib/tools/cvtcolor.c
@@ -3,7 +3,7 @@
*
* Last changed in libpng 1.6.0 [February 14, 2013]
*
- * COPYRIGHT: Written by John Cunningham Bowler, 2012.
+ * COPYRIGHT: Written by John Cunningham Bowler, 2013.
* To the extent possible under law, the author has waived all copyright and
* related or neighboring rights to this work. This work is published from:
* United States.
diff --git a/contrib/tools/intgamma.sh b/contrib/tools/intgamma.sh
index e3219473f..41c5d6dd2 100644
--- a/contrib/tools/intgamma.sh
+++ b/contrib/tools/intgamma.sh
@@ -4,7 +4,7 @@
#
# Last changed in libpng 1.6.0 [February 14, 2013]
#
-# COPYRIGHT: Written by John Cunningham Bowler, 2012.
+# COPYRIGHT: Written by John Cunningham Bowler, 2013.
# To the extent possible under law, the author has waived all copyright and
# related or neighboring rights to this work. This work is published from:
# United States.
diff --git a/contrib/tools/makesRGB.c b/contrib/tools/makesRGB.c
index de9191e1d..e66c9f157 100644
--- a/contrib/tools/makesRGB.c
+++ b/contrib/tools/makesRGB.c
@@ -2,7 +2,7 @@
*
* Last changed in libpng 1.6.0 [February 14, 2013]
*
- * COPYRIGHT: Written by John Cunningham Bowler, 2012.
+ * COPYRIGHT: Written by John Cunningham Bowler, 2013.
* To the extent possible under law, the author has waived all copyright and
* related or neighboring rights to this work. This work is published from:
* United States.
diff --git a/contrib/tools/sRGB.h b/contrib/tools/sRGB.h
index 833f2305f..22c8f7c0e 100644
--- a/contrib/tools/sRGB.h
+++ b/contrib/tools/sRGB.h
@@ -3,7 +3,7 @@
*
* Last changed in libpng 1.6.0 [February 14, 2013]
*
- * COPYRIGHT: Written by John Cunningham Bowler, 2012.
+ * COPYRIGHT: Written by John Cunningham Bowler, 2013.
* To the extent possible under law, the author has waived all copyright and
* related or neighboring rights to this work. This work is published from:
* United States.