[libpng17]Rearranged png_struct, remove unused members, change png_set_filter

handling png_struct members rearranged - partly to reorder to avoid packing,
partly to put frequently accessed members at the start and partly to make
the grouping more clear. png_set_filter code has been rewritten and the
code shared with png_write_start_row moved to a common function.  Comments
in png.h have been made more clear. Minor fixes to
contrib/libtests/timepng.c and some of the png_*_tRNS logic, including
more error detection in png_set_tRNS.
This commit is contained in:
John Bowler 2012-12-14 22:31:50 -06:00 committed by Glenn Randers-Pehrson
parent 3e42c81193
commit 240ac287eb
11 changed files with 49 additions and 31 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.7.0alpha01 - December 10, 2012 Libpng 1.7.0alpha01 - December 15, 2012
This is not intended to be a public release. It will be replaced This is not intended to be a public release. It will be replaced
within a few weeks by a public version or by another test version. within a few weeks by a public version or by another test version.
@ -26,7 +26,7 @@ Other information:
Changes since the last public release (1.6.0): Changes since the last public release (1.6.0):
Version 1.7.0alpha01 [December 10, 2012] Version 1.7.0alpha01 [December 15, 2012]
Started 1.7.0 branch from libpng-1.6.0beta33. Started 1.7.0 branch from libpng-1.6.0beta33.
Made 8-bit compose and rgb_to_grayscale accuracy improvements. These Made 8-bit compose and rgb_to_grayscale accuracy improvements. These
changes cause 16-bit arithmetic to be used for 8-bit data in the gamma changes cause 16-bit arithmetic to be used for 8-bit data in the gamma
@ -45,6 +45,14 @@ Version 1.7.0alpha01 [December 10, 2012]
more calculations and the algorithm used to minimize the number of more calculations and the algorithm used to minimize the number of
calculations has been extended to all the 16-bit tables; it has advantages calculations has been extended to all the 16-bit tables; it has advantages
for any significant gamma correction. for any significant gamma correction.
Rearranged png_struct, remove unused members, change png_set_filter handling
png_struct members rearranged - partly to reorder to avoid packing, partly
to put frequently accessed members at the start and partly to make
the grouping more clear. png_set_filter code has been rewritten and the
code shared with png_write_start_row moved to a common function. Comments
in png.h have been made more clear. Minor fixes to
contrib/libtests/timepng.c and some of the png_*_tRNS logic, including
more error detection in png_set_tRNS.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit

10
CHANGES
View File

@ -4311,7 +4311,7 @@ Version 1.6.0beta33 [December 10, 2012]
fall-through condition. fall-through condition.
Change png_warning() to png_app_warning() in png_write_tRNS(). Change png_warning() to png_app_warning() in png_write_tRNS().
Version 1.7.0alpha01 [December 10, 2012] Version 1.7.0alpha01 [December 15, 2012]
Started 1.7.0 branch from libpng-1.6.0beta33. Started 1.7.0 branch from libpng-1.6.0beta33.
Made 8-bit compose and rgb_to_grayscale accuracy improvements. These Made 8-bit compose and rgb_to_grayscale accuracy improvements. These
changes cause 16-bit arithmetic to be used for 8-bit data in the gamma changes cause 16-bit arithmetic to be used for 8-bit data in the gamma
@ -4330,6 +4330,14 @@ Version 1.7.0alpha01 [December 10, 2012]
more calculations and the algorithm used to minimize the number of more calculations and the algorithm used to minimize the number of
calculations has been extended to all the 16-bit tables; it has advantages calculations has been extended to all the 16-bit tables; it has advantages
for any significant gamma correction. for any significant gamma correction.
Rearranged png_struct, remove unused members, change png_set_filter handling
png_struct members rearranged - partly to reorder to avoid packing, partly
to put frequently accessed members at the start and partly to make
the grouping more clear. png_set_filter code has been rewritten and the
code shared with png_write_start_row moved to a common function. Comments
in png.h have been made more clear. Minor fixes to
contrib/libtests/timepng.c and some of the png_*_tRNS logic, including
more error detection in png_set_tRNS.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit

View File

@ -252,7 +252,7 @@ int main(int argc, char **argv)
while (fgets(filename, FILENAME_MAX+1, stdin)) while (fgets(filename, FILENAME_MAX+1, stdin))
{ {
int len = strlen(filename); size_t len = strlen(filename);
if (filename[len-1] == '\n') if (filename[len-1] == '\n')
{ {

6
png.c
View File

@ -14,7 +14,7 @@
#include "pngpriv.h" #include "pngpriv.h"
/* Generate a compiler error if there is an old png.h in the search path. */ /* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_7_0alpha01 Your_png_h_is_not_version_1_7_0alpha01; typedef png_libpng_version_1_6_0beta32 Your_png_h_is_not_version_1_6_0beta32;
/* Tells libpng that we have already handled the first "num_bytes" bytes /* Tells libpng that we have already handled the first "num_bytes" bytes
* of the PNG file signature. If the PNG data is embedded into another * of the PNG file signature. If the PNG data is embedded into another
@ -744,13 +744,13 @@ png_get_copyright(png_const_structrp png_ptr)
#else #else
# ifdef __STDC__ # ifdef __STDC__
return PNG_STRING_NEWLINE \ return PNG_STRING_NEWLINE \
"libpng version 1.7.0alpha01 - December 10, 2012" PNG_STRING_NEWLINE \ "libpng version 1.6.0beta32 - November 25, 2012" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2012 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2012 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE; PNG_STRING_NEWLINE;
# else # else
return "libpng version 1.7.0alpha01 - December 10, 2012\ return "libpng version 1.6.0beta32 - November 25, 2012\
Copyright (c) 1998-2012 Glenn Randers-Pehrson\ Copyright (c) 1998-2012 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";

28
png.h
View File

@ -1,7 +1,7 @@
/* png.h - header file for PNG reference library /* png.h - header file for PNG reference library
* *
* libpng version 1.7.0alpha01 - December 10, 2012 * libpng version 1.6.0beta32 - November 25, 2012
* Copyright (c) 1998-2012 Glenn Randers-Pehrson * Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -11,7 +11,7 @@
* Authors and maintainers: * Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.7.0alpha01 - December 10, 2012: Glenn * libpng versions 0.97, January 1998, through 1.6.0beta32 - November 25, 2012: Glenn
* See also "Contributing Authors", below. * See also "Contributing Authors", below.
* *
* Note about libpng version numbers: * Note about libpng version numbers:
@ -198,7 +198,7 @@
* *
* This code is released under the libpng license. * This code is released under the libpng license.
* *
* libpng versions 1.2.6, August 15, 2004, through 1.7.0alpha01, December 10, 2012, are * libpng versions 1.2.6, August 15, 2004, through 1.6.0beta32, November 25, 2012, are
* Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are * Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are
* distributed according to the same disclaimer and license as libpng-1.2.5 * distributed according to the same disclaimer and license as libpng-1.2.5
* with the following individual added to the list of Contributing Authors: * with the following individual added to the list of Contributing Authors:
@ -310,13 +310,13 @@
* Y2K compliance in libpng: * Y2K compliance in libpng:
* ========================= * =========================
* *
* December 10, 2012 * November 25, 2012
* *
* Since the PNG Development group is an ad-hoc body, we can't make * Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration. * an official declaration.
* *
* This is your unofficial assurance that libpng from version 0.71 and * This is your unofficial assurance that libpng from version 0.71 and
* upward through 1.7.0alpha01 are Y2K compliant. It is my belief that * upward through 1.6.0beta32 are Y2K compliant. It is my belief that
* earlier versions were also Y2K compliant. * earlier versions were also Y2K compliant.
* *
* Libpng only has two year fields. One is a 2-byte unsigned integer * Libpng only has two year fields. One is a 2-byte unsigned integer
@ -376,23 +376,23 @@
*/ */
/* Version information for png.h - this should match the version in png.c */ /* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.7.0alpha01" #define PNG_LIBPNG_VER_STRING "1.6.0beta32"
#define PNG_HEADER_VERSION_STRING \ #define PNG_HEADER_VERSION_STRING \
" libpng version 1.7.0alpha01 - December 10, 2012\n" " libpng version 1.6.0beta32 - November 25, 2012\n"
#define PNG_LIBPNG_VER_SONUM 17 #define PNG_LIBPNG_VER_SONUM 16
#define PNG_LIBPNG_VER_DLLNUM 17 #define PNG_LIBPNG_VER_DLLNUM 16
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1 #define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 7 #define PNG_LIBPNG_VER_MINOR 6
#define PNG_LIBPNG_VER_RELEASE 0 #define PNG_LIBPNG_VER_RELEASE 0
/* This should match the numeric part of the final component of /* This should match the numeric part of the final component of
* PNG_LIBPNG_VER_STRING, omitting any leading zero: * PNG_LIBPNG_VER_STRING, omitting any leading zero:
*/ */
#define PNG_LIBPNG_VER_BUILD 01 #define PNG_LIBPNG_VER_BUILD 32
/* Release Status */ /* Release Status */
#define PNG_LIBPNG_BUILD_ALPHA 1 #define PNG_LIBPNG_BUILD_ALPHA 1
@ -409,7 +409,7 @@
#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
PNG_LIBPNG_BUILD_PRIVATE */ PNG_LIBPNG_BUILD_PRIVATE */
#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_ALPHA #define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA
/* Careful here. At one time, Guy wanted to use 082, but that would be octal. /* Careful here. At one time, Guy wanted to use 082, but that would be octal.
* We must not include leading zeros. * We must not include leading zeros.
@ -417,7 +417,7 @@
* version 1.0.0 was mis-numbered 100 instead of 10000). From * version 1.0.0 was mis-numbered 100 instead of 10000). From
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
*/ */
#define PNG_LIBPNG_VER 10700 /* 1.7.0 */ #define PNG_LIBPNG_VER 10600 /* 1.6.0 */
/* Library configuration: these options cannot be changed after /* Library configuration: these options cannot be changed after
* the library has been built. * the library has been built.
@ -522,7 +522,7 @@ extern "C" {
/* This triggers a compiler error in png.c, if png.c and png.h /* This triggers a compiler error in png.c, if png.c and png.h
* do not agree upon the version number. * do not agree upon the version number.
*/ */
typedef char* png_libpng_version_1_7_0alpha01; typedef char* png_libpng_version_1_6_0beta32;
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info. /* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
* *

View File

@ -1,7 +1,7 @@
/* pngconf.h - machine configurable file for libpng /* pngconf.h - machine configurable file for libpng
* *
* libpng version 1.7.0alpha01 - December 10, 2012 * libpng version 1.6.0beta32 - November 25, 2012
* *
* Copyright (c) 1998-2012 Glenn Randers-Pehrson * Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)

View File

@ -163,7 +163,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
case PNG_NUMBER_FORMAT_02u: case PNG_NUMBER_FORMAT_02u:
/* Expects at least 2 digits. */ /* Expects at least 2 digits. */
mincount = 2; mincount = 2;
/* FALL THROUGH */ /* fall through */
case PNG_NUMBER_FORMAT_u: case PNG_NUMBER_FORMAT_u:
*--end = digits[number % 10]; *--end = digits[number % 10];
@ -173,7 +173,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
case PNG_NUMBER_FORMAT_02x: case PNG_NUMBER_FORMAT_02x:
/* This format expects at least two digits */ /* This format expects at least two digits */
mincount = 2; mincount = 2;
/* FALL THROUGH */ /* fall through */
case PNG_NUMBER_FORMAT_x: case PNG_NUMBER_FORMAT_x:
*--end = digits[number & 0xf]; *--end = digits[number & 0xf];

View File

@ -1009,7 +1009,9 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
png_ptr->rgb_to_gray_red_coeff = red_int; png_ptr->rgb_to_gray_red_coeff = red_int;
png_ptr->rgb_to_gray_green_coeff = green_int; png_ptr->rgb_to_gray_green_coeff = green_int;
png_ptr->rgb_to_gray_coefficients_set = 1; # if defined PNG_COLORS_SPACE_SUPPORTED || defined PNG_GAMMA_SUPPORTED
png_ptr->colorspace.flags |= PNG_COLORSPACE_RGB_TO_GRAY_SET;
# endif
} }
else else

View File

@ -1949,4 +1949,4 @@ main(void)
#endif #endif
/* Generate a compiler error if there is an old png.h in the search path. */ /* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_7_0alpha01 Your_png_h_is_not_version_1_7_0alpha01; typedef png_libpng_version_1_6_0beta32 Your_png_h_is_not_version_1_6_0beta32;

View File

@ -1446,6 +1446,7 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
/* One 16 bit value */ /* One 16 bit value */
if (tran->gray >= (1 << png_ptr->bit_depth)) if (tran->gray >= (1 << png_ptr->bit_depth))
{ {
/* This can no longer happen because it is checked in png_set_tRNS */
png_warning(png_ptr, png_warning(png_ptr,
"Ignoring attempt to write tRNS chunk out-of-range for bit_depth"); "Ignoring attempt to write tRNS chunk out-of-range for bit_depth");
@ -1468,7 +1469,8 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
if (buf[0] | buf[2] | buf[4]) if (buf[0] | buf[2] | buf[4])
#endif #endif
{ {
png_app_warning(png_ptr, /* Also checked in png_set_tRNS */
png_warning(png_ptr,
"Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8"); "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8");
return; return;
} }
@ -1521,7 +1523,6 @@ png_write_bKGD(png_structrp png_ptr, png_const_color_16p back, int color_type)
if (buf[0] | buf[2] | buf[4]) if (buf[0] | buf[2] | buf[4])
#endif #endif
{ {
/* This can no longer happen because it is checked in png_set_tRNS */
png_warning(png_ptr, png_warning(png_ptr,
"Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8"); "Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8");
@ -1535,7 +1536,6 @@ png_write_bKGD(png_structrp png_ptr, png_const_color_16p back, int color_type)
{ {
if (back->gray >= (1 << png_ptr->bit_depth)) if (back->gray >= (1 << png_ptr->bit_depth))
{ {
/* Also checked in png_set_tRNS */
png_warning(png_ptr, png_warning(png_ptr,
"Ignoring attempt to write bKGD chunk out-of-range for bit_depth"); "Ignoring attempt to write bKGD chunk out-of-range for bit_depth");

View File

@ -286,9 +286,9 @@ option IO_STATE
# read: # read:
# Added at libpng-1.2.43; adds limit fields to png_struct, # Added at libpng-1.2.43; adds limit fields to png_struct,
# allows some usages of these fields # allows some usages of these fields, from 1.7.0 only limits read
option USER_LIMITS option USER_LIMITS requires READ
# Added at libpng-1.2.6; adds setting APIs, allows additional # Added at libpng-1.2.6; adds setting APIs, allows additional
# usage of this field (UTSL) # usage of this field (UTSL)