diff options
author | Glenn Randers-Pehrson <glennrp at users.sourceforge.net> | 2012-12-15 10:05:54 -0600 |
---|---|---|
committer | Glenn Randers-Pehrson <glennrp at users.sourceforge.net> | 2012-12-15 12:33:44 -0600 |
commit | ec1d13a1d4950f87264036056f516f3e479c300d (patch) | |
tree | 75d15e18d4f67e6b9306001b6cfe6b94b927d2c0 | |
parent | d9002f94cb541c97eac8220b13ae15c89428f9bb (diff) | |
download | libpng-ec1d13a1d4950f87264036056f516f3e479c300d.tar.gz |
[libpng17] Imported from libpng-1.7.0alpha01.tarv1.7.0alpha01
-rw-r--r-- | LICENSE | 4 | ||||
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | arm/arm_init.c | 16 | ||||
-rw-r--r-- | arm/filter_neon.S | 1 | ||||
-rw-r--r-- | contrib/tools/scale.c | 238 | ||||
-rw-r--r-- | libpng-manual.txt | 6 | ||||
-rw-r--r-- | libpng.3 | 14 | ||||
-rw-r--r-- | libpngpf.3 | 2 | ||||
-rw-r--r-- | png.5 | 2 | ||||
-rw-r--r-- | pngrutil.c | 12 | ||||
-rw-r--r-- | projects/vstudio/readme.txt | 2 | ||||
-rw-r--r-- | projects/vstudio/zlib.props | 2 | ||||
-rw-r--r-- | scripts/README.txt | 2 | ||||
-rw-r--r-- | scripts/pnglibconf.h.prebuilt | 2 | ||||
-rw-r--r-- | scripts/symbols.def | 1 |
15 files changed, 284 insertions, 22 deletions
@@ -10,7 +10,7 @@ this sentence. This code is released under the libpng license. -libpng versions 1.2.6, August 15, 2004, through 1.7.0alpha01, December 10, 2012, are +libpng versions 1.2.6, August 15, 2004, through 1.7.0alpha01, December 15, 2012, 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 -December 10, 2012 +December 15, 2012 @@ -1,4 +1,4 @@ -README for libpng version 1.7.0alpha01 - December 10, 2012 (shared library 17.0) +README for libpng version 1.7.0alpha01 - December 15, 2012 (shared library 17.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 6b0a925f2..6d19cf1b3 100644 --- a/arm/arm_init.c +++ b/arm/arm_init.c @@ -1,8 +1,9 @@ -/* filter_neon.S - NEON optimised filter functions +/* arm_init.c - NEON optimised filter functions * - * Copyright (c) 2011 Glenn Randers-Pehrson + * Copyright (c) 2012 Glenn Randers-Pehrson * Written by Mans Rullgard, 2011. + * Last changed in libpng 1.6.0 [(PENDING RELEASE)] * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer @@ -50,6 +51,17 @@ png_init_filter_functions_neon(png_structp pp, unsigned int bpp) 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 + * 'prefix' option to configure works: + * + * ./configure --with-libpng-prefix=foobar_ + * + * Verify you have got this right by running the above command, doing a build + * and examining pngprefix.h; it must contain a #define for every external + * function you add. (Notice that this happens automatically for the + * initialization function.) + */ pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_neon; if (bpp == 3) diff --git a/arm/filter_neon.S b/arm/filter_neon.S index 9ce04d3be..4aa500cd7 100644 --- a/arm/filter_neon.S +++ b/arm/filter_neon.S @@ -3,6 +3,7 @@ * * Copyright (c) 2011 Glenn Randers-Pehrson * Written by Mans Rullgard, 2011. + * Last changed in libpng 1.5.7 [December 15, 2011] * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer diff --git a/contrib/tools/scale.c b/contrib/tools/scale.c index 3b14c3114..6fe08675e 100644 --- a/contrib/tools/scale.c +++ b/contrib/tools/scale.c @@ -236,3 +236,241 @@ main(int argc, const char **argv) /* Just an exit code - the printout above lists the problem */ return err; } +/* Given a target range and a source range work out an expression to scale from + * the source to the target of the form: + * + * (number * mult + add)>>16 + * + * The command arguments are: + * + * scale target source + * + * and the program works out a pair of numbers, mult and add, that evaluate: + * + * number * target + * round( --------------- ) + * source + * + * exactly for number in the range 0..source + */ +#define _ISOC99_SOURCE 1 + +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <math.h> + +static double minerr; +static unsigned long minmult, minadd, minshift; +static long mindelta; + +static int +test(unsigned long target, unsigned long source, unsigned long mult, + long add, unsigned long shift, long delta) +{ + unsigned long i; + double maxerr = 0; + double rs = (double)target/source; + + for (i=0; i<=source; ++i) + { + unsigned long t = i*mult+add; + double err = fabs((t >> shift) - i*rs); + + if (err > minerr) + return 0; + + if (err > maxerr) + maxerr = err; + } + + if (maxerr < minerr) + { + minerr = maxerr; + minmult = mult; + minadd = add; + minshift = shift; + mindelta = delta; + } + + return maxerr < .5; +} + +static int +dotest(unsigned long target, unsigned long source, unsigned long mult, + long add, unsigned long shift, long delta, int print) +{ + if (test(target, source, mult, add, shift, delta)) + { + if (print & 4) + printf(" {%11lu,%6ld /* >>%lu */ }, /* %lu/%lu */\n", + mult, add, shift, target, source); + + else if (print & 2) + printf(" {%11lu,%6ld,%3lu }, /* %lu/%lu */\n", + mult, add, shift, target, source); + + else if (print) + printf("number * %lu/%lu = (number * %lu + %ld) >> %lu [delta %ld]\n", + target, source, mult, add, shift, delta); + + return 1; + } + + return 0; +} + +static int +find(unsigned long target, unsigned long source, int print, int fixshift) +{ + unsigned long shift = 0; + unsigned long shiftlim = 0; + + /* In the final math the sum is at most (source*mult+add) >> shift, so: + * + * source*mult+add < 1<<32 + * mult < (1<<32)/source + * + * but: + * + * mult = (target<<shift)/source + * + * so: + * + * (target<<shift) < (1<<32) + */ + if (fixshift < 0) + while ((target<<shiftlim) < 0x80000000U) ++shiftlim; + + else + shift = shiftlim = (unsigned long)fixshift; + + minerr = 1E8; + + for (; shift<=shiftlim; ++shift) + { + unsigned long mult = ((target<<shift) + (source>>1)) / source; + long delta; + long limit = 1; /* seems to be sufficient */ + long add, start, end; + + end = 1<<shift; + start = -end; + + for (add=start; add<=end; ++add) + if (dotest(target,source,mult,add,shift,0,print)) + return 1; + + for (delta=1; delta<=limit; ++delta) + { +# if 0 + fprintf(stderr, "%lu/%lu: shift %lu, delta %lu\n", target, source, + shift, delta); +# endif + + for (add=start; add<=end; ++add) + { + if (dotest(target, source, mult-delta, add, shift, -delta, print)) + return 1; + + if (dotest(target, source, mult+delta, add, shift, delta, print)) + return 1; + } + } + } + + if (print & 4) + printf(" {%11lu,%6ld /* >>%lu */ }, /* %lu/%lu ERROR: .5+%g*/\n", + minmult, minadd, minshift, target, source, minerr-.5); + + else if (print & 2) + printf(" {%11lu,%6ld,%3lu }, /* %lu/%lu ERROR: .5+%g*/\n", + minmult, minadd, minshift, target, source, minerr-.5); + + else if (print) + printf( + "number * %lu/%lu ~= (number * %lu + %ld) >> %lu +/-.5+%g [delta %ld]\n", + target, source, minmult, minadd, minshift, minerr-.5, mindelta); + + return 0; +} + +static void +usage(const char *prog) +{ + fprintf(stderr, + "usage: %s {--denominator|--maxshift|--code} target {source}\n" + " For each 'source' prints 'mult' and 'add' such that:\n\n" + " (number * mult + add) >> 16 = round(number*target/source)\n\n" + " for all integer values of number in the range 0..source.\n\n" + " --denominator: swap target and source (specify a single source first\n" + " and follow with multiple targets.)\n" + " --maxshift: find the lowest shift value that works for all the\n" + " repeated 'source' values\n" + " --code: output C code for array/structure initialization\n", + prog); + exit(1); +} + +int +main(int argc, const char **argv) +{ + int i, err = 0, maxshift = 0, firstsrc = 1, code = 0, denominator = 0; + unsigned long target, shift = 0; + + while (argc > 1) + { + if (strcmp(argv[firstsrc], "--maxshift") == 0) + { + maxshift = 1; + ++firstsrc; + } + + else if (strcmp(argv[firstsrc], "--code") == 0) + { + code = 1; + ++firstsrc; + } + + else if (strcmp(argv[firstsrc], "--denominator") == 0) + { + denominator = 1; + ++firstsrc; + } + + else + break; + } + + + if (argc < 2+firstsrc) + usage(argv[0]); + + target = strtoul(argv[firstsrc++], 0, 0); + if (target == 0) usage(argv[0]); + + for (i=firstsrc; i<argc; ++i) + { + unsigned long source = strtoul(argv[i], 0, 0); + + if (source == 0) usage(argv[0]); + + if (!find(denominator ? source : target, denominator ? target : source, + maxshift ? 0 : 1+code, -1)) + err = 1; + + if (minshift > shift) shift = minshift; + } + + if (maxshift) for (i=firstsrc; i<argc; ++i) + { + unsigned long source = strtoul(argv[i], 0, 0); + + if (!find(denominator ? source : target, denominator ? target : source, + code ? 4 : 1, shift)) + err = 1; + } + + /* Just an exit code - the printout above lists the problem */ + return err; +} diff --git a/libpng-manual.txt b/libpng-manual.txt index 33ae86bfa..6d3c93fc4 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.7.0alpha01 - December 10, 2012 + libpng version 1.7.0alpha01 - December 15, 2012 Updated and distributed by Glenn Randers-Pehrson <glennrp at users.sourceforge.net> Copyright (c) 1998-2011 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.7.0alpha01 - December 10, 2012 + libpng versions 0.97, January 1998, through 1.7.0alpha01 - December 15, 2012 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2011 Glenn Randers-Pehrson @@ -5126,7 +5126,7 @@ Other rules can be inferred by inspecting the libpng source. XVI. Y2K Compliance in libpng -December 10, 2012 +December 15, 2012 Since the PNG Development group is an ad-hoc body, we can't make an official declaration. @@ -1,4 +1,4 @@ -.TH LIBPNG 3 "December 10, 2012" +.TH LIBPNG 3 "December 15, 2012" .SH NAME libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0alpha01 .SH SYNOPSIS @@ -997,7 +997,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.7.0alpha01 - December 10, 2012 + libpng version 1.7.0alpha01 - December 15, 2012 Updated and distributed by Glenn Randers-Pehrson <glennrp at users.sourceforge.net> Copyright (c) 1998-2011 Glenn Randers-Pehrson @@ -1008,7 +1008,7 @@ libpng-manual.txt - A description on how to use and modify libpng Based on: - libpng versions 0.97, January 1998, through 1.7.0alpha01 - December 10, 2012 + libpng versions 0.97, January 1998, through 1.7.0alpha01 - December 15, 2012 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2011 Glenn Randers-Pehrson @@ -6124,7 +6124,7 @@ Other rules can be inferred by inspecting the libpng source. .SH XVI. Y2K Compliance in libpng -December 10, 2012 +December 15, 2012 Since the PNG Development group is an ad-hoc body, we can't make an official declaration. @@ -6393,7 +6393,7 @@ possible without all of you. Thanks to Frank J. T. Wojcik for helping with the documentation. -Libpng version 1.7.0alpha01 - December 10, 2012: +Libpng version 1.7.0alpha01 - December 15, 2012: Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc. Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net). @@ -6416,7 +6416,7 @@ this sentence. This code is released under the libpng license. -libpng versions 1.2.6, August 15, 2004, through 1.7.0alpha01, December 10, 2012, are +libpng versions 1.2.6, August 15, 2004, through 1.7.0alpha01, December 15, 2012, 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 @@ -6515,7 +6515,7 @@ certification mark of the Open Source Initiative. Glenn Randers-Pehrson glennrp at users.sourceforge.net -December 10, 2012 +December 15, 2012 .\" end of man page diff --git a/libpngpf.3 b/libpngpf.3 index 07d5b3350..01bff517d 100644 --- a/libpngpf.3 +++ b/libpngpf.3 @@ -1,4 +1,4 @@ -.TH LIBPNGPF 3 "December 10, 2012" +.TH LIBPNGPF 3 "December 15, 2012" .SH NAME libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0alpha01 (private functions) @@ -1,4 +1,4 @@ -.TH PNG 5 "December 10, 2012" +.TH PNG 5 "December 15, 2012" .SH NAME png \- Portable Network Graphics (PNG) format .SH DESCRIPTION diff --git a/pngrutil.c b/pngrutil.c index f46793ec7..86bf4cd82 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -3868,6 +3868,14 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row, static void png_init_filter_functions(png_structrp pp) + /* This function is called once for every PNG image to set the + * implementations required to reverse the filtering of PNG rows. Reversing + * the filter is the first transformation performed on the row data. It is + * performed in place, therefore an implementation can be selected based on + * the image pixel format. If the implementation depends on image width then + * take care to ensure that it works corretly if the image is interlaced - + * interlacing causes the actual row width to vary. + */ { unsigned int bpp = (pp->pixel_depth + 7) >> 3; @@ -3898,6 +3906,10 @@ void /* PRIVATE */ png_read_filter_row(png_structrp pp, png_row_infop row_info, png_bytep row, png_const_bytep prev_row, int filter) { + /* OPTIMIZATION: DO NOT MODIFY THIS FUNCTION, instead #define + * PNG_FILTER_OPTIMIZATIONS to a function that overrides the generic + * implementations. See png_init_filter_functions above. + */ if (pp->read_filter[0] == NULL) png_init_filter_functions(pp); if (filter > PNG_FILTER_VALUE_NONE && filter < PNG_FILTER_VALUE_LAST) diff --git a/projects/vstudio/readme.txt b/projects/vstudio/readme.txt index 779b9460a..688aefd2f 100644 --- a/projects/vstudio/readme.txt +++ b/projects/vstudio/readme.txt @@ -1,7 +1,7 @@ VisualStudio instructions -libpng version 1.7.0alpha01 - December 10, 2012 +libpng version 1.7.0alpha01 - December 15, 2012 Copyright (c) 1998-2010 Glenn Randers-Pehrson diff --git a/projects/vstudio/zlib.props b/projects/vstudio/zlib.props index d205e75f1..752f38121 100644 --- a/projects/vstudio/zlib.props +++ b/projects/vstudio/zlib.props @@ -2,7 +2,7 @@ <!-- * zlib.props - location of zlib source * - * libpng version 1.7.0alpha01 - December 10, 2012 + * libpng version 1.7.0alpha01 - December 15, 2012 * * Copyright (c) 1998-2011 Glenn Randers-Pehrson * diff --git a/scripts/README.txt b/scripts/README.txt index 7d2b023e3..8fc12515c 100644 --- a/scripts/README.txt +++ b/scripts/README.txt @@ -1,5 +1,5 @@ -Makefiles for libpng version 1.7.0alpha01 - December 10, 2012 +Makefiles for libpng version 1.7.0alpha01 - December 15, 2012 pnglibconf.h.prebuilt => Stores configuration settings makefile.linux => Linux/ELF makefile diff --git a/scripts/pnglibconf.h.prebuilt b/scripts/pnglibconf.h.prebuilt index 3b9436b29..5378c587d 100644 --- a/scripts/pnglibconf.h.prebuilt +++ b/scripts/pnglibconf.h.prebuilt @@ -3,7 +3,7 @@ /* pnglibconf.h - library build configuration */ -/* Libpng 1.7.0alpha01 - December 10, 2012 */ +/* Libpng 1.7.0alpha01 - December 15, 2012 */ /* Copyright (c) 1998-2012 Glenn Randers-Pehrson */ diff --git a/scripts/symbols.def b/scripts/symbols.def index 4a6537f54..538a9b8f8 100644 --- a/scripts/symbols.def +++ b/scripts/symbols.def @@ -28,7 +28,6 @@ EXPORTS png_write_info_before_PLTE @20 png_write_info @21 png_read_info @22 - png_convert_to_rfc1123 @23 png_convert_from_struct_tm @24 png_convert_from_time_t @25 png_set_expand @26 |