[master] Updated the read macros and functions from 1.5.0beta38.

This commit is contained in:
Glenn Randers-Pehrson 2010-07-31 16:37:38 -05:00
parent 6da5b35fca
commit 2af7ef63c3
5 changed files with 37 additions and 36 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.4.4beta04 - July 24, 2010 Libpng 1.4.4beta04 - July 31, 2010
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.
@ -46,7 +46,8 @@ version 1.4.4beta03 [July 24, 2010]
Eliminated the new special case typedef of png_longjmp_ptr for WATCOM Eliminated the new special case typedef of png_longjmp_ptr for WATCOM
and made a special case "#define PNGAPI" in pngconf.h instead. and made a special case "#define PNGAPI" in pngconf.h instead.
version 1.4.4beta04 [July 24, 2010] version 1.4.4beta04 [July 31, 2010]
Updated the read macros and functions from 1.5.0beta38.
Send comments/corrections/commendations to glennrp at users.sourceforge.net Send comments/corrections/commendations to glennrp at users.sourceforge.net
or to png-mng-implement at lists.sf.net (subscription required; visit or to png-mng-implement at lists.sf.net (subscription required; visit

View File

@ -2630,7 +2630,8 @@ version 1.4.4beta03 [July 24, 2010]
Eliminated the new special case typedef of png_longjmp_ptr for WATCOM Eliminated the new special case typedef of png_longjmp_ptr for WATCOM
and made a special case "#define PNGAPI" in pngconf.h instead. and made a special case "#define PNGAPI" in pngconf.h instead.
version 1.4.4beta04 [July 24, 2010] version 1.4.4beta04 [July 31, 2010]
Updated the read macros and functions from 1.5.0beta38.
Send comments/corrections/commendations to glennrp at users.sourceforge.net Send comments/corrections/commendations to glennrp at users.sourceforge.net
or to png-mng-implement at lists.sf.net (subscription required; visit or to png-mng-implement at lists.sf.net (subscription required; visit

4
png.c
View File

@ -551,13 +551,13 @@ png_get_copyright(png_structp png_ptr)
#else #else
#ifdef __STDC__ #ifdef __STDC__
return ((png_charp) PNG_STRING_NEWLINE \ return ((png_charp) PNG_STRING_NEWLINE \
"libpng version 1.4.4beta04 - July 24, 2010" PNG_STRING_NEWLINE \ "libpng version 1.4.4beta04 - July 31, 2010" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2010 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2010 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 ((png_charp) "libpng version 1.4.4beta04 - July 24, 2010\ return ((png_charp) "libpng version 1.4.4beta04 - July 31, 2010\
Copyright (c) 1998-2010 Glenn Randers-Pehrson\ Copyright (c) 1998-2010 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.");

20
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.4.4beta04 - July 24, 2010 * libpng version 1.4.4beta04 - July 31, 2010
* Copyright (c) 1998-2010 Glenn Randers-Pehrson * Copyright (c) 1998-2010 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.4.4beta04 - July 24, 2010: Glenn * libpng versions 0.97, January 1998, through 1.4.4beta04 - July 31, 2010: Glenn
* See also "Contributing Authors", below. * See also "Contributing Authors", below.
* *
* Note about libpng version numbers: * Note about libpng version numbers:
@ -177,7 +177,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.4.4beta04, July 24, 2010, are * libpng versions 1.2.6, August 15, 2004, through 1.4.4beta04, July 31, 2010, are
* Copyright (c) 2004, 2006-2010 Glenn Randers-Pehrson, and are * Copyright (c) 2004, 2006-2010 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:
@ -289,7 +289,7 @@
* Y2K compliance in libpng: * Y2K compliance in libpng:
* ========================= * =========================
* *
* July 24, 2010 * July 31, 2010
* *
* 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.
@ -353,7 +353,7 @@
/* 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.4.4beta04" #define PNG_LIBPNG_VER_STRING "1.4.4beta04"
#define PNG_HEADER_VERSION_STRING \ #define PNG_HEADER_VERSION_STRING \
" libpng version 1.4.4beta04 - July 24, 2010\n" " libpng version 1.4.4beta04 - July 31, 2010\n"
#define PNG_LIBPNG_VER_SONUM 14 #define PNG_LIBPNG_VER_SONUM 14
#define PNG_LIBPNG_VER_DLLNUM 14 #define PNG_LIBPNG_VER_DLLNUM 14
@ -2639,7 +2639,6 @@ PNG_EXPORT(png_bytep,png_get_io_chunk_name)
* The png_get_int_32() routine assumes we are using two's complement * The png_get_int_32() routine assumes we are using two's complement
* format for negative values, which is almost certainly true. * format for negative values, which is almost certainly true.
*/ */
/* We could make special-case BIG_ENDIAN macros that do direct reads here */
# define png_get_uint_32(buf) \ # define png_get_uint_32(buf) \
(((png_uint_32)(*(buf)) << 24) + \ (((png_uint_32)(*(buf)) << 24) + \
((png_uint_32)(*((buf) + 1)) << 16) + \ ((png_uint_32)(*((buf) + 1)) << 16) + \
@ -2648,13 +2647,10 @@ PNG_EXPORT(png_bytep,png_get_io_chunk_name)
# define png_get_uint_16(buf) \ # define png_get_uint_16(buf) \
(((png_uint_32)(*(buf)) << 8) + \ (((png_uint_32)(*(buf)) << 8) + \
((png_uint_32)(*((buf) + 1)))) ((png_uint_32)(*((buf) + 1))))
#ifdef PNG_GET_INT_32_SUPPORTED
# define png_get_int_32(buf) \ # define png_get_int_32(buf) \
(((png_int_32)(*(buf)) << 24) + \ ((png_int_32)((*(buf) & 0x80) \
((png_int_32)(*((buf) + 1)) << 16) + \ ? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffff)+1)) \
((png_int_32)(*((buf) + 2)) << 8) + \ : (png_int_32)png_get_uint_32(buf)))
((png_int_32)(*((buf) + 3))))
#endif
#else #else
PNG_EXPORT(png_uint_32,png_get_uint_32) PNGARG((png_bytep buf)); PNG_EXPORT(png_uint_32,png_get_uint_32) PNGARG((png_bytep buf));
PNG_EXPORT(png_uint_16,png_get_uint_16) PNGARG((png_bytep buf)); PNG_EXPORT(png_uint_16,png_get_uint_16) PNGARG((png_bytep buf));

View File

@ -30,38 +30,41 @@ png_get_uint_31(png_structp png_ptr, png_bytep buf)
} }
#ifndef PNG_USE_READ_MACROS #ifndef PNG_USE_READ_MACROS
/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */ /* Grab an unsigned 32-bit integer from a buffer in big-endian format. */
png_uint_32 PNGAPI png_uint_32 (PNGAPI
png_get_uint_32(png_bytep buf) png_get_uint_32)(png_bytep buf)
{ {
png_uint_32 i = ((png_uint_32)(*buf) << 24) + png_uint_32 i =
((png_uint_32)(*(buf )) << 24) +
((png_uint_32)(*(buf + 1)) << 16) + ((png_uint_32)(*(buf + 1)) << 16) +
((png_uint_32)(*(buf + 2)) << 8) + ((png_uint_32)(*(buf + 2)) << 8) +
(png_uint_32)(*(buf + 3)); ((png_uint_32)(*(buf + 3)) ) ;
return (i); return (i);
} }
/* Grab a signed 32-bit integer from a buffer in big-endian format. The /* Grab a signed 32-bit integer from a buffer in big-endian format. The
* data is stored in the PNG file in two's complement format, and it is * data is stored in the PNG file in two's complement format and there
* assumed that the machine format for signed integers is the same. * is no guarantee that a 'png_int_32' is exactly 32 bits, therefore
* the following code does a two's complement to native conversion.
*/ */
png_int_32 PNGAPI png_int_32 (PNGAPI
png_get_int_32(png_bytep buf) png_get_int_32)(png_bytep buf)
{ {
png_int_32 i = ((png_int_32)(*buf) << 24) + png_uint_32 u = png_get_uint_32(buf);
((png_int_32)(*(buf + 1)) << 16) + if ((u & 0x80000000) == 0) /* non-negative */
((png_int_32)(*(buf + 2)) << 8) + return u;
(png_int_32)(*(buf + 3));
return (i); u = (u ^ 0xffffffff) + 1; /* 2's complement: -x = ~x+1 */
return -(png_int_32)u;
} }
/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */ /* Grab an unsigned 16-bit integer from a buffer in big-endian format. */
png_uint_16 PNGAPI png_uint_16 (PNGAPI
png_get_uint_16(png_bytep buf) png_get_uint_16)(png_bytep buf)
{ {
png_uint_16 i = (png_uint_16)(((png_uint_16)(*buf) << 8) + png_uint_16 i =
(png_uint_16)(*(buf + 1))); ((png_uint_32)(*buf) << 8) +
((png_uint_32)(*(buf + 1)));
return (i); return (i);
} }