mirror of https://github.com/stella-emu/stella.git
Updated built-in PNG lib to version 1.4.5 (current latest release).
Hopefully this marks a return to Stella development, as I haven't had much free time over the past month or so. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2194 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
8705a33f18
commit
af181e925a
11
Changes.txt
11
Changes.txt
|
@ -1,4 +1,4 @@
|
|||
===========================================================================
|
||||
===========================================================================
|
||||
|
||||
SSSS tt lll lll
|
||||
SS SS tt ll ll
|
||||
|
@ -12,6 +12,13 @@
|
|||
Release History
|
||||
===========================================================================
|
||||
|
||||
3.3 to 3.4: (xx. xx, 2010)
|
||||
|
||||
* Updated built-in version of the PNG library to the latest version.
|
||||
|
||||
-Have fun!
|
||||
|
||||
|
||||
3.2.2 to 3.3: (November 12, 2010)
|
||||
|
||||
* Added the following Distella 'directives', which are used to override
|
||||
|
@ -103,8 +110,6 @@
|
|||
* State files from older versions will no longer work in this release,
|
||||
because of the extensive changes to the debugger and disassembler.
|
||||
|
||||
-Have fun!
|
||||
|
||||
|
||||
3.2.1 to 3.2.2: (September 17, 2010)
|
||||
|
||||
|
|
|
@ -17,11 +17,7 @@
|
|||
#include "pngpriv.h"
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef version_1_4_3 Your_png_h_is_not_version_1_4_3;
|
||||
|
||||
/* Version information for C files. This had better match the version
|
||||
* string defined in png.h.
|
||||
*/
|
||||
typedef version_1_4_5 Your_png_h_is_not_version_1_4_5;
|
||||
|
||||
/* 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
|
||||
|
@ -551,13 +547,13 @@ png_get_copyright(png_structp png_ptr)
|
|||
#else
|
||||
#ifdef __STDC__
|
||||
return ((png_charp) PNG_STRING_NEWLINE \
|
||||
"libpng version 1.4.3 - June 26, 2010" PNG_STRING_NEWLINE \
|
||||
"libpng version 1.4.5 - December 9, 2010" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1998-2010 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
|
||||
PNG_STRING_NEWLINE);
|
||||
#else
|
||||
return ((png_charp) "libpng version 1.4.3 - June 26, 2010\
|
||||
return ((png_charp) "libpng version 1.4.5 - December 9, 2010\
|
||||
Copyright (c) 1998-2010 Glenn Randers-Pehrson\
|
||||
Copyright (c) 1996-1997 Andreas Dilger\
|
||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.");
|
||||
|
@ -678,7 +674,7 @@ png_convert_size(size_t size)
|
|||
*/
|
||||
|
||||
void /* PRIVATE */
|
||||
png_64bit_product (long v1, long v2, unsigned long *hi_product,
|
||||
png_64bit_product(long v1, long v2, unsigned long *hi_product,
|
||||
unsigned long *lo_product)
|
||||
{
|
||||
int a, b, c, d;
|
||||
|
|
452
src/libpng/png.h
452
src/libpng/png.h
File diff suppressed because it is too large
Load Diff
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng version 1.4.3 - June 26, 2010
|
||||
* libpng version 1.4.5 - December 9, 2010
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
|
@ -44,14 +44,14 @@
|
|||
* includes the resource compiler for Windows DLL configurations.
|
||||
*/
|
||||
#ifdef PNG_USER_CONFIG
|
||||
# include "pngusr.h"
|
||||
# ifndef PNG_USER_PRIVATEBUILD
|
||||
# define PNG_USER_PRIVATEBUILD
|
||||
# endif
|
||||
# include "pngusr.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If you create a private DLL you need to define in "pngusr.h" the followings:
|
||||
* If you create a private DLL you should define in "pngusr.h" the following:
|
||||
* #define PNG_USER_PRIVATEBUILD <Describes by whom and why this version of
|
||||
* the DLL was built>
|
||||
* e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons."
|
||||
|
@ -59,7 +59,7 @@
|
|||
* distinguish your DLL from those of the official release. These
|
||||
* correspond to the trailing letters that come after the version
|
||||
* number and must match your private DLL name>
|
||||
* e.g. // private DLL "libpng13gx.dll"
|
||||
* e.g. // private DLL "libpng14gx.dll"
|
||||
* #define PNG_USER_DLLFNAME_POSTFIX "gx"
|
||||
*
|
||||
* The following macros are also at your disposal if you want to complete the
|
||||
|
@ -278,11 +278,19 @@
|
|||
* #define PNG_NO_STDIO
|
||||
*/
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
# define PNG_NO_CONSOLE_IO
|
||||
# define PNG_NO_STDIO
|
||||
# define PNG_NO_TIME_RFC1123
|
||||
# ifdef PNG_DEBUG
|
||||
# undef PNG_DEBUG
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(PNG_NO_STDIO) && !defined(PNG_STDIO_SUPPORTED)
|
||||
# define PNG_STDIO_SUPPORTED
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef PNG_BUILD_DLL
|
||||
# if !defined(PNG_CONSOLE_IO_SUPPORTED) && !defined(PNG_NO_CONSOLE_IO)
|
||||
# define PNG_NO_CONSOLE_IO
|
||||
|
@ -448,7 +456,7 @@
|
|||
|
||||
/* The following uses const char * instead of char * for error
|
||||
* and warning message functions, so some compilers won't complain.
|
||||
* If you do not want to use const, define PNG_NO_CONST here.
|
||||
* If you do not want to use const, define PNG_NO_CONST.
|
||||
*/
|
||||
|
||||
#ifndef PNG_CONST
|
||||
|
@ -463,8 +471,10 @@
|
|||
* library that you will not be using. I wish I could figure out how to
|
||||
* automate this, but I can't do that without making it seriously hard
|
||||
* on the users. So if you are not using an ability, change the #define
|
||||
* to and #undef, and that part of the library will not be compiled. If
|
||||
* your linker can't find a function, you may want to make sure the
|
||||
* to an #undef, or pass in PNG_NO_feature and that part of the library
|
||||
* will not be compiled.
|
||||
|
||||
* If your linker can't find a function, you may want to make sure the
|
||||
* ability is defined here. Some of these depend upon some others being
|
||||
* defined. I haven't figured out all the interactions here, so you may
|
||||
* have to experiment awhile to get everything to compile. If you are
|
||||
|
@ -1123,7 +1133,7 @@ typedef unsigned char png_byte;
|
|||
#else
|
||||
typedef size_t png_size_t;
|
||||
#endif
|
||||
#define png_sizeof(x) sizeof(x)
|
||||
#define png_sizeof(x) (sizeof (x))
|
||||
|
||||
/* The following is needed for medium model support. It cannot be in the
|
||||
* pngpriv.h header. Needs modification for other compilers besides
|
||||
|
@ -1245,6 +1255,13 @@ typedef char FAR * FAR * FAR * png_charppp;
|
|||
# define PNG_DLL
|
||||
#endif
|
||||
|
||||
/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall",
|
||||
* you may get warnings regarding the linkage of png_zalloc and png_zfree.
|
||||
* Don't ignore those warnings; you must also reset the default calling
|
||||
* convention in your compiler to match your PNGAPI, and you must build
|
||||
* zlib and your applications the same way you build libpng.
|
||||
*/
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
# undef PNGAPI
|
||||
# define PNGAPI __cdecl
|
||||
|
@ -1252,14 +1269,11 @@ typedef char FAR * FAR * FAR * png_charppp;
|
|||
# define PNG_IMPEXP
|
||||
#endif
|
||||
|
||||
#define PNG_USE_LOCAL_ARRAYS /* Not used in libpng, defined for legacy apps */
|
||||
|
||||
/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall",
|
||||
* you may get warnings regarding the linkage of png_zalloc and png_zfree.
|
||||
* Don't ignore those warnings; you must also reset the default calling
|
||||
* convention in your compiler to match your PNGAPI, and you must build
|
||||
* zlib and your applications the same way you build libpng.
|
||||
*/
|
||||
#ifdef __WATCOMC__
|
||||
# ifndef PNGAPI
|
||||
# define PNGAPI
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__MINGW32__) && !defined(PNG_MODULEDEF)
|
||||
# ifndef PNG_NO_MODULEDEF
|
||||
|
@ -1344,6 +1358,8 @@ typedef char FAR * FAR * FAR * png_charppp;
|
|||
# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol
|
||||
#endif
|
||||
|
||||
#define PNG_USE_LOCAL_ARRAYS /* Not used in libpng, defined for legacy apps */
|
||||
|
||||
/* Support for compiler specific function attributes. These are used
|
||||
* so that where compiler support is available incorrect use of API
|
||||
* functions in png.h will generate compiler warnings.
|
||||
|
@ -1421,7 +1437,7 @@ typedef char FAR * FAR * FAR * png_charppp;
|
|||
|
||||
/* memory model/platform independent fns */
|
||||
#ifndef PNG_ABORT
|
||||
# ifdef _WINDOWS_
|
||||
# if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_))
|
||||
# define PNG_ABORT() ExitProcess(0)
|
||||
# else
|
||||
# define PNG_ABORT() abort()
|
||||
|
@ -1442,7 +1458,8 @@ typedef char FAR * FAR * FAR * png_charppp;
|
|||
# define png_memset _fmemset
|
||||
# define png_sprintf sprintf
|
||||
#else
|
||||
# ifdef _WINDOWS_ /* Favor Windows over C runtime fns */
|
||||
# if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_))
|
||||
# /* Favor Windows over C runtime fns */
|
||||
# define CVT_PTR(ptr) (ptr)
|
||||
# define CVT_PTR_NOCHECK(ptr) (ptr)
|
||||
# define png_strcpy lstrcpyA
|
||||
|
@ -1462,31 +1479,32 @@ typedef char FAR * FAR * FAR * png_charppp;
|
|||
# define png_memcpy memcpy
|
||||
# define png_memset memset
|
||||
# define png_sprintf sprintf
|
||||
# ifndef PNG_NO_SNPRINTF
|
||||
# ifdef _MSC_VER
|
||||
# define png_snprintf _snprintf /* Added to v 1.2.19 */
|
||||
# define png_snprintf2 _snprintf
|
||||
# define png_snprintf6 _snprintf
|
||||
# else
|
||||
# define png_snprintf snprintf /* Added to v 1.2.19 */
|
||||
# define png_snprintf2 snprintf
|
||||
# define png_snprintf6 snprintf
|
||||
# endif
|
||||
# else
|
||||
/* You don't have or don't want to use snprintf(). Caution: Using
|
||||
* sprintf instead of snprintf exposes your application to accidental
|
||||
* or malevolent buffer overflows. If you don't have snprintf()
|
||||
* as a general rule you should provide one (you can get one from
|
||||
* Portable OpenSSH).
|
||||
*/
|
||||
# define png_snprintf(s1,n,fmt,x1) sprintf(s1,fmt,x1)
|
||||
# define png_snprintf2(s1,n,fmt,x1,x2) sprintf(s1,fmt,x1,x2)
|
||||
# define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \
|
||||
sprintf(s1,fmt,x1,x2,x3,x4,x5,x6)
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef PNG_NO_SNPRINTF
|
||||
# ifdef _MSC_VER
|
||||
# define png_snprintf _snprintf /* Added to v 1.2.19 */
|
||||
# define png_snprintf2 _snprintf
|
||||
# define png_snprintf6 _snprintf
|
||||
# else
|
||||
# define png_snprintf snprintf /* Added to v 1.2.19 */
|
||||
# define png_snprintf2 snprintf
|
||||
# define png_snprintf6 snprintf
|
||||
# endif
|
||||
#else
|
||||
/* You don't have or don't want to use snprintf(). Caution: Using
|
||||
* sprintf instead of snprintf exposes your application to accidental
|
||||
* or malevolent buffer overflows. If you don't have snprintf()
|
||||
* as a general rule you should provide one (you can get one from
|
||||
* Portable OpenSSH).
|
||||
*/
|
||||
# define png_snprintf(s1,n,fmt,x1) png_sprintf(s1,fmt,x1)
|
||||
# define png_snprintf2(s1,n,fmt,x1,x2) png_sprintf(s1,fmt,x1,x2)
|
||||
# define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \
|
||||
png_sprintf(s1,fmt,x1,x2,x3,x4,x5,x6)
|
||||
#endif
|
||||
|
||||
/* png_alloc_size_t is guaranteed to be no smaller than png_size_t,
|
||||
* and no smaller than png_uint_32. Casts from png_size_t or png_uint_32
|
||||
* to png_alloc_size_t are not necessary; in fact, it is recommended
|
||||
|
@ -1497,22 +1515,19 @@ typedef char FAR * FAR * FAR * png_charppp;
|
|||
* to encounter practical situations that require such conversions.
|
||||
*/
|
||||
#if defined(__TURBOC__) && !defined(__FLAT__)
|
||||
# define png_mem_alloc farmalloc
|
||||
# define png_mem_free farfree
|
||||
typedef unsigned long png_alloc_size_t;
|
||||
#else
|
||||
# if defined(_MSC_VER) && defined(MAXSEG_64K)
|
||||
# define png_mem_alloc(s) halloc(s, 1)
|
||||
# define png_mem_free hfree
|
||||
typedef unsigned long png_alloc_size_t;
|
||||
# else
|
||||
# if defined(_WINDOWS_) && (!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)
|
||||
# define png_mem_alloc(s) HeapAlloc(GetProcessHeap(), 0, s)
|
||||
# define png_mem_free(p) HeapFree(GetProcessHeap(), 0, p)
|
||||
typedef DWORD png_alloc_size_t;
|
||||
/* This is an attempt to detect an old Windows system where (int) is
|
||||
* actually 16 bits, in that case png_malloc must have an argument with a
|
||||
* bigger size to accomodate the requirements of the library.
|
||||
*/
|
||||
# if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_)) && \
|
||||
(!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)
|
||||
typedef DWORD png_alloc_size_t;
|
||||
# else
|
||||
# define png_mem_alloc malloc
|
||||
# define png_mem_free free
|
||||
typedef png_size_t png_alloc_size_t;
|
||||
# endif
|
||||
# endif
|
||||
|
|
|
@ -858,7 +858,7 @@ png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
|
|||
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
png_byte PNGAPI
|
||||
png_get_rgb_to_gray_status (png_structp png_ptr)
|
||||
png_get_rgb_to_gray_status(png_structp png_ptr)
|
||||
{
|
||||
return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0);
|
||||
}
|
||||
|
@ -883,24 +883,24 @@ png_get_compression_buffer_size(png_structp png_ptr)
|
|||
/* These functions were added to libpng 1.2.6 and were enabled
|
||||
* by default in libpng-1.4.0 */
|
||||
png_uint_32 PNGAPI
|
||||
png_get_user_width_max (png_structp png_ptr)
|
||||
png_get_user_width_max(png_structp png_ptr)
|
||||
{
|
||||
return (png_ptr? png_ptr->user_width_max : 0);
|
||||
}
|
||||
png_uint_32 PNGAPI
|
||||
png_get_user_height_max (png_structp png_ptr)
|
||||
png_get_user_height_max(png_structp png_ptr)
|
||||
{
|
||||
return (png_ptr? png_ptr->user_height_max : 0);
|
||||
}
|
||||
/* This function was added to libpng 1.4.0 */
|
||||
png_uint_32 PNGAPI
|
||||
png_get_chunk_cache_max (png_structp png_ptr)
|
||||
png_get_chunk_cache_max(png_structp png_ptr)
|
||||
{
|
||||
return (png_ptr? png_ptr->user_chunk_cache_max : 0);
|
||||
}
|
||||
/* This function was added to libpng 1.4.1 */
|
||||
png_alloc_size_t PNGAPI
|
||||
png_get_chunk_malloc_max (png_structp png_ptr)
|
||||
png_get_chunk_malloc_max(png_structp png_ptr)
|
||||
{
|
||||
return (png_ptr?
|
||||
png_ptr->user_chunk_malloc_max : 0);
|
||||
|
@ -910,13 +910,13 @@ png_get_chunk_malloc_max (png_structp png_ptr)
|
|||
/* These functions were added to libpng 1.4.0 */
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_io_state (png_structp png_ptr)
|
||||
png_get_io_state(png_structp png_ptr)
|
||||
{
|
||||
return png_ptr->io_state;
|
||||
}
|
||||
|
||||
png_bytep PNGAPI
|
||||
png_get_io_chunk_name (png_structp png_ptr)
|
||||
png_get_io_chunk_name(png_structp png_ptr)
|
||||
{
|
||||
return png_ptr->chunk_name;
|
||||
}
|
||||
|
|
|
@ -843,7 +843,7 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
|
|||
* or the stream marked as finished.
|
||||
*/
|
||||
while (png_ptr->zstream.avail_in > 0 &&
|
||||
!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
|
||||
!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
@ -872,49 +872,49 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer,
|
|||
/* Check for any failure before proceeding. */
|
||||
if (ret != Z_OK && ret != Z_STREAM_END)
|
||||
{
|
||||
/* Terminate the decompression. */
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
|
||||
/* Terminate the decompression. */
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
|
||||
|
||||
/* This may be a truncated stream (missing or
|
||||
* damaged end code). Treat that as a warning.
|
||||
*/
|
||||
* damaged end code). Treat that as a warning.
|
||||
*/
|
||||
if (png_ptr->row_number >= png_ptr->num_rows ||
|
||||
png_ptr->pass > 6)
|
||||
png_warning(png_ptr, "Truncated compressed data in IDAT");
|
||||
else
|
||||
png_error(png_ptr, "Decompression error in IDAT");
|
||||
png_ptr->pass > 6)
|
||||
png_warning(png_ptr, "Truncated compressed data in IDAT");
|
||||
else
|
||||
png_error(png_ptr, "Decompression error in IDAT");
|
||||
|
||||
/* Skip the check on unprocessed input */
|
||||
/* Skip the check on unprocessed input */
|
||||
return;
|
||||
}
|
||||
|
||||
/* Did inflate output any data? */
|
||||
if (png_ptr->zstream.next_out != png_ptr->row_buf)
|
||||
{
|
||||
/* Is this unexpected data after the last row?
|
||||
* If it is, artificially terminate the LZ output
|
||||
* here.
|
||||
*/
|
||||
/* Is this unexpected data after the last row?
|
||||
* If it is, artificially terminate the LZ output
|
||||
* here.
|
||||
*/
|
||||
if (png_ptr->row_number >= png_ptr->num_rows ||
|
||||
png_ptr->pass > 6)
|
||||
png_ptr->pass > 6)
|
||||
{
|
||||
/* Extra data. */
|
||||
png_warning(png_ptr, "Extra compressed data in IDAT");
|
||||
/* Extra data. */
|
||||
png_warning(png_ptr, "Extra compressed data in IDAT");
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
|
||||
/* Do no more processing; skip the unprocessed
|
||||
* input check below.
|
||||
*/
|
||||
/* Do no more processing; skip the unprocessed
|
||||
* input check below.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Do we have a complete row? */
|
||||
if (png_ptr->zstream.avail_out == 0)
|
||||
png_push_process_row(png_ptr);
|
||||
/* Do we have a complete row? */
|
||||
if (png_ptr->zstream.avail_out == 0)
|
||||
png_push_process_row(png_ptr);
|
||||
}
|
||||
|
||||
/* And check for the end of the stream. */
|
||||
if (ret == Z_STREAM_END)
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
|
||||
}
|
||||
|
||||
/* All the data should have been processed, if anything
|
||||
|
@ -988,7 +988,7 @@ png_push_process_row(png_structp png_ptr)
|
|||
|
||||
if (png_ptr->pass == 6 && png_ptr->height <= 4)
|
||||
{
|
||||
png_push_have_row(png_ptr, NULL);
|
||||
png_push_have_row(png_ptr, NULL);
|
||||
png_read_push_finish_row(png_ptr);
|
||||
}
|
||||
|
||||
|
@ -1028,7 +1028,7 @@ png_push_process_row(png_structp png_ptr)
|
|||
|
||||
for (i = 0; i < 4 && png_ptr->pass == 2; i++)
|
||||
{
|
||||
png_push_have_row(png_ptr, NULL);
|
||||
png_push_have_row(png_ptr, NULL);
|
||||
png_read_push_finish_row(png_ptr);
|
||||
}
|
||||
|
||||
|
@ -1078,13 +1078,13 @@ png_push_process_row(png_structp png_ptr)
|
|||
|
||||
for (i = 0; i < 2 && png_ptr->pass == 4; i++)
|
||||
{
|
||||
png_push_have_row(png_ptr, NULL);
|
||||
png_push_have_row(png_ptr, NULL);
|
||||
png_read_push_finish_row(png_ptr);
|
||||
}
|
||||
|
||||
if (png_ptr->pass == 6) /* Pass 5 might be empty */
|
||||
{
|
||||
png_push_have_row(png_ptr, NULL);
|
||||
png_push_have_row(png_ptr, NULL);
|
||||
png_read_push_finish_row(png_ptr);
|
||||
}
|
||||
|
||||
|
@ -1103,12 +1103,14 @@ png_push_process_row(png_structp png_ptr)
|
|||
|
||||
if (png_ptr->pass == 6) /* Skip top generated row */
|
||||
{
|
||||
png_push_have_row(png_ptr, NULL);
|
||||
png_push_have_row(png_ptr, NULL);
|
||||
png_read_push_finish_row(png_ptr);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
case 6:
|
||||
{
|
||||
png_push_have_row(png_ptr, png_ptr->row_buf + 1);
|
||||
|
@ -1117,7 +1119,7 @@ png_push_process_row(png_structp png_ptr)
|
|||
if (png_ptr->pass != 6)
|
||||
break;
|
||||
|
||||
png_push_have_row(png_ptr, NULL);
|
||||
png_push_have_row(png_ptr, NULL);
|
||||
png_read_push_finish_row(png_ptr);
|
||||
}
|
||||
}
|
||||
|
@ -1726,7 +1728,7 @@ png_push_have_row(png_structp png_ptr, png_bytep row)
|
|||
}
|
||||
|
||||
void PNGAPI
|
||||
png_progressive_combine_row (png_structp png_ptr,
|
||||
png_progressive_combine_row(png_structp png_ptr,
|
||||
png_bytep old_row, png_bytep new_row)
|
||||
{
|
||||
PNG_CONST int FARDATA png_pass_dsp_mask[7] =
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngpriv.h - private declarations for use inside libpng
|
||||
*
|
||||
* libpng version 1.4.3 - June 26, 2010
|
||||
* libpng version 1.4.5 - December 9, 2010
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
|
@ -28,14 +28,16 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef PNG_EXTERN
|
||||
/* The functions exported by PNG_EXTERN are internal functions, which
|
||||
* aren't usually used outside the library (as far as I know), so it is
|
||||
* debatable if they should be exported at all. In the future, when it
|
||||
* is possible to have run-time registry of chunk-handling functions,
|
||||
* some of these will be made available again.
|
||||
#define PNG_EXTERN extern
|
||||
# define PNG_EXTERN extern
|
||||
*/
|
||||
#define PNG_EXTERN
|
||||
# define PNG_EXTERN
|
||||
#endif
|
||||
|
||||
/* Other defines specific to compilers can go here. Try to keep
|
||||
* them inside an appropriate ifdef/endif pair for portability.
|
||||
|
@ -75,10 +77,6 @@
|
|||
#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \
|
||||
defined(_WIN32) || defined(__WIN32__)
|
||||
# include <windows.h> /* defines _WINDOWS_ macro */
|
||||
/* I have no idea why is this necessary... */
|
||||
# ifdef _MSC_VER
|
||||
# include <malloc.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Various modes of operation. Note that after an init, mode is set to
|
||||
|
@ -292,6 +290,9 @@ PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr));
|
|||
PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data,
|
||||
png_size_t length));
|
||||
|
||||
/* Read and check the PNG file signature */
|
||||
PNG_EXTERN void png_read_sig PNGARG((png_structp png_ptr, png_infop info_ptr));
|
||||
|
||||
/* Read the chunk header (length + type name) */
|
||||
PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr));
|
||||
|
||||
|
@ -672,7 +673,7 @@ PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr,
|
|||
#endif
|
||||
|
||||
#ifdef PNG_READ_iCCP_SUPPORTED
|
||||
extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr,
|
||||
PNG_EXTERN void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 length));
|
||||
#endif /* PNG_READ_iCCP_SUPPORTED */
|
||||
|
||||
|
@ -707,7 +708,7 @@ PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
|
|||
#endif
|
||||
|
||||
#ifdef PNG_READ_sPLT_SUPPORTED
|
||||
extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr,
|
||||
PNG_EXTERN void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr,
|
||||
png_uint_32 length));
|
||||
#endif /* PNG_READ_sPLT_SUPPORTED */
|
||||
|
||||
|
@ -828,14 +829,14 @@ PNG_EXTERN void png_check_IHDR PNGARG((png_structp png_ptr,
|
|||
int filter_type));
|
||||
|
||||
/* Free all memory used by the read (old method - NOT DLL EXPORTED) */
|
||||
extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
|
||||
PNG_EXTERN void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
|
||||
png_infop end_info_ptr));
|
||||
|
||||
/* Free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */
|
||||
extern void png_write_destroy PNGARG((png_structp png_ptr));
|
||||
PNG_EXTERN void png_write_destroy PNGARG((png_structp png_ptr));
|
||||
|
||||
#ifdef USE_FAR_KEYWORD /* memory model conversion function */
|
||||
extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
|
||||
PNG_EXTERN void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
|
||||
int check));
|
||||
#endif /* USE_FAR_KEYWORD */
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.4.1 [February 25, 2010]
|
||||
* Last changed in libpng 1.4.5 [December 9, 2010]
|
||||
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -214,34 +214,12 @@ void PNGAPI
|
|||
png_read_info(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
png_debug(1, "in png_read_info");
|
||||
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* If we haven't checked all of the PNG signature bytes, do so now. */
|
||||
if (png_ptr->sig_bytes < 8)
|
||||
{
|
||||
png_size_t num_checked = png_ptr->sig_bytes,
|
||||
num_to_check = 8 - num_checked;
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
png_ptr->io_state = PNG_IO_READING | PNG_IO_SIGNATURE;
|
||||
#endif
|
||||
|
||||
png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check);
|
||||
png_ptr->sig_bytes = 8;
|
||||
|
||||
if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check))
|
||||
{
|
||||
if (num_checked < 4 &&
|
||||
png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4))
|
||||
png_error(png_ptr, "Not a PNG file");
|
||||
else
|
||||
png_error(png_ptr, "PNG file corrupted by ASCII conversion");
|
||||
}
|
||||
if (num_checked < 3)
|
||||
png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
|
||||
}
|
||||
/* Read and check the PNG file signature. */
|
||||
png_read_sig(png_ptr, info_ptr);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
|
@ -426,7 +404,7 @@ void PNGAPI
|
|||
png_read_update_info(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
png_debug(1, "in png_read_update_info");
|
||||
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||
|
@ -448,7 +426,7 @@ void PNGAPI
|
|||
png_start_read_image(png_structp png_ptr)
|
||||
{
|
||||
png_debug(1, "in png_start_read_image");
|
||||
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||
|
@ -465,10 +443,10 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
0xff};
|
||||
PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
|
||||
int ret;
|
||||
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
|
||||
png_debug2(1, "in png_read_row (row %lu, pass %d)",
|
||||
(unsigned long) png_ptr->row_number, png_ptr->pass);
|
||||
|
||||
|
@ -524,6 +502,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if ((png_ptr->row_number & 0x07) || png_ptr->width < 5)
|
||||
{
|
||||
|
@ -534,6 +513,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if ((png_ptr->row_number & 0x07) != 4)
|
||||
{
|
||||
|
@ -544,6 +524,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if ((png_ptr->row_number & 3) || png_ptr->width < 3)
|
||||
{
|
||||
|
@ -554,6 +535,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if ((png_ptr->row_number & 3) != 2)
|
||||
{
|
||||
|
@ -564,6 +546,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case 5:
|
||||
if ((png_ptr->row_number & 1) || png_ptr->width < 2)
|
||||
{
|
||||
|
@ -574,6 +557,8 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
|||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
case 6:
|
||||
if (!(png_ptr->row_number & 1))
|
||||
{
|
||||
|
@ -724,7 +709,7 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
|
|||
png_bytepp dp;
|
||||
|
||||
png_debug(1, "in png_read_rows");
|
||||
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
rp = row;
|
||||
|
@ -775,7 +760,7 @@ png_read_image(png_structp png_ptr, png_bytepp image)
|
|||
png_bytepp rp;
|
||||
|
||||
png_debug(1, "in png_read_image");
|
||||
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
|
@ -813,7 +798,7 @@ void PNGAPI
|
|||
png_read_end(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
png_debug(1, "in png_read_end");
|
||||
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */
|
||||
|
@ -993,7 +978,7 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
|||
#endif
|
||||
|
||||
png_debug(1, "in png_destroy_read_struct");
|
||||
|
||||
|
||||
if (png_ptr_ptr != NULL)
|
||||
png_ptr = *png_ptr_ptr;
|
||||
if (png_ptr == NULL)
|
||||
|
@ -1069,7 +1054,7 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr,
|
|||
#endif
|
||||
|
||||
png_debug(1, "in png_read_destroy");
|
||||
|
||||
|
||||
if (info_ptr != NULL)
|
||||
png_info_destroy(png_ptr, info_ptr);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* Last changed in libpng 1.4.1 [February 25, 2010]
|
||||
* Last changed in libpng 1.4.5 [December 9, 2010]
|
||||
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -33,7 +33,7 @@ void /* PRIVATE */
|
|||
png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_debug1(4, "reading %d bytes", (int)length);
|
||||
|
||||
|
||||
if (png_ptr->read_data_fn != NULL)
|
||||
(*(png_ptr->read_data_fn))(png_ptr, data, length);
|
||||
else
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* Last changed in libpng 1.4.2 [May 6, 2010]
|
||||
* Last changed in libpng 1.4.5 [December 9, 2010]
|
||||
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -26,7 +26,7 @@ void PNGAPI
|
|||
png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
|
||||
{
|
||||
png_debug(1, "in png_set_crc_action");
|
||||
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
|
@ -98,7 +98,7 @@ png_set_background(png_structp png_ptr,
|
|||
int need_expand, double background_gamma)
|
||||
{
|
||||
png_debug(1, "in png_set_background");
|
||||
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN)
|
||||
|
@ -686,6 +686,11 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
|
|||
break;
|
||||
|
||||
case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR;
|
||||
break;
|
||||
|
||||
default:
|
||||
png_error(png_ptr, "invalid error action in png_set_rgb_to_gray");
|
||||
break;
|
||||
}
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
#ifdef PNG_READ_EXPAND_SUPPORTED
|
||||
|
@ -828,6 +833,8 @@ png_init_read_transformations(png_structp png_ptr)
|
|||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
case 8:
|
||||
|
||||
case 16:
|
||||
|
@ -1028,6 +1035,9 @@ png_init_read_transformations(png_structp png_ptr)
|
|||
gs = 1.0 / (png_ptr->background_gamma *
|
||||
png_ptr->screen_gamma);
|
||||
break;
|
||||
|
||||
default:
|
||||
png_error(png_ptr, "invalid background gamma type");
|
||||
}
|
||||
|
||||
png_ptr->background_1.gray = (png_uint_16)(pow(
|
||||
|
@ -1626,6 +1636,9 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
row_info->bit_depth = 8;
|
||||
row_info->pixel_depth = (png_byte)(8 * row_info->channels);
|
||||
|
@ -1682,6 +1695,9 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
|
|||
|
||||
switch (row_info->bit_depth)
|
||||
{
|
||||
default:
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
png_bytep bp;
|
||||
|
@ -2798,6 +2814,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -3230,6 +3249,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
|
@ -3428,6 +3450,9 @@ png_do_gamma(png_row_infop row_info, png_bytep row,
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3522,6 +3547,9 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
row_info->bit_depth = 8;
|
||||
row_info->pixel_depth = 8;
|
||||
|
@ -3672,6 +3700,9 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
row_info->bit_depth = 8;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngrutil.c - utilities to read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.4.3 [June 26, 2010]
|
||||
* Last changed in libpng 1.4.5 [December 9, 2010]
|
||||
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -23,50 +23,98 @@
|
|||
png_uint_32 PNGAPI
|
||||
png_get_uint_31(png_structp png_ptr, png_bytep buf)
|
||||
{
|
||||
png_uint_32 i = png_get_uint_32(buf);
|
||||
if (i > PNG_UINT_31_MAX)
|
||||
png_error(png_ptr, "PNG unsigned integer out of range");
|
||||
return (i);
|
||||
}
|
||||
#ifndef PNG_USE_READ_MACROS
|
||||
/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */
|
||||
png_uint_32 PNGAPI
|
||||
png_get_uint_32(png_bytep buf)
|
||||
{
|
||||
png_uint_32 i = ((png_uint_32)(*buf) << 24) +
|
||||
((png_uint_32)(*(buf + 1)) << 16) +
|
||||
((png_uint_32)(*(buf + 2)) << 8) +
|
||||
(png_uint_32)(*(buf + 3));
|
||||
png_uint_32 val = png_get_uint_32(buf);
|
||||
|
||||
return (i);
|
||||
if (val > PNG_UINT_31_MAX)
|
||||
png_error(png_ptr, "PNG unsigned integer out of range");
|
||||
return (val);
|
||||
}
|
||||
|
||||
#ifndef PNG_USE_READ_MACROS
|
||||
/* The parentheses around "PNGAPI function_name" in the following three
|
||||
* functions are necessary because they allow the macros to co-exist with
|
||||
* these (unused but exported) functions.
|
||||
*/
|
||||
|
||||
/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */
|
||||
png_uint_32 (PNGAPI
|
||||
png_get_uint_32)(png_bytep buf)
|
||||
{
|
||||
png_uint_32 uval = png_get_uint_32(buf);
|
||||
if ((uval & 0x80000000L) == 0) /* non-negative */
|
||||
return uval;
|
||||
|
||||
uval = (uval ^ 0xffffffffL) + 1; /* 2's complement: -x = ~x+1 */
|
||||
return -(png_int_32)uval;
|
||||
}
|
||||
|
||||
/* 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
|
||||
* assumed that the machine format for signed integers is the same.
|
||||
* data is stored in the PNG file in two's complement format and there
|
||||
* 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_get_int_32(png_bytep buf)
|
||||
png_int_32 (PNGAPI
|
||||
png_get_int_32)(png_bytep buf)
|
||||
{
|
||||
png_int_32 i = ((png_int_32)(*buf) << 24) +
|
||||
((png_int_32)(*(buf + 1)) << 16) +
|
||||
((png_int_32)(*(buf + 2)) << 8) +
|
||||
(png_int_32)(*(buf + 3));
|
||||
png_uint_32 uval = png_get_uint_32(buf);
|
||||
if ((uval & 0x80000000L) == 0) /* non-negative */
|
||||
return uval;
|
||||
|
||||
return (i);
|
||||
uval = (uval ^ 0xffffffffL) + 1; /* 2's complement: -x = ~x+1 */
|
||||
return -(png_int_32)uval;
|
||||
}
|
||||
|
||||
/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */
|
||||
png_uint_16 PNGAPI
|
||||
png_get_uint_16(png_bytep buf)
|
||||
png_uint_16 (PNGAPI
|
||||
png_get_uint_16)(png_bytep buf)
|
||||
{
|
||||
png_uint_16 i = (png_uint_16)(((png_uint_16)(*buf) << 8) +
|
||||
(png_uint_16)(*(buf + 1)));
|
||||
/* ANSI-C requires an int value to accomodate at least 16 bits so this
|
||||
* works and allows the compiler not to worry about possible narrowing
|
||||
* on 32 bit systems. (Pre-ANSI systems did not make integers smaller
|
||||
* than 16 bits either.)
|
||||
*/
|
||||
unsigned int val =
|
||||
((unsigned int)(*buf) << 8) +
|
||||
((unsigned int)(*(buf + 1)));
|
||||
|
||||
return (i);
|
||||
return (png_uint_16)val;
|
||||
}
|
||||
#endif /* PNG_USE_READ_MACROS */
|
||||
|
||||
/* Read and check the PNG file signature */
|
||||
void /* PRIVATE */
|
||||
png_read_sig(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
png_size_t num_checked, num_to_check;
|
||||
|
||||
/* Exit if the user application does not expect a signature. */
|
||||
if (png_ptr->sig_bytes >= 8)
|
||||
return;
|
||||
|
||||
num_checked = png_ptr->sig_bytes;
|
||||
num_to_check = 8 - num_checked;
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
png_ptr->io_state = PNG_IO_READING | PNG_IO_SIGNATURE;
|
||||
#endif
|
||||
|
||||
/* The signature must be serialized in a single I/O call. */
|
||||
png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check);
|
||||
png_ptr->sig_bytes = 8;
|
||||
|
||||
if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check))
|
||||
{
|
||||
if (num_checked < 4 &&
|
||||
png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4))
|
||||
png_error(png_ptr, "Not a PNG file");
|
||||
|
||||
else
|
||||
png_error(png_ptr, "PNG file corrupted by ASCII conversion");
|
||||
}
|
||||
if (num_checked < 3)
|
||||
png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
|
||||
}
|
||||
|
||||
/* Read the chunk header (length + type name).
|
||||
* Put the type name into png_ptr->chunk_name, and return the length.
|
||||
*/
|
||||
|
@ -77,32 +125,31 @@ png_read_chunk_header(png_structp png_ptr)
|
|||
png_uint_32 length;
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
/* Inform the I/O callback that the chunk header is being read.
|
||||
* PNG_IO_CHUNK_HDR requires a single I/O call.
|
||||
*/
|
||||
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_HDR;
|
||||
#endif
|
||||
|
||||
/* Read the length and the chunk name */
|
||||
/* Read the length and the chunk name.
|
||||
* This must be performed in a single I/O call.
|
||||
*/
|
||||
png_read_data(png_ptr, buf, 8);
|
||||
length = png_get_uint_31(png_ptr, buf);
|
||||
|
||||
/* Put the chunk name into png_ptr->chunk_name */
|
||||
/* Put the chunk name into png_ptr->chunk_name. */
|
||||
png_memcpy(png_ptr->chunk_name, buf + 4, 4);
|
||||
|
||||
png_debug2(0, "Reading %s chunk, length = %lu",
|
||||
png_ptr->chunk_name, length);
|
||||
|
||||
/* Reset the crc and run it over the chunk name */
|
||||
/* Reset the crc and run it over the chunk name. */
|
||||
png_reset_crc(png_ptr);
|
||||
png_calculate_crc(png_ptr, png_ptr->chunk_name, 4);
|
||||
|
||||
/* Check to see if chunk name is valid */
|
||||
/* Check to see if chunk name is valid. */
|
||||
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
/* Inform the I/O callback that chunk data will (possibly) be read.
|
||||
* PNG_IO_CHUNK_DATA does NOT require a specific number of I/O calls.
|
||||
/* It is unspecified how many I/O calls will be performed
|
||||
* during the serialization of the chunk data.
|
||||
*/
|
||||
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA;
|
||||
#endif
|
||||
|
@ -116,6 +163,7 @@ png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length)
|
|||
{
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_read_data(png_ptr, buf, length);
|
||||
png_calculate_crc(png_ptr, buf, length);
|
||||
}
|
||||
|
@ -135,6 +183,7 @@ png_crc_finish(png_structp png_ptr, png_uint_32 skip)
|
|||
{
|
||||
png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);
|
||||
}
|
||||
|
||||
if (i)
|
||||
{
|
||||
png_crc_read(png_ptr, png_ptr->zbuf, i);
|
||||
|
@ -149,11 +198,13 @@ png_crc_finish(png_structp png_ptr, png_uint_32 skip)
|
|||
{
|
||||
png_chunk_warning(png_ptr, "CRC error");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
png_chunk_benign_error(png_ptr, "CRC error");
|
||||
return (0);
|
||||
}
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
@ -176,6 +227,7 @@ png_crc_error(png_structp png_ptr)
|
|||
(PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))
|
||||
need_crc = 0;
|
||||
}
|
||||
|
||||
else /* critical */
|
||||
{
|
||||
if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE)
|
||||
|
@ -183,11 +235,10 @@ png_crc_error(png_structp png_ptr)
|
|||
}
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
/* Inform the I/O callback that the chunk CRC is being read */
|
||||
/* PNG_IO_CHUNK_CRC requires the I/O to be done at once */
|
||||
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_CRC;
|
||||
#endif
|
||||
|
||||
/* The chunk CRC must be serialized in a single I/O call. */
|
||||
png_read_data(png_ptr, crc_bytes, 4);
|
||||
|
||||
if (need_crc)
|
||||
|
@ -195,6 +246,7 @@ png_crc_error(png_structp png_ptr)
|
|||
crc = png_get_uint_32(crc_bytes);
|
||||
return ((int)(crc != png_ptr->crc));
|
||||
}
|
||||
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
@ -234,6 +286,7 @@ png_inflate(png_structp png_ptr, const png_byte *data, png_size_t size,
|
|||
if (avail < copy) copy = avail;
|
||||
png_memcpy(output + count, png_ptr->zbuf, copy);
|
||||
}
|
||||
|
||||
count += avail;
|
||||
}
|
||||
|
||||
|
@ -267,9 +320,11 @@ png_inflate(png_structp png_ptr, const png_byte *data, png_size_t size,
|
|||
case Z_BUF_ERROR:
|
||||
msg = "Buffer error in compressed datastream in %s chunk";
|
||||
break;
|
||||
|
||||
case Z_DATA_ERROR:
|
||||
msg = "Data error in compressed datastream in %s chunk";
|
||||
break;
|
||||
|
||||
default:
|
||||
msg = "Incomplete compressed datastream in %s chunk";
|
||||
break;
|
||||
|
@ -346,7 +401,7 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
|
|||
{
|
||||
/* Success (maybe) - really uncompress the chunk. */
|
||||
png_size_t new_size = 0;
|
||||
png_charp text = (png_charp) png_malloc_warn(png_ptr,
|
||||
png_charp text = (png_charp)png_malloc_warn(png_ptr,
|
||||
prefix_size + expanded_size + 1);
|
||||
|
||||
if (text != NULL)
|
||||
|
@ -369,6 +424,7 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
|
|||
png_warning(png_ptr, "png_inflate logic error");
|
||||
png_free(png_ptr, text);
|
||||
}
|
||||
|
||||
else
|
||||
png_warning(png_ptr, "Not enough memory to decompress chunk");
|
||||
}
|
||||
|
@ -394,7 +450,7 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
|
|||
* amount of compressed data.
|
||||
*/
|
||||
{
|
||||
png_charp text = (png_charp) png_malloc_warn(png_ptr, prefix_size + 1);
|
||||
png_charp text = (png_charp)png_malloc_warn(png_ptr, prefix_size + 1);
|
||||
if (text != NULL)
|
||||
{
|
||||
if (prefix_size > 0)
|
||||
|
@ -1128,20 +1184,20 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||
|
||||
if (profile_size > profile_length)
|
||||
{
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
char umsg[50];
|
||||
#endif
|
||||
png_free(png_ptr, png_ptr->chunkdata);
|
||||
png_ptr->chunkdata = NULL;
|
||||
png_warning(png_ptr, "Ignoring truncated iCCP profile");
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
{
|
||||
char umsg[50];
|
||||
|
||||
png_snprintf(umsg, 50, "declared profile size = %lu",
|
||||
(unsigned long)profile_size);
|
||||
png_warning(png_ptr, umsg);
|
||||
png_snprintf(umsg, 50, "actual profile length = %lu",
|
||||
(unsigned long)profile_length);
|
||||
png_warning(png_ptr, umsg);
|
||||
}
|
||||
png_snprintf(umsg, 50, "declared profile size = %lu",
|
||||
(unsigned long)profile_size);
|
||||
png_warning(png_ptr, umsg);
|
||||
png_snprintf(umsg, 50, "actual profile length = %lu",
|
||||
(unsigned long)profile_length);
|
||||
png_warning(png_ptr, umsg);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
@ -1875,9 +1931,6 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||
png_warning(png_ptr, "malformed height string in sCAL chunk");
|
||||
png_free(png_ptr, png_ptr->chunkdata);
|
||||
png_ptr->chunkdata = NULL;
|
||||
#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
png_free(png_ptr, swidth);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#else
|
||||
|
@ -1888,9 +1941,7 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||
png_warning(png_ptr, "Out of memory while processing sCAL chunk height");
|
||||
png_free(png_ptr, png_ptr->chunkdata);
|
||||
png_ptr->chunkdata = NULL;
|
||||
#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
png_free(png_ptr, swidth);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
png_memcpy(sheight, ep, png_strlen(ep));
|
||||
|
@ -3111,17 +3162,10 @@ png_read_finish_row(png_structp png_ptr)
|
|||
{
|
||||
while (!png_ptr->idat_size)
|
||||
{
|
||||
png_byte chunk_length[4];
|
||||
|
||||
png_crc_finish(png_ptr, 0);
|
||||
|
||||
png_read_data(png_ptr, chunk_length, 4);
|
||||
png_ptr->idat_size = png_get_uint_31(png_ptr, chunk_length);
|
||||
png_reset_crc(png_ptr);
|
||||
png_crc_read(png_ptr, png_ptr->chunk_name, 4);
|
||||
png_ptr->idat_size = png_read_chunk_header(png_ptr);
|
||||
if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||
png_error(png_ptr, "Not enough image data");
|
||||
|
||||
}
|
||||
png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size;
|
||||
png_ptr->zstream.next_in = png_ptr->zbuf;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* Last changed in libpng 1.4.1 [February 25, 2010]
|
||||
* Last changed in libpng 1.4.5 [December 9, 2010]
|
||||
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -690,6 +690,13 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
|||
if (text_ptr[i].key == NULL)
|
||||
continue;
|
||||
|
||||
if (text_ptr[i].compression < PNG_TEXT_COMPRESSION_NONE ||
|
||||
text_ptr[i].compression >= PNG_TEXT_COMPRESSION_LAST)
|
||||
{
|
||||
png_warning(png_ptr, "text compression mode is out of range");
|
||||
continue;
|
||||
}
|
||||
|
||||
key_len = png_strlen(text_ptr[i].key);
|
||||
|
||||
if (text_ptr[i].compression <= 0)
|
||||
|
@ -1004,7 +1011,7 @@ png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr,
|
|||
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features)
|
||||
png_permit_mng_features(png_structp png_ptr, png_uint_32 mng_features)
|
||||
{
|
||||
png_debug(1, "in png_permit_mng_features");
|
||||
|
||||
|
@ -1118,7 +1125,7 @@ png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask)
|
|||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
/* This function was added to libpng 1.2.6 */
|
||||
void PNGAPI
|
||||
png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max,
|
||||
png_set_user_limits(png_structp png_ptr, png_uint_32 user_width_max,
|
||||
png_uint_32 user_height_max)
|
||||
{
|
||||
/* Images with dimensions larger than these limits will be
|
||||
|
@ -1133,7 +1140,7 @@ png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max,
|
|||
|
||||
/* This function was added to libpng 1.4.0 */
|
||||
void PNGAPI
|
||||
png_set_chunk_cache_max (png_structp png_ptr,
|
||||
png_set_chunk_cache_max(png_structp png_ptr,
|
||||
png_uint_32 user_chunk_cache_max)
|
||||
{
|
||||
if (png_ptr)
|
||||
|
@ -1142,7 +1149,7 @@ png_set_chunk_cache_max (png_structp png_ptr,
|
|||
|
||||
/* This function was added to libpng 1.4.1 */
|
||||
void PNGAPI
|
||||
png_set_chunk_malloc_max (png_structp png_ptr,
|
||||
png_set_chunk_malloc_max(png_structp png_ptr,
|
||||
png_alloc_size_t user_chunk_malloc_max)
|
||||
{
|
||||
if (png_ptr)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngtest.c - a simple test program to test libpng
|
||||
*
|
||||
* Last changed in libpng 1.4.1 [February 25, 2010]
|
||||
* Last changed in libpng 1.4.5 [December 9, 2010]
|
||||
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
@ -263,6 +263,48 @@ static int wrote_question = 0;
|
|||
* than changing the library.
|
||||
*/
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
void
|
||||
pngtest_check_io_state(png_structp png_ptr, png_size_t data_length,
|
||||
png_uint_32 io_op);
|
||||
void
|
||||
pngtest_check_io_state(png_structp png_ptr, png_size_t data_length,
|
||||
png_uint_32 io_op)
|
||||
{
|
||||
png_uint_32 io_state = png_get_io_state(png_ptr);
|
||||
int err = 0;
|
||||
|
||||
/* Check if the current operation (reading / writing) is as expected. */
|
||||
if ((io_state & PNG_IO_MASK_OP) != io_op)
|
||||
png_error(png_ptr, "Incorrect operation in I/O state");
|
||||
|
||||
/* Check if the buffer size specific to the current location
|
||||
* (file signature / header / data / crc) is as expected.
|
||||
*/
|
||||
switch (io_state & PNG_IO_MASK_LOC)
|
||||
{
|
||||
case PNG_IO_SIGNATURE:
|
||||
if (data_length > 8)
|
||||
err = 1;
|
||||
break;
|
||||
case PNG_IO_CHUNK_HDR:
|
||||
if (data_length != 8)
|
||||
err = 1;
|
||||
break;
|
||||
case PNG_IO_CHUNK_DATA:
|
||||
break; /* no restrictions here */
|
||||
case PNG_IO_CHUNK_CRC:
|
||||
if (data_length != 4)
|
||||
err = 1;
|
||||
break;
|
||||
default:
|
||||
err = 1; /* uninitialized */
|
||||
}
|
||||
if (err)
|
||||
png_error(png_ptr, "Bad I/O state or buffer size");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef USE_FAR_KEYWORD
|
||||
static void
|
||||
pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
|
@ -281,8 +323,12 @@ pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
|
||||
if (check != length)
|
||||
{
|
||||
png_error(png_ptr, "Read Error!");
|
||||
png_error(png_ptr, "Read Error");
|
||||
}
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
pngtest_check_io_state(png_ptr, length, PNG_IO_READING);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
/* This is the model-independent version. Since the standard I/O library
|
||||
|
@ -302,7 +348,7 @@ pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
|
||||
/* Check if data really is near. If so, use usual code. */
|
||||
n_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
||||
io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
|
||||
io_ptr = (png_FILE_p)CVT_PTR(png_get_io_ptr(png_ptr));
|
||||
if ((png_bytep)n_data == data)
|
||||
{
|
||||
check = fread(n_data, 1, length, io_ptr);
|
||||
|
@ -328,7 +374,11 @@ pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
while (remaining != 0);
|
||||
}
|
||||
if (check != length)
|
||||
png_error(png_ptr, "read Error");
|
||||
png_error(png_ptr, "Read Error");
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
pngtest_check_io_state(png_ptr, length, PNG_IO_READING);
|
||||
#endif
|
||||
}
|
||||
#endif /* USE_FAR_KEYWORD */
|
||||
|
||||
|
@ -351,12 +401,18 @@ static void
|
|||
pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
{
|
||||
png_size_t check;
|
||||
png_FILE_p io_ptr;
|
||||
io_ptr = (png_FILE_p)CVT_PTR(png_get_io_ptr(png_ptr));
|
||||
|
||||
check = fwrite(data, 1, length, (png_FILE_p)png_ptr->io_ptr);
|
||||
check = fwrite(data, 1, length, io_ptr);
|
||||
if (check != length)
|
||||
{
|
||||
png_error(png_ptr, "Write Error");
|
||||
}
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
pngtest_check_io_state(png_ptr, length, PNG_IO_WRITING);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
/* This is the model-independent version. Since the standard I/O library
|
||||
|
@ -405,6 +461,10 @@ pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
{
|
||||
png_error(png_ptr, "Write Error");
|
||||
}
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
pngtest_check_io_state(png_ptr, length, PNG_IO_WRITING);
|
||||
#endif
|
||||
}
|
||||
#endif /* USE_FAR_KEYWORD */
|
||||
|
||||
|
@ -1627,4 +1687,4 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef version_1_4_3 your_png_h_is_not_version_1_4_3;
|
||||
typedef version_1_4_5 your_png_h_is_not_version_1_4_5;
|
||||
|
|
|
@ -673,5 +673,5 @@ png_get_user_transform_ptr(png_structp png_ptr)
|
|||
#endif
|
||||
}
|
||||
#endif /* PNG_READ_USER_TRANSFORM_SUPPORTED ||
|
||||
PNG_WRITE_USER_TRANSFORM_SUPPORTED */
|
||||
PNG_WRITE_USER_TRANSFORM_SUPPORTED */
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
|
|
|
@ -195,6 +195,9 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
|||
*dp = (png_byte)v;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
row_info->bit_depth = (png_byte)bit_depth;
|
||||
row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels);
|
||||
|
|
|
@ -246,10 +246,12 @@ png_text_compress(png_structp png_ptr,
|
|||
*/
|
||||
|
||||
/* Set up the compression buffers */
|
||||
/* TODO: the following cast hides a potential overflow problem. */
|
||||
png_ptr->zstream.avail_in = (uInt)text_len;
|
||||
/* NOTE: assume zlib doesn't overwrite the input */
|
||||
png_ptr->zstream.next_in = (Bytef *)text;
|
||||
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
|
||||
png_ptr->zstream.next_out = (Bytef *)png_ptr->zbuf;
|
||||
png_ptr->zstream.avail_out = png_ptr->zbuf_size;
|
||||
png_ptr->zstream.next_out = png_ptr->zbuf;
|
||||
|
||||
/* This is the same compression loop as in png_write_row() */
|
||||
do
|
||||
|
|
Loading…
Reference in New Issue