mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Compare commits
9 Commits
v1.7.0beta
...
v1.7.0beta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b1d9e8c2a | ||
|
|
bb4bcecaa0 | ||
|
|
28fa0d23c1 | ||
|
|
1bfeb46881 | ||
|
|
ace10ed9a2 | ||
|
|
156006bb1a | ||
|
|
8d48a512bd | ||
|
|
c75a0a40b4 | ||
|
|
fad9c9af47 |
31
ANNOUNCE
31
ANNOUNCE
@@ -1,5 +1,5 @@
|
||||
|
||||
Libpng 1.7.0beta74 - December 19, 2015
|
||||
Libpng 1.7.0beta75 - December 21, 2015
|
||||
|
||||
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.
|
||||
@@ -9,20 +9,20 @@ Files available for download:
|
||||
Source files with LF line endings (for Unix/Linux) and with a
|
||||
"configure" script
|
||||
|
||||
1.7.0beta74.tar.xz (LZMA-compressed, recommended)
|
||||
1.7.0beta74.tar.gz
|
||||
1.7.0beta75.tar.xz (LZMA-compressed, recommended)
|
||||
1.7.0beta75.tar.gz
|
||||
|
||||
Source files with CRLF line endings (for Windows), without the
|
||||
"configure" script
|
||||
|
||||
/scratch/glennrp/Libpng17/lp170b74.7z (LZMA-compressed, recommended)
|
||||
/scratch/glennrp/Libpng17/lp170b74.zip
|
||||
/scratch/glennrp/Libpng17/lp170b75.7z (LZMA-compressed, recommended)
|
||||
/scratch/glennrp/Libpng17/lp170b75.zip
|
||||
|
||||
Other information:
|
||||
|
||||
1.7.0beta74-README.txt
|
||||
1.7.0beta74-LICENSE.txt
|
||||
libpng-1.7.0beta74-*.asc (armored detached GPG signatures)
|
||||
1.7.0beta75-README.txt
|
||||
1.7.0beta75-LICENSE.txt
|
||||
libpng-1.7.0beta75-*.asc (armored detached GPG signatures)
|
||||
|
||||
Changes since the last public release (1.6.0):
|
||||
|
||||
@@ -1124,6 +1124,21 @@ Version 1.7.0beta74 [December 19, 2015]
|
||||
Added .travis.yml configuration file to control Travis continuous
|
||||
integration testing (David Drysdale).
|
||||
|
||||
Version 1.7.0beta75 [December 21, 2015]
|
||||
Fixed duplicate tIME chunk from png_write_png.
|
||||
Added an example program, pngcp.c, that illustrates the problem when
|
||||
used to copy pngtest.png (the result is an invalid PNG because the
|
||||
tIME chunk is duplicated.)
|
||||
Re-enabled 'methodical' filter selection code.
|
||||
Added an accurate 'methodical' measure.
|
||||
Fixed incorrect references to 'pngimage' in pngcp.
|
||||
Fixed incorrect debug macro in release builds.
|
||||
Reversed the order of tests in png_zlib_compress_validate(().
|
||||
Undefined behaviour sanitizer currently fires for this test
|
||||
with an error about member access within null pointer to
|
||||
struct; put the check that relies on pz->list being non-NULL
|
||||
second (David Drysdale).
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
|
||||
15
CHANGES
15
CHANGES
@@ -5423,6 +5423,21 @@ Version 1.7.0beta74 [December 19, 2015]
|
||||
Added .travis.yml configuration file to control Travis continuous
|
||||
integration testing (David Drysdale).
|
||||
|
||||
Version 1.7.0beta75 [December 21, 2015]
|
||||
Fixed duplicate tIME chunk from png_write_png.
|
||||
Added an example program, pngcp.c, that illustrates the problem when
|
||||
used to copy pngtest.png (the result is an invalid PNG because the
|
||||
tIME chunk is duplicated.)
|
||||
Re-enabled 'methodical' filter selection code.
|
||||
Added an accurate 'methodical' measure.
|
||||
Fixed incorrect references to 'pngimage' in pngcp.
|
||||
Fixed incorrect debug macro in release builds.
|
||||
Reversed the order of tests in png_zlib_compress_validate(().
|
||||
Undefined behaviour sanitizer currently fires for this test
|
||||
with an error about member access within null pointer to
|
||||
struct; put the check that relies on pz->list being non-NULL
|
||||
second (David Drysdale).
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
|
||||
@@ -261,7 +261,7 @@ endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
# SET UP LINKS
|
||||
if(PNG_SHARED)
|
||||
set_target_properties(${PNG_LIB_NAME} PROPERTIES
|
||||
# VERSION 17.${PNGLIB_RELEASE}.1.7.0beta74
|
||||
# VERSION 17.${PNGLIB_RELEASE}.1.7.0beta75
|
||||
VERSION 17.${PNGLIB_RELEASE}.0
|
||||
SOVERSION 17
|
||||
CLEAN_DIRECT_OUTPUT 1)
|
||||
|
||||
4
LICENSE
4
LICENSE
@@ -10,7 +10,7 @@ this sentence.
|
||||
|
||||
This code is released under the libpng license.
|
||||
|
||||
libpng versions 1.0.7, July 1, 2000, through 1.7.0beta74, December 19, 2015, are
|
||||
libpng versions 1.0.7, July 1, 2000, through 1.7.0beta75, December 21, 2015, are
|
||||
Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, are
|
||||
derived from libpng-1.0.6, and are distributed according to the same
|
||||
disclaimer and license as libpng-1.0.6 with the following individuals
|
||||
@@ -109,4 +109,4 @@ the additional disclaimers inserted at version 1.0.7.
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
glennrp at users.sourceforge.net
|
||||
December 19, 2015
|
||||
December 21, 2015
|
||||
|
||||
2
README
2
README
@@ -1,4 +1,4 @@
|
||||
README for libpng version 1.7.0beta74 - December 19, 2015 (shared library 17.0)
|
||||
README for libpng version 1.7.0beta75 - December 21, 2015 (shared library 17.0)
|
||||
See the note about version numbers near the top of png.h
|
||||
|
||||
See INSTALL for instructions on how to install libpng.
|
||||
|
||||
@@ -18,7 +18,7 @@ AC_PREREQ([2.68])
|
||||
|
||||
dnl Version number stuff here:
|
||||
|
||||
AC_INIT([libpng],[1.7.0beta74],[png-mng-implement@lists.sourceforge.net])
|
||||
AC_INIT([libpng],[1.7.0beta75],[png-mng-implement@lists.sourceforge.net])
|
||||
AC_CONFIG_MACRO_DIR([scripts])
|
||||
|
||||
# libpng does not follow GNU file name conventions (hence 'foreign')
|
||||
@@ -40,7 +40,7 @@ dnl automake, so the following is not necessary (and is not defined anyway):
|
||||
dnl AM_PREREQ([1.11.2])
|
||||
dnl stop configure from automagically running automake
|
||||
|
||||
PNGLIB_VERSION=1.7.0beta74
|
||||
PNGLIB_VERSION=1.7.0beta75
|
||||
PNGLIB_MAJOR=1
|
||||
PNGLIB_MINOR=7
|
||||
PNGLIB_RELEASE=0
|
||||
|
||||
535
contrib/examples/pngcp.c
Normal file
535
contrib/examples/pngcp.c
Normal file
@@ -0,0 +1,535 @@
|
||||
/* pngcp.c
|
||||
*
|
||||
* Copyright (c) 2015 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* This is a minimal example of copying a PNG without changes using the
|
||||
* png_read_png and png_write_png interfaces.
|
||||
*
|
||||
* For a more extensive example that uses the transforms see
|
||||
* contrib/libtests/pngimage.c in the libpng distribution.
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
/* Define the following to use this test against your installed libpng, rather
|
||||
* than the one being built here:
|
||||
*/
|
||||
#ifdef PNG_FREESTANDING_TESTS
|
||||
# include <png.h>
|
||||
#else
|
||||
# include "../../png.h"
|
||||
#endif
|
||||
|
||||
#ifndef PNG_SETJMP_SUPPORTED
|
||||
# include <setjmp.h> /* because png.h did *not* include this */
|
||||
#endif
|
||||
|
||||
#if (defined(PNG_READ_PNG_SUPPORTED)) && (defined(PNG_WRITE_PNG_SUPPORTED))
|
||||
/* This structure is used to control the test of a single file. */
|
||||
typedef enum
|
||||
{
|
||||
VERBOSE, /* switches on all messages */
|
||||
INFORMATION,
|
||||
WARNINGS, /* switches on warnings */
|
||||
LIBPNG_WARNING,
|
||||
APP_WARNING,
|
||||
ERRORS, /* just errors */
|
||||
APP_FAIL, /* continuable error - no need to longjmp */
|
||||
LIBPNG_ERROR, /* this and higher cause a longjmp */
|
||||
LIBPNG_BUG, /* erroneous behavior in libpng */
|
||||
APP_ERROR, /* such as out-of-memory in a callback */
|
||||
QUIET, /* no normal messages */
|
||||
USER_ERROR, /* such as file-not-found */
|
||||
INTERNAL_ERROR
|
||||
} error_level;
|
||||
#define LEVEL_MASK 0xf /* where the level is in 'options' */
|
||||
|
||||
#define STRICT 0x010 /* Fail on warnings as well as errors */
|
||||
#define LOG 0x020 /* Log pass/fail to stdout */
|
||||
#define CONTINUE 0x040 /* Continue on APP_FAIL errors */
|
||||
|
||||
/* Result masks apply to the result bits in the 'results' field below; these
|
||||
* bits are simple 1U<<error_level. A pass requires either nothing worse than
|
||||
* warnings (--relaxes) or nothing worse than information (--strict)
|
||||
*/
|
||||
#define RESULT_STRICT(r) (((r) & ~((1U<<WARNINGS)-1)) == 0)
|
||||
#define RESULT_RELAXED(r) (((r) & ~((1U<<ERRORS)-1)) == 0)
|
||||
|
||||
struct display
|
||||
{
|
||||
jmp_buf error_return; /* Where to go to on error */
|
||||
|
||||
const char *operation; /* What is happening */
|
||||
const char *filename; /* The name of the original file */
|
||||
const char *output_file; /* The name of the output file */
|
||||
png_uint_32 options; /* See display_log below */
|
||||
png_uint_32 results; /* A mask of errors seen */
|
||||
|
||||
/* Used on both read and write: */
|
||||
FILE *fp;
|
||||
|
||||
/* Used on a read, both the original read and when validating a written
|
||||
* image.
|
||||
*/
|
||||
png_structp read_pp;
|
||||
png_infop ip;
|
||||
|
||||
/* Used to write a new image (the original info_ptr is used) */
|
||||
png_structp write_pp;
|
||||
};
|
||||
|
||||
static void
|
||||
display_init(struct display *dp)
|
||||
/* Call this only once right at the start to initialize the control
|
||||
* structure, the (struct buffer) lists are maintained across calls - the
|
||||
* memory is not freed.
|
||||
*/
|
||||
{
|
||||
memset(dp, 0, sizeof *dp);
|
||||
dp->options = WARNINGS; /* default to !verbose, !quiet */
|
||||
dp->filename = NULL;
|
||||
dp->fp = NULL;
|
||||
dp->read_pp = NULL;
|
||||
dp->ip = NULL;
|
||||
dp->output_file = NULL;
|
||||
dp->write_pp = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
display_clean_read(struct display *dp)
|
||||
{
|
||||
if (dp->read_pp != NULL)
|
||||
png_destroy_read_struct(&dp->read_pp, NULL, NULL);
|
||||
|
||||
if (dp->fp != NULL)
|
||||
{
|
||||
FILE *fp = dp->fp;
|
||||
dp->fp = NULL;
|
||||
(void)fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
display_clean_write(struct display *dp)
|
||||
{
|
||||
if (dp->fp != NULL)
|
||||
{
|
||||
FILE *fp = dp->fp;
|
||||
dp->fp = NULL;
|
||||
(void)fclose(fp);
|
||||
}
|
||||
|
||||
if (dp->write_pp != NULL)
|
||||
png_destroy_write_struct(&dp->write_pp, &dp->ip);
|
||||
}
|
||||
|
||||
static void
|
||||
display_clean(struct display *dp)
|
||||
{
|
||||
display_clean_read(dp);
|
||||
display_clean_write(dp);
|
||||
dp->output_file = NULL;
|
||||
|
||||
/* leave the filename for error detection */
|
||||
dp->results = 0; /* reset for next time */
|
||||
}
|
||||
|
||||
static void
|
||||
display_destroy(struct display *dp)
|
||||
{
|
||||
/* Release any memory held in the display. */
|
||||
display_clean(dp);
|
||||
}
|
||||
|
||||
static struct display *
|
||||
get_dp(png_structp pp)
|
||||
/* The display pointer is always stored in the png_struct error pointer */
|
||||
{
|
||||
struct display *dp = (struct display*)png_get_error_ptr(pp);
|
||||
|
||||
if (dp == NULL)
|
||||
{
|
||||
fprintf(stderr, "pngcp: internal error (no display)\n");
|
||||
exit(99); /* prevents a crash */
|
||||
}
|
||||
|
||||
return dp;
|
||||
}
|
||||
|
||||
/* error handling */
|
||||
#ifdef __GNUC__
|
||||
# define VGATTR __attribute__((__format__ (__printf__,3,4)))
|
||||
/* Required to quiet GNUC warnings when the compiler sees a stdarg function
|
||||
* that calls one of the stdio v APIs.
|
||||
*/
|
||||
#else
|
||||
# define VGATTR
|
||||
#endif
|
||||
static void VGATTR
|
||||
display_log(struct display *dp, error_level level, const char *fmt, ...)
|
||||
/* 'level' is as above, fmt is a stdio style format string. This routine
|
||||
* does not return if level is above LIBPNG_WARNING
|
||||
*/
|
||||
{
|
||||
dp->results |= 1U << level;
|
||||
|
||||
if (level > (error_level)(dp->options & LEVEL_MASK))
|
||||
{
|
||||
const char *lp;
|
||||
va_list ap;
|
||||
|
||||
switch (level)
|
||||
{
|
||||
case INFORMATION: lp = "information"; break;
|
||||
case LIBPNG_WARNING: lp = "warning(libpng)"; break;
|
||||
case APP_WARNING: lp = "warning(pngcp)"; break;
|
||||
case APP_FAIL: lp = "error(continuable)"; break;
|
||||
case LIBPNG_ERROR: lp = "error(libpng)"; break;
|
||||
case LIBPNG_BUG: lp = "bug(libpng)"; break;
|
||||
case APP_ERROR: lp = "error(pngcp)"; break;
|
||||
case USER_ERROR: lp = "error(user)"; break;
|
||||
|
||||
case INTERNAL_ERROR: /* anything unexpected is an internal error: */
|
||||
case VERBOSE: case WARNINGS: case ERRORS: case QUIET:
|
||||
default: lp = "bug(pngcp)"; break;
|
||||
}
|
||||
|
||||
fprintf(stderr, "%s: %s: %s",
|
||||
dp->filename != NULL ? dp->filename : "<stdin>", lp, dp->operation);
|
||||
|
||||
fprintf(stderr, ": ");
|
||||
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
fputc('\n', stderr);
|
||||
}
|
||||
/* else do not output any message */
|
||||
|
||||
/* Errors cause this routine to exit to the fail code */
|
||||
if (level > APP_FAIL || (level > ERRORS && !(dp->options & CONTINUE)))
|
||||
longjmp(dp->error_return, level);
|
||||
}
|
||||
|
||||
/* error handler callbacks for libpng */
|
||||
static void PNGCBAPI
|
||||
display_warning(png_structp pp, png_const_charp warning)
|
||||
{
|
||||
display_log(get_dp(pp), LIBPNG_WARNING, "%s", warning);
|
||||
}
|
||||
|
||||
static void PNGCBAPI
|
||||
display_error(png_structp pp, png_const_charp error)
|
||||
{
|
||||
struct display *dp = get_dp(pp);
|
||||
|
||||
display_log(dp, LIBPNG_ERROR, "%s", error);
|
||||
}
|
||||
|
||||
static void
|
||||
display_start_read(struct display *dp, const char *filename)
|
||||
{
|
||||
if (filename != NULL)
|
||||
{
|
||||
dp->filename = filename;
|
||||
dp->fp = fopen(filename, "rb");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
dp->filename = "<stdin>";
|
||||
dp->fp = stdin;
|
||||
}
|
||||
|
||||
if (dp->fp == NULL)
|
||||
display_log(dp, APP_ERROR, "file open failed (%s)", strerror(errno));
|
||||
}
|
||||
|
||||
static void PNGCBAPI
|
||||
read_function(png_structp pp, png_bytep data, png_size_t size)
|
||||
{
|
||||
struct display *dp = get_dp(pp);
|
||||
|
||||
if (fread(data, size, 1U, dp->fp) != 1U)
|
||||
{
|
||||
if (feof(dp->fp))
|
||||
display_log(dp, USER_ERROR, "PNG file truncated");
|
||||
else
|
||||
display_log(dp, APP_ERROR, "PNG file read failed (%s)",
|
||||
strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
read_png(struct display *dp, const char *filename)
|
||||
{
|
||||
dp->operation = "read";
|
||||
display_clean_read(dp); /* safety */
|
||||
display_start_read(dp, filename);
|
||||
|
||||
dp->read_pp = png_create_read_struct(PNG_LIBPNG_VER_STRING, dp,
|
||||
display_error, display_warning);
|
||||
if (dp->read_pp == NULL)
|
||||
display_log(dp, LIBPNG_ERROR, "failed to create read struct");
|
||||
|
||||
/* The png_read_png API requires us to make the info struct, but it does the
|
||||
* call to png_read_info.
|
||||
*/
|
||||
dp->ip = png_create_info_struct(dp->read_pp);
|
||||
if (dp->ip == NULL)
|
||||
display_log(dp, LIBPNG_ERROR, "failed to create info struct");
|
||||
|
||||
/* Set the IO handling */
|
||||
png_set_read_fn(dp->read_pp, dp, read_function);
|
||||
|
||||
# ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_set_keep_unknown_chunks(dp->read_pp, PNG_HANDLE_CHUNK_ALWAYS, NULL,
|
||||
0);
|
||||
# endif /* SET_UNKNOWN_CHUNKS */
|
||||
|
||||
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
/* Remove the user limits, if any */
|
||||
png_set_user_limits(dp->read_pp, 0x7fffffff, 0x7fffffff);
|
||||
# endif /* SET_USER_LIMITS */
|
||||
|
||||
/* Now read the PNG. */
|
||||
png_read_png(dp->read_pp, dp->ip, 0U/*transforms*/, NULL/*params*/);
|
||||
display_clean_read(dp);
|
||||
dp->operation = "none";
|
||||
}
|
||||
|
||||
static void
|
||||
display_start_write(struct display *dp, const char *filename)
|
||||
{
|
||||
if (filename != NULL)
|
||||
{
|
||||
dp->output_file = filename;
|
||||
dp->fp = fopen(filename, "wb");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
dp->output_file = "<stdout>";
|
||||
dp->fp = stdout;
|
||||
}
|
||||
|
||||
if (dp->fp == NULL)
|
||||
display_log(dp, APP_ERROR, "%s: file open failed (%s)", dp->output_file,
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
static void PNGCBAPI
|
||||
write_function(png_structp pp, png_bytep data, png_size_t size)
|
||||
{
|
||||
struct display *dp = get_dp(pp);
|
||||
|
||||
if (fwrite(data, size, 1U, dp->fp) != 1U)
|
||||
display_log(dp, APP_ERROR, "%s: PNG file write failed (%s)",
|
||||
dp->output_file, strerror(errno));
|
||||
}
|
||||
|
||||
static void
|
||||
write_png(struct display *dp, const char *destname)
|
||||
{
|
||||
dp->operation = "write";
|
||||
display_clean_write(dp); /* safety */
|
||||
display_start_write(dp, destname);
|
||||
|
||||
dp->write_pp = png_create_write_struct(PNG_LIBPNG_VER_STRING, dp,
|
||||
display_error, display_warning);
|
||||
|
||||
if (dp->write_pp == NULL)
|
||||
display_log(dp, APP_ERROR, "failed to create write png_struct");
|
||||
|
||||
png_set_write_fn(dp->write_pp, dp, write_function, NULL/*flush*/);
|
||||
|
||||
# ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_set_keep_unknown_chunks(dp->write_pp, PNG_HANDLE_CHUNK_ALWAYS, NULL,
|
||||
0);
|
||||
# endif /* SET_UNKNOWN_CHUNKS */
|
||||
|
||||
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
/* Remove the user limits, if any */
|
||||
png_set_user_limits(dp->write_pp, 0x7fffffff, 0x7fffffff);
|
||||
# endif
|
||||
|
||||
/* This just uses the 'read' info_struct directly, it contains the image. */
|
||||
png_write_png(dp->write_pp, dp->ip, 0U/*transforms*/, NULL/*params*/);
|
||||
|
||||
/* Make sure the file was written ok: */
|
||||
{
|
||||
FILE *fp = dp->fp;
|
||||
dp->fp = NULL;
|
||||
if (fclose(fp))
|
||||
display_log(dp, APP_ERROR, "%s: write failed (%s)", destname,
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
/* Clean it on the way out - if control returns to the caller then the
|
||||
* written_file contains the required data.
|
||||
*/
|
||||
display_clean_write(dp);
|
||||
dp->operation = "none";
|
||||
}
|
||||
|
||||
static void
|
||||
cp_one_file(struct display *dp, const char *filename, const char *destname)
|
||||
{
|
||||
/* Read it then write it: */
|
||||
read_png(dp, filename);
|
||||
write_png(dp, destname);
|
||||
}
|
||||
|
||||
static int
|
||||
cppng(struct display *dp, const char *file, const char *dest)
|
||||
/* Exists solely to isolate the setjmp clobbers */
|
||||
{
|
||||
int ret = setjmp(dp->error_return);
|
||||
|
||||
if (ret == 0)
|
||||
{
|
||||
cp_one_file(dp, file, dest);
|
||||
return 0;
|
||||
}
|
||||
|
||||
else if (ret < ERRORS) /* shouldn't longjmp on warnings */
|
||||
display_log(dp, INTERNAL_ERROR, "unexpected return code %d", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
main(const int argc, const char * const * const argv)
|
||||
{
|
||||
/* For each file on the command line test it with a range of transforms */
|
||||
int option_end, ilog = 0;
|
||||
struct display d;
|
||||
|
||||
display_init(&d);
|
||||
|
||||
for (option_end=1; option_end<argc; ++option_end)
|
||||
{
|
||||
const char *name = argv[option_end];
|
||||
|
||||
if (strcmp(name, "--verbose") == 0)
|
||||
d.options = (d.options & ~LEVEL_MASK) | VERBOSE;
|
||||
|
||||
else if (strcmp(name, "--warnings") == 0)
|
||||
d.options = (d.options & ~LEVEL_MASK) | WARNINGS;
|
||||
|
||||
else if (strcmp(name, "--errors") == 0)
|
||||
d.options = (d.options & ~LEVEL_MASK) | ERRORS;
|
||||
|
||||
else if (strcmp(name, "--quiet") == 0)
|
||||
d.options = (d.options & ~LEVEL_MASK) | QUIET;
|
||||
|
||||
else if (strcmp(name, "--strict") == 0)
|
||||
d.options |= STRICT;
|
||||
|
||||
else if (strcmp(name, "--relaxed") == 0)
|
||||
d.options &= ~STRICT;
|
||||
|
||||
else if (strcmp(name, "--log") == 0)
|
||||
{
|
||||
ilog = option_end; /* prevent display */
|
||||
d.options |= LOG;
|
||||
}
|
||||
|
||||
else if (strcmp(name, "--nolog") == 0)
|
||||
d.options &= ~LOG;
|
||||
|
||||
else if (strcmp(name, "--continue") == 0)
|
||||
d.options |= CONTINUE;
|
||||
|
||||
else if (strcmp(name, "--stop") == 0)
|
||||
d.options &= ~CONTINUE;
|
||||
|
||||
else if (name[0] == '-' && name[1] == '-')
|
||||
{
|
||||
fprintf(stderr, "pngcp: %s: unknown option\n", name);
|
||||
return 99;
|
||||
}
|
||||
|
||||
else
|
||||
break; /* Not an option */
|
||||
}
|
||||
|
||||
{
|
||||
int errors = 0;
|
||||
int i = option_end;
|
||||
|
||||
{
|
||||
const char *infile = NULL;
|
||||
const char *outfile = NULL;
|
||||
|
||||
if (i < argc)
|
||||
{
|
||||
infile = argv[i++];
|
||||
if (i < argc)
|
||||
outfile = argv[i++];
|
||||
}
|
||||
|
||||
{
|
||||
int ret = cppng(&d, infile, outfile);
|
||||
|
||||
if (ret > QUIET) /* abort on user or internal error */
|
||||
return 99;
|
||||
}
|
||||
|
||||
/* Here on any return, including failures, except user/internal issues
|
||||
*/
|
||||
{
|
||||
const int pass = (d.options & STRICT) ?
|
||||
RESULT_STRICT(d.results) : RESULT_RELAXED(d.results);
|
||||
|
||||
if (!pass)
|
||||
++errors;
|
||||
|
||||
if (d.options & LOG)
|
||||
{
|
||||
int j;
|
||||
|
||||
printf("%s: pngcp", pass ? "PASS" : "FAIL");
|
||||
|
||||
for (j=1; j<option_end; ++j) if (j != ilog)
|
||||
printf(" %s", argv[j]);
|
||||
|
||||
if (infile != NULL)
|
||||
printf(" %s", infile);
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
display_clean(&d);
|
||||
}
|
||||
|
||||
/* Release allocated memory */
|
||||
display_destroy(&d);
|
||||
|
||||
return errors != 0;
|
||||
}
|
||||
}
|
||||
#else /* !READ_PNG || !WRITE_PNG */
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
fprintf(stderr, "pngcp: no support for png_read/write_image\n");
|
||||
return 77;
|
||||
}
|
||||
#endif
|
||||
@@ -1,6 +1,6 @@
|
||||
libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 1.7.0beta74 - December 19, 2015
|
||||
libpng version 1.7.0beta75 - December 21, 2015
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<glennrp at users.sourceforge.net>
|
||||
Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
@@ -11,7 +11,7 @@ libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
Based on:
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.7.0beta74 - December 19, 2015
|
||||
libpng versions 0.97, January 1998, through 1.7.0beta75 - December 21, 2015
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
|
||||
@@ -5321,7 +5321,7 @@ Since the PNG Development group is an ad-hoc body, we can't make
|
||||
an official declaration.
|
||||
|
||||
This is your unofficial assurance that libpng from version 0.71 and
|
||||
upward through 1.7.0beta74 are Y2K compliant. It is my belief that earlier
|
||||
upward through 1.7.0beta75 are Y2K compliant. It is my belief that earlier
|
||||
versions were also Y2K compliant.
|
||||
|
||||
Libpng only has two year fields. One is a 2-byte unsigned integer
|
||||
|
||||
18
libpng.3
18
libpng.3
@@ -1,6 +1,6 @@
|
||||
.TH LIBPNG 3 "December 19, 2015"
|
||||
.TH LIBPNG 3 "December 21, 2015"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta74
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta75
|
||||
.SH SYNOPSIS
|
||||
\fB
|
||||
#include <png.h>\fP
|
||||
@@ -498,7 +498,7 @@ Following is a copy of the libpng-manual.txt file that accompanies libpng.
|
||||
.SH LIBPNG.TXT
|
||||
libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 1.7.0beta74 - December 19, 2015
|
||||
libpng version 1.7.0beta75 - December 21, 2015
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<glennrp at users.sourceforge.net>
|
||||
Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
@@ -509,7 +509,7 @@ libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
Based on:
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.7.0beta74 - December 19, 2015
|
||||
libpng versions 0.97, January 1998, through 1.7.0beta75 - December 21, 2015
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
|
||||
@@ -5819,7 +5819,7 @@ Since the PNG Development group is an ad-hoc body, we can't make
|
||||
an official declaration.
|
||||
|
||||
This is your unofficial assurance that libpng from version 0.71 and
|
||||
upward through 1.7.0beta74 are Y2K compliant. It is my belief that earlier
|
||||
upward through 1.7.0beta75 are Y2K compliant. It is my belief that earlier
|
||||
versions were also Y2K compliant.
|
||||
|
||||
Libpng only has two year fields. One is a 2-byte unsigned integer
|
||||
@@ -5924,7 +5924,7 @@ the first widely used release:
|
||||
1.6.19rc01-03 16 10619 16.so.16.19[.0]
|
||||
...
|
||||
1.7.0alpha01-10 17 10700 17.so.17.0[.0]
|
||||
1.7.0beta01-73 17 10700 17.so.17.0[.0]
|
||||
1.7.0beta01-75 17 10700 17.so.17.0[.0]
|
||||
|
||||
Henceforth the source version will match the shared-library minor
|
||||
and patch numbers; the shared-library major version number will be
|
||||
@@ -5980,7 +5980,7 @@ possible without all of you.
|
||||
|
||||
Thanks to Frank J. T. Wojcik for helping with the documentation.
|
||||
|
||||
Libpng version 1.7.0beta74 - December 19, 2015:
|
||||
Libpng version 1.7.0beta75 - December 21, 2015:
|
||||
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
|
||||
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
|
||||
|
||||
@@ -6005,7 +6005,7 @@ this sentence.
|
||||
|
||||
This code is released under the libpng license.
|
||||
|
||||
libpng versions 1.0.7, July 1, 2000, through 1.7.0beta74, December 19, 2015, are
|
||||
libpng versions 1.0.7, July 1, 2000, through 1.7.0beta75, December 21, 2015, are
|
||||
Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, are
|
||||
derived from libpng-1.0.6, and are distributed according to the same
|
||||
disclaimer and license as libpng-1.0.6 with the following individuals
|
||||
@@ -6104,7 +6104,7 @@ the additional disclaimers inserted at version 1.0.7.
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
glennrp at users.sourceforge.net
|
||||
December 19, 2015
|
||||
December 21, 2015
|
||||
|
||||
.\" end of man page
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.TH LIBPNGPF 3 "December 19, 2015"
|
||||
.TH LIBPNGPF 3 "December 21, 2015"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta74
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta75
|
||||
(private functions)
|
||||
.SH SYNOPSIS
|
||||
\fB#include \fI"pngpriv.h"
|
||||
|
||||
2
png.5
2
png.5
@@ -1,4 +1,4 @@
|
||||
.TH PNG 5 "December 19, 2015"
|
||||
.TH PNG 5 "December 21, 2015"
|
||||
.SH NAME
|
||||
png \- Portable Network Graphics (PNG) format
|
||||
.SH DESCRIPTION
|
||||
|
||||
6
png.c
6
png.c
@@ -15,7 +15,7 @@
|
||||
#define PNG_SRC_FILE PNG_SRC_FILE_png
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef png_libpng_version_1_7_0beta74 Your_png_h_is_not_version_1_7_0beta74;
|
||||
typedef png_libpng_version_1_7_0beta75 Your_png_h_is_not_version_1_7_0beta75;
|
||||
|
||||
/* 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
|
||||
@@ -705,14 +705,14 @@ png_get_copyright(png_const_structrp png_ptr)
|
||||
#else
|
||||
# ifdef __STDC__
|
||||
return PNG_STRING_NEWLINE \
|
||||
"libpng version 1.7.0beta74 - December 19, 2015" PNG_STRING_NEWLINE \
|
||||
"libpng version 1.7.0beta75 - December 21, 2015" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1998-2002,2004,2006-2015 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 "libpng version 1.7.0beta74 - December 19, 2015\
|
||||
return "libpng version 1.7.0beta75 - December 21, 2015\
|
||||
Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson\
|
||||
Copyright (c) 1996-1997 Andreas Dilger\
|
||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
|
||||
|
||||
20
png.h
20
png.h
@@ -1,7 +1,7 @@
|
||||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng version 1.7.0beta74, December 19, 2015
|
||||
* libpng version 1.7.0beta75, December 21, 2015
|
||||
*
|
||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
@@ -12,7 +12,7 @@
|
||||
* Authors and maintainers:
|
||||
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
||||
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||
* libpng versions 0.97, January 1998, through 1.7.0beta74, December 19, 2015:
|
||||
* libpng versions 0.97, January 1998, through 1.7.0beta75, December 21, 2015:
|
||||
* Glenn Randers-Pehrson.
|
||||
* See also "Contributing Authors", below.
|
||||
*/
|
||||
@@ -25,7 +25,7 @@
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
*
|
||||
* libpng versions 1.0.7, July 1, 2000, through 1.7.0beta74, December 19, 2015, are
|
||||
* libpng versions 1.0.7, July 1, 2000, through 1.7.0beta75, December 21, 2015, are
|
||||
* Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, are
|
||||
* derived from libpng-1.0.6, and are distributed according to the same
|
||||
* disclaimer and license as libpng-1.0.6 with the following individuals
|
||||
@@ -190,7 +190,7 @@
|
||||
* 1.6.19rc01-03 16 10619 16.so.16.19[.0]
|
||||
* ...
|
||||
* 1.7.0alpha01-10 17 10700 17.so.17.0[.0]
|
||||
* 1.7.0beta01-73 17 10700 17.so.17.0[.0]
|
||||
* 1.7.0beta01-75 17 10700 17.so.17.0[.0]
|
||||
*
|
||||
* Henceforth the source version will match the shared-library major
|
||||
* and minor numbers; the shared-library major version number will be
|
||||
@@ -218,13 +218,13 @@
|
||||
* Y2K compliance in libpng:
|
||||
* =========================
|
||||
*
|
||||
* December 19, 2015
|
||||
* December 21, 2015
|
||||
*
|
||||
* Since the PNG Development group is an ad-hoc body, we can't make
|
||||
* an official declaration.
|
||||
*
|
||||
* This is your unofficial assurance that libpng from version 0.71 and
|
||||
* upward through 1.7.0beta74 are Y2K compliant. It is my belief that
|
||||
* upward through 1.7.0beta75 are Y2K compliant. It is my belief that
|
||||
* earlier versions were also Y2K compliant.
|
||||
*
|
||||
* Libpng only has two year fields. One is a 2-byte unsigned integer
|
||||
@@ -286,9 +286,9 @@
|
||||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.7.0beta74"
|
||||
#define PNG_LIBPNG_VER_STRING "1.7.0beta75"
|
||||
#define PNG_HEADER_VERSION_STRING \
|
||||
" libpng version 1.7.0beta74 - December 19, 2015\n"
|
||||
" libpng version 1.7.0beta75 - December 21, 2015\n"
|
||||
|
||||
#define PNG_LIBPNG_VER_SONUM 17
|
||||
#define PNG_LIBPNG_VER_DLLNUM 17
|
||||
@@ -302,7 +302,7 @@
|
||||
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
|
||||
*/
|
||||
|
||||
#define PNG_LIBPNG_VER_BUILD 74
|
||||
#define PNG_LIBPNG_VER_BUILD 75
|
||||
|
||||
/* Release Status */
|
||||
#define PNG_LIBPNG_BUILD_ALPHA 1
|
||||
@@ -562,7 +562,7 @@ extern "C" {
|
||||
/* This triggers a compiler error in png.c, if png.c and png.h
|
||||
* do not agree upon the version number.
|
||||
*/
|
||||
typedef char* png_libpng_version_1_7_0beta74;
|
||||
typedef char* png_libpng_version_1_7_0beta75;
|
||||
|
||||
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
|
||||
*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng version 1.7.0beta74, December 19, 2015
|
||||
* libpng version 1.7.0beta75, December 21, 2015
|
||||
*
|
||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
|
||||
@@ -400,6 +400,9 @@ struct png_struct_def
|
||||
unsigned int palette_index_check_disabled :1; /* defaults to 0, 'enabled' */
|
||||
unsigned int palette_index_check_issued :1; /* error message output */
|
||||
#endif /* CHECK_FOR_INVALID_INDEX */
|
||||
#ifdef PNG_WRITE_tIME_SUPPORTED
|
||||
unsigned int wrote_tIME :1; /* Stop writing of duplicate tIME chunks */
|
||||
#endif /* WRITE_tIME */
|
||||
#ifdef PNG_READ_tRNS_SUPPORTED
|
||||
png_color_16 trans_color; /* transparent color for non-paletted files */
|
||||
#endif /* READ_tRNS */
|
||||
|
||||
@@ -2070,4 +2070,4 @@ main(void)
|
||||
#endif
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef png_libpng_version_1_7_0beta74 Your_png_h_is_not_version_1_7_0beta74;
|
||||
typedef png_libpng_version_1_7_0beta75 Your_png_h_is_not_version_1_7_0beta75;
|
||||
|
||||
BIN
pngtest.png
BIN
pngtest.png
Binary file not shown.
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.6 KiB |
211
pngwutil.c
211
pngwutil.c
@@ -469,6 +469,56 @@ png_zlib_compress_init(png_structrp png_ptr, png_zlib_compressp pz)
|
||||
*/
|
||||
#define png_ptr png_voidcast(png_const_structrp, pz->zs.opaque)
|
||||
|
||||
#if PNG_RELEASE_BUILD
|
||||
# define png_zlib_compress_validate(pz, in_use) ((void)0)
|
||||
#else /* !RELEASE_BUILD */
|
||||
static void
|
||||
png_zlib_compress_validate(png_zlib_compressp pz, int in_use)
|
||||
{
|
||||
const uInt o_size = sizeof pz->list->output;
|
||||
|
||||
affirm(pz->end != NULL && (in_use || (pz->zs.next_in == NULL &&
|
||||
pz->zs.avail_in == 0U && *pz->end == NULL)));
|
||||
|
||||
if (pz->overflow == 0U && pz->len == 0U && pz->start == 0U) /* empty */
|
||||
{
|
||||
affirm((pz->end == &pz->list && pz->zs.next_out == NULL
|
||||
&& pz->zs.avail_out == 0U) ||
|
||||
(pz->end == &pz->list->next && pz->zs.next_out == pz->list->output
|
||||
&& pz->zs.avail_out == o_size));
|
||||
}
|
||||
|
||||
else /* not empty */
|
||||
{
|
||||
png_compression_bufferp *ep = &pz->list, list;
|
||||
png_uint_32 o, l;
|
||||
|
||||
affirm(*ep != NULL && pz->zs.next_out != NULL);
|
||||
|
||||
/* Check the list length: */
|
||||
o = pz->overflow;
|
||||
l = pz->len;
|
||||
affirm((l & 0x80000000U) == 0U && (o & 0x80000000U) == 0U);
|
||||
|
||||
do
|
||||
{
|
||||
list = *ep;
|
||||
l -= o_size;
|
||||
if (l & 0x80000000U) --o, l &= 0x7FFFFFFFU;
|
||||
ep = &list->next;
|
||||
}
|
||||
while (ep != pz->end);
|
||||
|
||||
l += pz->start;
|
||||
l += pz->zs.avail_out;
|
||||
if (l & 0x80000000U) ++o, l &= 0x7FFFFFFFU;
|
||||
|
||||
affirm(o == 0U && l == 0U && pz->zs.next_out >= list->output &&
|
||||
pz->zs.next_out + pz->zs.avail_out == list->output + o_size);
|
||||
}
|
||||
}
|
||||
#endif /* !RELEASE_BUILD */
|
||||
|
||||
/* Destroy one zlib compress structure. */
|
||||
static void
|
||||
png_zlib_compress_destroy(png_zlib_compressp pz, int check)
|
||||
@@ -479,7 +529,12 @@ png_zlib_compress_destroy(png_zlib_compressp pz, int check)
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
if (pz->zs.state != NULL)
|
||||
{
|
||||
if (check)
|
||||
png_zlib_compress_validate(pz, 0/*in_use*/);
|
||||
|
||||
png_deflateEnd(png_ptr, &pz->zs, check);
|
||||
}
|
||||
|
||||
pz->end = &pz->list; /* safety */
|
||||
png_free_compression_buffer(png_ptr, &pz->list);
|
||||
@@ -494,6 +549,8 @@ png_zlib_compress_avail_out(png_zlib_compressp pz)
|
||||
{
|
||||
uInt avail_out = pz->zs.avail_out;
|
||||
|
||||
png_zlib_compress_validate(pz, 1/*in_use*/);
|
||||
|
||||
if (avail_out == 0U)
|
||||
{
|
||||
png_compression_bufferp next;
|
||||
@@ -2160,6 +2217,12 @@ png_write_tIME(png_structrp png_ptr, png_const_timep mod_time)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Duplicate tIME chunks are invalid; this works round a bug in png_write_png
|
||||
* where it would write the tIME chunk once before and once after the IDAT.
|
||||
*/
|
||||
if (png_ptr->wrote_tIME)
|
||||
return;
|
||||
|
||||
png_save_uint_16(buf, mod_time->year);
|
||||
buf[2] = mod_time->month;
|
||||
buf[3] = mod_time->day;
|
||||
@@ -2168,6 +2231,7 @@ png_write_tIME(png_structrp png_ptr, png_const_timep mod_time)
|
||||
buf[6] = mod_time->second;
|
||||
|
||||
png_write_complete_chunk(png_ptr, png_tIME, buf, (png_size_t)7);
|
||||
png_ptr->wrote_tIME = 1U;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2250,6 +2314,7 @@ png_write_IDAT(png_structrp png_ptr, int flush)
|
||||
* pointer is NULL means that the end of the list can be easily detected.
|
||||
*/
|
||||
affirm(ps != NULL && ps->s.end != NULL && *ps->s.end == NULL);
|
||||
png_zlib_compress_validate(&png_ptr->zlib_state->s, 0/*in_use*/);
|
||||
|
||||
/* Write IDAT chunks while either 'flush' is true or there are at
|
||||
* least png_ptr->IDAT_size bytes available to be written.
|
||||
@@ -2270,7 +2335,7 @@ png_write_IDAT(png_structrp png_ptr, int flush)
|
||||
if (!flush)
|
||||
return;
|
||||
|
||||
if (avail == 0)
|
||||
if (avail == 0U)
|
||||
break;
|
||||
|
||||
len = avail;
|
||||
@@ -2302,8 +2367,9 @@ png_write_IDAT(png_structrp png_ptr, int flush)
|
||||
}
|
||||
|
||||
else /* not end of list */
|
||||
debug(ps->s.zs.next_out < next->output ||
|
||||
ps->s.zs.next_out > next->output + sizeof next->output);
|
||||
debug((ps->s.zs.next_out < next->output ||
|
||||
ps->s.zs.next_out > next->output + sizeof next->output) &&
|
||||
(ps->s.overflow > 0 || ps->s.len >= sizeof next->output));
|
||||
|
||||
/* First, if this is the very first IDAT (PNG_HAVE_IDAT not set)
|
||||
* optimize the CINFO field:
|
||||
@@ -2368,6 +2434,7 @@ png_write_IDAT(png_structrp png_ptr, int flush)
|
||||
affirm(ps->s.overflow > 0U);
|
||||
--ps->s.overflow;
|
||||
ps->s.len += 0x80000000U - written;
|
||||
UNTESTED
|
||||
}
|
||||
}
|
||||
while (len > 0U);
|
||||
@@ -2417,6 +2484,7 @@ png_compress_IDAT_data(png_const_structrp png_ptr, png_zlib_statep ps,
|
||||
(ret == Z_STREAM_END) == (flush == Z_FINISH));
|
||||
pz->zs.next_in = NULL;
|
||||
pz->zs.avail_in = 0U; /* safety */
|
||||
png_zlib_compress_validate(pz, 0/*in_use*/);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -2976,9 +3044,10 @@ png_zlib_filter_revert(png_structrp png_ptr, png_zlib_statep ps, png_byte i)
|
||||
png_zlib_compressp pz = &ps->filter[i];
|
||||
|
||||
affirm(pz->zs.opaque != NULL);
|
||||
png_zlib_compress_validate(pz, 0/*in_use*/);
|
||||
|
||||
/* First merge the buffer lists. */
|
||||
if (pz->overflow || pz->len > 0U)
|
||||
if (pz->overflow > 0U || pz->len > 0U)
|
||||
{
|
||||
affirm(pz->list != NULL);
|
||||
debug(ps->s.end != NULL && *ps->s.end == NULL);
|
||||
@@ -2988,8 +3057,9 @@ png_zlib_filter_revert(png_structrp png_ptr, png_zlib_statep ps, png_byte i)
|
||||
* the main z_stream, if pz->zs.next_out still points into this buffer the
|
||||
* pointer must be updated to point to the old buffer.
|
||||
*/
|
||||
if (pz->start > 0U)
|
||||
if (ps->s.zs.avail_out > 0U)
|
||||
{
|
||||
affirm(ps->s.zs.avail_out + pz->start == sizeof ps->s.list->output);
|
||||
/* Copy everything after pz->start into the old buffer. */
|
||||
memcpy(ps->s.zs.next_out, pz->list->output + pz->start,
|
||||
ps->s.zs.avail_out);
|
||||
@@ -3015,6 +3085,8 @@ png_zlib_filter_revert(png_structrp png_ptr, png_zlib_statep ps, png_byte i)
|
||||
{
|
||||
debug(pz->overflow == 0U &&
|
||||
pz->len + pz->start < (sizeof pz->list->output) &&
|
||||
pz->zs.next_out + pz->zs.avail_out ==
|
||||
pz->list->output + (sizeof pz->list->output) &&
|
||||
ps->s.zs.avail_out > pz->zs.avail_out);
|
||||
pz->zs.next_out = ps->s.zs.next_out + ps->s.zs.avail_out -
|
||||
pz->zs.avail_out;
|
||||
@@ -3023,6 +3095,8 @@ png_zlib_filter_revert(png_structrp png_ptr, png_zlib_statep ps, png_byte i)
|
||||
|
||||
else
|
||||
{
|
||||
affirm(pz->start == 0U);
|
||||
|
||||
/* Nothing to copy, the whole new list is appended to the existing one.
|
||||
*/
|
||||
*ps->s.end = pz->list;
|
||||
@@ -3052,11 +3126,11 @@ png_zlib_filter_revert(png_structrp png_ptr, png_zlib_statep ps, png_byte i)
|
||||
{
|
||||
z_stream zs = ps->s.zs;
|
||||
|
||||
ps->s.zs = pz->zs;
|
||||
png_zlib_compress_validate(&ps->s, 0/*in_use*/);
|
||||
zs.next_in = zs.next_out = NULL;
|
||||
zs.avail_in = zs.avail_out = 0U;
|
||||
zs.msg = PNGZ_MSG_CAST("invalid");
|
||||
|
||||
ps->s.zs = pz->zs;
|
||||
pz->zs = zs;
|
||||
}
|
||||
}
|
||||
@@ -3130,6 +3204,113 @@ select_filter_methodically_init(png_structrp png_ptr,
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
select_filter_methodically_better(png_structrp png_ptr, png_zlib_compressp pz,
|
||||
png_uint_32p op/*high 32 bits*/, png_uint_32p lp/*low 31 bits*/,
|
||||
Bytef *scratch_out, uInt avail_out, int flush)
|
||||
/* Called at the end of a row for each filter being tested to work out if
|
||||
* this filter is apparently producing better results than {*op,*lp}, which
|
||||
* is preset to a number larger than any possible 63-bit value and then set,
|
||||
* here, as required to {overflow,len} from a selected filter.
|
||||
*/
|
||||
{
|
||||
/* The pre-check here is that the data already produced by the compression
|
||||
* engine does not exceed the best count found so far:
|
||||
*/
|
||||
png_uint_32 o = pz->overflow, l = pz->len;
|
||||
|
||||
png_zlib_compress_validate(pz, 0/*in_use*/);
|
||||
|
||||
if (o < *op || (o == *op && l < *lp))
|
||||
{
|
||||
/* But if the stream hasn't been flushed this proves nothing; test the
|
||||
* pending output by using an appropriate flush:
|
||||
*/
|
||||
if (flush == Z_NO_FLUSH)
|
||||
{
|
||||
int ret;
|
||||
z_stream zs;
|
||||
|
||||
ret = deflateCopy(&zs, &pz->zs);
|
||||
|
||||
if (ret == Z_OK)
|
||||
{
|
||||
zs.next_in = NULL;
|
||||
zs.avail_in = 0U;
|
||||
|
||||
/* Extract all the output from zlib by doing dummy deflates. Note
|
||||
* that all the flush possibilites give approximately the same
|
||||
* result but PARTIAL, SYNC and FULL seem to be mildly better
|
||||
* probably because they avoid the rounding and block overhead.
|
||||
*
|
||||
* Z_PARTIAL_FLUSH 1
|
||||
* Z_SYNC_FLUSH 2
|
||||
* Z_FULL_FLUSH 3
|
||||
* Z_FINISH 4
|
||||
* Z_BLOCK 5
|
||||
*/
|
||||
flush = Z_PARTIAL_FLUSH;
|
||||
|
||||
do
|
||||
{
|
||||
if (l & 0x80000000U)
|
||||
++o, l &= 0x7FFFFFFFU;
|
||||
|
||||
zs.next_out = scratch_out;
|
||||
zs.avail_out = avail_out;
|
||||
l += avail_out;
|
||||
|
||||
ret = deflate(&zs, flush);
|
||||
} while (ret == Z_OK && zs.avail_out == 0U);
|
||||
|
||||
if (ret == (flush == Z_FINISH ? Z_STREAM_END : Z_OK))
|
||||
{
|
||||
/* This cannot underflow because the check above is performed
|
||||
* before adding 'avail_out' to l:
|
||||
*/
|
||||
l -= zs.avail_out;
|
||||
(void)deflateEnd(&zs);
|
||||
png_zlib_compress_validate(pz, 0/*in_use*/);
|
||||
|
||||
if (l & 0x80000000U)
|
||||
++o, l &= 0x7FFFFFFFU;
|
||||
|
||||
if (o < *op || (o == *op && l < *lp))
|
||||
{
|
||||
*op = o;
|
||||
*lp = l;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* No errors but the result was longer (this can't be the first
|
||||
* filter.)
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
else /* problem in deflate */
|
||||
(void)deflateEnd(&zs);
|
||||
}
|
||||
|
||||
/* We arrive here if there was an error somewhere inside zlib. */
|
||||
png_zstream_error(&zs, ret);
|
||||
png_warning(png_ptr, zs.msg);
|
||||
}
|
||||
|
||||
else /* flush already performed */
|
||||
{
|
||||
*op = o;
|
||||
*lp = l;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* This is the failure case, however if this is the first filter to be tested
|
||||
* return success anyway, without resetting {op,lp}:
|
||||
*/
|
||||
return *op == 0xFFFFFFFFU && *lp == 0xFFFFFFFFU;
|
||||
}
|
||||
|
||||
static void
|
||||
select_filter_methodically(png_structrp png_ptr, png_const_bytep prev_row,
|
||||
png_bytep prev_pixels, png_const_bytep unfiltered_row,
|
||||
@@ -3160,8 +3341,7 @@ select_filter_methodically(png_structrp png_ptr, png_const_bytep prev_row,
|
||||
{
|
||||
if (png_zlib_filter_compress(png_ptr, ps, filter,
|
||||
filter == PNG_FILTER_VALUE_NONE ?
|
||||
unfiltered_row : test_buffers[filter-1],
|
||||
row_bytes, flush))
|
||||
unfiltered_row : test_buffers[filter-1], row_bytes, flush))
|
||||
ok_filter = filter;
|
||||
|
||||
else /* remove this filter from the test list: */
|
||||
@@ -3181,15 +3361,10 @@ select_filter_methodically(png_structrp png_ptr, png_const_bytep prev_row,
|
||||
ok_filter = PNG_FILTER_VALUE_LAST;
|
||||
|
||||
for (filter=0U; filter < PNG_FILTER_VALUE_LAST; ++filter)
|
||||
if ((filters_to_try & PNG_FILTER_MASK(filter)) != 0U)
|
||||
if (ps->filter[filter].overflow < o ||
|
||||
(ps->filter[filter].overflow == o &&
|
||||
ps->filter[filter].len < l))
|
||||
{
|
||||
ok_filter = filter;
|
||||
o = ps->filter[filter].overflow;
|
||||
l = ps->filter[filter].len;
|
||||
}
|
||||
if ((filters_to_try & PNG_FILTER_MASK(filter)) != 0U &&
|
||||
select_filter_methodically_better(png_ptr, &ps->filter[filter],
|
||||
&o, &l, test_buffers[0], sizeof test_buffers, flush))
|
||||
ok_filter = filter;
|
||||
}
|
||||
|
||||
/* Keep going if there is more than one filter left, otherwise, if there
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
VisualStudio instructions
|
||||
|
||||
libpng version 1.7.0beta74 - December 19, 2015
|
||||
libpng version 1.7.0beta75 - December 21, 2015
|
||||
|
||||
Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!--
|
||||
* zlib.props - location of zlib source
|
||||
*
|
||||
* libpng version 1.7.0beta74 - December 19, 2015
|
||||
* libpng version 1.7.0beta75 - December 21, 2015
|
||||
*
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
*
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
Makefiles for libpng version 1.7.0beta74 - December 19, 2015
|
||||
Makefiles for libpng version 1.7.0beta75 - December 21, 2015
|
||||
|
||||
pnglibconf.h.prebuilt => Stores configuration settings
|
||||
makefile.linux => Linux/ELF makefile
|
||||
(gcc, creates libpng17.so.17.1.7.0beta74)
|
||||
(gcc, creates libpng17.so.17.1.7.0beta75)
|
||||
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
|
||||
makefile.knr => Archaic UNIX Makefile that converts files with
|
||||
ansi2knr (Requires ansi2knr.c from
|
||||
@@ -33,12 +33,12 @@ pnglibconf.h.prebuilt => Stores configuration settings
|
||||
makefile.os2 => OS/2 Makefile (gcc and emx, requires libpng.def)
|
||||
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
|
||||
makefile.sggcc => Silicon Graphics (gcc,
|
||||
creates libpng17.so.17.1.7.0beta74)
|
||||
creates libpng17.so.17.1.7.0beta75)
|
||||
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
|
||||
makefile.solaris => Solaris 2.X makefile (gcc,
|
||||
creates libpng17.so.17.1.7.0beta74)
|
||||
creates libpng17.so.17.1.7.0beta75)
|
||||
makefile.so9 => Solaris 9 makefile (gcc,
|
||||
creates libpng17.so.17.1.7.0beta74)
|
||||
creates libpng17.so.17.1.7.0beta75)
|
||||
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
|
||||
makefile.sunos => Sun makefile
|
||||
makefile.32sunu => Sun Ultra 32-bit makefile
|
||||
|
||||
@@ -21,7 +21,7 @@ PNG_DFN "OS2 DESCRIPTION "PNG image compression library""
|
||||
PNG_DFN "OS2 CODE PRELOAD MOVEABLE DISCARDABLE"
|
||||
PNG_DFN ""
|
||||
PNG_DFN "EXPORTS"
|
||||
PNG_DFN ";Version 1.7.0beta74"
|
||||
PNG_DFN ";Version 1.7.0beta75"
|
||||
|
||||
#define PNG_EXPORTA(ordinal, type, name, args, attributes)\
|
||||
PNG_DFN "@" SYMBOL_PREFIX "@@" name "@"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
# Modeled after libxml-config.
|
||||
|
||||
version=1.7.0beta74
|
||||
version=1.7.0beta75
|
||||
prefix=""
|
||||
libdir=""
|
||||
libs=""
|
||||
|
||||
@@ -5,6 +5,6 @@ includedir=@includedir@/libpng17
|
||||
|
||||
Name: libpng
|
||||
Description: Loads and saves PNG files
|
||||
Version: 1.7.0beta74
|
||||
Version: 1.7.0beta75
|
||||
Libs: -L${libdir} -lpng17
|
||||
Cflags: -I${includedir}
|
||||
|
||||
@@ -17,7 +17,7 @@ INCSDIR=${LOCALBASE}/include/libpng17
|
||||
|
||||
LIB= png17
|
||||
SHLIB_MAJOR= 0
|
||||
SHLIB_MINOR= 1.7.0beta74
|
||||
SHLIB_MINOR= 1.7.0beta75
|
||||
SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
|
||||
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
|
||||
pngwtran.c pngmem.c pngerror.c pngpread.c
|
||||
|
||||
@@ -17,7 +17,7 @@ INCSDIR=${LOCALBASE}/include
|
||||
|
||||
LIB= png
|
||||
SHLIB_MAJOR= 17
|
||||
SHLIB_MINOR= 1.7.0beta74
|
||||
SHLIB_MINOR= 1.7.0beta75
|
||||
SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
|
||||
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
|
||||
pngwtran.c pngmem.c pngerror.c pngpread.c
|
||||
|
||||
@@ -11,7 +11,7 @@ LIBDIR= ${PREFIX}/lib
|
||||
MANDIR= ${PREFIX}/man/cat
|
||||
|
||||
SHLIB_MAJOR= 17
|
||||
SHLIB_MINOR= 1.7.0beta74
|
||||
SHLIB_MINOR= 1.7.0beta75
|
||||
|
||||
LIB= png
|
||||
SRCS= png.c pngerror.c pngget.c pngmem.c pngpread.c \
|
||||
|
||||
@@ -942,8 +942,7 @@ option CONVERT_tIME requires WRITE_ANCILLARY_CHUNKS
|
||||
# See png.h for more description of these options.
|
||||
option WRITE_FILTER requires WRITE
|
||||
option SELECT_FILTER_HEURISTICALLY requires WRITE_FILTER enables SET_OPTION
|
||||
option SELECT_FILTER_METHODICALLY requires WRITE_FILTER enables SET_OPTION,
|
||||
disabled
|
||||
option SELECT_FILTER_METHODICALLY requires WRITE_FILTER enables SET_OPTION
|
||||
|
||||
# added at libpng-1.5.4
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* libpng 1.7.0beta74 STANDARD API DEFINITION */
|
||||
/* libpng 1.7.0beta75 STANDARD API DEFINITION */
|
||||
|
||||
/* pnglibconf.h - library build configuration */
|
||||
|
||||
/* Libpng version 1.7.0beta74, December 19, 2015 */
|
||||
/* Libpng version 1.7.0beta75, December 21, 2015 */
|
||||
|
||||
/* Copyright (c) 1998-2015 Glenn Randers-Pehrson */
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
#define PNG_READ_zTXt_SUPPORTED
|
||||
#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_SELECT_FILTER_HEURISTICALLY_SUPPORTED
|
||||
/*#undef PNG_SELECT_FILTER_METHODICALLY_SUPPORTED*/
|
||||
#define PNG_SELECT_FILTER_METHODICALLY_SUPPORTED
|
||||
#define PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
#define PNG_SETJMP_SUPPORTED
|
||||
#define PNG_SETTING_SUPPORTED
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
;Version 1.7.0beta74
|
||||
;Version 1.7.0beta75
|
||||
;--------------------------------------------------------------
|
||||
; LIBPNG symbol list as a Win32 DEF file
|
||||
; Contains all the symbols that can be exported from libpng
|
||||
|
||||
Reference in New Issue
Block a user