Changeset 1165
- Timestamp:
- Sep 15, 2015, 12:22:09 PM (10 years ago)
- Location:
- libpng/vendor/current
- Files:
-
- 16 added
- 66 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified libpng/vendor/current/ANNOUNCE ¶
r1059 r1165 1 Libpng 1.6.1 6 - December 22, 20141 Libpng 1.6.18 - July 23, 2015 2 2 3 3 This is a public release of libpng, intended for use in production codes. … … 8 8 "configure" script 9 9 10 libpng-1.6.1 6.tar.xz (LZMA-compressed, recommended)11 libpng-1.6.1 6.tar.gz10 libpng-1.6.18.tar.xz (LZMA-compressed, recommended) 11 libpng-1.6.18.tar.gz 12 12 13 13 Source files with CRLF line endings (for Windows), without the 14 14 "configure" script 15 15 16 lpng161 6.7z (LZMA-compressed, recommended)17 lpng161 6.zip16 lpng1618.7z (LZMA-compressed, recommended) 17 lpng1618.zip 18 18 19 19 Other information: 20 20 21 libpng-1.6.1 6-README.txt22 libpng-1.6.1 6-LICENSE.txt23 libpng-1.6.1 6-*.asc (armored detached GPG signatures)21 libpng-1.6.18-README.txt 22 libpng-1.6.18-LICENSE.txt 23 libpng-1.6.18-*.asc (armored detached GPG signatures) 24 24 25 Changes since the last public release (1.6.15): 26 Added ".align 2" to arm/filter_neon.S to support old GAS assemblers that 27 don't do alignment correctly. 28 Revised Makefile.am and scripts/*.dfn to work with MinGW/MSYS; 29 renamed scripts/*.dfn to scripts/*.c (Bob Friesenhahn and John Bowler). 30 Quiet a "comparison always true" warning in pngstest.c (John Bowler). 31 Restored a test on width that was removed from png.c at libpng-1.6.9 32 (Bug report by Alex Eubanks). 33 Fixed an overflow in png_combine_row with very wide interlaced images. 25 Changes since the last public release (1.6.17): 26 Removed PNG_SET_CHUNK_[CACHE|MALLOC]_LIMIT_SUPPORTED macros. They 27 have been combined with PNG_SET_USER_LIMITS_SUPPORTED (resolves 28 bug report by Andrew Church). 29 Fixed rgb_to_gray checks and added tRNS checks to pngvalid.c. This 30 fixes some arithmetic errors that caused some tests to fail on 31 some 32-bit platforms (Bug reports by Peter Breitenlohner [i686] 32 and Petr Gajdos [i586]). 33 Suppressed some warnings from the Borland C++ 5.5.1/5.82 compiler 34 (Bug report by Viktor Szaka'ts). 35 Replaced "unexpected" with an integer (0xabadca11) in pngset.c 36 where a long was expected, to avoid a compiler warning when PNG_DEBUG > 1. 37 Added contrib/examples/simpleover.c, to demonstrate how to handle 38 alpha compositing of multiple images, using the "simplified API" 39 and an example PNG generation tool, contrib/examples/genpng.c 40 (John Bowler). 41 PNG_RELEASE_BUILD replaces tests where the code depended on the build base 42 type and can be defined on the command line, allowing testing in beta 43 builds (John Bowler). 44 Avoid Coverity issue 80858 (REVERSE NULL) in pngtest.c 45 Avoid a harmless potential integer overflow in png_XYZ_from_xy() (Bug 46 report from Christopher Ferris). 47 Backport filter selection code from libpng-1.7.0beta51, to combine 48 sub_row, up_row, avg_row, and paeth_row into try_row and tst_row. 49 Changed png_voidcast(), etc., to voidcast(), etc., in contrib/tools/pngfix.c 50 to avoid confusion with the libpng private macros. 51 Fixed old cut&paste bug in the weighted filter selection code in 52 pngwutil.c, introduced in libpng-0.95, March 1997. 53 Removed WRITE_WEIGHTED_FILTERED code, to save a few kbytes of the 54 compiled library size. It never worked properly and as far as we can 55 tell, no one uses it. The png_set_filter_heuristics() and 56 png_set_filter_heuristics_fixed() APIs are retained but deprecated 57 and do nothing. 58 Quieted some Coverity issues in pngfix.c, png-fix-itxt.c, pngvalid.c, 59 pngstest.c, and pngimage.c. Most seem harmless, but png-fix-itxt 60 would only work with iTXt chunks with length 255 or less. 61 Removed non-working progressive reader 'skip' function. This 62 function has apparently never been used. It was implemented 63 to support back-door modification of png_struct in libpng-1.4.x 64 but (because it does nothing and cannot do anything) was apparently 65 never tested (John Bowler). 66 Fixed cexcept.h in which GCC 5 now reports that one of the auto 67 variables in the Try macro needs to be volatile to prevent value 68 being lost over the setjmp (John Bowler). 69 Added #ifdef's to contrib/examples programs so people don't try 70 to compile them without the minimum required support enabled 71 (suggested by Flavio Medeiros). 72 Eliminated the final two Coverity defects (insecure temporary file 73 handling in contrib/libtests/pngstest.c; possible overflow of 74 unsigned char in contrib/tools/png-fix-itxt.c). To use the "secure" 75 file handling, define PNG_USE_MKSTEMP, otherwise "tmpfile()" will 76 be used. 77 Removed some unused WEIGHTED_FILTER macros from pngstruct.h 78 Replaced arbitrary use of 'extern' with #define PNG_LINKAGE_*. To 79 preserve API compatibility, the new defines all default to "extern" 80 (requested by Jan Nijtmans). 81 Belatedly added Mans Rullgard and James Yu to the list of Contributing 82 Authors. 34 83 35 84 Send comments/corrections/commendations to png-mng-implement at lists.sf.net -
TabularUnified libpng/vendor/current/CHANGES ¶
r1059 r1165 1 1 #if 0 2 2 CHANGES - changes for libpng 3 3 4 Version 0.2 4 version 0.1 [March 29, 1995] 5 initial work-in-progress release 6 7 version 0.2 [April 1, 1995] 5 8 added reader into png.h 6 9 fixed small problems in stub file 7 10 8 Version 0.3 11 version 0.3 [April 8, 1995] 9 12 added pull reader 10 13 split up pngwrite.c to several files … … 15 18 interfaced with zlib 0.5 16 19 added K&R support 17 added check for 64 KB blocks for 16 -bit machines18 19 Version 0.4 20 added check for 64 KB blocks for 16 bit machines 21 22 version 0.4 [April 26, 1995] 20 23 cleaned up code and commented code 21 24 simplified time handling into png_time … … 28 31 split transformations into pngrtran.c and pngwtran.c 29 32 30 Version 0.5 33 version 0.5 [April 30, 1995] 31 34 interfaced with zlib 0.8 32 35 fixed many reading and writing bugs 33 36 saved using 3 spaces instead of tabs 34 37 35 Version 0.6 38 version 0.6 [May 1, 1995] 39 first beta release 36 40 added png_large_malloc() and png_large_free() 37 41 added png_size_t … … 39 43 added png_start_read_image() 40 44 41 Version 0.7 45 version 0.7 [June 24, 1995] 42 46 cleaned up lots of bugs 43 47 finished dithering and other stuff … … 45 49 changed name from pnglib to libpng 46 50 47 Version 0.71 [June, 1995]51 version 0.71 [June 26, 1995] 48 52 changed pngtest.png for zlib 0.93 49 53 fixed error in libpng.txt and example.c 50 54 51 Version 0.8 55 version 0.8 [August 20, 1995] 52 56 cleaned up some bugs 53 57 added png_set_filler() … … 92 96 added callbacks for read/write and warning/error functions 93 97 94 Version 0.89 [Ju ly, 1996]98 Version 0.89 [June 5, 1996] 95 99 Added new initialization API to make libpng work better with shared libs 96 100 we now have png_create_read_struct(), png_create_write_struct(), … … 119 123 Updated documentation to reflect new API 120 124 125 Version 0.89c [June 17, 1996] 126 Bug fixes. 127 121 128 Version 0.90 [January, 1997] 122 129 Made CRC errors/warnings on critical and ancillary chunks configurable … … 159 166 Added experimental filter selection weighting (Greg Roelofs) 160 167 Removed old png_set_rgbx() and png_set_xrgb() functions that have been 161 168 obsolete for about 2 years now (use png_set_filler() instead) 162 169 Added macros to read 16- and 32-bit ints directly from buffer, to be 163 170 used only on those systems that support it (namely PowerPC and 680x0) … … 441 448 Version 1.0.3a [August 12, 1999] 442 449 Added check for PNG_READ_INTERLACE_SUPPORTED in pngread.c; issue a warning 443 450 if an attempt is made to read an interlaced image when it's not supported. 444 451 Added check if png_ptr->trans is defined before freeing it in pngread.c 445 452 Modified the Y2K statement to include versions back to version 0.71 … … 449 456 Changed "dworkin.wustl.edu" to "ccrc.wustl.edu" in various documents. 450 457 Changed (float)red and (float)green to (double)red, (double)green 451 458 in png_set_rgb_to_gray() to avoid "promotion" problems in AIX. 452 459 Fixed a bug in pngconf.h that omitted <stdio.h> when PNG_DEBUG==0 (K Bracey). 453 460 Reformatted libpng.3 and libpngpf.3 with proper fonts (script by J. vanZandt). … … 492 499 Added a demo read_user_transform_fn that examines the row filters in pngtest.c 493 500 494 Version 1.0.4 [September 24, 1999 ]501 Version 1.0.4 [September 24, 1999, not distributed publicly] 495 502 Define PNG_ALWAYS_EXTERN in pngconf.h if __STDC__ is defined 496 503 Delete #define PNG_INTERNAL and include "png.h" from pngasmrd.h … … 519 526 a helpful compiler error if an old png.h is found in the search path. 520 527 Changed type of png_user_transform_depth|channels from int to png_byte. 528 Added "Libpng is OSI Certified Open Source Software" statement to png.h 521 529 522 530 Version 1.0.4d [October 6, 1999] … … 905 913 Added png_free(png_ptr, key) two places in pngpread.c to stop memory leaks. 906 914 Changed PNG_NO_STDIO to PNG_NO_CONSOLE_IO, several places in pngrutil.c and 907 915 pngwutil.c. 908 916 Changed PNG_EXPORT_VAR to use PNG_IMPEXP, in pngconf.h. 909 917 Removed unused "#include <assert.h>" from png.c … … 913 921 Version 1.0.8beta2 [July 10, 2000] 914 922 Added project files to the wince directory and made further revisions 915 923 of pngtest.c, pngrio.c, and pngwio.c in support of WindowsCE. 916 924 917 925 Version 1.0.8beta3 [July 11, 2000] 918 926 Only set the PNG_FLAG_FREE_TRNS or PNG_FREE_TRNS flag in png_handle_tRNS() 919 920 927 for indexed-color input files to avoid potential double-freeing trans array 928 under some unusual conditions; problem was introduced in version 1.0.6f. 921 929 Further revisions to pngtest.c and files in the wince subdirectory. 922 930 … … 1090 1098 Version 1.2.0beta4 [June 23, 2001] 1091 1099 Check for missing profile length field in iCCP chunk and free chunk_data 1092 1100 in case of truncated iCCP chunk. 1093 1101 Bumped shared-library number to 3 in makefile.sgi and makefile.sggcc 1094 1102 Bumped dll-number from 2 to 3 in makefile.cygwin 1095 1103 Revised contrib/gregbook/rpng*-x.c to avoid a memory leak and to exit cleanly 1096 1104 if user attempts to run it on an 8-bit display. 1097 1105 Updated contrib/gregbook 1098 1106 Use png_malloc instead of png_zalloc to allocate palette in pngset.c 1099 1107 Updated makefile.ibmc 1100 1108 Added some typecasts to eliminate gcc 3.0 warnings. Changed prototypes 1101 1109 of png_write_oFFS width and height from png_uint_32 to png_int_32. 1102 1110 Updated example.c 1103 1111 Revised prototypes for png_debug_malloc and png_debug_free in pngtest.c … … 1107 1115 Revised makefile.gcmmx 1108 1116 Revised pnggccrd.c to conditionally compile some thread-unsafe code only 1109 1117 when PNG_THREAD_UNSAFE_OK is defined. 1110 1118 Added tests to prevent pngwutil.c from writing a bKGD or tRNS chunk with 1111 1119 value exceeding 2^bit_depth-1 1112 1120 Revised makefile.sgi and makefile.sggcc 1113 1121 Replaced calls to fprintf(stderr,...) with png_warning() in pnggccrd.c … … 1450 1458 1451 1459 Version 1.0.16rc1 and 1.2.6rc1 [August 4, 2004] 1452 Fixed buffer overflow vulnerability in png_handle_tRNS() 1453 Fixed integer arithmetic overflow vulnerability in png_read_png(). 1460 Fixed buffer overflow vulnerability (CVE-2004-0597) in png_handle_tRNS(). 1461 Fixed NULL dereference vulnerability (CVE-2004-0598) in png_handle_iCCP(). 1462 Fixed integer overflow vulnerability (CVE-2004-0599) in png_read_png(). 1454 1463 Fixed some harmless bugs in png_handle_sBIT, etc, that would cause 1455 1464 duplicate chunk types to go undetected. … … 1494 1503 Version 1.0.16rc5 and 1.2.6rc5 [August 10, 2004] 1495 1504 Moved "PNG_HANDLE_CHUNK_*" macros out of PNG_ASSEMBLER_CODE_SUPPORTED 1496 1505 section of png.h where they were inadvertently placed in version rc3. 1497 1506 1498 1507 Version 1.2.6 and 1.0.16 [August 15, 2004] … … 2103 2112 Put a call to png_check_chunk_name() in png_read_chunk_header(). 2104 2113 Revised png_check_chunk_name() to reject a name with a lowercase 3rd byte. 2105 Removed two calls to png_check_chunk_name() occur ing later in the process.2114 Removed two calls to png_check_chunk_name() occurring later in the process. 2106 2115 Define PNG_NO_ERROR_NUMBERS by default in pngconf.h 2107 2116 … … 2326 2335 Eliminated PNG_LEGACY_SUPPORTED code. 2327 2336 Moved the various unknown chunk macro definitions outside of the 2328 2337 PNG_READ|WRITE_ANCILLARY_CHUNK_SUPPORTED blocks. 2329 2338 2330 2339 Version 1.4.0beta65 [June 26, 2009] … … 4526 4535 the need to call png_set_keep_unknown_chunks() when writing them. 4527 4536 Avoid dereferencing NULL pointer possibly returned from 4528 4537 png_create_write_struct() (Andrew Church). 4529 4538 4530 4539 Version 1.6.3beta05 [May 9, 2013] … … 5115 5124 Version 1.6.16rc01 [December 21, 2014] 5116 5125 Restored a test on width that was removed from png.c at libpng-1.6.9 5117 (Bug report by Alex Eubanks ).5126 (Bug report by Alex Eubanks, CVE-2015-0973). 5118 5127 5119 5128 Version 1.6.16rc02 [December 21, 2014] … … 5121 5130 5122 5131 Version 1.6.16rc03 [December 21, 2014] 5123 Fixed an overflow in png_combine_row with very wide interlaced images. 5132 Fixed an overflow in png_combine_row() with very wide interlaced images 5133 (Bug report and fix by John Bowler, CVE-2014-9495). 5124 5134 5125 5135 Version 1.6.16 [December 22, 2014] 5136 No changes. 5137 5138 Version 1.6.17beta01 [January 29, 2015] 5139 Removed duplicate PNG_SAFE_LIMITS_SUPPORTED handling from pngconf.h 5140 Corrected the width limit calculation in png_check_IHDR(). 5141 Removed user limits from pngfix. Also pass NULL pointers to 5142 png_read_row to skip the unnecessary row de-interlace stuff. 5143 Added testing of png_set_packing() to pngvalid.c 5144 Regenerated configure scripts in the *.tar distributions with libtool-2.4.4 5145 Implement previously untested cases of libpng transforms in pngvalid.c 5146 Fixed byte order in 2-byte filler, in png_do_read_filler(). 5147 Made the check for out-of-range values in png_set_tRNS() detect 5148 values that are exactly 2^bit_depth, and work on 16-bit platforms. 5149 Merged some parts of libpng-1.6.17beta01 and libpng-1.7.0beta47. 5150 Added #ifndef __COVERITY__ where needed in png.c, pngrutil.c and 5151 pngset.c to avoid warnings about dead code. 5152 Added "& 0xff" to many instances of expressions that are typecast 5153 to (png_byte), to avoid Coverity warnings. 5154 5155 Version 1.6.17beta02 [February 7, 2015] 5156 Work around one more Coverity-scan dead-code warning. 5157 Do not build png_product2() when it is unused. 5158 5159 Version 1.6.17beta03 [February 17, 2015] 5160 Display user limits in the output from pngtest. 5161 Eliminated the PNG_SAFE_LIMITS macro and restored the 1-million-column 5162 and 1-million-row default limits in pnglibconf.dfa, that can be reset 5163 by the user at build time or run time. This provides a more robust 5164 defense against DOS and as-yet undiscovered overflows. 5165 5166 Version 1.6.17beta04 [February 21, 2015] 5167 Added PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED macro, on by default. 5168 Allow user to call png_get_IHDR() with NULL arguments (Reuben Hawkins). 5169 Rebuilt configure scripts with automake-1.15 and libtool-2.4.6 5170 5171 Version 1.6.17beta05 [February 25, 2015] 5172 Restored compiling of png_reciprocal2 with PNG_NO_16BIT. 5173 5174 Version 1.6.17beta06 [February 27, 2015] 5175 Moved png_set_filter() prototype into a PNG_WRITE_SUPPORTED block 5176 of png.h. 5177 Avoid runtime checks when converting integer to png_byte with 5178 Visual Studio (Sergey Kosarevsky) 5179 5180 Version 1.6.17rc01 [March 4, 2015] 5181 No changes. 5182 5183 Version 1.6.17rc02 [March 9, 2015] 5184 Removed some comments that the configure script did not handle 5185 properly from scripts/pnglibconf.dfa and pnglibconf.h.prebuilt. 5186 Free the unknown_chunks structure even when it contains no data. 5187 5188 Version 1.6.17rc03 [March 12, 2015] 5189 Updated CMakeLists.txt to add OSX framework, change YES/NO to ON/OFF 5190 for consistency, and remove some useless tests (Alexey Petruchik). 5191 5192 Version 1.6.17rc04 [March 16, 2015] 5193 Remove pnglibconf.h, pnglibconf.c, and pnglibconf.out instead of 5194 pnglibconf.* in "make clean" (Cosmin). 5195 Fix bug in calculation of maxbits, in png_write_sBIT, introduced 5196 in libpng-1.6.17beta01 (John Bowler). 5197 5198 Version 1.6.17rc05 [March 21, 2015] 5199 Define PNG_FILTER_* and PNG_FILTER_VALUE_* in png.h even when WRITE 5200 is not supported (John Bowler). This fixes an error introduced in 5201 libpng-1.6.17beta06. 5202 Reverted "& 0xff" additions of version 1.6.17beta01. Libpng passes 5203 the Coverity scan without them. 5204 5205 Version 1.6.17rc06 [March 23, 2015] 5206 Remove pnglibconf.dfn and pnglibconf.pre with "make clean". 5207 Reformatted some "&0xff" instances to "& 0xff". 5208 Fixed simplified 8-bit-linear to sRGB alpha. The calculated alpha 5209 value was wrong. It's not clear if this affected the final stored 5210 value; in the obvious code path the upper and lower 8-bits of the 5211 alpha value were identical and the alpha was truncated to 8-bits 5212 rather than dividing by 257 (John Bowler). 5213 5214 Version 1.6.17 [March 26, 2015] 5215 No changes. 5216 5217 Version 1.6.18beta01 [April 1, 2015] 5218 Removed PNG_SET_CHUNK_[CACHE|MALLOC]_LIMIT_SUPPORTED macros. They 5219 have been combined with PNG_SET_USER_LIMITS_SUPPORTED (resolves 5220 bug report by Andrew Church). 5221 Fixed rgb_to_gray checks and added tRNS checks to pngvalid.c. This 5222 fixes some arithmetic errors that caused some tests to fail on 5223 some 32-bit platforms (Bug reports by Peter Breitenlohner [i686] 5224 and Petr Gajdos [i586]). 5225 5226 Version 1.6.18beta02 [April 26, 2015] 5227 Suppressed some warnings from the Borland C++ 5.5.1/5.82 compiler 5228 (Bug report by Viktor Szaka'ts). 5229 5230 Version 1.6.18beta03 [May 6, 2015] 5231 Replaced "unexpected" with an integer (0xabadca11) in pngset.c 5232 where a long was expected, to avoid a compiler warning when PNG_DEBUG > 1. 5233 Added contrib/examples/simpleover.c, to demonstrate how to handle 5234 alpha compositing of multiple images, using the "simplified API" 5235 and an example PNG generation tool, contrib/examples/genpng.c 5236 (John Bowler). 5237 5238 Version 1.6.18beta04 [May 20, 2015] 5239 PNG_RELEASE_BUILD replaces tests where the code depended on the build base 5240 type and can be defined on the command line, allowing testing in beta 5241 builds (John Bowler). 5242 Avoid Coverity issue 80858 (REVERSE NULL) in pngtest.c PNG_DEBUG builds. 5243 Avoid a harmless potential integer overflow in png_XYZ_from_xy() (Bug 5244 report from Christopher Ferris). 5245 5246 Version 1.6.18beta05 [May 31, 2015] 5247 Backport filter selection code from libpng-1.7.0beta51, to combine 5248 sub_row, up_row, avg_row, and paeth_row into try_row and tst_row. 5249 Changed png_voidcast(), etc., to voidcast(), etc., in contrib/tools/pngfix.c 5250 to avoid confusion with the libpng private macros. 5251 Fixed old cut&paste bug in the weighted filter selection code in 5252 pngwutil.c, introduced in libpng-0.95, March 1997. 5253 5254 Version 1.6.18beta06 [June 1, 2015] 5255 Removed WRITE_WEIGHTED_FILTERED code, to save a few kbytes of the 5256 compiled library size. It never worked properly and as far as we can 5257 tell, no one uses it. The png_set_filter_heuristics() and 5258 png_set_filter_heuristics_fixed() APIs are retained but deprecated 5259 and do nothing. 5260 5261 Version 1.6.18beta07 [June 6, 2015] 5262 Removed non-working progressive reader 'skip' function. This 5263 function has apparently never been used. It was implemented 5264 to support back-door modification of png_struct in libpng-1.4.x 5265 but (because it does nothing and cannot do anything) was apparently 5266 never tested (John Bowler). 5267 Fixed cexcept.h in which GCC 5 now reports that one of the auto 5268 variables in the Try macro needs to be volatile to prevent value 5269 being lost over the setjmp (John Bowler). 5270 Fixed NO_WRITE_FILTER and -Wconversion build breaks (John Bowler). 5271 Fix g++ build breaks (John Bowler). 5272 Quieted some Coverity issues in pngfix.c, png-fix-itxt.c, pngvalid.c, 5273 pngstest.c, and pngimage.c. Most seem harmless, but png-fix-itxt 5274 would only work with iTXt chunks with length 255 or less. 5275 Added #ifdef's to contrib/examples programs so people don't try 5276 to compile them without the minimum required support enabled 5277 (suggested by Flavio Medeiros). 5278 5279 Version 1.6.18beta08 [June 30, 2015] 5280 Eliminated the final two Coverity defects (insecure temporary file 5281 handling in contrib/libtests/pngstest.c; possible overflow of 5282 unsigned char in contrib/tools/png-fix-itxt.c). To use the "secure" 5283 file handling, define PNG_USE_MKSTEMP, otherwise "tmpfile()" will 5284 be used. 5285 Removed some unused WEIGHTED_FILTER macros from png.h and pngstruct.h 5286 5287 Version 1.6.18beta09 [July 5, 2015] 5288 Removed some useless typecasts from contrib/tools/png-fix-itxt.c 5289 Fixed a new signed-unsigned comparison in pngrtran.c (Max Stepin). 5290 Replaced arbitrary use of 'extern' with #define PNG_LINKAGE_*. To 5291 preserve API compatibility, the new defines all default to "extern" 5292 (requested by Jan Nijtmans). 5293 5294 Version 1.6.18rc01 [July 9, 2015] 5295 Belatedly added Mans Rullgard and James Yu to the list of Contributing 5296 Authors. 5297 5298 Version 1.6.18rc02 [July 12, 2015] 5299 Restored unused FILTER_HEURISTIC macros removed at libpng-1.6.18beta08 5300 to png.h to avoid compatibility warnings. 5301 5302 Version 1.6.18rc03 [July 15, 2015] 5303 Minor changes to the man page 5304 5305 Version 1.6.18 [July 23, 2015] 5126 5306 No changes. 5127 5307 … … 5133 5313 5134 5314 Glenn R-P 5315 #endif -
TabularUnified libpng/vendor/current/CMakeLists.txt ¶
r1059 r1165 1 1 # CMakeLists.txt 2 2 3 # Copyright (C) 2007-201 4Glenn Randers-Pehrson3 # Copyright (C) 2007-2015 Glenn Randers-Pehrson 4 4 5 5 # This code is released under the libpng license. … … 17 17 set(PNGLIB_MAJOR 1) 18 18 set(PNGLIB_MINOR 6) 19 set(PNGLIB_RELEASE 1 6)19 set(PNGLIB_RELEASE 18) 20 20 set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR}) 21 21 set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE}) … … 31 31 ) 32 32 if(NOT M_LIBRARY) 33 message(STATUS 34 "math library 'libm' not found - floating point support disabled") 33 message(STATUS "math lib 'libm' not found; floating point support disabled") 35 34 endif() 36 35 else() … … 40 39 41 40 # COMMAND LINE OPTIONS 42 if(DEFINED PNG_SHARED) 43 option(PNG_SHARED "Build shared lib" ${PNG_SHARED}) 44 else() 45 option(PNG_SHARED "Build shared lib" ON) 46 endif() 47 if(DEFINED PNG_STATIC) 48 option(PNG_STATIC "Build static lib" ${PNG_STATIC}) 49 else() 50 option(PNG_STATIC "Build static lib" ON) 51 endif() 52 53 option(PNG_TESTS "Build libpng tests" YES) 41 option(PNG_SHARED "Build shared lib" ON) 42 option(PNG_STATIC "Build static lib" ON) 43 option(PNG_TESTS "Build libpng tests" ON) 54 44 55 45 # Many more configuration options could be added here 56 option(PNG_DEBUG "Build with debug output" NO) 57 option(PNGARG "Disable ANSI-C prototypes" NO) 46 option(PNG_FRAMEWORK "Build OS X framework" OFF) 47 option(PNG_DEBUG "Build with debug output" OFF) 48 option(PNGARG "Disable ANSI-C prototypes" OFF) 58 49 59 50 # SET LIBNAME … … 135 126 136 127 if(PNG_STATIC) 137 # does not work without changing name128 # does not work without changing name 138 129 set(PNG_LIB_NAME_STATIC ${PNG_LIB_NAME}_static) 139 130 add_library(${PNG_LIB_NAME_STATIC} STATIC ${libpng_sources}) … … 146 137 endif() 147 138 139 if(PNG_FRAMEWORK) 140 set(PNG_LIB_NAME_FRAMEWORK ${PNG_LIB_NAME}_framework) 141 add_library(${PNG_LIB_NAME_FRAMEWORK} SHARED ${libpng_sources}) 142 list(APPEND PNG_LIB_TARGETS ${PNG_LIB_NAME_FRAMEWORK}) 143 set_target_properties(${PNG_LIB_NAME_FRAMEWORK} PROPERTIES 144 FRAMEWORK TRUE 145 FRAMEWORK_VERSION ${PNGLIB_VERSION} 146 MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PNGLIB_MAJOR}.${PNGLIB_MINOR} 147 MACOSX_FRAMEWORK_BUNDLE_VERSION ${PNGLIB_VERSION} 148 MACOSX_FRAMEWORK_IDENTIFIER org.libpng.libpng 149 XCODE_ATTRIBUTE_INSTALL_PATH "@rpath" 150 PUBLIC_HEADER "${libpng_public_hdrs}" 151 OUTPUT_NAME png) 152 target_link_libraries(${PNG_LIB_NAME_FRAMEWORK} ${ZLIB_LIBRARY} ${M_LIBRARY}) 153 endif() 154 148 155 if(NOT PNG_LIB_TARGETS) 149 156 message(SEND_ERROR 150 157 "No library variant selected to build. " 151 "Please enable at least one of the following options: PNG_STATIC, PNG_SHARED") 158 "Please enable at least one of the following options: " 159 " PNG_STATIC, PNG_SHARED, PNG_FRAMEWORK") 152 160 endif() 153 161 … … 254 262 if(PNG_SHARED) 255 263 set_target_properties(${PNG_LIB_NAME} PROPERTIES 256 # VERSION 16.${PNGLIB_RELEASE}.1.6.1 6264 # VERSION 16.${PNGLIB_RELEASE}.1.6.18 257 265 VERSION 16.${PNGLIB_RELEASE}.0 258 266 SOVERSION 16 … … 285 293 RUNTIME DESTINATION bin 286 294 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 287 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) 295 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 296 FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}) 288 297 289 298 if(PNG_SHARED) -
TabularUnified libpng/vendor/current/INSTALL ¶
r1059 r1165 18 18 XIII. Removing unwanted object code 19 19 XIV. Changes to the build and configuration of libpng in libpng-1.5.x 20 XV. Configuring libpng for multiprocessing20 XV. Setjmp/longjmp issues 21 21 XVI. Other sources of information about libpng 22 22 … … 190 190 191 191 You will want to look into zconf.h to tell zlib (and thus libpng) that 192 it cannot allocate more th en 64K at a time. Even if you can, the memory192 it cannot allocate more than 64K at a time. Even if you can, the memory 193 193 won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K. 194 194 … … 363 363 that were used to build libpng. 364 364 365 XV. Configuring libpng for multiprocessing365 XV. Setjmp/longjmp issues 366 366 367 367 Libpng uses setjmp()/longjmp() for error handling. Unfortunately setjmp() … … 376 376 in your pnglibconf.h or pngusr.h. 377 377 378 Starting with libpng-1.6.0, the library included a "simplified API". 379 This requires setjmp/longjmp, so you must either build the library 380 with PNG_SETJMP_SUPPORTED defined, or with PNG_SIMPLIFIED_READ_SUPPORTED 381 and PNG_SIMPLIFIED_WRITE_SUPPORTED undefined. 382 378 383 XVI. Other sources of information about libpng: 379 384 -
TabularUnified libpng/vendor/current/LICENSE ¶
r1059 r1165 11 11 This code is released under the libpng license. 12 12 13 libpng versions 1.2.6, August 15, 2004, through 1.6.16, December 22, 2014, are 14 Copyright (c) 2004, 2006-2014 Glenn Randers-Pehrson, and are 15 distributed according to the same disclaimer and license as libpng-1.2.5 16 with the following individual added to the list of Contributing Authors 17 18 Cosmin Truta 19 20 libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are 21 Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are 13 libpng versions 1.0.7, July 1, 2000, through 1.6.18, July 23, 2015, are 14 Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, and are 22 15 distributed according to the same disclaimer and license as libpng-1.0.6 23 with the following individuals added to the list of Contributing Authors 16 with the following individuals added to the list of Contributing Authors: 24 17 25 18 Simon-Pierre Cadieux 26 19 Eric S. Raymond 20 Mans Rullgard 21 Cosmin Truta 27 22 Gilles Vollant 23 James Yu 28 24 29 25 and with the following additions to the disclaimer: … … 37 33 38 34 libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are 39 Copyright (c) 1998 , 1999 Glenn Randers-Pehrson, and are40 distributed according to the same disclaimer and license as libpng-0.96, 41 with the followingindividuals added to the list of Contributing Authors:35 Copyright (c) 1998-2000 Glenn Randers-Pehrson, and are distributed according 36 to the same disclaimer and license as libpng-0.96, with the following 37 individuals added to the list of Contributing Authors: 42 38 43 39 Tom Lane … … 46 42 47 43 libpng versions 0.89, June 1996, through 0.96, May 1997, are 48 Copyright (c) 1996 , 1997 Andreas Dilger49 Distributed according to the same disclaimer and license as libpng-0.88,44 Copyright (c) 1996-1997 Andreas Dilger, and are 45 distributed according to the same disclaimer and license as libpng-0.88, 50 46 with the following individuals added to the list of Contributing Authors: 51 47 … … 58 54 59 55 libpng versions 0.5, May 1995, through 0.88, January 1996, are 60 Copyright (c) 1995 ,1996 Guy Eric Schalnat, Group 42, Inc.56 Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. 61 57 62 58 For the purposes of this copyright and license, "Contributing Authors" … … 81 77 to the following restrictions: 82 78 83 1. The origin of this source code must not be misrepresented.79 1. The origin of this source code must not be misrepresented. 84 80 85 2. Altered versions must be plainly marked as such and must not86 be misrepresented as being the original source.81 2. Altered versions must be plainly marked as such and must not 82 be misrepresented as being the original source. 87 83 88 3. This Copyright notice may not be removed or altered from any89 source or altered source distribution.84 3. This Copyright notice may not be removed or altered from any 85 source or altered source distribution. 90 86 91 87 The Contributing Authors and Group 42, Inc. specifically permit, without … … 95 91 appreciated. 96 92 97 98 93 A "png_get_copyright" function is available, for convenient use in "about" 99 94 boxes and the like: 100 95 101 printf("%s", png_get_copyright(NULL));96 printf("%s", png_get_copyright(NULL)); 102 97 103 98 Also, the PNG logo (in PNG format, of course) is supplied in the 104 99 files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). 105 100 106 Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a 107 certification mark of the Open Source Initiative. 101 Libpng is OSI Certified Open Source Software. OSI Certified Open Source is 102 a certification mark of the Open Source Initiative. OSI has not addressed 103 the additional disclaimers inserted at version 1.0.7. 108 104 109 105 Glenn Randers-Pehrson 110 106 glennrp at users.sourceforge.net 111 December 22, 2014 107 July 23, 2015 -
TabularUnified libpng/vendor/current/Makefile.am ¶
r1059 r1165 130 130 CMakeLists.txt example.c libpng-manual.txt 131 131 132 SCRIPT_CLEANFILES=scripts/*.out scripts/*.chk scripts/pnglibconf.c132 SCRIPT_CLEANFILES=scripts/*.out scripts/*.chk 133 133 134 134 CLEANFILES= *.tf? pngout.png libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc \ 135 135 libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config libpng.vers libpng.sym \ 136 check.new pnglibconf.* pngprefix.h symbols.new pngtest-log.txt \ 136 check.new pnglibconf.h pngprefix.h symbols.new pngtest-log.txt \ 137 pnglibconf.out pnglibconf.c pnglibconf.pre pnglibconf.dfn \ 137 138 $(SCRIPT_CLEANFILES) 138 139 -
TabularUnified libpng/vendor/current/README ¶
r1059 r1165 1 README for libpng version 1.6.1 6 - December 22, 2014(shared library 16.0)1 README for libpng version 1.6.18 - July 23, 2015 (shared library 16.0) 2 2 See the note about version numbers near the top of png.h 3 3 … … 135 135 136 136 Please do not send suggestions on how to change PNG. We have 137 been discussing PNG for nineteenyears now, and it is official and137 been discussing PNG for twenty years now, and it is official and 138 138 finished. If you have suggestions for libpng, however, I'll 139 139 gladly listen. Even if your suggestion is not used immediately, -
TabularUnified libpng/vendor/current/autogen.sh ¶
r922 r1165 74 74 # 75 75 # The autotools generated files: 76 libpng_autotools_files="Makefile.in aclocal.m4 config.guess config.h.in\ 77 config.sub configure depcomp install-sh ltmain.sh missing test-driver" 76 libpng_autotools_files="Makefile.in aclocal.m4 config.guess config.h.in 77 config.h.in~ config.sub configure depcomp install-sh ltmain.sh missing\ 78 test-driver" 78 79 # 79 80 # Files generated by versions of configue >2.68 or automake >1.13 (i.e. later -
TabularUnified libpng/vendor/current/compile ¶
r922 r1165 4 4 scriptversion=2012-10-14.11; # UTC 5 5 6 # Copyright (C) 1999-201 3Free Software Foundation, Inc.6 # Copyright (C) 1999-2014 Free Software Foundation, Inc. 7 7 # Written by Tom Tromey <tromey@cygnus.com>. 8 8 # -
TabularUnified libpng/vendor/current/configure.ac ¶
r1059 r1165 19 19 dnl Version number stuff here: 20 20 21 AC_INIT([libpng],[1.6.1 6],[png-mng-implement@lists.sourceforge.net])21 AC_INIT([libpng],[1.6.18],[png-mng-implement@lists.sourceforge.net]) 22 22 AC_CONFIG_MACRO_DIR([scripts]) 23 23 … … 40 40 dnl stop configure from automagically running automake 41 41 42 PNGLIB_VERSION=1.6.1 642 PNGLIB_VERSION=1.6.18 43 43 PNGLIB_MAJOR=1 44 44 PNGLIB_MINOR=6 45 PNGLIB_RELEASE=1 645 PNGLIB_RELEASE=18 46 46 47 47 dnl End of version number stuff -
TabularUnified libpng/vendor/current/contrib/arm-neon/README ¶
r922 r1165 2 2 -------------------------------------------- 3 3 4 Detection of the ability to exe xcute ARM NEON on an ARM processor requires4 Detection of the ability to execute ARM NEON on an ARM processor requires 5 5 operating system support. (The information is not available in user mode.) 6 6 -
TabularUnified libpng/vendor/current/contrib/examples/iccfrompng.c ¶
r922 r1165 26 26 27 27 #include <png.h> 28 29 #if defined(PNG_READ_SUPPORTED) && defined(PNG_STDIO_SUPPORTED) && \ 30 defined (PNG_iCCP_SUPPORTED) 31 28 32 29 33 static int verbose = 1; … … 179 183 return extracted == 0; 180 184 } 185 #endif /* READ && STDIO && iCCP */ -
TabularUnified libpng/vendor/current/contrib/examples/pngpixel.c ¶
r922 r1165 28 28 #include "../../png.h" 29 29 30 #if defined(PNG_READ_SUPPORTED) && defined(PNG_SEQUENTIAL_READ_SUPPORTED) 31 30 32 /* Return component 'c' of pixel 'x' from the given row. */ 31 33 static unsigned int … … 367 369 return result; 368 370 } 371 #endif /* READ && SEQUENTIAL_READ */ -
TabularUnified libpng/vendor/current/contrib/examples/pngtopng.c ¶
r922 r1165 21 21 */ 22 22 #include "../../png.h" 23 #if defined(PNG_SIMPLIFIED_READ_SUPPORTED) && \ 24 defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) 23 25 24 26 int main(int argc, const char **argv) … … 91 93 return result; 92 94 } 95 #endif /* READ && WRITE */ -
TabularUnified libpng/vendor/current/contrib/libtests/pngimage.c ¶
r1059 r1165 1 1 /* pngimage.c 2 2 * 3 * Copyright (c) 201 4John Cunningham Bowler3 * Copyright (c) 2015 John Cunningham Bowler 4 4 * 5 * Last changed in libpng 1.6.1 0 [March 6, 2014]5 * Last changed in libpng 1.6.18 [July 23, 2015] 6 6 * 7 7 * This code is released under the libpng license. … … 1121 1121 int b; 1122 1122 1123 case 16: /* Two bytes per component, bi t-endian */1124 for (b = (bpp >> 4); b > 0; )1123 case 16: /* Two bytes per component, big-endian */ 1124 for (b = (bpp >> 4); b > 0; --b) 1125 1125 { 1126 1126 unsigned int sig = (unsigned int)(0xffff0000 >> sig_bits[b]); -
TabularUnified libpng/vendor/current/contrib/libtests/pngstest.c ¶
r1059 r1165 2 2 * pngstest.c 3 3 * 4 * Copyright (c) 2013-201 4John Cunningham Bowler4 * Copyright (c) 2013-2015 John Cunningham Bowler 5 5 * 6 * Last changed in libpng 1.6.1 6 [December 22, 2014]6 * Last changed in libpng 1.6.18 [July 23, 2015] 7 7 * 8 8 * This code is released under the libpng license. … … 616 616 if (image->tmpfile_name[0] != 0 && (image->opts & KEEP_TMPFILES) == 0) 617 617 { 618 remove(image->tmpfile_name);618 (void)remove(image->tmpfile_name); 619 619 image->tmpfile_name[0] = 0; 620 620 } … … 2829 2829 else if (y >= b->image.colormap_entries) 2830 2830 { 2831 if (( a->opts & ACCUMULATE) == 0)2831 if ((b->opts & ACCUMULATE) == 0) 2832 2832 { 2833 2833 char pindex[9]; … … 3176 3176 if (cb > 0) 3177 3177 { 3178 #ifndef __COVERITY__ 3178 3179 if ((unsigned long int)cb <= (size_t)~(size_t)0) 3180 #endif 3179 3181 { 3180 3182 png_bytep b = voidcast(png_bytep, malloc((size_t)cb)); … … 3244 3246 if (image->opts & USE_STDIO) 3245 3247 { 3248 #ifndef PNG_USE_MKSTEMP 3246 3249 FILE *f = tmpfile(); 3247 3250 #else 3251 /* Experimental. Coverity says tmpfile() is insecure because it 3252 * generates predictable names. 3253 * 3254 * It is possible to satisfy Coverity by using mkstemp(); however, 3255 * any platform supporting mkstemp() undoubtedly has a secure tmpfile() 3256 * implementation as well, and doesn't need the fix. Note that 3257 * the fix won't work on platforms that don't support mkstemp(). 3258 * 3259 * https://www.securecoding.cert.org/confluence/display/c/ 3260 * FIO21-C.+Do+not+create+temporary+files+in+shared+directories 3261 * says that most historic implementations of tmpfile() provide 3262 * only a limited number of possible temporary file names 3263 * (usually 26) before file names are recycled. That article also 3264 * provides a secure solution that unfortunately depends upon mkstemp(). 3265 */ 3266 char tmpfile[] = "pngstest-XXXXXX"; 3267 int filedes; 3268 FILE *f; 3269 umask(0177); 3270 filedes = mkstemp(tmpfile); 3271 if (filedes < 0) 3272 f = NULL; 3273 else 3274 { 3275 f = fdopen(filedes,"w+"); 3276 /* Hide the filename immediately and ensure that the file does 3277 * not exist after the program ends 3278 */ 3279 (void) unlink(tmpfile); 3280 } 3281 #endif 3282 3248 3283 if (f != NULL) 3249 3284 { … … 3589 3624 3590 3625 /* Safe: checked above */ 3591 str cpy(tmpf, argv[c]);3626 strncpy(tmpf, argv[c], sizeof (tmpf)-1); 3592 3627 } 3593 3628 -
TabularUnified libpng/vendor/current/contrib/libtests/pngunknown.c ¶
r922 r1165 1243 1243 return 77; 1244 1244 } 1245 #endif /* SET_UNKNOWN_CHUNKS && READ */1245 #endif /* SET_UNKNOWN_CHUNKS && READ */ -
TabularUnified libpng/vendor/current/contrib/libtests/pngvalid.c ¶
r1059 r1165 2 2 /* pngvalid.c - validate libpng by constructing then reading png files. 3 3 * 4 * Last changed in libpng 1.6.1 4 [October 23, 2014]5 * Copyright (c) 2014 Glenn Randers-Pehrson4 * Last changed in libpng 1.6.18 [July 23, 2015] 5 * Copyright (c) 2014-2015 Glenn Randers-Pehrson 6 6 * Written by John Cunningham Bowler 7 7 * … … 259 259 } 260 260 261 #if def PNG_READ_SUPPORTED261 #if defined PNG_READ_SUPPORTED || defined PNG_WRITE_tRNS_SUPPORTED 262 262 static void 263 263 randomize(void *pv, size_t size) … … 268 268 269 269 #define RANDOMIZE(this) randomize(&(this), sizeof (this)) 270 270 #endif /* READ || WRITE_tRNS */ 271 272 #ifdef PNG_READ_SUPPORTED 271 273 static unsigned int 272 274 random_mod(unsigned int max) … … 279 281 } 280 282 281 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED 283 #if (defined PNG_READ_RGB_TO_GRAY_SUPPORTED) ||\ 284 (defined PNG_READ_FILLER_SUPPORTED) 282 285 static int 283 286 random_choice(void) … … 295 298 * simply records whether pngvalid did the interlace itself or whether it 296 299 * was done by libpng. Width and height must be less than 256. 'palette' is an 297 * index of the palette to use for formats with a palette (0 otherwise.) 300 * index of the palette to use for formats with a palette otherwise a boolean 301 * indicating if a tRNS chunk was generated. 298 302 */ 299 303 #define FILEID(col, depth, palette, interlace, width, height, do_interlace) \ … … 304 308 #define DEPTH_FROM_ID(id) ((png_byte)(((id) >> 3) & 0x1fU)) 305 309 #define PALETTE_FROM_ID(id) (((id) >> 8) & 0x1f) 306 #define INTERLACE_FROM_ID(id) (( int)(((id) >> 13) & 0x3))310 #define INTERLACE_FROM_ID(id) ((png_byte)(((id) >> 13) & 0x3)) 307 311 #define DO_INTERLACE_FROM_ID(id) ((int)(((id)>>15) & 1)) 308 312 #define WIDTH_FROM_ID(id) (((id)>>16) & 0xff) … … 316 320 { 317 321 pos = safecat(buffer, bufsize, pos, colour_types[colour_type]); 318 if ( npalette > 0)322 if (colour_type == 3) /* must have a palette */ 319 323 { 320 324 pos = safecat(buffer, bufsize, pos, "["); … … 322 326 pos = safecat(buffer, bufsize, pos, "]"); 323 327 } 328 329 else if (npalette != 0) 330 pos = safecat(buffer, bufsize, pos, "+tRNS"); 331 324 332 pos = safecat(buffer, bufsize, pos, " "); 325 333 pos = safecatn(buffer, bufsize, pos, bit_depth); … … 378 386 static int 379 387 next_format(png_bytep colour_type, png_bytep bit_depth, 380 unsigned int* palette_number, int no_low_depth_gray)388 unsigned int* palette_number, int low_depth_gray, int tRNS) 381 389 { 382 390 if (*bit_depth == 0) 383 391 { 384 392 *colour_type = 0; 385 if (no_low_depth_gray) 393 if (low_depth_gray) 394 *bit_depth = 1; 395 else 386 396 *bit_depth = 8; 387 else388 *bit_depth = 1;389 397 *palette_number = 0; 390 398 return 1; 391 399 } 392 400 393 if (*colour_type == 3) 394 { 395 /* Add multiple palettes for colour type 3. */ 396 if (++*palette_number < PALETTE_COUNT(*bit_depth)) 401 if (*colour_type < 4/*no alpha channel*/) 402 { 403 /* Add multiple palettes for colour type 3, one image with tRNS 404 * and one without for other non-alpha formats: 405 */ 406 unsigned int pn = ++*palette_number; 407 png_byte ct = *colour_type; 408 409 if (((ct == 0/*GRAY*/ || ct/*RGB*/ == 2) && tRNS && pn < 2) || 410 (ct == 3/*PALETTE*/ && pn < PALETTE_COUNT(*bit_depth))) 397 411 return 1; 398 412 413 /* No: next bit depth */ 399 414 *palette_number = 0; 400 415 } … … 441 456 static unsigned int 442 457 sample(png_const_bytep row, png_byte colour_type, png_byte bit_depth, 443 png_uint_32 x, unsigned int sample_index )458 png_uint_32 x, unsigned int sample_index, int swap16, int littleendian) 444 459 { 445 460 png_uint_32 bit_index, result; … … 470 485 471 486 else if (bit_depth > 8) 472 return (result << 8) + *++row; 473 474 /* Less than 8 bits per sample. */ 487 { 488 if (swap16) 489 return (*++row << 8) + result; 490 else 491 return (result << 8) + *++row; 492 } 493 494 /* Less than 8 bits per sample. By default PNG has the big end of 495 * the egg on the left of the screen, but if littleendian is set 496 * then the big end is on the right. 497 */ 475 498 bit_index &= 7; 476 return (result >> (8-bit_index-bit_depth)) & ((1U<<bit_depth)-1); 499 500 if (!littleendian) 501 bit_index = 8-bit_index-bit_depth; 502 503 return (result >> bit_index) & ((1U<<bit_depth)-1); 477 504 } 478 505 #endif /* PNG_READ_TRANSFORMS_SUPPORTED */ … … 1293 1320 */ 1294 1321 if (ps->current == NULL) 1322 { 1295 1323 store_log(ps, ps->pread, "no current stream for palette", 1); 1324 return NULL; 1325 } 1296 1326 1297 1327 /* The result may be null if there is no palette. */ … … 1566 1596 else 1567 1597 # endif 1568 ps->pwrite = png_create_write_struct( png_get_libpng_ver(NULL),1598 ps->pwrite = png_create_write_struct(PNG_LIBPNG_VER_STRING, 1569 1599 ps, store_error, store_warning); 1570 1600 … … 1947 1977 /* Run tests on reading with a combination of transforms, */ 1948 1978 unsigned int test_transform :1; 1979 unsigned int test_tRNS :1; /* Includes tRNS images */ 1949 1980 1950 1981 /* When to use the use_input_precision option, this controls the gamma … … 1977 2008 unsigned int test_gamma_expand16 :1; 1978 2009 unsigned int test_exhaustive :1; 2010 2011 /* Whether or not to run the low-bit-depth grayscale tests. This fail on 2012 * gamma images in some cases because of gross inaccuracies in the grayscale 2013 * gamma handling for low bit depth. 2014 */ 2015 unsigned int test_lbg :1; 2016 unsigned int test_lbg_gamma_threshold :1; 2017 unsigned int test_lbg_gamma_transform :1; 2018 unsigned int test_lbg_gamma_sbit :1; 2019 unsigned int test_lbg_gamma_composition :1; 1979 2020 1980 2021 unsigned int log :1; /* Log max error */ … … 2030 2071 pm->test_size = 0; 2031 2072 pm->test_transform = 0; 2073 # ifdef PNG_WRITE_tRNS_SUPPORTED 2074 pm->test_tRNS = 1; 2075 # else 2076 pm->test_tRNS = 0; 2077 # endif 2032 2078 pm->use_input_precision = 0; 2033 2079 pm->use_input_precision_sbit = 0; … … 2042 2088 pm->test_gamma_alpha_mode = 0; 2043 2089 pm->test_gamma_expand16 = 0; 2090 pm->test_lbg = 1; 2091 pm->test_lbg_gamma_threshold = 1; 2092 pm->test_lbg_gamma_transform = 1; 2093 pm->test_lbg_gamma_sbit = 1; 2094 pm->test_lbg_gamma_composition = 1; 2044 2095 pm->test_exhaustive = 0; 2045 2096 pm->log = 0; … … 3173 3224 tRNS[i] = 24; 3174 3225 3175 # ifdef PNG_WRITE_tRNS_SUPPORTED3226 # ifdef PNG_WRITE_tRNS_SUPPORTED 3176 3227 if (j > 0) 3177 3228 png_set_tRNS(pp, pi, tRNS, j, 0/*color*/); 3178 # endif 3179 } 3180 } 3229 # endif 3230 } 3231 } 3232 3233 #ifdef PNG_WRITE_tRNS_SUPPORTED 3234 static void 3235 set_random_tRNS(png_structp pp, png_infop pi, PNG_CONST png_byte colour_type, 3236 PNG_CONST int bit_depth) 3237 { 3238 /* To make this useful the tRNS color needs to match at least one pixel. 3239 * Random values are fine for gray, including the 16-bit case where we know 3240 * that the test image contains all the gray values. For RGB we need more 3241 * method as only 65536 different RGB values are generated. 3242 */ 3243 png_color_16 tRNS; 3244 const png_uint_16 mask = (png_uint_16)((1U << bit_depth)-1); 3245 3246 RANDOMIZE(tRNS); 3247 3248 if (colour_type & 2/*RGB*/) 3249 { 3250 if (bit_depth == 8) 3251 { 3252 tRNS.blue = tRNS.red ^ tRNS.green; 3253 tRNS.red &= mask; 3254 tRNS.green &= mask; 3255 tRNS.blue &= mask; 3256 } 3257 3258 else /* bit_depth == 16 */ 3259 { 3260 tRNS.green = (png_uint_16)(tRNS.red * 257); 3261 tRNS.blue = (png_uint_16)(tRNS.green * 17); 3262 } 3263 } 3264 3265 else 3266 tRNS.gray &= mask; 3267 3268 png_set_tRNS(pp, pi, NULL, 0, &tRNS); 3269 } 3270 #endif 3181 3271 3182 3272 /* The number of passes is related to the interlace type. There was no libpng … … 3513 3603 init_standard_palette(ps, pp, pi, 1U << bit_depth, 1/*do tRNS*/); 3514 3604 3605 # ifdef PNG_WRITE_tRNS_SUPPORTED 3606 else if (palette_number) 3607 set_random_tRNS(pp, pi, colour_type, bit_depth); 3608 # endif 3609 3515 3610 png_write_info(pp, pi); 3516 3611 … … 3586 3681 3587 3682 static void 3588 make_transform_images(png_ store *ps)3683 make_transform_images(png_modifier *pm) 3589 3684 { 3590 3685 png_byte colour_type = 0; … … 3593 3688 3594 3689 /* This is in case of errors. */ 3595 safecat(p s->test, sizeof ps->test, 0, "make standard images");3690 safecat(pm->this.test, sizeof pm->this.test, 0, "make standard images"); 3596 3691 3597 3692 /* Use next_format to enumerate all the combinations we test, including 3598 * generating multiple low bit depth palette images. 3599 */ 3600 while (next_format(&colour_type, &bit_depth, &palette_number, 0)) 3693 * generating multiple low bit depth palette images. Non-A images (palette 3694 * and direct) are created with and without tRNS chunks. 3695 */ 3696 while (next_format(&colour_type, &bit_depth, &palette_number, 1, 1)) 3601 3697 { 3602 3698 int interlace_type; … … 3609 3705 standard_name(name, sizeof name, 0, colour_type, bit_depth, 3610 3706 palette_number, interlace_type, 0, 0, 0); 3611 make_transform_image( ps, colour_type, bit_depth, palette_number,3707 make_transform_image(&pm->this, colour_type, bit_depth, palette_number, 3612 3708 interlace_type, name); 3613 3709 } … … 4005 4101 Try 4006 4102 { 4007 png_structp pp;4103 volatile png_structp pp; 4008 4104 png_infop pi; 4009 4105 … … 4264 4360 png_byte blue_sBIT; 4265 4361 png_byte alpha_sBIT; 4266 int interlace_type; 4362 png_byte interlace_type; 4363 png_byte filler; /* Output has a filler */ 4267 4364 png_uint_32 id; /* Calculated file ID */ 4268 4365 png_uint_32 w; /* Width of image */ … … 4274 4371 int do_interlace; /* Do interlacing internally */ 4275 4372 int is_transparent; /* Transparency information was present. */ 4373 int has_tRNS; /* color type GRAY or RGB with a tRNS chunk. */ 4276 4374 int speed; /* Doing a speed test */ 4277 4375 int use_update_info;/* Call update_info, not start_image */ … … 4606 4704 dp->transparent.red = dp->transparent.green = dp->transparent.blue = 4607 4705 trans_color->gray; 4608 dp-> is_transparent= 1;4706 dp->has_tRNS = 1; 4609 4707 break; 4610 4708 … … 4613 4711 dp->transparent.green = trans_color->green; 4614 4712 dp->transparent.blue = trans_color->blue; 4615 dp-> is_transparent= 1;4713 dp->has_tRNS = 1; 4616 4714 break; 4617 4715 … … 4651 4749 { 4652 4750 /* Record cbRow now that it can be found. */ 4653 dp->pixel_size = bit_size(pp, png_get_color_type(pp, pi), 4654 png_get_bit_depth(pp, pi)); 4751 { 4752 png_byte ct = png_get_color_type(pp, pi); 4753 png_byte bd = png_get_bit_depth(pp, pi); 4754 4755 if (bd >= 8 && (ct == PNG_COLOR_TYPE_RGB || ct == PNG_COLOR_TYPE_GRAY) && 4756 dp->filler) 4757 ct |= 4; /* handle filler as faked alpha channel */ 4758 4759 dp->pixel_size = bit_size(pp, ct, bd); 4760 } 4655 4761 dp->bit_width = png_get_image_width(pp, pi) * dp->pixel_size; 4656 4762 dp->cbRow = png_get_rowbytes(pp, pi); … … 5292 5398 unsigned int red, green, blue, alpha; /* For non-palette images. */ 5293 5399 unsigned int palette_index; /* For a palette image. */ 5294 png_byte colour_type; /* As in the spec. */ 5295 png_byte bit_depth; /* Defines bit size in row */ 5296 png_byte sample_depth; /* Scale of samples */ 5297 int have_tRNS; /* tRNS chunk may need processing */ 5400 png_byte colour_type; /* As in the spec. */ 5401 png_byte bit_depth; /* Defines bit size in row */ 5402 png_byte sample_depth; /* Scale of samples */ 5403 unsigned int have_tRNS :1; /* tRNS chunk may need processing */ 5404 unsigned int swap_rgb :1; /* RGB swapped to BGR */ 5405 unsigned int alpha_first :1; /* Alpha at start, not end */ 5406 unsigned int alpha_inverted :1; /* Alpha channel inverted */ 5407 unsigned int mono_inverted :1; /* Gray channel inverted */ 5408 unsigned int swap16 :1; /* Byte swap 16-bit components */ 5409 unsigned int littleendian :1; /* High bits on right */ 5410 unsigned int sig_bits :1; /* Pixel shifted (sig bits only) */ 5298 5411 5299 5412 /* For checking the code calculates double precision floating point values … … 5303 5416 * channel is stored. This sBIT value is folded in to the stored error value 5304 5417 * at the end of the application of the transforms to the pixel. 5418 * 5419 * If sig_bits is set above the red, green, blue and alpha values have been 5420 * scaled so they only contain the significant bits of the component values. 5305 5421 */ 5306 5422 double redf, greenf, bluef, alphaf; … … 5311 5427 /* Shared utility function, see below. */ 5312 5428 static void 5313 image_pixel_setf(image_pixel *this, unsigned int max) 5314 { 5315 this->redf = this->red / (double)max; 5316 this->greenf = this->green / (double)max; 5317 this->bluef = this->blue / (double)max; 5318 this->alphaf = this->alpha / (double)max; 5319 5320 if (this->red < max) 5429 image_pixel_setf(image_pixel *this, unsigned int rMax, unsigned int gMax, 5430 unsigned int bMax, unsigned int aMax) 5431 { 5432 this->redf = this->red / (double)rMax; 5433 this->greenf = this->green / (double)gMax; 5434 this->bluef = this->blue / (double)bMax; 5435 this->alphaf = this->alpha / (double)aMax; 5436 5437 if (this->red < rMax) 5321 5438 this->rede = this->redf * DBL_EPSILON; 5322 5439 else 5323 5440 this->rede = 0; 5324 if (this->green < max)5441 if (this->green < gMax) 5325 5442 this->greene = this->greenf * DBL_EPSILON; 5326 5443 else 5327 5444 this->greene = 0; 5328 if (this->blue < max)5445 if (this->blue < bMax) 5329 5446 this->bluee = this->bluef * DBL_EPSILON; 5330 5447 else 5331 5448 this->bluee = 0; 5332 if (this->alpha < max)5449 if (this->alpha < aMax) 5333 5450 this->alphae = this->alphaf * DBL_EPSILON; 5334 5451 else … … 5342 5459 static void 5343 5460 image_pixel_init(image_pixel *this, png_const_bytep row, png_byte colour_type, 5344 png_byte bit_depth, png_uint_32 x, store_palette palette) 5461 png_byte bit_depth, png_uint_32 x, store_palette palette, 5462 PNG_CONST image_pixel *format /*from pngvalid transform of input*/) 5345 5463 { 5346 5464 PNG_CONST png_byte sample_depth = (png_byte)(colour_type == 5347 5465 PNG_COLOR_TYPE_PALETTE ? 8 : bit_depth); 5348 5466 PNG_CONST unsigned int max = (1U<<sample_depth)-1; 5467 PNG_CONST int swap16 = (format != 0 && format->swap16); 5468 PNG_CONST int littleendian = (format != 0 && format->littleendian); 5469 PNG_CONST int sig_bits = (format != 0 && format->sig_bits); 5349 5470 5350 5471 /* Initially just set everything to the same number and the alpha to opaque. … … 5353 5474 */ 5354 5475 this->palette_index = this->red = this->green = this->blue = 5355 sample(row, colour_type, bit_depth, x, 0 );5476 sample(row, colour_type, bit_depth, x, 0, swap16, littleendian); 5356 5477 this->alpha = max; 5357 5478 this->red_sBIT = this->green_sBIT = this->blue_sBIT = this->alpha_sBIT = … … 5377 5498 unsigned int i = 0; 5378 5499 5500 if ((colour_type & 4) != 0 && format != 0 && format->alpha_first) 5501 { 5502 this->alpha = this->red; 5503 /* This handles the gray case for 'AG' pixels */ 5504 this->palette_index = this->red = this->green = this->blue = 5505 sample(row, colour_type, bit_depth, x, 1, swap16, littleendian); 5506 i = 1; 5507 } 5508 5379 5509 if (colour_type & 2) 5380 5510 { 5381 this->green = sample(row, colour_type, bit_depth, x, 1); 5382 this->blue = sample(row, colour_type, bit_depth, x, 2); 5383 i = 2; 5384 } 5385 if (colour_type & 4) 5386 this->alpha = sample(row, colour_type, bit_depth, x, ++i); 5511 /* Green is second for both BGR and RGB: */ 5512 this->green = sample(row, colour_type, bit_depth, x, ++i, swap16, 5513 littleendian); 5514 5515 if (format != 0 && format->swap_rgb) /* BGR */ 5516 this->red = sample(row, colour_type, bit_depth, x, ++i, swap16, 5517 littleendian); 5518 else 5519 this->blue = sample(row, colour_type, bit_depth, x, ++i, swap16, 5520 littleendian); 5521 } 5522 5523 else /* grayscale */ if (format != 0 && format->mono_inverted) 5524 this->red = this->green = this->blue = this->red ^ max; 5525 5526 if ((colour_type & 4) != 0) /* alpha */ 5527 { 5528 if (format == 0 || !format->alpha_first) 5529 this->alpha = sample(row, colour_type, bit_depth, x, ++i, swap16, 5530 littleendian); 5531 5532 if (format != 0 && format->alpha_inverted) 5533 this->alpha ^= max; 5534 } 5387 5535 } 5388 5536 … … 5391 5539 * from the header file. 5392 5540 */ 5393 image_pixel_setf(this, max); 5541 image_pixel_setf(this, 5542 sig_bits ? (1U << format->red_sBIT)-1 : max, 5543 sig_bits ? (1U << format->green_sBIT)-1 : max, 5544 sig_bits ? (1U << format->blue_sBIT)-1 : max, 5545 sig_bits ? (1U << format->alpha_sBIT)-1 : max); 5394 5546 5395 5547 /* Store the input information for use in the transforms - these will … … 5400 5552 this->sample_depth = sample_depth; 5401 5553 this->have_tRNS = 0; 5554 this->swap_rgb = 0; 5555 this->alpha_first = 0; 5556 this->alpha_inverted = 0; 5557 this->mono_inverted = 0; 5558 this->swap16 = 0; 5559 this->littleendian = 0; 5560 this->sig_bits = 0; 5402 5561 } 5403 5562 … … 5444 5603 { 5445 5604 if (this->bit_depth < 8) 5446 this->bit_depth = 8;5605 this->bit_depth = this->sample_depth = 8; 5447 5606 5448 5607 if (this->have_tRNS) … … 5479 5638 else 5480 5639 this->alphaf = 1; 5481 5482 this->colour_type = PNG_COLOR_TYPE_RGB_ALPHA;5483 5640 } 5641 else 5642 this->alphaf = 1; 5643 5644 this->colour_type = PNG_COLOR_TYPE_RGB_ALPHA; 5484 5645 } 5485 5646 … … 5561 5722 png_byte output_colour_type; 5562 5723 png_byte output_bit_depth; 5724 png_byte unpacked; 5563 5725 5564 5726 /* Modifications (not necessarily used.) */ … … 5636 5798 { 5637 5799 PNG_CONST unsigned int scale = (1U<<that->sample_depth)-1; 5800 PNG_CONST int sig_bits = that->sig_bits; 5638 5801 5639 5802 UNUSED(this) … … 5649 5812 */ 5650 5813 that->red = sample_scale(that->redf, scale); 5814 5815 /* This is a bit bogus; really the above calculation should use the red_sBIT 5816 * value, not sample_depth, but because libpng does png_set_shift by just 5817 * shifting the bits we get errors if we don't do it the same way. 5818 */ 5819 if (sig_bits && that->red_sBIT < that->sample_depth) 5820 that->red >>= that->sample_depth - that->red_sBIT; 5651 5821 5652 5822 /* The error value is increased, at the end, according to the lowest sBIT … … 5665 5835 { 5666 5836 that->green = sample_scale(that->greenf, scale); 5837 if (sig_bits && that->green_sBIT < that->sample_depth) 5838 that->green >>= that->sample_depth - that->green_sBIT; 5839 5667 5840 that->blue = sample_scale(that->bluef, scale); 5841 if (sig_bits && that->blue_sBIT < that->sample_depth) 5842 that->blue >>= that->sample_depth - that->blue_sBIT; 5843 5668 5844 that->greene += 1./(2*((1U<<that->green_sBIT)-1)); 5669 5845 that->bluee += 1./(2*((1U<<that->blue_sBIT)-1)); … … 5685 5861 { 5686 5862 that->alpha = scale; /* opaque */ 5687 that->alpha = 1;/* Override this. */5863 that->alphaf = 1; /* Override this. */ 5688 5864 that->alphae = 0; /* It's exact ;-) */ 5689 5865 } 5866 5867 if (sig_bits && that->alpha_sBIT < that->sample_depth) 5868 that->alpha >>= that->sample_depth - that->alpha_sBIT; 5690 5869 } 5691 5870 … … 5725 5904 dp->output_colour_type = 255; /* invalid */ 5726 5905 dp->output_bit_depth = 255; /* invalid */ 5906 dp->unpacked = 0; /* not unpacked */ 5727 5907 } 5728 5908 … … 5751 5931 dp->output_colour_type = png_get_color_type(pp, pi); 5752 5932 dp->output_bit_depth = png_get_bit_depth(pp, pi); 5933 5934 /* If png_set_filler is in action then fake the output color type to include 5935 * an alpha channel where appropriate. 5936 */ 5937 if (dp->output_bit_depth >= 8 && 5938 (dp->output_colour_type == PNG_COLOR_TYPE_RGB || 5939 dp->output_colour_type == PNG_COLOR_TYPE_GRAY) && dp->this.filler) 5940 dp->output_colour_type |= 4; 5753 5941 5754 5942 /* Validate the combination of colour type and bit depth that we are getting … … 5786 5974 5787 5975 /* Use a test pixel to check that the output agrees with what we expect - 5788 * this avoids running the whole test if the output is unexpected. 5976 * this avoids running the whole test if the output is unexpected. This also 5977 * checks for internal errors. 5789 5978 */ 5790 5979 { … … 5801 5990 * arithmetic overflows. 5802 5991 */ 5803 test_pixel.have_tRNS = dp->this.is_transparent ;5992 test_pixel.have_tRNS = dp->this.is_transparent != 0; 5804 5993 test_pixel.red_sBIT = test_pixel.green_sBIT = test_pixel.blue_sBIT = 5805 5994 test_pixel.alpha_sBIT = test_pixel.sample_depth; … … 5832 6021 5833 6022 /* If both bit depth and colour type are correct check the sample depth. 5834 * I believe these are both internal errors.5835 6023 */ 5836 if (test_pixel.colour_type == PNG_COLOR_TYPE_PALETTE) 5837 { 5838 if (test_pixel.sample_depth != 8) /* oops - internal error! */ 5839 png_error(pp, "pngvalid: internal: palette sample depth not 8"); 5840 } 5841 else if (test_pixel.sample_depth != dp->output_bit_depth) 6024 if (test_pixel.colour_type == PNG_COLOR_TYPE_PALETTE && 6025 test_pixel.sample_depth != 8) /* oops - internal error! */ 6026 png_error(pp, "pngvalid: internal: palette sample depth not 8"); 6027 else if (dp->unpacked && test_pixel.bit_depth != 8) 6028 png_error(pp, "pngvalid: internal: bad unpacked pixel depth"); 6029 else if (!dp->unpacked && test_pixel.colour_type != PNG_COLOR_TYPE_PALETTE 6030 && test_pixel.bit_depth != test_pixel.sample_depth) 5842 6031 { 5843 6032 char message[128]; … … 5845 6034 "internal: sample depth "); 5846 6035 6036 /* Because unless something has set 'unpacked' or the image is palette 6037 * mapped we expect the transform to keep sample depth and bit depth 6038 * the same. 6039 */ 6040 pos = safecatn(message, sizeof message, pos, test_pixel.sample_depth); 6041 pos = safecat(message, sizeof message, pos, " expected "); 6042 pos = safecatn(message, sizeof message, pos, test_pixel.bit_depth); 6043 6044 png_error(pp, message); 6045 } 6046 else if (test_pixel.bit_depth != dp->output_bit_depth) 6047 { 6048 /* This could be a libpng error too; libpng has not produced what we 6049 * expect for the output bit depth. 6050 */ 6051 char message[128]; 6052 size_t pos = safecat(message, sizeof message, 0, 6053 "internal: bit depth "); 6054 5847 6055 pos = safecatn(message, sizeof message, pos, dp->output_bit_depth); 5848 6056 pos = safecat(message, sizeof message, pos, " expected "); 5849 pos = safecatn(message, sizeof message, pos, test_pixel. sample_depth);6057 pos = safecatn(message, sizeof message, pos, test_pixel.bit_depth); 5850 6058 5851 6059 png_error(pp, message); … … 5994 6202 5995 6203 /* Find out what we think the pixel should be: */ 5996 image_pixel_init(&in_pixel, std, in_ct, in_bd, x, dp->this.palette); 6204 image_pixel_init(&in_pixel, std, in_ct, in_bd, x, dp->this.palette, 6205 NULL); 5997 6206 5998 6207 in_pixel.red_sBIT = red_sBIT; … … 6000 6209 in_pixel.blue_sBIT = blue_sBIT; 6001 6210 in_pixel.alpha_sBIT = alpha_sBIT; 6002 in_pixel.have_tRNS = have_tRNS ;6211 in_pixel.have_tRNS = have_tRNS != 0; 6003 6212 6004 6213 /* For error detection, below. */ … … 6008 6217 a = in_pixel.alpha; 6009 6218 6219 /* This applies the transforms to the input date, including output 6220 * format operations which must be used when reading the output 6221 * pixel that libpng produces. 6222 */ 6010 6223 dp->transform_list->mod(dp->transform_list, &in_pixel, pp, dp); 6011 6224 6012 6225 /* Read the output pixel and compare it to what we got, we don't 6013 * use the error field here, so no need to update sBIT. 6226 * use the error field here, so no need to update sBIT. in_pixel 6227 * says whether we expect libpng to change the output format. 6014 6228 */ 6015 image_pixel_init(&out_pixel, pRow, out_ct, out_bd, x, out_palette); 6229 image_pixel_init(&out_pixel, pRow, out_ct, out_bd, x, out_palette, 6230 &in_pixel); 6016 6231 6017 6232 /* We don't expect changes to the index here even if the bit depth is … … 6245 6460 { 6246 6461 png_set_tRNS_to_alpha(pp); 6462 6463 /* If there was a tRNS chunk that would get expanded and add an alpha 6464 * channel is_transparent must be updated: 6465 */ 6466 if (that->this.has_tRNS) 6467 that->this.is_transparent = 1; 6468 6247 6469 this->next->set(this->next, that, pp, pi); 6248 6470 } … … 6303 6525 { 6304 6526 png_set_gray_to_rgb(pp); 6527 /* NOTE: this doesn't result in tRNS expansion. */ 6305 6528 this->next->set(this->next, that, pp, pi); 6306 6529 } … … 6362 6585 { 6363 6586 png_set_expand(pp); 6587 6588 if (that->this.has_tRNS) 6589 that->this.is_transparent = 1; 6590 6364 6591 this->next->set(this->next, that, pp, pi); 6365 6592 } … … 6412 6639 { 6413 6640 png_set_expand_gray_1_2_4_to_8(pp); 6641 /* NOTE: don't expect this to expand tRNS */ 6414 6642 this->next->set(this->next, that, pp, pi); 6415 6643 } … … 6443 6671 { 6444 6672 png_set_expand_16(pp); 6673 6674 /* NOTE: at present libpng does SET_EXPAND as well, so tRNS is expanded. */ 6675 if (that->this.has_tRNS) 6676 that->this.is_transparent = 1; 6677 6445 6678 this->next->set(this->next, that, pp, pi); 6446 6679 } … … 6794 7027 * +/-(1<<(15-PNG_MAX_GAMMA_8)) in the 8-bit case. 6795 7028 */ 6796 that->pm->limit += 6797 # if PNG_MAX_GAMMA_8 < 146798 pow((that->this.bit_depth == 16 ?6799 8. : 6. + (1<<(15-PNG_MAX_GAMMA_8)))/65535, data.gamma);6800 # else6801 pow((that->this.bit_depth == 16 ?6802 8. : 8. + (1<<(15-PNG_MAX_GAMMA_8)))/65535, data.gamma); 6803 # endif 7029 that->pm->limit += pow( 7030 # if PNG_MAX_GAMMA_8 < 14 7031 (that->this.bit_depth == 16 ? 8. : 7032 6. + (1<<(15-PNG_MAX_GAMMA_8))) 7033 # else 7034 8. 7035 # endif 7036 /65535, data.gamma); 6804 7037 } 6805 7038 … … 6813 7046 * tested allow a bigger slack. 6814 7047 * 6815 * NOTE: this magic number was determined by experiment to be 1.1 (when 6816 * using fixed point arithmetic). There's no great merit to the value 6817 * below, however it only affects the limit used for checking for 6818 * internal calculation errors, not the actual limit imposed by 6819 * pngvalid on the output errors. 7048 * NOTE: this magic number was determined by experiment to be about 7049 * 1.263. There's no great merit to the value below, however it only 7050 * affects the limit used for checking for internal calculation errors, 7051 * not the actual limit imposed by pngvalid on the output errors. 6820 7052 */ 6821 that->pm->limit += 7053 that->pm->limit += pow( 6822 7054 # if DIGITIZE 6823 pow(1.1 /255, data.gamma);7055 1.3 6824 7056 # else 6825 pow(1.0 /255, data.gamma);7057 1.0 6826 7058 # endif 7059 /255, data.gamma); 6827 7060 } 6828 7061 } … … 6984 7217 const unsigned int calc_depth = (pm->assume_16_bit_calculations ? 16 : 6985 7218 sample_depth); 6986 const unsigned int gamma_depth = (sample_depth == 16 ? 16 : 7219 const unsigned int gamma_depth = (sample_depth == 16 ? 7220 PNG_MAX_GAMMA_8 : 6987 7221 (pm->assume_16_bit_calculations ? PNG_MAX_GAMMA_8 : sample_depth)); 6988 7222 int isgray; … … 6998 7232 * transform, feel free to delete the png_error checks on this below in 6999 7233 * the future (this is just me trying to ensure it works!) 7234 * 7235 * Interval arithmetic is exact, but to implement it it must be 7236 * possible to control the floating point implementation rounding mode. 7237 * This cannot be done in ANSI-C, so instead I reduce the 'lo' values 7238 * by DBL_EPSILON and increase the 'hi' values by the same. 7000 7239 */ 7240 # define DD(v,d,r) (digitize(v*(1-DBL_EPSILON), d, r) * (1-DBL_EPSILON)) 7241 # define DU(v,d,r) (digitize(v*(1+DBL_EPSILON), d, r) * (1+DBL_EPSILON)) 7242 7001 7243 r = rlo = rhi = that->redf; 7002 7244 rlo -= that->rede; 7003 rlo = digitize(rlo, calc_depth, 1/*round*/);7245 rlo = DD(rlo, calc_depth, 1/*round*/); 7004 7246 rhi += that->rede; 7005 rhi = digitize(rhi, calc_depth, 1/*round*/);7247 rhi = DU(rhi, calc_depth, 1/*round*/); 7006 7248 7007 7249 g = glo = ghi = that->greenf; 7008 7250 glo -= that->greene; 7009 glo = digitize(glo, calc_depth, 1/*round*/);7251 glo = DD(glo, calc_depth, 1/*round*/); 7010 7252 ghi += that->greene; 7011 ghi = digitize(ghi, calc_depth, 1/*round*/);7253 ghi = DU(ghi, calc_depth, 1/*round*/); 7012 7254 7013 7255 b = blo = bhi = that->bluef; 7014 7256 blo -= that->bluee; 7015 blo = digitize(blo, calc_depth, 1/*round*/);7257 blo = DD(blo, calc_depth, 1/*round*/); 7016 7258 bhi += that->greene; 7017 bhi = digitize(bhi, calc_depth, 1/*round*/);7259 bhi = DU(bhi, calc_depth, 1/*round*/); 7018 7260 7019 7261 isgray = r==g && g==b; … … 7022 7264 { 7023 7265 PNG_CONST double power = 1/data.gamma; 7024 PNG_CONST double abse = calc_depth == 16 ? .5/65535 : .5/255; 7025 7026 /* 'abse' is the absolute error permitted in linear calculations. It 7027 * is used here to capture the error permitted in the handling 7028 * (undoing) of the gamma encoding. Once again digitization occurs 7029 * to handle the upper and lower bounds of the values. This is 7030 * where the real errors are introduced. 7266 PNG_CONST double abse = .5/(sample_depth == 16 ? 65535 : 255); 7267 7268 /* If a gamma calculation is done it is done using lookup tables of 7269 * precision gamma_depth, so the already digitized value above may 7270 * need to be further digitized here. 7031 7271 */ 7272 if (gamma_depth != calc_depth) 7273 { 7274 rlo = DD(rlo, gamma_depth, 0/*truncate*/); 7275 rhi = DU(rhi, gamma_depth, 0/*truncate*/); 7276 glo = DD(glo, gamma_depth, 0/*truncate*/); 7277 ghi = DU(ghi, gamma_depth, 0/*truncate*/); 7278 blo = DD(blo, gamma_depth, 0/*truncate*/); 7279 bhi = DU(bhi, gamma_depth, 0/*truncate*/); 7280 } 7281 7282 /* 'abse' is the error in the gamma table calculation itself. */ 7032 7283 r = pow(r, power); 7033 rlo = digitize(pow(rlo, power)-abse, calc_depth, 1);7034 rhi = digitize(pow(rhi, power)+abse, calc_depth, 1);7284 rlo = DD(pow(rlo, power)-abse, calc_depth, 1); 7285 rhi = DU(pow(rhi, power)+abse, calc_depth, 1); 7035 7286 7036 7287 g = pow(g, power); 7037 glo = digitize(pow(glo, power)-abse, calc_depth, 1);7038 ghi = digitize(pow(ghi, power)+abse, calc_depth, 1);7288 glo = DD(pow(glo, power)-abse, calc_depth, 1); 7289 ghi = DU(pow(ghi, power)+abse, calc_depth, 1); 7039 7290 7040 7291 b = pow(b, power); 7041 blo = digitize(pow(blo, power)-abse, calc_depth, 1);7042 bhi = digitize(pow(bhi, power)+abse, calc_depth, 1);7292 blo = DD(pow(blo, power)-abse, calc_depth, 1); 7293 bhi = DU(pow(bhi, power)+abse, calc_depth, 1); 7043 7294 } 7044 7295 … … 7047 7298 * line (in which case truncation to 15 bits happened) or not (rounding 7048 7299 * was used) the maxium error in an individual coefficient is always 7049 * 1/32768, because even in the rounding case the requirement that7300 * 2/32768, because even in the rounding case the requirement that 7050 7301 * coefficients add up to 32768 can cause a larger rounding error. 7051 7302 * … … 7058 7309 { 7059 7310 PNG_CONST int do_round = data.gamma != 1 || calc_depth == 16; 7060 PNG_CONST double ce = 1. / 32768;7061 7062 graylo = digitize(rlo * (data.red_coefficient-ce) +7311 PNG_CONST double ce = 2. / 32768; 7312 7313 graylo = DD(rlo * (data.red_coefficient-ce) + 7063 7314 glo * (data.green_coefficient-ce) + 7064 blo * (data.blue_coefficient-ce), gamma_depth, do_round);7065 if (graylo <= 0)7066 graylo = 0;7067 7068 grayhi = digitize(rhi * (data.red_coefficient+ce) +7315 blo * (data.blue_coefficient-ce), calc_depth, do_round); 7316 if (graylo > gray) /* always accept the right answer */ 7317 graylo = gray; 7318 7319 grayhi = DU(rhi * (data.red_coefficient+ce) + 7069 7320 ghi * (data.green_coefficient+ce) + 7070 bhi * (data.blue_coefficient+ce), gamma_depth, do_round);7071 if (grayhi >= 1)7072 grayhi = 1;7321 bhi * (data.blue_coefficient+ce), calc_depth, do_round); 7322 if (grayhi < gray) 7323 grayhi = gray; 7073 7324 } 7074 7325 … … 7078 7329 PNG_CONST double power = data.gamma; 7079 7330 7331 /* And this happens yet again, shifting the values once more. */ 7332 if (gamma_depth != sample_depth) 7333 { 7334 rlo = DD(rlo, gamma_depth, 0/*truncate*/); 7335 rhi = DU(rhi, gamma_depth, 0/*truncate*/); 7336 glo = DD(glo, gamma_depth, 0/*truncate*/); 7337 ghi = DU(ghi, gamma_depth, 0/*truncate*/); 7338 blo = DD(blo, gamma_depth, 0/*truncate*/); 7339 bhi = DU(bhi, gamma_depth, 0/*truncate*/); 7340 } 7341 7080 7342 gray = pow(gray, power); 7081 graylo = digitize(pow(graylo, power), sample_depth, 1);7082 grayhi = digitize(pow(grayhi, power), sample_depth, 1);7343 graylo = DD(pow(graylo, power), sample_depth, 1); 7344 grayhi = DU(pow(grayhi, power), sample_depth, 1); 7083 7345 } 7346 7347 # undef DD 7348 # undef DU 7084 7349 7085 7350 /* Now the error can be calculated. … … 7133 7398 /* There is no need to do the conversions to and from linear space, 7134 7399 * so the calculation should be a lot more accurate. There is a 7135 * built in 1/32768 error in the coefficients because they only have 7136 * 15 bits and are adjusted to make sure they add up to 32768, so 7137 * the result may have an additional error up to 1/32768. (Note 7138 * that adding the 1/32768 here avoids needing to increase the 7139 * global error limits to take this into account.) 7400 * built in error in the coefficients because they only have 15 bits 7401 * and are adjusted to make sure they add up to 32768. This 7402 * involves a integer calculation with truncation of the form: 7403 * 7404 * ((int)(coefficient * 100000) * 32768)/100000 7405 * 7406 * This is done to the red and green coefficients (the ones 7407 * provided to the API) then blue is calculated from them so the 7408 * result adds up to 32768. In the worst case this can result in 7409 * a -1 error in red and green and a +2 error in blue. Consequently 7410 * the worst case in the calculation below is 2/32768 error. 7411 * 7412 * TODO: consider fixing this in libpng by rounding the calculation 7413 * limiting the error to 1/32768. 7414 * 7415 * Handling this by adding 2/32768 here avoids needing to increase 7416 * the global error limits to take this into account.) 7140 7417 */ 7141 7418 gray = r * data.red_coefficient + g * data.green_coefficient + 7142 7419 b * data.blue_coefficient; 7143 7420 err = re * data.red_coefficient + ge * data.green_coefficient + 7144 be * data.blue_coefficient + 1./32768 + gray * 5 * DBL_EPSILON;7421 be * data.blue_coefficient + 2./32768 + gray * 5 * DBL_EPSILON; 7145 7422 } 7146 7423 … … 7177 7454 */ 7178 7455 gray = r * data.red_coefficient + g * data.green_coefficient + 7179 b * data.blue_coefficient - 1./32768 - out_qe;7456 b * data.blue_coefficient - 2./32768 - out_qe; 7180 7457 if (gray <= 0) 7181 7458 gray = 0; … … 7187 7464 7188 7465 grayhi = rhi * data.red_coefficient + ghi * data.green_coefficient + 7189 bhi * data.blue_coefficient + 1./32768 + out_qe;7466 bhi * data.blue_coefficient + 2./32768 + out_qe; 7190 7467 grayhi *= (1 + 6 * DBL_EPSILON); 7191 7468 if (grayhi >= 1) … … 7302 7579 else 7303 7580 { 7581 if (that->this.has_tRNS) 7582 that->this.is_transparent = 1; 7583 7304 7584 bit_depth = that->this.bit_depth; 7305 7585 expand = 1; … … 7307 7587 7308 7588 image_pixel_init(&data, random_bytes, colour_type, 7309 bit_depth, 0/*x*/, 0/*unused: palette*/ );7589 bit_depth, 0/*x*/, 0/*unused: palette*/, NULL/*format*/); 7310 7590 7311 7591 /* Extract the background colour from this image_pixel, but make sure the … … 7379 7659 that->alphaf = 1; 7380 7660 that->alphae = 0; 7381 7382 if (that->colour_type == PNG_COLOR_TYPE_RGB_ALPHA) 7383 that->colour_type = PNG_COLOR_TYPE_RGB;7384 else if (that->colour_type == PNG_COLOR_TYPE_GRAY_ALPHA)7385 that->colour_type = PNG_COLOR_TYPE_GRAY;7386 /* PNG_COLOR_TYPE_PALETTE is not changed */7387 }7661 } 7662 7663 if (that->colour_type == PNG_COLOR_TYPE_RGB_ALPHA) 7664 that->colour_type = PNG_COLOR_TYPE_RGB; 7665 else if (that->colour_type == PNG_COLOR_TYPE_GRAY_ALPHA) 7666 that->colour_type = PNG_COLOR_TYPE_GRAY; 7667 /* PNG_COLOR_TYPE_PALETTE is not changed */ 7388 7668 7389 7669 this->next->mod(this->next, that, pp, display); … … 7397 7677 #define PT ITSTRUCT(background) 7398 7678 #endif /* PNG_READ_BACKGROUND_SUPPORTED */ 7679 7680 /* png_set_quantize(png_structp, png_colorp palette, int num_palette, 7681 * int maximum_colors, png_const_uint_16p histogram, int full_quantize) 7682 * 7683 * Very difficult to validate this! 7684 */ 7685 /*NOTE: TBD NYI */ 7686 7687 /* The data layout transforms are handled by swapping our own channel data, 7688 * necessarily these need to happen at the end of the transform list because the 7689 * semantic of the channels changes after these are executed. Some of these, 7690 * like set_shift and set_packing, can't be done at present because they change 7691 * the layout of the data at the sub-sample level so sample() won't get the 7692 * right answer. 7693 */ 7694 /* png_set_invert_alpha */ 7695 #ifdef PNG_READ_INVERT_ALPHA_SUPPORTED 7696 /* Invert the alpha channel 7697 * 7698 * png_set_invert_alpha(png_structrp png_ptr) 7699 */ 7700 static void 7701 image_transform_png_set_invert_alpha_set(PNG_CONST image_transform *this, 7702 transform_display *that, png_structp pp, png_infop pi) 7703 { 7704 png_set_invert_alpha(pp); 7705 this->next->set(this->next, that, pp, pi); 7706 } 7707 7708 static void 7709 image_transform_png_set_invert_alpha_mod(PNG_CONST image_transform *this, 7710 image_pixel *that, png_const_structp pp, 7711 PNG_CONST transform_display *display) 7712 { 7713 if (that->colour_type & 4) 7714 that->alpha_inverted = 1; 7715 7716 this->next->mod(this->next, that, pp, display); 7717 } 7718 7719 static int 7720 image_transform_png_set_invert_alpha_add(image_transform *this, 7721 PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth) 7722 { 7723 UNUSED(bit_depth) 7724 7725 this->next = *that; 7726 *that = this; 7727 7728 /* Only has an effect on pixels with alpha: */ 7729 return (colour_type & 4) != 0; 7730 } 7731 7732 IT(invert_alpha); 7733 #undef PT 7734 #define PT ITSTRUCT(invert_alpha) 7735 7736 #endif /* PNG_READ_INVERT_ALPHA_SUPPORTED */ 7737 7738 /* png_set_bgr */ 7739 #ifdef PNG_READ_BGR_SUPPORTED 7740 /* Swap R,G,B channels to order B,G,R. 7741 * 7742 * png_set_bgr(png_structrp png_ptr) 7743 * 7744 * This only has an effect on RGB and RGBA pixels. 7745 */ 7746 static void 7747 image_transform_png_set_bgr_set(PNG_CONST image_transform *this, 7748 transform_display *that, png_structp pp, png_infop pi) 7749 { 7750 png_set_bgr(pp); 7751 this->next->set(this->next, that, pp, pi); 7752 } 7753 7754 static void 7755 image_transform_png_set_bgr_mod(PNG_CONST image_transform *this, 7756 image_pixel *that, png_const_structp pp, 7757 PNG_CONST transform_display *display) 7758 { 7759 if (that->colour_type == PNG_COLOR_TYPE_RGB || 7760 that->colour_type == PNG_COLOR_TYPE_RGBA) 7761 that->swap_rgb = 1; 7762 7763 this->next->mod(this->next, that, pp, display); 7764 } 7765 7766 static int 7767 image_transform_png_set_bgr_add(image_transform *this, 7768 PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth) 7769 { 7770 UNUSED(bit_depth) 7771 7772 this->next = *that; 7773 *that = this; 7774 7775 return colour_type == PNG_COLOR_TYPE_RGB || 7776 colour_type == PNG_COLOR_TYPE_RGBA; 7777 } 7778 7779 IT(bgr); 7780 #undef PT 7781 #define PT ITSTRUCT(bgr) 7782 7783 #endif /* PNG_READ_BGR_SUPPORTED */ 7784 7785 /* png_set_swap_alpha */ 7786 #ifdef PNG_READ_SWAP_ALPHA_SUPPORTED 7787 /* Put the alpha channel first. 7788 * 7789 * png_set_swap_alpha(png_structrp png_ptr) 7790 * 7791 * This only has an effect on GA and RGBA pixels. 7792 */ 7793 static void 7794 image_transform_png_set_swap_alpha_set(PNG_CONST image_transform *this, 7795 transform_display *that, png_structp pp, png_infop pi) 7796 { 7797 png_set_swap_alpha(pp); 7798 this->next->set(this->next, that, pp, pi); 7799 } 7800 7801 static void 7802 image_transform_png_set_swap_alpha_mod(PNG_CONST image_transform *this, 7803 image_pixel *that, png_const_structp pp, 7804 PNG_CONST transform_display *display) 7805 { 7806 if (that->colour_type == PNG_COLOR_TYPE_GA || 7807 that->colour_type == PNG_COLOR_TYPE_RGBA) 7808 that->alpha_first = 1; 7809 7810 this->next->mod(this->next, that, pp, display); 7811 } 7812 7813 static int 7814 image_transform_png_set_swap_alpha_add(image_transform *this, 7815 PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth) 7816 { 7817 UNUSED(bit_depth) 7818 7819 this->next = *that; 7820 *that = this; 7821 7822 return colour_type == PNG_COLOR_TYPE_GA || 7823 colour_type == PNG_COLOR_TYPE_RGBA; 7824 } 7825 7826 IT(swap_alpha); 7827 #undef PT 7828 #define PT ITSTRUCT(swap_alpha) 7829 7830 #endif /* PNG_READ_SWAP_ALPHA_SUPPORTED */ 7831 7832 /* png_set_swap */ 7833 #ifdef PNG_READ_SWAP_SUPPORTED 7834 /* Byte swap 16-bit components. 7835 * 7836 * png_set_swap(png_structrp png_ptr) 7837 */ 7838 static void 7839 image_transform_png_set_swap_set(PNG_CONST image_transform *this, 7840 transform_display *that, png_structp pp, png_infop pi) 7841 { 7842 png_set_swap(pp); 7843 this->next->set(this->next, that, pp, pi); 7844 } 7845 7846 static void 7847 image_transform_png_set_swap_mod(PNG_CONST image_transform *this, 7848 image_pixel *that, png_const_structp pp, 7849 PNG_CONST transform_display *display) 7850 { 7851 if (that->bit_depth == 16) 7852 that->swap16 = 1; 7853 7854 this->next->mod(this->next, that, pp, display); 7855 } 7856 7857 static int 7858 image_transform_png_set_swap_add(image_transform *this, 7859 PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth) 7860 { 7861 UNUSED(colour_type) 7862 7863 this->next = *that; 7864 *that = this; 7865 7866 return bit_depth == 16; 7867 } 7868 7869 IT(swap); 7870 #undef PT 7871 #define PT ITSTRUCT(swap) 7872 7873 #endif /* PNG_READ_SWAP_SUPPORTED */ 7874 7875 #ifdef PNG_READ_FILLER_SUPPORTED 7876 /* Add a filler byte to 8-bit Gray or 24-bit RGB images. 7877 * 7878 * png_set_filler, (png_structp png_ptr, png_uint_32 filler, int flags)); 7879 * 7880 * Flags: 7881 * 7882 * PNG_FILLER_BEFORE 7883 * PNG_FILLER_AFTER 7884 */ 7885 #define data ITDATA(filler) 7886 static struct 7887 { 7888 png_uint_32 filler; 7889 int flags; 7890 } data; 7891 7892 static void 7893 image_transform_png_set_filler_set(PNG_CONST image_transform *this, 7894 transform_display *that, png_structp pp, png_infop pi) 7895 { 7896 /* Need a random choice for 'before' and 'after' as well as for the 7897 * filler. The 'filler' value has all 32 bits set, but only bit_depth 7898 * will be used. At this point we don't know bit_depth. 7899 */ 7900 RANDOMIZE(data.filler); 7901 data.flags = random_choice(); 7902 7903 png_set_filler(pp, data.filler, data.flags); 7904 7905 /* The standard display handling stuff also needs to know that 7906 * there is a filler, so set that here. 7907 */ 7908 that->this.filler = 1; 7909 7910 this->next->set(this->next, that, pp, pi); 7911 } 7912 7913 static void 7914 image_transform_png_set_filler_mod(PNG_CONST image_transform *this, 7915 image_pixel *that, png_const_structp pp, 7916 PNG_CONST transform_display *display) 7917 { 7918 if (that->bit_depth >= 8 && 7919 (that->colour_type == PNG_COLOR_TYPE_RGB || 7920 that->colour_type == PNG_COLOR_TYPE_GRAY)) 7921 { 7922 PNG_CONST unsigned int max = (1U << that->bit_depth)-1; 7923 that->alpha = data.filler & max; 7924 that->alphaf = ((double)that->alpha) / max; 7925 that->alphae = 0; 7926 7927 /* The filler has been stored in the alpha channel, we must record 7928 * that this has been done for the checking later on, the color 7929 * type is faked to have an alpha channel, but libpng won't report 7930 * this; the app has to know the extra channel is there and this 7931 * was recording in standard_display::filler above. 7932 */ 7933 that->colour_type |= 4; /* alpha added */ 7934 that->alpha_first = data.flags == PNG_FILLER_BEFORE; 7935 } 7936 7937 this->next->mod(this->next, that, pp, display); 7938 } 7939 7940 static int 7941 image_transform_png_set_filler_add(image_transform *this, 7942 PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth) 7943 { 7944 this->next = *that; 7945 *that = this; 7946 7947 return bit_depth >= 8 && (colour_type == PNG_COLOR_TYPE_RGB || 7948 colour_type == PNG_COLOR_TYPE_GRAY); 7949 } 7950 7951 #undef data 7952 IT(filler); 7953 #undef PT 7954 #define PT ITSTRUCT(filler) 7955 7956 /* png_set_add_alpha, (png_structp png_ptr, png_uint_32 filler, int flags)); */ 7957 /* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */ 7958 #define data ITDATA(add_alpha) 7959 static struct 7960 { 7961 png_uint_32 filler; 7962 int flags; 7963 } data; 7964 7965 static void 7966 image_transform_png_set_add_alpha_set(PNG_CONST image_transform *this, 7967 transform_display *that, png_structp pp, png_infop pi) 7968 { 7969 /* Need a random choice for 'before' and 'after' as well as for the 7970 * filler. The 'filler' value has all 32 bits set, but only bit_depth 7971 * will be used. At this point we don't know bit_depth. 7972 */ 7973 RANDOMIZE(data.filler); 7974 data.flags = random_choice(); 7975 7976 png_set_add_alpha(pp, data.filler, data.flags); 7977 this->next->set(this->next, that, pp, pi); 7978 } 7979 7980 static void 7981 image_transform_png_set_add_alpha_mod(PNG_CONST image_transform *this, 7982 image_pixel *that, png_const_structp pp, 7983 PNG_CONST transform_display *display) 7984 { 7985 if (that->bit_depth >= 8 && 7986 (that->colour_type == PNG_COLOR_TYPE_RGB || 7987 that->colour_type == PNG_COLOR_TYPE_GRAY)) 7988 { 7989 PNG_CONST unsigned int max = (1U << that->bit_depth)-1; 7990 that->alpha = data.filler & max; 7991 that->alphaf = ((double)that->alpha) / max; 7992 that->alphae = 0; 7993 7994 that->colour_type |= 4; /* alpha added */ 7995 that->alpha_first = data.flags == PNG_FILLER_BEFORE; 7996 } 7997 7998 this->next->mod(this->next, that, pp, display); 7999 } 8000 8001 static int 8002 image_transform_png_set_add_alpha_add(image_transform *this, 8003 PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth) 8004 { 8005 this->next = *that; 8006 *that = this; 8007 8008 return bit_depth >= 8 && (colour_type == PNG_COLOR_TYPE_RGB || 8009 colour_type == PNG_COLOR_TYPE_GRAY); 8010 } 8011 8012 #undef data 8013 IT(add_alpha); 8014 #undef PT 8015 #define PT ITSTRUCT(add_alpha) 8016 8017 #endif /* PNG_READ_FILLER_SUPPORTED */ 8018 8019 /* png_set_packing */ 8020 #ifdef PNG_READ_PACK_SUPPORTED 8021 /* Use 1 byte per pixel in 1, 2, or 4-bit depth files. 8022 * 8023 * png_set_packing(png_structrp png_ptr) 8024 * 8025 * This should only affect grayscale and palette images with less than 8 bits 8026 * per pixel. 8027 */ 8028 static void 8029 image_transform_png_set_packing_set(PNG_CONST image_transform *this, 8030 transform_display *that, png_structp pp, png_infop pi) 8031 { 8032 png_set_packing(pp); 8033 that->unpacked = 1; 8034 this->next->set(this->next, that, pp, pi); 8035 } 8036 8037 static void 8038 image_transform_png_set_packing_mod(PNG_CONST image_transform *this, 8039 image_pixel *that, png_const_structp pp, 8040 PNG_CONST transform_display *display) 8041 { 8042 /* The general expand case depends on what the colour type is, 8043 * low bit-depth pixel values are unpacked into bytes without 8044 * scaling, so sample_depth is not changed. 8045 */ 8046 if (that->bit_depth < 8) /* grayscale or palette */ 8047 that->bit_depth = 8; 8048 8049 this->next->mod(this->next, that, pp, display); 8050 } 8051 8052 static int 8053 image_transform_png_set_packing_add(image_transform *this, 8054 PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth) 8055 { 8056 UNUSED(colour_type) 8057 8058 this->next = *that; 8059 *that = this; 8060 8061 /* Nothing should happen unless the bit depth is less than 8: */ 8062 return bit_depth < 8; 8063 } 8064 8065 IT(packing); 8066 #undef PT 8067 #define PT ITSTRUCT(packing) 8068 8069 #endif /* PNG_READ_PACK_SUPPORTED */ 8070 8071 /* png_set_packswap */ 8072 #ifdef PNG_READ_PACKSWAP_SUPPORTED 8073 /* Swap pixels packed into bytes; reverses the order on screen so that 8074 * the high order bits correspond to the rightmost pixels. 8075 * 8076 * png_set_packswap(png_structrp png_ptr) 8077 */ 8078 static void 8079 image_transform_png_set_packswap_set(PNG_CONST image_transform *this, 8080 transform_display *that, png_structp pp, png_infop pi) 8081 { 8082 png_set_packswap(pp); 8083 this->next->set(this->next, that, pp, pi); 8084 } 8085 8086 static void 8087 image_transform_png_set_packswap_mod(PNG_CONST image_transform *this, 8088 image_pixel *that, png_const_structp pp, 8089 PNG_CONST transform_display *display) 8090 { 8091 if (that->bit_depth < 8) 8092 that->littleendian = 1; 8093 8094 this->next->mod(this->next, that, pp, display); 8095 } 8096 8097 static int 8098 image_transform_png_set_packswap_add(image_transform *this, 8099 PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth) 8100 { 8101 UNUSED(colour_type) 8102 8103 this->next = *that; 8104 *that = this; 8105 8106 return bit_depth < 8; 8107 } 8108 8109 IT(packswap); 8110 #undef PT 8111 #define PT ITSTRUCT(packswap) 8112 8113 #endif /* PNG_READ_PACKSWAP_SUPPORTED */ 8114 8115 8116 /* png_set_invert_mono */ 8117 #ifdef PNG_READ_INVERT_MONO_SUPPORTED 8118 /* Invert the gray channel 8119 * 8120 * png_set_invert_mono(png_structrp png_ptr) 8121 */ 8122 static void 8123 image_transform_png_set_invert_mono_set(PNG_CONST image_transform *this, 8124 transform_display *that, png_structp pp, png_infop pi) 8125 { 8126 png_set_invert_mono(pp); 8127 this->next->set(this->next, that, pp, pi); 8128 } 8129 8130 static void 8131 image_transform_png_set_invert_mono_mod(PNG_CONST image_transform *this, 8132 image_pixel *that, png_const_structp pp, 8133 PNG_CONST transform_display *display) 8134 { 8135 if (that->colour_type & 4) 8136 that->mono_inverted = 1; 8137 8138 this->next->mod(this->next, that, pp, display); 8139 } 8140 8141 static int 8142 image_transform_png_set_invert_mono_add(image_transform *this, 8143 PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth) 8144 { 8145 UNUSED(bit_depth) 8146 8147 this->next = *that; 8148 *that = this; 8149 8150 /* Only has an effect on pixels with no colour: */ 8151 return (colour_type & 2) == 0; 8152 } 8153 8154 IT(invert_mono); 8155 #undef PT 8156 #define PT ITSTRUCT(invert_mono) 8157 8158 #endif /* PNG_READ_INVERT_MONO_SUPPORTED */ 8159 8160 #ifdef PNG_READ_SHIFT_SUPPORTED 8161 /* png_set_shift(png_structp, png_const_color_8p true_bits) 8162 * 8163 * The output pixels will be shifted by the given true_bits 8164 * values. 8165 */ 8166 #define data ITDATA(shift) 8167 static png_color_8 data; 8168 8169 static void 8170 image_transform_png_set_shift_set(PNG_CONST image_transform *this, 8171 transform_display *that, png_structp pp, png_infop pi) 8172 { 8173 /* Get a random set of shifts. The shifts need to do something 8174 * to test the transform, so they are limited to the bit depth 8175 * of the input image. Notice that in the following the 'gray' 8176 * field is randomized independently. This acts as a check that 8177 * libpng does use the correct field. 8178 */ 8179 PNG_CONST unsigned int depth = that->this.bit_depth; 8180 8181 data.red = (png_byte)/*SAFE*/(random_mod(depth)+1); 8182 data.green = (png_byte)/*SAFE*/(random_mod(depth)+1); 8183 data.blue = (png_byte)/*SAFE*/(random_mod(depth)+1); 8184 data.gray = (png_byte)/*SAFE*/(random_mod(depth)+1); 8185 data.alpha = (png_byte)/*SAFE*/(random_mod(depth)+1); 8186 8187 png_set_shift(pp, &data); 8188 this->next->set(this->next, that, pp, pi); 8189 } 8190 8191 static void 8192 image_transform_png_set_shift_mod(PNG_CONST image_transform *this, 8193 image_pixel *that, png_const_structp pp, 8194 PNG_CONST transform_display *display) 8195 { 8196 /* Copy the correct values into the sBIT fields, libpng does not do 8197 * anything to palette data: 8198 */ 8199 if (that->colour_type != PNG_COLOR_TYPE_PALETTE) 8200 { 8201 that->sig_bits = 1; 8202 8203 /* The sBIT fields are reset to the values previously sent to 8204 * png_set_shift according to the colour type. 8205 * does. 8206 */ 8207 if (that->colour_type & 2) /* RGB channels */ 8208 { 8209 that->red_sBIT = data.red; 8210 that->green_sBIT = data.green; 8211 that->blue_sBIT = data.blue; 8212 } 8213 8214 else /* One grey channel */ 8215 that->red_sBIT = that->green_sBIT = that->blue_sBIT = data.gray; 8216 8217 that->alpha_sBIT = data.alpha; 8218 } 8219 8220 this->next->mod(this->next, that, pp, display); 8221 } 8222 8223 static int 8224 image_transform_png_set_shift_add(image_transform *this, 8225 PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth) 8226 { 8227 UNUSED(bit_depth) 8228 8229 this->next = *that; 8230 *that = this; 8231 8232 return colour_type != PNG_COLOR_TYPE_PALETTE; 8233 } 8234 8235 IT(shift); 8236 #undef PT 8237 #define PT ITSTRUCT(shift) 8238 8239 #endif /* PNG_READ_SHIFT_SUPPORTED */ 8240 8241 #ifdef THIS_IS_THE_PROFORMA 8242 static void 8243 image_transform_png_set_@_set(PNG_CONST image_transform *this, 8244 transform_display *that, png_structp pp, png_infop pi) 8245 { 8246 png_set_@(pp); 8247 this->next->set(this->next, that, pp, pi); 8248 } 8249 8250 static void 8251 image_transform_png_set_@_mod(PNG_CONST image_transform *this, 8252 image_pixel *that, png_const_structp pp, 8253 PNG_CONST transform_display *display) 8254 { 8255 this->next->mod(this->next, that, pp, display); 8256 } 8257 8258 static int 8259 image_transform_png_set_@_add(image_transform *this, 8260 PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth) 8261 { 8262 this->next = *that; 8263 *that = this; 8264 8265 return 1; 8266 } 8267 8268 IT(@); 8269 #endif 8270 7399 8271 7400 8272 /* This may just be 'end' if all the transforms are disabled! */ … … 7575 8447 } 7576 8448 7577 #ifdef THIS_IS_THE_PROFORMA7578 static void7579 image_transform_png_set_@_set(PNG_CONST image_transform *this,7580 transform_display *that, png_structp pp, png_infop pi)7581 {7582 png_set_@(pp);7583 this->next->set(this->next, that, pp, pi);7584 }7585 7586 static void7587 image_transform_png_set_@_mod(PNG_CONST image_transform *this,7588 image_pixel *that, png_const_structp pp,7589 PNG_CONST transform_display *display)7590 {7591 this->next->mod(this->next, that, pp, display);7592 }7593 7594 static int7595 image_transform_png_set_@_add(image_transform *this,7596 PNG_CONST image_transform **that, char *name, size_t sizeof_name,7597 size_t *pos, png_byte colour_type, png_byte bit_depth)7598 {7599 this->next = *that;7600 *that = this;7601 7602 *pos = safecat(name, sizeof_name, *pos, " +@");7603 7604 return 1;7605 }7606 7607 IT(@);7608 #endif7609 7610 /* png_set_quantize(png_structp, png_colorp palette, int num_palette,7611 * int maximum_colors, png_const_uint_16p histogram, int full_quantize)7612 *7613 * Very difficult to validate this!7614 */7615 /*NOTE: TBD NYI */7616 7617 /* The data layout transforms are handled by swapping our own channel data,7618 * necessarily these need to happen at the end of the transform list because the7619 * semantic of the channels changes after these are executed. Some of these,7620 * like set_shift and set_packing, can't be done at present because they change7621 * the layout of the data at the sub-sample level so sample() won't get the7622 * right answer.7623 */7624 /* png_set_invert_alpha */7625 /*NOTE: TBD NYI */7626 7627 /* png_set_bgr */7628 /*NOTE: TBD NYI */7629 7630 /* png_set_swap_alpha */7631 /*NOTE: TBD NYI */7632 7633 /* png_set_swap */7634 /*NOTE: TBD NYI */7635 7636 /* png_set_filler, (png_structp png_ptr, png_uint_32 filler, int flags)); */7637 /*NOTE: TBD NYI */7638 7639 /* png_set_add_alpha, (png_structp png_ptr, png_uint_32 filler, int flags)); */7640 /*NOTE: TBD NYI */7641 7642 /* png_set_packing */7643 /*NOTE: TBD NYI */7644 7645 /* png_set_packswap */7646 /*NOTE: TBD NYI */7647 7648 /* png_set_invert_mono */7649 /*NOTE: TBD NYI */7650 7651 /* png_set_shift(png_structp, png_const_color_8p true_bits) */7652 /*NOTE: TBD NYI */7653 7654 8449 static void 7655 8450 perform_transform_test(png_modifier *pm) … … 7659 8454 unsigned int palette_number = 0; 7660 8455 7661 while (next_format(&colour_type, &bit_depth, &palette_number, 0)) 8456 while (next_format(&colour_type, &bit_depth, &palette_number, pm->test_lbg, 8457 pm->test_tRNS)) 7662 8458 { 7663 8459 png_uint_32 counter = 0; … … 7962 8758 7963 8759 if ((dp->this.colour_type & PNG_COLOR_MASK_ALPHA) != 0 || 7964 (dp->this.colour_type == 3 && dp->this.is_transparent)) 8760 (dp->this.colour_type == 3 && dp->this.is_transparent) || 8761 ((dp->this.colour_type == 0 || dp->this.colour_type == 2) && 8762 dp->this.has_tRNS)) 7965 8763 { 7966 8764 vi->do_background = dp->do_background; … … 7992 8790 } 7993 8791 } 7994 else 8792 else /* Do not expect any background processing */ 7995 8793 vi->do_background = 0; 7996 8794 … … 8708 9506 PNG_CONST store_palette_entry *in_palette = dp->this.palette; 8709 9507 PNG_CONST int in_is_transparent = dp->this.is_transparent; 9508 int process_tRNS; 8710 9509 int out_npalette = -1; 8711 9510 int out_is_transparent = 0; /* Just refers to the palette case */ … … 8723 9522 processing = (vi.gamma_correction > 0 && !dp->threshold_test) 8724 9523 || in_bd != out_bd || in_ct != out_ct || vi.do_background; 9524 process_tRNS = dp->this.has_tRNS && vi.do_background; 8725 9525 8726 9526 /* TODO: FIX THIS: MAJOR BUG! If the transformations all happen inside … … 8754 9554 /* Record the palette index for index images. */ 8755 9555 PNG_CONST unsigned int in_index = 8756 in_ct == 3 ? sample(std, 3, in_bd, x, 0 ) : 256;9556 in_ct == 3 ? sample(std, 3, in_bd, x, 0, 0, 0) : 256; 8757 9557 PNG_CONST unsigned int out_index = 8758 out_ct == 3 ? sample(std, 3, out_bd, x, 0 ) : 256;9558 out_ct == 3 ? sample(std, 3, out_bd, x, 0, 0, 0) : 256; 8759 9559 8760 9560 /* Handle input alpha - png_set_background will cause the output 8761 9561 * alpha to disappear so there is nothing to check. 8762 9562 */ 8763 if ((in_ct & PNG_COLOR_MASK_ALPHA) != 0 || (in_ct == 3 &&8764 in_is_transparent))9563 if ((in_ct & PNG_COLOR_MASK_ALPHA) != 0 || 9564 (in_ct == 3 && in_is_transparent)) 8765 9565 { 8766 9566 PNG_CONST unsigned int input_alpha = in_ct == 3 ? 8767 9567 dp->this.palette[in_index].alpha : 8768 sample(std, in_ct, in_bd, x, samples_per_pixel );9568 sample(std, in_ct, in_bd, x, samples_per_pixel, 0, 0); 8769 9569 8770 9570 unsigned int output_alpha = 65536 /* as a flag value */; … … 8778 9578 else if ((out_ct & PNG_COLOR_MASK_ALPHA) != 0) 8779 9579 output_alpha = sample(pRow, out_ct, out_bd, x, 8780 samples_per_pixel );9580 samples_per_pixel, 0, 0); 8781 9581 8782 9582 if (output_alpha != 65536) … … 8794 9594 } 8795 9595 9596 else if (process_tRNS) 9597 { 9598 /* alpha needs to be set appropriately for this pixel, it is 9599 * currently 1 and needs to be 0 for an input pixel which matches 9600 * the values in tRNS. 9601 */ 9602 switch (in_ct) 9603 { 9604 case 0: /* gray */ 9605 if (sample(std, in_ct, in_bd, x, 0, 0, 0) == 9606 dp->this.transparent.red) 9607 alpha = 0; 9608 break; 9609 9610 case 2: /* RGB */ 9611 if (sample(std, in_ct, in_bd, x, 0, 0, 0) == 9612 dp->this.transparent.red && 9613 sample(std, in_ct, in_bd, x, 1, 0, 0) == 9614 dp->this.transparent.green && 9615 sample(std, in_ct, in_bd, x, 2, 0, 0) == 9616 dp->this.transparent.blue) 9617 alpha = 0; 9618 break; 9619 9620 default: 9621 break; 9622 } 9623 } 9624 8796 9625 /* Handle grayscale or RGB components. */ 8797 9626 if ((in_ct & PNG_COLOR_MASK_COLOR) == 0) /* grayscale */ 8798 9627 (void)gamma_component_validate("gray", &vi, 8799 sample(std, in_ct, in_bd, x, 0 ),8800 sample(pRow, out_ct, out_bd, x, 0 ), alpha/*component*/,8801 vi.background_red);9628 sample(std, in_ct, in_bd, x, 0, 0, 0), 9629 sample(pRow, out_ct, out_bd, x, 0, 0, 0), 9630 alpha/*component*/, vi.background_red); 8802 9631 else /* RGB or palette */ 8803 9632 { 8804 9633 (void)gamma_component_validate("red", &vi, 8805 9634 in_ct == 3 ? in_palette[in_index].red : 8806 sample(std, in_ct, in_bd, x, 0 ),9635 sample(std, in_ct, in_bd, x, 0, 0, 0), 8807 9636 out_ct == 3 ? out_palette[out_index].red : 8808 sample(pRow, out_ct, out_bd, x, 0 ),9637 sample(pRow, out_ct, out_bd, x, 0, 0, 0), 8809 9638 alpha/*component*/, vi.background_red); 8810 9639 8811 9640 (void)gamma_component_validate("green", &vi, 8812 9641 in_ct == 3 ? in_palette[in_index].green : 8813 sample(std, in_ct, in_bd, x, 1 ),9642 sample(std, in_ct, in_bd, x, 1, 0, 0), 8814 9643 out_ct == 3 ? out_palette[out_index].green : 8815 sample(pRow, out_ct, out_bd, x, 1 ),9644 sample(pRow, out_ct, out_bd, x, 1, 0, 0), 8816 9645 alpha/*component*/, vi.background_green); 8817 9646 8818 9647 (void)gamma_component_validate("blue", &vi, 8819 9648 in_ct == 3 ? in_palette[in_index].blue : 8820 sample(std, in_ct, in_bd, x, 2 ),9649 sample(std, in_ct, in_bd, x, 2, 0, 0), 8821 9650 out_ct == 3 ? out_palette[out_index].blue : 8822 sample(pRow, out_ct, out_bd, x, 2 ),9651 sample(pRow, out_ct, out_bd, x, 2, 0, 0), 8823 9652 alpha/*component*/, vi.background_blue); 8824 9653 } … … 8903 9732 modification_reset(d.pm->modifications); 8904 9733 8905 /* Get a png_struct for writing the image. */9734 /* Get a png_struct for reading the image. */ 8906 9735 pp = set_modifier_for_read(d.pm, &pi, d.this.id, name); 8907 9736 standard_palette_init(&d.this); … … 9042 9871 * fact this test is somewhat excessive since libpng doesn't make this 9043 9872 * decision based on colour type or bit depth! 9044 */ 9045 while (next_format(&colour_type, &bit_depth, &palette_number, 1/*gamma*/)) 9046 if (palette_number == 0) 9873 * 9874 * CHANGED: now test two palettes and, as a side effect, images with and 9875 * without tRNS. 9876 */ 9877 while (next_format(&colour_type, &bit_depth, &palette_number, 9878 pm->test_lbg_gamma_threshold, pm->test_tRNS)) 9879 if (palette_number < 2) 9047 9880 { 9048 9881 double test_gamma = 1.0; … … 9104 9937 unsigned int palette_number = 0; 9105 9938 9106 while (next_format(&colour_type, &bit_depth, &palette_number, 1/*gamma*/)) 9939 while (next_format(&colour_type, &bit_depth, &palette_number, 9940 pm->test_lbg_gamma_transform, pm->test_tRNS)) 9107 9941 { 9108 9942 unsigned int i, j; … … 9134 9968 unsigned int npalette = 0; 9135 9969 9136 while (next_format(&colour_type, &bit_depth, &npalette, 1/*gamma*/)) 9970 while (next_format(&colour_type, &bit_depth, &npalette, 9971 pm->test_lbg_gamma_sbit, pm->test_tRNS)) 9137 9972 if ((colour_type & PNG_COLOR_MASK_ALPHA) == 0 && 9138 9973 ((colour_type == 3 && sbit < 8) || … … 9325 10160 9326 10161 background.index = 193; /* rgb(193,193,193) to detect errors */ 10162 9327 10163 if (!(colour_type & PNG_COLOR_MASK_COLOR)) 9328 10164 { 10165 /* Because, currently, png_set_background is always called with 10166 * 'need_expand' false in this case and because the gamma test itself 10167 * doesn't cause an expand to 8-bit for lower bit depths the colour must 10168 * be reduced to the correct range. 10169 */ 10170 if (bit_depth < 8) 10171 background.gray &= (png_uint_16)((1U << bit_depth)-1); 10172 9329 10173 /* Grayscale input, we do not convert to RGB (TBD), so we must set the 9330 10174 * background to gray - else libpng seems to fail. … … 9375 10219 /* Skip the non-alpha cases - there is no setting of a transparency colour at 9376 10220 * present. 9377 */ 9378 while (next_format(&colour_type, &bit_depth, &palette_number, 1/*gamma*/)) 9379 if ((colour_type & PNG_COLOR_MASK_ALPHA) != 0) 10221 * 10222 * TODO: incorrect; the palette case sets tRNS and, now RGB and gray do, 10223 * however the palette case fails miserably so is commented out below. 10224 */ 10225 while (next_format(&colour_type, &bit_depth, &palette_number, 10226 pm->test_lbg_gamma_composition, pm->test_tRNS)) 10227 if ((colour_type & PNG_COLOR_MASK_ALPHA) != 0 10228 #if 0 /* TODO: FIXME */ 10229 /*TODO: FIXME: this should work */ 10230 || colour_type == 3 10231 #endif 10232 || (colour_type != 3 && palette_number != 0)) 9380 10233 { 9381 10234 unsigned int i, j; … … 10109 10962 pm.ngamma_tests = 0; /* default to off */ 10110 10963 10964 /* Low bit depth gray images don't do well in the gamma tests, until 10965 * this is fixed turn them off for some gamma cases: 10966 */ 10967 # ifdef PNG_WRITE_tRNS_SUPPORTED 10968 pm.test_tRNS = 1; 10969 # endif 10970 pm.test_lbg = 0; 10971 pm.test_lbg_gamma_threshold = 1; 10972 pm.test_lbg_gamma_transform = 0/*PNG_LIBPNG_VER >= 10700*/; 10973 pm.test_lbg_gamma_sbit = 1; 10974 pm.test_lbg_gamma_composition = 0; 10975 10111 10976 /* And the test encodings */ 10112 10977 pm.encodings = test_encodings; … … 10221 11086 pm.test_gamma_sbit = 1; 10222 11087 pm.test_gamma_scale16 = 1; 10223 pm.test_gamma_background = 1; 11088 pm.test_gamma_background = 1; /* composition */ 10224 11089 pm.test_gamma_alpha_mode = 1; 10225 11090 } … … 10269 11134 else if (strcmp(*argv, "--noexpand16") == 0) 10270 11135 pm.test_gamma_expand16 = 0; 11136 11137 else if (strcmp(*argv, "--low-depth-gray") == 0) 11138 pm.test_lbg = pm.test_lbg_gamma_threshold = 11139 pm.test_lbg_gamma_transform = pm.test_lbg_gamma_sbit = 11140 pm.test_lbg_gamma_composition = 1; 11141 11142 else if (strcmp(*argv, "--nolow-depth-gray") == 0) 11143 pm.test_lbg = pm.test_lbg_gamma_threshold = 11144 pm.test_lbg_gamma_transform = pm.test_lbg_gamma_sbit = 11145 pm.test_lbg_gamma_composition = 0; 11146 11147 # ifdef PNG_WRITE_tRNS_SUPPORTED 11148 else if (strcmp(*argv, "--tRNS") == 0) 11149 pm.test_tRNS = 1; 11150 # endif 11151 11152 else if (strcmp(*argv, "--notRNS") == 0) 11153 pm.test_tRNS = 0; 10271 11154 10272 11155 else if (strcmp(*argv, "--more-gammas") == 0) … … 10460 11343 { 10461 11344 /* Make useful base images */ 10462 make_transform_images(&pm .this);11345 make_transform_images(&pm); 10463 11346 10464 11347 /* Perform the standard and gamma tests. */ -
TabularUnified libpng/vendor/current/contrib/tools/png-fix-itxt.c ¶
r922 r1165 2 2 /* png-fix-itxt version 1.0.0 3 3 * 4 * Copyright 201 3Glenn Randers-Pehrson5 * Last changed in libpng 1.6. 3 [July 18, 2013]4 * Copyright 2015 Glenn Randers-Pehrson 5 * Last changed in libpng 1.6.18 [July 23, 2015] 6 6 * 7 7 * This code is released under the libpng license. … … 35 35 #define MAX_LENGTH 500000 36 36 37 #define GETBREAK ((unsigned char)(inchar=getchar())); if (inchar == EOF) break 38 37 /* Read one character (inchar), also return octet (c), break if EOF */ 38 #define GETBREAK inchar=getchar(); \ 39 c=(inchar & 0xffU);\ 40 if (inchar != c) break 39 41 int 40 42 main(void) … … 49 51 for (i=8; i; i--) 50 52 { 51 c=GETBREAK;53 GETBREAK; 52 54 putchar(c); 53 55 } 54 56 55 if (inchar != EOF)57 if (inchar == c) /* !EOF */ 56 58 for (;;) 57 59 { 58 60 /* Read the length */ 59 61 unsigned long length; /* must be 32 bits! */ 60 c=GETBREAK; buf[0] = c; length = c; length <<= 8;61 c=GETBREAK; buf[1] = c; length += c; length <<= 8;62 c=GETBREAK; buf[2] = c; length += c; length <<= 8;63 c=GETBREAK; buf[3] = c; length += c;62 GETBREAK; buf[0] = c; length = c; length <<= 8; 63 GETBREAK; buf[1] = c; length += c; length <<= 8; 64 GETBREAK; buf[2] = c; length += c; length <<= 8; 65 GETBREAK; buf[3] = c; length += c; 64 66 65 67 /* Read the chunkname */ 66 c=GETBREAK; buf[4] = c;67 c=GETBREAK; buf[5] = c;68 c=GETBREAK; buf[6] = c;69 c=GETBREAK; buf[7] = c;68 GETBREAK; buf[4] = c; 69 GETBREAK; buf[5] = c; 70 GETBREAK; buf[6] = c; 71 GETBREAK; buf[7] = c; 70 72 71 73 … … 82 84 for (i=8; i < length + 12; i++) 83 85 { 84 c=GETBREAK; buf[i] = c;86 GETBREAK; buf[i] = c; 85 87 } 88 89 if (inchar != c) /* EOF */ 90 break; 86 91 87 92 /* Calculate the CRC */ … … 91 96 { 92 97 /* Check the CRC */ 93 if (((crc >> 24) & 0xff ) == buf[length+8] &&94 ((crc >> 16) & 0xff ) == buf[length+9] &&95 ((crc >> 8) & 0xff ) == buf[length+10] &&96 ((crc ) & 0xff ) == buf[length+11])98 if (((crc >> 24) & 0xffU) == buf[length+8] && 99 ((crc >> 16) & 0xffU) == buf[length+9] && 100 ((crc >> 8) & 0xffU) == buf[length+10] && 101 ((crc ) & 0xffU) == buf[length+11]) 97 102 break; 98 103 … … 102 107 break; 103 108 104 c=GETBREAK;105 buf[length+11] =c;109 GETBREAK; 110 buf[length+11] = c; 106 111 107 112 /* Update the CRC */ … … 109 114 } 110 115 116 if (inchar != c) /* EOF */ 117 break; 118 111 119 /* Update length bytes */ 112 buf[0] = (unsigned char)((length << 24) & 0xff);113 buf[1] = (unsigned char)((length << 16) & 0xff);114 buf[2] = (unsigned char)((length << 8) & 0xff);115 buf[3] = (unsigned char)((length ) & 0xff );120 buf[0] = (unsigned char)((length >> 24) & 0xffU); 121 buf[1] = (unsigned char)((length >> 16) & 0xffU); 122 buf[2] = (unsigned char)((length >> 8) & 0xffU); 123 buf[3] = (unsigned char)((length ) & 0xffU); 116 124 117 125 /* Write the fixed iTXt chunk (length, name, data, crc) */ … … 122 130 else 123 131 { 132 if (inchar != c) /* EOF */ 133 break; 134 124 135 /* Copy bytes that were already read (length and chunk name) */ 125 136 for (i=0; i<8; i++) … … 129 140 for (i=8; i< length+12; i++) 130 141 { 131 c=GETBREAK;142 GETBREAK; 132 143 putchar(c); 133 144 } 134 145 135 if (inchar == EOF)146 if (inchar != c) /* EOF */ 136 147 { 137 148 break; … … 143 154 } 144 155 145 if (inchar == EOF)156 if (inchar != c) /* EOF */ 146 157 break; 147 158 -
TabularUnified libpng/vendor/current/contrib/tools/pngfix.c ¶
r1059 r1165 1 1 /* pngfix.c 2 2 * 3 * Copyright (c) 2014 John Cunningham Bowler3 * Copyright (c) 2014-2015 John Cunningham Bowler 4 4 * 5 * Last changed in libpng 1.6.1 4 [October 23, 2014]5 * Last changed in libpng 1.6.18 [July 23, 2015] 6 6 * 7 7 * This code is released under the libpng license. … … 72 72 */ 73 73 #if ZLIB_VERNUM < 0x1260 74 # define PNGZ_MSG_CAST(s) png_constcast(char*,s)75 # define PNGZ_INPUT_CAST(b) png_constcast(png_bytep,b)74 # define PNGZ_MSG_CAST(s) constcast(char*,s) 75 # define PNGZ_INPUT_CAST(b) constcast(png_bytep,b) 76 76 #else 77 77 # define PNGZ_MSG_CAST(s) (s) … … 87 87 /* Copied from pngpriv.h */ 88 88 #ifdef __cplusplus 89 # define png_voidcast(type, value) static_cast<type>(value)90 # define png_constcast(type, value) const_cast<type>(value)91 # define png_aligncast(type, value) \89 # define voidcast(type, value) static_cast<type>(value) 90 # define constcast(type, value) const_cast<type>(value) 91 # define aligncast(type, value) \ 92 92 static_cast<type>(static_cast<void*>(value)) 93 # define png_aligncastconst(type, value) \93 # define aligncastconst(type, value) \ 94 94 static_cast<type>(static_cast<const void*>(value)) 95 95 #else 96 # define png_voidcast(type, value) (value)97 # define png_constcast(type, value) ((type)(value))98 # define png_aligncast(type, value) ((void*)(value))99 # define png_aligncastconst(type, value) ((const void*)(value))96 # define voidcast(type, value) (value) 97 # define constcast(type, value) ((type)(value)) 98 # define aligncast(type, value) ((void*)(value)) 99 # define aligncastconst(type, value) ((const void*)(value)) 100 100 #endif /* __cplusplus */ 101 101 … … 447 447 { 448 448 png_uint_32 u0 = seed[0], u1 = seed[1]; 449 png_bytep bytes = png_voidcast(png_bytep, pv);449 png_bytep bytes = voidcast(png_bytep, pv); 450 450 451 451 /* There are thirty-three bits; the next bit in the sequence is bit-33 XOR … … 669 669 length = tail->length; 670 670 671 next = png_voidcast(IDAT_list*, malloc(IDAT_list_size(NULL, length)));671 next = voidcast(IDAT_list*, malloc(IDAT_list_size(NULL, length))); 672 672 CLEAR(*next); 673 673 … … 2139 2139 * z-rc is the zlib failure code; message is the error message with 2140 2140 * spaces replaced by '-'. The compressed byte count indicates where 2141 * in the zlib stream the error occur ed.2141 * in the zlib stream the error occurred. 2142 2142 */ 2143 2143 type_name(zlib->chunk->chunk_type, stdout); … … 3536 3536 * don't always exist. 3537 3537 */ 3538 struct control *control = png_voidcast(struct control*,3538 struct control *control = voidcast(struct control*, 3539 3539 png_get_error_ptr(png_ptr)); 3540 3540 return &control->file; … … 3544 3544 allocate(struct file *file, int allocate_idat) 3545 3545 { 3546 struct control *control = png_voidcast(struct control*, file->alloc_ptr);3546 struct control *control = voidcast(struct control*, file->alloc_ptr); 3547 3547 3548 3548 if (allocate_idat) … … 3578 3578 png_structp png_ptr; 3579 3579 png_infop info_ptr = NULL; 3580 volatile png_bytep row = NULL, display = NULL;3581 3580 volatile int rc; 3582 3581 3583 png_ptr = png_create_read_struct( png_get_libpng_ver(NULL), control,3582 png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, control, 3584 3583 error_handler, warning_handler); 3585 3584 … … 3595 3594 if (rc == 0) 3596 3595 { 3596 # ifdef PNG_SET_USER_LIMITS_SUPPORTED 3597 /* Remove any limits on the size of PNG files that can be read, 3598 * without this we may reject files based on built-in safety 3599 * limits. 3600 */ 3601 png_set_user_limits(png_ptr, 0x7fffffff, 0x7fffffff); 3602 png_set_chunk_cache_max(png_ptr, 0); 3603 png_set_chunk_malloc_max(png_ptr, 0); 3604 # endif 3605 3597 3606 png_set_read_fn(png_ptr, control, read_callback); 3598 3607 … … 3607 3616 3608 3617 { 3609 png_size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr); 3610 3611 row = png_voidcast(png_byte*, malloc(rowbytes)); 3612 display = png_voidcast(png_byte*, malloc(rowbytes)); 3613 3614 if (row == NULL || display == NULL) 3615 png_error(png_ptr, "OOM allocating row buffers"); 3616 3617 { 3618 png_uint_32 height = png_get_image_height(png_ptr, info_ptr); 3619 int passes = png_set_interlace_handling(png_ptr); 3620 int pass; 3621 3622 png_start_read_image(png_ptr); 3623 3624 for (pass = 0; pass < passes; ++pass) 3625 { 3626 png_uint_32 y = height; 3627 3628 /* NOTE: this trashes the row each time; interlace handling won't 3629 * work, but this avoids memory thrashing for speed testing. 3630 */ 3631 while (y-- > 0) 3632 png_read_row(png_ptr, row, display); 3633 } 3634 } 3618 png_uint_32 height = png_get_image_height(png_ptr, info_ptr); 3619 int passes = png_set_interlace_handling(png_ptr); 3620 int pass; 3621 3622 png_start_read_image(png_ptr); 3623 3624 for (pass = 0; pass < passes; ++pass) 3625 { 3626 png_uint_32 y = height; 3627 3628 /* NOTE: this skips asking libpng to return either version of 3629 * the image row, but libpng still reads the rows. 3630 */ 3631 while (y-- > 0) 3632 png_read_row(png_ptr, NULL, NULL); 3633 } 3635 3634 } 3636 3635 … … 3643 3642 3644 3643 png_destroy_read_struct(&png_ptr, &info_ptr, NULL); 3645 if (row != NULL) free(row);3646 if (display != NULL) free(display);3647 3644 return rc; 3648 3645 } … … 3706 3703 " values.", 3707 3704 " cHRM, iCCP [color]: These specify how colors are encoded. iCCP also", 3708 " specifies the exact encoding of a pixel value however in practice",3709 " most programs will ignore it.",3705 " specifies the exact encoding of a pixel value; however, in", 3706 " practice most programs will ignore it.", 3710 3707 " bKGD [transform]: This is used by libpng transforms." 3711 3708 " --max=<number>:", … … 3713 3710 " chunks will be the maximum size permitted; 2^31-1 bytes. If the option", 3714 3711 " is omitted the original chunk sizes will not be changed. When the", 3715 " option is given --strip=unsafe is set automatically , this may be",3712 " option is given --strip=unsafe is set automatically. This may be", 3716 3713 " cancelled if you know that all unknown unsafe-to-copy chunks really are", 3717 3714 " safe to copy across an IDAT size change. This is true of all chunks", … … 3720 3717 " By default the program only outputs summaries for each file.", 3721 3718 " --quiet (-q):", 3722 " Do not output the summaries except for files whichcannot be read. With",3719 " Do not output the summaries except for files that cannot be read. With", 3723 3720 " two --quiets these are not output either.", 3724 3721 " --errors (-e):", … … 3753 3750 " together - check one file at a time to get a meaningful error code!", 3754 3751 " 0x01: The zlib too-far-back error existed in at least one chunk.", 3755 " 0x02: At least on ce chunk had a CRC error.",3752 " 0x02: At least one chunk had a CRC error.", 3756 3753 " 0x04: A chunk length was incorrect.", 3757 3754 " 0x08: The file was truncated.", … … 3761 3758 " 0x10: The file could not be read, even with corrections.", 3762 3759 " 0x20: The output file could not be written.", 3763 " 0x40: An unexpected, potentially internal, error occur ed.",3760 " 0x40: An unexpected, potentially internal, error occurred.", 3764 3761 " If the command line arguments are incorrect the program exits with exit", 3765 3762 " 255. Some older operating systems only support 7-bit exit codes, on those", … … 3821 3818 " explanation 'message'", 3822 3819 " ERR: The read of the file was aborted. The parameters explain why.", 3823 "$3 status: For 'ERR' the accumulate status code from 'EXIT CODES' above.",3820 "$3 status: For 'ERR' the accumulated status code from 'EXIT CODES' above.", 3824 3821 " This is printed as a 2 digit hexadecimal value", 3825 3822 " comp-level: The recorded compression level (FLEVEL) of a zlib stream", … … 3857 3854 main(int argc, const char **argv) 3858 3855 { 3856 char temp_name[FILENAME_MAX+1]; 3859 3857 const char * prog = *argv; 3860 3858 const char * outfile = NULL; … … 3959 3957 { 3960 3958 size_t outlen = strlen(*argv); 3961 char temp_name[FILENAME_MAX+1];3962 3959 3963 3960 if (outfile == NULL) /* else this takes precedence */ -
TabularUnified libpng/vendor/current/contrib/visupng/cexcept.h ¶
r922 r1165 1 1 /*=== 2 cexcept.h 2.0.1 (2008-Jul-19-Sat )2 cexcept.h 2.0.1 (2008-Jul-19-Sat, modified 2015-Jun-03-Mon) 3 3 http://www.nicemice.net/cexcept/ 4 4 Adam M. Costello … … 6 6 7 7 An interface for exception-handling in ANSI C (C89 and subsequent ISO 8 standards), developed jointly with Cosmin Truta. 8 standards), developed jointly with Cosmin Truta. Revised by John Bowler, 9 June 2015, to declare exception_env and exception_prev "volatile". 9 10 10 11 Copyright (c) 2000-2008 Adam M. Costello and Cosmin Truta. … … 211 212 #define Try \ 212 213 { \ 213 jmp_buf * exception__prev, exception__env; \214 jmp_buf * volatile exception__prev, exception__env; \ 214 215 exception__prev = the_exception_context->penv; \ 215 216 the_exception_context->penv = &exception__env; \ -
TabularUnified libpng/vendor/current/depcomp ¶
r922 r1165 4 4 scriptversion=2013-05-30.07; # UTC 5 5 6 # Copyright (C) 1999-201 3Free Software Foundation, Inc.6 # Copyright (C) 1999-2014 Free Software Foundation, Inc. 7 7 8 8 # This program is free software; you can redistribute it and/or modify -
TabularUnified libpng/vendor/current/libpng-manual.txt ¶
r1059 r1165 1 1 libpng-manual.txt - A description on how to use and modify libpng 2 2 3 libpng version 1.6.1 6 - December 22, 20143 libpng version 1.6.18 - July 23, 2015 4 4 Updated and distributed by Glenn Randers-Pehrson 5 5 <glennrp at users.sourceforge.net> 6 Copyright (c) 1998-201 4Glenn Randers-Pehrson6 Copyright (c) 1998-2015 Glenn Randers-Pehrson 7 7 8 8 This document is released under the libpng license. … … 12 12 Based on: 13 13 14 libpng versions 0.97, January 1998, through 1.6.1 6 - December 22, 201414 libpng versions 0.97, January 1998, through 1.6.18 - July 23, 2015 15 15 Updated and distributed by Glenn Randers-Pehrson 16 Copyright (c) 1998-201 4Glenn Randers-Pehrson16 Copyright (c) 1998-2015 Glenn Randers-Pehrson 17 17 18 18 libpng 1.0 beta 6 - version 0.96 - May 28, 1997 … … 337 337 If you are intending to keep the file pointer open for use in libpng, 338 338 you must ensure you don't read more than 8 bytes from the beginning 339 of the file, and you also have to make a call to png_set_sig_bytes _read()339 of the file, and you also have to make a call to png_set_sig_bytes() 340 340 with the number of bytes you read from the beginning. Libpng will 341 341 then only check the bytes (if any) that your program didn't read. … … 344 344 to replace them with custom functions. See the discussion under 345 345 Customizing libpng. 346 347 346 348 347 FILE *fp = fopen(file_name, "rb"); … … 352 351 } 353 352 354 fread(header, 1, number, fp); 353 if (fread(header, 1, number, fp) != number) 354 { 355 return (ERROR); 356 } 357 355 358 is_png = !png_sig_cmp(header, 0, number); 356 357 359 if (!is_png) 358 360 { 359 361 return (NOT_PNG); 360 362 } 361 362 363 363 364 Next, png_struct and png_info need to be allocated and initialized. In … … 650 651 large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns. 651 652 Larger images will be rejected immediately with a png_error() call. If 652 you wish to reduce these limits, you can use653 you wish to change these limits, you can use 653 654 654 655 png_set_user_limits(png_ptr, width_max, height_max); … … 1265 1266 a MNG-1.0 datastream) 1266 1267 1267 Any o r all of interlace_type, compression_type, or1268 filter_method can be NULL if you are1269 not interested in their values.1268 Any of width, height, color_type, bit_depth, 1269 interlace_type, compression_type, or filter_method can 1270 be NULL if you are not interested in their values. 1270 1271 1271 1272 Note that png_get_IHDR() returns 32-bit data into 1272 1273 the application's width and height variables. 1273 This is an unsafe situation if these are 16-bit1274 This is an unsafe situation if these are not png_uint_32 1274 1275 variables. In such situations, the 1275 1276 png_get_image_width() and png_get_image_height() … … 1994 1995 1995 1996 If you need to reduce an RGB file to a paletted file, or if a paletted 1996 file has more entries th en will fit on your screen, png_set_quantize()1997 file has more entries than will fit on your screen, png_set_quantize() 1997 1998 will do that. Note that this is a simple match quantization that merely 1998 1999 finds the closest color available. This should work fairly well with … … 2547 2548 of 4K. Although you can give it much less if 2548 2549 necessary (I assume you can give it chunks of 2549 1 byte, I haven't tried less th en 256 bytes2550 1 byte, I haven't tried less than 256 bytes 2550 2551 yet). When this function returns, you may 2551 2552 want to display any rows that were generated … … 4065 4066 With all APIs row_stride is handled as in the read APIs - it is the spacing 4066 4067 from one row to the next in component sized units (float) and if negative 4067 indicates a bottom-up row layout in the buffer. 4068 indicates a bottom-up row layout in the buffer. If you pass zero, libpng will 4069 calculate the row_stride for you from the width and number of channels. 4068 4070 4069 4071 Note that the write API does not support interlacing, sub-8-bit pixels, 4070 and indexed (paletted) images.4072 indexed (paletted) images, or most ancillary chunks. 4071 4073 4072 4074 VI. Modifying/Customizing libpng … … 4355 4357 same as the value of filter_method used 4356 4358 in png_set_IHDR(). 4357 4358 It is also possible to influence how libpng chooses from among the4359 available filters. This is done in one or both of two ways - by4360 telling it how important it is to keep the same filter for successive4361 rows, and by telling it the relative computational costs of the filters.4362 4363 double weights[3] = {1.5, 1.3, 1.1},4364 costs[PNG_FILTER_VALUE_LAST] =4365 {1.0, 1.3, 1.3, 1.5, 1.7};4366 4367 png_set_filter_heuristics(png_ptr,4368 PNG_FILTER_HEURISTIC_WEIGHTED, 3,4369 weights, costs);4370 4371 The weights are multiplying factors that indicate to libpng that the4372 row filter should be the same for successive rows unless another row filter4373 is that many times better than the previous filter. In the above example,4374 if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a4375 "sum of absolute differences" 1.5 x 1.3 times higher than other filters4376 and still be chosen, while the NONE filter could have a sum 1.1 times4377 higher than other filters and still be chosen. Unspecified weights are4378 taken to be 1.0, and the specified weights should probably be declining4379 like those above in order to emphasize recent filters over older filters.4380 4381 The filter costs specify for each filter type a relative decoding cost4382 to be considered when selecting row filters. This means that filters4383 with higher costs are less likely to be chosen over filters with lower4384 costs, unless their "sum of absolute differences" is that much smaller.4385 The costs do not necessarily reflect the exact computational speeds of4386 the various filters, since this would unduly influence the final image4387 size.4388 4389 Note that the numbers above were invented purely for this example and4390 are given only to help explain the function usage. Little testing has4391 been done to find optimum values for either the costs or the weights.4392 4359 4393 4360 Requesting debug printout … … 5032 4999 where "rp" indicates a "restricted pointer". 5033 5000 5001 The support for FAR/far types has been eliminated and the definition of 5002 png_alloc_size_t is now controlled by a flag so that 'small size_t' systems 5003 can select it if necessary. 5004 5034 5005 Error detection in some chunks has improved; in particular the iCCP chunk 5035 5006 reader now does pretty complete validation of the basic format. Some bad … … 5046 5017 #endif 5047 5018 5048 It's not a good idea to do this if you are using the new"simplified API",5019 It's not a good idea to do this if you are using the "simplified API", 5049 5020 which needs to be able to recognize sRGB profiles conveyed via the iCCP 5050 5021 chunk. … … 5105 5076 contrib/tools/png-fix-itxt) has been added to the libpng distribution. 5106 5077 5078 Starting with libpng-1.6.17, the PNG_SAFE_LIMITS macro was eliminated 5079 and safe limits are used by default (users who need larger limits 5080 can still override them at compile time or run time, as described above). 5081 5082 The new limits are 5083 default spec limit 5084 png_user_width_max 1,000,000 2,147,483,647 5085 png_user_height_max 1,000,000 2,147,483,647 5086 png_user_chunk_cache_max 128 unlimited 5087 png_user_chunk_malloc_max 8,000,000 unlimited 5088 5089 Starting with libpng-1.6.18, a PNG_RELEASE_BUILD macro was added, which allows 5090 library builders to control compilation for an installed system (a release build). 5091 It can be set for testing debug or beta builds to ensure that they will compile 5092 when the build type is switched to RC or STABLE. In essence this overrides the 5093 PNG_LIBPNG_BUILD_BASE_TYPE definition which is not directly user controllable. 5094 5107 5095 XIII. Detecting libpng 5108 5096 … … 5275 5263 XVI. Y2K Compliance in libpng 5276 5264 5277 December 22, 2014 5265 July 23, 2015 5278 5266 5279 5267 Since the PNG Development group is an ad-hoc body, we can't make … … 5281 5269 5282 5270 This is your unofficial assurance that libpng from version 0.71 and 5283 upward through 1.6.1 6are Y2K compliant. It is my belief that earlier5271 upward through 1.6.18 are Y2K compliant. It is my belief that earlier 5284 5272 versions were also Y2K compliant. 5285 5273 -
TabularUnified libpng/vendor/current/libpng.3 ¶
r1059 r1165 1 .TH LIBPNG 3 " December 22, 2014"1 .TH LIBPNG 3 "July 23, 2015" 2 2 .SH NAME 3 libpng \- Portable Network Graphics (PNG) Reference Library 1.6.1 63 libpng \- Portable Network Graphics (PNG) Reference Library 1.6.18 4 4 .SH SYNOPSIS 5 5 \fB … … 120 120 \fBpng_byte png_get_libpng_ver (png_const_structp \fIpng_ptr\fP\fB);\fP 121 121 122 \fBint png_get_palette_max(png_const_structp \fP\fIpng_ptr\fP\fB, png_const_infop \fIinfo_ptr\fP\fB);\fP 123 122 124 \fBpng_voidp png_get_mem_ptr (png_const_structp \fIpng_ptr\fP\fB);\fP 123 125 … … 369 371 370 372 \fBvoid png_set_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIoffset_x\fP\fB, png_uint_32 \fP\fIoffset_y\fP\fB, int \fIunit_type\fP\fB);\fP 373 374 \fBint png_set_option(png_structrp \fP\fIpng_ptr\fP\fB, int \fP\fIoption\fP\fB, int \fIonoff\fP\fB);\fP 371 375 372 376 \fBvoid png_set_packing (png_structp \fIpng_ptr\fP\fB);\fP … … 505 509 libpng-manual.txt - A description on how to use and modify libpng 506 510 507 libpng version 1.6.1 6 - December 22, 2014511 libpng version 1.6.18 - July 23, 2015 508 512 Updated and distributed by Glenn Randers-Pehrson 509 513 <glennrp at users.sourceforge.net> 510 Copyright (c) 1998-201 4Glenn Randers-Pehrson514 Copyright (c) 1998-2015 Glenn Randers-Pehrson 511 515 512 516 This document is released under the libpng license. … … 516 520 Based on: 517 521 518 libpng versions 0.97, January 1998, through 1.6.1 6 - December 22, 2014522 libpng versions 0.97, January 1998, through 1.6.18 - July 23, 2015 519 523 Updated and distributed by Glenn Randers-Pehrson 520 Copyright (c) 1998-201 4Glenn Randers-Pehrson524 Copyright (c) 1998-2015 Glenn Randers-Pehrson 521 525 522 526 libpng 1.0 beta 6 - version 0.96 - May 28, 1997 … … 841 845 If you are intending to keep the file pointer open for use in libpng, 842 846 you must ensure you don't read more than 8 bytes from the beginning 843 of the file, and you also have to make a call to png_set_sig_bytes _read()847 of the file, and you also have to make a call to png_set_sig_bytes() 844 848 with the number of bytes you read from the beginning. Libpng will 845 849 then only check the bytes (if any) that your program didn't read. … … 848 852 to replace them with custom functions. See the discussion under 849 853 Customizing libpng. 850 851 854 852 855 FILE *fp = fopen(file_name, "rb"); … … 856 859 } 857 860 858 fread(header, 1, number, fp); 861 if (fread(header, 1, number, fp) != number) 862 { 863 return (ERROR); 864 } 865 859 866 is_png = !png_sig_cmp(header, 0, number); 860 861 867 if (!is_png) 862 868 { 863 869 return (NOT_PNG); 864 870 } 865 866 871 867 872 Next, png_struct and png_info need to be allocated and initialized. In … … 1154 1159 large as 2^(31\-1 (0x7fffffff), or about 2.147 billion rows and columns. 1155 1160 Larger images will be rejected immediately with a png_error() call. If 1156 you wish to reduce these limits, you can use1161 you wish to change these limits, you can use 1157 1162 1158 1163 png_set_user_limits(png_ptr, width_max, height_max); … … 1769 1774 a MNG-1.0 datastream) 1770 1775 1771 Any o r all of interlace_type, compression_type, or1772 filter_method can be NULL if you are1773 not interested in their values.1776 Any of width, height, color_type, bit_depth, 1777 interlace_type, compression_type, or filter_method can 1778 be NULL if you are not interested in their values. 1774 1779 1775 1780 Note that png_get_IHDR() returns 32-bit data into 1776 1781 the application's width and height variables. 1777 This is an unsafe situation if these are 16-bit1782 This is an unsafe situation if these are not png_uint_32 1778 1783 variables. In such situations, the 1779 1784 png_get_image_width() and png_get_image_height() … … 2498 2503 2499 2504 If you need to reduce an RGB file to a paletted file, or if a paletted 2500 file has more entries th en will fit on your screen, png_set_quantize()2505 file has more entries than will fit on your screen, png_set_quantize() 2501 2506 will do that. Note that this is a simple match quantization that merely 2502 2507 finds the closest color available. This should work fairly well with … … 3051 3056 of 4K. Although you can give it much less if 3052 3057 necessary (I assume you can give it chunks of 3053 1 byte, I haven't tried less th en 256 bytes3058 1 byte, I haven't tried less than 256 bytes 3054 3059 yet). When this function returns, you may 3055 3060 want to display any rows that were generated … … 4569 4574 With all APIs row_stride is handled as in the read APIs - it is the spacing 4570 4575 from one row to the next in component sized units (float) and if negative 4571 indicates a bottom-up row layout in the buffer. 4576 indicates a bottom-up row layout in the buffer. If you pass zero, libpng will 4577 calculate the row_stride for you from the width and number of channels. 4572 4578 4573 4579 Note that the write API does not support interlacing, sub-8-bit pixels, 4574 and indexed (paletted) images.4580 indexed (paletted) images, or most ancillary chunks. 4575 4581 4576 4582 .SH VI. Modifying/Customizing libpng … … 4859 4865 same as the value of filter_method used 4860 4866 in png_set_IHDR(). 4861 4862 It is also possible to influence how libpng chooses from among the4863 available filters. This is done in one or both of two ways - by4864 telling it how important it is to keep the same filter for successive4865 rows, and by telling it the relative computational costs of the filters.4866 4867 double weights[3] = {1.5, 1.3, 1.1},4868 costs[PNG_FILTER_VALUE_LAST] =4869 {1.0, 1.3, 1.3, 1.5, 1.7};4870 4871 png_set_filter_heuristics(png_ptr,4872 PNG_FILTER_HEURISTIC_WEIGHTED, 3,4873 weights, costs);4874 4875 The weights are multiplying factors that indicate to libpng that the4876 row filter should be the same for successive rows unless another row filter4877 is that many times better than the previous filter. In the above example,4878 if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a4879 "sum of absolute differences" 1.5 x 1.3 times higher than other filters4880 and still be chosen, while the NONE filter could have a sum 1.1 times4881 higher than other filters and still be chosen. Unspecified weights are4882 taken to be 1.0, and the specified weights should probably be declining4883 like those above in order to emphasize recent filters over older filters.4884 4885 The filter costs specify for each filter type a relative decoding cost4886 to be considered when selecting row filters. This means that filters4887 with higher costs are less likely to be chosen over filters with lower4888 costs, unless their "sum of absolute differences" is that much smaller.4889 The costs do not necessarily reflect the exact computational speeds of4890 the various filters, since this would unduly influence the final image4891 size.4892 4893 Note that the numbers above were invented purely for this example and4894 are given only to help explain the function usage. Little testing has4895 been done to find optimum values for either the costs or the weights.4896 4867 4897 4868 .SS Requesting debug printout … … 5536 5507 where "rp" indicates a "restricted pointer". 5537 5508 5509 The support for FAR/far types has been eliminated and the definition of 5510 png_alloc_size_t is now controlled by a flag so that 'small size_t' systems 5511 can select it if necessary. 5512 5538 5513 Error detection in some chunks has improved; in particular the iCCP chunk 5539 5514 reader now does pretty complete validation of the basic format. Some bad … … 5550 5525 #endif 5551 5526 5552 It's not a good idea to do this if you are using the new"simplified API",5527 It's not a good idea to do this if you are using the "simplified API", 5553 5528 which needs to be able to recognize sRGB profiles conveyed via the iCCP 5554 5529 chunk. … … 5609 5584 contrib/tools/png-fix-itxt) has been added to the libpng distribution. 5610 5585 5586 Starting with libpng-1.6.17, the PNG_SAFE_LIMITS macro was eliminated 5587 and safe limits are used by default (users who need larger limits 5588 can still override them at compile time or run time, as described above). 5589 5590 The new limits are 5591 default spec limit 5592 png_user_width_max 1,000,000 2,147,483,647 5593 png_user_height_max 1,000,000 2,147,483,647 5594 png_user_chunk_cache_max 128 unlimited 5595 png_user_chunk_malloc_max 8,000,000 unlimited 5596 5597 Starting with libpng-1.6.18, a PNG_RELEASE_BUILD macro was added, which allows 5598 library builders to control compilation for an installed system (a release build). 5599 It can be set for testing debug or beta builds to ensure that they will compile 5600 when the build type is switched to RC or STABLE. In essence this overrides the 5601 PNG_LIBPNG_BUILD_BASE_TYPE definition which is not directly user controllable. 5602 5611 5603 .SH XIII. Detecting libpng 5612 5604 … … 5779 5771 .SH XVI. Y2K Compliance in libpng 5780 5772 5781 December 22, 2014 5773 July 23, 2015 5782 5774 5783 5775 Since the PNG Development group is an ad-hoc body, we can't make … … 5785 5777 5786 5778 This is your unofficial assurance that libpng from version 0.71 and 5787 upward through 1.6.1 6are Y2K compliant. It is my belief that earlier5779 upward through 1.6.18 are Y2K compliant. It is my belief that earlier 5788 5780 versions were also Y2K compliant. 5789 5781 … … 6037 6029 1.6.16rc01-02 16 10616 16.so.16.16[.0] 6038 6030 1.6.16 16 10616 16.so.16.16[.0] 6031 1.6.17beta01-06 16 10617 16.so.16.17[.0] 6032 1.6.17rc01-06 16 10617 16.so.16.17[.0] 6033 1.6.17 16 10617 16.so.16.17[.0] 6034 1.6.18beta01-09 16 10618 16.so.16.18[.0] 6035 1.6.18rc01-03 16 10618 16.so.16.18[.0] 6036 1.6.18 16 10618 16.so.16.18[.0] 6039 6037 6040 6038 Henceforth the source version will match the shared-library minor … … 6093 6091 Thanks to Frank J. T. Wojcik for helping with the documentation. 6094 6092 6095 Libpng version 1.6.1 6 - December 22, 2014:6093 Libpng version 1.6.18 - July 23, 2015: 6096 6094 Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc. 6097 6095 Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net). … … 6116 6114 This code is released under the libpng license. 6117 6115 6118 libpng versions 1.2.6, August 15, 2004, through 1.6.16, December 22, 2014, are 6119 Copyright (c) 2004,2006-2014 Glenn Randers-Pehrson, and are 6120 distributed according to the same disclaimer and license as libpng-1.2.5 6121 with the following individual added to the list of Contributing Authors 6122 6123 Cosmin Truta 6124 6125 libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are 6126 Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are 6116 libpng versions 1.0.7, July 1, 2000, through 1.6.18, July 23, 2015, are 6117 Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, and are 6127 6118 distributed according to the same disclaimer and license as libpng-1.0.6 6128 with the following individuals added to the list of Contributing Authors 6119 with the following individuals added to the list of Contributing Authors: 6129 6120 6130 6121 Simon-Pierre Cadieux 6131 6122 Eric S. Raymond 6123 Mans Rullgard 6124 Cosmin Truta 6132 6125 Gilles Vollant 6126 James Yu 6133 6127 6134 6128 and with the following additions to the disclaimer: 6135 6129 6136 There is no warranty against interference with your 6137 enjoyment of the library or against infringement. 6138 There is no warranty that our efforts or the library 6139 will fulfill any of your particular purposes or needs. 6140 This library is provided with all faults, and the entire 6141 risk of satisfactory quality, performance, accuracy, and 6142 effort is with the user. 6130 There is no warranty against interference with your enjoyment of the 6131 library or against infringement. There is no warranty that our 6132 efforts or the library will fulfill any of your particular purposes 6133 or needs. This library is provided with all faults, and the entire 6134 risk of satisfactory quality, performance, accuracy, and effort is with 6135 the user. 6143 6136 6144 6137 libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are 6145 Copyright (c) 1998 , 1999 Glenn Randers-Pehrson6146 Distributed according to the same disclaimer and license as libpng-0.96, 6147 with the followingindividuals added to the list of Contributing Authors:6138 Copyright (c) 1998-2000 Glenn Randers-Pehrson, and are distributed according 6139 to the same disclaimer and license as libpng-0.96, with the following 6140 individuals added to the list of Contributing Authors: 6148 6141 6149 6142 Tom Lane … … 6152 6145 6153 6146 libpng versions 0.89, June 1996, through 0.96, May 1997, are 6154 Copyright (c) 1996 , 1997 Andreas Dilger6155 Distributed according to the same disclaimer and license as libpng-0.88,6147 Copyright (c) 1996-1997 Andreas Dilger, and are 6148 distributed according to the same disclaimer and license as libpng-0.88, 6156 6149 with the following individuals added to the list of Contributing Authors: 6157 6150 … … 6164 6157 6165 6158 libpng versions 0.5, May 1995, through 0.88, January 1996, are 6166 Copyright (c) 1995 ,1996 Guy Eric Schalnat, Group 42, Inc.6159 Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. 6167 6160 6168 6161 For the purposes of this copyright and license, "Contributing Authors" … … 6187 6180 to the following restrictions: 6188 6181 6189 1. The origin of this source code must not be misrepresented.6190 6191 2. Altered versions must be plainly marked as such and 6192 must notbe misrepresented as being the original source.6193 6194 3. This Copyright notice may not be removed or altered from 6195 anysource or altered source distribution.6182 1. The origin of this source code must not be misrepresented. 6183 6184 2. Altered versions must be plainly marked as such and must not 6185 be misrepresented as being the original source. 6186 6187 3. This Copyright notice may not be removed or altered from any 6188 source or altered source distribution. 6196 6189 6197 6190 The Contributing Authors and Group 42, Inc. specifically permit, without … … 6201 6194 appreciated. 6202 6195 6203 6204 6196 A "png_get_copyright" function is available, for convenient use in "about" 6205 6197 boxes and the like: 6206 6198 6207 printf("%s", png_get_copyright(NULL));6199 printf("%s", png_get_copyright(NULL)); 6208 6200 6209 6201 Also, the PNG logo (in PNG format, of course) is supplied in the 6210 6202 files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). 6211 6203 6212 Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a 6213 certification mark of the Open Source Initiative. 6204 Libpng is OSI Certified Open Source Software. OSI Certified Open Source is 6205 a certification mark of the Open Source Initiative. OSI has not addressed 6206 the additional disclaimers inserted at version 1.0.7. 6214 6207 6215 6208 Glenn Randers-Pehrson 6216 6209 glennrp at users.sourceforge.net 6217 December 22, 2014 6210 July 23, 2015 6218 6211 6219 6212 .\" end of man page -
TabularUnified libpng/vendor/current/libpngpf.3 ¶
r1059 r1165 1 .TH LIBPNGPF 3 " December 22, 2014"1 .TH LIBPNGPF 3 "July 23, 2015" 2 2 .SH NAME 3 libpng \- Portable Network Graphics (PNG) Reference Library 1.6.1 63 libpng \- Portable Network Graphics (PNG) Reference Library 1.6.18 4 4 (private functions) 5 5 .SH SYNOPSIS -
TabularUnified libpng/vendor/current/png.5 ¶
r1059 r1165 1 .TH PNG 5 " December 22, 2014"1 .TH PNG 5 "July 23, 2015" 2 2 .SH NAME 3 3 png \- Portable Network Graphics (PNG) format -
TabularUnified libpng/vendor/current/png.c ¶
r1059 r1165 2 2 /* png.c - location for general purpose libpng functions 3 3 * 4 * Last changed in libpng 1.6.1 6 [December 22, 2014]5 * Copyright (c) 1998-201 4Glenn Randers-Pehrson4 * Last changed in libpng 1.6.18 [July 23, 2015] 5 * Copyright (c) 1998-2015 Glenn Randers-Pehrson 6 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 7 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) … … 15 15 16 16 /* Generate a compiler error if there is an old png.h in the search path. */ 17 typedef png_libpng_version_1_6_1 6 Your_png_h_is_not_version_1_6_16;17 typedef png_libpng_version_1_6_18 Your_png_h_is_not_version_1_6_18; 18 18 19 19 /* Tells libpng that we have already handled the first "num_bytes" bytes … … 35 35 png_error(png_ptr, "Too many bytes for PNG signature"); 36 36 37 png_ptr->sig_bytes = (png_byte)( num_bytes < 0 ? 0 : num_bytes);37 png_ptr->sig_bytes = (png_byte)((num_bytes < 0 ? 0 : num_bytes) & 0xff); 38 38 } 39 39 … … 102 102 png_reset_crc(png_structrp png_ptr) 103 103 { 104 /* The cast is safe because the crc is a 32 104 /* The cast is safe because the crc is a 32-bit value. */ 105 105 png_ptr->crc = (png_uint_32)crc32(0, Z_NULL, 0); 106 106 } … … 130 130 131 131 /* 'uLong' is defined in zlib.h as unsigned long; this means that on some 132 * systems it is a 64 132 * systems it is a 64-bit value. crc32, however, returns 32 bits so the 133 133 * following cast is safe. 'uInt' may be no more than 16 bits, so it is 134 134 * necessary to perform a loop here. … … 141 141 { 142 142 uInt safe_length = (uInt)length; 143 #ifndef __COVERITY__ 143 144 if (safe_length == 0) 144 145 safe_length = (uInt)-1; /* evil, but safe */ 146 #endif 145 147 146 148 crc = crc32(crc, ptr, safe_length); … … 242 244 243 245 # ifdef PNG_USER_CHUNK_CACHE_MAX 244 245 246 /* Added at libpng-1.2.43 and 1.4.0 */ 247 create_struct.user_chunk_cache_max = PNG_USER_CHUNK_CACHE_MAX; 246 248 # endif 247 249 248 250 # ifdef PNG_USER_CHUNK_MALLOC_MAX 249 250 251 252 251 /* Added at libpng-1.2.43 and 1.4.1, required only for read but exists 252 * in png_struct regardless. 253 */ 254 create_struct.user_chunk_malloc_max = PNG_USER_CHUNK_MALLOC_MAX; 253 255 # endif 254 256 # endif … … 274 276 # ifdef PNG_SETJMP_SUPPORTED 275 277 if (!setjmp(create_jmp_buf)) 278 # endif 276 279 { 280 # ifdef PNG_SETJMP_SUPPORTED 277 281 /* Temporarily fake out the longjmp information until we have 278 282 * successfully completed this function. This only works if we have … … 283 287 create_struct.jmp_buf_size = 0; /*stack allocation*/ 284 288 create_struct.longjmp_fn = longjmp; 285 # else286 {287 289 # endif 288 290 /* Call the general version checker (shared with read and write code): … … 303 305 304 306 # ifdef PNG_SETJMP_SUPPORTED 305 306 307 308 307 /* Eliminate the local error handling: */ 308 create_struct.jmp_buf_ptr = NULL; 309 create_struct.jmp_buf_size = 0; 310 create_struct.longjmp_fn = 0; 309 311 # endif 310 312 … … 477 479 if (((mask & PNG_FREE_TRNS) & info_ptr->free_me) != 0) 478 480 { 481 info_ptr->valid &= ~PNG_INFO_tRNS; 479 482 png_free(png_ptr, info_ptr->trans_alpha); 480 483 info_ptr->trans_alpha = NULL; 481 info_ptr-> valid &= ~PNG_INFO_tRNS;484 info_ptr->num_trans = 0; 482 485 } 483 486 #endif … … 545 548 else 546 549 { 547 if (info_ptr->splt_palettes_num != 0) 550 int i; 551 552 for (i = 0; i < info_ptr->splt_palettes_num; i++) 548 553 { 549 int i; 550 551 for (i = 0; i < info_ptr->splt_palettes_num; i++) 552 { 553 png_free(png_ptr, info_ptr->splt_palettes[i].name); 554 png_free(png_ptr, info_ptr->splt_palettes[i].entries); 555 } 556 557 png_free(png_ptr, info_ptr->splt_palettes); 558 info_ptr->splt_palettes = NULL; 559 info_ptr->splt_palettes_num = 0; 554 png_free(png_ptr, info_ptr->splt_palettes[i].name); 555 png_free(png_ptr, info_ptr->splt_palettes[i].entries); 560 556 } 557 558 png_free(png_ptr, info_ptr->splt_palettes); 559 info_ptr->splt_palettes = NULL; 560 info_ptr->splt_palettes_num = 0; 561 561 info_ptr->valid &= ~PNG_INFO_sPLT; 562 562 } … … 578 578 int i; 579 579 580 if (info_ptr->unknown_chunks_num != 0) 581 { 582 for (i = 0; i < info_ptr->unknown_chunks_num; i++) 583 png_free(png_ptr, info_ptr->unknown_chunks[i].data); 584 585 png_free(png_ptr, info_ptr->unknown_chunks); 586 info_ptr->unknown_chunks = NULL; 587 info_ptr->unknown_chunks_num = 0; 588 } 580 for (i = 0; i < info_ptr->unknown_chunks_num; i++) 581 png_free(png_ptr, info_ptr->unknown_chunks[i].data); 582 583 png_free(png_ptr, info_ptr->unknown_chunks); 584 info_ptr->unknown_chunks = NULL; 585 info_ptr->unknown_chunks_num = 0; 589 586 } 590 587 } … … 667 664 # endif 668 665 669 # ifdef PNG_SAVE_INT_32_SUPPORTED666 # ifdef PNG_SAVE_INT_32_SUPPORTED 670 667 /* The png_save_int_32 function assumes integers are stored in two's 671 668 * complement format. If this isn't the case, then this routine needs to … … 682 679 buf[3] = (png_byte)(i & 0xff); 683 680 } 684 # endif681 # endif 685 682 686 683 # ifdef PNG_TIME_RFC1123_SUPPORTED … … 735 732 } 736 733 737 # 734 # if PNG_LIBPNG_VER < 10700 738 735 /* To do: remove the following from libpng-1.7 */ 739 736 /* Original API that uses a private buffer in png_struct. … … 756 753 return NULL; 757 754 } 758 # endif755 # endif /* LIBPNG_VER < 10700 */ 759 756 # endif /* TIME_RFC1123 */ 760 757 … … 770 767 # ifdef __STDC__ 771 768 return PNG_STRING_NEWLINE \ 772 "libpng version 1.6.16 - December 22, 2014" PNG_STRING_NEWLINE \773 "Copyright (c) 1998-2014Glenn Randers-Pehrson" PNG_STRING_NEWLINE \774 "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \775 "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \776 PNG_STRING_NEWLINE;769 "libpng version 1.6.18 - July 23, 2015" PNG_STRING_NEWLINE \ 770 "Copyright (c) 1998-2015 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \ 771 "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ 772 "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ 773 PNG_STRING_NEWLINE; 777 774 # else 778 return "libpng version 1.6.16 - December 22, 2014\779 Copyright (c) 1998-201 4Glenn Randers-Pehrson\775 return "libpng version 1.6.18 - July 23, 2015\ 776 Copyright (c) 1998-2015 Glenn Randers-Pehrson\ 780 777 Copyright (c) 1996-1997 Andreas Dilger\ 781 778 Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; … … 815 812 return PNG_HEADER_VERSION_STRING 816 813 # ifndef PNG_READ_SUPPORTED 817 "(NO READ SUPPORT)"814 " (NO READ SUPPORT)" 818 815 # endif 819 PNG_STRING_NEWLINE;816 PNG_STRING_NEWLINE; 820 817 #else 821 818 return PNG_HEADER_VERSION_STRING; … … 873 870 for (i = 0, v = 0; i < num_palette; i++, v += color_inc) 874 871 { 875 palette[i].red = (png_byte) v;876 palette[i].green = (png_byte) v;877 palette[i].blue = (png_byte) v;872 palette[i].red = (png_byte)(v & 0xff); 873 palette[i].green = (png_byte)(v & 0xff); 874 palette[i].blue = (png_byte)(v & 0xff); 878 875 } 879 876 } … … 947 944 return((png_uint_32)PNG_LIBPNG_VER); 948 945 } 949 950 951 946 952 947 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) … … 1092 1087 1093 1088 # ifdef PNG_READ_gAMA_SUPPORTED 1094 1095 1096 1097 1089 /* Allow the application to set the gamma value more than once */ 1090 else if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 && 1091 (colorspace->flags & PNG_COLORSPACE_FROM_gAMA) != 0) 1092 errmsg = "duplicate"; 1098 1093 # endif 1099 1094 … … 1136 1131 1137 1132 # ifdef PNG_COLORSPACE_SUPPORTED 1138 1139 1133 /* Clean up the iCCP profile now if it won't be used. */ 1134 png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, -1/*not used*/); 1140 1135 # else 1141 1136 PNG_UNUSED(png_ptr) 1142 1137 # endif 1143 1138 } … … 1146 1141 { 1147 1142 # ifdef PNG_COLORSPACE_SUPPORTED 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1143 /* Leave the INFO_iCCP flag set if the pngset.c code has already set 1144 * it; this allows a PNG to contain a profile which matches sRGB and 1145 * yet still have that profile retrievable by the application. 1146 */ 1147 if ((info_ptr->colorspace.flags & PNG_COLORSPACE_MATCHES_sRGB) != 0) 1148 info_ptr->valid |= PNG_INFO_sRGB; 1149 1150 else 1151 info_ptr->valid &= ~PNG_INFO_sRGB; 1152 1153 if ((info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) 1154 info_ptr->valid |= PNG_INFO_cHRM; 1155 1156 else 1157 info_ptr->valid &= ~PNG_INFO_cHRM; 1163 1158 # endif 1164 1159 … … 1182 1177 } 1183 1178 #endif 1184 #endif 1179 #endif /* GAMMA */ 1185 1180 1186 1181 #ifdef PNG_COLORSPACE_SUPPORTED … … 1241 1236 /* Check xy and, implicitly, z. Note that wide gamut color spaces typically 1242 1237 * have end points with 0 tristimulus values (these are impossible end 1243 * points, but they are used to cover the possible colors.) 1244 */ 1245 if (xy->redx < 0 || xy->redx > PNG_FP_1) return 1; 1246 if (xy->redy < 0 || xy->redy > PNG_FP_1-xy->redx) return 1; 1238 * points, but they are used to cover the possible colors). We check 1239 * xy->whitey against 5, not 0, to avoid a possible integer overflow. 1240 */ 1241 if (xy->redx < 0 || xy->redx > PNG_FP_1) return 1; 1242 if (xy->redy < 0 || xy->redy > PNG_FP_1-xy->redx) return 1; 1247 1243 if (xy->greenx < 0 || xy->greenx > PNG_FP_1) return 1; 1248 1244 if (xy->greeny < 0 || xy->greeny > PNG_FP_1-xy->greenx) return 1; 1249 if (xy->bluex < 0 || xy->bluex > PNG_FP_1) return 1;1250 if (xy->bluey < 0 || xy->bluey > PNG_FP_1-xy->bluex) return 1;1245 if (xy->bluex < 0 || xy->bluex > PNG_FP_1) return 1; 1246 if (xy->bluey < 0 || xy->bluey > PNG_FP_1-xy->bluex) return 1; 1251 1247 if (xy->whitex < 0 || xy->whitex > PNG_FP_1) return 1; 1252 if (xy->whitey < 0|| xy->whitey > PNG_FP_1-xy->whitex) return 1;1248 if (xy->whitey < 5 || xy->whitey > PNG_FP_1-xy->whitex) return 1; 1253 1249 1254 1250 /* The reverse calculation is more difficult because the original tristimulus … … 2167 2163 } 2168 2164 2169 #if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0 2165 #ifdef PNG_sRGB_SUPPORTED 2166 #if PNG_sRGB_PROFILE_CHECKS >= 0 2170 2167 /* Information about the known ICC sRGB profiles */ 2171 2168 static const struct … … 2281 2278 /* Length *and* intent must match */ 2282 2279 if (length == png_sRGB_checks[i].length && 2283 intent == png_sRGB_checks[i].intent)2280 intent == (png_uint_32) png_sRGB_checks[i].intent) 2284 2281 { 2285 2282 /* Now calculate the adler32 if not done already. */ … … 2325 2322 else if (png_sRGB_checks[i].have_md5 == 0) 2326 2323 { 2327 png_chunk_report(png_ptr, "out-of-date sRGB profile with"2328 " no signature",2324 png_chunk_report(png_ptr, 2325 "out-of-date sRGB profile with no signature", 2329 2326 PNG_CHUNK_WARNING); 2330 2327 } … … 2339 2336 * Fall through to "no match". 2340 2337 */ 2341 png_chunk_report(png_ptr, "Not recognizing known sRGB profile that"2342 " has been edited",2338 png_chunk_report(png_ptr, 2339 "Not recognizing known sRGB profile that has been edited", 2343 2340 PNG_CHUNK_WARNING); 2344 2341 break; … … 2350 2347 return 0; /* no match */ 2351 2348 } 2352 #endif 2353 2354 #ifdef PNG_sRGB_SUPPORTED 2349 #endif /* PNG_sRGB_PROFILE_CHECKS >= 0 */ 2350 2355 2351 void /* PRIVATE */ 2356 2352 png_icc_set_sRGB(png_const_structrp png_ptr, … … 2366 2362 (int)/*already checked*/png_get_uint_32(profile+64)); 2367 2363 } 2368 #endif /* READ_sRGB */2364 #endif /* sRGB */ 2369 2365 2370 2366 int /* PRIVATE */ … … 2458 2454 } 2459 2455 } 2460 #endif 2456 #endif /* READ_RGB_TO_GRAY */ 2461 2457 2462 2458 #endif /* COLORSPACE */ … … 2487 2483 error = 1; 2488 2484 } 2489 else if (width > PNG_UINT_31_MAX) 2485 2486 if (width > PNG_UINT_31_MAX) 2490 2487 { 2491 2488 png_warning(png_ptr, "Invalid image width in IHDR"); … … 2493 2490 } 2494 2491 2495 else if (png_gt(width,2496 (PNG_SIZE_MAX >> 3) /* 8-byte RGBA pixels */2497 - 48/* big_row_buf hack */2498 - 1/* filter byte */2499 - 7*8 /* rounding width to multiple of 8 pix*/2500 - 8))/* extra max_pixel_depth pad */2492 if (png_gt(((width + 7) & (~7)), 2493 ((PNG_SIZE_MAX 2494 - 48 /* big_row_buf hack */ 2495 - 1) /* filter byte */ 2496 / 8) /* 8-byte RGBA pixels */ 2497 - 1)) /* extra max_pixel_depth pad */ 2501 2498 { 2502 2499 /* The size of the row must be within the limits of this architecture. … … 2514 2511 error = 1; 2515 2512 } 2516 else 2517 { 2518 # ifdef PNG_SET_USER_LIMITS_SUPPORTED 2519 if (width > png_ptr->user_width_max) 2520 # else 2521 if (width > PNG_USER_WIDTH_MAX) 2522 # endif 2523 { 2524 png_warning(png_ptr, "Image width exceeds user limit in IHDR"); 2525 error = 1; 2526 } 2513 2514 #ifdef PNG_SET_USER_LIMITS_SUPPORTED 2515 if (width > png_ptr->user_width_max) 2516 #else 2517 if (width > PNG_USER_WIDTH_MAX) 2518 #endif 2519 { 2520 png_warning(png_ptr, "Image width exceeds user limit in IHDR"); 2521 error = 1; 2527 2522 } 2528 2523 … … 2532 2527 error = 1; 2533 2528 } 2534 else if (height > PNG_UINT_31_MAX) 2529 2530 if (height > PNG_UINT_31_MAX) 2535 2531 { 2536 2532 png_warning(png_ptr, "Invalid image height in IHDR"); 2537 2533 error = 1; 2538 2534 } 2539 else 2540 { 2541 # ifdef PNG_SET_USER_LIMITS_SUPPORTED 2542 if (height > png_ptr->user_height_max) 2543 # else 2544 if (height > PNG_USER_HEIGHT_MAX) 2545 # endif 2546 { 2547 png_warning(png_ptr, "Image height exceeds user limit in IHDR"); 2548 error = 1; 2549 } 2535 2536 #ifdef PNG_SET_USER_LIMITS_SUPPORTED 2537 if (height > png_ptr->user_height_max) 2538 #else 2539 if (height > PNG_USER_HEIGHT_MAX) 2540 #endif 2541 { 2542 png_warning(png_ptr, "Image height exceeds user limit in IHDR"); 2543 error = 1; 2550 2544 } 2551 2545 … … 2586 2580 } 2587 2581 2588 # 2582 #ifdef PNG_MNG_FEATURES_SUPPORTED 2589 2583 /* Accept filter_method 64 (intrapixel differencing) only if 2590 2584 * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and … … 2619 2613 } 2620 2614 2621 # 2615 #else 2622 2616 if (filter_type != PNG_FILTER_TYPE_BASE) 2623 2617 { … … 2625 2619 error = 1; 2626 2620 } 2627 # 2621 #endif 2628 2622 2629 2623 if (error == 1) … … 2851 2845 if (fp >= DBL_MIN && fp <= DBL_MAX) 2852 2846 { 2853 int exp_b10; 2847 int exp_b10; /* A base 10 exponent */ 2854 2848 double base; /* 10^exp_b10 */ 2855 2849 … … 2899 2893 2900 2894 { 2901 int czero, clead, cdigits;2895 unsigned int czero, clead, cdigits; 2902 2896 char exponent[10]; 2903 2897 … … 2929 2923 * that the final digit is rounded. 2930 2924 */ 2931 if (cdigits+czero -clead+1 < (int)precision)2925 if (cdigits+czero+1 < precision+clead) 2932 2926 fp = modf(fp, &d); 2933 2927 … … 3035 3029 } 3036 3030 } 3037 while (cdigits+czero -clead < (int)precision&& fp > DBL_MIN);3031 while (cdigits+czero < precision+clead && fp > DBL_MIN); 3038 3032 3039 3033 /* The total output count (max) is now 4+precision */ … … 3042 3036 * done and just need to terminate the string. At 3043 3037 * this point exp_b10==(-1) is effectively if flag - it got 3044 * to '-1' because of the decrement after output ing3038 * to '-1' because of the decrement after outputting 3045 3039 * the decimal point above (the exponent required is 3046 3040 * *not* -1!) … … 3050 3044 /* The following only happens if we didn't output the 3051 3045 * leading zeros above for negative exponent, so this 3052 * does t add to the digit requirement. Note that the3046 * doesn't add to the digit requirement. Note that the 3053 3047 * two zeros here can only be output if the two leading 3054 3048 * zeros were *not* output, so this doesn't increase … … 3103 3097 * this need not be considered above. 3104 3098 */ 3105 if ( (int)size > cdigits)3099 if (size > cdigits) 3106 3100 { 3107 3101 while (cdigits > 0) *ascii++ = exponent[--cdigits]; … … 3207 3201 } 3208 3202 # endif /* FIXED_POINT */ 3209 #endif /* READ_SCAL */3203 #endif /* SCAL */ 3210 3204 3211 3205 #if defined(PNG_FLOATING_POINT_SUPPORTED) && \ … … 3225 3219 3226 3220 # ifndef PNG_ERROR_TEXT_SUPPORTED 3227 3221 PNG_UNUSED(text) 3228 3222 # endif 3229 3223 … … 3406 3400 3407 3401 #ifdef PNG_READ_GAMMA_SUPPORTED 3408 #if defined(PNG_16BIT_SUPPORTED) || !defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)3402 #ifdef PNG_16BIT_SUPPORTED 3409 3403 /* A local convenience routine. */ 3410 3404 static png_fixed_point … … 3412 3406 { 3413 3407 /* The required result is 1/a * 1/b; the following preserves accuracy. */ 3414 # 3408 #ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED 3415 3409 double r = a * 1E-5; 3416 3410 r *= b; … … 3419 3413 if (r <= 2147483647. && r >= -2147483648.) 3420 3414 return (png_fixed_point)r; 3421 # 3415 #else 3422 3416 png_fixed_point res; 3423 3417 3424 3418 if (png_muldiv(&res, a, b, 100000) != 0) 3425 3419 return res; 3426 # 3420 #endif 3427 3421 3428 3422 return 0; /* overflow */ 3429 3423 } 3430 #endif /* 16BIT || !FLOATING_ARITHMETIC*/3424 #endif /* 16BIT */ 3431 3425 3432 3426 /* The inverse of the above. */ … … 3436 3430 /* The required result is 1/a * 1/b; the following preserves accuracy. */ 3437 3431 #ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED 3438 double r = 1E15/a; 3439 r /= b; 3440 r = floor(r+.5); 3441 3442 if (r <= 2147483647. && r >= -2147483648.) 3443 return (png_fixed_point)r; 3432 if (a != 0 && b != 0) 3433 { 3434 double r = 1E15/a; 3435 r /= b; 3436 r = floor(r+.5); 3437 3438 if (r <= 2147483647. && r >= -2147483648.) 3439 return (png_fixed_point)r; 3440 } 3444 3441 #else 3445 3442 /* This may overflow because the range of png_fixed_point isn't symmetric, … … 3732 3729 */ 3733 3730 x -= x >> 8; 3734 return (png_byte)(( x + 0x7fffffU) >> 24);3731 return (png_byte)(((x + 0x7fffffU) >> 24) & 0xff); 3735 3732 } 3736 3733 … … 3793 3790 } 3794 3791 3795 return (png_byte) value;3792 return (png_byte)(value & 0xff); 3796 3793 } 3797 3794 … … 4015 4012 else 4016 4013 for (i=0; i<256; ++i) 4017 table[i] = (png_byte) i;4014 table[i] = (png_byte)(i & 0xff); 4018 4015 } 4019 4016 … … 4155 4152 */ 4156 4153 if (sig_bit > 0 && sig_bit < 16U) 4157 shift = (png_byte)(16U - sig_bit); /* shift == insignificant bits */ 4154 /* shift == insignificant bits */ 4155 shift = (png_byte)((16U - sig_bit) & 0xff); 4158 4156 4159 4157 else … … 4224 4222 int current = png_ptr->options; 4225 4223 4226 png_ptr->options = (png_byte)(( current & ~mask) | setting);4224 png_ptr->options = (png_byte)(((current & ~mask) | setting) & 0xff); 4227 4225 4228 4226 return (current & mask) >> option; … … 4240 4238 * specification (see the article at http://en.wikipedia.org/wiki/SRGB) 4241 4239 * is used, not the gamma=1/2.2 approximation use elsewhere in libpng. 4242 * The sRGB to linear table is exact (to the nearest 16 4240 * The sRGB to linear table is exact (to the nearest 16-bit linear fraction). 4243 4241 * The inverse (linear to sRGB) table has accuracies as follows: 4244 4242 * -
TabularUnified libpng/vendor/current/png.h ¶
r1059 r1165 2 2 /* png.h - header file for PNG reference library 3 3 * 4 * libpng version 1.6.16, December 22, 2014 5 * Copyright (c) 1998-2014 Glenn Randers-Pehrson 4 * libpng version 1.6.18, July 23, 2015 5 * 6 * Copyright (c) 1998-2015 Glenn Randers-Pehrson 6 7 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 7 8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) … … 11 12 * Authors and maintainers: 12 13 * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat 13 * libpng versions 0.89 c, June 1996, through 0.96, May 1997: Andreas Dilger14 * libpng versions 0.97, January 1998, through 1.6.1 6, December 22, 2014: Glenn14 * libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger 15 * libpng versions 0.97, January 1998, through 1.6.18, July 23, 2015: Glenn 15 16 * See also "Contributing Authors", below. 16 17 * … … 213 214 * 1.6.16rc01-02 16 10616 16.so.16.16[.0] 214 215 * 1.6.16 16 10616 16.so.16.16[.0] 216 * 1.6.17beta01-06 16 10617 16.so.16.17[.0] 217 * 1.6.17rc01-06 16 10617 16.so.16.17[.0] 218 * 1.6.17 16 10617 16.so.16.17[.0] 219 * 1.6.18beta01-09 16 10618 16.so.16.18[.0] 220 * 1.6.18rc01-03 16 10618 16.so.16.18[.0] 221 * 1.6.18 16 10618 16.so.16.18[.0] 215 222 * 216 223 * Henceforth the source version will match the shared-library major … … 244 251 * This code is released under the libpng license. 245 252 * 246 * libpng versions 1.2.6, August 15, 2004, through 1.6.16, December 22, 2014, are 247 * Copyright (c) 2004, 2006-2014 Glenn Randers-Pehrson, and are 248 * distributed according to the same disclaimer and license as libpng-1.2.5 249 * with the following individual added to the list of Contributing Authors: 250 * 251 * Cosmin Truta 252 * 253 * libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are 254 * Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are 253 * libpng versions 1.0.7, July 1, 2000, through 1.6.18, July 23, 2015, are 254 * Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, and are 255 255 * distributed according to the same disclaimer and license as libpng-1.0.6 256 256 * with the following individuals added to the list of Contributing Authors: 257 257 * 258 258 * Simon-Pierre Cadieux 259 * Eric S. Raymond 259 * Mans Rullgard 260 * Cosmin Truta 260 261 * Gilles Vollant 262 * James Yu 261 263 * 262 264 * and with the following additions to the disclaimer: … … 270 272 * 271 273 * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are 272 * Copyright (c) 1998 , 1999, 2000 Glenn Randers-Pehrson, and are273 * distributed according to the same disclaimer and license as libpng-0.96,274 * with the followingindividuals added to the list of Contributing Authors:274 * Copyright (c) 1998-2000 Glenn Randers-Pehrson, and are distributed according 275 * to the same disclaimer and license as libpng-0.96, with the following 276 * individuals added to the list of Contributing Authors: 275 277 * 276 278 * Tom Lane 277 279 * Glenn Randers-Pehrson 280 * Eric S. Raymond 278 281 * Willem van Schaik 279 282 * 280 283 * libpng versions 0.89, June 1996, through 0.96, May 1997, are 281 * Copyright (c) 1996 , 1997 Andreas Dilger282 * Distributed according to the same disclaimer and license as libpng-0.88,284 * Copyright (c) 1996-1997 Andreas Dilger, and are 285 * distributed according to the same disclaimer and license as libpng-0.88, 283 286 * with the following individuals added to the list of Contributing Authors: 284 287 * … … 291 294 * 292 295 * libpng versions 0.5, May 1995, through 0.88, January 1996, are 293 * Copyright (c) 1995 ,1996 Guy Eric Schalnat, Group 42, Inc.296 * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. 294 297 * 295 298 * For the purposes of this copyright and license, "Contributing Authors" … … 319 322 * be misrepresented as being the original source. 320 323 * 321 * 3. This Copyright notice may not be removed or altered from 322 * anysource or altered source distribution.324 * 3. This Copyright notice may not be removed or altered from any 325 * source or altered source distribution. 323 326 * 324 327 * The Contributing Authors and Group 42, Inc. specifically permit, without … … 333 336 * boxes and the like: 334 337 * 335 * 338 * printf("%s", png_get_copyright(NULL)); 336 339 * 337 340 * Also, the PNG logo (in PNG format, of course) is supplied in the … … 340 343 341 344 /* 342 * Libpng is OSI Certified Open Source Software. OSI Certified is a 343 * certification mark of the Open Source Initiative. 345 * Libpng is OSI Certified Open Source Software. OSI Certified Open Source is 346 * a certification mark of the Open Source Initiative. OSI has not addressed 347 * the additional disclaimers inserted at version 1.0.7. 344 348 */ 345 349 … … 356 360 * ========================= 357 361 * 358 * December 22, 2014362 * July 23, 2015 359 363 * 360 364 * Since the PNG Development group is an ad-hoc body, we can't make … … 362 366 * 363 367 * This is your unofficial assurance that libpng from version 0.71 and 364 * upward through 1.6.1 6are Y2K compliant. It is my belief that368 * upward through 1.6.18 are Y2K compliant. It is my belief that 365 369 * earlier versions were also Y2K compliant. 366 370 * … … 424 428 425 429 /* Version information for png.h - this should match the version in png.c */ 426 #define PNG_LIBPNG_VER_STRING "1.6.1 6"430 #define PNG_LIBPNG_VER_STRING "1.6.18" 427 431 #define PNG_HEADER_VERSION_STRING \ 428 " libpng version 1.6.1 6 - December 22, 2014\n"432 " libpng version 1.6.18 - July 23, 2015\n" 429 433 430 434 #define PNG_LIBPNG_VER_SONUM 16 … … 434 438 #define PNG_LIBPNG_VER_MAJOR 1 435 439 #define PNG_LIBPNG_VER_MINOR 6 436 #define PNG_LIBPNG_VER_RELEASE 1 6440 #define PNG_LIBPNG_VER_RELEASE 18 437 441 438 442 /* This should match the numeric part of the final component of … … 465 469 * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release 466 470 */ 467 #define PNG_LIBPNG_VER 1061 6 /* 1.6.16*/471 #define PNG_LIBPNG_VER 10618 /* 1.6.18 */ 468 472 469 473 /* Library configuration: these options cannot be changed after … … 570 574 * do not agree upon the version number. 571 575 */ 572 typedef char* png_libpng_version_1_6_1 6;576 typedef char* png_libpng_version_1_6_18; 573 577 574 578 /* Basic control structions. Read libpng-manual.txt or libpng.3 for more info. … … 1579 1583 #define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ 1580 1584 1585 #ifdef PNG_WRITE_SUPPORTED 1581 1586 /* These functions give the user control over the scan-line filtering in 1582 1587 * libpng and the compression methods used by zlib. These functions are … … 1592 1597 PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method, 1593 1598 int filters)); 1599 #endif /* WRITE */ 1594 1600 1595 1601 /* Flags for png_set_filter() to say which filters to use. The flags … … 1617 1623 #define PNG_FILTER_VALUE_LAST 5 1618 1624 1619 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* EXPERIMENTAL */ 1620 /* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_ 1621 * defines, either the default (minimum-sum-of-absolute-differences), or 1622 * the experimental method (weighted-minimum-sum-of-absolute-differences). 1623 * 1624 * Weights are factors >= 1.0, indicating how important it is to keep the 1625 * filter type consistent between rows. Larger numbers mean the current 1626 * filter is that many times as likely to be the same as the "num_weights" 1627 * previous filters. This is cumulative for each previous row with a weight. 1628 * There needs to be "num_weights" values in "filter_weights", or it can be 1629 * NULL if the weights aren't being specified. Weights have no influence on 1630 * the selection of the first row filter. Well chosen weights can (in theory) 1631 * improve the compression for a given image. 1632 * 1633 * Costs are factors >= 1.0 indicating the relative decoding costs of a 1634 * filter type. Higher costs indicate more decoding expense, and are 1635 * therefore less likely to be selected over a filter with lower computational 1636 * costs. There needs to be a value in "filter_costs" for each valid filter 1637 * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't 1638 * setting the costs. Costs try to improve the speed of decompression without 1639 * unduly increasing the compressed image size. 1640 * 1641 * A negative weight or cost indicates the default value is to be used, and 1642 * values in the range [0.0, 1.0) indicate the value is to remain unchanged. 1643 * The default values for both weights and costs are currently 1.0, but may 1644 * change if good general weighting/cost heuristics can be found. If both 1645 * the weights and costs are set to 1.0, this degenerates the WEIGHTED method 1646 * to the UNWEIGHTED method, but with added encoding time/computation. 1647 */ 1625 #ifdef PNG_WRITE_SUPPORTED 1626 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */ 1648 1627 PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr, 1649 1628 int heuristic_method, int num_weights, png_const_doublep filter_weights, … … 1655 1634 #endif /* WRITE_WEIGHTED_FILTER */ 1656 1635 1657 /* Heuristic used for row filter selection. These defines should NOT be 1658 * changed. 1659 */ 1636 /* The following are no longer used and will be removed from libpng-1.7: */ 1660 1637 #define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ 1661 1638 #define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ … … 1663 1640 #define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ 1664 1641 1665 #ifdef PNG_WRITE_SUPPORTED1666 1642 /* Set the library compression level. Currently, valid values range from 1667 1643 * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 … … 1671 1647 * these values may not correspond directly to the zlib compression levels. 1672 1648 */ 1649 #ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED 1673 1650 PNG_EXPORT(69, void, png_set_compression_level, (png_structrp png_ptr, 1674 1651 int level)); … … 1688 1665 PNG_EXPORT(73, void, png_set_compression_method, (png_structrp png_ptr, 1689 1666 int method)); 1690 #endif 1667 #endif /* WRITE_CUSTOMIZE_COMPRESSION */ 1691 1668 1692 1669 #ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED … … 1710 1687 int method)); 1711 1688 #endif /* WRITE_CUSTOMIZE_ZTXT_COMPRESSION */ 1689 #endif /* WRITE */ 1712 1690 1713 1691 /* These next functions are called for input/output, memory, and error … … 1820 1798 * The integer return from the callback function is interpreted thus: 1821 1799 * 1822 * negative: An error occur ed,png_chunk_error will be called.1800 * negative: An error occurred; png_chunk_error will be called. 1823 1801 * zero: The chunk was not handled, the chunk will be saved. A critical 1824 1802 * chunk will cause an error at this point unless it is to be saved. … … 2665 2643 + (png_uint_16)(bg)*(png_uint_16)(255 \ 2666 2644 - (png_uint_16)(alpha)) + 128); \ 2667 (composite) = (png_byte)(( temp + (temp >> 8)) >> 8); }2645 (composite) = (png_byte)(((temp + (temp >> 8)) >> 8) & 0xff); } 2668 2646 2669 2647 # define png_composite_16(composite, fg, alpha, bg) \ … … 2672 2650 + (png_uint_32)(bg)*(65535 \ 2673 2651 - (png_uint_32)(alpha)) + 32768); \ 2674 (composite) = (png_uint_16)( (temp + (temp >> 16)) >> 16); }2652 (composite) = (png_uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); } 2675 2653 2676 2654 #else /* Standard method using integer division */ 2677 2655 2678 # define png_composite(composite, fg, alpha, bg) \ 2679 (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ 2680 (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ 2681 127) / 255) 2656 # define png_composite(composite, fg, alpha, bg) \ 2657 (composite) = \ 2658 (png_byte)(0xff & (((png_uint_16)(fg) * (png_uint_16)(alpha) + \ 2659 (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ 2660 127) / 255)) 2682 2661 2683 2662 # define png_composite_16(composite, fg, alpha, bg) \ 2684 (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \ 2685 (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \ 2686 32767) / 65535) 2663 (composite) = \ 2664 (png_uint_16)(0xffff & (((png_uint_32)(fg) * (png_uint_32)(alpha) + \ 2665 (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \ 2666 32767) / 65535)) 2687 2667 #endif /* READ_COMPOSITE_NODIV */ 2688 2668 … … 2774 2754 * To read a PNG file using the simplified API: 2775 2755 * 2776 * 1) Declare a 'png_image' structure (see below) on the stack and set the 2777 * version field to PNG_IMAGE_VERSION. 2756 * 1) Declare a 'png_image' structure (see below) on the stack, set the 2757 * version field to PNG_IMAGE_VERSION and the 'opaque' pointer to NULL 2758 * (this is REQUIRED, your program may crash if you don't do it.) 2778 2759 * 2) Call the appropriate png_image_begin_read... function. 2779 2760 * 3) Set the png_image 'format' member to the required sample format. … … 3200 3181 * With all APIs row_stride is handled as in the read APIs - it is the spacing 3201 3182 * from one row to the next in component sized units (1 or 2 bytes) and if 3202 * negative indicates a bottom-up row layout in the buffer. 3203 * 3204 * Note that the write API does not support interlacing or sub-8-bit pixels. 3183 * negative indicates a bottom-up row layout in the buffer. If row_stride is zero, 3184 * libpng will calculate it for you from the image width and number of channels. 3185 * 3186 * Note that the write API does not support interlacing, sub-8-bit pixels, indexed 3187 * PNG (color_type 3) or most ancillary chunks. 3205 3188 */ 3206 3189 #endif /* STDIO */ -
TabularUnified libpng/vendor/current/pngconf.h ¶
r1059 r1165 2 2 /* pngconf.h - machine configurable file for libpng 3 3 * 4 * libpng version 1.6.1 6,December 22, 20145 * 6 * Copyright (c) 1998-201 4Glenn Randers-Pehrson4 * libpng version 1.6.18, July 23, 2015 5 * 6 * Copyright (c) 1998-2015 Glenn Randers-Pehrson 7 7 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 8 8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) … … 12 12 * and license in png.h 13 13 * 14 */ 15 16 /* Any machine specific code is near the front of this file, so if you 14 * Any machine specific code is near the front of this file, so if you 17 15 * are configuring libpng for a machine, you may want to read the section 18 16 * starting here down to where it starts to typedef png_color, png_text, … … 22 20 #ifndef PNGCONF_H 23 21 #define PNGCONF_H 24 25 /* To do: Do all of this in scripts/pnglibconf.dfa */26 #ifdef PNG_SAFE_LIMITS_SUPPORTED27 # ifdef PNG_USER_WIDTH_MAX28 # undef PNG_USER_WIDTH_MAX29 # define PNG_USER_WIDTH_MAX 1000000L30 # endif31 # ifdef PNG_USER_HEIGHT_MAX32 # undef PNG_USER_HEIGHT_MAX33 # define PNG_USER_HEIGHT_MAX 1000000L34 # endif35 # ifdef PNG_USER_CHUNK_MALLOC_MAX36 # undef PNG_USER_CHUNK_MALLOC_MAX37 # define PNG_USER_CHUNK_MALLOC_MAX 4000000L38 # endif39 # ifdef PNG_USER_CHUNK_CACHE_MAX40 # undef PNG_USER_CHUNK_CACHE_MAX41 # define PNG_USER_CHUNK_CACHE_MAX 12842 # endif43 #endif44 22 45 23 #ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */ … … 318 296 * scripts directory. 319 297 */ 298 320 299 #ifndef PNG_EXPORTA 321 322 # define PNG_EXPORTA(ordinal, type, name, args, attributes)\ 323 PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \ 324 extern attributes) 300 # define PNG_EXPORTA(ordinal, type, name, args, attributes) \ 301 PNG_FUNCTION(PNG_EXPORT_TYPE(type), (PNGAPI name), PNGARG(args), \ 302 PNG_LINKAGE_API attributes) 325 303 #endif 326 304 … … 330 308 #define PNG_EMPTY /*empty list*/ 331 309 332 #define PNG_EXPORT(ordinal, type, name, args) \310 #define PNG_EXPORT(ordinal, type, name, args) \ 333 311 PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY) 334 312 -
TabularUnified libpng/vendor/current/pngdebug.h ¶
r922 r1165 2 2 /* pngdebug.h - Debugging macros for libpng, also used in pngtest.c 3 3 * 4 * Last changed in libpng 1.6.8 [December 19, 2013] 4 5 * Copyright (c) 1998-2013 Glenn Randers-Pehrson 5 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 6 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 7 *8 * Last changed in libpng 1.6.8 [December 19, 2013]9 8 * 10 9 * This code is released under the libpng license. -
TabularUnified libpng/vendor/current/pngget.c ¶
r1059 r1165 2 2 /* pngget.c - retrieval of values from info struct 3 3 * 4 * Last changed in libpng 1.6.1 5 [November 20, 2014]5 * Copyright (c) 1998-201 4Glenn Randers-Pehrson4 * Last changed in libpng 1.6.17 [March 26, 2015] 5 * Copyright (c) 1998-2015 Glenn Randers-Pehrson 6 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 7 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) … … 800 800 png_debug1(1, "in %s retrieval function", "IHDR"); 801 801 802 if (png_ptr == NULL || info_ptr == NULL || width == NULL || 803 height == NULL || bit_depth == NULL || color_type == NULL) 802 if (png_ptr == NULL || info_ptr == NULL) 804 803 return (0); 805 804 806 *width = info_ptr->width; 807 *height = info_ptr->height; 808 *bit_depth = info_ptr->bit_depth; 809 *color_type = info_ptr->color_type; 805 if (width != NULL) 806 *width = info_ptr->width; 807 808 if (height != NULL) 809 *height = info_ptr->height; 810 811 if (bit_depth != NULL) 812 *bit_depth = info_ptr->bit_depth; 813 814 if (color_type != NULL) 815 *color_type = info_ptr->color_type; 810 816 811 817 if (compression_type != NULL) … … 1136 1142 return 0; 1137 1143 1138 # 1144 #ifdef PNG_WRITE_SUPPORTED 1139 1145 if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0) 1140 # 1141 { 1142 # 1146 #endif 1147 { 1148 #ifdef PNG_SEQUENTIAL_READ_SUPPORTED 1143 1149 return png_ptr->IDAT_read_size; 1144 # 1150 #else 1145 1151 return PNG_IDAT_READ_SIZE; 1146 # 1147 } 1148 1149 # 1152 #endif 1153 } 1154 1155 #ifdef PNG_WRITE_SUPPORTED 1150 1156 else 1151 1157 return png_ptr->zbuffer_size; 1152 # 1158 #endif 1153 1159 } 1154 1160 -
TabularUnified libpng/vendor/current/pnginfo.h ¶
r1059 r1165 2 2 /* pnginfo.h - header file for PNG reference library 3 3 * 4 * Last changed in libpng 1.6.1 [March 28, 2013] 4 5 * Copyright (c) 1998-2013 Glenn Randers-Pehrson 5 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 6 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 7 *8 * Last changed in libpng 1.6.1 [March 28, 2013]9 8 * 10 9 * This code is released under the libpng license. -
TabularUnified libpng/vendor/current/pngmem.c ¶
r1059 r1165 42 42 43 43 /* Allocate memory. For reasonable files, size should never exceed 44 * 64K. However, zlib may allocate more th en 64K if you don't tell44 * 64K. However, zlib may allocate more than 64K if you don't tell 45 45 * it not to. See zconf.h and png.h for more information. zlib does 46 46 * need to allocate exactly 64K, so whatever you call here must … … 78 78 #endif 79 79 80 /* Some compilers complain that this is always true. However, it 81 * can be false when integer overflow happens. 82 */ 80 83 if (size > 0 && size <= PNG_SIZE_MAX 81 84 # ifdef PNG_MAX_MALLOC_64K -
TabularUnified libpng/vendor/current/pngpread.c ¶
r1059 r1165 2 2 /* pngpread.c - read a png file in push mode 3 3 * 4 * Last changed in libpng 1.6.1 5 [November 20, 2014]5 * Copyright (c) 1998-201 4Glenn Randers-Pehrson4 * Last changed in libpng 1.6.18 [July 23, 2015] 5 * Copyright (c) 1998-2015 Glenn Randers-Pehrson 6 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 7 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) … … 20 20 #define PNG_READ_CHUNK_MODE 1 21 21 #define PNG_READ_IDAT_MODE 2 22 #define PNG_SKIP_MODE 323 22 #define PNG_READ_tEXt_MODE 4 24 23 #define PNG_READ_zTXt_MODE 5 … … 79 78 png_process_data_skip(png_structrp png_ptr) 80 79 { 81 png_uint_32 remaining = 0; 82 83 if (png_ptr != NULL && png_ptr->process_mode == PNG_SKIP_MODE && 84 png_ptr->skip_length > 0) 85 { 86 /* At the end of png_process_data the buffer size must be 0 (see the loop 87 * above) so we can detect a broken call here: 88 */ 89 if (png_ptr->buffer_size != 0) 90 png_error(png_ptr, 91 "png_process_data_skip called inside png_process_data"); 92 93 /* If is impossible for there to be a saved buffer at this point - 94 * otherwise we could not be in SKIP mode. This will also happen if 95 * png_process_skip is called inside png_process_data (but only very 96 * rarely.) 97 */ 98 if (png_ptr->save_buffer_size != 0) 99 png_error(png_ptr, "png_process_data_skip called with saved data"); 100 101 remaining = png_ptr->skip_length; 102 png_ptr->skip_length = 0; 103 png_ptr->process_mode = PNG_READ_CHUNK_MODE; 104 } 105 106 return remaining; 80 /* TODO: Deprecate and remove this API. 81 * Somewhere the implementation of this seems to have been lost, 82 * or abandoned. It was only to support some internal back-door access 83 * to png_struct) in libpng-1.4.x. 84 */ 85 png_app_warning(png_ptr, 86 "png_process_data_skip is not implemented in any current version of libpng"); 87 return 0; 107 88 } 108 89 … … 133 114 { 134 115 png_push_read_IDAT(png_ptr); 135 break;136 }137 138 case PNG_SKIP_MODE:139 {140 png_push_crc_finish(png_ptr);141 116 break; 142 117 } … … 160 135 { 161 136 png_size_t num_checked = png_ptr->sig_bytes, /* SAFE, does not exceed 8 */ 162 137 num_to_check = 8 - num_checked; 163 138 164 139 if (png_ptr->buffer_size < num_to_check) … … 440 415 } 441 416 442 void /* PRIVATE */443 png_push_crc_skip(png_structrp png_ptr, png_uint_32 skip)444 {445 png_ptr->process_mode = PNG_SKIP_MODE;446 png_ptr->skip_length = skip;447 }448 449 void /* PRIVATE */450 png_push_crc_finish(png_structrp png_ptr)451 {452 if (png_ptr->skip_length != 0 && png_ptr->save_buffer_size != 0)453 {454 png_size_t save_size = png_ptr->save_buffer_size;455 png_uint_32 skip_length = png_ptr->skip_length;456 457 /* We want the smaller of 'skip_length' and 'save_buffer_size', but458 * they are of different types and we don't know which variable has the459 * fewest bits. Carefully select the smaller and cast it to the type of460 * the larger - this cannot overflow. Do not cast in the following test461 * - it will break on either 16 or 64 bit platforms.462 */463 if (skip_length < save_size)464 save_size = (png_size_t)skip_length;465 466 else467 skip_length = (png_uint_32)save_size;468 469 png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size);470 471 png_ptr->skip_length -= skip_length;472 png_ptr->buffer_size -= save_size;473 png_ptr->save_buffer_size -= save_size;474 png_ptr->save_buffer_ptr += save_size;475 }476 if (png_ptr->skip_length != 0 && png_ptr->current_buffer_size != 0)477 {478 png_size_t save_size = png_ptr->current_buffer_size;479 png_uint_32 skip_length = png_ptr->skip_length;480 481 /* We want the smaller of 'skip_length' and 'current_buffer_size', here,482 * the same problem exists as above and the same solution.483 */484 if (skip_length < save_size)485 save_size = (png_size_t)skip_length;486 487 else488 skip_length = (png_uint_32)save_size;489 490 png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size);491 492 png_ptr->skip_length -= skip_length;493 png_ptr->buffer_size -= save_size;494 png_ptr->current_buffer_size -= save_size;495 png_ptr->current_buffer_ptr += save_size;496 }497 if (png_ptr->skip_length == 0)498 {499 PNG_PUSH_SAVE_BUFFER_IF_LT(4)500 png_crc_finish(png_ptr, 0);501 png_ptr->process_mode = PNG_READ_CHUNK_MODE;502 }503 }504 505 417 void PNGCBAPI 506 418 png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) … … 585 497 { 586 498 png_free(png_ptr, old_buffer); 587 old_buffer = NULL;588 499 png_error(png_ptr, "Insufficient memory for save_buffer"); 589 500 } … … 591 502 memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size); 592 503 png_free(png_ptr, old_buffer); 593 old_buffer = NULL;594 504 png_ptr->save_buffer_max = new_max; 595 505 } … … 697 607 png_ptr->current_buffer_ptr += save_size; 698 608 } 609 699 610 if (png_ptr->idat_size == 0) 700 611 { … … 727 638 */ 728 639 while (png_ptr->zstream.avail_in > 0 && 729 !(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))640 (png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0) 730 641 { 731 642 int ret; … … 1037 948 } 1038 949 else 950 #endif 1039 951 { 1040 952 png_push_have_row(png_ptr, png_ptr->row_buf + 1); … … 1046 958 png_read_push_finish_row(png_structrp png_ptr) 1047 959 { 960 #ifdef PNG_READ_INTERLACING_SUPPORTED 1048 961 /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ 1049 962 … … 1070 983 return; 1071 984 985 #ifdef PNG_READ_INTERLACING_SUPPORTED 1072 986 if (png_ptr->interlaced != 0) 1073 987 { … … 1104 1018 } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0); 1105 1019 } 1020 #endif /* READ_INTERLACING */ 1106 1021 } 1107 1022 … … 1128 1043 } 1129 1044 1045 #ifdef PNG_READ_INTERLACING_SUPPORTED 1130 1046 void PNGAPI 1131 1047 png_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row, … … 1142 1058 png_combine_row(png_ptr, old_row, 1/*blocky display*/); 1143 1059 } 1060 #endif /* READ_INTERLACING */ 1144 1061 1145 1062 void PNGAPI -
TabularUnified libpng/vendor/current/pngpriv.h ¶
r1059 r1165 2 2 /* pngpriv.h - private declarations for use inside libpng 3 3 * 4 * For conditions of distribution and use, see copyright notice in png.h5 * Copyright (c) 1998-201 4Glenn Randers-Pehrson4 * Last changed in libpng 1.6.18 [July 23, 2015] 5 * Copyright (c) 1998-2015 Glenn Randers-Pehrson 6 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 7 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 8 *9 * Last changed in libpng 1.6.10 [March 6, 1014]]10 8 * 11 9 * This code is released under the libpng license. … … 121 119 * off. 122 120 * 123 * Note that gcc-4.9 defines __ARM_NEON instead of __ARM_NEON__, so we 124 * check both variants. 121 * Note that gcc-4.9 defines __ARM_NEON instead of the deprecated 122 * __ARM_NEON__, so we check both variants. 123 * 124 * To disable ARM_NEON optimizations entirely, and skip compiling the 125 * associated assembler code, pass --enable-arm-neon=no to configure 126 * or put -DPNG_ARM_NEON_OPT=0 in CPPFLAGS. 125 127 */ 126 128 # if (defined(__ARM_NEON__) || defined(__ARM_NEON)) && \ … … 251 253 */ 252 254 #ifndef PNG_INTERNAL_DATA 253 # define PNG_INTERNAL_DATA(type, name, array) externtype name array255 # define PNG_INTERNAL_DATA(type, name, array) PNG_LINKAGE_DATA type name array 254 256 #endif 255 257 256 258 #ifndef PNG_INTERNAL_FUNCTION 257 259 # define PNG_INTERNAL_FUNCTION(type, name, args, attributes)\ 258 externPNG_FUNCTION(type, name, args, PNG_EMPTY attributes)260 PNG_LINKAGE_FUNCTION PNG_FUNCTION(type, name, args, PNG_EMPTY attributes) 259 261 #endif 260 262 261 263 #ifndef PNG_INTERNAL_CALLBACK 262 264 # define PNG_INTERNAL_CALLBACK(type, name, args, attributes)\ 263 extern PNG_FUNCTION(type, (PNGCBAPI name), args, PNG_EMPTY attributes) 265 PNG_LINKAGE_CALLBACK PNG_FUNCTION(type, (PNGCBAPI name), args,\ 266 PNG_EMPTY attributes) 264 267 #endif 265 268 … … 299 302 #endif 300 303 304 /* This is a global switch to set the compilation for an installed system 305 * (a release build). It can be set for testing debug builds to ensure that 306 * they will compile when the build type is switched to RC or STABLE, the 307 * default is just to use PNG_LIBPNG_BUILD_BASE_TYPE. Set this in CPPFLAGS 308 * with either: 309 * 310 * -DPNG_RELEASE_BUILD Turns on the release compile path 311 * -DPNG_RELEASE_BUILD=0 Turns it off 312 * or in your pngusr.h with 313 * #define PNG_RELEASE_BUILD=1 Turns on the release compile path 314 * #define PNG_RELEASE_BUILD=0 Turns it off 315 */ 316 #ifndef PNG_RELEASE_BUILD 317 # define PNG_RELEASE_BUILD (PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC) 318 #endif 319 301 320 /* SECURITY and SAFETY: 302 321 * 303 * By default libpng is built without any internal limits on image size, 304 * individual heap (png_malloc) allocations or the total amount of memory used. 305 * If PNG_SAFE_LIMITS_SUPPORTED is defined, however, the limits below are used 306 * (unless individually overridden). These limits are believed to be fairly 307 * safe, but builders of secure systems should verify the values against the 308 * real system capabilities. 309 */ 310 #ifdef PNG_SAFE_LIMITS_SUPPORTED 311 /* 'safe' limits */ 312 # ifndef PNG_USER_WIDTH_MAX 313 # define PNG_USER_WIDTH_MAX 1000000 314 # endif 315 # ifndef PNG_USER_HEIGHT_MAX 316 # define PNG_USER_HEIGHT_MAX 1000000 317 # endif 318 # ifndef PNG_USER_CHUNK_CACHE_MAX 319 # define PNG_USER_CHUNK_CACHE_MAX 128 320 # endif 321 # ifndef PNG_USER_CHUNK_MALLOC_MAX 322 # define PNG_USER_CHUNK_MALLOC_MAX 8000000 323 # endif 324 #else 325 /* values for no limits */ 326 # ifndef PNG_USER_WIDTH_MAX 327 # define PNG_USER_WIDTH_MAX 0x7fffffff 328 # endif 329 # ifndef PNG_USER_HEIGHT_MAX 330 # define PNG_USER_HEIGHT_MAX 0x7fffffff 331 # endif 332 # ifndef PNG_USER_CHUNK_CACHE_MAX 333 # define PNG_USER_CHUNK_CACHE_MAX 0 334 # endif 335 # ifndef PNG_USER_CHUNK_MALLOC_MAX 336 # define PNG_USER_CHUNK_MALLOC_MAX 0 337 # endif 338 #endif 339 340 /* Moved to pngpriv.h at libpng-1.5.0 */ 341 /* NOTE: some of these may have been used in external applications as 342 * these definitions were exposed in pngconf.h prior to 1.5. 322 * libpng is built with support for internal limits on image dimensions and 323 * memory usage. These are documented in scripts/pnglibconf.dfa of the 324 * source and recorded in the machine generated header file pnglibconf.h. 343 325 */ 344 326 … … 583 565 #define PNG_RGB_TO_GRAY 0x600000 /* two bits, RGB_TO_GRAY_ERR|WARN */ 584 566 #define PNG_ENCODE_ALPHA 0x800000 /* Added to libpng-1.5.4 */ 585 #define PNG_ADD_ALPHA 586 #define PNG_EXPAND_tRNS 587 #define PNG_SCALE_16_TO_8 588 /* 0x8000000 unused */589 /* 0x10000000 unused */590 /* 0x20000000 unused */591 /* 0x40000000 unused */567 #define PNG_ADD_ALPHA 0x1000000 /* Added to libpng-1.2.7 */ 568 #define PNG_EXPAND_tRNS 0x2000000 /* Added to libpng-1.2.9 */ 569 #define PNG_SCALE_16_TO_8 0x4000000 /* Added to libpng-1.5.4 */ 570 /* 0x8000000 unused */ 571 /* 0x10000000 unused */ 572 /* 0x20000000 unused */ 573 /* 0x40000000 unused */ 592 574 /* Flags for png_create_struct */ 593 575 #define PNG_STRUCT_PNG 0x0001 … … 781 763 */ 782 764 #define PNG_CHUNK_FROM_STRING(s)\ 783 PNG_U32(0xff &(s)[0], 0xff&(s)[1], 0xff&(s)[2], 0xff&(s)[3])765 PNG_U32(0xff & (s)[0], 0xff & (s)[1], 0xff & (s)[2], 0xff & (s)[3]) 784 766 785 767 /* This uses (char), not (png_byte) to avoid warnings on systems where (char) is … … 788 770 */ 789 771 #define PNG_STRING_FROM_CHUNK(s,c)\ 790 (void)(((char*)(s))[0]=(char)((c)>>24), ((char*)(s))[1]=(char)((c)>>16),\ 791 ((char*)(s))[2]=(char)((c)>>8), ((char*)(s))[3]=(char)((c))) 772 (void)(((char*)(s))[0]=(char)(((c)>>24) & 0xff), \ 773 ((char*)(s))[1]=(char)(((c)>>16) & 0xff),\ 774 ((char*)(s))[2]=(char)(((c)>>8) & 0xff), \ 775 ((char*)(s))[3]=(char)((c & 0xff))) 792 776 793 777 /* Do the same but terminate with a null character. */ … … 851 835 PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]); 852 836 853 #define PNG_sRGB_FROM_LINEAR(linear) ((png_byte)((png_sRGB_base[(linear)>>15] +\ 854 ((((linear)&0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8)) 837 #define PNG_sRGB_FROM_LINEAR(linear) \ 838 ((png_byte)(0xff & ((png_sRGB_base[(linear)>>15] \ 839 + ((((linear) & 0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8))) 855 840 /* Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB 856 841 * encoded value with maximum error 0.646365. Note that the input is not a … … 911 896 defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) 912 897 /* Internal array allocator, outputs no error or warning messages on failure, 913 * just returns NULL. 898 * just returns NULL. 914 899 */ 915 900 PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_array,(png_const_structrp png_ptr, … … 1409 1394 png_inforp info_ptr),PNG_EMPTY); 1410 1395 PNG_INTERNAL_FUNCTION(void,png_push_check_crc,(png_structrp png_ptr),PNG_EMPTY); 1411 PNG_INTERNAL_FUNCTION(void,png_push_crc_skip,(png_structrp png_ptr,1412 png_uint_32 length),PNG_EMPTY);1413 PNG_INTERNAL_FUNCTION(void,png_push_crc_finish,(png_structrp png_ptr),1414 PNG_EMPTY);1415 1396 PNG_INTERNAL_FUNCTION(void,png_push_save_buffer,(png_structrp png_ptr), 1416 1397 PNG_EMPTY); -
TabularUnified libpng/vendor/current/pngread.c ¶
r1059 r1165 2 2 /* pngread.c - read a PNG file 3 3 * 4 * Last changed in libpng 1.6.1 5 [November 20, 2014]5 * Copyright (c) 1998-201 4Glenn Randers-Pehrson4 * Last changed in libpng 1.6.17 [March 26, 2015] 5 * Copyright (c) 1998-2015 Glenn Randers-Pehrson 6 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 7 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) … … 64 64 * handled. 65 65 */ 66 # if PNG_ LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC66 # if PNG_RELEASE_BUILD 67 67 png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN; 68 68 # endif … … 815 815 * read, but not after other chunks have been read. 816 816 */ 817 if ((length > 0) || 818 (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0) 817 if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0) 819 818 png_benign_error(png_ptr, "Too many IDATs found"); 820 819 … … 1045 1044 */ 1046 1045 if ((transforms & PNG_TRANSFORM_SCALE_16) != 0) 1047 /* Added at libpng-1.5.4. "strip_16" produces the same result that it1048 * did in earlier versions, while "scale_16" is now more accurate.1049 */1046 /* Added at libpng-1.5.4. "strip_16" produces the same result that it 1047 * did in earlier versions, while "scale_16" is now more accurate. 1048 */ 1050 1049 #ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED 1051 1050 png_set_scale_16(png_ptr); … … 1211 1210 for (iptr = 0; iptr < info_ptr->height; iptr++) 1212 1211 info_ptr->row_pointers[iptr] = png_voidcast(png_bytep, 1213 png_malloc(png_ptr, info_ptr->rowbytes));1212 png_malloc(png_ptr, info_ptr->rowbytes)); 1214 1213 } 1215 1214 … … 1825 1824 y *= 255; 1826 1825 y = PNG_sRGB_FROM_LINEAR((y + 64) >> 7); 1826 alpha = PNG_DIV257(alpha); 1827 1827 encoding = P_sRGB; 1828 1828 } … … 2287 2287 break; 2288 2288 } 2289 2289 #ifdef __COVERITY__ 2290 /* Coverity claims that output_encoding cannot be 2 (P_LINEAR) 2291 * here. 2292 */ 2293 back_alpha = 255; 2294 #else 2290 2295 back_alpha = output_encoding == P_LINEAR ? 65535 : 255; 2296 #endif 2291 2297 } 2292 2298 … … 2413 2419 background_index = i; 2414 2420 png_create_colormap_entry(display, i++, back_r, back_g, back_b, 2415 output_encoding == P_LINEAR ? 65535U : 255U, output_encoding); 2421 #ifdef __COVERITY__ 2422 /* Coverity claims that output_encoding cannot be 2 (P_LINEAR) 2423 * here. 2424 */ 255U, 2425 #else 2426 output_encoding == P_LINEAR ? 65535U : 255U, 2427 #endif 2428 output_encoding); 2416 2429 2417 2430 /* For non-opaque input composite on the sRGB background - this … … 3247 3260 ptrdiff_t step_row = display->row_bytes; 3248 3261 unsigned int channels = 3249 (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;3262 (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1; 3250 3263 int pass; 3251 3264 -
TabularUnified libpng/vendor/current/pngrio.c ¶
r1059 r1165 2 2 /* pngrio.c - functions for data input 3 3 * 4 * Last changed in libpng 1.6.1 5 [November 20, 2014]5 * Copyright (c) 1998-201 4Glenn Randers-Pehrson4 * Last changed in libpng 1.6.17 [March 26, 2015] 5 * Copyright (c) 1998-2015 Glenn Randers-Pehrson 6 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 7 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) … … 27 27 * with very small lengths, so you should implement some kind of simple 28 28 * buffering if you are using unbuffered reads. This should never be asked 29 * to read more th en 64K on a 16 bit machine.29 * to read more than 64K on a 16 bit machine. 30 30 */ 31 31 void /* PRIVATE */ -
TabularUnified libpng/vendor/current/pngrtran.c ¶
r1059 r1165 2 2 /* pngrtran.c - transforms the data in a row for PNG readers 3 3 * 4 * Last changed in libpng 1.6.1 5 [November 20, 2014]5 * Copyright (c) 1998-201 4Glenn Randers-Pehrson4 * Last changed in libpng 1.6.18 [July 23, 2015] 5 * Copyright (c) 1998-2015 Glenn Randers-Pehrson 6 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 7 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) … … 395 395 * of elements in the palette, the maximum number of elements 396 396 * allowed, and a histogram if possible. If the current number 397 * of colors is greater th en the maximum number, the palette will be397 * of colors is greater than the maximum number, the palette will be 398 398 * modified to fit in the maximum number. "full_quantize" indicates 399 399 * whether we need a quantizing cube set up for RGB images, or if we … … 2358 2358 channel = 0; 2359 2359 *bp++ = (png_byte)(value >> 8); 2360 *bp++ = (png_byte) (value & 0xff);2360 *bp++ = (png_byte)value; 2361 2361 } 2362 2362 break; … … 2663 2663 2664 2664 #ifdef PNG_READ_16BIT_SUPPORTED 2665 png_byte hi_filler = (png_byte)( (filler>>8) & 0xff);2666 #endif 2667 png_byte lo_filler = (png_byte) (filler & 0xff);2665 png_byte hi_filler = (png_byte)(filler>>8); 2666 #endif 2667 png_byte lo_filler = (png_byte)filler; 2668 2668 2669 2669 png_debug(1, "in png_do_read_filler"); … … 2716 2716 for (i = 1; i < row_width; i++) 2717 2717 { 2718 *(--dp) = lo_filler; 2718 2719 *(--dp) = hi_filler; 2719 *(--dp) = lo_filler;2720 2720 *(--dp) = *(--sp); 2721 2721 *(--dp) = *(--sp); 2722 2722 } 2723 *(--dp) = lo_filler; 2723 2724 *(--dp) = hi_filler; 2724 *(--dp) = lo_filler;2725 2725 row_info->channels = 2; 2726 2726 row_info->pixel_depth = 32; … … 2737 2737 *(--dp) = *(--sp); 2738 2738 *(--dp) = *(--sp); 2739 *(--dp) = lo_filler; 2739 2740 *(--dp) = hi_filler; 2740 *(--dp) = lo_filler;2741 2741 } 2742 2742 row_info->channels = 2; … … 2797 2797 for (i = 1; i < row_width; i++) 2798 2798 { 2799 *(--dp) = lo_filler; 2799 2800 *(--dp) = hi_filler; 2800 *(--dp) = lo_filler;2801 2801 *(--dp) = *(--sp); 2802 2802 *(--dp) = *(--sp); … … 2806 2806 *(--dp) = *(--sp); 2807 2807 } 2808 *(--dp) = lo_filler; 2808 2809 *(--dp) = hi_filler; 2809 *(--dp) = lo_filler;2810 2810 row_info->channels = 4; 2811 2811 row_info->pixel_depth = 64; … … 2826 2826 *(--dp) = *(--sp); 2827 2827 *(--dp) = *(--sp); 2828 *(--dp) = lo_filler; 2828 2829 *(--dp) = hi_filler; 2829 *(--dp) = lo_filler;2830 2830 } 2831 2831 … … 3088 3088 { 3089 3089 png_uint_16 red, green, blue, w; 3090 3091 red = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2; 3092 green = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2; 3093 blue = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2; 3090 png_byte hi,lo; 3091 3092 hi=*(sp)++; lo=*(sp)++; red = (png_uint_16)((hi << 8) | (lo)); 3093 hi=*(sp)++; lo=*(sp)++; green = (png_uint_16)((hi << 8) | (lo)); 3094 hi=*(sp)++; lo=*(sp)++; blue = (png_uint_16)((hi << 8) | (lo)); 3094 3095 3095 3096 if (red == green && red == blue) … … 3105 3106 else 3106 3107 { 3107 png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red &0xff)3108 png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red & 0xff) 3108 3109 >> png_ptr->gamma_shift][red>>8]; 3109 3110 png_uint_16 green_1 = 3110 png_ptr->gamma_16_to_1[(green &0xff) >>3111 png_ptr->gamma_16_to_1[(green & 0xff) >> 3111 3112 png_ptr->gamma_shift][green>>8]; 3112 png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue &0xff)3113 png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue & 0xff) 3113 3114 >> png_ptr->gamma_shift][blue>>8]; 3114 3115 png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1 3115 3116 + bc*blue_1 + 16384)>>15); 3116 w = png_ptr->gamma_16_from_1[(gray16 &0xff) >>3117 w = png_ptr->gamma_16_from_1[(gray16 & 0xff) >> 3117 3118 png_ptr->gamma_shift][gray16 >> 8]; 3118 3119 rgb_error |= 1; … … 3139 3140 { 3140 3141 png_uint_16 red, green, blue, gray16; 3141 3142 red = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2; 3143 green = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2; 3144 blue = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2; 3142 png_byte hi,lo; 3143 3144 hi=*(sp)++; lo=*(sp)++; red = (png_uint_16)((hi << 8) | (lo)); 3145 hi=*(sp)++; lo=*(sp)++; green = (png_uint_16)((hi << 8) | (lo)); 3146 hi=*(sp)++; lo=*(sp)++; blue = (png_uint_16)((hi << 8) | (lo)); 3145 3147 3146 3148 if (red != green || red != blue) … … 3668 3670 w = v; 3669 3671 else 3670 w = gamma_16_from_1[(v&0xff) >> gamma_shift][v >> 8]; 3672 w = gamma_16_from_1[(v & 0xff) >> 3673 gamma_shift][v >> 8]; 3671 3674 *sp = (png_byte)((w >> 8) & 0xff); 3672 3675 *(sp + 1) = (png_byte)(w & 0xff); … … 3832 3835 png_composite_16(w, v, a, png_ptr->background_1.red); 3833 3836 if (optimize == 0) 3834 w = gamma_16_from_1[((w &0xff) >> gamma_shift)][w >>3837 w = gamma_16_from_1[((w & 0xff) >> gamma_shift)][w >> 3835 3838 8]; 3836 3839 *sp = (png_byte)((w >> 8) & 0xff); … … 3840 3843 png_composite_16(w, v, a, png_ptr->background_1.green); 3841 3844 if (optimize == 0) 3842 w = gamma_16_from_1[((w &0xff) >> gamma_shift)][w >>3845 w = gamma_16_from_1[((w & 0xff) >> gamma_shift)][w >> 3843 3846 8]; 3844 3847 … … 3849 3852 png_composite_16(w, v, a, png_ptr->background_1.blue); 3850 3853 if (optimize == 0) 3851 w = gamma_16_from_1[((w &0xff) >> gamma_shift)][w >>3854 w = gamma_16_from_1[((w & 0xff) >> gamma_shift)][w >> 3852 3855 8]; 3853 3856 … … 4458 4461 for (i = 0; i < row_width; i++) 4459 4462 { 4460 if ( *sp== gray)4463 if ((*sp & 0xffU) == gray) 4461 4464 *dp-- = 0; 4462 4465 … … 4476 4479 for (i = 0; i < row_width; i++) 4477 4480 { 4478 if (*(sp - 1) == gray_high && *(sp) == gray_low) 4481 if ((*(sp - 1) & 0xffU) == gray_high && 4482 (*(sp) & 0xffU) == gray_low) 4479 4483 { 4480 4484 *dp-- = 0; … … 4838 4842 * do (if there is an alpha channel or transparency.) 4839 4843 */ 4840 !((png_ptr->transformations & PNG_COMPOSE) &&4844 !((png_ptr->transformations & PNG_COMPOSE) != 0 && 4841 4845 ((png_ptr->num_trans != 0) || 4842 4846 (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)) && -
TabularUnified libpng/vendor/current/pngrutil.c ¶
r1059 r1165 2 2 /* pngrutil.c - utilities to read a PNG file 3 3 * 4 * Last changed in libpng 1.6.1 5 [November 20, 2014]5 * Copyright (c) 1998-201 4Glenn Randers-Pehrson4 * Last changed in libpng 1.6.18 [July 23, 2015] 5 * Copyright (c) 1998-2015 Glenn Randers-Pehrson 6 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 7 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) … … 342 342 */ 343 343 (void)png_safecat(msg, (sizeof msg), 4, " using zstream"); 344 #if PNG_ LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC344 #if PNG_RELEASE_BUILD 345 345 png_chunk_warning(png_ptr, msg); 346 346 png_ptr->zowner = 0; … … 576 576 png_alloc_size_t limit = PNG_SIZE_MAX; 577 577 578 # ifdef PNG_SET_ CHUNK_MALLOC_LIMIT_SUPPORTED578 # ifdef PNG_SET_USER_LIMITS_SUPPORTED 579 579 if (png_ptr->user_chunk_malloc_max > 0 && 580 580 png_ptr->user_chunk_malloc_max < limit) … … 671 671 */ 672 672 png_free(png_ptr, text); 673 text = NULL;674 673 675 674 /* This really is very benign, but it's still an error because … … 1148 1147 1149 1148 for (i=0; i<truelen; ++i) 1149 { 1150 1150 if (buf[i] == 0 || buf[i] > sample_depth) 1151 1151 { … … 1153 1153 return; 1154 1154 } 1155 } 1155 1156 1156 1157 if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0) … … 1463 1464 1464 1465 # ifdef PNG_sRGB_SUPPORTED 1465 1466 1467 1468 1466 /* Check for a match against sRGB */ 1467 png_icc_set_sRGB(png_ptr, 1468 &png_ptr->colorspace, profile, 1469 png_ptr->zstream.adler); 1469 1470 # endif 1470 1471 … … 1516 1517 errmsg = "truncated"; 1517 1518 1519 #ifndef __COVERITY__ 1518 1520 else 1519 1521 errmsg = png_ptr->zstream.msg; 1522 #endif 1520 1523 } 1521 1524 … … 1674 1677 if (dl > max_dl) 1675 1678 { 1676 1677 1679 png_warning(png_ptr, "sPLT chunk too long"); 1680 return; 1678 1681 } 1679 1682 … … 1685 1688 if (new_palette.entries == NULL) 1686 1689 { 1687 1688 1690 png_warning(png_ptr, "sPLT chunk requires too much memory"); 1691 return; 1689 1692 } 1690 1693 … … 1816 1819 } 1817 1820 1818 if (length > png_ptr->num_palette || length > PNG_MAX_PALETTE_LENGTH || 1821 if (length > png_ptr->num_palette || 1822 length > (unsigned int) PNG_MAX_PALETTE_LENGTH || 1819 1823 length == 0) 1820 1824 { … … 1979 1983 num = length / 2 ; 1980 1984 1981 if (num != png_ptr->num_palette || num > PNG_MAX_PALETTE_LENGTH)1985 if (num != png_ptr->num_palette || num > (unsigned int) PNG_MAX_PALETTE_LENGTH) 1982 1986 { 1983 1987 png_crc_finish(png_ptr, length); … … 2714 2718 } 2715 2719 2716 # ifdef PNG_SET_ CHUNK_MALLOC_LIMIT_SUPPORTED2717 2718 2719 2720 # ifdef PNG_SET_USER_LIMITS_SUPPORTED 2721 if (png_ptr->user_chunk_malloc_max > 0 && 2722 png_ptr->user_chunk_malloc_max < limit) 2723 limit = png_ptr->user_chunk_malloc_max; 2720 2724 2721 2725 # elif PNG_USER_CHUNK_MALLOC_MAX > 0 2722 2723 2726 if (PNG_USER_CHUNK_MALLOC_MAX < limit) 2727 limit = PNG_USER_CHUNK_MALLOC_MAX; 2724 2728 # endif 2725 2729 … … 2784 2788 # ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED 2785 2789 # ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED 2786 2790 keep = png_chunk_unknown_handling(png_ptr, png_ptr->chunk_name); 2787 2791 # endif 2788 2792 # endif … … 2793 2797 */ 2794 2798 # ifdef PNG_READ_USER_CHUNKS_SUPPORTED 2795 /* The user callback takes precedence over the chunk keep value, but the 2796 * keep value is still required to validate a save of a critical chunk. 2797 */ 2798 if (png_ptr->read_user_chunk_fn != NULL) 2799 { 2800 if (png_cache_unknown_chunk(png_ptr, length) != 0) 2799 /* The user callback takes precedence over the chunk keep value, but the 2800 * keep value is still required to validate a save of a critical chunk. 2801 */ 2802 if (png_ptr->read_user_chunk_fn != NULL) 2803 { 2804 if (png_cache_unknown_chunk(png_ptr, length) != 0) 2805 { 2806 /* Callback to user unknown chunk handler */ 2807 int ret = (*(png_ptr->read_user_chunk_fn))(png_ptr, 2808 &png_ptr->unknown_chunk); 2809 2810 /* ret is: 2811 * negative: An error occurred; png_chunk_error will be called. 2812 * zero: The chunk was not handled, the chunk will be discarded 2813 * unless png_set_keep_unknown_chunks has been used to set 2814 * a 'keep' behavior for this particular chunk, in which 2815 * case that will be used. A critical chunk will cause an 2816 * error at this point unless it is to be saved. 2817 * positive: The chunk was handled, libpng will ignore/discard it. 2818 */ 2819 if (ret < 0) 2820 png_chunk_error(png_ptr, "error in user chunk"); 2821 2822 else if (ret == 0) 2801 2823 { 2802 /* Callback to user unknown chunk handler */ 2803 int ret = (*(png_ptr->read_user_chunk_fn))(png_ptr, 2804 &png_ptr->unknown_chunk); 2805 2806 /* ret is: 2807 * negative: An error occured, png_chunk_error will be called. 2808 * zero: The chunk was not handled, the chunk will be discarded 2809 * unless png_set_keep_unknown_chunks has been used to set 2810 * a 'keep' behavior for this particular chunk, in which 2811 * case that will be used. A critical chunk will cause an 2812 * error at this point unless it is to be saved. 2813 * positive: The chunk was handled, libpng will ignore/discard it. 2824 /* If the keep value is 'default' or 'never' override it, but 2825 * still error out on critical chunks unless the keep value is 2826 * 'always' While this is weird it is the behavior in 1.4.12. 2827 * A possible improvement would be to obey the value set for the 2828 * chunk, but this would be an API change that would probably 2829 * damage some applications. 2830 * 2831 * The png_app_warning below catches the case that matters, where 2832 * the application has not set specific save or ignore for this 2833 * chunk or global save or ignore. 2814 2834 */ 2815 if (ret < 0) 2816 png_chunk_error(png_ptr, "error in user chunk"); 2817 2818 else if (ret == 0) 2835 if (keep < PNG_HANDLE_CHUNK_IF_SAFE) 2819 2836 { 2820 /* If the keep value is 'default' or 'never' override it, but 2821 * still error out on critical chunks unless the keep value is 2822 * 'always' While this is weird it is the behavior in 1.4.12. 2823 * A possible improvement would be to obey the value set for the 2824 * chunk, but this would be an API change that would probably 2825 * damage some applications. 2826 * 2827 * The png_app_warning below catches the case that matters, where 2828 * the application has not set specific save or ignore for this 2829 * chunk or global save or ignore. 2830 */ 2831 if (keep < PNG_HANDLE_CHUNK_IF_SAFE) 2837 # ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED 2838 if (png_ptr->unknown_default < PNG_HANDLE_CHUNK_IF_SAFE) 2832 2839 { 2833 # ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED 2834 if (png_ptr->unknown_default < PNG_HANDLE_CHUNK_IF_SAFE) 2835 { 2836 png_chunk_warning(png_ptr, "Saving unknown chunk:"); 2837 png_app_warning(png_ptr, 2838 "forcing save of an unhandled chunk;" 2839 " please call png_set_keep_unknown_chunks"); 2840 /* with keep = PNG_HANDLE_CHUNK_IF_SAFE */ 2841 } 2842 # endif 2843 keep = PNG_HANDLE_CHUNK_IF_SAFE; 2840 png_chunk_warning(png_ptr, "Saving unknown chunk:"); 2841 png_app_warning(png_ptr, 2842 "forcing save of an unhandled chunk;" 2843 " please call png_set_keep_unknown_chunks"); 2844 /* with keep = PNG_HANDLE_CHUNK_IF_SAFE */ 2844 2845 } 2845 } 2846 2847 else /* chunk was handled */ 2848 { 2849 handled = 1; 2850 /* Critical chunks can be safely discarded at this point. */ 2851 keep = PNG_HANDLE_CHUNK_NEVER; 2846 # endif 2847 keep = PNG_HANDLE_CHUNK_IF_SAFE; 2852 2848 } 2853 2849 } 2854 2850 2855 else 2856 keep = PNG_HANDLE_CHUNK_NEVER; /* insufficient memory */ 2851 else /* chunk was handled */ 2852 { 2853 handled = 1; 2854 /* Critical chunks can be safely discarded at this point. */ 2855 keep = PNG_HANDLE_CHUNK_NEVER; 2856 } 2857 2857 } 2858 2858 2859 2859 else 2860 /* Use the SAVE_UNKNOWN_CHUNKS code or skip the chunk */ 2860 keep = PNG_HANDLE_CHUNK_NEVER; /* insufficient memory */ 2861 } 2862 2863 else 2864 /* Use the SAVE_UNKNOWN_CHUNKS code or skip the chunk */ 2861 2865 # endif /* READ_USER_CHUNKS */ 2862 2866 2863 2867 # ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2868 { 2869 /* keep is currently just the per-chunk setting, if there was no 2870 * setting change it to the global default now (not that this may 2871 * still be AS_DEFAULT) then obtain the cache of the chunk if required, 2872 * if not simply skip the chunk. 2873 */ 2874 if (keep == PNG_HANDLE_CHUNK_AS_DEFAULT) 2875 keep = png_ptr->unknown_default; 2876 2877 if (keep == PNG_HANDLE_CHUNK_ALWAYS || 2878 (keep == PNG_HANDLE_CHUNK_IF_SAFE && 2879 PNG_CHUNK_ANCILLARY(png_ptr->chunk_name))) 2880 { 2881 if (png_cache_unknown_chunk(png_ptr, length) == 0) 2882 keep = PNG_HANDLE_CHUNK_NEVER; 2883 } 2884 2885 else 2886 png_crc_finish(png_ptr, length); 2887 } 2884 2888 # else 2885 2889 # ifndef PNG_READ_USER_CHUNKS_SUPPORTED … … 2887 2891 # endif 2888 2892 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2893 { 2894 /* If here there is no read callback pointer set and no support is 2895 * compiled in to just save the unknown chunks, so simply skip this 2896 * chunk. If 'keep' is something other than AS_DEFAULT or NEVER then 2897 * the app has erroneously asked for unknown chunk saving when there 2898 * is no support. 2899 */ 2900 if (keep > PNG_HANDLE_CHUNK_NEVER) 2901 png_app_error(png_ptr, "no unknown chunk support available"); 2902 2903 png_crc_finish(png_ptr, length); 2904 } 2901 2905 # endif 2902 2906 2903 2907 # ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED 2904 2905 2906 2907 2908 2909 2910 2908 /* Now store the chunk in the chunk list if appropriate, and if the limits 2909 * permit it. 2910 */ 2911 if (keep == PNG_HANDLE_CHUNK_ALWAYS || 2912 (keep == PNG_HANDLE_CHUNK_IF_SAFE && 2913 PNG_CHUNK_ANCILLARY(png_ptr->chunk_name))) 2914 { 2911 2915 # ifdef PNG_USER_LIMITS_SUPPORTED 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 # 2929 2930 2931 2932 2933 2934 2935 # 2936 2937 2938 # 2939 2916 switch (png_ptr->user_chunk_cache_max) 2917 { 2918 case 2: 2919 png_ptr->user_chunk_cache_max = 1; 2920 png_chunk_benign_error(png_ptr, "no space in chunk cache"); 2921 /* FALL THROUGH */ 2922 case 1: 2923 /* NOTE: prior to 1.6.0 this case resulted in an unknown critical 2924 * chunk being skipped, now there will be a hard error below. 2925 */ 2926 break; 2927 2928 default: /* not at limit */ 2929 --(png_ptr->user_chunk_cache_max); 2930 /* FALL THROUGH */ 2931 case 0: /* no limit */ 2932 # endif /* USER_LIMITS */ 2933 /* Here when the limit isn't reached or when limits are compiled 2934 * out; store the chunk. 2935 */ 2936 png_set_unknown_chunks(png_ptr, info_ptr, 2937 &png_ptr->unknown_chunk, 1); 2938 handled = 1; 2939 # ifdef PNG_USER_LIMITS_SUPPORTED 2940 break; 2941 } 2942 # endif 2943 } 2940 2944 # else /* no store support: the chunk must be handled by the user callback */ 2941 2945 PNG_UNUSED(info_ptr) 2942 2946 # endif 2943 2947 … … 3041 3045 end_byte = *end_ptr; 3042 3046 # ifdef PNG_READ_PACKSWAP_SUPPORTED 3043 3044 3045 3046 3047 3047 if ((png_ptr->transformations & PNG_PACKSWAP) != 0) 3048 /* little-endian byte */ 3049 end_mask = 0xff << end_mask; 3050 3051 else /* big-endian byte */ 3048 3052 # endif 3049 3053 end_mask = 0xff >> end_mask; 3050 3054 /* end_mask is now the bits to *keep* from the destination row */ 3051 3055 } … … 3205 3209 3206 3210 # ifdef PNG_READ_PACKSWAP_SUPPORTED 3207 3208 3209 3210 3211 if ((png_ptr->transformations & PNG_PACKSWAP) != 0) 3212 mask = MASK(pass, pixel_depth, display, 0); 3213 3214 else 3211 3215 # endif 3212 3216 mask = MASK(pass, pixel_depth, display, 1); 3213 3217 3214 3218 for (;;) … … 3811 3815 pc = a - c; 3812 3816 3813 # 3814 3815 3816 3817 # 3818 3819 3820 3821 # 3817 #ifdef PNG_USE_ABS 3818 pa = abs(p); 3819 pb = abs(pc); 3820 pc = abs(p + pc); 3821 #else 3822 pa = p < 0 ? -p : p; 3823 pb = pc < 0 ? -pc : pc; 3824 pc = (p + pc) < 0 ? -(p + pc) : p + pc; 3825 #endif 3822 3826 3823 3827 /* Find the best predictor, the least of pa, pb, pc favoring the earlier … … 3866 3870 pc = a - c; 3867 3871 3868 # 3869 3870 3871 3872 # 3873 3874 3875 3876 # 3872 #ifdef PNG_USE_ABS 3873 pa = abs(p); 3874 pb = abs(pc); 3875 pc = abs(p + pc); 3876 #else 3877 pa = p < 0 ? -p : p; 3878 pb = pc < 0 ? -pc : pc; 3879 pc = (p + pc) < 0 ? -(p + pc) : p + pc; 3880 #endif 3877 3881 3878 3882 if (pb < pa) pa = pb, a = b; … … 4279 4283 if ((png_ptr->transformations & PNG_EXPAND_16) != 0) 4280 4284 { 4281 # 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 # 4292 4285 # ifdef PNG_READ_EXPAND_SUPPORTED 4286 /* In fact it is an error if it isn't supported, but checking is 4287 * the safe way. 4288 */ 4289 if ((png_ptr->transformations & PNG_EXPAND) != 0) 4290 { 4291 if (png_ptr->bit_depth < 16) 4292 max_pixel_depth *= 2; 4293 } 4294 else 4295 # endif 4296 png_ptr->transformations &= ~PNG_EXPAND_16; 4293 4297 } 4294 4298 #endif -
TabularUnified libpng/vendor/current/pngset.c ¶
r1059 r1165 2 2 /* pngset.c - storage of image information into info struct 3 3 * 4 * Last changed in libpng 1.6.1 5 [November 20, 2014]5 * Copyright (c) 1998-201 4Glenn Randers-Pehrson4 * Last changed in libpng 1.6.18 [July 23, 2015] 5 * Copyright (c) 1998-2015 Glenn Randers-Pehrson 6 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 7 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) … … 191 191 { 192 192 png_warning(png_ptr, "Insufficient memory for hIST chunk data"); 193 193 194 return; 194 195 } … … 272 273 273 274 if (png_ptr == NULL || info_ptr == NULL || purpose == NULL || units == NULL 274 || (nparams > 0 && params == NULL))275 || (nparams > 0 && params == NULL)) 275 276 return; 276 277 … … 302 303 { 303 304 png_warning(png_ptr, "Insufficient memory for pCAL purpose"); 305 304 306 return; 305 307 } … … 323 325 { 324 326 png_warning(png_ptr, "Insufficient memory for pCAL units"); 327 325 328 return; 326 329 } … … 334 337 { 335 338 png_warning(png_ptr, "Insufficient memory for pCAL params"); 339 336 340 return; 337 341 } … … 350 354 { 351 355 png_warning(png_ptr, "Insufficient memory for pCAL parameter"); 356 352 357 return; 353 358 } … … 399 404 { 400 405 png_warning(png_ptr, "Memory allocation failed while processing sCAL"); 406 401 407 return; 402 408 } … … 417 423 418 424 png_warning(png_ptr, "Memory allocation failed while processing sCAL"); 425 419 426 return; 420 427 } … … 520 527 { 521 528 png_warning(png_ptr, "Invalid palette length"); 529 522 530 return; 523 531 } … … 532 540 { 533 541 png_error(png_ptr, "Invalid palette"); 534 return;535 542 } 536 543 … … 656 663 { 657 664 png_benign_error(png_ptr, "Insufficient memory to process iCCP chunk"); 665 658 666 return; 659 667 } … … 666 674 { 667 675 png_free(png_ptr, new_iccp_name); 668 new_iccp_name = NULL;669 676 png_benign_error(png_ptr, 670 677 "Insufficient memory to process iCCP profile"); 678 671 679 return; 672 680 } … … 702 710 int i; 703 711 704 png_debug1(1, "in %lx storage function", png_ptr == NULL ? "unexpected":712 png_debug1(1, "in %lx storage function", png_ptr == NULL ? 0xabadca11 : 705 713 (unsigned long)png_ptr->chunk_name); 706 714 … … 744 752 png_chunk_report(png_ptr, "too many text chunks", 745 753 PNG_CHUNK_WRITE_ERROR); 754 746 755 return 1; 747 756 } … … 799 808 lang_key_len = 0; 800 809 } 801 # else /* PNG_iTXt_SUPPORTED*/810 # else /* iTXt */ 802 811 { 803 812 png_chunk_report(png_ptr, "iTXt chunk not supported", … … 832 841 png_chunk_report(png_ptr, "text chunk: out of memory", 833 842 PNG_CHUNK_WRITE_ERROR); 843 834 844 return 1; 835 845 } … … 905 915 { 906 916 png_warning(png_ptr, "Ignoring invalid time value"); 917 907 918 return; 908 919 } … … 921 932 922 933 if (png_ptr == NULL || info_ptr == NULL) 934 923 935 return; 924 936 … … 946 958 if (trans_color != NULL) 947 959 { 948 int sample_max = (1 << info_ptr->bit_depth); 949 950 if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY && 951 trans_color->gray > sample_max) || 952 (info_ptr->color_type == PNG_COLOR_TYPE_RGB && 953 (trans_color->red > sample_max || 954 trans_color->green > sample_max || 955 trans_color->blue > sample_max))) 956 png_warning(png_ptr, 957 "tRNS chunk has out-of-range samples for bit_depth"); 960 #ifdef PNG_WARNINGS_SUPPORTED 961 if (info_ptr->bit_depth < 16) 962 { 963 int sample_max = (1 << info_ptr->bit_depth) - 1; 964 965 if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY && 966 trans_color->gray > sample_max) || 967 (info_ptr->color_type == PNG_COLOR_TYPE_RGB && 968 (trans_color->red > sample_max || 969 trans_color->green > sample_max || 970 trans_color->blue > sample_max))) 971 png_warning(png_ptr, 972 "tRNS chunk has out-of-range samples for bit_depth"); 973 } 974 #endif 958 975 959 976 info_ptr->trans_color = *trans_color; … … 1002 1019 /* Out of memory or too many chunks */ 1003 1020 png_chunk_report(png_ptr, "too many sPLT chunks", PNG_CHUNK_WRITE_ERROR); 1021 1004 1022 return; 1005 1023 } … … 1117 1135 1118 1136 if (png_ptr == NULL || info_ptr == NULL || num_unknowns <= 0 || 1119 unknowns == NULL)1137 unknowns == NULL) 1120 1138 return; 1121 1139 … … 1131 1149 { 1132 1150 png_app_error(png_ptr, "no unknown chunk support on read"); 1151 1133 1152 return; 1134 1153 } … … 1139 1158 { 1140 1159 png_app_error(png_ptr, "no unknown chunk support on write"); 1160 1141 1161 return; 1142 1162 } … … 1156 1176 png_chunk_report(png_ptr, "too many unknown chunks", 1157 1177 PNG_CHUNK_WRITE_ERROR); 1178 1158 1179 return; 1159 1180 } … … 1233 1254 } 1234 1255 } 1235 #endif 1236 1256 #endif /* STORE_UNKNOWN_CHUNKS */ 1237 1257 1238 1258 #ifdef PNG_MNG_FEATURES_SUPPORTED … … 1265 1285 { 1266 1286 list[4] = (png_byte)keep; 1287 1267 1288 return count; 1268 1289 } … … 1292 1313 { 1293 1314 png_app_error(png_ptr, "png_set_keep_unknown_chunks: invalid keep"); 1315 1294 1316 return; 1295 1317 } … … 1341 1363 */ 1342 1364 png_app_error(png_ptr, "png_set_keep_unknown_chunks: no chunk list"); 1365 1343 1366 return; 1344 1367 } … … 1356 1379 { 1357 1380 png_app_error(png_ptr, "png_set_keep_unknown_chunks: too many chunks"); 1381 1358 1382 return; 1359 1383 } … … 1493 1517 png_warning(png_ptr, 1494 1518 "Compression buffer size cannot be changed because it is in use"); 1519 1495 1520 return; 1496 1521 } 1497 1522 1523 #ifndef __COVERITY__ 1524 /* Some compilers complain that this is always false. However, it 1525 * can be true when integer overflow happens. 1526 */ 1498 1527 if (size > ZLIB_IO_MAX) 1499 1528 { … … 1502 1531 size = ZLIB_IO_MAX; /* must fit */ 1503 1532 } 1504 1505 else if (size < 6) 1533 #endif 1534 1535 if (size < 6) 1506 1536 { 1507 1537 /* Deflate will potentially go into an infinite loop on a SYNC_FLUSH … … 1510 1540 png_warning(png_ptr, 1511 1541 "Compression buffer size cannot be reduced below 6"); 1542 1512 1543 return; 1513 1544 } … … 1551 1582 png_set_chunk_cache_max (png_structrp png_ptr, png_uint_32 user_chunk_cache_max) 1552 1583 { 1553 1554 1584 if (png_ptr != NULL) 1585 png_ptr->user_chunk_cache_max = user_chunk_cache_max; 1555 1586 } 1556 1587 -
TabularUnified libpng/vendor/current/pngstruct.h ¶
r1059 r1165 2 2 /* pngstruct.h - header file for PNG reference library 3 3 * 4 * Copyright (c) 1998-2013 Glenn Randers-Pehrson 4 * Last changed in libpng 1.6.18 [July 23, 2015] 5 * Copyright (c) 1998-2015 Glenn Randers-Pehrson 5 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 6 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 7 *8 * Last changed in libpng 1.6.1 [March 28, 2013]9 8 * 10 9 * This code is released under the libpng license. … … 102 101 103 102 #if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED) 104 /* A colorspace is all the above plus, potentially, profile information ,103 /* A colorspace is all the above plus, potentially, profile information; 105 104 * however at present libpng does not use the profile internally so it is only 106 105 * stored in the png_info struct (if iCCP is supported.) The rendering intent … … 221 220 png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */ 222 221 png_bytep prev_row; /* buffer to save previous (unfiltered) row. 223 * This is a pointer into big_prev_row 222 * While reading this is a pointer into 223 * big_prev_row; while writing it is separately 224 * allocated if needed. 224 225 */ 225 226 png_bytep row_buf; /* buffer to save current (unfiltered) row. 226 * This is a pointer into big_row_buf 227 * While reading, this is a pointer into 228 * big_row_buf; while writing it is separately 229 * allocated. 227 230 */ 228 #ifdef PNG_WRITE_SUPPORTED 229 png_bytep sub_row; /* buffer to save "sub" row when filtering */ 230 png_bytep up_row; /* buffer to save "up" row when filtering */ 231 png_bytep avg_row; /* buffer to save "avg" row when filtering */ 232 png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ 231 #ifdef PNG_WRITE_FILTER_SUPPORTED 232 png_bytep try_row; /* buffer to save trial row when filtering */ 233 png_bytep tst_row; /* buffer to save best trial row when filtering */ 233 234 #endif 234 235 png_size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */ … … 348 349 #endif 349 350 350 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 351 png_byte heuristic_method; /* heuristic for row filter selection */ 352 png_byte num_prev_filters; /* number of weights for previous rows */ 353 png_bytep prev_filters; /* filter type(s) of previous row(s) */ 354 png_uint_16p filter_weights; /* weight(s) for previous line(s) */ 355 png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */ 356 png_uint_16p filter_costs; /* relative filter calculation cost */ 357 png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */ 358 #endif 359 360 /* Options */ 351 /* Options */ 361 352 #ifdef PNG_SET_OPTION_SUPPORTED 362 353 png_byte options; /* On/off state (up to 4 options) */ -
TabularUnified libpng/vendor/current/pngtest.c ¶
r1059 r1165 2 2 /* pngtest.c - a simple test program to test libpng 3 3 * 4 * Last changed in libpng 1.6.1 5 [November 20, 2014]5 * Copyright (c) 1998-201 4Glenn Randers-Pehrson4 * Last changed in libpng 1.6.18 [July 23, 2015] 5 * Copyright (c) 1998-2015 Glenn Randers-Pehrson 6 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 7 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) … … 470 470 471 471 /* Allocate memory. For reasonable files, size should never exceed 472 * 64K. However, zlib may allocate more th en 64K if you don't tell472 * 64K. However, zlib may allocate more than 64K if you don't tell 473 473 * it not to. See zconf.h and png.h for more information. zlib does 474 474 * need to allocate exactly 64K, so whatever you call here must … … 566 566 567 567 /* Unlink the element from the list. */ 568 if (pinformation != NULL) 568 569 { 569 570 memory_infop *ppinfo = &pinformation; … … 582 583 the memory that is to be freed. */ 583 584 memset(ptr, 0x55, pinfo->size); 584 if (pinfo != NULL) 585 free(pinfo); 585 free(pinfo); 586 586 pinfo = NULL; 587 587 break; … … 1702 1702 int ierror = 0; 1703 1703 1704 png_structp dummy_ptr; 1705 1704 1706 fprintf(STDERR, "\n Testing libpng version %s\n", PNG_LIBPNG_VER_STRING); 1705 1707 fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION); … … 1832 1834 #endif 1833 1835 #ifdef PNG_TIME_RFC1123_SUPPORTED 1834 if (tIME_chunk_present != 0)1835 fprintf(STDERR, " tIME = %s\n", tIME_string);1836 1837 tIME_chunk_present = 0;1836 if (tIME_chunk_present != 0) 1837 fprintf(STDERR, " tIME = %s\n", tIME_string); 1838 1839 tIME_chunk_present = 0; 1838 1840 #endif /* TIME_RFC1123 */ 1839 1841 } … … 1995 1997 fprintf(STDERR, " libpng FAILS test\n"); 1996 1998 1999 dummy_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); 2000 fprintf(STDERR, " Default limits:\n"); 2001 fprintf(STDERR, " width_max = %lu\n", 2002 (unsigned long) png_get_user_width_max(dummy_ptr)); 2003 fprintf(STDERR, " height_max = %lu\n", 2004 (unsigned long) png_get_user_height_max(dummy_ptr)); 2005 if (png_get_chunk_cache_max(dummy_ptr) == 0) 2006 fprintf(STDERR, " cache_max = unlimited\n"); 2007 else 2008 fprintf(STDERR, " cache_max = %lu\n", 2009 (unsigned long) png_get_chunk_cache_max(dummy_ptr)); 2010 if (png_get_chunk_malloc_max(dummy_ptr) == 0) 2011 fprintf(STDERR, " malloc_max = unlimited\n"); 2012 else 2013 fprintf(STDERR, " malloc_max = %lu\n", 2014 (unsigned long) png_get_chunk_malloc_max(dummy_ptr)); 2015 png_destroy_read_struct(&dummy_ptr, NULL, NULL); 2016 1997 2017 return (int)(ierror != 0); 1998 2018 } … … 2009 2029 2010 2030 /* Generate a compiler error if there is an old png.h in the search path. */ 2011 typedef png_libpng_version_1_6_1 6 Your_png_h_is_not_version_1_6_16;2031 typedef png_libpng_version_1_6_18 Your_png_h_is_not_version_1_6_18; -
TabularUnified libpng/vendor/current/pngtrans.c ¶
r1059 r1165 2 2 /* pngtrans.c - transforms the data in a row (used by both readers and writers) 3 3 * 4 * Last changed in libpng 1.6.1 5 [November 20, 2014]5 * Copyright (c) 1998-201 4Glenn Randers-Pehrson4 * Last changed in libpng 1.6.18 [July 23, 2015] 5 * Copyright (c) 1998-2015 Glenn Randers-Pehrson 6 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 7 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) … … 705 705 for (; rp > png_ptr->row_buf; rp--) 706 706 { 707 if ( *rp >> padding!= 0)707 if ((*rp >> padding) != 0) 708 708 png_ptr->num_palette_max = 1; 709 709 padding = 0; -
TabularUnified libpng/vendor/current/pngusr.dfa ¶
r922 r1165 9 9 # them to be passed through to the build of pnglibconf.h), for example: 10 10 # 11 # @# define PNG_USER_WIDTH_MAX 100000012 # @# define PNG_USER_HEIGHT_MAX 100000013 # @# define PNG_USER_CHUNK_CACHE_MAX 12814 # @# define PNG_USER_CHUNK_MALLOC_MAX 800000011 # @# define PNG_USER_WIDTH_MAX 65535 12 # @# define PNG_USER_HEIGHT_MAX 65535 13 # @# define PNG_USER_CHUNK_CACHE_MAX 256 14 # @# define PNG_USER_CHUNK_MALLOC_MAX 640000 -
TabularUnified libpng/vendor/current/pngwrite.c ¶
r1059 r1165 2 2 /* pngwrite.c - general routines to write a PNG file 3 3 * 4 * Last changed in libpng 1.6.1 5 [November 20, 2014]5 * Copyright (c) 1998-201 4Glenn Randers-Pehrson4 * Last changed in libpng 1.6.18 [July 23, 2015] 5 * Copyright (c) 1998-2015 Glenn Randers-Pehrson 6 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 7 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) … … 91 91 if ((png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE) == 0) 92 92 { 93 /* Write PNG signature */94 png_write_sig(png_ptr);93 /* Write PNG signature */ 94 png_write_sig(png_ptr); 95 95 96 96 #ifdef PNG_MNG_FEATURES_SUPPORTED 97 if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) != 0 && \ 98 png_ptr->mng_features_permitted != 0) 99 { 100 png_warning(png_ptr, "MNG features are not allowed in a PNG datastream"); 101 png_ptr->mng_features_permitted = 0; 102 } 103 #endif 104 105 /* Write IHDR information. */ 106 png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height, 107 info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type, 108 info_ptr->filter_type, 97 if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) != 0 && \ 98 png_ptr->mng_features_permitted != 0) 99 { 100 png_warning(png_ptr, 101 "MNG features are not allowed in a PNG datastream"); 102 png_ptr->mng_features_permitted = 0; 103 } 104 #endif 105 106 /* Write IHDR information. */ 107 png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height, 108 info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type, 109 info_ptr->filter_type, 109 110 #ifdef PNG_WRITE_INTERLACING_SUPPORTED 110 info_ptr->interlace_type111 info_ptr->interlace_type 111 112 #else 112 0113 #endif 114 );115 116 /* The rest of these check to see if the valid field has the appropriate117 * flag set, and if it does, writes the chunk.118 *119 * 1.6.0: COLORSPACE support controls the writing of these chunks too, and120 * the chunks will be written if the WRITE routine is there and information121 * is available in the COLORSPACE. (See png_colorspace_sync_info in png.c122 *for where the valid flags get set.)123 *124 * Under certain circumstances the colorspace can be invalidated without125 * syncing the info_struct 'valid' flags; this happens if libpng detects and126 * error and calls png_error while the color space is being set, yet the127 * application continues writing the PNG. So check the 'invalid' flag here128 *too.129 */113 0 114 #endif 115 ); 116 117 /* The rest of these check to see if the valid field has the appropriate 118 * flag set, and if it does, writes the chunk. 119 * 120 * 1.6.0: COLORSPACE support controls the writing of these chunks too, and 121 * the chunks will be written if the WRITE routine is there and 122 * information * is available in the COLORSPACE. (See 123 * png_colorspace_sync_info in png.c for where the valid flags get set.) 124 * 125 * Under certain circumstances the colorspace can be invalidated without 126 * syncing the info_struct 'valid' flags; this happens if libpng detects 127 * an error and calls png_error while the color space is being set, yet 128 * the application continues writing the PNG. So check the 'invalid' 129 * flag here too. 130 */ 130 131 #ifdef PNG_GAMMA_SUPPORTED 131 132 # ifdef PNG_WRITE_gAMA_SUPPORTED … … 138 139 139 140 #ifdef PNG_COLORSPACE_SUPPORTED 140 /* Write only one of sRGB or an ICC profile. If a profile was supplied141 * and it matches one of the known sRGB ones issue a warning.142 */141 /* Write only one of sRGB or an ICC profile. If a profile was supplied 142 * and it matches one of the known sRGB ones issue a warning. 143 */ 143 144 # ifdef PNG_WRITE_iCCP_SUPPORTED 144 if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&145 (info_ptr->valid & PNG_INFO_iCCP) != 0)146 {147 # 148 if ((info_ptr->valid & PNG_INFO_sRGB) != 0)149 png_app_warning(png_ptr,150 "profile matches sRGB but writing iCCP instead");151 # 152 153 png_write_iCCP(png_ptr, info_ptr->iccp_name,154 info_ptr->iccp_profile);155 }145 if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 && 146 (info_ptr->valid & PNG_INFO_iCCP) != 0) 147 { 148 # ifdef PNG_WRITE_sRGB_SUPPORTED 149 if ((info_ptr->valid & PNG_INFO_sRGB) != 0) 150 png_app_warning(png_ptr, 151 "profile matches sRGB but writing iCCP instead"); 152 # endif 153 154 png_write_iCCP(png_ptr, info_ptr->iccp_name, 155 info_ptr->iccp_profile); 156 } 156 157 # ifdef PNG_WRITE_sRGB_SUPPORTED 157 158 else … … 160 161 161 162 # ifdef PNG_WRITE_sRGB_SUPPORTED 162 if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&163 (info_ptr->valid & PNG_INFO_sRGB) != 0)164 png_write_sRGB(png_ptr, info_ptr->colorspace.rendering_intent);163 if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 && 164 (info_ptr->valid & PNG_INFO_sRGB) != 0) 165 png_write_sRGB(png_ptr, info_ptr->colorspace.rendering_intent); 165 166 # endif /* WRITE_sRGB */ 166 167 #endif /* COLORSPACE */ 167 168 168 169 #ifdef PNG_WRITE_sBIT_SUPPORTED 169 if ((info_ptr->valid & PNG_INFO_sBIT) != 0)170 png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type);170 if ((info_ptr->valid & PNG_INFO_sBIT) != 0) 171 png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type); 171 172 #endif 172 173 173 174 #ifdef PNG_COLORSPACE_SUPPORTED 174 175 # ifdef PNG_WRITE_cHRM_SUPPORTED 175 if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&176 (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) != 0 &&177 (info_ptr->valid & PNG_INFO_cHRM) != 0)178 png_write_cHRM_fixed(png_ptr, &info_ptr->colorspace.end_points_xy);176 if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 && 177 (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) != 0 && 178 (info_ptr->valid & PNG_INFO_cHRM) != 0) 179 png_write_cHRM_fixed(png_ptr, &info_ptr->colorspace.end_points_xy); 179 180 # endif 180 181 #endif 181 182 182 183 #ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED 183 write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_IHDR);184 write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_IHDR); 184 185 #endif 185 186 … … 217 218 info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) 218 219 { 219 int j; 220 for (j = 0; j<(int)info_ptr->num_trans; j++) 220 int j, jend; 221 222 jend = info_ptr->num_trans; 223 if (jend > PNG_MAX_PALETTE_LENGTH) 224 jend = PNG_MAX_PALETTE_LENGTH; 225 226 for (j = 0; j<jend; ++j) 221 227 info_ptr->trans_alpha[j] = 222 228 (png_byte)(255 - info_ptr->trans_alpha[j]); … … 539 545 * are errors during development. 540 546 */ 541 #if PNG_ LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC547 #if PNG_RELEASE_BUILD 542 548 png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN; 543 549 #endif … … 639 645 for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) 640 646 { 641 *(rp) = (png_byte)( (*rp - *(rp + 1)) & 0xff);642 *(rp + 2) = (png_byte)( (*(rp + 2) - *(rp + 1)) & 0xff);647 *(rp) = (png_byte)(*rp - *(rp + 1)); 648 *(rp + 2) = (png_byte)(*(rp + 2) - *(rp + 1)); 643 649 } 644 650 } … … 666 672 png_uint_32 red = (png_uint_32)((s0 - s1) & 0xffffL); 667 673 png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL); 668 *(rp ) = (png_byte)( (red >> 8) & 0xff);669 *(rp + 1) = (png_byte) (red & 0xff);670 *(rp + 4) = (png_byte)( (blue >> 8) & 0xff);671 *(rp + 5) = (png_byte) (blue & 0xff);674 *(rp ) = (png_byte)(red >> 8); 675 *(rp + 1) = (png_byte)red; 676 *(rp + 4) = (png_byte)(blue >> 8); 677 *(rp + 5) = (png_byte)blue; 672 678 } 673 679 } … … 850 856 */ 851 857 if (row_info.pixel_depth != png_ptr->pixel_depth || 852 row_info.pixel_depth != png_ptr->transformed_pixel_depth)858 row_info.pixel_depth != png_ptr->transformed_pixel_depth) 853 859 png_error(png_ptr, "internal write transform logic error"); 854 860 … … 918 924 #endif /* WRITE_FLUSH */ 919 925 920 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED921 static void png_reset_filter_heuristics(png_structrp png_ptr);/* forward decl */922 #endif923 924 926 /* Free any memory used in png_ptr struct without freeing the struct itself. */ 925 927 static void … … 938 940 #ifdef PNG_WRITE_FILTER_SUPPORTED 939 941 png_free(png_ptr, png_ptr->prev_row); 940 png_free(png_ptr, png_ptr->sub_row); 941 png_free(png_ptr, png_ptr->up_row); 942 png_free(png_ptr, png_ptr->avg_row); 943 png_free(png_ptr, png_ptr->paeth_row); 942 png_free(png_ptr, png_ptr->try_row); 943 png_free(png_ptr, png_ptr->tst_row); 944 944 png_ptr->prev_row = NULL; 945 png_ptr->sub_row = NULL; 946 png_ptr->up_row = NULL; 947 png_ptr->avg_row = NULL; 948 png_ptr->paeth_row = NULL; 949 #endif 950 951 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 952 /* Use this to save a little code space, it doesn't free the filter_costs */ 953 png_reset_filter_heuristics(png_ptr); 954 png_free(png_ptr, png_ptr->filter_costs); 955 png_free(png_ptr, png_ptr->inv_filter_costs); 956 png_ptr->filter_costs = NULL; 957 png_ptr->inv_filter_costs = NULL; 945 png_ptr->try_row = NULL; 946 png_ptr->tst_row = NULL; 958 947 #endif 959 948 … … 1045 1034 } 1046 1035 1036 #ifdef PNG_WRITE_FILTER_SUPPORTED 1047 1037 /* If we have allocated the row_buf, this means we have already started 1048 1038 * with the image and we should have allocated all of the filter buffers … … 1051 1041 * will be missing the data in the previous row. If an application 1052 1042 * wants to start and stop using particular filters during compression, 1053 * it should start out with all of the filters, and then add and 1054 * remove them after the start of compression. 1043 * it should start out with all of the filters, and then remove them 1044 * or add them back after the start of compression. 1045 * 1046 * NOTE: this is a nasty constraint on the code, because it means that the 1047 * prev_row buffer must be maintained even if there are currently no 1048 * 'prev_row' requiring filters active. 1055 1049 */ 1056 1050 if (png_ptr->row_buf != NULL) 1057 1051 { 1058 #ifdef PNG_WRITE_FILTER_SUPPORTED 1059 if ((png_ptr->do_filter & PNG_FILTER_SUB) != 0 && 1060 png_ptr->sub_row == NULL) 1052 int num_filters; 1053 png_alloc_size_t buf_size; 1054 1055 /* Repeat the checks in png_write_start_row; 1 pixel high or wide 1056 * images cannot benefit from certain filters. If this isn't done here 1057 * the check below will fire on 1 pixel high images. 1058 */ 1059 if (png_ptr->height == 1) 1060 filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH); 1061 1062 if (png_ptr->width == 1) 1063 filters &= ~(PNG_FILTER_SUB|PNG_FILTER_AVG|PNG_FILTER_PAETH); 1064 1065 if ((filters & (PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH)) != 0 1066 && png_ptr->prev_row == NULL) 1061 1067 { 1062 png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, 1063 (png_ptr->rowbytes + 1)); 1064 png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB; 1068 /* This is the error case, however it is benign - the previous row 1069 * is not available so the filter can't be used. Just warn here. 1070 */ 1071 png_app_warning(png_ptr, 1072 "png_set_filter: UP/AVG/PAETH cannot be added after start"); 1073 filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH); 1065 1074 } 1066 1075 1067 if ((png_ptr->do_filter & PNG_FILTER_UP) != 0 && 1068 png_ptr->up_row == NULL) 1076 num_filters = 0; 1077 1078 if (filters & PNG_FILTER_SUB) 1079 num_filters++; 1080 1081 if (filters & PNG_FILTER_UP) 1082 num_filters++; 1083 1084 if (filters & PNG_FILTER_AVG) 1085 num_filters++; 1086 1087 if (filters & PNG_FILTER_PAETH) 1088 num_filters++; 1089 1090 /* Allocate needed row buffers if they have not already been 1091 * allocated. 1092 */ 1093 buf_size = PNG_ROWBYTES(png_ptr->usr_channels * png_ptr->usr_bit_depth, 1094 png_ptr->width) + 1; 1095 1096 if (png_ptr->try_row == NULL) 1097 png_ptr->try_row = png_voidcast(png_bytep, 1098 png_malloc(png_ptr, buf_size)); 1099 1100 if (num_filters > 1) 1069 1101 { 1070 if (png_ptr->prev_row == NULL) 1071 { 1072 png_warning(png_ptr, "Can't add Up filter after starting"); 1073 png_ptr->do_filter = (png_byte)(png_ptr->do_filter & 1074 ~PNG_FILTER_UP); 1075 } 1076 1077 else 1078 { 1079 png_ptr->up_row = (png_bytep)png_malloc(png_ptr, 1080 (png_ptr->rowbytes + 1)); 1081 png_ptr->up_row[0] = PNG_FILTER_VALUE_UP; 1082 } 1102 if (png_ptr->tst_row == NULL) 1103 png_ptr->tst_row = png_voidcast(png_bytep, 1104 png_malloc(png_ptr, buf_size)); 1083 1105 } 1084 1085 if ((png_ptr->do_filter & PNG_FILTER_AVG) != 0 && 1086 png_ptr->avg_row == NULL) 1087 { 1088 if (png_ptr->prev_row == NULL) 1089 { 1090 png_warning(png_ptr, "Can't add Average filter after starting"); 1091 png_ptr->do_filter = (png_byte)(png_ptr->do_filter & 1092 ~PNG_FILTER_AVG); 1093 } 1094 1095 else 1096 { 1097 png_ptr->avg_row = (png_bytep)png_malloc(png_ptr, 1098 (png_ptr->rowbytes + 1)); 1099 png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG; 1100 } 1101 } 1102 1103 if ((png_ptr->do_filter & PNG_FILTER_PAETH) != 0 && 1104 png_ptr->paeth_row == NULL) 1105 { 1106 if (png_ptr->prev_row == NULL) 1107 { 1108 png_warning(png_ptr, "Can't add Paeth filter after starting"); 1109 png_ptr->do_filter &= (png_byte)(~PNG_FILTER_PAETH); 1110 } 1111 1112 else 1113 { 1114 png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr, 1115 (png_ptr->rowbytes + 1)); 1116 png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH; 1117 } 1118 } 1119 1120 if (png_ptr->do_filter == PNG_NO_FILTERS) 1121 #endif /* WRITE_FILTER */ 1122 png_ptr->do_filter = PNG_FILTER_NONE; 1123 } 1106 } 1107 png_ptr->do_filter = (png_byte)filters; 1108 #endif 1124 1109 } 1125 1110 else … … 1127 1112 } 1128 1113 1129 /* This allows us to influence the way in which libpng chooses the "best" 1130 * filter for the current scanline. While the "minimum-sum-of-absolute- 1131 * differences metric is relatively fast and effective, there is some 1132 * question as to whether it can be improved upon by trying to keep the 1133 * filtered data going to zlib more consistent, hopefully resulting in 1134 * better compression. 1135 */ 1136 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* GRR 970116 */ 1137 /* Convenience reset API. */ 1138 static void 1139 png_reset_filter_heuristics(png_structrp png_ptr) 1140 { 1141 /* Clear out any old values in the 'weights' - this must be done because if 1142 * the app calls set_filter_heuristics multiple times with different 1143 * 'num_weights' values we would otherwise potentially have wrong sized 1144 * arrays. 1145 */ 1146 png_ptr->num_prev_filters = 0; 1147 png_ptr->heuristic_method = PNG_FILTER_HEURISTIC_UNWEIGHTED; 1148 if (png_ptr->prev_filters != NULL) 1149 { 1150 png_bytep old = png_ptr->prev_filters; 1151 png_ptr->prev_filters = NULL; 1152 png_free(png_ptr, old); 1153 } 1154 if (png_ptr->filter_weights != NULL) 1155 { 1156 png_uint_16p old = png_ptr->filter_weights; 1157 png_ptr->filter_weights = NULL; 1158 png_free(png_ptr, old); 1159 } 1160 1161 if (png_ptr->inv_filter_weights != NULL) 1162 { 1163 png_uint_16p old = png_ptr->inv_filter_weights; 1164 png_ptr->inv_filter_weights = NULL; 1165 png_free(png_ptr, old); 1166 } 1167 1168 /* Leave the filter_costs - this array is fixed size. */ 1169 } 1170 1171 static int 1172 png_init_filter_heuristics(png_structrp png_ptr, int heuristic_method, 1173 int num_weights) 1174 { 1175 if (png_ptr == NULL) 1176 return 0; 1177 1178 /* Clear out the arrays */ 1179 png_reset_filter_heuristics(png_ptr); 1180 1181 /* Check arguments; the 'reset' function makes the correct settings for the 1182 * unweighted case, but we must handle the weight case by initializing the 1183 * arrays for the caller. 1184 */ 1185 if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) 1186 { 1187 int i; 1188 1189 if (num_weights > 0) 1190 { 1191 png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr, 1192 (png_uint_32)((sizeof (png_byte)) * num_weights)); 1193 1194 /* To make sure that the weighting starts out fairly */ 1195 for (i = 0; i < num_weights; i++) 1196 { 1197 png_ptr->prev_filters[i] = 255; 1198 } 1199 1200 png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr, 1201 (png_uint_32)((sizeof (png_uint_16)) * num_weights)); 1202 1203 png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr, 1204 (png_uint_32)((sizeof (png_uint_16)) * num_weights)); 1205 1206 for (i = 0; i < num_weights; i++) 1207 { 1208 png_ptr->inv_filter_weights[i] = 1209 png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; 1210 } 1211 1212 /* Safe to set this now */ 1213 png_ptr->num_prev_filters = (png_byte)num_weights; 1214 } 1215 1216 /* If, in the future, there are other filter methods, this would 1217 * need to be based on png_ptr->filter. 1218 */ 1219 if (png_ptr->filter_costs == NULL) 1220 { 1221 png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr, 1222 (png_uint_32)((sizeof (png_uint_16)) * PNG_FILTER_VALUE_LAST)); 1223 1224 png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr, 1225 (png_uint_32)((sizeof (png_uint_16)) * PNG_FILTER_VALUE_LAST)); 1226 } 1227 1228 for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) 1229 { 1230 png_ptr->inv_filter_costs[i] = 1231 png_ptr->filter_costs[i] = PNG_COST_FACTOR; 1232 } 1233 1234 /* All the arrays are inited, safe to set this: */ 1235 png_ptr->heuristic_method = PNG_FILTER_HEURISTIC_WEIGHTED; 1236 1237 /* Return the 'ok' code. */ 1238 return 1; 1239 } 1240 else if (heuristic_method == PNG_FILTER_HEURISTIC_DEFAULT || 1241 heuristic_method == PNG_FILTER_HEURISTIC_UNWEIGHTED) 1242 { 1243 return 1; 1244 } 1245 else 1246 { 1247 png_warning(png_ptr, "Unknown filter heuristic method"); 1248 return 0; 1249 } 1250 } 1251 1114 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */ 1252 1115 /* Provide floating and fixed point APIs */ 1253 1116 #ifdef PNG_FLOATING_POINT_SUPPORTED … … 1257 1120 png_const_doublep filter_costs) 1258 1121 { 1259 png_debug(1, "in png_set_filter_heuristics"); 1260 1261 /* The internal API allocates all the arrays and ensures that the elements of 1262 * those arrays are set to the default value. 1263 */ 1264 if (png_init_filter_heuristics(png_ptr, heuristic_method, num_weights) == 0) 1265 return; 1266 1267 /* If using the weighted method copy in the weights. */ 1268 if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) 1269 { 1270 int i; 1271 for (i = 0; i < num_weights; i++) 1272 { 1273 if (filter_weights[i] <= 0.0) 1274 { 1275 png_ptr->inv_filter_weights[i] = 1276 png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; 1277 } 1278 1279 else 1280 { 1281 png_ptr->inv_filter_weights[i] = 1282 (png_uint_16)(PNG_WEIGHT_FACTOR*filter_weights[i]+.5); 1283 1284 png_ptr->filter_weights[i] = 1285 (png_uint_16)(PNG_WEIGHT_FACTOR/filter_weights[i]+.5); 1286 } 1287 } 1288 1289 /* Here is where we set the relative costs of the different filters. We 1290 * should take the desired compression level into account when setting 1291 * the costs, so that Paeth, for instance, has a high relative cost at low 1292 * compression levels, while it has a lower relative cost at higher 1293 * compression settings. The filter types are in order of increasing 1294 * relative cost, so it would be possible to do this with an algorithm. 1295 */ 1296 for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) if (filter_costs[i] >= 1.0) 1297 { 1298 png_ptr->inv_filter_costs[i] = 1299 (png_uint_16)(PNG_COST_FACTOR / filter_costs[i] + .5); 1300 1301 png_ptr->filter_costs[i] = 1302 (png_uint_16)(PNG_COST_FACTOR * filter_costs[i] + .5); 1303 } 1304 } 1122 PNG_UNUSED(png_ptr) 1123 PNG_UNUSED(heuristic_method) 1124 PNG_UNUSED(num_weights) 1125 PNG_UNUSED(filter_weights) 1126 PNG_UNUSED(filter_costs) 1305 1127 } 1306 1128 #endif /* FLOATING_POINT */ … … 1312 1134 png_const_fixed_point_p filter_costs) 1313 1135 { 1314 png_debug(1, "in png_set_filter_heuristics_fixed"); 1315 1316 /* The internal API allocates all the arrays and ensures that the elements of 1317 * those arrays are set to the default value. 1318 */ 1319 if (png_init_filter_heuristics(png_ptr, heuristic_method, num_weights) == 0) 1320 return; 1321 1322 /* If using the weighted method copy in the weights. */ 1323 if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) 1324 { 1325 int i; 1326 for (i = 0; i < num_weights; i++) 1327 { 1328 if (filter_weights[i] <= 0) 1329 { 1330 png_ptr->inv_filter_weights[i] = 1331 png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; 1332 } 1333 1334 else 1335 { 1336 png_ptr->inv_filter_weights[i] = (png_uint_16) 1337 ((PNG_WEIGHT_FACTOR*filter_weights[i]+PNG_FP_HALF)/PNG_FP_1); 1338 1339 png_ptr->filter_weights[i] = (png_uint_16)((PNG_WEIGHT_FACTOR* 1340 PNG_FP_1+(filter_weights[i]/2))/filter_weights[i]); 1341 } 1342 } 1343 1344 /* Here is where we set the relative costs of the different filters. We 1345 * should take the desired compression level into account when setting 1346 * the costs, so that Paeth, for instance, has a high relative cost at low 1347 * compression levels, while it has a lower relative cost at higher 1348 * compression settings. The filter types are in order of increasing 1349 * relative cost, so it would be possible to do this with an algorithm. 1350 */ 1351 for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) 1352 if (filter_costs[i] >= PNG_FP_1) 1353 { 1354 png_uint_32 tmp; 1355 1356 /* Use a 32 bit unsigned temporary here because otherwise the 1357 * intermediate value will be a 32 bit *signed* integer (ANSI rules) 1358 * and this will get the wrong answer on division. 1359 */ 1360 tmp = PNG_COST_FACTOR*PNG_FP_1 + (filter_costs[i]/2); 1361 tmp /= filter_costs[i]; 1362 1363 png_ptr->inv_filter_costs[i] = (png_uint_16)tmp; 1364 1365 tmp = PNG_COST_FACTOR * filter_costs[i] + PNG_FP_HALF; 1366 tmp /= PNG_FP_1; 1367 1368 png_ptr->filter_costs[i] = (png_uint_16)tmp; 1369 } 1370 } 1136 PNG_UNUSED(png_ptr) 1137 PNG_UNUSED(heuristic_method) 1138 PNG_UNUSED(num_weights) 1139 PNG_UNUSED(filter_weights) 1140 PNG_UNUSED(filter_costs) 1371 1141 } 1372 1142 #endif /* FIXED_POINT */ 1373 1143 #endif /* WRITE_WEIGHTED_FILTER */ 1374 1144 1145 #ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED 1375 1146 void PNGAPI 1376 1147 png_set_compression_level(png_structrp png_ptr, int level) … … 1418 1189 return; 1419 1190 1420 /* Prior to 1.6.0 this would warn but then set the window_bits value , this1421 * meant that negative window bits values could be selected whichwould cause1191 /* Prior to 1.6.0 this would warn but then set the window_bits value. This 1192 * meant that negative window bits values could be selected that would cause 1422 1193 * libpng to write a non-standard PNG file with raw deflate or gzip 1423 1194 * compressed IDAT or ancillary chunks. Such files can be read and there is … … 1455 1226 png_ptr->zlib_method = method; 1456 1227 } 1228 #endif /* WRITE_CUSTOMIZE_COMPRESSION */ 1457 1229 1458 1230 /* The following were added to libpng-1.5.4 */ … … 1615 1387 */ 1616 1388 if ((transforms & (PNG_TRANSFORM_STRIP_FILLER_AFTER| 1617 PNG_TRANSFORM_STRIP_FILLER_BEFORE)) != 0)1389 PNG_TRANSFORM_STRIP_FILLER_BEFORE)) != 0) 1618 1390 { 1619 1391 #ifdef PNG_WRITE_FILLER_SUPPORTED … … 1622 1394 if ((transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE) != 0) 1623 1395 png_app_error(png_ptr, 1624 "PNG_TRANSFORM_STRIP_FILLER: BEFORE+AFTER not supported");1396 "PNG_TRANSFORM_STRIP_FILLER: BEFORE+AFTER not supported"); 1625 1397 1626 1398 /* Continue if ignored - this is the pre-1.6.10 behavior */ … … 1681 1453 1682 1454 #ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED 1683 # ifdef PNG_STDIO_SUPPORTED /* currently required for png_image_write_* */1455 # ifdef PNG_STDIO_SUPPORTED /* currently required for png_image_write_* */ 1684 1456 /* Initialize the write structure - general purpose utility. */ 1685 1457 static int … … 1687 1459 { 1688 1460 png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, image, 1689 1461 png_safe_error, png_safe_warning); 1690 1462 1691 1463 if (png_ptr != NULL) … … 1696 1468 { 1697 1469 png_controlp control = png_voidcast(png_controlp, 1698 png_malloc_warn(png_ptr, (sizeof *control)));1470 png_malloc_warn(png_ptr, (sizeof *control))); 1699 1471 1700 1472 if (control != NULL) … … 1743 1515 { 1744 1516 png_image_write_control *display = png_voidcast(png_image_write_control*, 1745 argument);1517 argument); 1746 1518 png_imagep image = display->image; 1747 1519 png_structrp png_ptr = image->opaque->png_ptr; 1748 1520 1749 1521 png_const_uint_16p input_row = png_voidcast(png_const_uint_16p, 1750 display->first_row);1522 display->first_row); 1751 1523 png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row); 1752 1524 png_uint_16p row_end; … … 1757 1529 if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0) 1758 1530 { 1759 # ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED 1760 if ((image->format & PNG_FORMAT_FLAG_AFIRST) != 0) 1761 { 1762 aindex = -1; 1763 ++input_row; /* To point to the first component */ 1764 ++output_row; 1765 } 1766 1531 # ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED 1532 if ((image->format & PNG_FORMAT_FLAG_AFIRST) != 0) 1533 { 1534 aindex = -1; 1535 ++input_row; /* To point to the first component */ 1536 ++output_row; 1537 } 1767 1538 else 1539 aindex = channels; 1540 # else 1541 aindex = channels; 1768 1542 # endif 1769 aindex = channels;1770 1543 } 1771 1544 … … 1849 1622 * be scaled in the range 0..255*65535, so include that scaling here. 1850 1623 */ 1851 # define UNP_RECIPROCAL(alpha) ((((0xffff*0xff)<<7)+(alpha>>1))/alpha)1624 # define UNP_RECIPROCAL(alpha) ((((0xffff*0xff)<<7)+(alpha>>1))/alpha) 1852 1625 1853 1626 static png_byte … … 1900 1673 { 1901 1674 png_image_write_control *display = png_voidcast(png_image_write_control*, 1902 argument);1675 argument); 1903 1676 png_imagep image = display->image; 1904 1677 png_structrp png_ptr = image->opaque->png_ptr; 1905 1678 1906 1679 png_const_uint_16p input_row = png_voidcast(png_const_uint_16p, 1907 display->first_row);1680 display->first_row); 1908 1681 png_bytep output_row = png_voidcast(png_bytep, display->local_row); 1909 1682 png_uint_32 y = image->height; … … 1915 1688 int aindex; 1916 1689 1917 # 1918 1919 1920 1921 1922 1923 1924 1925 1926 # 1927 1690 # ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED 1691 if ((image->format & PNG_FORMAT_FLAG_AFIRST) != 0) 1692 { 1693 aindex = -1; 1694 ++input_row; /* To point to the first component */ 1695 ++output_row; 1696 } 1697 1698 else 1699 # endif 1700 aindex = channels; 1928 1701 1929 1702 /* Use row_end in place of a loop counter: */ … … 1959 1732 1960 1733 png_write_row(png_ptr, png_voidcast(png_const_bytep, 1961 display->local_row));1734 display->local_row)); 1962 1735 input_row += display->row_bytes/(sizeof (png_uint_16)); 1963 1736 } /* while y */ … … 1998 1771 const void *cmap = display->colormap; 1999 1772 const int entries = image->colormap_entries > 256 ? 256 : 2000 (int)image->colormap_entries;1773 (int)image->colormap_entries; 2001 1774 2002 1775 /* NOTE: the caller must check for cmap != NULL and entries != 0 */ … … 2004 1777 const int channels = PNG_IMAGE_SAMPLE_CHANNELS(format); 2005 1778 2006 # if defined(PNG_FORMAT_BGR_SUPPORTED) &&\1779 # if defined(PNG_FORMAT_BGR_SUPPORTED) &&\ 2007 1780 defined(PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED) 2008 1781 const int afirst = (format & PNG_FORMAT_FLAG_AFIRST) != 0 && 2009 (format & PNG_FORMAT_FLAG_ALPHA) != 0;2010 # else1782 (format & PNG_FORMAT_FLAG_ALPHA) != 0; 1783 # else 2011 1784 # define afirst 0 2012 # endif2013 2014 # ifdef PNG_FORMAT_BGR_SUPPORTED1785 # endif 1786 1787 # ifdef PNG_FORMAT_BGR_SUPPORTED 2015 1788 const int bgr = (format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0; 2016 # else1789 # else 2017 1790 # define bgr 0 2018 # endif1791 # endif 2019 1792 2020 1793 int i, num_trans; … … 2041 1814 { 2042 1815 palette[i].blue = (png_byte)PNG_sRGB_FROM_LINEAR(255 * 2043 entry[(2 ^ bgr)]);1816 entry[(2 ^ bgr)]); 2044 1817 palette[i].green = (png_byte)PNG_sRGB_FROM_LINEAR(255 * 2045 entry[1]);1818 entry[1]); 2046 1819 palette[i].red = (png_byte)PNG_sRGB_FROM_LINEAR(255 * 2047 entry[bgr]);1820 entry[bgr]); 2048 1821 } 2049 1822 … … 2121 1894 } 2122 1895 2123 # ifdef afirst1896 # ifdef afirst 2124 1897 # undef afirst 2125 # endif2126 # ifdef bgr1898 # endif 1899 # ifdef bgr 2127 1900 # undef bgr 2128 # endif1901 # endif 2129 1902 2130 1903 png_set_PLTE(image->opaque->png_ptr, image->opaque->info_ptr, palette, … … 2154 1927 int write_16bit = linear && !colormap && (display->convert_to_8bit == 0); 2155 1928 2156 # ifdef PNG_BENIGN_ERRORS_SUPPORTED1929 # ifdef PNG_BENIGN_ERRORS_SUPPORTED 2157 1930 /* Make sure we error out on any bad situation */ 2158 1931 png_set_benign_errors(png_ptr, 0/*error*/); 2159 # endif1932 # endif 2160 1933 2161 1934 /* Default the 'row_stride' parameter if required. */ … … 2236 2009 } 2237 2010 2238 # ifdef PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED2011 # ifdef PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED 2239 2012 if ((format & PNG_FORMAT_FLAG_BGR) != 0) 2240 2013 { … … 2243 2016 format &= ~PNG_FORMAT_FLAG_BGR; 2244 2017 } 2245 # endif2246 2247 # ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED2018 # endif 2019 2020 # ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED 2248 2021 if ((format & PNG_FORMAT_FLAG_AFIRST) != 0) 2249 2022 { … … 2252 2025 format &= ~PNG_FORMAT_FLAG_AFIRST; 2253 2026 } 2254 # endif2027 # endif 2255 2028 2256 2029 /* If there are 16 or fewer color-map entries we wrote a lower bit depth … … 2288 2061 * total (user) time on a heavily loaded system. 2289 2062 */ 2063 # ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED 2290 2064 png_set_compression_level(png_ptr, 3); 2065 # endif 2291 2066 } 2292 2067 … … 2451 2226 return 0; 2452 2227 } 2453 # endif /* STDIO */2228 # endif /* STDIO */ 2454 2229 #endif /* SIMPLIFIED_WRITE */ 2455 2230 #endif /* WRITE */ -
TabularUnified libpng/vendor/current/pngwtran.c ¶
r1059 r1165 2 2 /* pngwtran.c - transforms the data in a row for PNG writers 3 3 * 4 * Last changed in libpng 1.6.1 5 [November 20, 2014]5 * Copyright (c) 1998-201 4Glenn Randers-Pehrson4 * Last changed in libpng 1.6.18 [July 23, 2015] 5 * Copyright (c) 1998-2015 Glenn Randers-Pehrson 6 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 7 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) … … 72 72 { 73 73 png_bytep sp, dp; 74 int shift, v; 74 unsigned int shift; 75 int v; 75 76 png_uint_32 i; 76 77 png_uint_32 row_width = row_info->width; … … 111 112 { 112 113 png_bytep sp, dp; 113 int shift, v; 114 unsigned int shift; 115 int v; 114 116 png_uint_32 i; 115 117 png_uint_32 row_width = row_info->width; … … 423 425 */ 424 426 sp+=3; dp = sp; 425 * (dp++)= (png_byte)(255 - *(sp++));427 *dp = (png_byte)(255 - *(sp++)); 426 428 } 427 429 } … … 447 449 sp+=6; dp = sp; 448 450 *(dp++) = (png_byte)(255 - *(sp++)); 449 * (dp++)= (png_byte)(255 - *(sp++));451 *dp = (png_byte)(255 - *(sp++)); 450 452 } 451 453 } … … 485 487 sp+=2; dp = sp; 486 488 *(dp++) = (png_byte)(255 - *(sp++)); 487 * (dp++)= (png_byte)(255 - *(sp++));489 *dp = (png_byte)(255 - *(sp++)); 488 490 } 489 491 } -
TabularUnified libpng/vendor/current/pngwutil.c ¶
r1059 r1165 2 2 /* pngwutil.c - utilities to write a PNG file 3 3 * 4 * Last changed in libpng 1.6.1 5 [November 20, 2014]5 * Copyright (c) 1998-201 4Glenn Randers-Pehrson4 * Last changed in libpng 1.6.18 [July 23, 2015] 5 * Copyright (c) 1998-2015 Glenn Randers-Pehrson 6 6 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 7 7 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) … … 24 24 png_save_uint_32(png_bytep buf, png_uint_32 i) 25 25 { 26 buf[0] = (png_byte)( (i >> 24) & 0xff);27 buf[1] = (png_byte)( (i >> 16) & 0xff);28 buf[2] = (png_byte)( (i >> 8) & 0xff);29 buf[3] = (png_byte)(i & 0xff);26 buf[0] = (png_byte)(i >> 24); 27 buf[1] = (png_byte)(i >> 16); 28 buf[2] = (png_byte)(i >> 8); 29 buf[3] = (png_byte)(i ); 30 30 } 31 31 … … 37 37 png_save_uint_16(png_bytep buf, unsigned int i) 38 38 { 39 buf[0] = (png_byte)( (i >> 8) & 0xff);40 buf[1] = (png_byte)(i & 0xff);39 buf[0] = (png_byte)(i >> 8); 40 buf[1] = (png_byte)(i ); 41 41 } 42 42 #endif … … 309 309 (void)png_safecat(msg, (sizeof msg), 10, " using zstream"); 310 310 #endif 311 #if PNG_ LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC311 #if PNG_RELEASE_BUILD 312 312 png_warning(png_ptr, msg); 313 313 … … 696 696 while (*key && key_len < 79) 697 697 { 698 png_byte ch = (png_byte) (0xff & *key++);698 png_byte ch = (png_byte)*key++; 699 699 700 700 if ((ch > 32 && ch <= 126) || (ch >= 161 /*&& ch <= 255*/)) … … 872 872 #endif 873 873 874 /* Save the relev ent information */874 /* Save the relevant information */ 875 875 png_ptr->bit_depth = (png_byte)bit_depth; 876 876 png_ptr->color_type = (png_byte)color_type; … … 1766 1766 1767 1767 else 1768 png_write_chunk_data(png_ptr, (png_const_bytep)text, comp. input_len);1768 png_write_chunk_data(png_ptr, (png_const_bytep)text, comp.output_len); 1769 1769 1770 1770 png_write_chunk_end(png_ptr); … … 1962 1962 int usr_pixel_depth; 1963 1963 1964 #ifdef PNG_WRITE_FILTER_SUPPORTED 1965 png_byte filters; 1966 #endif 1967 1964 1968 png_debug(1, "in png_write_start_row"); 1965 1969 … … 1972 1976 1973 1977 /* Set up row buffer */ 1974 png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, buf_size);1978 png_ptr->row_buf = png_voidcast(png_bytep, png_malloc(png_ptr, buf_size)); 1975 1979 1976 1980 png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE; 1977 1981 1978 1982 #ifdef PNG_WRITE_FILTER_SUPPORTED 1979 /* Set up filtering buffer, if using this filter */ 1980 if (png_ptr->do_filter & PNG_FILTER_SUB) 1981 { 1982 png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, png_ptr->rowbytes + 1); 1983 1984 png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB; 1985 } 1986 1987 /* We only need to keep the previous row if we are using one of these. */ 1988 if ((png_ptr->do_filter & 1989 (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) != 0) 1990 { 1991 /* Set up previous row buffer */ 1992 png_ptr->prev_row = (png_bytep)png_calloc(png_ptr, buf_size); 1993 1994 if ((png_ptr->do_filter & PNG_FILTER_UP) != 0) 1995 { 1996 png_ptr->up_row = (png_bytep)png_malloc(png_ptr, 1997 png_ptr->rowbytes + 1); 1998 1999 png_ptr->up_row[0] = PNG_FILTER_VALUE_UP; 2000 } 2001 2002 if ((png_ptr->do_filter & PNG_FILTER_AVG) != 0) 2003 { 2004 png_ptr->avg_row = (png_bytep)png_malloc(png_ptr, 2005 png_ptr->rowbytes + 1); 2006 2007 png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG; 2008 } 2009 2010 if ((png_ptr->do_filter & PNG_FILTER_PAETH) != 0) 2011 { 2012 png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr, 2013 png_ptr->rowbytes + 1); 2014 2015 png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH; 2016 } 2017 } 1983 filters = png_ptr->do_filter; 1984 1985 if (png_ptr->height == 1) 1986 filters &= 0xff & ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH); 1987 1988 if (png_ptr->width == 1) 1989 filters &= 0xff & ~(PNG_FILTER_SUB|PNG_FILTER_AVG|PNG_FILTER_PAETH); 1990 1991 if (filters == 0) 1992 filters = PNG_FILTER_NONE; 1993 1994 png_ptr->do_filter = filters; 1995 1996 if (((filters & (PNG_FILTER_SUB | PNG_FILTER_UP | PNG_FILTER_AVG | 1997 PNG_FILTER_PAETH)) != 0) && png_ptr->try_row == NULL) 1998 { 1999 int num_filters = 0; 2000 2001 png_ptr->try_row = png_voidcast(png_bytep, png_malloc(png_ptr, buf_size)); 2002 2003 if (filters & PNG_FILTER_SUB) 2004 num_filters++; 2005 2006 if (filters & PNG_FILTER_UP) 2007 num_filters++; 2008 2009 if (filters & PNG_FILTER_AVG) 2010 num_filters++; 2011 2012 if (filters & PNG_FILTER_PAETH) 2013 num_filters++; 2014 2015 if (num_filters > 1) 2016 png_ptr->tst_row = png_voidcast(png_bytep, png_malloc(png_ptr, 2017 buf_size)); 2018 } 2019 2020 /* We only need to keep the previous row if we are using one of the following 2021 * filters. 2022 */ 2023 if ((filters & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) != 0) 2024 png_ptr->prev_row = png_voidcast(png_bytep, 2025 png_calloc(png_ptr, buf_size)); 2018 2026 #endif /* WRITE_FILTER */ 2019 2027 … … 2161 2169 png_bytep sp; 2162 2170 png_bytep dp; 2163 int shift;2171 unsigned int shift; 2164 2172 int d; 2165 2173 int value; … … 2199 2207 png_bytep sp; 2200 2208 png_bytep dp; 2201 int shift;2209 unsigned int shift; 2202 2210 int d; 2203 2211 int value; … … 2236 2244 png_bytep sp; 2237 2245 png_bytep dp; 2238 int shift;2246 unsigned int shift; 2239 2247 int d; 2240 2248 int value; … … 2311 2319 #endif 2312 2320 2321 2313 2322 /* This filters the row, chooses which filter to use, if it has not already 2314 2323 * been specified by the application, and then writes the row out with the 2315 2324 * chosen filter. 2316 2325 */ 2317 static void 2326 static void /* PRIVATE */ 2318 2327 png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row, 2319 2328 png_size_t row_bytes); 2320 2329 2321 #define PNG_MAXSUM (((png_uint_32)(-1)) >> 1) 2322 #define PNG_HISHIFT 10 2323 #define PNG_LOMASK ((png_uint_32)0xffffL) 2324 #define PNG_HIMASK ((png_uint_32)(~PNG_LOMASK >> PNG_HISHIFT)) 2330 #ifdef PNG_WRITE_FILTER_SUPPORTED 2331 static png_size_t /* PRIVATE */ 2332 png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp, 2333 const png_size_t row_bytes, const png_size_t lmins) 2334 { 2335 png_bytep rp, dp, lp; 2336 png_size_t i; 2337 png_size_t sum = 0; 2338 int v; 2339 2340 png_ptr->try_row[0] = PNG_FILTER_VALUE_SUB; 2341 2342 for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1; i < bpp; 2343 i++, rp++, dp++) 2344 { 2345 v = *dp = *rp; 2346 sum += (v < 128) ? v : 256 - v; 2347 } 2348 2349 for (lp = png_ptr->row_buf + 1; i < row_bytes; 2350 i++, rp++, lp++, dp++) 2351 { 2352 v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff); 2353 sum += (v < 128) ? v : 256 - v; 2354 2355 if (sum > lmins) /* We are already worse, don't continue. */ 2356 break; 2357 } 2358 2359 return (sum); 2360 } 2361 2362 static png_size_t /* PRIVATE */ 2363 png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes, 2364 const png_size_t lmins) 2365 { 2366 png_bytep rp, dp, pp; 2367 png_size_t i; 2368 png_size_t sum = 0; 2369 int v; 2370 2371 png_ptr->try_row[0] = PNG_FILTER_VALUE_UP; 2372 2373 for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, 2374 pp = png_ptr->prev_row + 1; i < row_bytes; 2375 i++, rp++, pp++, dp++) 2376 { 2377 v = *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff); 2378 sum += (v < 128) ? v : 256 - v; 2379 2380 if (sum > lmins) /* We are already worse, don't continue. */ 2381 break; 2382 } 2383 2384 return (sum); 2385 } 2386 2387 static png_size_t /* PRIVATE */ 2388 png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp, 2389 const png_size_t row_bytes, const png_size_t lmins) 2390 { 2391 png_bytep rp, dp, pp, lp; 2392 png_uint_32 i; 2393 png_size_t sum = 0; 2394 int v; 2395 2396 png_ptr->try_row[0] = PNG_FILTER_VALUE_AVG; 2397 2398 for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, 2399 pp = png_ptr->prev_row + 1; i < bpp; i++) 2400 { 2401 v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff); 2402 2403 sum += (v < 128) ? v : 256 - v; 2404 } 2405 2406 for (lp = png_ptr->row_buf + 1; i < row_bytes; i++) 2407 { 2408 v = *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) 2409 & 0xff); 2410 2411 sum += (v < 128) ? v : 256 - v; 2412 2413 if (sum > lmins) /* We are already worse, don't continue. */ 2414 break; 2415 } 2416 2417 return (sum); 2418 } 2419 2420 static png_size_t /* PRIVATE */ 2421 png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp, 2422 const png_size_t row_bytes, const png_size_t lmins) 2423 { 2424 png_bytep rp, dp, pp, cp, lp; 2425 png_size_t i; 2426 png_size_t sum = 0; 2427 int v; 2428 2429 png_ptr->try_row[0] = PNG_FILTER_VALUE_PAETH; 2430 2431 for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, 2432 pp = png_ptr->prev_row + 1; i < bpp; i++) 2433 { 2434 v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); 2435 2436 sum += (v < 128) ? v : 256 - v; 2437 } 2438 2439 for (lp = png_ptr->row_buf + 1, cp = png_ptr->prev_row + 1; i < row_bytes; 2440 i++) 2441 { 2442 int a, b, c, pa, pb, pc, p; 2443 2444 b = *pp++; 2445 c = *cp++; 2446 a = *lp++; 2447 2448 p = b - c; 2449 pc = a - c; 2450 2451 #ifdef PNG_USE_ABS 2452 pa = abs(p); 2453 pb = abs(pc); 2454 pc = abs(p + pc); 2455 #else 2456 pa = p < 0 ? -p : p; 2457 pb = pc < 0 ? -pc : pc; 2458 pc = (p + pc) < 0 ? -(p + pc) : p + pc; 2459 #endif 2460 2461 p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; 2462 2463 v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff); 2464 2465 sum += (v < 128) ? v : 256 - v; 2466 2467 if (sum > lmins) /* We are already worse, don't continue. */ 2468 break; 2469 } 2470 2471 return (sum); 2472 } 2473 #endif /* WRITE_FILTER */ 2474 2325 2475 void /* PRIVATE */ 2326 2476 png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) 2327 2477 { 2478 #ifndef PNG_WRITE_FILTER_SUPPORTED 2479 png_write_filtered_row(png_ptr, png_ptr->row_buf, row_info->rowbytes+1); 2480 #else 2481 png_byte filter_to_do = png_ptr->do_filter; 2482 png_bytep row_buf; 2328 2483 png_bytep best_row; 2329 #ifdef PNG_WRITE_FILTER_SUPPORTED 2330 png_bytep prev_row, row_buf; 2331 png_uint_32 mins, bpp; 2332 png_byte filter_to_do = png_ptr->do_filter; 2484 png_uint_32 bpp; 2485 png_size_t mins; 2333 2486 png_size_t row_bytes = row_info->rowbytes; 2334 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED2335 int num_p_filters = png_ptr->num_prev_filters;2336 #endif2337 2487 2338 2488 png_debug(1, "in png_write_find_filter"); 2339 2340 #ifndef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED2341 if (png_ptr->row_number == 0 && filter_to_do == PNG_ALL_FILTERS)2342 {2343 /* These will never be selected so we need not test them. */2344 filter_to_do &= ~(PNG_FILTER_UP | PNG_FILTER_PAETH);2345 }2346 #endif2347 2489 2348 2490 /* Find out how many bytes offset each pixel is */ 2349 2491 bpp = (row_info->pixel_depth + 7) >> 3; 2350 2492 2351 prev_row = png_ptr->prev_row; 2352 #endif 2353 best_row = png_ptr->row_buf; 2354 #ifdef PNG_WRITE_FILTER_SUPPORTED 2355 row_buf = best_row; 2356 mins = PNG_MAXSUM; 2493 row_buf = png_ptr->row_buf; 2494 mins = PNG_SIZE_MAX - 256/* so we can detect potential overflow of the 2495 running sum */; 2357 2496 2358 2497 /* The prediction method we use is to find which method provides the … … 2384 2523 * that has been chosen, as it doesn't actually do anything to the data. 2385 2524 */ 2525 best_row = png_ptr->row_buf; 2526 2527 2386 2528 if ((filter_to_do & PNG_FILTER_NONE) != 0 && filter_to_do != PNG_FILTER_NONE) 2387 2529 { 2388 2530 png_bytep rp; 2389 png_ uint_32sum = 0;2531 png_size_t sum = 0; 2390 2532 png_size_t i; 2391 2533 int v; 2392 2534 2393 for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++) 2394 { 2395 v = *rp; 2396 sum += (v < 128) ? v : 256 - v; 2397 } 2398 2399 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 2400 if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) 2401 { 2402 png_uint_32 sumhi, sumlo; 2403 int j; 2404 sumlo = sum & PNG_LOMASK; 2405 sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; /* Gives us some footroom */ 2406 2407 /* Reduce the sum if we match any of the previous rows */ 2408 for (j = 0; j < num_p_filters; j++) 2535 if (PNG_SIZE_MAX/128 <= row_bytes) 2536 { 2537 for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++) 2409 2538 { 2410 if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE) 2411 { 2412 sumlo = (sumlo * png_ptr->filter_weights[j]) >> 2413 PNG_WEIGHT_SHIFT; 2414 2415 sumhi = (sumhi * png_ptr->filter_weights[j]) >> 2416 PNG_WEIGHT_SHIFT; 2417 } 2539 /* Check for overflow */ 2540 if (sum > PNG_SIZE_MAX/128 - 256) 2541 break; 2542 2543 v = *rp; 2544 sum += (v < 128) ? v : 256 - v; 2418 2545 } 2419 2420 /* Factor in the cost of this filter (this is here for completeness, 2421 * but it makes no sense to have a "cost" for the NONE filter, as 2422 * it has the minimum possible computational cost - none). 2423 */ 2424 sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >> 2425 PNG_COST_SHIFT; 2426 2427 sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >> 2428 PNG_COST_SHIFT; 2429 2430 if (sumhi > PNG_HIMASK) 2431 sum = PNG_MAXSUM; 2432 2433 else 2434 sum = (sumhi << PNG_HISHIFT) + sumlo; 2435 } 2436 #endif 2546 } 2547 else /* Overflow is not possible */ 2548 { 2549 for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++) 2550 { 2551 v = *rp; 2552 sum += (v < 128) ? v : 256 - v; 2553 } 2554 } 2555 2437 2556 mins = sum; 2438 2557 } … … 2442 2561 /* It's the only filter so no testing is needed */ 2443 2562 { 2444 png_bytep rp, lp, dp; 2445 png_size_t i; 2446 2447 for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp; 2448 i++, rp++, dp++) 2449 { 2450 *dp = *rp; 2451 } 2452 2453 for (lp = row_buf + 1; i < row_bytes; 2454 i++, rp++, lp++, dp++) 2455 { 2456 *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff); 2457 } 2458 2459 best_row = png_ptr->sub_row; 2563 (void) png_setup_sub_row(png_ptr, bpp, row_bytes, mins); 2564 best_row = png_ptr->try_row; 2460 2565 } 2461 2566 2462 2567 else if ((filter_to_do & PNG_FILTER_SUB) != 0) 2463 2568 { 2464 png_bytep rp, dp, lp; 2465 png_uint_32 sum = 0, lmins = mins; 2466 png_size_t i; 2467 int v; 2468 2469 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 2470 /* We temporarily increase the "minimum sum" by the factor we 2471 * would reduce the sum of this filter, so that we can do the 2472 * early exit comparison without scaling the sum each time. 2473 */ 2474 if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) 2475 { 2476 int j; 2477 png_uint_32 lmhi, lmlo; 2478 lmlo = lmins & PNG_LOMASK; 2479 lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; 2480 2481 for (j = 0; j < num_p_filters; j++) 2569 png_size_t sum; 2570 png_size_t lmins = mins; 2571 2572 sum = png_setup_sub_row(png_ptr, bpp, row_bytes, lmins); 2573 2574 if (sum < mins) 2575 { 2576 mins = sum; 2577 best_row = png_ptr->try_row; 2578 if (png_ptr->tst_row != NULL) 2482 2579 { 2483 if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB) 2484 { 2485 lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> 2486 PNG_WEIGHT_SHIFT; 2487 2488 lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> 2489 PNG_WEIGHT_SHIFT; 2490 } 2580 png_ptr->try_row = png_ptr->tst_row; 2581 png_ptr->tst_row = best_row; 2491 2582 } 2492 2493 lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >>2494 PNG_COST_SHIFT;2495 2496 lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >>2497 PNG_COST_SHIFT;2498 2499 if (lmhi > PNG_HIMASK)2500 lmins = PNG_MAXSUM;2501 2502 else2503 lmins = (lmhi << PNG_HISHIFT) + lmlo;2504 }2505 #endif2506 2507 for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp;2508 i++, rp++, dp++)2509 {2510 v = *dp = *rp;2511 2512 sum += (v < 128) ? v : 256 - v;2513 }2514 2515 for (lp = row_buf + 1; i < row_bytes;2516 i++, rp++, lp++, dp++)2517 {2518 v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);2519 2520 sum += (v < 128) ? v : 256 - v;2521 2522 if (sum > lmins) /* We are already worse, don't continue. */2523 break;2524 }2525 2526 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED2527 if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)2528 {2529 int j;2530 png_uint_32 sumhi, sumlo;2531 sumlo = sum & PNG_LOMASK;2532 sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;2533 2534 for (j = 0; j < num_p_filters; j++)2535 {2536 if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB)2537 {2538 sumlo = (sumlo * png_ptr->inv_filter_weights[j]) >>2539 PNG_WEIGHT_SHIFT;2540 2541 sumhi = (sumhi * png_ptr->inv_filter_weights[j]) >>2542 PNG_WEIGHT_SHIFT;2543 }2544 }2545 2546 sumlo = (sumlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >>2547 PNG_COST_SHIFT;2548 2549 sumhi = (sumhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >>2550 PNG_COST_SHIFT;2551 2552 if (sumhi > PNG_HIMASK)2553 sum = PNG_MAXSUM;2554 2555 else2556 sum = (sumhi << PNG_HISHIFT) + sumlo;2557 }2558 #endif2559 2560 if (sum < mins)2561 {2562 mins = sum;2563 best_row = png_ptr->sub_row;2564 2583 } 2565 2584 } … … 2568 2587 if (filter_to_do == PNG_FILTER_UP) 2569 2588 { 2570 png_bytep rp, dp, pp; 2571 png_size_t i; 2572 2573 for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1, 2574 pp = prev_row + 1; i < row_bytes; 2575 i++, rp++, pp++, dp++) 2576 { 2577 *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff); 2578 } 2579 2580 best_row = png_ptr->up_row; 2589 (void) png_setup_up_row(png_ptr, row_bytes, mins); 2590 best_row = png_ptr->try_row; 2581 2591 } 2582 2592 2583 2593 else if ((filter_to_do & PNG_FILTER_UP) != 0) 2584 2594 { 2585 png_bytep rp, dp, pp; 2586 png_uint_32 sum = 0, lmins = mins; 2587 png_size_t i; 2588 int v; 2589 2590 2591 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 2592 if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) 2593 { 2594 int j; 2595 png_uint_32 lmhi, lmlo; 2596 lmlo = lmins & PNG_LOMASK; 2597 lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; 2598 2599 for (j = 0; j < num_p_filters; j++) 2595 png_size_t sum; 2596 png_size_t lmins = mins; 2597 2598 sum = png_setup_up_row(png_ptr, row_bytes, lmins); 2599 2600 if (sum < mins) 2601 { 2602 mins = sum; 2603 best_row = png_ptr->try_row; 2604 if (png_ptr->tst_row != NULL) 2600 2605 { 2601 if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP) 2602 { 2603 lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> 2604 PNG_WEIGHT_SHIFT; 2605 2606 lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> 2607 PNG_WEIGHT_SHIFT; 2608 } 2606 png_ptr->try_row = png_ptr->tst_row; 2607 png_ptr->tst_row = best_row; 2609 2608 } 2610 2611 lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >>2612 PNG_COST_SHIFT;2613 2614 lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >>2615 PNG_COST_SHIFT;2616 2617 if (lmhi > PNG_HIMASK)2618 lmins = PNG_MAXSUM;2619 2620 else2621 lmins = (lmhi << PNG_HISHIFT) + lmlo;2622 }2623 #endif2624 2625 for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1,2626 pp = prev_row + 1; i < row_bytes; i++)2627 {2628 v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);2629 2630 sum += (v < 128) ? v : 256 - v;2631 2632 if (sum > lmins) /* We are already worse, don't continue. */2633 break;2634 }2635 2636 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED2637 if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)2638 {2639 int j;2640 png_uint_32 sumhi, sumlo;2641 sumlo = sum & PNG_LOMASK;2642 sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;2643 2644 for (j = 0; j < num_p_filters; j++)2645 {2646 if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP)2647 {2648 sumlo = (sumlo * png_ptr->filter_weights[j]) >>2649 PNG_WEIGHT_SHIFT;2650 2651 sumhi = (sumhi * png_ptr->filter_weights[j]) >>2652 PNG_WEIGHT_SHIFT;2653 }2654 }2655 2656 sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >>2657 PNG_COST_SHIFT;2658 2659 sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >>2660 PNG_COST_SHIFT;2661 2662 if (sumhi > PNG_HIMASK)2663 sum = PNG_MAXSUM;2664 2665 else2666 sum = (sumhi << PNG_HISHIFT) + sumlo;2667 }2668 #endif2669 2670 if (sum < mins)2671 {2672 mins = sum;2673 best_row = png_ptr->up_row;2674 2609 } 2675 2610 } … … 2678 2613 if (filter_to_do == PNG_FILTER_AVG) 2679 2614 { 2680 png_bytep rp, dp, pp, lp; 2681 png_uint_32 i; 2682 2683 for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1, 2684 pp = prev_row + 1; i < bpp; i++) 2685 { 2686 *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff); 2687 } 2688 2689 for (lp = row_buf + 1; i < row_bytes; i++) 2690 { 2691 *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) 2692 & 0xff); 2693 } 2694 best_row = png_ptr->avg_row; 2615 (void) png_setup_avg_row(png_ptr, bpp, row_bytes, mins); 2616 best_row = png_ptr->try_row; 2695 2617 } 2696 2618 2697 2619 else if ((filter_to_do & PNG_FILTER_AVG) != 0) 2698 2620 { 2699 png_bytep rp, dp, pp, lp; 2700 png_uint_32 sum = 0, lmins = mins; 2701 png_size_t i; 2702 int v; 2703 2704 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 2705 if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) 2706 { 2707 int j; 2708 png_uint_32 lmhi, lmlo; 2709 lmlo = lmins & PNG_LOMASK; 2710 lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; 2711 2712 for (j = 0; j < num_p_filters; j++) 2621 png_size_t sum; 2622 png_size_t lmins = mins; 2623 2624 sum= png_setup_avg_row(png_ptr, bpp, row_bytes, lmins); 2625 2626 if (sum < mins) 2627 { 2628 mins = sum; 2629 best_row = png_ptr->try_row; 2630 if (png_ptr->tst_row != NULL) 2713 2631 { 2714 if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_AVG) 2715 { 2716 lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> 2717 PNG_WEIGHT_SHIFT; 2718 2719 lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> 2720 PNG_WEIGHT_SHIFT; 2721 } 2632 png_ptr->try_row = png_ptr->tst_row; 2633 png_ptr->tst_row = best_row; 2722 2634 } 2723 2724 lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >>2725 PNG_COST_SHIFT;2726 2727 lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >>2728 PNG_COST_SHIFT;2729 2730 if (lmhi > PNG_HIMASK)2731 lmins = PNG_MAXSUM;2732 2733 else2734 lmins = (lmhi << PNG_HISHIFT) + lmlo;2735 }2736 #endif2737 2738 for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1,2739 pp = prev_row + 1; i < bpp; i++)2740 {2741 v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);2742 2743 sum += (v < 128) ? v : 256 - v;2744 }2745 2746 for (lp = row_buf + 1; i < row_bytes; i++)2747 {2748 v = *dp++ =2749 (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) & 0xff);2750 2751 sum += (v < 128) ? v : 256 - v;2752 2753 if (sum > lmins) /* We are already worse, don't continue. */2754 break;2755 }2756 2757 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED2758 if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)2759 {2760 int j;2761 png_uint_32 sumhi, sumlo;2762 sumlo = sum & PNG_LOMASK;2763 sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;2764 2765 for (j = 0; j < num_p_filters; j++)2766 {2767 if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE)2768 {2769 sumlo = (sumlo * png_ptr->filter_weights[j]) >>2770 PNG_WEIGHT_SHIFT;2771 2772 sumhi = (sumhi * png_ptr->filter_weights[j]) >>2773 PNG_WEIGHT_SHIFT;2774 }2775 }2776 2777 sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >>2778 PNG_COST_SHIFT;2779 2780 sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >>2781 PNG_COST_SHIFT;2782 2783 if (sumhi > PNG_HIMASK)2784 sum = PNG_MAXSUM;2785 2786 else2787 sum = (sumhi << PNG_HISHIFT) + sumlo;2788 }2789 #endif2790 2791 if (sum < mins)2792 {2793 mins = sum;2794 best_row = png_ptr->avg_row;2795 2635 } 2796 2636 } … … 2799 2639 if ((filter_to_do == PNG_FILTER_PAETH) != 0) 2800 2640 { 2801 png_bytep rp, dp, pp, cp, lp; 2802 png_size_t i; 2803 2804 for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1, 2805 pp = prev_row + 1; i < bpp; i++) 2806 { 2807 *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); 2808 } 2809 2810 for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++) 2811 { 2812 int a, b, c, pa, pb, pc, p; 2813 2814 b = *pp++; 2815 c = *cp++; 2816 a = *lp++; 2817 2818 p = b - c; 2819 pc = a - c; 2820 2821 #ifdef PNG_USE_ABS 2822 pa = abs(p); 2823 pb = abs(pc); 2824 pc = abs(p + pc); 2825 #else 2826 pa = p < 0 ? -p : p; 2827 pb = pc < 0 ? -pc : pc; 2828 pc = (p + pc) < 0 ? -(p + pc) : p + pc; 2829 #endif 2830 2831 p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; 2832 2833 *dp++ = (png_byte)(((int)*rp++ - p) & 0xff); 2834 } 2835 best_row = png_ptr->paeth_row; 2641 (void) png_setup_paeth_row(png_ptr, bpp, row_bytes, mins); 2642 best_row = png_ptr->try_row; 2836 2643 } 2837 2644 2838 2645 else if ((filter_to_do & PNG_FILTER_PAETH) != 0) 2839 2646 { 2840 png_bytep rp, dp, pp, cp, lp; 2841 png_uint_32 sum = 0, lmins = mins; 2842 png_size_t i; 2843 int v; 2844 2845 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 2846 if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) 2847 { 2848 int j; 2849 png_uint_32 lmhi, lmlo; 2850 lmlo = lmins & PNG_LOMASK; 2851 lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK; 2852 2853 for (j = 0; j < num_p_filters; j++) 2647 png_size_t sum; 2648 png_size_t lmins = mins; 2649 2650 sum = png_setup_paeth_row(png_ptr, bpp, row_bytes, lmins); 2651 2652 if (sum < mins) 2653 { 2654 mins = sum; 2655 best_row = png_ptr->try_row; 2656 if (png_ptr->tst_row != NULL) 2854 2657 { 2855 if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH) 2856 { 2857 lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >> 2858 PNG_WEIGHT_SHIFT; 2859 2860 lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >> 2861 PNG_WEIGHT_SHIFT; 2862 } 2658 png_ptr->try_row = png_ptr->tst_row; 2659 png_ptr->tst_row = best_row; 2863 2660 } 2864 2865 lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >> 2866 PNG_COST_SHIFT; 2867 2868 lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >> 2869 PNG_COST_SHIFT; 2870 2871 if (lmhi > PNG_HIMASK) 2872 lmins = PNG_MAXSUM; 2873 2874 else 2875 lmins = (lmhi << PNG_HISHIFT) + lmlo; 2876 } 2877 #endif 2878 2879 for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1, 2880 pp = prev_row + 1; i < bpp; i++) 2881 { 2882 v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); 2883 2884 sum += (v < 128) ? v : 256 - v; 2885 } 2886 2887 for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++) 2888 { 2889 int a, b, c, pa, pb, pc, p; 2890 2891 b = *pp++; 2892 c = *cp++; 2893 a = *lp++; 2894 2895 #ifndef PNG_SLOW_PAETH 2896 p = b - c; 2897 pc = a - c; 2898 #ifdef PNG_USE_ABS 2899 pa = abs(p); 2900 pb = abs(pc); 2901 pc = abs(p + pc); 2902 #else 2903 pa = p < 0 ? -p : p; 2904 pb = pc < 0 ? -pc : pc; 2905 pc = (p + pc) < 0 ? -(p + pc) : p + pc; 2906 #endif 2907 p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; 2908 #else /* SLOW_PAETH */ 2909 p = a + b - c; 2910 pa = abs(p - a); 2911 pb = abs(p - b); 2912 pc = abs(p - c); 2913 2914 if (pa <= pb && pa <= pc) 2915 p = a; 2916 2917 else if (pb <= pc) 2918 p = b; 2919 2920 else 2921 p = c; 2922 #endif /* SLOW_PAETH */ 2923 2924 v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff); 2925 2926 sum += (v < 128) ? v : 256 - v; 2927 2928 if (sum > lmins) /* We are already worse, don't continue. */ 2929 break; 2930 } 2931 2932 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 2933 if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED) 2934 { 2935 int j; 2936 png_uint_32 sumhi, sumlo; 2937 sumlo = sum & PNG_LOMASK; 2938 sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; 2939 2940 for (j = 0; j < num_p_filters; j++) 2941 { 2942 if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH) 2943 { 2944 sumlo = (sumlo * png_ptr->filter_weights[j]) >> 2945 PNG_WEIGHT_SHIFT; 2946 2947 sumhi = (sumhi * png_ptr->filter_weights[j]) >> 2948 PNG_WEIGHT_SHIFT; 2949 } 2950 } 2951 2952 sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >> 2953 PNG_COST_SHIFT; 2954 2955 sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >> 2956 PNG_COST_SHIFT; 2957 2958 if (sumhi > PNG_HIMASK) 2959 sum = PNG_MAXSUM; 2960 2961 else 2962 sum = (sumhi << PNG_HISHIFT) + sumlo; 2963 } 2964 #endif 2965 2966 if (sum < mins) 2967 { 2968 best_row = png_ptr->paeth_row; 2969 } 2970 } 2971 #endif /* WRITE_FILTER */ 2661 } 2662 } 2972 2663 2973 2664 /* Do the actual writing of the filtered row data from the chosen filter. */ 2974 2665 png_write_filtered_row(png_ptr, best_row, row_info->rowbytes+1); 2975 2666 2976 #ifdef PNG_WRITE_FILTER_SUPPORTED2977 #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED2978 /* Save the type of filter we picked this time for future calculations */2979 if (png_ptr->num_prev_filters > 0)2980 {2981 int j;2982 2983 for (j = 1; j < num_p_filters; j++)2984 {2985 png_ptr->prev_filters[j] = png_ptr->prev_filters[j - 1];2986 }2987 2988 png_ptr->prev_filters[j] = best_row[0];2989 }2990 #endif2991 2667 #endif /* WRITE_FILTER */ 2992 2668 } … … 3004 2680 png_compress_IDAT(png_ptr, filtered_row, full_row_length, Z_NO_FLUSH); 3005 2681 2682 #ifdef PNG_WRITE_FILTER_SUPPORTED 3006 2683 /* Swap the current and previous rows */ 3007 2684 if (png_ptr->prev_row != NULL) … … 3013 2690 png_ptr->row_buf = tptr; 3014 2691 } 2692 #endif /* WRITE_FILTER */ 3015 2693 3016 2694 /* Finish row - updates counters and flushes zlib if last row */ -
TabularUnified libpng/vendor/current/projects/vstudio/readme.txt ¶
r1059 r1165 2 2 VisualStudio instructions 3 3 4 libpng version 1.6.1 6 - December 22, 20144 libpng version 1.6.18 - July 23, 2015 5 5 6 6 Copyright (c) 1998-2010 Glenn Randers-Pehrson -
TabularUnified libpng/vendor/current/projects/vstudio/zlib.props ¶
r1059 r1165 3 3 * zlib.props - location of zlib source 4 4 * 5 * libpng version 1.6.1 6 - December 22, 20145 * libpng version 1.6.18 - July 23, 2015 6 6 * 7 7 * Copyright (c) 1998-2011 Glenn Randers-Pehrson -
TabularUnified libpng/vendor/current/scripts/README.txt ¶
r1059 r1165 1 1 2 Makefiles for libpng version 1.6.1 6 - December 22, 20142 Makefiles for libpng version 1.6.18 - July 23, 2015 3 3 4 4 pnglibconf.h.prebuilt => Stores configuration settings 5 5 makefile.linux => Linux/ELF makefile 6 (gcc, creates libpng16.so.16.1.6.1 6)6 (gcc, creates libpng16.so.16.1.6.18) 7 7 makefile.gcc => Generic makefile (gcc, creates static libpng.a) 8 8 makefile.knr => Archaic UNIX Makefile that converts files with … … 34 34 makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc 35 35 makefile.sggcc => Silicon Graphics (gcc, 36 creates libpng16.so.16.1.6.1 6)36 creates libpng16.so.16.1.6.18) 37 37 makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib) 38 38 makefile.solaris => Solaris 2.X makefile (gcc, 39 creates libpng16.so.16.1.6.1 6)39 creates libpng16.so.16.1.6.18) 40 40 makefile.so9 => Solaris 9 makefile (gcc, 41 creates libpng16.so.16.1.6.1 6)41 creates libpng16.so.16.1.6.18) 42 42 makefile.std => Generic UNIX makefile (cc, creates static libpng.a) 43 43 makefile.sunos => Sun makefile -
TabularUnified libpng/vendor/current/scripts/def.c ¶
r1059 r1165 22 22 PNG_DFN "" 23 23 PNG_DFN "EXPORTS" 24 PNG_DFN ";Version 1.6.1 6"24 PNG_DFN ";Version 1.6.18" 25 25 26 26 #define PNG_EXPORTA(ordinal, type, name, args, attributes)\ -
TabularUnified libpng/vendor/current/scripts/dfn.awk ¶
r922 r1165 18 18 out="/dev/null" # as a flag 19 19 out_count=0 # count of output lines 20 err=0 # set if an error occur ed20 err=0 # set if an error occurred 21 21 sort=0 # sort the output 22 22 array[""]="" -
TabularUnified libpng/vendor/current/scripts/libpng-config-head.in ¶
r1059 r1165 12 12 # Modeled after libxml-config. 13 13 14 version=1.6.1 614 version=1.6.18 15 15 prefix="" 16 16 libdir="" -
TabularUnified libpng/vendor/current/scripts/libpng.pc.in ¶
r1059 r1165 6 6 Name: libpng 7 7 Description: Loads and saves PNG files 8 Version: 1.6.1 68 Version: 1.6.18 9 9 Libs: -L${libdir} -lpng16 10 10 Cflags: -I${includedir} -
TabularUnified libpng/vendor/current/scripts/makefile.cegcc ¶
r1059 r1165 24 24 VERMAJ = 1 25 25 VERMIN = 6 26 VERMIC = 1 626 VERMIC = 18 27 27 VER = $(VERMAJ).$(VERMIN).$(VERMIC) 28 28 NAME = libpng -
TabularUnified libpng/vendor/current/scripts/makefile.linux ¶
r1059 r1165 11 11 LIBNAME = libpng16 12 12 PNGMAJ = 16 13 RELEASE = 1 613 RELEASE = 18 14 14 15 15 # Shared library names: -
TabularUnified libpng/vendor/current/scripts/makefile.msys ¶
r1059 r1165 19 19 LIBNAME = libpng16 20 20 PNGMAJ = 16 21 RELEASE = 1 621 RELEASE = 18 22 22 23 23 # Shared library names: -
TabularUnified libpng/vendor/current/scripts/makefile.ne12bsd ¶
r1059 r1165 18 18 LIB= png16 19 19 SHLIB_MAJOR= 0 20 SHLIB_MINOR= 1.6.1 620 SHLIB_MINOR= 1.6.18 21 21 SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ 22 22 pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ -
TabularUnified libpng/vendor/current/scripts/makefile.netbsd ¶
r1059 r1165 18 18 LIB= png 19 19 SHLIB_MAJOR= 16 20 SHLIB_MINOR= 1.6.1 620 SHLIB_MINOR= 1.6.18 21 21 SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ 22 22 pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ -
TabularUnified libpng/vendor/current/scripts/makefile.openbsd ¶
r1059 r1165 12 12 13 13 SHLIB_MAJOR= 16 14 SHLIB_MINOR= 1.6.1 614 SHLIB_MINOR= 1.6.18 15 15 16 16 LIB= png -
TabularUnified libpng/vendor/current/scripts/makefile.std ¶
r922 r1165 107 107 108 108 clean: 109 $(RM_F) *.o libpng.a pngtest pngout.png pnglibconf.* 109 $(RM_F) *.o libpng.a pngtest pngout.png pnglibconf.h pnglibconf.c \ 110 pnglibconf.out 110 111 111 112 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO -
TabularUnified libpng/vendor/current/scripts/pnglibconf.dfa ¶
r1059 r1165 223 223 # ARM_NEON_CHECK: (PNG_ARM_NEON == 1) compile a run-time check to see if Neon 224 224 # extensions are supported. This is poorly supported and 225 # deprec tated - use the png_set_option API.225 # deprecated - use the png_set_option API. 226 226 setting ARM_NEON_OPT 227 227 option ARM_NEON_API disabled requires ALIGNED_MEMORY enables SET_OPTION, … … 249 249 setting Z_DEFAULT_NOFILTER_STRATEGY default @Z_DEFAULT_STRATEGY 250 250 setting ZLIB_VERNUM default @ZLIB_VERNUM 251 252 # Linkage of: 253 # 254 # API: libpng API functions 255 # CALLBACK: internal non-file-local callbacks 256 # FUNCTION: internal non-file-local functions 257 # DATA: internal non-file-local (const) data 258 setting LINKAGE_API default extern 259 setting LINKAGE_CALLBACK default extern 260 setting LINKAGE_FUNCTION default extern 261 setting LINKAGE_DATA default extern 251 262 252 263 setting TEXT_Z_DEFAULT_COMPRESSION default @Z_DEFAULT_COMPRESSION … … 351 362 option IO_STATE 352 363 353 # This is only for PowerPC big-endian and 680x0 systems 354 # some testing, not enabled by default. 355 # NO LONGER USED 356 357 #option READ_BIG_ENDIAN disabled 358 359 # Allow users to control limits on what the READ code will 360 # read: 361 362 # Added at libpng-1.2.43; adds limit fields to png_struct, 363 # allows some usages of these fields 364 365 option USER_LIMITS 366 367 # Added at libpng-1.2.6; adds setting APIs, allows additional 368 # usage of this field (UTSL) 369 370 option SET_USER_LIMITS requires USER_LIMITS 371 372 # Feature added at libpng-1.4.0, this flag added at 1.4.1 373 option SET_USER_LIMITS enables SET_CHUNK_CACHE_LIMIT 374 # Feature added at libpng-1.4.1, this flag added at 1.4.1 375 376 option SET_USER_LIMITS enables SET_CHUNK_MALLOC_LIMIT 377 378 # Libpng limits. 379 # 380 # If these settings are *not* set libpng will not limit the size of 381 # images or the size of data in ancilliary chunks. This does lead to 382 # security issues if PNG files come from untrusted sources. Settings have the 364 # Libpng limits: limit the size of images and data on read. 365 # 366 # If this option is disabled all the limit checking code will be disabled: 367 368 option USER_LIMITS requires READ 369 370 # The default settings given below for the limits mean that libpng will 371 # limit the size of images or the size of data in ancilliary chunks to less 372 # than the specification or implementation limits. Settings have the 383 373 # following interpretations: 384 374 # … … 389 379 # 390 380 # Only chunks that are variable in number are counted towards the 391 # USER_CHUNK_CACHE_MAX limit 392 setting USER_WIDTH_MAX 393 setting USER_ HEIGHT_MAX394 setting USER_ CHUNK_CACHE_MAX395 setting USER_CHUNK_MALLOC_MAX 396 397 # To default all these settings to values that are large but probably 398 # safe turn the SAFE_LIMITS option on; this will cause the value in 399 # pngpriv.h to be used. Individual values can also be set, simply set 400 # them in pngusr.dfa with '@#define PNG_setting value' lines.401 option SAFE_LIMITS enables USER_LIMITS disabled 402 = SAFE_LIMITS SAFE_LIMITS381 382 # Use 0x7fffffff for unlimited 383 setting USER_WIDTH_MAX default 1000000 384 setting USER_HEIGHT_MAX default 1000000 385 386 # Use 0 for unlimited 387 setting USER_CHUNK_CACHE_MAX default 1000 388 setting USER_CHUNK_MALLOC_MAX default 8000000 389 390 # If this option is enabled APIs to set the above limits at run time are added; 391 # without this the hardwired (compile time) limits will be used. 392 option SET_USER_LIMITS requires USER_LIMITS 403 393 404 394 # All of the following options relate to code capabilities for … … 542 532 # was added at libpng-1.5.3. 543 533 option WRITE_CUSTOMIZE_ZTXT_COMPRESSION requires WRITE 534 option WRITE_CUSTOMIZE_COMPRESSION requires WRITE 544 535 545 536 # Any chunks you are not interested in, you can undef here. The … … 667 658 # results in more memory being used, and more pow() functions 668 659 # being called to fill in the gamma tables. Don't set this value 669 # less th en 8, and even that may not work (I haven't tested it).660 # less than 8, and even that may not work (I haven't tested it). 670 661 671 662 setting MAX_GAMMA_8 default 11 -
TabularUnified libpng/vendor/current/scripts/pnglibconf.h.prebuilt ¶
r1059 r1165 1 /* libpng 1.6.1 6STANDARD API DEFINITION */1 /* libpng 1.6.18 STANDARD API DEFINITION */ 2 2 3 3 /* pnglibconf.h - library build configuration */ 4 4 5 /* Libpng version 1.6.1 6 - December 22, 2014*/5 /* Libpng version 1.6.18 - July 23, 2015 */ 6 6 7 7 /* Copyright (c) 1998-2014 Glenn Randers-Pehrson */ … … 98 98 #define PNG_READ_tRNS_SUPPORTED 99 99 #define PNG_READ_zTXt_SUPPORTED 100 /*#undef PNG_SAFE_LIMITS_SUPPORTED*/101 100 #define PNG_SAVE_INT_32_SUPPORTED 102 101 #define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED 103 102 #define PNG_SEQUENTIAL_READ_SUPPORTED 104 103 #define PNG_SETJMP_SUPPORTED 105 #define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED106 #define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED107 104 #define PNG_SET_OPTION_SUPPORTED 108 105 #define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED … … 130 127 #define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED 131 128 #define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED 129 #define PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED 132 130 #define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED 133 131 #define PNG_WRITE_FILLER_SUPPORTED … … 193 191 #define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE 194 192 #define PNG_INFLATE_BUF_SIZE 1024 193 #define PNG_LINKAGE_API extern 194 #define PNG_LINKAGE_CALLBACK extern 195 #define PNG_LINKAGE_DATA extern 196 #define PNG_LINKAGE_FUNCTION extern 195 197 #define PNG_MAX_GAMMA_8 11 196 198 #define PNG_QUANTIZE_BLUE_BITS 5 … … 199 201 #define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1) 200 202 #define PNG_TEXT_Z_DEFAULT_STRATEGY 0 203 #define PNG_USER_CHUNK_CACHE_MAX 1000 204 #define PNG_USER_CHUNK_MALLOC_MAX 8000000 205 #define PNG_USER_HEIGHT_MAX 1000000 206 #define PNG_USER_WIDTH_MAX 1000000 201 207 #define PNG_WEIGHT_SHIFT 8 202 208 #define PNG_ZBUF_SIZE 8192 -
TabularUnified libpng/vendor/current/scripts/pnglibconf.mak ¶
r922 r1165 50 50 51 51 clean-pnglibconf: 52 $(DELETE) pnglibconf.* 52 $(DELETE) pnglibconf.h pnglibconf.c pnglibconf.out pnglibconf.pre \ 53 pnglibconf.dfn 53 54 54 55 clean: clean-pnglibconf -
TabularUnified libpng/vendor/current/scripts/symbols.def ¶
r1059 r1165 1 ;Version 1.6.1 61 ;Version 1.6.18 2 2 ;-------------------------------------------------------------- 3 3 ; LIBPNG symbol list as a Win32 DEF file -
TabularUnified libpng/vendor/current/test-driver ¶
r922 r1165 4 4 scriptversion=2013-07-13.22; # UTC 5 5 6 # Copyright (C) 2011-201 3Free Software Foundation, Inc.6 # Copyright (C) 2011-2014 Free Software Foundation, Inc. 7 7 # 8 8 # This program is free software; you can redistribute it and/or modify … … 107 107 "$@" >$log_file 2>&1 108 108 estatus=$? 109 109 110 if test $enable_hard_errors = no && test $estatus -eq 99; then 110 estatus=1 111 tweaked_estatus=1 112 else 113 tweaked_estatus=$estatus 111 114 fi 112 115 113 case $ estatus:$expect_failure in116 case $tweaked_estatus:$expect_failure in 114 117 0:yes) col=$red res=XPASS recheck=yes gcopy=yes;; 115 118 0:*) col=$grn res=PASS recheck=no gcopy=no;; … … 119 122 *:*) col=$red res=FAIL recheck=yes gcopy=yes;; 120 123 esac 124 125 # Report the test outcome and exit status in the logs, so that one can 126 # know whether the test passed or failed simply by looking at the '.log' 127 # file, without the need of also peaking into the corresponding '.trs' 128 # file (automake bug#11814). 129 echo "$res $test_name (exit status: $estatus)" >>$log_file 121 130 122 131 # Report outcome to console.
Note:
See TracChangeset
for help on using the changeset viewer.