mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Imported from pngcrush-1.6.5.tar
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
Change log:
|
Change log:
|
||||||
|
|
||||||
|
Version 1.6.5 (built with libpng-1.2.29 and zlib-1.2.3.2)
|
||||||
|
Discontinued adding a new gAMA chunk when writing sRGB chunk.
|
||||||
|
|
||||||
Version 1.6.4 (built with libpng-1.2.9rc1 and zlib-1.2.3)
|
Version 1.6.4 (built with libpng-1.2.9rc1 and zlib-1.2.3)
|
||||||
Fixed bug in handling of undocumented -trns_a option (Michal Politowski).
|
Fixed bug in handling of undocumented -trns_a option (Michal Politowski).
|
||||||
Fixed bug with "nosave" handling of unknown chunks.
|
Fixed bug with "nosave" handling of unknown chunks.
|
||||||
|
|||||||
18
Makefile
18
Makefile
@@ -10,21 +10,19 @@
|
|||||||
|
|
||||||
# macros --------------------------------------------------------------------
|
# macros --------------------------------------------------------------------
|
||||||
|
|
||||||
GAS_VERSION := $(shell as --version | grep "GNU assembler" | sed -e 's/GNU assembler //' -e 's/ .*//')
|
|
||||||
|
|
||||||
# uncomment these 2 lines only if you are using an external copy of zlib:
|
# uncomment these 2 lines only if you are using an external copy of zlib:
|
||||||
#ZINC = ../../zlib
|
#ZINC = ../../zlib
|
||||||
#ZLIB = ../../zlib
|
#ZLIB = ../../zlib
|
||||||
|
|
||||||
CC = gcc
|
# CC = gcc
|
||||||
LD = gcc
|
CC = gcc-4.3.0
|
||||||
|
LD = gcc-4.3.0
|
||||||
|
# LD = gcc
|
||||||
RM = rm -f
|
RM = rm -f
|
||||||
#CFLAGS = -I. -O -Wall
|
#CFLAGS = -I. -O -Wall
|
||||||
#CFLAGS = -I. -O3 -fomit-frame-pointer -Wall -DPNG_USE_PNGGCCRD
|
#CFLAGS = -I. -O3 -fomit-frame-pointer -Wall
|
||||||
CFLAGS = -I. -O3 -fomit-frame-pointer -Wall -DPNG_USE_PNGGCCRD \
|
CFLAGS = -I. -O3 -fomit-frame-pointer -Wall
|
||||||
-DGAS_VERSION="\"${GAS_VERSION}\""
|
#CFLAGS = -I${ZINC} -I. -O3 -fomit-frame-pointer -Wall
|
||||||
#CFLAGS = -I${ZINC} -I. -O3 -fomit-frame-pointer -Wall -DPNG_USE_PNGGCCRD \
|
|
||||||
# -DGAS_VERSION="\"${GAS_VERSION}\""
|
|
||||||
# [note that -Wall is a gcc-specific compilation flag ("all warnings on")]
|
# [note that -Wall is a gcc-specific compilation flag ("all warnings on")]
|
||||||
LDFLAGS =
|
LDFLAGS =
|
||||||
O = .o
|
O = .o
|
||||||
@@ -44,7 +42,7 @@ ZOBJS = adler32$(O) compress$(O) crc32$(O) deflate$(O) gzio$(O) \
|
|||||||
|
|
||||||
OBJS = pngcrush$(O) png$(O) pngerror$(O) pngget$(O) pngmem$(O) \
|
OBJS = pngcrush$(O) png$(O) pngerror$(O) pngget$(O) pngmem$(O) \
|
||||||
pngpread$(O) pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) \
|
pngpread$(O) pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) \
|
||||||
pngset$(O) pngtrans$(O) pngwio$(O) pngwrite$(O) pnggccrd$(O) \
|
pngset$(O) pngtrans$(O) pngwio$(O) pngwrite$(O) \
|
||||||
pngwtran$(O) pngwutil$(O) $(ZOBJS)
|
pngwtran$(O) pngwutil$(O) $(ZOBJS)
|
||||||
|
|
||||||
EXES = $(PNGCRUSH)$(E)
|
EXES = $(PNGCRUSH)$(E)
|
||||||
|
|||||||
44
adler32.c
44
adler32.c
@@ -1,5 +1,5 @@
|
|||||||
/* adler32.c -- compute the Adler-32 checksum of a data stream
|
/* adler32.c -- compute the Adler-32 checksum of a data stream
|
||||||
* Copyright (C) 1995-2004 Mark Adler
|
* Copyright (C) 1995-2006 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -8,6 +8,15 @@
|
|||||||
#define ZLIB_INTERNAL
|
#define ZLIB_INTERNAL
|
||||||
#include "zlib.h"
|
#include "zlib.h"
|
||||||
|
|
||||||
|
#define local static
|
||||||
|
|
||||||
|
#ifdef _LARGEFILE64_SOURCE
|
||||||
|
local uLong adler32_combine_(uLong adler1, uLong adler2, off64_t len2);
|
||||||
|
#else
|
||||||
|
local uLong adler32_combine_(uLong adler1, uLong adler2, z_off_t len2);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define BASE 65521UL /* largest prime smaller than 65536 */
|
#define BASE 65521UL /* largest prime smaller than 65536 */
|
||||||
#define NMAX 5552
|
#define NMAX 5552
|
||||||
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
||||||
@@ -125,10 +134,14 @@ uLong ZEXPORT adler32(adler, buf, len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
uLong ZEXPORT adler32_combine(adler1, adler2, len2)
|
local uLong adler32_combine_(adler1, adler2, len2)
|
||||||
uLong adler1;
|
uLong adler1;
|
||||||
uLong adler2;
|
uLong adler2;
|
||||||
|
#ifdef _LARGEFILE64_SOURCE
|
||||||
|
off64_t len2;
|
||||||
|
#else
|
||||||
z_off_t len2;
|
z_off_t len2;
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
unsigned long sum1;
|
unsigned long sum1;
|
||||||
unsigned long sum2;
|
unsigned long sum2;
|
||||||
@@ -147,3 +160,30 @@ uLong ZEXPORT adler32_combine(adler1, adler2, len2)
|
|||||||
if (sum2 > BASE) sum2 -= BASE;
|
if (sum2 > BASE) sum2 -= BASE;
|
||||||
return sum1 | (sum2 << 16);
|
return sum1 | (sum2 << 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ========================================================================= */
|
||||||
|
uLong ZEXPORT adler32_combine(adler1, adler2, len2)
|
||||||
|
uLong adler1;
|
||||||
|
uLong adler2;
|
||||||
|
z_off_t len2;
|
||||||
|
{
|
||||||
|
return adler32_combine_(adler1, adler2, len2);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _LARGEFILE64_SOURCE
|
||||||
|
uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
|
||||||
|
uLong adler1;
|
||||||
|
uLong adler2;
|
||||||
|
off64_t len2;
|
||||||
|
{
|
||||||
|
return adler32_combine_(adler1, adler2, len2);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
|
||||||
|
uLong adler1;
|
||||||
|
uLong adler2;
|
||||||
|
z_off_t len2;
|
||||||
|
{
|
||||||
|
return adler32_combine_(adler1, adler2, len2);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* compress.c -- compress a memory buffer
|
/* compress.c -- compress a memory buffer
|
||||||
* Copyright (C) 1995-2003 Jean-loup Gailly.
|
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -75,5 +75,6 @@ int ZEXPORT compress (dest, destLen, source, sourceLen)
|
|||||||
uLong ZEXPORT compressBound (sourceLen)
|
uLong ZEXPORT compressBound (sourceLen)
|
||||||
uLong sourceLen;
|
uLong sourceLen;
|
||||||
{
|
{
|
||||||
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11;
|
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
|
||||||
|
(sourceLen >> 25) + 13;
|
||||||
}
|
}
|
||||||
|
|||||||
41
crc32.c
41
crc32.c
@@ -1,5 +1,5 @@
|
|||||||
/* crc32.c -- compute the CRC-32 of a data stream
|
/* crc32.c -- compute the CRC-32 of a data stream
|
||||||
* Copyright (C) 1995-2005 Mark Adler
|
* Copyright (C) 1995-2006 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*
|
*
|
||||||
* Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
|
* Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
|
||||||
@@ -68,6 +68,12 @@
|
|||||||
local unsigned long gf2_matrix_times OF((unsigned long *mat,
|
local unsigned long gf2_matrix_times OF((unsigned long *mat,
|
||||||
unsigned long vec));
|
unsigned long vec));
|
||||||
local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
|
local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
|
||||||
|
#ifdef _LARGEFILE64_SOURCE
|
||||||
|
local uLong crc32_combine_(uLong crc1, uLong crc2, off64_t len2);
|
||||||
|
#else
|
||||||
|
local uLong crc32_combine_(uLong crc1, uLong crc2, z_off_t len2);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef DYNAMIC_CRC_TABLE
|
#ifdef DYNAMIC_CRC_TABLE
|
||||||
|
|
||||||
@@ -367,10 +373,14 @@ local void gf2_matrix_square(square, mat)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
uLong ZEXPORT crc32_combine(crc1, crc2, len2)
|
local uLong crc32_combine_(crc1, crc2, len2)
|
||||||
uLong crc1;
|
uLong crc1;
|
||||||
uLong crc2;
|
uLong crc2;
|
||||||
|
#ifdef _LARGEFILE64_SOURCE
|
||||||
|
off64_t len2;
|
||||||
|
#else
|
||||||
z_off_t len2;
|
z_off_t len2;
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
unsigned long row;
|
unsigned long row;
|
||||||
@@ -421,3 +431,30 @@ uLong ZEXPORT crc32_combine(crc1, crc2, len2)
|
|||||||
crc1 ^= crc2;
|
crc1 ^= crc2;
|
||||||
return crc1;
|
return crc1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ========================================================================= */
|
||||||
|
uLong ZEXPORT crc32_combine(crc1, crc2, len2)
|
||||||
|
uLong crc1;
|
||||||
|
uLong crc2;
|
||||||
|
z_off_t len2;
|
||||||
|
{
|
||||||
|
return crc32_combine_(crc1, crc2, len2);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _LARGEFILE64_SOURCE
|
||||||
|
uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
|
||||||
|
uLong crc1;
|
||||||
|
uLong crc2;
|
||||||
|
off64_t len2;
|
||||||
|
{
|
||||||
|
return crc32_combine_(crc1, crc2, len2);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
|
||||||
|
uLong crc1;
|
||||||
|
uLong crc2;
|
||||||
|
z_off_t len2;
|
||||||
|
{
|
||||||
|
return crc32_combine_(crc1, crc2, len2);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
64
deflate.c
64
deflate.c
@@ -1,5 +1,5 @@
|
|||||||
/* deflate.c -- compress data using the deflation algorithm
|
/* deflate.c -- compress data using the deflation algorithm
|
||||||
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
* Copyright (C) 1995-2006 Jean-loup Gailly.
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
#include "deflate.h"
|
#include "deflate.h"
|
||||||
|
|
||||||
const char deflate_copyright[] =
|
const char deflate_copyright[] =
|
||||||
" deflate 1.2.3 Copyright 1995-2005 Jean-loup Gailly ";
|
" deflate 1.2.3.3 Copyright 1995-2006 Jean-loup Gailly ";
|
||||||
/*
|
/*
|
||||||
If you use the zlib library in a product, an acknowledgment is welcome
|
If you use the zlib library in a product, an acknowledgment is welcome
|
||||||
in the documentation of your product. If for some reason you cannot
|
in the documentation of your product. If for some reason you cannot
|
||||||
@@ -106,7 +106,7 @@ local void check_match OF((deflate_state *s, IPos start, IPos match,
|
|||||||
/* Tail of hash chains */
|
/* Tail of hash chains */
|
||||||
|
|
||||||
#ifndef TOO_FAR
|
#ifndef TOO_FAR
|
||||||
# define TOO_FAR 32767
|
# define TOO_FAR 4096
|
||||||
#endif
|
#endif
|
||||||
/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
|
/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
|
||||||
|
|
||||||
@@ -481,33 +481,65 @@ int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
|
|||||||
* resulting from using fixed blocks instead of stored blocks, which deflate
|
* resulting from using fixed blocks instead of stored blocks, which deflate
|
||||||
* can emit on compressed data for some combinations of the parameters.
|
* can emit on compressed data for some combinations of the parameters.
|
||||||
*
|
*
|
||||||
* This function could be more sophisticated to provide closer upper bounds
|
* This function could be more sophisticated to provide closer upper bounds for
|
||||||
* for every combination of windowBits and memLevel, as well as wrap.
|
* every combination of windowBits and memLevel. But even the conservative
|
||||||
* But even the conservative upper bound of about 14% expansion does not
|
* upper bound of about 14% expansion does not seem onerous for output buffer
|
||||||
* seem onerous for output buffer allocation.
|
* allocation.
|
||||||
*/
|
*/
|
||||||
uLong ZEXPORT deflateBound(strm, sourceLen)
|
uLong ZEXPORT deflateBound(strm, sourceLen)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
uLong sourceLen;
|
uLong sourceLen;
|
||||||
{
|
{
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
uLong destLen;
|
uLong complen, wraplen;
|
||||||
|
Bytef *str;
|
||||||
|
|
||||||
/* conservative upper bound */
|
/* conservative upper bound for compressed data */
|
||||||
destLen = sourceLen +
|
complen = sourceLen +
|
||||||
((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 11;
|
((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5;
|
||||||
|
|
||||||
/* if can't get parameters, return conservative bound */
|
/* if can't get parameters, return conservative bound plus zlib wrapper */
|
||||||
if (strm == Z_NULL || strm->state == Z_NULL)
|
if (strm == Z_NULL || strm->state == Z_NULL)
|
||||||
return destLen;
|
return complen + 6;
|
||||||
|
|
||||||
|
/* compute wrapper length */
|
||||||
|
s = strm->state;
|
||||||
|
switch (s->wrap) {
|
||||||
|
case 0: /* raw deflate */
|
||||||
|
wraplen = 0;
|
||||||
|
break;
|
||||||
|
case 1: /* zlib wrapper */
|
||||||
|
wraplen = 6 + (s->strstart ? 4 : 0);
|
||||||
|
break;
|
||||||
|
case 2: /* gzip wrapper */
|
||||||
|
wraplen = 18;
|
||||||
|
if (s->gzhead != NULL) { /* user-supplied gzip header */
|
||||||
|
if (s->gzhead->extra != NULL)
|
||||||
|
wraplen += 2 + s->gzhead->extra_len;
|
||||||
|
str = s->gzhead->name;
|
||||||
|
if (str != NULL)
|
||||||
|
do {
|
||||||
|
wraplen++;
|
||||||
|
} while (*str++);
|
||||||
|
str = s->gzhead->comment;
|
||||||
|
if (str != NULL)
|
||||||
|
do {
|
||||||
|
wraplen++;
|
||||||
|
} while (*str++);
|
||||||
|
if (s->gzhead->hcrc)
|
||||||
|
wraplen += 2;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default: /* for compiler happiness */
|
||||||
|
wraplen = 6;
|
||||||
|
}
|
||||||
|
|
||||||
/* if not default parameters, return conservative bound */
|
/* if not default parameters, return conservative bound */
|
||||||
s = strm->state;
|
|
||||||
if (s->w_bits != 15 || s->hash_bits != 8 + 7)
|
if (s->w_bits != 15 || s->hash_bits != 8 + 7)
|
||||||
return destLen;
|
return complen + wraplen;
|
||||||
|
|
||||||
/* default settings: return tight bound for that case */
|
/* default settings: return tight bound for that case */
|
||||||
return compressBound(sourceLen);
|
return compressBound(sourceLen) - 6 + wraplen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* deflate.h -- internal compression state
|
/* deflate.h -- internal compression state
|
||||||
* Copyright (C) 1995-2004 Jean-loup Gailly
|
* Copyright (C) 1995-2005 Jean-loup Gailly
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
138
gzio.c
138
gzio.c
@@ -1,5 +1,5 @@
|
|||||||
/* gzio.c -- IO on .gz files
|
/* gzio.c -- IO on .gz files
|
||||||
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
* Copyright (C) 1995-2006 Jean-loup Gailly.
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*
|
*
|
||||||
* Compile this file with -DNO_GZCOMPRESS to avoid the compression code.
|
* Compile this file with -DNO_GZCOMPRESS to avoid the compression code.
|
||||||
@@ -7,9 +7,17 @@
|
|||||||
|
|
||||||
/* @(#) $Id$ */
|
/* @(#) $Id$ */
|
||||||
|
|
||||||
#include <stdio.h>
|
#ifdef _LARGEFILE64_SOURCE
|
||||||
|
# ifndef _LARGEFILE_SOURCE
|
||||||
|
# define _LARGEFILE_SOURCE
|
||||||
|
# endif
|
||||||
|
# ifdef _FILE_OFFSET_BITS
|
||||||
|
# undef _FILE_OFFSET_BITS
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "zutil.h"
|
#include "zutil.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef NO_DEFLATE /* for compatibility with old definition */
|
#ifdef NO_DEFLATE /* for compatibility with old definition */
|
||||||
# define NO_GZCOMPRESS
|
# define NO_GZCOMPRESS
|
||||||
@@ -40,6 +48,14 @@ extern voidp malloc OF((uInt size));
|
|||||||
extern void free OF((voidpf ptr));
|
extern void free OF((voidpf ptr));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef NO_FSEEKO
|
||||||
|
# define FSEEK fseek
|
||||||
|
# define FTELL ftell
|
||||||
|
#else
|
||||||
|
# define FSEEK fseeko
|
||||||
|
# define FTELL ftello
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ALLOC(size) malloc(size)
|
#define ALLOC(size) malloc(size)
|
||||||
#define TRYFREE(p) {if (p) free(p);}
|
#define TRYFREE(p) {if (p) free(p);}
|
||||||
|
|
||||||
@@ -65,15 +81,27 @@ typedef struct gz_stream {
|
|||||||
char *path; /* path name for debugging only */
|
char *path; /* path name for debugging only */
|
||||||
int transparent; /* 1 if input file is not a .gz file */
|
int transparent; /* 1 if input file is not a .gz file */
|
||||||
char mode; /* 'w' or 'r' */
|
char mode; /* 'w' or 'r' */
|
||||||
|
#ifdef _LARGEFILE64_SOURCE
|
||||||
|
off64_t start; /* start of compressed data in file (header skipped) */
|
||||||
|
off64_t in; /* bytes into deflate or inflate */
|
||||||
|
off64_t out; /* bytes out of deflate or inflate */
|
||||||
|
#else
|
||||||
z_off_t start; /* start of compressed data in file (header skipped) */
|
z_off_t start; /* start of compressed data in file (header skipped) */
|
||||||
z_off_t in; /* bytes into deflate or inflate */
|
z_off_t in; /* bytes into deflate or inflate */
|
||||||
z_off_t out; /* bytes out of deflate or inflate */
|
z_off_t out; /* bytes out of deflate or inflate */
|
||||||
|
#endif
|
||||||
int back; /* one character push-back */
|
int back; /* one character push-back */
|
||||||
int last; /* true if push-back is last character */
|
int last; /* true if push-back is last character */
|
||||||
} gz_stream;
|
} gz_stream;
|
||||||
|
|
||||||
|
|
||||||
local gzFile gz_open OF((const char *path, const char *mode, int fd));
|
local gzFile gz_open OF((const char *path, const char *mode, int fd,
|
||||||
|
int use64));
|
||||||
|
#ifdef _LARGEFILE64_SOURCE
|
||||||
|
local off64_t gz_seek OF((gzFile file, off64_t offset, int whence, int use64));
|
||||||
|
#else
|
||||||
|
local z_off_t gz_seek OF((gzFile file, z_off_t offset, int whence, int use64));
|
||||||
|
#endif
|
||||||
local int do_flush OF((gzFile file, int flush));
|
local int do_flush OF((gzFile file, int flush));
|
||||||
local int get_byte OF((gz_stream *s));
|
local int get_byte OF((gz_stream *s));
|
||||||
local void check_header OF((gz_stream *s));
|
local void check_header OF((gz_stream *s));
|
||||||
@@ -90,10 +118,11 @@ local uLong getLong OF((gz_stream *s));
|
|||||||
can be checked to distinguish the two cases (if errno is zero, the
|
can be checked to distinguish the two cases (if errno is zero, the
|
||||||
zlib error is Z_MEM_ERROR).
|
zlib error is Z_MEM_ERROR).
|
||||||
*/
|
*/
|
||||||
local gzFile gz_open (path, mode, fd)
|
local gzFile gz_open (path, mode, fd, use64)
|
||||||
const char *path;
|
const char *path;
|
||||||
const char *mode;
|
const char *mode;
|
||||||
int fd;
|
int fd;
|
||||||
|
int use64;
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
int level = Z_DEFAULT_COMPRESSION; /* compression level */
|
int level = Z_DEFAULT_COMPRESSION; /* compression level */
|
||||||
@@ -165,12 +194,7 @@ local gzFile gz_open (path, mode, fd)
|
|||||||
s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE);
|
s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE);
|
||||||
|
|
||||||
err = inflateInit2(&(s->stream), -MAX_WBITS);
|
err = inflateInit2(&(s->stream), -MAX_WBITS);
|
||||||
/* windowBits is passed < 0 to tell that there is no zlib header.
|
/* windowBits is passed < 0 to tell that there is no zlib header */
|
||||||
* Note that in this case inflate *requires* an extra "dummy" byte
|
|
||||||
* after the compressed stream in order to complete decompression and
|
|
||||||
* return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are
|
|
||||||
* present after the compressed stream.
|
|
||||||
*/
|
|
||||||
if (err != Z_OK || s->inbuf == Z_NULL) {
|
if (err != Z_OK || s->inbuf == Z_NULL) {
|
||||||
return destroy(s), (gzFile)Z_NULL;
|
return destroy(s), (gzFile)Z_NULL;
|
||||||
}
|
}
|
||||||
@@ -178,7 +202,8 @@ local gzFile gz_open (path, mode, fd)
|
|||||||
s->stream.avail_out = Z_BUFSIZE;
|
s->stream.avail_out = Z_BUFSIZE;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode);
|
s->file = fd < 0 ? (use64 ? F_OPEN64(path, fmode) : F_OPEN(path, fmode)) :
|
||||||
|
(FILE*)fdopen(fd, fmode);
|
||||||
|
|
||||||
if (s->file == NULL) {
|
if (s->file == NULL) {
|
||||||
return destroy(s), (gzFile)Z_NULL;
|
return destroy(s), (gzFile)Z_NULL;
|
||||||
@@ -187,7 +212,10 @@ local gzFile gz_open (path, mode, fd)
|
|||||||
/* Write a very simple .gz header:
|
/* Write a very simple .gz header:
|
||||||
*/
|
*/
|
||||||
fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1],
|
fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1],
|
||||||
Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE);
|
Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, level == 9 ? 2 :
|
||||||
|
(strategy >= Z_HUFFMAN_ONLY ||
|
||||||
|
(level != Z_DEFAULT_COMPRESSION && level < 2) ?
|
||||||
|
4 : 0) /*xflags*/, OS_CODE);
|
||||||
s->start = 10L;
|
s->start = 10L;
|
||||||
/* We use 10L instead of ftell(s->file) to because ftell causes an
|
/* We use 10L instead of ftell(s->file) to because ftell causes an
|
||||||
* fflush on some systems. This version of the library doesn't use
|
* fflush on some systems. This version of the library doesn't use
|
||||||
@@ -196,7 +224,7 @@ local gzFile gz_open (path, mode, fd)
|
|||||||
*/
|
*/
|
||||||
} else {
|
} else {
|
||||||
check_header(s); /* skip the .gz header */
|
check_header(s); /* skip the .gz header */
|
||||||
s->start = ftell(s->file) - s->stream.avail_in;
|
s->start = FTELL(s->file) - s->stream.avail_in;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (gzFile)s;
|
return (gzFile)s;
|
||||||
@@ -209,7 +237,17 @@ gzFile ZEXPORT gzopen (path, mode)
|
|||||||
const char *path;
|
const char *path;
|
||||||
const char *mode;
|
const char *mode;
|
||||||
{
|
{
|
||||||
return gz_open (path, mode, -1);
|
return gz_open (path, mode, -1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ===========================================================================
|
||||||
|
Opens a gzip (.gz) file for reading or writing for 64-bit offsets
|
||||||
|
*/
|
||||||
|
gzFile ZEXPORT gzopen64 (path, mode)
|
||||||
|
const char *path;
|
||||||
|
const char *mode;
|
||||||
|
{
|
||||||
|
return gz_open (path, mode, -1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
@@ -225,7 +263,7 @@ gzFile ZEXPORT gzdopen (fd, mode)
|
|||||||
if (fd < 0) return (gzFile)Z_NULL;
|
if (fd < 0) return (gzFile)Z_NULL;
|
||||||
sprintf(name, "<fd:%d>", fd); /* for debugging */
|
sprintf(name, "<fd:%d>", fd); /* for debugging */
|
||||||
|
|
||||||
return gz_open (name, mode, fd);
|
return gz_open (name, mode, fd, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
@@ -256,7 +294,7 @@ int ZEXPORT gzsetparams (file, level, strategy)
|
|||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
Read a byte from a gz_stream; update next_in and avail_in. Return EOF
|
Read a byte from a gz_stream; update next_in and avail_in. Return EOF
|
||||||
for end of file.
|
for end of file.
|
||||||
IN assertion: the stream s has been sucessfully opened for reading.
|
IN assertion: the stream s has been successfully opened for reading.
|
||||||
*/
|
*/
|
||||||
local int get_byte(s)
|
local int get_byte(s)
|
||||||
gz_stream *s;
|
gz_stream *s;
|
||||||
@@ -281,7 +319,7 @@ local int get_byte(s)
|
|||||||
mode to transparent if the gzip magic header is not present; set s->err
|
mode to transparent if the gzip magic header is not present; set s->err
|
||||||
to Z_DATA_ERROR if the magic header is present but the rest of the header
|
to Z_DATA_ERROR if the magic header is present but the rest of the header
|
||||||
is incorrect.
|
is incorrect.
|
||||||
IN assertion: the stream s has already been created sucessfully;
|
IN assertion: the stream s has already been created successfully;
|
||||||
s->stream.avail_in is zero for the first time, but may be non-zero
|
s->stream.avail_in is zero for the first time, but may be non-zero
|
||||||
for concatenated .gz files.
|
for concatenated .gz files.
|
||||||
*/
|
*/
|
||||||
@@ -301,6 +339,7 @@ local void check_header(s)
|
|||||||
if (len) s->inbuf[0] = s->stream.next_in[0];
|
if (len) s->inbuf[0] = s->stream.next_in[0];
|
||||||
errno = 0;
|
errno = 0;
|
||||||
len = (uInt)fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file);
|
len = (uInt)fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file);
|
||||||
|
if (len == 0) s->z_eof = 1;
|
||||||
if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO;
|
if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO;
|
||||||
s->stream.avail_in += len;
|
s->stream.avail_in += len;
|
||||||
s->stream.next_in = s->inbuf;
|
s->stream.next_in = s->inbuf;
|
||||||
@@ -436,7 +475,7 @@ int ZEXPORT gzread (file, buf, len)
|
|||||||
s->stream.avail_out -= n;
|
s->stream.avail_out -= n;
|
||||||
s->stream.avail_in -= n;
|
s->stream.avail_in -= n;
|
||||||
}
|
}
|
||||||
if (s->stream.avail_out > 0) {
|
if (s->stream.avail_out > 0 && !feof(s->file)) {
|
||||||
s->stream.avail_out -=
|
s->stream.avail_out -=
|
||||||
(uInt)fread(next_out, 1, s->stream.avail_out, s->file);
|
(uInt)fread(next_out, 1, s->stream.avail_out, s->file);
|
||||||
}
|
}
|
||||||
@@ -764,10 +803,17 @@ int ZEXPORT gzflush (file, flush)
|
|||||||
SEEK_END is not implemented, returns error.
|
SEEK_END is not implemented, returns error.
|
||||||
In this version of the library, gzseek can be extremely slow.
|
In this version of the library, gzseek can be extremely slow.
|
||||||
*/
|
*/
|
||||||
z_off_t ZEXPORT gzseek (file, offset, whence)
|
#ifdef _LARGEFILE64_SOURCE
|
||||||
|
local off64_t gz_seek (file, offset, whence, use64)
|
||||||
|
gzFile file;
|
||||||
|
off64_t offset;
|
||||||
|
#else
|
||||||
|
local z_off_t gz_seek (file, offset, whence, use64)
|
||||||
gzFile file;
|
gzFile file;
|
||||||
z_off_t offset;
|
z_off_t offset;
|
||||||
|
#endif
|
||||||
int whence;
|
int whence;
|
||||||
|
int use64;
|
||||||
{
|
{
|
||||||
gz_stream *s = (gz_stream*)file;
|
gz_stream *s = (gz_stream*)file;
|
||||||
|
|
||||||
@@ -816,7 +862,13 @@ z_off_t ZEXPORT gzseek (file, offset, whence)
|
|||||||
s->back = EOF;
|
s->back = EOF;
|
||||||
s->stream.avail_in = 0;
|
s->stream.avail_in = 0;
|
||||||
s->stream.next_in = s->inbuf;
|
s->stream.next_in = s->inbuf;
|
||||||
if (fseek(s->file, offset, SEEK_SET) < 0) return -1L;
|
#ifdef _LARGEFILE64_SOURCE
|
||||||
|
if ((use64 ? fseeko64(s->file, offset, SEEK_SET) :
|
||||||
|
FSEEK(s->file, offset, SEEK_SET)) < 0)
|
||||||
|
return -1L;
|
||||||
|
#else
|
||||||
|
if (FSEEK(s->file, offset, SEEK_SET) < 0) return -1L;
|
||||||
|
#endif
|
||||||
|
|
||||||
s->in = s->out = offset;
|
s->in = s->out = offset;
|
||||||
return offset;
|
return offset;
|
||||||
@@ -851,6 +903,35 @@ z_off_t ZEXPORT gzseek (file, offset, whence)
|
|||||||
return s->out;
|
return s->out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ===========================================================================
|
||||||
|
Define external functions gzseek() and gzseek64() using local gz_seek().
|
||||||
|
*/
|
||||||
|
z_off_t ZEXPORT gzseek (file, offset, whence)
|
||||||
|
gzFile file;
|
||||||
|
z_off_t offset;
|
||||||
|
int whence;
|
||||||
|
{
|
||||||
|
return (z_off_t)gz_seek(file, offset, whence, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _LARGEFILE64_SOURCE
|
||||||
|
off64_t ZEXPORT gzseek64 (file, offset, whence)
|
||||||
|
gzFile file;
|
||||||
|
off64_t offset;
|
||||||
|
int whence;
|
||||||
|
{
|
||||||
|
return gz_seek(file, offset, whence, 1);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
z_off_t ZEXPORT gzseek64 (file, offset, whence)
|
||||||
|
gzFile file;
|
||||||
|
z_off_t offset;
|
||||||
|
int whence;
|
||||||
|
{
|
||||||
|
return gz_seek(file, offset, whence, 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
Rewinds input file.
|
Rewinds input file.
|
||||||
*/
|
*/
|
||||||
@@ -870,7 +951,7 @@ int ZEXPORT gzrewind (file)
|
|||||||
if (!s->transparent) (void)inflateReset(&s->stream);
|
if (!s->transparent) (void)inflateReset(&s->stream);
|
||||||
s->in = 0;
|
s->in = 0;
|
||||||
s->out = 0;
|
s->out = 0;
|
||||||
return fseek(s->file, s->start, SEEK_SET);
|
return FSEEK(s->file, s->start, SEEK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
@@ -884,6 +965,19 @@ z_off_t ZEXPORT gztell (file)
|
|||||||
return gzseek(file, 0L, SEEK_CUR);
|
return gzseek(file, 0L, SEEK_CUR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ===========================================================================
|
||||||
|
64-bit version
|
||||||
|
*/
|
||||||
|
#ifdef _LARGEFILE64_SOURCE
|
||||||
|
off64_t ZEXPORT gztell64 (file)
|
||||||
|
#else
|
||||||
|
z_off_t ZEXPORT gztell64 (file)
|
||||||
|
#endif
|
||||||
|
gzFile file;
|
||||||
|
{
|
||||||
|
return gzseek64(file, 0L, SEEK_CUR);
|
||||||
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
Returns 1 when EOF has previously been detected reading the given
|
Returns 1 when EOF has previously been detected reading the given
|
||||||
input stream, otherwise zero.
|
input stream, otherwise zero.
|
||||||
@@ -971,7 +1065,7 @@ int ZEXPORT gzclose (file)
|
|||||||
return destroy((gz_stream*)file);
|
return destroy((gz_stream*)file);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef STDC
|
#if defined(STDC) && !defined(_WIN32_WCE)
|
||||||
# define zstrerror(errnum) strerror(errnum)
|
# define zstrerror(errnum) strerror(errnum)
|
||||||
#else
|
#else
|
||||||
# define zstrerror(errnum) ""
|
# define zstrerror(errnum) ""
|
||||||
|
|||||||
80
infback.c
80
infback.c
@@ -1,5 +1,5 @@
|
|||||||
/* infback.c -- inflate using a call-back interface
|
/* infback.c -- inflate using a call-back interface
|
||||||
* Copyright (C) 1995-2005 Mark Adler
|
* Copyright (C) 1995-2006 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ void FAR *out_desc;
|
|||||||
unsigned bits; /* bits in bit buffer */
|
unsigned bits; /* bits in bit buffer */
|
||||||
unsigned copy; /* number of stored or match bytes to copy */
|
unsigned copy; /* number of stored or match bytes to copy */
|
||||||
unsigned char FAR *from; /* where to copy match bytes from */
|
unsigned char FAR *from; /* where to copy match bytes from */
|
||||||
code this; /* current decoding table entry */
|
code here; /* current decoding table entry */
|
||||||
code last; /* parent table entry */
|
code last; /* parent table entry */
|
||||||
unsigned len; /* length to copy for repeats, bits to drop */
|
unsigned len; /* length to copy for repeats, bits to drop */
|
||||||
int ret; /* return code */
|
int ret; /* return code */
|
||||||
@@ -389,19 +389,19 @@ void FAR *out_desc;
|
|||||||
state->have = 0;
|
state->have = 0;
|
||||||
while (state->have < state->nlen + state->ndist) {
|
while (state->have < state->nlen + state->ndist) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->lencode[BITS(state->lenbits)];
|
here = state->lencode[BITS(state->lenbits)];
|
||||||
if ((unsigned)(this.bits) <= bits) break;
|
if ((unsigned)(here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
if (this.val < 16) {
|
if (here.val < 16) {
|
||||||
NEEDBITS(this.bits);
|
NEEDBITS(here.bits);
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
state->lens[state->have++] = this.val;
|
state->lens[state->have++] = here.val;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (this.val == 16) {
|
if (here.val == 16) {
|
||||||
NEEDBITS(this.bits + 2);
|
NEEDBITS(here.bits + 2);
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
if (state->have == 0) {
|
if (state->have == 0) {
|
||||||
strm->msg = (char *)"invalid bit length repeat";
|
strm->msg = (char *)"invalid bit length repeat";
|
||||||
state->mode = BAD;
|
state->mode = BAD;
|
||||||
@@ -411,16 +411,16 @@ void FAR *out_desc;
|
|||||||
copy = 3 + BITS(2);
|
copy = 3 + BITS(2);
|
||||||
DROPBITS(2);
|
DROPBITS(2);
|
||||||
}
|
}
|
||||||
else if (this.val == 17) {
|
else if (here.val == 17) {
|
||||||
NEEDBITS(this.bits + 3);
|
NEEDBITS(here.bits + 3);
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
len = 0;
|
len = 0;
|
||||||
copy = 3 + BITS(3);
|
copy = 3 + BITS(3);
|
||||||
DROPBITS(3);
|
DROPBITS(3);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
NEEDBITS(this.bits + 7);
|
NEEDBITS(here.bits + 7);
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
len = 0;
|
len = 0;
|
||||||
copy = 11 + BITS(7);
|
copy = 11 + BITS(7);
|
||||||
DROPBITS(7);
|
DROPBITS(7);
|
||||||
@@ -474,28 +474,28 @@ void FAR *out_desc;
|
|||||||
|
|
||||||
/* get a literal, length, or end-of-block code */
|
/* get a literal, length, or end-of-block code */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->lencode[BITS(state->lenbits)];
|
here = state->lencode[BITS(state->lenbits)];
|
||||||
if ((unsigned)(this.bits) <= bits) break;
|
if ((unsigned)(here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
if (this.op && (this.op & 0xf0) == 0) {
|
if (here.op && (here.op & 0xf0) == 0) {
|
||||||
last = this;
|
last = here;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->lencode[last.val +
|
here = state->lencode[last.val +
|
||||||
(BITS(last.bits + last.op) >> last.bits)];
|
(BITS(last.bits + last.op) >> last.bits)];
|
||||||
if ((unsigned)(last.bits + this.bits) <= bits) break;
|
if ((unsigned)(last.bits + here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
DROPBITS(last.bits);
|
DROPBITS(last.bits);
|
||||||
}
|
}
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
state->length = (unsigned)this.val;
|
state->length = (unsigned)here.val;
|
||||||
|
|
||||||
/* process literal */
|
/* process literal */
|
||||||
if (this.op == 0) {
|
if (here.op == 0) {
|
||||||
Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
|
Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
|
||||||
"inflate: literal '%c'\n" :
|
"inflate: literal '%c'\n" :
|
||||||
"inflate: literal 0x%02x\n", this.val));
|
"inflate: literal 0x%02x\n", here.val));
|
||||||
ROOM();
|
ROOM();
|
||||||
*put++ = (unsigned char)(state->length);
|
*put++ = (unsigned char)(state->length);
|
||||||
left--;
|
left--;
|
||||||
@@ -504,21 +504,21 @@ void FAR *out_desc;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* process end of block */
|
/* process end of block */
|
||||||
if (this.op & 32) {
|
if (here.op & 32) {
|
||||||
Tracevv((stderr, "inflate: end of block\n"));
|
Tracevv((stderr, "inflate: end of block\n"));
|
||||||
state->mode = TYPE;
|
state->mode = TYPE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* invalid code */
|
/* invalid code */
|
||||||
if (this.op & 64) {
|
if (here.op & 64) {
|
||||||
strm->msg = (char *)"invalid literal/length code";
|
strm->msg = (char *)"invalid literal/length code";
|
||||||
state->mode = BAD;
|
state->mode = BAD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* length code -- get extra bits, if any */
|
/* length code -- get extra bits, if any */
|
||||||
state->extra = (unsigned)(this.op) & 15;
|
state->extra = (unsigned)(here.op) & 15;
|
||||||
if (state->extra != 0) {
|
if (state->extra != 0) {
|
||||||
NEEDBITS(state->extra);
|
NEEDBITS(state->extra);
|
||||||
state->length += BITS(state->extra);
|
state->length += BITS(state->extra);
|
||||||
@@ -528,30 +528,30 @@ void FAR *out_desc;
|
|||||||
|
|
||||||
/* get distance code */
|
/* get distance code */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->distcode[BITS(state->distbits)];
|
here = state->distcode[BITS(state->distbits)];
|
||||||
if ((unsigned)(this.bits) <= bits) break;
|
if ((unsigned)(here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
if ((this.op & 0xf0) == 0) {
|
if ((here.op & 0xf0) == 0) {
|
||||||
last = this;
|
last = here;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->distcode[last.val +
|
here = state->distcode[last.val +
|
||||||
(BITS(last.bits + last.op) >> last.bits)];
|
(BITS(last.bits + last.op) >> last.bits)];
|
||||||
if ((unsigned)(last.bits + this.bits) <= bits) break;
|
if ((unsigned)(last.bits + here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
DROPBITS(last.bits);
|
DROPBITS(last.bits);
|
||||||
}
|
}
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
if (this.op & 64) {
|
if (here.op & 64) {
|
||||||
strm->msg = (char *)"invalid distance code";
|
strm->msg = (char *)"invalid distance code";
|
||||||
state->mode = BAD;
|
state->mode = BAD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
state->offset = (unsigned)this.val;
|
state->offset = (unsigned)here.val;
|
||||||
|
|
||||||
/* get distance extra bits, if any */
|
/* get distance extra bits, if any */
|
||||||
state->extra = (unsigned)(this.op) & 15;
|
state->extra = (unsigned)(here.op) & 15;
|
||||||
if (state->extra != 0) {
|
if (state->extra != 0) {
|
||||||
NEEDBITS(state->extra);
|
NEEDBITS(state->extra);
|
||||||
state->offset += BITS(state->extra);
|
state->offset += BITS(state->extra);
|
||||||
|
|||||||
57
inffast.c
57
inffast.c
@@ -1,5 +1,5 @@
|
|||||||
/* inffast.c -- fast decoding
|
/* inffast.c -- fast decoding
|
||||||
* Copyright (C) 1995-2004 Mark Adler
|
* Copyright (C) 1995-2006 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
|||||||
code const FAR *dcode; /* local strm->distcode */
|
code const FAR *dcode; /* local strm->distcode */
|
||||||
unsigned lmask; /* mask for first level of length codes */
|
unsigned lmask; /* mask for first level of length codes */
|
||||||
unsigned dmask; /* mask for first level of distance codes */
|
unsigned dmask; /* mask for first level of distance codes */
|
||||||
code this; /* retrieved table entry */
|
code here; /* retrieved table entry */
|
||||||
unsigned op; /* code bits, operation, extra bits, or */
|
unsigned op; /* code bits, operation, extra bits, or */
|
||||||
/* window position, window bytes to copy */
|
/* window position, window bytes to copy */
|
||||||
unsigned len; /* match length, unused bytes */
|
unsigned len; /* match length, unused bytes */
|
||||||
@@ -124,20 +124,20 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
|||||||
hold += (unsigned long)(PUP(in)) << bits;
|
hold += (unsigned long)(PUP(in)) << bits;
|
||||||
bits += 8;
|
bits += 8;
|
||||||
}
|
}
|
||||||
this = lcode[hold & lmask];
|
here = lcode[hold & lmask];
|
||||||
dolen:
|
dolen:
|
||||||
op = (unsigned)(this.bits);
|
op = (unsigned)(here.bits);
|
||||||
hold >>= op;
|
hold >>= op;
|
||||||
bits -= op;
|
bits -= op;
|
||||||
op = (unsigned)(this.op);
|
op = (unsigned)(here.op);
|
||||||
if (op == 0) { /* literal */
|
if (op == 0) { /* literal */
|
||||||
Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
|
Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
|
||||||
"inflate: literal '%c'\n" :
|
"inflate: literal '%c'\n" :
|
||||||
"inflate: literal 0x%02x\n", this.val));
|
"inflate: literal 0x%02x\n", here.val));
|
||||||
PUP(out) = (unsigned char)(this.val);
|
PUP(out) = (unsigned char)(here.val);
|
||||||
}
|
}
|
||||||
else if (op & 16) { /* length base */
|
else if (op & 16) { /* length base */
|
||||||
len = (unsigned)(this.val);
|
len = (unsigned)(here.val);
|
||||||
op &= 15; /* number of extra bits */
|
op &= 15; /* number of extra bits */
|
||||||
if (op) {
|
if (op) {
|
||||||
if (bits < op) {
|
if (bits < op) {
|
||||||
@@ -155,14 +155,14 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
|||||||
hold += (unsigned long)(PUP(in)) << bits;
|
hold += (unsigned long)(PUP(in)) << bits;
|
||||||
bits += 8;
|
bits += 8;
|
||||||
}
|
}
|
||||||
this = dcode[hold & dmask];
|
here = dcode[hold & dmask];
|
||||||
dodist:
|
dodist:
|
||||||
op = (unsigned)(this.bits);
|
op = (unsigned)(here.bits);
|
||||||
hold >>= op;
|
hold >>= op;
|
||||||
bits -= op;
|
bits -= op;
|
||||||
op = (unsigned)(this.op);
|
op = (unsigned)(here.op);
|
||||||
if (op & 16) { /* distance base */
|
if (op & 16) { /* distance base */
|
||||||
dist = (unsigned)(this.val);
|
dist = (unsigned)(here.val);
|
||||||
op &= 15; /* number of extra bits */
|
op &= 15; /* number of extra bits */
|
||||||
if (bits < op) {
|
if (bits < op) {
|
||||||
hold += (unsigned long)(PUP(in)) << bits;
|
hold += (unsigned long)(PUP(in)) << bits;
|
||||||
@@ -187,9 +187,30 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
|||||||
if (dist > op) { /* see if copy from window */
|
if (dist > op) { /* see if copy from window */
|
||||||
op = dist - op; /* distance back in window */
|
op = dist - op; /* distance back in window */
|
||||||
if (op > whave) {
|
if (op > whave) {
|
||||||
strm->msg = (char *)"invalid distance too far back";
|
if (state->sane) {
|
||||||
state->mode = BAD;
|
strm->msg = (char *)"invalid distance too far back";
|
||||||
break;
|
state->mode = BAD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
|
||||||
|
if (len <= op - whave) {
|
||||||
|
do {
|
||||||
|
PUP(out) = 0;
|
||||||
|
} while (--len);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
len -= op - whave;
|
||||||
|
do {
|
||||||
|
PUP(out) = 0;
|
||||||
|
} while (--op > whave);
|
||||||
|
if (op == 0) {
|
||||||
|
from = out - dist;
|
||||||
|
do {
|
||||||
|
PUP(out) = PUP(from);
|
||||||
|
} while (--len);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
from = window - OFF;
|
from = window - OFF;
|
||||||
if (write == 0) { /* very common case */
|
if (write == 0) { /* very common case */
|
||||||
@@ -259,7 +280,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((op & 64) == 0) { /* 2nd level distance code */
|
else if ((op & 64) == 0) { /* 2nd level distance code */
|
||||||
this = dcode[this.val + (hold & ((1U << op) - 1))];
|
here = dcode[here.val + (hold & ((1U << op) - 1))];
|
||||||
goto dodist;
|
goto dodist;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -269,7 +290,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((op & 64) == 0) { /* 2nd level length code */
|
else if ((op & 64) == 0) { /* 2nd level length code */
|
||||||
this = lcode[this.val + (hold & ((1U << op) - 1))];
|
here = lcode[here.val + (hold & ((1U << op) - 1))];
|
||||||
goto dolen;
|
goto dolen;
|
||||||
}
|
}
|
||||||
else if (op & 32) { /* end-of-block */
|
else if (op & 32) { /* end-of-block */
|
||||||
|
|||||||
123
inflate.c
123
inflate.c
@@ -1,5 +1,5 @@
|
|||||||
/* inflate.c -- zlib decompression
|
/* inflate.c -- zlib decompression
|
||||||
* Copyright (C) 1995-2005 Mark Adler
|
* Copyright (C) 1995-2006 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -121,6 +121,7 @@ z_streamp strm;
|
|||||||
state->hold = 0;
|
state->hold = 0;
|
||||||
state->bits = 0;
|
state->bits = 0;
|
||||||
state->lencode = state->distcode = state->next = state->codes;
|
state->lencode = state->distcode = state->next = state->codes;
|
||||||
|
state->sane = 1;
|
||||||
Tracev((stderr, "inflate: reset\n"));
|
Tracev((stderr, "inflate: reset\n"));
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
@@ -564,7 +565,7 @@ int flush;
|
|||||||
unsigned in, out; /* save starting available input and output */
|
unsigned in, out; /* save starting available input and output */
|
||||||
unsigned copy; /* number of stored or match bytes to copy */
|
unsigned copy; /* number of stored or match bytes to copy */
|
||||||
unsigned char FAR *from; /* where to copy match bytes from */
|
unsigned char FAR *from; /* where to copy match bytes from */
|
||||||
code this; /* current decoding table entry */
|
code here; /* current decoding table entry */
|
||||||
code last; /* parent table entry */
|
code last; /* parent table entry */
|
||||||
unsigned len; /* length to copy for repeats, bits to drop */
|
unsigned len; /* length to copy for repeats, bits to drop */
|
||||||
int ret; /* return code */
|
int ret; /* return code */
|
||||||
@@ -876,19 +877,19 @@ int flush;
|
|||||||
case CODELENS:
|
case CODELENS:
|
||||||
while (state->have < state->nlen + state->ndist) {
|
while (state->have < state->nlen + state->ndist) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->lencode[BITS(state->lenbits)];
|
here = state->lencode[BITS(state->lenbits)];
|
||||||
if ((unsigned)(this.bits) <= bits) break;
|
if ((unsigned)(here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
if (this.val < 16) {
|
if (here.val < 16) {
|
||||||
NEEDBITS(this.bits);
|
NEEDBITS(here.bits);
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
state->lens[state->have++] = this.val;
|
state->lens[state->have++] = here.val;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (this.val == 16) {
|
if (here.val == 16) {
|
||||||
NEEDBITS(this.bits + 2);
|
NEEDBITS(here.bits + 2);
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
if (state->have == 0) {
|
if (state->have == 0) {
|
||||||
strm->msg = (char *)"invalid bit length repeat";
|
strm->msg = (char *)"invalid bit length repeat";
|
||||||
state->mode = BAD;
|
state->mode = BAD;
|
||||||
@@ -898,16 +899,16 @@ int flush;
|
|||||||
copy = 3 + BITS(2);
|
copy = 3 + BITS(2);
|
||||||
DROPBITS(2);
|
DROPBITS(2);
|
||||||
}
|
}
|
||||||
else if (this.val == 17) {
|
else if (here.val == 17) {
|
||||||
NEEDBITS(this.bits + 3);
|
NEEDBITS(here.bits + 3);
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
len = 0;
|
len = 0;
|
||||||
copy = 3 + BITS(3);
|
copy = 3 + BITS(3);
|
||||||
DROPBITS(3);
|
DROPBITS(3);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
NEEDBITS(this.bits + 7);
|
NEEDBITS(here.bits + 7);
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
len = 0;
|
len = 0;
|
||||||
copy = 11 + BITS(7);
|
copy = 11 + BITS(7);
|
||||||
DROPBITS(7);
|
DROPBITS(7);
|
||||||
@@ -955,40 +956,40 @@ int flush;
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->lencode[BITS(state->lenbits)];
|
here = state->lencode[BITS(state->lenbits)];
|
||||||
if ((unsigned)(this.bits) <= bits) break;
|
if ((unsigned)(here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
if (this.op && (this.op & 0xf0) == 0) {
|
if (here.op && (here.op & 0xf0) == 0) {
|
||||||
last = this;
|
last = here;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->lencode[last.val +
|
here = state->lencode[last.val +
|
||||||
(BITS(last.bits + last.op) >> last.bits)];
|
(BITS(last.bits + last.op) >> last.bits)];
|
||||||
if ((unsigned)(last.bits + this.bits) <= bits) break;
|
if ((unsigned)(last.bits + here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
DROPBITS(last.bits);
|
DROPBITS(last.bits);
|
||||||
}
|
}
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
state->length = (unsigned)this.val;
|
state->length = (unsigned)here.val;
|
||||||
if ((int)(this.op) == 0) {
|
if ((int)(here.op) == 0) {
|
||||||
Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
|
Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
|
||||||
"inflate: literal '%c'\n" :
|
"inflate: literal '%c'\n" :
|
||||||
"inflate: literal 0x%02x\n", this.val));
|
"inflate: literal 0x%02x\n", here.val));
|
||||||
state->mode = LIT;
|
state->mode = LIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (this.op & 32) {
|
if (here.op & 32) {
|
||||||
Tracevv((stderr, "inflate: end of block\n"));
|
Tracevv((stderr, "inflate: end of block\n"));
|
||||||
state->mode = TYPE;
|
state->mode = TYPE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (this.op & 64) {
|
if (here.op & 64) {
|
||||||
strm->msg = (char *)"invalid literal/length code";
|
strm->msg = (char *)"invalid literal/length code";
|
||||||
state->mode = BAD;
|
state->mode = BAD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
state->extra = (unsigned)(this.op) & 15;
|
state->extra = (unsigned)(here.op) & 15;
|
||||||
state->mode = LENEXT;
|
state->mode = LENEXT;
|
||||||
case LENEXT:
|
case LENEXT:
|
||||||
if (state->extra) {
|
if (state->extra) {
|
||||||
@@ -1000,28 +1001,28 @@ int flush;
|
|||||||
state->mode = DIST;
|
state->mode = DIST;
|
||||||
case DIST:
|
case DIST:
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->distcode[BITS(state->distbits)];
|
here = state->distcode[BITS(state->distbits)];
|
||||||
if ((unsigned)(this.bits) <= bits) break;
|
if ((unsigned)(here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
if ((this.op & 0xf0) == 0) {
|
if ((here.op & 0xf0) == 0) {
|
||||||
last = this;
|
last = here;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->distcode[last.val +
|
here = state->distcode[last.val +
|
||||||
(BITS(last.bits + last.op) >> last.bits)];
|
(BITS(last.bits + last.op) >> last.bits)];
|
||||||
if ((unsigned)(last.bits + this.bits) <= bits) break;
|
if ((unsigned)(last.bits + here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
DROPBITS(last.bits);
|
DROPBITS(last.bits);
|
||||||
}
|
}
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
if (this.op & 64) {
|
if (here.op & 64) {
|
||||||
strm->msg = (char *)"invalid distance code";
|
strm->msg = (char *)"invalid distance code";
|
||||||
state->mode = BAD;
|
state->mode = BAD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
state->offset = (unsigned)this.val;
|
state->offset = (unsigned)here.val;
|
||||||
state->extra = (unsigned)(this.op) & 15;
|
state->extra = (unsigned)(here.op) & 15;
|
||||||
state->mode = DISTEXT;
|
state->mode = DISTEXT;
|
||||||
case DISTEXT:
|
case DISTEXT:
|
||||||
if (state->extra) {
|
if (state->extra) {
|
||||||
@@ -1036,11 +1037,6 @@ int flush;
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (state->offset > state->whave + out - left) {
|
|
||||||
strm->msg = (char *)"invalid distance too far back";
|
|
||||||
state->mode = BAD;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Tracevv((stderr, "inflate: distance %u\n", state->offset));
|
Tracevv((stderr, "inflate: distance %u\n", state->offset));
|
||||||
state->mode = MATCH;
|
state->mode = MATCH;
|
||||||
case MATCH:
|
case MATCH:
|
||||||
@@ -1048,6 +1044,26 @@ int flush;
|
|||||||
copy = out - left;
|
copy = out - left;
|
||||||
if (state->offset > copy) { /* copy from window */
|
if (state->offset > copy) { /* copy from window */
|
||||||
copy = state->offset - copy;
|
copy = state->offset - copy;
|
||||||
|
if (copy > state->whave) {
|
||||||
|
if (state->sane) {
|
||||||
|
strm->msg = (char *)"invalid distance too far back";
|
||||||
|
state->mode = BAD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
|
||||||
|
Trace((stderr, "inflate.c too far\n"));
|
||||||
|
copy -= state->whave;
|
||||||
|
if (copy > state->length) copy = state->length;
|
||||||
|
if (copy > left) copy = left;
|
||||||
|
left -= copy;
|
||||||
|
state->length -= copy;
|
||||||
|
do {
|
||||||
|
*put++ = 0;
|
||||||
|
} while (--copy);
|
||||||
|
if (state->length == 0) state->mode = LEN;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
if (copy > state->write) {
|
if (copy > state->write) {
|
||||||
copy -= state->write;
|
copy -= state->write;
|
||||||
from = state->window + (state->wsize - copy);
|
from = state->window + (state->wsize - copy);
|
||||||
@@ -1366,3 +1382,20 @@ z_streamp source;
|
|||||||
dest->state = (struct internal_state FAR *)copy;
|
dest->state = (struct internal_state FAR *)copy;
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ZEXPORT inflateUndermine(strm, subvert)
|
||||||
|
z_streamp strm;
|
||||||
|
int subvert;
|
||||||
|
{
|
||||||
|
struct inflate_state FAR *state;
|
||||||
|
|
||||||
|
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
|
||||||
|
state = (struct inflate_state FAR *)strm->state;
|
||||||
|
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
|
||||||
|
state->sane = !subvert;
|
||||||
|
return Z_OK;
|
||||||
|
#else
|
||||||
|
state->sane = 1;
|
||||||
|
return Z_DATA_ERROR;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* inflate.h -- internal inflate state definition
|
/* inflate.h -- internal inflate state definition
|
||||||
* Copyright (C) 1995-2004 Mark Adler
|
* Copyright (C) 1995-2006 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ typedef enum {
|
|||||||
CHECK -> LENGTH -> DONE
|
CHECK -> LENGTH -> DONE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* state maintained between inflate() calls. Approximately 7K bytes. */
|
/* state maintained between inflate() calls. Approximately 10K bytes. */
|
||||||
struct inflate_state {
|
struct inflate_state {
|
||||||
inflate_mode mode; /* current inflate mode */
|
inflate_mode mode; /* current inflate mode */
|
||||||
int last; /* true if processing last block */
|
int last; /* true if processing last block */
|
||||||
@@ -112,4 +112,5 @@ struct inflate_state {
|
|||||||
unsigned short lens[320]; /* temporary storage for code lengths */
|
unsigned short lens[320]; /* temporary storage for code lengths */
|
||||||
unsigned short work[288]; /* work area for code table building */
|
unsigned short work[288]; /* work area for code table building */
|
||||||
code codes[ENOUGH]; /* space for code tables */
|
code codes[ENOUGH]; /* space for code tables */
|
||||||
|
int sane; /* if false, allow invalid distance too far */
|
||||||
};
|
};
|
||||||
|
|||||||
44
inftrees.c
44
inftrees.c
@@ -1,5 +1,5 @@
|
|||||||
/* inftrees.c -- generate Huffman trees for efficient decoding
|
/* inftrees.c -- generate Huffman trees for efficient decoding
|
||||||
* Copyright (C) 1995-2005 Mark Adler
|
* Copyright (C) 1995-2006 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
#define MAXBITS 15
|
#define MAXBITS 15
|
||||||
|
|
||||||
const char inflate_copyright[] =
|
const char inflate_copyright[] =
|
||||||
" inflate 1.2.3 Copyright 1995-2005 Mark Adler ";
|
" inflate 1.2.3.3 Copyright 1995-2006 Mark Adler ";
|
||||||
/*
|
/*
|
||||||
If you use the zlib library in a product, an acknowledgment is welcome
|
If you use the zlib library in a product, an acknowledgment is welcome
|
||||||
in the documentation of your product. If for some reason you cannot
|
in the documentation of your product. If for some reason you cannot
|
||||||
@@ -50,7 +50,7 @@ unsigned short FAR *work;
|
|||||||
unsigned fill; /* index for replicating entries */
|
unsigned fill; /* index for replicating entries */
|
||||||
unsigned low; /* low bits for current root entry */
|
unsigned low; /* low bits for current root entry */
|
||||||
unsigned mask; /* mask for low root bits */
|
unsigned mask; /* mask for low root bits */
|
||||||
code this; /* table entry for duplication */
|
code here; /* table entry for duplication */
|
||||||
code FAR *next; /* next available space in table */
|
code FAR *next; /* next available space in table */
|
||||||
const unsigned short FAR *base; /* base value table to use */
|
const unsigned short FAR *base; /* base value table to use */
|
||||||
const unsigned short FAR *extra; /* extra bits table to use */
|
const unsigned short FAR *extra; /* extra bits table to use */
|
||||||
@@ -62,7 +62,7 @@ unsigned short FAR *work;
|
|||||||
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
||||||
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
||||||
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
||||||
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 201, 196};
|
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 201, 203};
|
||||||
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
|
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
|
||||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
||||||
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
||||||
@@ -115,11 +115,11 @@ unsigned short FAR *work;
|
|||||||
if (count[max] != 0) break;
|
if (count[max] != 0) break;
|
||||||
if (root > max) root = max;
|
if (root > max) root = max;
|
||||||
if (max == 0) { /* no symbols to code at all */
|
if (max == 0) { /* no symbols to code at all */
|
||||||
this.op = (unsigned char)64; /* invalid code marker */
|
here.op = (unsigned char)64; /* invalid code marker */
|
||||||
this.bits = (unsigned char)1;
|
here.bits = (unsigned char)1;
|
||||||
this.val = (unsigned short)0;
|
here.val = (unsigned short)0;
|
||||||
*(*table)++ = this; /* make a table to force an error */
|
*(*table)++ = here; /* make a table to force an error */
|
||||||
*(*table)++ = this;
|
*(*table)++ = here;
|
||||||
*bits = 1;
|
*bits = 1;
|
||||||
return 0; /* no symbols, but wait for decoding to report error */
|
return 0; /* no symbols, but wait for decoding to report error */
|
||||||
}
|
}
|
||||||
@@ -215,18 +215,18 @@ unsigned short FAR *work;
|
|||||||
/* process all codes and make table entries */
|
/* process all codes and make table entries */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
/* create table entry */
|
/* create table entry */
|
||||||
this.bits = (unsigned char)(len - drop);
|
here.bits = (unsigned char)(len - drop);
|
||||||
if ((int)(work[sym]) < end) {
|
if ((int)(work[sym]) < end) {
|
||||||
this.op = (unsigned char)0;
|
here.op = (unsigned char)0;
|
||||||
this.val = work[sym];
|
here.val = work[sym];
|
||||||
}
|
}
|
||||||
else if ((int)(work[sym]) > end) {
|
else if ((int)(work[sym]) > end) {
|
||||||
this.op = (unsigned char)(extra[work[sym]]);
|
here.op = (unsigned char)(extra[work[sym]]);
|
||||||
this.val = base[work[sym]];
|
here.val = base[work[sym]];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.op = (unsigned char)(32 + 64); /* end of block */
|
here.op = (unsigned char)(32 + 64); /* end of block */
|
||||||
this.val = 0;
|
here.val = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* replicate for those indices with low len bits equal to huff */
|
/* replicate for those indices with low len bits equal to huff */
|
||||||
@@ -235,7 +235,7 @@ unsigned short FAR *work;
|
|||||||
min = fill; /* save offset to next table */
|
min = fill; /* save offset to next table */
|
||||||
do {
|
do {
|
||||||
fill -= incr;
|
fill -= incr;
|
||||||
next[(huff >> drop) + fill] = this;
|
next[(huff >> drop) + fill] = here;
|
||||||
} while (fill != 0);
|
} while (fill != 0);
|
||||||
|
|
||||||
/* backwards increment the len-bit code huff */
|
/* backwards increment the len-bit code huff */
|
||||||
@@ -295,20 +295,20 @@ unsigned short FAR *work;
|
|||||||
through high index bits. When the current sub-table is filled, the loop
|
through high index bits. When the current sub-table is filled, the loop
|
||||||
drops back to the root table to fill in any remaining entries there.
|
drops back to the root table to fill in any remaining entries there.
|
||||||
*/
|
*/
|
||||||
this.op = (unsigned char)64; /* invalid code marker */
|
here.op = (unsigned char)64; /* invalid code marker */
|
||||||
this.bits = (unsigned char)(len - drop);
|
here.bits = (unsigned char)(len - drop);
|
||||||
this.val = (unsigned short)0;
|
here.val = (unsigned short)0;
|
||||||
while (huff != 0) {
|
while (huff != 0) {
|
||||||
/* when done with sub-table, drop back to root table */
|
/* when done with sub-table, drop back to root table */
|
||||||
if (drop != 0 && (huff & mask) != low) {
|
if (drop != 0 && (huff & mask) != low) {
|
||||||
drop = 0;
|
drop = 0;
|
||||||
len = root;
|
len = root;
|
||||||
next = *table;
|
next = *table;
|
||||||
this.bits = (unsigned char)len;
|
here.bits = (unsigned char)len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* put invalid code marker in table */
|
/* put invalid code marker in table */
|
||||||
next[huff >> drop] = this;
|
next[huff >> drop] = here;
|
||||||
|
|
||||||
/* backwards increment the len-bit code huff */
|
/* backwards increment the len-bit code huff */
|
||||||
incr = 1U << (len - 1);
|
incr = 1U << (len - 1);
|
||||||
|
|||||||
322
minigzip.c
322
minigzip.c
@@ -1,322 +0,0 @@
|
|||||||
/* minigzip.c -- simulate gzip using the zlib compression library
|
|
||||||
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* minigzip is a minimal implementation of the gzip utility. This is
|
|
||||||
* only an example of using zlib and isn't meant to replace the
|
|
||||||
* full-featured gzip. No attempt is made to deal with file systems
|
|
||||||
* limiting names to 14 or 8+3 characters, etc... Error checking is
|
|
||||||
* very limited. So use minigzip only for testing; use gzip for the
|
|
||||||
* real thing. On MSDOS, use only on file names without extension
|
|
||||||
* or in pipe mode.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* @(#) $Id$ */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "zlib.h"
|
|
||||||
|
|
||||||
#ifdef STDC
|
|
||||||
# include <string.h>
|
|
||||||
# include <stdlib.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_MMAP
|
|
||||||
# include <sys/types.h>
|
|
||||||
# include <sys/mman.h>
|
|
||||||
# include <sys/stat.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
|
|
||||||
# include <fcntl.h>
|
|
||||||
# include <io.h>
|
|
||||||
# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
|
|
||||||
#else
|
|
||||||
# define SET_BINARY_MODE(file)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef VMS
|
|
||||||
# define unlink delete
|
|
||||||
# define GZ_SUFFIX "-gz"
|
|
||||||
#endif
|
|
||||||
#ifdef RISCOS
|
|
||||||
# define unlink remove
|
|
||||||
# define GZ_SUFFIX "-gz"
|
|
||||||
# define fileno(file) file->__file
|
|
||||||
#endif
|
|
||||||
#if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
|
|
||||||
# include <unix.h> /* for fileno */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef WIN32 /* unlink already in stdio.h for WIN32 */
|
|
||||||
extern int unlink OF((const char *));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef GZ_SUFFIX
|
|
||||||
# define GZ_SUFFIX ".gz"
|
|
||||||
#endif
|
|
||||||
#define SUFFIX_LEN (sizeof(GZ_SUFFIX)-1)
|
|
||||||
|
|
||||||
#define BUFLEN 16384
|
|
||||||
#define MAX_NAME_LEN 1024
|
|
||||||
|
|
||||||
#ifdef MAXSEG_64K
|
|
||||||
# define local static
|
|
||||||
/* Needed for systems with limitation on stack size. */
|
|
||||||
#else
|
|
||||||
# define local
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char *prog;
|
|
||||||
|
|
||||||
void error OF((const char *msg));
|
|
||||||
void gz_compress OF((FILE *in, gzFile out));
|
|
||||||
#ifdef USE_MMAP
|
|
||||||
int gz_compress_mmap OF((FILE *in, gzFile out));
|
|
||||||
#endif
|
|
||||||
void gz_uncompress OF((gzFile in, FILE *out));
|
|
||||||
void file_compress OF((char *file, char *mode));
|
|
||||||
void file_uncompress OF((char *file));
|
|
||||||
int main OF((int argc, char *argv[]));
|
|
||||||
|
|
||||||
/* ===========================================================================
|
|
||||||
* Display error message and exit
|
|
||||||
*/
|
|
||||||
void error(msg)
|
|
||||||
const char *msg;
|
|
||||||
{
|
|
||||||
fprintf(stderr, "%s: %s\n", prog, msg);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ===========================================================================
|
|
||||||
* Compress input to output then close both files.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void gz_compress(in, out)
|
|
||||||
FILE *in;
|
|
||||||
gzFile out;
|
|
||||||
{
|
|
||||||
local char buf[BUFLEN];
|
|
||||||
int len;
|
|
||||||
int err;
|
|
||||||
|
|
||||||
#ifdef USE_MMAP
|
|
||||||
/* Try first compressing with mmap. If mmap fails (minigzip used in a
|
|
||||||
* pipe), use the normal fread loop.
|
|
||||||
*/
|
|
||||||
if (gz_compress_mmap(in, out) == Z_OK) return;
|
|
||||||
#endif
|
|
||||||
for (;;) {
|
|
||||||
len = (int)fread(buf, 1, sizeof(buf), in);
|
|
||||||
if (ferror(in)) {
|
|
||||||
perror("fread");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (len == 0) break;
|
|
||||||
|
|
||||||
if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err));
|
|
||||||
}
|
|
||||||
fclose(in);
|
|
||||||
if (gzclose(out) != Z_OK) error("failed gzclose");
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef USE_MMAP /* MMAP version, Miguel Albrecht <malbrech@eso.org> */
|
|
||||||
|
|
||||||
/* Try compressing the input file at once using mmap. Return Z_OK if
|
|
||||||
* if success, Z_ERRNO otherwise.
|
|
||||||
*/
|
|
||||||
int gz_compress_mmap(in, out)
|
|
||||||
FILE *in;
|
|
||||||
gzFile out;
|
|
||||||
{
|
|
||||||
int len;
|
|
||||||
int err;
|
|
||||||
int ifd = fileno(in);
|
|
||||||
caddr_t buf; /* mmap'ed buffer for the entire input file */
|
|
||||||
off_t buf_len; /* length of the input file */
|
|
||||||
struct stat sb;
|
|
||||||
|
|
||||||
/* Determine the size of the file, needed for mmap: */
|
|
||||||
if (fstat(ifd, &sb) < 0) return Z_ERRNO;
|
|
||||||
buf_len = sb.st_size;
|
|
||||||
if (buf_len <= 0) return Z_ERRNO;
|
|
||||||
|
|
||||||
/* Now do the actual mmap: */
|
|
||||||
buf = mmap((caddr_t) 0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0);
|
|
||||||
if (buf == (caddr_t)(-1)) return Z_ERRNO;
|
|
||||||
|
|
||||||
/* Compress the whole file at once: */
|
|
||||||
len = gzwrite(out, (char *)buf, (unsigned)buf_len);
|
|
||||||
|
|
||||||
if (len != (int)buf_len) error(gzerror(out, &err));
|
|
||||||
|
|
||||||
munmap(buf, buf_len);
|
|
||||||
fclose(in);
|
|
||||||
if (gzclose(out) != Z_OK) error("failed gzclose");
|
|
||||||
return Z_OK;
|
|
||||||
}
|
|
||||||
#endif /* USE_MMAP */
|
|
||||||
|
|
||||||
/* ===========================================================================
|
|
||||||
* Uncompress input to output then close both files.
|
|
||||||
*/
|
|
||||||
void gz_uncompress(in, out)
|
|
||||||
gzFile in;
|
|
||||||
FILE *out;
|
|
||||||
{
|
|
||||||
local char buf[BUFLEN];
|
|
||||||
int len;
|
|
||||||
int err;
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
len = gzread(in, buf, sizeof(buf));
|
|
||||||
if (len < 0) error (gzerror(in, &err));
|
|
||||||
if (len == 0) break;
|
|
||||||
|
|
||||||
if ((int)fwrite(buf, 1, (unsigned)len, out) != len) {
|
|
||||||
error("failed fwrite");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (fclose(out)) error("failed fclose");
|
|
||||||
|
|
||||||
if (gzclose(in) != Z_OK) error("failed gzclose");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* ===========================================================================
|
|
||||||
* Compress the given file: create a corresponding .gz file and remove the
|
|
||||||
* original.
|
|
||||||
*/
|
|
||||||
void file_compress(file, mode)
|
|
||||||
char *file;
|
|
||||||
char *mode;
|
|
||||||
{
|
|
||||||
local char outfile[MAX_NAME_LEN];
|
|
||||||
FILE *in;
|
|
||||||
gzFile out;
|
|
||||||
|
|
||||||
strcpy(outfile, file);
|
|
||||||
strcat(outfile, GZ_SUFFIX);
|
|
||||||
|
|
||||||
in = fopen(file, "rb");
|
|
||||||
if (in == NULL) {
|
|
||||||
perror(file);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
out = gzopen(outfile, mode);
|
|
||||||
if (out == NULL) {
|
|
||||||
fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
gz_compress(in, out);
|
|
||||||
|
|
||||||
unlink(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* ===========================================================================
|
|
||||||
* Uncompress the given file and remove the original.
|
|
||||||
*/
|
|
||||||
void file_uncompress(file)
|
|
||||||
char *file;
|
|
||||||
{
|
|
||||||
local char buf[MAX_NAME_LEN];
|
|
||||||
char *infile, *outfile;
|
|
||||||
FILE *out;
|
|
||||||
gzFile in;
|
|
||||||
uInt len = (uInt)strlen(file);
|
|
||||||
|
|
||||||
strcpy(buf, file);
|
|
||||||
|
|
||||||
if (len > SUFFIX_LEN && strcmp(file+len-SUFFIX_LEN, GZ_SUFFIX) == 0) {
|
|
||||||
infile = file;
|
|
||||||
outfile = buf;
|
|
||||||
outfile[len-3] = '\0';
|
|
||||||
} else {
|
|
||||||
outfile = file;
|
|
||||||
infile = buf;
|
|
||||||
strcat(infile, GZ_SUFFIX);
|
|
||||||
}
|
|
||||||
in = gzopen(infile, "rb");
|
|
||||||
if (in == NULL) {
|
|
||||||
fprintf(stderr, "%s: can't gzopen %s\n", prog, infile);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
out = fopen(outfile, "wb");
|
|
||||||
if (out == NULL) {
|
|
||||||
perror(file);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
gz_uncompress(in, out);
|
|
||||||
|
|
||||||
unlink(infile);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* ===========================================================================
|
|
||||||
* Usage: minigzip [-d] [-f] [-h] [-r] [-1 to -9] [files...]
|
|
||||||
* -d : decompress
|
|
||||||
* -f : compress with Z_FILTERED
|
|
||||||
* -h : compress with Z_HUFFMAN_ONLY
|
|
||||||
* -r : compress with Z_RLE
|
|
||||||
* -1 to -9 : compression level
|
|
||||||
*/
|
|
||||||
|
|
||||||
int main(argc, argv)
|
|
||||||
int argc;
|
|
||||||
char *argv[];
|
|
||||||
{
|
|
||||||
int uncompr = 0;
|
|
||||||
gzFile file;
|
|
||||||
char outmode[20];
|
|
||||||
|
|
||||||
strcpy(outmode, "wb6 ");
|
|
||||||
|
|
||||||
prog = argv[0];
|
|
||||||
argc--, argv++;
|
|
||||||
|
|
||||||
while (argc > 0) {
|
|
||||||
if (strcmp(*argv, "-d") == 0)
|
|
||||||
uncompr = 1;
|
|
||||||
else if (strcmp(*argv, "-f") == 0)
|
|
||||||
outmode[3] = 'f';
|
|
||||||
else if (strcmp(*argv, "-h") == 0)
|
|
||||||
outmode[3] = 'h';
|
|
||||||
else if (strcmp(*argv, "-r") == 0)
|
|
||||||
outmode[3] = 'R';
|
|
||||||
else if ((*argv)[0] == '-' && (*argv)[1] >= '1' && (*argv)[1] <= '9' &&
|
|
||||||
(*argv)[2] == 0)
|
|
||||||
outmode[2] = (*argv)[1];
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
argc--, argv++;
|
|
||||||
}
|
|
||||||
if (outmode[3] == ' ')
|
|
||||||
outmode[3] = 0;
|
|
||||||
if (argc == 0) {
|
|
||||||
SET_BINARY_MODE(stdin);
|
|
||||||
SET_BINARY_MODE(stdout);
|
|
||||||
if (uncompr) {
|
|
||||||
file = gzdopen(fileno(stdin), "rb");
|
|
||||||
if (file == NULL) error("can't gzdopen stdin");
|
|
||||||
gz_uncompress(file, stdout);
|
|
||||||
} else {
|
|
||||||
file = gzdopen(fileno(stdout), outmode);
|
|
||||||
if (file == NULL) error("can't gzdopen stdout");
|
|
||||||
gz_compress(stdin, file);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
do {
|
|
||||||
if (uncompr) {
|
|
||||||
file_uncompress(*argv);
|
|
||||||
} else {
|
|
||||||
file_compress(*argv, outmode);
|
|
||||||
}
|
|
||||||
} while (argv++, --argc);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
145
png.c
145
png.c
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
/* png.c - location for general purpose libpng functions
|
/* png.c - location for general purpose libpng functions
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.2.9 April 14, 2006
|
* Last changed in libpng 1.2.21 October 4, 2007
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*/
|
*/
|
||||||
@@ -13,20 +13,20 @@
|
|||||||
#include "png.h"
|
#include "png.h"
|
||||||
|
|
||||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||||
typedef version_1_2_11beta4 Your_png_h_is_not_version_1_2_11beta4;
|
typedef version_1_2_29 Your_png_h_is_not_version_1_2_29;
|
||||||
|
|
||||||
/* Version information for C files. This had better match the version
|
/* Version information for C files. This had better match the version
|
||||||
* string defined in png.h. */
|
* string defined in png.h. */
|
||||||
|
|
||||||
#ifdef PNG_USE_GLOBAL_ARRAYS
|
#ifdef PNG_USE_GLOBAL_ARRAYS
|
||||||
/* png_libpng_ver was changed to a function in version 1.0.5c */
|
/* png_libpng_ver was changed to a function in version 1.0.5c */
|
||||||
const char png_libpng_ver[18] = PNG_LIBPNG_VER_STRING;
|
PNG_CONST char png_libpng_ver[18] = PNG_LIBPNG_VER_STRING;
|
||||||
|
|
||||||
#ifdef PNG_READ_SUPPORTED
|
#ifdef PNG_READ_SUPPORTED
|
||||||
|
|
||||||
/* png_sig was changed to a function in version 1.0.5c */
|
/* png_sig was changed to a function in version 1.0.5c */
|
||||||
/* Place to hold the signature string for a PNG file. */
|
/* Place to hold the signature string for a PNG file. */
|
||||||
const png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
PNG_CONST png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||||
#endif /* PNG_READ_SUPPORTED */
|
#endif /* PNG_READ_SUPPORTED */
|
||||||
|
|
||||||
/* Invoke global declarations for constant strings for known chunk types */
|
/* Invoke global declarations for constant strings for known chunk types */
|
||||||
@@ -56,32 +56,27 @@ PNG_zTXt;
|
|||||||
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||||
|
|
||||||
/* start of interlace block */
|
/* start of interlace block */
|
||||||
const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
|
PNG_CONST int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
|
||||||
|
|
||||||
/* offset to next interlace block */
|
/* offset to next interlace block */
|
||||||
const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
|
PNG_CONST int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
|
||||||
|
|
||||||
/* start of interlace block in the y direction */
|
/* start of interlace block in the y direction */
|
||||||
const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
|
PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
|
||||||
|
|
||||||
/* offset to next interlace block in the y direction */
|
/* offset to next interlace block in the y direction */
|
||||||
const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
|
PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
|
||||||
|
|
||||||
/* width of interlace block (used in assembler routines only) */
|
|
||||||
#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
|
|
||||||
const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Height of interlace block. This is not currently used - if you need
|
/* Height of interlace block. This is not currently used - if you need
|
||||||
* it, uncomment it here and in png.h
|
* it, uncomment it here and in png.h
|
||||||
const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
|
PNG_CONST int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Mask to determine which pixels are valid in a pass */
|
/* Mask to determine which pixels are valid in a pass */
|
||||||
const int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
|
PNG_CONST int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
|
||||||
|
|
||||||
/* Mask to determine which pixels to overwrite while displaying */
|
/* Mask to determine which pixels to overwrite while displaying */
|
||||||
const int FARDATA png_pass_dsp_mask[]
|
PNG_CONST int FARDATA png_pass_dsp_mask[]
|
||||||
= {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
|
= {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
|
||||||
|
|
||||||
#endif /* PNG_READ_SUPPORTED */
|
#endif /* PNG_READ_SUPPORTED */
|
||||||
@@ -97,6 +92,7 @@ const int FARDATA png_pass_dsp_mask[]
|
|||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_sig_bytes(png_structp png_ptr, int num_bytes)
|
png_set_sig_bytes(png_structp png_ptr, int num_bytes)
|
||||||
{
|
{
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
png_debug(1, "in png_set_sig_bytes\n");
|
png_debug(1, "in png_set_sig_bytes\n");
|
||||||
if (num_bytes > 8)
|
if (num_bytes > 8)
|
||||||
png_error(png_ptr, "Too many bytes for PNG signature.");
|
png_error(png_ptr, "Too many bytes for PNG signature.");
|
||||||
@@ -133,7 +129,7 @@ png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check)
|
|||||||
#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
|
#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
|
||||||
/* (Obsolete) function to check signature bytes. It does not allow one
|
/* (Obsolete) function to check signature bytes. It does not allow one
|
||||||
* to check a partial signature. This function might be removed in the
|
* to check a partial signature. This function might be removed in the
|
||||||
* future - use png_sig_cmp(). Returns true (nonzero) if the file is a PNG.
|
* future - use png_sig_cmp(). Returns true (nonzero) if the file is PNG.
|
||||||
*/
|
*/
|
||||||
int PNGAPI
|
int PNGAPI
|
||||||
png_check_sig(png_bytep sig, int num)
|
png_check_sig(png_bytep sig, int num)
|
||||||
@@ -153,13 +149,14 @@ voidpf /* private */
|
|||||||
png_zalloc(voidpf png_ptr, uInt items, uInt size)
|
png_zalloc(voidpf png_ptr, uInt items, uInt size)
|
||||||
{
|
{
|
||||||
png_voidp ptr;
|
png_voidp ptr;
|
||||||
png_structp p=png_ptr;
|
png_structp p=(png_structp)png_ptr;
|
||||||
png_uint_32 save_flags=p->flags;
|
png_uint_32 save_flags=p->flags;
|
||||||
png_uint_32 num_bytes;
|
png_uint_32 num_bytes;
|
||||||
|
|
||||||
|
if(png_ptr == NULL) return (NULL);
|
||||||
if (items > PNG_UINT_32_MAX/size)
|
if (items > PNG_UINT_32_MAX/size)
|
||||||
{
|
{
|
||||||
png_warning (png_ptr, "Potential overflow in png_zalloc()");
|
png_warning (p, "Potential overflow in png_zalloc()");
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
num_bytes = (png_uint_32)items * size;
|
num_bytes = (png_uint_32)items * size;
|
||||||
@@ -266,6 +263,7 @@ void PNGAPI
|
|||||||
png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
|
png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
|
||||||
{
|
{
|
||||||
png_infop info_ptr = NULL;
|
png_infop info_ptr = NULL;
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
|
|
||||||
png_debug(1, "in png_destroy_info_struct\n");
|
png_debug(1, "in png_destroy_info_struct\n");
|
||||||
if (info_ptr_ptr != NULL)
|
if (info_ptr_ptr != NULL)
|
||||||
@@ -304,6 +302,8 @@ png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size)
|
|||||||
{
|
{
|
||||||
png_infop info_ptr = *ptr_ptr;
|
png_infop info_ptr = *ptr_ptr;
|
||||||
|
|
||||||
|
if(info_ptr == NULL) return;
|
||||||
|
|
||||||
png_debug(1, "in png_info_init_3\n");
|
png_debug(1, "in png_info_init_3\n");
|
||||||
|
|
||||||
if(png_sizeof(png_info) > png_info_struct_size)
|
if(png_sizeof(png_info) > png_info_struct_size)
|
||||||
@@ -485,6 +485,11 @@ if (mask & PNG_FREE_SPLT)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||||
|
if(png_ptr->unknown_chunk.data)
|
||||||
|
{
|
||||||
|
png_free(png_ptr, png_ptr->unknown_chunk.data);
|
||||||
|
png_ptr->unknown_chunk.data = NULL;
|
||||||
|
}
|
||||||
#ifdef PNG_FREE_ME_SUPPORTED
|
#ifdef PNG_FREE_ME_SUPPORTED
|
||||||
if ((mask & PNG_FREE_UNKN) & info_ptr->free_me)
|
if ((mask & PNG_FREE_UNKN) & info_ptr->free_me)
|
||||||
#else
|
#else
|
||||||
@@ -611,6 +616,7 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr)
|
|||||||
png_voidp PNGAPI
|
png_voidp PNGAPI
|
||||||
png_get_io_ptr(png_structp png_ptr)
|
png_get_io_ptr(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
|
if(png_ptr == NULL) return (NULL);
|
||||||
return (png_ptr->io_ptr);
|
return (png_ptr->io_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -626,6 +632,7 @@ void PNGAPI
|
|||||||
png_init_io(png_structp png_ptr, png_FILE_p fp)
|
png_init_io(png_structp png_ptr, png_FILE_p fp)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_init_io\n");
|
png_debug(1, "in png_init_io\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
png_ptr->io_ptr = (png_voidp)fp;
|
png_ptr->io_ptr = (png_voidp)fp;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -641,6 +648,7 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
|
|||||||
{"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
{"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||||
|
|
||||||
|
if(png_ptr == NULL) return (NULL);
|
||||||
if (png_ptr->time_buffer == NULL)
|
if (png_ptr->time_buffer == NULL)
|
||||||
{
|
{
|
||||||
png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29*
|
png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29*
|
||||||
@@ -661,7 +669,7 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
|
|||||||
#ifdef USE_FAR_KEYWORD
|
#ifdef USE_FAR_KEYWORD
|
||||||
{
|
{
|
||||||
char near_time_buf[29];
|
char near_time_buf[29];
|
||||||
sprintf(near_time_buf, "%d %s %d %02d:%02d:%02d +0000",
|
png_snprintf6(near_time_buf,29,"%d %s %d %02d:%02d:%02d +0000",
|
||||||
ptime->day % 32, short_months[(ptime->month - 1) % 12],
|
ptime->day % 32, short_months[(ptime->month - 1) % 12],
|
||||||
ptime->year, ptime->hour % 24, ptime->minute % 60,
|
ptime->year, ptime->hour % 24, ptime->minute % 60,
|
||||||
ptime->second % 61);
|
ptime->second % 61);
|
||||||
@@ -669,7 +677,7 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
|
|||||||
29*png_sizeof(char));
|
29*png_sizeof(char));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
sprintf(png_ptr->time_buffer, "%d %s %d %02d:%02d:%02d +0000",
|
png_snprintf6(png_ptr->time_buffer,29,"%d %s %d %02d:%02d:%02d +0000",
|
||||||
ptime->day % 32, short_months[(ptime->month - 1) % 12],
|
ptime->day % 32, short_months[(ptime->month - 1) % 12],
|
||||||
ptime->year, ptime->hour % 24, ptime->minute % 60,
|
ptime->year, ptime->hour % 24, ptime->minute % 60,
|
||||||
ptime->second % 61);
|
ptime->second % 61);
|
||||||
@@ -679,25 +687,16 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
|
|||||||
}
|
}
|
||||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* Signature string for a PNG file. */
|
|
||||||
png_bytep PNGAPI
|
|
||||||
png_sig_bytes(void)
|
|
||||||
{
|
|
||||||
return ((png_bytep)"\211\120\116\107\015\012\032\012");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
|
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
|
||||||
|
|
||||||
png_charp PNGAPI
|
png_charp PNGAPI
|
||||||
png_get_copyright(png_structp png_ptr)
|
png_get_copyright(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */
|
png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */
|
||||||
return ((png_charp) "\n libpng version 1.2.11beta4 - June 7, 2006\n\
|
return ((png_charp) "\n libpng version 1.2.29 - May 8, 2008\n\
|
||||||
Copyright (c) 1998-2006 Glenn Randers-Pehrson\n\
|
Copyright (c) 1998-2008 Glenn Randers-Pehrson\n\
|
||||||
Copyright (c) 1996-1997 Andreas Dilger\n\
|
Copyright (c) 1996-1997 Andreas Dilger\n\
|
||||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n");
|
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n");
|
||||||
return ((png_charp) "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The following return the library version as a short string in the
|
/* The following return the library version as a short string in the
|
||||||
@@ -712,27 +711,28 @@ png_charp PNGAPI
|
|||||||
png_get_libpng_ver(png_structp png_ptr)
|
png_get_libpng_ver(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
/* Version of *.c files used when building libpng */
|
/* Version of *.c files used when building libpng */
|
||||||
if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */
|
png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */
|
||||||
return ((png_charp) PNG_LIBPNG_VER_STRING);
|
return ((png_charp) PNG_LIBPNG_VER_STRING);
|
||||||
return ((png_charp) "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
png_charp PNGAPI
|
png_charp PNGAPI
|
||||||
png_get_header_ver(png_structp png_ptr)
|
png_get_header_ver(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
/* Version of *.h files used when building libpng */
|
/* Version of *.h files used when building libpng */
|
||||||
if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */
|
png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */
|
||||||
return ((png_charp) PNG_LIBPNG_VER_STRING);
|
return ((png_charp) PNG_LIBPNG_VER_STRING);
|
||||||
return ((png_charp) "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
png_charp PNGAPI
|
png_charp PNGAPI
|
||||||
png_get_header_version(png_structp png_ptr)
|
png_get_header_version(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
/* Returns longer string containing both version and date */
|
/* Returns longer string containing both version and date */
|
||||||
if (&png_ptr != NULL) /* silence compiler warning about unused png_ptr */
|
png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */
|
||||||
return ((png_charp) PNG_HEADER_VERSION_STRING);
|
return ((png_charp) PNG_HEADER_VERSION_STRING
|
||||||
return ((png_charp) "");
|
#ifndef PNG_READ_SUPPORTED
|
||||||
|
" (NO READ SUPPORT)"
|
||||||
|
#endif
|
||||||
|
"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||||
@@ -743,7 +743,7 @@ png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
|
|||||||
/* check chunk_name and return "keep" value if it's on the list, else 0 */
|
/* check chunk_name and return "keep" value if it's on the list, else 0 */
|
||||||
int i;
|
int i;
|
||||||
png_bytep p;
|
png_bytep p;
|
||||||
if((png_ptr == NULL && chunk_name == NULL) || png_ptr->num_chunk_list<=0)
|
if(png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list<=0)
|
||||||
return 0;
|
return 0;
|
||||||
p=png_ptr->chunk_list+png_ptr->num_chunk_list*5-5;
|
p=png_ptr->chunk_list+png_ptr->num_chunk_list*5-5;
|
||||||
for (i = png_ptr->num_chunk_list; i; i--, p-=5)
|
for (i = png_ptr->num_chunk_list; i; i--, p-=5)
|
||||||
@@ -757,6 +757,7 @@ png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
|
|||||||
int PNGAPI
|
int PNGAPI
|
||||||
png_reset_zstream(png_structp png_ptr)
|
png_reset_zstream(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
|
if (png_ptr == NULL) return Z_STREAM_ERROR;
|
||||||
return (inflateReset(&png_ptr->zstream));
|
return (inflateReset(&png_ptr->zstream));
|
||||||
}
|
}
|
||||||
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
|
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
|
||||||
@@ -770,67 +771,17 @@ png_access_version_number(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(PNG_READ_SUPPORTED)
|
#if defined(PNG_READ_SUPPORTED) && defined(PNG_ASSEMBLER_CODE_SUPPORTED)
|
||||||
#if !defined(PNG_1_0_X)
|
#if !defined(PNG_1_0_X)
|
||||||
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
|
|
||||||
/* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */
|
|
||||||
/* this INTERNAL function was added to libpng 1.2.0 */
|
|
||||||
void /* PRIVATE */
|
|
||||||
png_init_mmx_flags (png_structp png_ptr)
|
|
||||||
{
|
|
||||||
png_ptr->mmx_rowbytes_threshold = 0;
|
|
||||||
png_ptr->mmx_bitdepth_threshold = 0;
|
|
||||||
|
|
||||||
# if (defined(PNG_USE_PNGVCRD) || defined(PNG_USE_PNGGCCRD))
|
|
||||||
|
|
||||||
png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_COMPILED;
|
|
||||||
|
|
||||||
if (png_mmx_support() > 0) {
|
|
||||||
png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU
|
|
||||||
# ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_COMBINE_ROW
|
|
||||||
# endif
|
|
||||||
# ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_INTERLACE
|
|
||||||
# endif
|
|
||||||
# ifndef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
|
|
||||||
;
|
|
||||||
# else
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_FILTER_SUB
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_FILTER_UP
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_FILTER_AVG
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
|
|
||||||
|
|
||||||
png_ptr->mmx_rowbytes_threshold = PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT;
|
|
||||||
png_ptr->mmx_bitdepth_threshold = PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT;
|
|
||||||
# endif
|
|
||||||
} else {
|
|
||||||
png_ptr->asm_flags &= ~( PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU
|
|
||||||
| PNG_MMX_READ_FLAGS
|
|
||||||
| PNG_MMX_WRITE_FLAGS );
|
|
||||||
}
|
|
||||||
|
|
||||||
# else /* !((PNGVCRD || PNGGCCRD) && PNG_ASSEMBLER_CODE_SUPPORTED)) */
|
|
||||||
|
|
||||||
/* clear all MMX flags; no support is compiled in */
|
|
||||||
png_ptr->asm_flags &= ~( PNG_MMX_FLAGS );
|
|
||||||
|
|
||||||
# endif /* ?(PNGVCRD || PNGGCCRD) */
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* !(PNG_ASSEMBLER_CODE_SUPPORTED) */
|
|
||||||
|
|
||||||
/* this function was added to libpng 1.2.0 */
|
/* this function was added to libpng 1.2.0 */
|
||||||
#if !defined(PNG_USE_PNGGCCRD) && \
|
|
||||||
!(defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD))
|
|
||||||
int PNGAPI
|
int PNGAPI
|
||||||
png_mmx_support(void)
|
png_mmx_support(void)
|
||||||
{
|
{
|
||||||
|
/* obsolete, to be removed from libpng-1.4.0 */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#endif /* PNG_1_0_X */
|
#endif /* PNG_1_0_X */
|
||||||
#endif /* PNG_READ_SUPPORTED */
|
#endif /* PNG_READ_SUPPORTED && PNG_ASSEMBLER_CODE_SUPPORTED */
|
||||||
|
|
||||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||||
#ifdef PNG_SIZE_T
|
#ifdef PNG_SIZE_T
|
||||||
|
|||||||
299
png.h
299
png.h
@@ -1,15 +1,14 @@
|
|||||||
|
|
||||||
/* png.h - header file for PNG reference library
|
/* png.h - header file for PNG reference library
|
||||||
*
|
*
|
||||||
* libpng version 1.2.11beta4 - June 7, 2006
|
* libpng version 1.2.29 - May 8, 2008
|
||||||
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
* Authors and maintainers:
|
* Authors and maintainers:
|
||||||
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
||||||
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
|
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||||
* libpng versions 0.97, January 1998, through 1.2.11beta4 - June 7, 2006: Glenn
|
* libpng versions 0.97, January 1998, through 1.2.29 - May 8, 2008: Glenn
|
||||||
* See also "Contributing Authors", below.
|
* See also "Contributing Authors", below.
|
||||||
*
|
*
|
||||||
* Note about libpng version numbers:
|
* Note about libpng version numbers:
|
||||||
@@ -103,14 +102,14 @@
|
|||||||
* 1.0.16 10 10016 10.so.0.1.0.16
|
* 1.0.16 10 10016 10.so.0.1.0.16
|
||||||
* 1.2.6 13 10206 12.so.0.1.2.6
|
* 1.2.6 13 10206 12.so.0.1.2.6
|
||||||
* 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2
|
* 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2
|
||||||
* 1.0.17rc1 10 10017 12.so.0.1.0.17rc1
|
* 1.0.17rc1 10 10017 10.so.0.1.0.17rc1
|
||||||
* 1.2.7rc1 13 10207 12.so.0.1.2.7rc1
|
* 1.2.7rc1 13 10207 12.so.0.1.2.7rc1
|
||||||
* 1.0.17 10 10017 12.so.0.1.0.17
|
* 1.0.17 10 10017 10.so.0.1.0.17
|
||||||
* 1.2.7 13 10207 12.so.0.1.2.7
|
* 1.2.7 13 10207 12.so.0.1.2.7
|
||||||
* 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5
|
* 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5
|
||||||
* 1.0.18rc1-5 10 10018 12.so.0.1.0.18rc1-5
|
* 1.0.18rc1-5 10 10018 10.so.0.1.0.18rc1-5
|
||||||
* 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5
|
* 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5
|
||||||
* 1.0.18 10 10018 12.so.0.1.0.18
|
* 1.0.18 10 10018 10.so.0.1.0.18
|
||||||
* 1.2.8 13 10208 12.so.0.1.2.8
|
* 1.2.8 13 10208 12.so.0.1.2.8
|
||||||
* 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3
|
* 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3
|
||||||
* 1.2.9beta4-11 13 10209 12.so.0.9[.0]
|
* 1.2.9beta4-11 13 10209 12.so.0.9[.0]
|
||||||
@@ -120,6 +119,79 @@
|
|||||||
* 1.2.10rc1-3 13 10210 12.so.0.10[.0]
|
* 1.2.10rc1-3 13 10210 12.so.0.10[.0]
|
||||||
* 1.2.10 13 10210 12.so.0.10[.0]
|
* 1.2.10 13 10210 12.so.0.10[.0]
|
||||||
* 1.2.11beta1-4 13 10211 12.so.0.11[.0]
|
* 1.2.11beta1-4 13 10211 12.so.0.11[.0]
|
||||||
|
* 1.0.19rc1-5 10 10019 10.so.0.19[.0]
|
||||||
|
* 1.2.11rc1-5 13 10211 12.so.0.11[.0]
|
||||||
|
* 1.0.19 10 10019 10.so.0.19[.0]
|
||||||
|
* 1.2.11 13 10211 12.so.0.11[.0]
|
||||||
|
* 1.0.20 10 10020 10.so.0.20[.0]
|
||||||
|
* 1.2.12 13 10212 12.so.0.12[.0]
|
||||||
|
* 1.2.13beta1 13 10213 12.so.0.13[.0]
|
||||||
|
* 1.0.21 10 10021 10.so.0.21[.0]
|
||||||
|
* 1.2.13 13 10213 12.so.0.13[.0]
|
||||||
|
* 1.2.14beta1-2 13 10214 12.so.0.14[.0]
|
||||||
|
* 1.0.22rc1 10 10022 10.so.0.22[.0]
|
||||||
|
* 1.2.14rc1 13 10214 12.so.0.14[.0]
|
||||||
|
* 1.0.22 10 10022 10.so.0.22[.0]
|
||||||
|
* 1.2.14 13 10214 12.so.0.14[.0]
|
||||||
|
* 1.2.15beta1-6 13 10215 12.so.0.15[.0]
|
||||||
|
* 1.0.23rc1-5 10 10023 10.so.0.23[.0]
|
||||||
|
* 1.2.15rc1-5 13 10215 12.so.0.15[.0]
|
||||||
|
* 1.0.23 10 10023 10.so.0.23[.0]
|
||||||
|
* 1.2.15 13 10215 12.so.0.15[.0]
|
||||||
|
* 1.2.16beta1-2 13 10216 12.so.0.16[.0]
|
||||||
|
* 1.2.16rc1 13 10216 12.so.0.16[.0]
|
||||||
|
* 1.0.24 10 10024 10.so.0.24[.0]
|
||||||
|
* 1.2.16 13 10216 12.so.0.16[.0]
|
||||||
|
* 1.2.17beta1-2 13 10217 12.so.0.17[.0]
|
||||||
|
* 1.0.25rc1 10 10025 10.so.0.25[.0]
|
||||||
|
* 1.2.17rc1-3 13 10217 12.so.0.17[.0]
|
||||||
|
* 1.0.25 10 10025 10.so.0.25[.0]
|
||||||
|
* 1.2.17 13 10217 12.so.0.17[.0]
|
||||||
|
* 1.0.26 10 10026 10.so.0.26[.0]
|
||||||
|
* 1.2.18 13 10218 12.so.0.18[.0]
|
||||||
|
* 1.2.19beta1-31 13 10219 12.so.0.19[.0]
|
||||||
|
* 1.0.27rc1-6 10 10027 10.so.0.27[.0]
|
||||||
|
* 1.2.19rc1-6 13 10219 12.so.0.19[.0]
|
||||||
|
* 1.0.27 10 10027 10.so.0.27[.0]
|
||||||
|
* 1.2.19 13 10219 12.so.0.19[.0]
|
||||||
|
* 1.2.20beta01-04 13 10220 12.so.0.20[.0]
|
||||||
|
* 1.0.28rc1-6 10 10028 10.so.0.28[.0]
|
||||||
|
* 1.2.20rc1-6 13 10220 12.so.0.20[.0]
|
||||||
|
* 1.0.28 10 10028 10.so.0.28[.0]
|
||||||
|
* 1.2.20 13 10220 12.so.0.20[.0]
|
||||||
|
* 1.2.21beta1-2 13 10221 12.so.0.21[.0]
|
||||||
|
* 1.2.21rc1-3 13 10221 12.so.0.21[.0]
|
||||||
|
* 1.0.29 10 10029 10.so.0.29[.0]
|
||||||
|
* 1.2.21 13 10221 12.so.0.21[.0]
|
||||||
|
* 1.2.22beta1-4 13 10222 12.so.0.22[.0]
|
||||||
|
* 1.0.30rc1 10 10030 10.so.0.30[.0]
|
||||||
|
* 1.2.22rc1 13 10222 12.so.0.22[.0]
|
||||||
|
* 1.0.30 10 10030 10.so.0.30[.0]
|
||||||
|
* 1.2.22 13 10222 12.so.0.22[.0]
|
||||||
|
* 1.2.23beta01-05 13 10223 12.so.0.23[.0]
|
||||||
|
* 1.2.23rc01 13 10223 12.so.0.23[.0]
|
||||||
|
* 1.2.23 13 10223 12.so.0.23[.0]
|
||||||
|
* 1.2.24beta01-02 13 10224 12.so.0.24[.0]
|
||||||
|
* 1.2.24rc01 13 10224 12.so.0.24[.0]
|
||||||
|
* 1.2.24 13 10224 12.so.0.24[.0]
|
||||||
|
* 1.2.25beta01-06 13 10225 12.so.0.25[.0]
|
||||||
|
* 1.2.25rc01-02 13 10225 12.so.0.25[.0]
|
||||||
|
* 1.0.31 10 10031 10.so.0.31[.0]
|
||||||
|
* 1.2.25 13 10225 12.so.0.25[.0]
|
||||||
|
* 1.2.26beta01-06 13 10226 12.so.0.26[.0]
|
||||||
|
* 1.2.26rc01 13 10226 12.so.0.26[.0]
|
||||||
|
* 1.2.26 13 10226 12.so.0.26[.0]
|
||||||
|
* 1.0.32 10 10032 10.so.0.32[.0]
|
||||||
|
* 1.2.27beta01-06 13 10227 12.so.0.27[.0]
|
||||||
|
* 1.2.27rc01 13 10227 12.so.0.27[.0]
|
||||||
|
* 1.0.33 10 10033 10.so.0.33[.0]
|
||||||
|
* 1.2.27 13 10227 12.so.0.27[.0]
|
||||||
|
* 1.0.34 10 10034 10.so.0.34[.0]
|
||||||
|
* 1.2.28 13 10228 12.so.0.28[.0]
|
||||||
|
* 1.2.29beta01-03 13 10229 12.so.0.29[.0]
|
||||||
|
* 1.2.29rc01 13 10229 12.so.0.29[.0]
|
||||||
|
* 1.0.35 10 10035 10.so.0.35[.0]
|
||||||
|
* 1.2.29 13 10229 12.so.0.29[.0]
|
||||||
*
|
*
|
||||||
* Henceforth the source version will match the shared-library major
|
* Henceforth the source version will match the shared-library major
|
||||||
* and minor numbers; the shared-library major version number will be
|
* and minor numbers; the shared-library major version number will be
|
||||||
@@ -129,7 +201,7 @@
|
|||||||
* to the source version x.y.z (leading zeros in y and z). Beta versions
|
* to the source version x.y.z (leading zeros in y and z). Beta versions
|
||||||
* were given the previous public release number plus a letter, until
|
* were given the previous public release number plus a letter, until
|
||||||
* version 1.0.6j; from then on they were given the upcoming public
|
* version 1.0.6j; from then on they were given the upcoming public
|
||||||
* release number plus "betaNN" or "rcN".
|
* release number plus "betaNN" or "rcNN".
|
||||||
*
|
*
|
||||||
* Binary incompatibility exists only when applications make direct access
|
* Binary incompatibility exists only when applications make direct access
|
||||||
* to the info_ptr or png_ptr members through png.h, and the compiled
|
* to the info_ptr or png_ptr members through png.h, and the compiled
|
||||||
@@ -149,8 +221,8 @@
|
|||||||
* If you modify libpng you may insert additional notices immediately following
|
* If you modify libpng you may insert additional notices immediately following
|
||||||
* this sentence.
|
* this sentence.
|
||||||
*
|
*
|
||||||
* libpng versions 1.2.6, August 15, 2004, through 1.2.11beta4, June 7, 2006, are
|
* libpng versions 1.2.6, August 15, 2004, through 1.2.29, May 8, 2008, are
|
||||||
* Copyright (c) 2004, 2006 Glenn Randers-Pehrson, and are
|
* Copyright (c) 2004, 2006-2008 Glenn Randers-Pehrson, and are
|
||||||
* distributed according to the same disclaimer and license as libpng-1.2.5
|
* distributed according to the same disclaimer and license as libpng-1.2.5
|
||||||
* with the following individual added to the list of Contributing Authors:
|
* with the following individual added to the list of Contributing Authors:
|
||||||
*
|
*
|
||||||
@@ -261,13 +333,13 @@
|
|||||||
* Y2K compliance in libpng:
|
* Y2K compliance in libpng:
|
||||||
* =========================
|
* =========================
|
||||||
*
|
*
|
||||||
* June 7, 2006
|
* May 8, 2008
|
||||||
*
|
*
|
||||||
* Since the PNG Development group is an ad-hoc body, we can't make
|
* Since the PNG Development group is an ad-hoc body, we can't make
|
||||||
* an official declaration.
|
* an official declaration.
|
||||||
*
|
*
|
||||||
* This is your unofficial assurance that libpng from version 0.71 and
|
* This is your unofficial assurance that libpng from version 0.71 and
|
||||||
* upward through 1.2.11beta4 are Y2K compliant. It is my belief that earlier
|
* upward through 1.2.29 are Y2K compliant. It is my belief that earlier
|
||||||
* versions were also Y2K compliant.
|
* versions were also Y2K compliant.
|
||||||
*
|
*
|
||||||
* Libpng only has three year fields. One is a 2-byte unsigned integer
|
* Libpng only has three year fields. One is a 2-byte unsigned integer
|
||||||
@@ -323,9 +395,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Version information for png.h - this should match the version in png.c */
|
/* Version information for png.h - this should match the version in png.c */
|
||||||
#define PNG_LIBPNG_VER_STRING "1.2.11beta4"
|
#define PNG_LIBPNG_VER_STRING "1.2.29"
|
||||||
#define PNG_HEADER_VERSION_STRING \
|
#define PNG_HEADER_VERSION_STRING \
|
||||||
" libpng version 1.2.11beta4 - June 7, 2006 (header)\n"
|
" libpng version 1.2.29 - May 8, 2008\n"
|
||||||
|
|
||||||
#define PNG_LIBPNG_VER_SONUM 0
|
#define PNG_LIBPNG_VER_SONUM 0
|
||||||
#define PNG_LIBPNG_VER_DLLNUM 13
|
#define PNG_LIBPNG_VER_DLLNUM 13
|
||||||
@@ -333,11 +405,11 @@
|
|||||||
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
|
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
|
||||||
#define PNG_LIBPNG_VER_MAJOR 1
|
#define PNG_LIBPNG_VER_MAJOR 1
|
||||||
#define PNG_LIBPNG_VER_MINOR 2
|
#define PNG_LIBPNG_VER_MINOR 2
|
||||||
#define PNG_LIBPNG_VER_RELEASE 11
|
#define PNG_LIBPNG_VER_RELEASE 29
|
||||||
/* This should match the numeric part of the final component of
|
/* This should match the numeric part of the final component of
|
||||||
* PNG_LIBPNG_VER_STRING, omitting any leading zero: */
|
* PNG_LIBPNG_VER_STRING, omitting any leading zero: */
|
||||||
|
|
||||||
#define PNG_LIBPNG_VER_BUILD 4
|
#define PNG_LIBPNG_VER_BUILD 0
|
||||||
|
|
||||||
/* Release Status */
|
/* Release Status */
|
||||||
#define PNG_LIBPNG_BUILD_ALPHA 1
|
#define PNG_LIBPNG_BUILD_ALPHA 1
|
||||||
@@ -354,14 +426,14 @@
|
|||||||
#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
|
#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
|
||||||
PNG_LIBPNG_BUILD_PRIVATE */
|
PNG_LIBPNG_BUILD_PRIVATE */
|
||||||
|
|
||||||
#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA
|
#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE
|
||||||
|
|
||||||
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
|
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
|
||||||
* We must not include leading zeros.
|
* We must not include leading zeros.
|
||||||
* Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
|
* Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
|
||||||
* version 1.0.0 was mis-numbered 100 instead of 10000). From
|
* version 1.0.0 was mis-numbered 100 instead of 10000). From
|
||||||
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */
|
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */
|
||||||
#define PNG_LIBPNG_VER 10211 /* 1.2.11 */
|
#define PNG_LIBPNG_VER 10229 /* 1.2.29 */
|
||||||
|
|
||||||
#ifndef PNG_VERSION_INFO_ONLY
|
#ifndef PNG_VERSION_INFO_ONLY
|
||||||
/* include the compression library's header */
|
/* include the compression library's header */
|
||||||
@@ -449,7 +521,7 @@ extern "C" {
|
|||||||
* the version above.
|
* the version above.
|
||||||
*/
|
*/
|
||||||
#ifdef PNG_USE_GLOBAL_ARRAYS
|
#ifdef PNG_USE_GLOBAL_ARRAYS
|
||||||
PNG_EXPORT_VAR (const char) png_libpng_ver[18];
|
PNG_EXPORT_VAR (PNG_CONST char) png_libpng_ver[18];
|
||||||
/* need room for 99.99.99beta99z */
|
/* need room for 99.99.99beta99z */
|
||||||
#else
|
#else
|
||||||
#define png_libpng_ver png_get_header_ver(NULL)
|
#define png_libpng_ver png_get_header_ver(NULL)
|
||||||
@@ -458,17 +530,14 @@ PNG_EXPORT_VAR (const char) png_libpng_ver[18];
|
|||||||
#ifdef PNG_USE_GLOBAL_ARRAYS
|
#ifdef PNG_USE_GLOBAL_ARRAYS
|
||||||
/* This was removed in version 1.0.5c */
|
/* This was removed in version 1.0.5c */
|
||||||
/* Structures to facilitate easy interlacing. See png.c for more details */
|
/* Structures to facilitate easy interlacing. See png.c for more details */
|
||||||
PNG_EXPORT_VAR (const int FARDATA) png_pass_start[7];
|
PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_start[7];
|
||||||
PNG_EXPORT_VAR (const int FARDATA) png_pass_inc[7];
|
PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_inc[7];
|
||||||
PNG_EXPORT_VAR (const int FARDATA) png_pass_ystart[7];
|
PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_ystart[7];
|
||||||
PNG_EXPORT_VAR (const int FARDATA) png_pass_yinc[7];
|
PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_yinc[7];
|
||||||
PNG_EXPORT_VAR (const int FARDATA) png_pass_mask[7];
|
PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_mask[7];
|
||||||
PNG_EXPORT_VAR (const int FARDATA) png_pass_dsp_mask[7];
|
PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_dsp_mask[7];
|
||||||
#ifdef PNG_USE_PNGGCCRD
|
|
||||||
PNG_EXPORT_VAR (const int FARDATA) png_pass_width[7];
|
|
||||||
#endif
|
|
||||||
/* This isn't currently used. If you need it, see png.c for more details.
|
/* This isn't currently used. If you need it, see png.c for more details.
|
||||||
PNG_EXPORT_VAR (const int FARDATA) png_pass_height[7];
|
PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_height[7];
|
||||||
*/
|
*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -605,9 +674,10 @@ typedef png_time FAR * FAR * png_timepp;
|
|||||||
* up private chunks for output even though the library doesn't actually
|
* up private chunks for output even though the library doesn't actually
|
||||||
* know about their semantics.
|
* know about their semantics.
|
||||||
*/
|
*/
|
||||||
|
#define PNG_CHUNK_NAME_LENGTH 5
|
||||||
typedef struct png_unknown_chunk_t
|
typedef struct png_unknown_chunk_t
|
||||||
{
|
{
|
||||||
png_byte name[5];
|
png_byte name[PNG_CHUNK_NAME_LENGTH];
|
||||||
png_byte *data;
|
png_byte *data;
|
||||||
png_size_t size;
|
png_size_t size;
|
||||||
|
|
||||||
@@ -1134,10 +1204,12 @@ struct png_struct_def
|
|||||||
png_uint_32 row_number; /* current row in interlace pass */
|
png_uint_32 row_number; /* current row in interlace pass */
|
||||||
png_bytep prev_row; /* buffer to save previous (unfiltered) row */
|
png_bytep prev_row; /* buffer to save previous (unfiltered) row */
|
||||||
png_bytep row_buf; /* buffer to save current (unfiltered) row */
|
png_bytep row_buf; /* buffer to save current (unfiltered) row */
|
||||||
|
#ifndef PNG_NO_WRITE_FILTERING
|
||||||
png_bytep sub_row; /* buffer to save "sub" row when filtering */
|
png_bytep sub_row; /* buffer to save "sub" row when filtering */
|
||||||
png_bytep up_row; /* buffer to save "up" row when filtering */
|
png_bytep up_row; /* buffer to save "up" row when filtering */
|
||||||
png_bytep avg_row; /* buffer to save "avg" row when filtering */
|
png_bytep avg_row; /* buffer to save "avg" row when filtering */
|
||||||
png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
|
png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
|
||||||
|
#endif
|
||||||
png_row_info row_info; /* used for transformation routines */
|
png_row_info row_info; /* used for transformation routines */
|
||||||
|
|
||||||
png_uint_32 idat_size; /* current IDAT size for read */
|
png_uint_32 idat_size; /* current IDAT size for read */
|
||||||
@@ -1239,8 +1311,7 @@ struct png_struct_def
|
|||||||
png_size_t current_text_left; /* how much text left to read in input */
|
png_size_t current_text_left; /* how much text left to read in input */
|
||||||
png_charp current_text; /* current text chunk buffer */
|
png_charp current_text; /* current text chunk buffer */
|
||||||
png_charp current_text_ptr; /* current location in current_text */
|
png_charp current_text_ptr; /* current location in current_text */
|
||||||
# endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */
|
# endif /* PNG_TEXT_SUPPORTED */
|
||||||
|
|
||||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||||
|
|
||||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||||
@@ -1322,16 +1393,20 @@ struct png_struct_def
|
|||||||
png_byte filter_type;
|
png_byte filter_type;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_1_0_X) || (defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD))
|
#if defined(PNG_1_0_X)
|
||||||
/* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */
|
/* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */
|
||||||
png_uint_32 row_buf_size;
|
png_uint_32 row_buf_size;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* New members added in libpng-1.2.0 */
|
/* New members added in libpng-1.2.0 */
|
||||||
#if !defined(PNG_1_0_X) && defined(PNG_ASSEMBLER_CODE_SUPPORTED)
|
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
|
||||||
|
# if !defined(PNG_1_0_X)
|
||||||
|
# if defined(PNG_MMX_CODE_SUPPORTED)
|
||||||
png_byte mmx_bitdepth_threshold;
|
png_byte mmx_bitdepth_threshold;
|
||||||
png_uint_32 mmx_rowbytes_threshold;
|
png_uint_32 mmx_rowbytes_threshold;
|
||||||
|
# endif
|
||||||
png_uint_32 asm_flags;
|
png_uint_32 asm_flags;
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */
|
/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */
|
||||||
@@ -1361,13 +1436,21 @@ struct png_struct_def
|
|||||||
png_uint_32 user_height_max;
|
png_uint_32 user_height_max;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* New member added in libpng-1.0.25 and 1.2.17 */
|
||||||
|
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||||
|
/* storage for unknown chunk that the library doesn't recognize. */
|
||||||
|
png_unknown_chunk unknown_chunk;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* New members added in libpng-1.2.26 */
|
||||||
|
png_uint_32 old_big_row_buf_size, old_prev_row_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* This triggers a compiler error in png.c, if png.c and png.h
|
/* This triggers a compiler error in png.c, if png.c and png.h
|
||||||
* do not agree upon the version number.
|
* do not agree upon the version number.
|
||||||
*/
|
*/
|
||||||
typedef png_structp version_1_2_11beta4;
|
typedef png_structp version_1_2_29;
|
||||||
|
|
||||||
typedef png_struct FAR * FAR * png_structpp;
|
typedef png_struct FAR * FAR * png_structpp;
|
||||||
|
|
||||||
@@ -2015,6 +2098,7 @@ extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
|
|||||||
int check));
|
int check));
|
||||||
#endif /* USE_FAR_KEYWORD */
|
#endif /* USE_FAR_KEYWORD */
|
||||||
|
|
||||||
|
#ifndef PNG_NO_ERROR_TEXT
|
||||||
/* Fatal error in PNG image of libpng - can't continue */
|
/* Fatal error in PNG image of libpng - can't continue */
|
||||||
extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr,
|
extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr,
|
||||||
png_const_charp error_message));
|
png_const_charp error_message));
|
||||||
@@ -2022,14 +2106,22 @@ extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr,
|
|||||||
/* The same, but the chunk name is prepended to the error string. */
|
/* The same, but the chunk name is prepended to the error string. */
|
||||||
extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr,
|
extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr,
|
||||||
png_const_charp error_message));
|
png_const_charp error_message));
|
||||||
|
#else
|
||||||
|
/* Fatal error in PNG image of libpng - can't continue */
|
||||||
|
extern PNG_EXPORT(void,png_err) PNGARG((png_structp png_ptr));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PNG_NO_WARNINGS
|
||||||
/* Non-fatal error in libpng. Can continue, but may have a problem. */
|
/* Non-fatal error in libpng. Can continue, but may have a problem. */
|
||||||
extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr,
|
extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr,
|
||||||
png_const_charp warning_message));
|
png_const_charp warning_message));
|
||||||
|
|
||||||
|
#ifdef PNG_READ_SUPPORTED
|
||||||
/* Non-fatal error in libpng, chunk name is prepended to message. */
|
/* Non-fatal error in libpng, chunk name is prepended to message. */
|
||||||
extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr,
|
extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr,
|
||||||
png_const_charp warning_message));
|
png_const_charp warning_message));
|
||||||
|
#endif /* PNG_READ_SUPPORTED */
|
||||||
|
#endif /* PNG_NO_WARNINGS */
|
||||||
|
|
||||||
/* The png_set_<chunk> functions are for storing values in the png_info_struct.
|
/* The png_set_<chunk> functions are for storing values in the png_info_struct.
|
||||||
* Similarly, the png_get_<chunk> calls are used to read values from the
|
* Similarly, the png_get_<chunk> calls are used to read values from the
|
||||||
@@ -2363,7 +2455,7 @@ extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr,
|
|||||||
handling or default unknown chunk handling is not desired. Any chunks not
|
handling or default unknown chunk handling is not desired. Any chunks not
|
||||||
listed will be handled in the default manner. The IHDR and IEND chunks
|
listed will be handled in the default manner. The IHDR and IEND chunks
|
||||||
must not be listed.
|
must not be listed.
|
||||||
keep = 0: follow default behavour
|
keep = 0: follow default behaviour
|
||||||
= 1: do not keep
|
= 1: do not keep
|
||||||
= 2: keep only if safe-to-copy
|
= 2: keep only if safe-to-copy
|
||||||
= 3: keep even if unsafe-to-copy
|
= 3: keep even if unsafe-to-copy
|
||||||
@@ -2451,10 +2543,6 @@ extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr,
|
|||||||
#define png_debug2(l, m, p1, p2)
|
#define png_debug2(l, m, p1, p2)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
|
||||||
extern PNG_EXPORT(png_bytep,png_sig_bytes) PNGARG((void));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr));
|
extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr));
|
||||||
extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr));
|
extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr));
|
||||||
extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr));
|
extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr));
|
||||||
@@ -2473,6 +2561,7 @@ extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp
|
|||||||
|
|
||||||
/* Added to version 1.2.0 */
|
/* Added to version 1.2.0 */
|
||||||
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
|
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
|
||||||
|
#if defined(PNG_MMX_CODE_SUPPORTED)
|
||||||
#define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED 0x01 /* not user-settable */
|
#define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED 0x01 /* not user-settable */
|
||||||
#define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU 0x02 /* not user-settable */
|
#define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU 0x02 /* not user-settable */
|
||||||
#define PNG_ASM_FLAG_MMX_READ_COMBINE_ROW 0x04
|
#define PNG_ASM_FLAG_MMX_READ_COMBINE_ROW 0x04
|
||||||
@@ -2498,6 +2587,7 @@ extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp
|
|||||||
|
|
||||||
#define PNG_SELECT_READ 1
|
#define PNG_SELECT_READ 1
|
||||||
#define PNG_SELECT_WRITE 2
|
#define PNG_SELECT_WRITE 2
|
||||||
|
#endif /* PNG_MMX_CODE_SUPPORTED */
|
||||||
|
|
||||||
#if !defined(PNG_1_0_X)
|
#if !defined(PNG_1_0_X)
|
||||||
/* pngget.c */
|
/* pngget.c */
|
||||||
@@ -2530,11 +2620,11 @@ extern PNG_EXPORT(void,png_set_mmx_thresholds)
|
|||||||
png_uint_32 mmx_rowbytes_threshold));
|
png_uint_32 mmx_rowbytes_threshold));
|
||||||
|
|
||||||
#endif /* PNG_1_0_X */
|
#endif /* PNG_1_0_X */
|
||||||
#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
|
|
||||||
|
|
||||||
#if !defined(PNG_1_0_X)
|
#if !defined(PNG_1_0_X)
|
||||||
/* png.c, pnggccrd.c, or pngvcrd.c */
|
/* png.c, pnggccrd.c, or pngvcrd.c */
|
||||||
extern PNG_EXPORT(int,png_mmx_support) PNGARG((void));
|
extern PNG_EXPORT(int,png_mmx_support) PNGARG((void));
|
||||||
|
#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
|
||||||
|
|
||||||
/* Strip the prepended error numbers ("#nnn ") from error and warning
|
/* Strip the prepended error numbers ("#nnn ") from error and warning
|
||||||
* messages before passing them to the error or warning handler. */
|
* messages before passing them to the error or warning handler. */
|
||||||
@@ -2642,16 +2732,21 @@ extern PNG_EXPORT(void,png_save_uint_16)
|
|||||||
* be found in the files where the functions are located.
|
* be found in the files where the functions are located.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(PNG_INTERNAL)
|
|
||||||
|
|
||||||
/* Various modes of operation. Note that after an init, mode is set to
|
/* Various modes of operation, that are visible to applications because
|
||||||
* zero automatically when the structure is created.
|
* they are used for unknown chunk location.
|
||||||
*/
|
*/
|
||||||
#define PNG_HAVE_IHDR 0x01
|
#define PNG_HAVE_IHDR 0x01
|
||||||
#define PNG_HAVE_PLTE 0x02
|
#define PNG_HAVE_PLTE 0x02
|
||||||
#define PNG_HAVE_IDAT 0x04
|
#define PNG_HAVE_IDAT 0x04
|
||||||
#define PNG_AFTER_IDAT 0x08 /* Have complete zlib datastream */
|
#define PNG_AFTER_IDAT 0x08 /* Have complete zlib datastream */
|
||||||
#define PNG_HAVE_IEND 0x10
|
#define PNG_HAVE_IEND 0x10
|
||||||
|
|
||||||
|
#if defined(PNG_INTERNAL)
|
||||||
|
|
||||||
|
/* More modes of operation. Note that after an init, mode is set to
|
||||||
|
* zero automatically when the structure is created.
|
||||||
|
*/
|
||||||
#define PNG_HAVE_gAMA 0x20
|
#define PNG_HAVE_gAMA 0x20
|
||||||
#define PNG_HAVE_cHRM 0x40
|
#define PNG_HAVE_cHRM 0x40
|
||||||
#define PNG_HAVE_sRGB 0x80
|
#define PNG_HAVE_sRGB 0x80
|
||||||
@@ -2771,11 +2866,8 @@ extern PNG_EXPORT(void,png_save_uint_16)
|
|||||||
#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
|
#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
|
||||||
/* place to hold the signature string for a PNG file. */
|
/* place to hold the signature string for a PNG file. */
|
||||||
#ifdef PNG_USE_GLOBAL_ARRAYS
|
#ifdef PNG_USE_GLOBAL_ARRAYS
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_sig[8];
|
PNG_EXPORT_VAR (PNG_CONST png_byte FARDATA) png_sig[8];
|
||||||
#else
|
#else
|
||||||
#if 0
|
|
||||||
#define png_sig png_sig_bytes(NULL)
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
#endif /* PNG_NO_EXTERN */
|
#endif /* PNG_NO_EXTERN */
|
||||||
|
|
||||||
@@ -2783,50 +2875,50 @@ extern PNG_EXPORT(void,png_save_uint_16)
|
|||||||
* define the name here, and add an invocation of the macro in png.c and
|
* define the name here, and add an invocation of the macro in png.c and
|
||||||
* wherever it's needed.
|
* wherever it's needed.
|
||||||
*/
|
*/
|
||||||
#define PNG_IHDR const png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'}
|
#define PNG_IHDR png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'}
|
||||||
#define PNG_IDAT const png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'}
|
#define PNG_IDAT png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'}
|
||||||
#define PNG_IEND const png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'}
|
#define PNG_IEND png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'}
|
||||||
#define PNG_PLTE const png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'}
|
#define PNG_PLTE png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'}
|
||||||
#define PNG_bKGD const png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'}
|
#define PNG_bKGD png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'}
|
||||||
#define PNG_cHRM const png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'}
|
#define PNG_cHRM png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'}
|
||||||
#define PNG_gAMA const png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'}
|
#define PNG_gAMA png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'}
|
||||||
#define PNG_hIST const png_byte png_hIST[5] = {104, 73, 83, 84, '\0'}
|
#define PNG_hIST png_byte png_hIST[5] = {104, 73, 83, 84, '\0'}
|
||||||
#define PNG_iCCP const png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'}
|
#define PNG_iCCP png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'}
|
||||||
#define PNG_iTXt const png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'}
|
#define PNG_iTXt png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'}
|
||||||
#define PNG_oFFs const png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'}
|
#define PNG_oFFs png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'}
|
||||||
#define PNG_pCAL const png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'}
|
#define PNG_pCAL png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'}
|
||||||
#define PNG_sCAL const png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'}
|
#define PNG_sCAL png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'}
|
||||||
#define PNG_pHYs const png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'}
|
#define PNG_pHYs png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'}
|
||||||
#define PNG_sBIT const png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'}
|
#define PNG_sBIT png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'}
|
||||||
#define PNG_sPLT const png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'}
|
#define PNG_sPLT png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'}
|
||||||
#define PNG_sRGB const png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'}
|
#define PNG_sRGB png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'}
|
||||||
#define PNG_tEXt const png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'}
|
#define PNG_tEXt png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'}
|
||||||
#define PNG_tIME const png_byte png_tIME[5] = {116, 73, 77, 69, '\0'}
|
#define PNG_tIME png_byte png_tIME[5] = {116, 73, 77, 69, '\0'}
|
||||||
#define PNG_tRNS const png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'}
|
#define PNG_tRNS png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'}
|
||||||
#define PNG_zTXt const png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'}
|
#define PNG_zTXt png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'}
|
||||||
|
|
||||||
#ifdef PNG_USE_GLOBAL_ARRAYS
|
#ifdef PNG_USE_GLOBAL_ARRAYS
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_IHDR[5];
|
PNG_EXPORT_VAR (png_byte FARDATA) png_IHDR[5];
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_IDAT[5];
|
PNG_EXPORT_VAR (png_byte FARDATA) png_IDAT[5];
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_IEND[5];
|
PNG_EXPORT_VAR (png_byte FARDATA) png_IEND[5];
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_PLTE[5];
|
PNG_EXPORT_VAR (png_byte FARDATA) png_PLTE[5];
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_bKGD[5];
|
PNG_EXPORT_VAR (png_byte FARDATA) png_bKGD[5];
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_cHRM[5];
|
PNG_EXPORT_VAR (png_byte FARDATA) png_cHRM[5];
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_gAMA[5];
|
PNG_EXPORT_VAR (png_byte FARDATA) png_gAMA[5];
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_hIST[5];
|
PNG_EXPORT_VAR (png_byte FARDATA) png_hIST[5];
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_iCCP[5];
|
PNG_EXPORT_VAR (png_byte FARDATA) png_iCCP[5];
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_iTXt[5];
|
PNG_EXPORT_VAR (png_byte FARDATA) png_iTXt[5];
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_oFFs[5];
|
PNG_EXPORT_VAR (png_byte FARDATA) png_oFFs[5];
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_pCAL[5];
|
PNG_EXPORT_VAR (png_byte FARDATA) png_pCAL[5];
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_sCAL[5];
|
PNG_EXPORT_VAR (png_byte FARDATA) png_sCAL[5];
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_pHYs[5];
|
PNG_EXPORT_VAR (png_byte FARDATA) png_pHYs[5];
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_sBIT[5];
|
PNG_EXPORT_VAR (png_byte FARDATA) png_sBIT[5];
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_sPLT[5];
|
PNG_EXPORT_VAR (png_byte FARDATA) png_sPLT[5];
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_sRGB[5];
|
PNG_EXPORT_VAR (png_byte FARDATA) png_sRGB[5];
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_tEXt[5];
|
PNG_EXPORT_VAR (png_byte FARDATA) png_tEXt[5];
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_tIME[5];
|
PNG_EXPORT_VAR (png_byte FARDATA) png_tIME[5];
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_tRNS[5];
|
PNG_EXPORT_VAR (png_byte FARDATA) png_tRNS[5];
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_zTXt[5];
|
PNG_EXPORT_VAR (png_byte FARDATA) png_zTXt[5];
|
||||||
#endif /* PNG_USE_GLOBAL_ARRAYS */
|
#endif /* PNG_USE_GLOBAL_ARRAYS */
|
||||||
|
|
||||||
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
|
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
|
||||||
@@ -3436,9 +3528,34 @@ PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
|
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
|
||||||
|
#if defined(PNG_MMX_CODE_SUPPORTED)
|
||||||
/* png.c */ /* PRIVATE */
|
/* png.c */ /* PRIVATE */
|
||||||
PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr));
|
PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr));
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||||
|
PNG_EXTERN png_uint_32 png_get_pixels_per_inch PNGARG((png_structp png_ptr,
|
||||||
|
png_infop info_ptr));
|
||||||
|
|
||||||
|
PNG_EXTERN png_uint_32 png_get_x_pixels_per_inch PNGARG((png_structp png_ptr,
|
||||||
|
png_infop info_ptr));
|
||||||
|
|
||||||
|
PNG_EXTERN png_uint_32 png_get_y_pixels_per_inch PNGARG((png_structp png_ptr,
|
||||||
|
png_infop info_ptr));
|
||||||
|
|
||||||
|
PNG_EXTERN float png_get_x_offset_inches PNGARG((png_structp png_ptr,
|
||||||
|
png_infop info_ptr));
|
||||||
|
|
||||||
|
PNG_EXTERN float png_get_y_offset_inches PNGARG((png_structp png_ptr,
|
||||||
|
png_infop info_ptr));
|
||||||
|
|
||||||
|
#if defined(PNG_pHYs_SUPPORTED)
|
||||||
|
PNG_EXTERN png_uint_32 png_get_pHYs_dpi PNGARG((png_structp png_ptr,
|
||||||
|
png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
|
||||||
|
#endif /* PNG_pHYs_SUPPORTED */
|
||||||
|
#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
|
||||||
|
|
||||||
/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
|
/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
|
||||||
|
|
||||||
#endif /* PNG_INTERNAL */
|
#endif /* PNG_INTERNAL */
|
||||||
|
|||||||
147
pngconf.h
147
pngconf.h
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
/* pngconf.h - machine configurable file for libpng
|
/* pngconf.h - machine configurable file for libpng
|
||||||
*
|
*
|
||||||
* libpng version 1.2.11beta4 - June 7, 2006
|
* libpng version 1.2.29 - May 8, 2008
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998-2005 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*/
|
*/
|
||||||
@@ -77,6 +77,14 @@
|
|||||||
|
|
||||||
/* End of material added to libpng-1.2.8 */
|
/* End of material added to libpng-1.2.8 */
|
||||||
|
|
||||||
|
/* Added at libpng-1.2.19, removed at libpng-1.2.20 because it caused trouble
|
||||||
|
Restored at libpng-1.2.21 */
|
||||||
|
#if !defined(PNG_NO_WARN_UNINITIALIZED_ROW) && \
|
||||||
|
!defined(PNG_WARN_UNINITIALIZED_ROW)
|
||||||
|
# define PNG_WARN_UNINITIALIZED_ROW 1
|
||||||
|
#endif
|
||||||
|
/* End of material added at libpng-1.2.19/1.2.21 */
|
||||||
|
|
||||||
/* This is the size of the compression buffer, and thus the size of
|
/* This is the size of the compression buffer, and thus the size of
|
||||||
* an IDAT chunk. Make this whatever size you feel is best for your
|
* an IDAT chunk. Make this whatever size you feel is best for your
|
||||||
* machine. One of these will be allocated per png_struct. When this
|
* machine. One of these will be allocated per png_struct. When this
|
||||||
@@ -278,6 +286,7 @@
|
|||||||
# define PNGARG(arglist) arglist
|
# define PNGARG(arglist) arglist
|
||||||
#endif /* _NO_PROTO */
|
#endif /* _NO_PROTO */
|
||||||
|
|
||||||
|
|
||||||
#endif /* OF */
|
#endif /* OF */
|
||||||
|
|
||||||
#endif /* PNGARG */
|
#endif /* PNGARG */
|
||||||
@@ -316,7 +325,7 @@
|
|||||||
/* If you encounter a compiler error here, see the explanation
|
/* If you encounter a compiler error here, see the explanation
|
||||||
* near the end of INSTALL.
|
* near the end of INSTALL.
|
||||||
*/
|
*/
|
||||||
__png.h__ already includes setjmp.h;
|
__pngconf.h__ already includes setjmp.h;
|
||||||
__dont__ include it again.;
|
__dont__ include it again.;
|
||||||
# endif
|
# endif
|
||||||
# endif /* __linux__ */
|
# endif /* __linux__ */
|
||||||
@@ -326,7 +335,9 @@
|
|||||||
|
|
||||||
# ifdef __linux__
|
# ifdef __linux__
|
||||||
# ifdef PNG_SAVE_BSD_SOURCE
|
# ifdef PNG_SAVE_BSD_SOURCE
|
||||||
# define _BSD_SOURCE
|
# ifndef _BSD_SOURCE
|
||||||
|
# define _BSD_SOURCE
|
||||||
|
# endif
|
||||||
# undef PNG_SAVE_BSD_SOURCE
|
# undef PNG_SAVE_BSD_SOURCE
|
||||||
# endif
|
# endif
|
||||||
# endif /* __linux__ */
|
# endif /* __linux__ */
|
||||||
@@ -596,16 +607,16 @@
|
|||||||
#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
|
#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
|
||||||
|
|
||||||
#if !defined(PNG_NO_PROGRESSIVE_READ) && \
|
#if !defined(PNG_NO_PROGRESSIVE_READ) && \
|
||||||
!defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */
|
!defined(PNG_PROGRESSIVE_READ_SUPPORTED) /* if you don't do progressive */
|
||||||
# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */
|
# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */
|
||||||
#endif /* about interlacing capability! You'll */
|
#endif /* about interlacing capability! You'll */
|
||||||
/* still have interlacing unless you change the following line: */
|
/* still have interlacing unless you change the following line: */
|
||||||
|
|
||||||
#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */
|
#define PNG_READ_INTERLACING_SUPPORTED /* required in PNG-compliant decoders */
|
||||||
|
|
||||||
#ifndef PNG_NO_READ_COMPOSITE_NODIV
|
#ifndef PNG_NO_READ_COMPOSITE_NODIV
|
||||||
# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */
|
# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */
|
||||||
# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */
|
# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -723,26 +734,46 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0
|
/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0
|
||||||
even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined */
|
* and removed from version 1.2.20. The following will be removed
|
||||||
|
* from libpng-1.4.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_OPTIMIZED_CODE)
|
||||||
|
# ifndef PNG_OPTIMIZED_CODE_SUPPORTED
|
||||||
|
# define PNG_OPTIMIZED_CODE_SUPPORTED
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE)
|
#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE)
|
||||||
# ifndef PNG_ASSEMBLER_CODE_SUPPORTED
|
# ifndef PNG_ASSEMBLER_CODE_SUPPORTED
|
||||||
# define PNG_ASSEMBLER_CODE_SUPPORTED
|
# define PNG_ASSEMBLER_CODE_SUPPORTED
|
||||||
# endif
|
# endif
|
||||||
# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) && \
|
|
||||||
defined(__MMX__)
|
# if defined(__GNUC__) && defined(__x86_64__) && (__GNUC__ < 4)
|
||||||
|
/* work around 64-bit gcc compiler bugs in gcc-3.x */
|
||||||
|
# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
|
||||||
|
# define PNG_NO_MMX_CODE
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if defined(__APPLE__)
|
||||||
|
# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
|
||||||
|
# define PNG_NO_MMX_CODE
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if (defined(__MWERKS__) && ((__MWERKS__ < 0x0900) || macintosh))
|
||||||
|
# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
|
||||||
|
# define PNG_NO_MMX_CODE
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
|
||||||
# define PNG_MMX_CODE_SUPPORTED
|
# define PNG_MMX_CODE_SUPPORTED
|
||||||
# endif
|
# endif
|
||||||
# if !defined(PNG_USE_PNGGCCRD) && !defined(PNG_NO_MMX_CODE) && \
|
|
||||||
!defined(PNG_USE_PNGVCRD) && defined(__MMX__)
|
|
||||||
# define PNG_USE_PNGGCCRD
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* If you are sure that you don't need thread safety and you are compiling
|
#endif
|
||||||
with PNG_USE_PNGCCRD for an MMX application, you can define this for
|
/* end of obsolete code to be removed from libpng-1.4.0 */
|
||||||
faster execution. See pnggccrd.c.
|
|
||||||
#define PNG_THREAD_UNSAFE_OK
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if !defined(PNG_1_0_X)
|
#if !defined(PNG_1_0_X)
|
||||||
#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED)
|
#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED)
|
||||||
@@ -1264,7 +1295,8 @@ typedef z_stream FAR * png_zstreamp;
|
|||||||
* but might be required for some pre-1.0.5c applications.
|
* but might be required for some pre-1.0.5c applications.
|
||||||
*/
|
*/
|
||||||
#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS)
|
#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS)
|
||||||
# if defined(PNG_NO_GLOBAL_ARRAYS) || (defined(__GNUC__) && defined(PNG_DLL))
|
# if defined(PNG_NO_GLOBAL_ARRAYS) || \
|
||||||
|
(defined(__GNUC__) && defined(PNG_DLL)) || defined(_MSC_VER)
|
||||||
# define PNG_USE_LOCAL_ARRAYS
|
# define PNG_USE_LOCAL_ARRAYS
|
||||||
# else
|
# else
|
||||||
# define PNG_USE_GLOBAL_ARRAYS
|
# define PNG_USE_GLOBAL_ARRAYS
|
||||||
@@ -1401,8 +1433,7 @@ typedef z_stream FAR * png_zstreamp;
|
|||||||
# define NOCHECK 0
|
# define NOCHECK 0
|
||||||
# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
|
# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
|
||||||
# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
|
# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
|
||||||
# define png_strcpy _fstrcpy
|
# define png_snprintf _fsnprintf /* Added to v 1.2.19 */
|
||||||
# define png_strncpy _fstrncpy /* Added to v 1.2.6 */
|
|
||||||
# define png_strlen _fstrlen
|
# define png_strlen _fstrlen
|
||||||
# define png_memcmp _fmemcmp /* SJT: added */
|
# define png_memcmp _fmemcmp /* SJT: added */
|
||||||
# define png_memcpy _fmemcpy
|
# define png_memcpy _fmemcpy
|
||||||
@@ -1410,8 +1441,27 @@ typedef z_stream FAR * png_zstreamp;
|
|||||||
#else /* use the usual functions */
|
#else /* use the usual functions */
|
||||||
# define CVT_PTR(ptr) (ptr)
|
# define CVT_PTR(ptr) (ptr)
|
||||||
# define CVT_PTR_NOCHECK(ptr) (ptr)
|
# define CVT_PTR_NOCHECK(ptr) (ptr)
|
||||||
# define png_strcpy strcpy
|
# ifndef PNG_NO_SNPRINTF
|
||||||
# define png_strncpy strncpy /* Added to v 1.2.6 */
|
# 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
|
||||||
# define png_strlen strlen
|
# define png_strlen strlen
|
||||||
# define png_memcmp memcmp /* SJT: added */
|
# define png_memcmp memcmp /* SJT: added */
|
||||||
# define png_memcpy memcpy
|
# define png_memcpy memcpy
|
||||||
@@ -1427,47 +1477,6 @@ typedef z_stream FAR * png_zstreamp;
|
|||||||
# define PNG_ZBUF_SIZE 65536L
|
# define PNG_ZBUF_SIZE 65536L
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_READ_SUPPORTED
|
|
||||||
/* Prior to libpng-1.0.9, this block was in pngasmrd.h */
|
|
||||||
#if defined(PNG_INTERNAL)
|
|
||||||
|
|
||||||
/* These are the default thresholds before the MMX code kicks in; if either
|
|
||||||
* rowbytes or bitdepth is below the threshold, plain C code is used. These
|
|
||||||
* can be overridden at runtime via the png_set_mmx_thresholds() call in
|
|
||||||
* libpng 1.2.0 and later. The values below were chosen by Intel.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT
|
|
||||||
# define PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT 128 /* >= */
|
|
||||||
#endif
|
|
||||||
#ifndef PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT
|
|
||||||
# define PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT 9 /* >= */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Set this in the makefile for VC++ on Pentium, not here. */
|
|
||||||
/* Platform must be Pentium. Makefile must assemble and load pngvcrd.c .
|
|
||||||
* MMX will be detected at run time and used if present.
|
|
||||||
*/
|
|
||||||
#ifdef PNG_USE_PNGVCRD
|
|
||||||
# define PNG_HAVE_ASSEMBLER_COMBINE_ROW
|
|
||||||
# define PNG_HAVE_ASSEMBLER_READ_INTERLACE
|
|
||||||
# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Set this in the makefile for gcc/as on Pentium, not here. */
|
|
||||||
/* Platform must be Pentium. Makefile must assemble and load pnggccrd.c .
|
|
||||||
* MMX will be detected at run time and used if present.
|
|
||||||
*/
|
|
||||||
#ifdef PNG_USE_PNGGCCRD
|
|
||||||
# define PNG_HAVE_ASSEMBLER_COMBINE_ROW
|
|
||||||
# define PNG_HAVE_ASSEMBLER_READ_INTERLACE
|
|
||||||
# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
|
|
||||||
#endif
|
|
||||||
/* - see pnggccrd.c for info about what is currently enabled */
|
|
||||||
|
|
||||||
#endif /* PNG_INTERNAL */
|
|
||||||
#endif /* PNG_READ_SUPPORTED */
|
|
||||||
|
|
||||||
/* Added at libpng-1.2.8 */
|
/* Added at libpng-1.2.8 */
|
||||||
#endif /* PNG_VERSION_INFO_ONLY */
|
#endif /* PNG_VERSION_INFO_ONLY */
|
||||||
|
|
||||||
|
|||||||
388
pngcrush.c
388
pngcrush.c
@@ -1,5 +1,5 @@
|
|||||||
/* pngcrush.c - recompresses png files
|
/* pngcrush.c - recompresses png files
|
||||||
* Copyright (C) 1998-2002,2006 Glenn Randers-Pehrson (glennrp@users.sf.net)
|
* Copyright (C) 1998-2002,2006-2008 Glenn Randers-Pehrson (glennrp@users.sf.net)
|
||||||
* Copyright (C) 2005 Greg Roelofs
|
* Copyright (C) 2005 Greg Roelofs
|
||||||
*
|
*
|
||||||
* The most recent version of pngcrush can be found at SourceForge in
|
* The most recent version of pngcrush can be found at SourceForge in
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PNGCRUSH_VERSION "1.6.4"
|
#define PNGCRUSH_VERSION "1.6.5"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#define PNGCRUSH_COUNT_COLORS
|
#define PNGCRUSH_COUNT_COLORS
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
* If you have modified this source, you may insert additional notices
|
* If you have modified this source, you may insert additional notices
|
||||||
* immediately after this sentence.
|
* immediately after this sentence.
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998-2002,2006 Glenn Randers-Pehrson (glennrp@users.sf.net)
|
* Copyright (C) 1998-2002,2006-2008 Glenn Randers-Pehrson (glennrp@users.sf.net)
|
||||||
* Copyright (C) 2005 Greg Roelofs
|
* Copyright (C) 2005 Greg Roelofs
|
||||||
*
|
*
|
||||||
* The pngcrush computer program is supplied "AS IS". The Author disclaims all
|
* The pngcrush computer program is supplied "AS IS". The Author disclaims all
|
||||||
@@ -128,13 +128,6 @@
|
|||||||
#define PNG_iCCP const png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'}
|
#define PNG_iCCP const png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'}
|
||||||
#define PNG_IEND const png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'}
|
#define PNG_IEND const png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'}
|
||||||
|
|
||||||
#if 0
|
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_IHDR[5];
|
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_IDAT[5];
|
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_IEND[5];
|
|
||||||
PNG_EXPORT_VAR (const png_byte FARDATA) png_iCCP[5];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define PNG_FLAG_CRC_CRITICAL_USE 0x0400
|
#define PNG_FLAG_CRC_CRITICAL_USE 0x0400
|
||||||
#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800
|
#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800
|
||||||
#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100
|
#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100
|
||||||
@@ -171,6 +164,10 @@ PNG_EXPORT_VAR (const png_byte FARDATA) png_iCCP[5];
|
|||||||
# define PNGCRUSH_LOCO
|
# define PNGCRUSH_LOCO
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef PNG_UINT_31_MAX
|
||||||
|
#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* These macros were renamed in libpng-1.2.6 */
|
/* These macros were renamed in libpng-1.2.6 */
|
||||||
#ifndef PNG_HANDLE_CHUNK_ALWAYS
|
#ifndef PNG_HANDLE_CHUNK_ALWAYS
|
||||||
#define PNG_HANDLE_CHUNK_ALWAYS HANDLE_CHUNK_ALWAYS
|
#define PNG_HANDLE_CHUNK_ALWAYS HANDLE_CHUNK_ALWAYS
|
||||||
@@ -268,11 +265,14 @@ struct options_help {
|
|||||||
static PNG_CONST char *progname;
|
static PNG_CONST char *progname;
|
||||||
static PNG_CONST char *inname = "pngtest" DOT "png";
|
static PNG_CONST char *inname = "pngtest" DOT "png";
|
||||||
static PNG_CONST char *outname = "pngout" DOT "png";
|
static PNG_CONST char *outname = "pngout" DOT "png";
|
||||||
|
static PNG_CONST char *mngname = "mngout" DOT "mng";
|
||||||
static PNG_CONST char *directory_name = "pngcrush" DOT "bak";
|
static PNG_CONST char *directory_name = "pngcrush" DOT "bak";
|
||||||
static PNG_CONST char *extension = "_C" DOT "png";
|
static PNG_CONST char *extension = "_C" DOT "png";
|
||||||
|
|
||||||
static png_uint_32 width, height;
|
static png_uint_32 width, height;
|
||||||
static png_uint_32 measured_idat_length;
|
static png_uint_32 measured_idat_length;
|
||||||
|
static int found_gAMA = 0;
|
||||||
|
static int found_cHRM = 0;
|
||||||
static int pngcrush_must_exit = 0;
|
static int pngcrush_must_exit = 0;
|
||||||
static int all_chunks_are_safe = 0;
|
static int all_chunks_are_safe = 0;
|
||||||
static int number_of_open_files;
|
static int number_of_open_files;
|
||||||
@@ -352,6 +352,9 @@ static int method = 10;
|
|||||||
static int pauses = 0;
|
static int pauses = 0;
|
||||||
static int nosave = 0;
|
static int nosave = 0;
|
||||||
static int nofilecheck = 0;
|
static int nofilecheck = 0;
|
||||||
|
#ifdef PNGCRUSH_LOCO
|
||||||
|
static int new_mng = 0;
|
||||||
|
#endif
|
||||||
static png_bytep row_buf;
|
static png_bytep row_buf;
|
||||||
#ifdef PNGCRUSH_MULTIPLE_ROWS
|
#ifdef PNGCRUSH_MULTIPLE_ROWS
|
||||||
static png_bytepp row_pointers;
|
static png_bytepp row_pointers;
|
||||||
@@ -397,11 +400,11 @@ static int num_palette;
|
|||||||
static png_byte palette_reorder[256];
|
static png_byte palette_reorder[256];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static png_structp read_ptr, write_ptr;
|
static png_structp read_ptr, write_ptr, mng_ptr;
|
||||||
static png_infop read_info_ptr, write_info_ptr;
|
static png_infop read_info_ptr, write_info_ptr;
|
||||||
static png_infop end_info_ptr;
|
static png_infop end_info_ptr;
|
||||||
static png_infop write_end_info_ptr;
|
static png_infop write_end_info_ptr;
|
||||||
static FILE *fpin, *fpout;
|
static FILE *fpin, *fpout, *mng_out;
|
||||||
png_uint_32 measure_idats(FILE * fpin);
|
png_uint_32 measure_idats(FILE * fpin);
|
||||||
#ifdef PNGCRUSH_LOCO
|
#ifdef PNGCRUSH_LOCO
|
||||||
static int do_loco = 0;
|
static int do_loco = 0;
|
||||||
@@ -1017,8 +1020,8 @@ png_voidp png_debug_malloc(png_structp png_ptr, png_uint_32 size)
|
|||||||
/* Make sure the caller isn't assuming zeroed memory. */
|
/* Make sure the caller isn't assuming zeroed memory. */
|
||||||
png_memset(pinfo->pointer, 0xdd, pinfo->size);
|
png_memset(pinfo->pointer, 0xdd, pinfo->size);
|
||||||
if (verbose > 2)
|
if (verbose > 2)
|
||||||
fprintf(STDERR, "Pointer %x allocated %lu bytes\n",
|
fprintf(STDERR, "Pointer %lux allocated %lu bytes\n",
|
||||||
(int) pinfo->pointer, size);
|
(unsigned long) pinfo->pointer, (unsigned long)size);
|
||||||
return (png_voidp) (pinfo->pointer);
|
return (png_voidp) (pinfo->pointer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1052,13 +1055,14 @@ void png_debug_free(png_structp png_ptr, png_voidp ptr)
|
|||||||
the memory that is to be freed. */
|
the memory that is to be freed. */
|
||||||
memset(ptr, 0x55, pinfo->size);
|
memset(ptr, 0x55, pinfo->size);
|
||||||
if (verbose > 2)
|
if (verbose > 2)
|
||||||
fprintf(STDERR, "Pointer %x freed %lu bytes\n",
|
fprintf(STDERR, "Pointer %lux freed %lu bytes\n",
|
||||||
(int) ptr, pinfo->size);
|
(unsigned long) ptr, (unsigned long)pinfo->size);
|
||||||
png_free_default(png_ptr, pinfo);
|
png_free_default(png_ptr, pinfo);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (pinfo->next == NULL) {
|
if (pinfo->next == NULL) {
|
||||||
fprintf(STDERR, "Pointer %x not found\n", (int) ptr);
|
fprintf(STDERR, "Pointer %lux not found\n",
|
||||||
|
(unsigned long) ptr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ppinfo = &pinfo->next;
|
ppinfo = &pinfo->next;
|
||||||
@@ -1309,23 +1313,23 @@ void show_result(void)
|
|||||||
fprintf(STDERR, " Overall result: no change\n");
|
fprintf(STDERR, " Overall result: no change\n");
|
||||||
else if (total_input_length > total_output_length)
|
else if (total_input_length > total_output_length)
|
||||||
fprintf(STDERR,
|
fprintf(STDERR,
|
||||||
" Overall result: %4.2f%% reduction, %ld bytes\n",
|
" Overall result: %4.2f%% reduction, %lu bytes\n",
|
||||||
(100.0 -
|
(100.0 -
|
||||||
(100.0 * total_output_length) / total_input_length),
|
(100.0 * total_output_length) / total_input_length),
|
||||||
total_input_length - total_output_length);
|
(unsigned long)(total_input_length-total_output_length));
|
||||||
else
|
else
|
||||||
fprintf(STDERR,
|
fprintf(STDERR,
|
||||||
" Overall result: %4.2f%% increase, %ld bytes\n",
|
" Overall result: %4.2f%% increase, %lu bytes\n",
|
||||||
-(100.0 -
|
-(100.0 -
|
||||||
(100.0 * total_output_length) / total_input_length),
|
(100.0 * total_output_length) / total_input_length),
|
||||||
total_output_length - total_input_length);
|
(unsigned long)(total_output_length - total_input_length));
|
||||||
}
|
}
|
||||||
t_stop = (TIME_T) clock();
|
t_stop = (TIME_T) clock();
|
||||||
t_misc += (t_stop - t_start);
|
t_misc += (t_stop - t_start);
|
||||||
if (t_stop < t_start) {
|
if (t_stop < t_start) {
|
||||||
t_misc += PNG_MAX_UINT;
|
t_misc += PNG_UINT_31_MAX;
|
||||||
if (t_stop < 0)
|
if (t_stop < 0)
|
||||||
t_misc += PNG_MAX_UINT;
|
t_misc += PNG_UINT_31_MAX;
|
||||||
}
|
}
|
||||||
t_start = t_stop;
|
t_start = t_stop;
|
||||||
fprintf(STDERR, " CPU time used = %.3f seconds",
|
fprintf(STDERR, " CPU time used = %.3f seconds",
|
||||||
@@ -1342,8 +1346,8 @@ void show_result(void)
|
|||||||
fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n",
|
fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n",
|
||||||
current_allocation);
|
current_allocation);
|
||||||
while (pinfo != NULL) {
|
while (pinfo != NULL) {
|
||||||
fprintf(STDERR, " %8lu bytes at %x\n", pinfo->size,
|
fprintf(STDERR, " %8lu bytes at %lux\n", (unsigned long)pinfo->size,
|
||||||
(int) pinfo->pointer);
|
(unsigned long) pinfo->pointer);
|
||||||
free(pinfo->pointer);
|
free(pinfo->pointer);
|
||||||
pinfo = pinfo->next;
|
pinfo = pinfo->next;
|
||||||
}
|
}
|
||||||
@@ -1551,6 +1555,7 @@ int main(int argc, char *argv[])
|
|||||||
#ifdef PNG_gAMA_SUPPORTED
|
#ifdef PNG_gAMA_SUPPORTED
|
||||||
else if (!strncmp(argv[i], "-dou", 4)) {
|
else if (!strncmp(argv[i], "-dou", 4)) {
|
||||||
double_gamma++;
|
double_gamma++;
|
||||||
|
found_gAMA=1;
|
||||||
global_things_have_changed = 1;
|
global_things_have_changed = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1646,6 +1651,7 @@ int main(int argc, char *argv[])
|
|||||||
else if (!strncmp(argv[i], "-g", 2)) {
|
else if (!strncmp(argv[i], "-g", 2)) {
|
||||||
names++;
|
names++;
|
||||||
BUMP_I;
|
BUMP_I;
|
||||||
|
found_gAMA=1;
|
||||||
if (intent < 0) {
|
if (intent < 0) {
|
||||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||||
int c;
|
int c;
|
||||||
@@ -1705,8 +1711,15 @@ int main(int argc, char *argv[])
|
|||||||
names++;
|
names++;
|
||||||
BUMP_I;
|
BUMP_I;
|
||||||
max_idat_size = (png_uint_32) atoi(argv[i]);
|
max_idat_size = (png_uint_32) atoi(argv[i]);
|
||||||
if (max_idat_size == 0 || max_idat_size > PNG_MAX_UINT)
|
if (max_idat_size == 0 || max_idat_size > PNG_UINT_31_MAX)
|
||||||
max_idat_size = PNG_ZBUF_SIZE;
|
max_idat_size = PNG_ZBUF_SIZE;
|
||||||
|
#ifdef PNGCRUSH_LOCO
|
||||||
|
} else if (!strncmp(argv[i], "-mng", 4)) {
|
||||||
|
names++;
|
||||||
|
BUMP_I;
|
||||||
|
mngname = argv[i];
|
||||||
|
new_mng++;
|
||||||
|
#endif
|
||||||
} else if (!strncmp(argv[i], "-m", 2)) {
|
} else if (!strncmp(argv[i], "-m", 2)) {
|
||||||
names++;
|
names++;
|
||||||
BUMP_I;
|
BUMP_I;
|
||||||
@@ -1742,6 +1755,7 @@ int main(int argc, char *argv[])
|
|||||||
else if (!strncmp(argv[i], "-rep", 4)) {
|
else if (!strncmp(argv[i], "-rep", 4)) {
|
||||||
names++;
|
names++;
|
||||||
BUMP_I;
|
BUMP_I;
|
||||||
|
found_gAMA=1;
|
||||||
{
|
{
|
||||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||||
int c;
|
int c;
|
||||||
@@ -1823,7 +1837,7 @@ int main(int argc, char *argv[])
|
|||||||
i += 2;
|
i += 2;
|
||||||
BUMP_I;
|
BUMP_I;
|
||||||
i -= 3;
|
i -= 3;
|
||||||
if (strlen(argv[i + 2]) < 80 && strlen(argv[i + 3]) < 2048 &&
|
if (strlen(argv[i + 2]) < 180 && strlen(argv[i + 3]) < 2048 &&
|
||||||
text_inputs < 10) {
|
text_inputs < 10) {
|
||||||
#ifdef PNG_iTXt_SUPPORTED
|
#ifdef PNG_iTXt_SUPPORTED
|
||||||
if (!strncmp(argv[i], "-zi", 3)) {
|
if (!strncmp(argv[i], "-zi", 3)) {
|
||||||
@@ -2135,8 +2149,47 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
already_crushed = 0;
|
already_crushed = 0;
|
||||||
|
|
||||||
|
#ifdef PNGCRUSH_LOCO
|
||||||
|
if (new_mng) {
|
||||||
|
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
mng_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING,
|
||||||
|
(png_voidp) NULL, (png_error_ptr) png_cexcept_error,
|
||||||
|
(png_error_ptr) NULL, (png_voidp) NULL,
|
||||||
|
(png_malloc_ptr) png_debug_malloc,
|
||||||
|
(png_free_ptr) png_debug_free);
|
||||||
|
#else
|
||||||
|
mng_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
||||||
|
(png_voidp) NULL, (png_error_ptr) png_cexcept_error,
|
||||||
|
(png_error_ptr) NULL);
|
||||||
|
#endif
|
||||||
|
if (mng_ptr == NULL)
|
||||||
|
fprintf(STDERR, "pngcrush could not create mng_ptr");
|
||||||
|
|
||||||
|
if ((mng_out = FOPEN(mngname, "wb")) == NULL) {
|
||||||
|
fprintf(STDERR, "Could not open output file %s\n",
|
||||||
|
mngname);
|
||||||
|
FCLOSE(fpin);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
number_of_open_files++;
|
||||||
|
png_init_io(mng_ptr, mng_out);
|
||||||
|
png_set_write_fn(mng_ptr, (png_voidp) mng_out,
|
||||||
|
(png_rw_ptr) NULL,
|
||||||
|
NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
idat_length[0] = measure_idats(fpin);
|
idat_length[0] = measure_idats(fpin);
|
||||||
|
|
||||||
|
#ifdef PNGCRUSH_LOCO
|
||||||
|
if (new_mng) {
|
||||||
|
png_destroy_write_struct(&mng_ptr, NULL);
|
||||||
|
FCLOSE(mng_out);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
FCLOSE(fpin);
|
FCLOSE(fpin);
|
||||||
|
|
||||||
if (already_crushed) {
|
if (already_crushed) {
|
||||||
@@ -2149,7 +2202,7 @@ int main(int argc, char *argv[])
|
|||||||
fprintf(STDERR, " Recompressing %s\n", inname);
|
fprintf(STDERR, " Recompressing %s\n", inname);
|
||||||
fprintf(STDERR,
|
fprintf(STDERR,
|
||||||
" Total length of data found in IDAT chunks = %8lu\n",
|
" Total length of data found in IDAT chunks = %8lu\n",
|
||||||
idat_length[0]);
|
(unsigned long)idat_length[0]);
|
||||||
fflush(STDERR);
|
fflush(STDERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2612,10 +2665,17 @@ int main(int argc, char *argv[])
|
|||||||
if (!(int)
|
if (!(int)
|
||||||
(png_memcmp(mng_signature, png_signature, 8))) {
|
(png_memcmp(mng_signature, png_signature, 8))) {
|
||||||
png_byte buffer[40];
|
png_byte buffer[40];
|
||||||
|
unsigned long length;
|
||||||
/* Skip the MHDR */
|
/* Skip the MHDR */
|
||||||
png_permit_mng_features(read_ptr,
|
png_permit_mng_features(read_ptr,
|
||||||
PNG_FLAG_MNG_FILTER_64);
|
PNG_FLAG_MNG_FILTER_64);
|
||||||
png_default_read_data(read_ptr, buffer, 40);
|
png_default_read_data(read_ptr, buffer, 4);
|
||||||
|
length=buffer[3]+(buffer[2]<<8)+(buffer[1]<<16)+(buffer[0]<<24);
|
||||||
|
png_default_read_data(read_ptr, buffer, 4);
|
||||||
|
printf("Skipping %c%c%c%c chunk.\n",buffer[0],buffer[1],
|
||||||
|
buffer[2],buffer[3]);
|
||||||
|
png_default_read_data(read_ptr, buffer, length);
|
||||||
|
png_default_read_data(read_ptr, buffer, 4);
|
||||||
input_format = 1;
|
input_format = 1;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
@@ -2630,7 +2690,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
png_read_info(read_ptr, read_info_ptr);
|
png_read_info(read_ptr, read_info_ptr);
|
||||||
|
|
||||||
{ /* GRR added for quick %-navigation (1) */
|
/* { GRR added for quick %-navigation (1) */
|
||||||
|
|
||||||
/* Start of chunk-copying/removal code, in order:
|
/* Start of chunk-copying/removal code, in order:
|
||||||
* - IHDR
|
* - IHDR
|
||||||
@@ -2673,8 +2733,9 @@ int main(int argc, char *argv[])
|
|||||||
if (verbose > 1 && first_trial) {
|
if (verbose > 1 && first_trial) {
|
||||||
fprintf(STDERR, " IHDR chunk data:\n");
|
fprintf(STDERR, " IHDR chunk data:\n");
|
||||||
fprintf(STDERR,
|
fprintf(STDERR,
|
||||||
" Width=%ld, height=%ld\n", width,
|
" Width=%lu, height=%lu\n",
|
||||||
height);
|
(unsigned long)width,
|
||||||
|
(unsigned long)height);
|
||||||
fprintf(STDERR, " Bit depth =%d\n",
|
fprintf(STDERR, " Bit depth =%d\n",
|
||||||
bit_depth);
|
bit_depth);
|
||||||
fprintf(STDERR, " Color type=%d\n",
|
fprintf(STDERR, " Color type=%d\n",
|
||||||
@@ -2871,7 +2932,7 @@ int main(int argc, char *argv[])
|
|||||||
png_fixed_point white_x, white_y, red_x, red_y,
|
png_fixed_point white_x, white_y, red_x, red_y,
|
||||||
green_x, green_y, blue_x, blue_y;
|
green_x, green_y, blue_x, blue_y;
|
||||||
|
|
||||||
if (png_get_cHRM_fixed
|
if (found_cHRM && png_get_cHRM_fixed
|
||||||
(read_ptr, read_info_ptr, &white_x, &white_y,
|
(read_ptr, read_info_ptr, &white_x, &white_y,
|
||||||
&red_x, &red_y, &green_x, &green_y, &blue_x,
|
&red_x, &red_y, &green_x, &green_y, &blue_x,
|
||||||
&blue_y)) {
|
&blue_y)) {
|
||||||
@@ -2945,10 +3006,10 @@ int main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||||
else if (png_get_gAMA_fixed
|
else if (found_gAMA && png_get_gAMA_fixed
|
||||||
(read_ptr, read_info_ptr, &file_gamma))
|
(read_ptr, read_info_ptr, &file_gamma))
|
||||||
#else
|
#else
|
||||||
else if (png_get_gAMA
|
else if (found_gAMA && png_get_gAMA
|
||||||
(read_ptr, read_info_ptr, &file_gamma))
|
(read_ptr, read_info_ptr, &file_gamma))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
@@ -3023,12 +3084,7 @@ int main(int argc, char *argv[])
|
|||||||
intent);
|
intent);
|
||||||
png_set_sRGB(write_ptr, write_info_ptr,
|
png_set_sRGB(write_ptr, write_info_ptr,
|
||||||
intent);
|
intent);
|
||||||
} else if (file_gamma == 0) {
|
} else if (file_gamma != 0) {
|
||||||
things_have_changed = 1;
|
|
||||||
png_set_sRGB_gAMA_and_cHRM(write_ptr,
|
|
||||||
write_info_ptr,
|
|
||||||
intent);
|
|
||||||
} else {
|
|
||||||
if (first_trial) {
|
if (first_trial) {
|
||||||
fprintf(STDERR, " Ignoring sRGB request; "
|
fprintf(STDERR, " Ignoring sRGB request; "
|
||||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||||
@@ -3036,7 +3092,8 @@ int main(int argc, char *argv[])
|
|||||||
#else
|
#else
|
||||||
"gamma=%f"
|
"gamma=%f"
|
||||||
#endif
|
#endif
|
||||||
" is not approx. 0.455\n", file_gamma);
|
" is not approx. 0.455\n",
|
||||||
|
(unsigned long)file_gamma);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* PNG_gAMA_SUPPORTED */
|
#endif /* PNG_gAMA_SUPPORTED */
|
||||||
@@ -3054,9 +3111,10 @@ int main(int argc, char *argv[])
|
|||||||
if (png_get_iCCP
|
if (png_get_iCCP
|
||||||
(read_ptr, read_info_ptr, &name,
|
(read_ptr, read_info_ptr, &name,
|
||||||
&compression_method, &profile, &proflen)) {
|
&compression_method, &profile, &proflen)) {
|
||||||
P1("Got iccp chunk, proflen=%lu\n", proflen);
|
P1("Got iCCP chunk, proflen=%lu\n",
|
||||||
|
(unsigned long)proflen);
|
||||||
if (iccp_length)
|
if (iccp_length)
|
||||||
P0("Will not replace existing iccp chunk.\n");
|
P0("Will not replace existing iCCP chunk.\n");
|
||||||
if (keep_chunk("iCCP", argv))
|
if (keep_chunk("iCCP", argv))
|
||||||
png_set_iCCP(write_ptr, write_info_ptr, name,
|
png_set_iCCP(write_ptr, write_info_ptr, name,
|
||||||
compression_method, profile,
|
compression_method, profile,
|
||||||
@@ -3067,7 +3125,7 @@ int main(int argc, char *argv[])
|
|||||||
else if (iccp_length) {
|
else if (iccp_length) {
|
||||||
png_set_iCCP(write_ptr, write_info_ptr, iccp_name,
|
png_set_iCCP(write_ptr, write_info_ptr, iccp_name,
|
||||||
0, iccp_text, iccp_length);
|
0, iccp_text, iccp_length);
|
||||||
P1("Wrote iccp chunk, proflen=%d\n", iccp_length);
|
P1("Wrote iCCP chunk, proflen=%d\n", iccp_length);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -3141,7 +3199,8 @@ int main(int argc, char *argv[])
|
|||||||
res_y, unit_type);
|
res_y, unit_type);
|
||||||
if (verbose > 0 && first_trial)
|
if (verbose > 0 && first_trial)
|
||||||
fprintf(STDERR, " Added pHYs %lu %lu 1 chunk\n",
|
fprintf(STDERR, " Added pHYs %lu %lu 1 chunk\n",
|
||||||
res_x, res_y);
|
(unsigned long)res_x,
|
||||||
|
(unsigned long)res_y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -3477,6 +3536,9 @@ int main(int argc, char *argv[])
|
|||||||
printf(" Added a%scompressed iTXt chunk"
|
printf(" Added a%scompressed iTXt chunk"
|
||||||
".\n", (added_text[0].compression == 1)?
|
".\n", (added_text[0].compression == 1)?
|
||||||
"n un" : " ");
|
"n un" : " ");
|
||||||
|
#endif
|
||||||
|
#if 0
|
||||||
|
printf(" key=%s.\n",(added_text[0].key));
|
||||||
#endif
|
#endif
|
||||||
png_free(write_ptr, added_text);
|
png_free(write_ptr, added_text);
|
||||||
added_text = (png_textp) NULL;
|
added_text = (png_textp) NULL;
|
||||||
@@ -3520,11 +3582,12 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
/* make an array of only those chunks we want to keep */
|
/* make an array of only those chunks we want to keep */
|
||||||
for (i = 0; i < num_unknowns; i++) {
|
for (i = 0; i < num_unknowns; i++) {
|
||||||
P1("Handling unknown chunk %d\n", i);
|
P1("Handling unknown chunk %d %s\n", i,
|
||||||
|
(char *)unknowns[i].name);
|
||||||
/* not EBCDIC-safe, but neither is keep_chunks(): */
|
/* not EBCDIC-safe, but neither is keep_chunks(): */
|
||||||
P2(" unknown[%d] = %s (%lu bytes, location %d)\n",
|
P2(" unknown[%d] = %s (%lu bytes, location %d)\n",
|
||||||
i, unknowns[i].name,
|
i, unknowns[i].name,
|
||||||
(png_uint_32)unknowns[i].size,
|
(unsigned long)unknowns[i].size,
|
||||||
unknowns[i].location);
|
unknowns[i].location);
|
||||||
if (keep_chunk((char *)unknowns[i].name, argv)) {
|
if (keep_chunk((char *)unknowns[i].name, argv)) {
|
||||||
memcpy(&unknowns_keep[num_unknowns_keep],
|
memcpy(&unknowns_keep[num_unknowns_keep],
|
||||||
@@ -3558,8 +3621,8 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
P0("unknown chunk handling done.\n");
|
P0("unknown chunk handling done.\n");
|
||||||
#endif /* PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED */
|
#endif /* PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED */
|
||||||
} /* GRR added for quick %-navigation (1) */
|
|
||||||
|
|
||||||
|
/* } GRR added for quick %-navigation (1) */
|
||||||
|
|
||||||
png_read_transform_info(read_ptr, read_info_ptr);
|
png_read_transform_info(read_ptr, read_info_ptr);
|
||||||
|
|
||||||
@@ -3610,8 +3673,7 @@ int main(int argc, char *argv[])
|
|||||||
#ifdef PNGCRUSH_LOCO
|
#ifdef PNGCRUSH_LOCO
|
||||||
if (do_loco) {
|
if (do_loco) {
|
||||||
png_byte buffer[30];
|
png_byte buffer[30];
|
||||||
const png_byte png_MHDR[5] =
|
const png_byte png_MHDR[5] = { 77, 72, 68, 82, '\0' };
|
||||||
{ 77, 72, 68, 82, '\0' };
|
|
||||||
png_byte mng_signature[8] =
|
png_byte mng_signature[8] =
|
||||||
{ 138, 77, 78, 71, 13, 10, 26, 10 };
|
{ 138, 77, 78, 71, 13, 10, 26, 10 };
|
||||||
/* write the MNG 8-byte signature */
|
/* write the MNG 8-byte signature */
|
||||||
@@ -3691,7 +3753,7 @@ int main(int argc, char *argv[])
|
|||||||
if (max_possible_size > max_idat_size)
|
if (max_possible_size > max_idat_size)
|
||||||
max_possible_size = max_idat_size;
|
max_possible_size = max_idat_size;
|
||||||
P2("reinitializing write zbuf to %lu.\n",
|
P2("reinitializing write zbuf to %lu.\n",
|
||||||
max_possible_size);
|
(unsigned long)max_possible_size);
|
||||||
png_set_compression_buffer_size(write_ptr,
|
png_set_compression_buffer_size(write_ptr,
|
||||||
max_possible_size);
|
max_possible_size);
|
||||||
}
|
}
|
||||||
@@ -3833,9 +3895,9 @@ int main(int argc, char *argv[])
|
|||||||
t_stop = (TIME_T) clock();
|
t_stop = (TIME_T) clock();
|
||||||
t_misc += (t_stop - t_start);
|
t_misc += (t_stop - t_start);
|
||||||
if (t_stop < t_start) {
|
if (t_stop < t_start) {
|
||||||
t_misc += PNG_MAX_UINT;
|
t_misc += PNG_UINT_31_MAX;
|
||||||
if (t_stop < 0)
|
if (t_stop < 0)
|
||||||
t_misc += PNG_MAX_UINT;
|
t_misc += PNG_UINT_31_MAX;
|
||||||
}
|
}
|
||||||
t_start = t_stop;
|
t_start = t_stop;
|
||||||
for (pass = 0; pass < num_pass; pass++) {
|
for (pass = 0; pass < num_pass; pass++) {
|
||||||
@@ -3862,9 +3924,9 @@ int main(int argc, char *argv[])
|
|||||||
t_stop = (TIME_T) clock();
|
t_stop = (TIME_T) clock();
|
||||||
t_decode += (t_stop - t_start);
|
t_decode += (t_stop - t_start);
|
||||||
if (t_stop < t_start) {
|
if (t_stop < t_start) {
|
||||||
t_decode += PNG_MAX_UINT;
|
t_decode += PNG_UINT_31_MAX;
|
||||||
if (t_stop < 0)
|
if (t_stop < 0)
|
||||||
t_decode += PNG_MAX_UINT;
|
t_decode += PNG_UINT_31_MAX;
|
||||||
}
|
}
|
||||||
t_start = t_stop;
|
t_start = t_stop;
|
||||||
#ifdef PNGCRUSH_MULTIPLE_ROWS
|
#ifdef PNGCRUSH_MULTIPLE_ROWS
|
||||||
@@ -3876,9 +3938,9 @@ int main(int argc, char *argv[])
|
|||||||
t_stop = (TIME_T) clock();
|
t_stop = (TIME_T) clock();
|
||||||
t_encode += (t_stop - t_start);
|
t_encode += (t_stop - t_start);
|
||||||
if (t_stop < t_start) {
|
if (t_stop < t_start) {
|
||||||
t_encode += PNG_MAX_UINT;
|
t_encode += PNG_UINT_31_MAX;
|
||||||
if (t_stop < 0)
|
if (t_stop < 0)
|
||||||
t_encode += PNG_MAX_UINT;
|
t_encode += PNG_UINT_31_MAX;
|
||||||
}
|
}
|
||||||
t_start = t_stop;
|
t_start = t_stop;
|
||||||
}
|
}
|
||||||
@@ -3889,9 +3951,9 @@ int main(int argc, char *argv[])
|
|||||||
t_stop = (TIME_T) clock();
|
t_stop = (TIME_T) clock();
|
||||||
t_decode += (t_stop - t_start);
|
t_decode += (t_stop - t_start);
|
||||||
if (t_stop < t_start) {
|
if (t_stop < t_start) {
|
||||||
t_decode += PNG_MAX_UINT;
|
t_decode += PNG_UINT_31_MAX;
|
||||||
if (t_stop < 0)
|
if (t_stop < 0)
|
||||||
t_decode += PNG_MAX_UINT;
|
t_decode += PNG_UINT_31_MAX;
|
||||||
}
|
}
|
||||||
t_start = t_stop;
|
t_start = t_stop;
|
||||||
}
|
}
|
||||||
@@ -3928,7 +3990,7 @@ int main(int argc, char *argv[])
|
|||||||
P1( "Reading and writing end_info data\n");
|
P1( "Reading and writing end_info data\n");
|
||||||
png_read_end(read_ptr, end_info_ptr);
|
png_read_end(read_ptr, end_info_ptr);
|
||||||
|
|
||||||
{ /* GRR: added for %-navigation (2) */
|
/* { GRR: added for %-navigation (2) */
|
||||||
|
|
||||||
#if (defined(PNG_READ_tEXt_SUPPORTED) && defined(PNG_WRITE_tEXt_SUPPORTED)) \
|
#if (defined(PNG_READ_tEXt_SUPPORTED) && defined(PNG_WRITE_tEXt_SUPPORTED)) \
|
||||||
|| (defined(PNG_READ_zTXt_SUPPORTED) && defined(PNG_WRITE_zTXt_SUPPORTED))
|
|| (defined(PNG_READ_zTXt_SUPPORTED) && defined(PNG_WRITE_zTXt_SUPPORTED))
|
||||||
@@ -4082,7 +4144,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} /* GRR: added for %-navigation (2) */
|
/* } GRR: added for %-navigation (2) */
|
||||||
|
|
||||||
if (nosave == 0) {
|
if (nosave == 0) {
|
||||||
#if 0 /* doesn't work; compression level has to be the same as in IDAT */
|
#if 0 /* doesn't work; compression level has to be the same as in IDAT */
|
||||||
@@ -4173,7 +4235,7 @@ int main(int argc, char *argv[])
|
|||||||
if (nosave == 0) {
|
if (nosave == 0) {
|
||||||
P1( "Opening file for length measurement\n");
|
P1( "Opening file for length measurement\n");
|
||||||
if ((fpin = FOPEN(outname, "rb")) == NULL) {
|
if ((fpin = FOPEN(outname, "rb")) == NULL) {
|
||||||
fprintf(STDERR, "Could not find file %s\n", outname);
|
fprintf(STDERR, "Could not find output file %s\n", outname);
|
||||||
if (png_row_filters != NULL) {
|
if (png_row_filters != NULL) {
|
||||||
free(png_row_filters);
|
free(png_row_filters);
|
||||||
png_row_filters = NULL;
|
png_row_filters = NULL;
|
||||||
@@ -4191,7 +4253,7 @@ int main(int argc, char *argv[])
|
|||||||
fprintf(STDERR,
|
fprintf(STDERR,
|
||||||
" IDAT length with method %3d (fm %d zl %d zs %d) = %8lu\n",
|
" IDAT length with method %3d (fm %d zl %d zs %d) = %8lu\n",
|
||||||
trial, filter_type, zlib_level, z_strategy,
|
trial, filter_type, zlib_level, z_strategy,
|
||||||
idat_length[trial]);
|
(unsigned long)idat_length[trial]);
|
||||||
fflush(STDERR);
|
fflush(STDERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4303,12 +4365,13 @@ png_uint_32 measure_idats(FILE * fpin)
|
|||||||
|
|
||||||
png_set_sig_bytes(read_ptr, 0);
|
png_set_sig_bytes(read_ptr, 0);
|
||||||
measured_idat_length = png_measure_idat(read_ptr);
|
measured_idat_length = png_measure_idat(read_ptr);
|
||||||
P2("measure_idats: IDAT length=%lu\n", measured_idat_length);
|
P2("measure_idats: IDAT length=%lu\n",
|
||||||
|
(unsigned long)measured_idat_length);
|
||||||
P1( "Destroying data structs\n");
|
P1( "Destroying data structs\n");
|
||||||
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
||||||
}
|
}
|
||||||
Catch(msg) {
|
Catch(msg) {
|
||||||
fprintf(STDERR, "\nWhile reading %s ", inname);
|
fprintf(STDERR, "\nWhile measuring IDATs in %s ", inname);
|
||||||
fprintf(STDERR, "pngcrush caught libpng error:\n %s\n\n", msg);
|
fprintf(STDERR, "pngcrush caught libpng error:\n %s\n\n", msg);
|
||||||
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
||||||
P1( "Destroyed data structs\n");
|
P1( "Destroyed data structs\n");
|
||||||
@@ -4326,6 +4389,8 @@ png_uint_32 png_measure_idat(png_structp png_ptr)
|
|||||||
/* Copyright (C) 1999-2002,2006 Glenn Randers-Pehrson (glennrp@users.sf.net)
|
/* Copyright (C) 1999-2002,2006 Glenn Randers-Pehrson (glennrp@users.sf.net)
|
||||||
See notice in pngcrush.c for conditions of use and distribution */
|
See notice in pngcrush.c for conditions of use and distribution */
|
||||||
png_uint_32 sum_idat_length = 0;
|
png_uint_32 sum_idat_length = 0;
|
||||||
|
png_byte *bb = NULL;
|
||||||
|
png_uint_32 malloced_length=0;
|
||||||
|
|
||||||
{
|
{
|
||||||
png_byte png_signature[8] = { 137, 80, 78, 71, 13, 10, 26, 10 };
|
png_byte png_signature[8] = { 137, 80, 78, 71, 13, 10, 26, 10 };
|
||||||
@@ -4338,10 +4403,50 @@ png_uint_32 png_measure_idat(png_structp png_ptr)
|
|||||||
|
|
||||||
#if defined(PNGCRUSH_LOCO)
|
#if defined(PNGCRUSH_LOCO)
|
||||||
if (!(int) (png_memcmp(mng_signature, png_signature, 8))) {
|
if (!(int) (png_memcmp(mng_signature, png_signature, 8))) {
|
||||||
|
const png_byte png_MHDR[5] = { 77, 72, 68, 82, '\0' };
|
||||||
|
|
||||||
|
int b;
|
||||||
png_byte buffer[40];
|
png_byte buffer[40];
|
||||||
/* skip the MHDR */
|
unsigned long length;
|
||||||
png_default_read_data(read_ptr, buffer, 40);
|
/* read the MHDR */
|
||||||
|
png_default_read_data(read_ptr, buffer, 4);
|
||||||
|
length=buffer[3]+(buffer[2]<<8)+(buffer[1]<<16)+(buffer[0]<<24);
|
||||||
|
png_default_read_data(read_ptr, buffer, 4);
|
||||||
|
printf("Reading %c%c%c%c chunk.\n",buffer[0],buffer[1],
|
||||||
|
buffer[2],buffer[3]);
|
||||||
|
for (b=0; b<40; b++)
|
||||||
|
buffer[b]='\0';
|
||||||
|
png_default_read_data(read_ptr, buffer, length);
|
||||||
|
if (verbose) {
|
||||||
|
printf(" width=%lu\n",(unsigned long)(buffer[3]+(buffer[2]<<8)
|
||||||
|
+(buffer[1]<<16)+(buffer[0]<<24)));
|
||||||
|
printf(" height=%lu\n",(unsigned long)(buffer[7]+(buffer[6]<<8)
|
||||||
|
+(buffer[5]<<16)+(buffer[4]<<24)));
|
||||||
|
printf(" ticksps=%lu\n",(unsigned long)(buffer[11]+
|
||||||
|
(buffer[10]<<8)+(buffer[9]<<16)+(buffer[8]<<24)));
|
||||||
|
printf(" nomlayc=%lu\n",(unsigned long)(buffer[15]+
|
||||||
|
(buffer[14]<<8)+(buffer[13]<<16)+(buffer[12]<<24)));
|
||||||
|
printf(" nomfram=%lu\n",(unsigned long)(buffer[19]+
|
||||||
|
(buffer[18]<<8)+(buffer[17]<<16)+(buffer[16]<<24)));
|
||||||
|
printf(" nomplay=%lu\n",(unsigned long)(buffer[23]+
|
||||||
|
(buffer[22]<<8)+(buffer[21]<<16)+(buffer[20]<<24)));
|
||||||
|
printf(" profile=%lu\n",(unsigned long)(buffer[27]+
|
||||||
|
(buffer[26]<<8)+(buffer[25]<<16)+(buffer[24]<<24)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (new_mng) {
|
||||||
|
/* write the MNG 8-byte signature */
|
||||||
|
png_default_write_data(mng_ptr, &mng_signature[0],
|
||||||
|
(png_size_t) 8);
|
||||||
|
|
||||||
|
/* Write a MHDR chunk */
|
||||||
|
png_write_chunk(mng_ptr, (png_bytep) png_MHDR,
|
||||||
|
buffer, (png_size_t) 28);
|
||||||
|
}
|
||||||
|
|
||||||
|
png_default_read_data(read_ptr, buffer, 4);
|
||||||
input_format = 1;
|
input_format = 1;
|
||||||
|
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
if (png_sig_cmp(png_signature, 0, 8)) {
|
if (png_sig_cmp(png_signature, 0, 8)) {
|
||||||
@@ -4353,10 +4458,15 @@ png_uint_32 png_measure_idat(png_structp png_ptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_CRC_WARN_USE
|
|
||||||
if (fix)
|
if (fix)
|
||||||
|
{
|
||||||
|
#ifdef PNG_CRC_WARN_USE
|
||||||
png_set_crc_action(png_ptr, PNG_CRC_WARN_USE, PNG_CRC_WARN_USE);
|
png_set_crc_action(png_ptr, PNG_CRC_WARN_USE, PNG_CRC_WARN_USE);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
|
||||||
|
inflateUndermine(&png_ptr->zstream, 1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
#ifndef PNG_UINT_IDAT
|
#ifndef PNG_UINT_IDAT
|
||||||
@@ -4382,6 +4492,85 @@ png_uint_32 png_measure_idat(png_structp png_ptr)
|
|||||||
png_reset_crc(png_ptr);
|
png_reset_crc(png_ptr);
|
||||||
png_crc_read(png_ptr, chunk_name, 4);
|
png_crc_read(png_ptr, chunk_name, 4);
|
||||||
|
|
||||||
|
if (new_mng) {
|
||||||
|
const png_byte png_DHDR[5] = { 68, 72, 68, 82, '\0' };
|
||||||
|
const png_byte png_DEFI[5] = { 68, 69, 70, 73, '\0' };
|
||||||
|
const png_byte png_FRAM[5] = { 70, 82, 65, 77, '\0' };
|
||||||
|
const png_byte png_nEED[5] = { 110, 69, 69, 68, '\0' };
|
||||||
|
if (!png_memcmp(chunk_name, png_nEED, 4))
|
||||||
|
{
|
||||||
|
/* Skip the nEED chunk */
|
||||||
|
printf (" skipping MNG %c%c%c%c chunk, %lu bytes\n",chunk_name[0],
|
||||||
|
chunk_name[1],chunk_name[2],chunk_name[3],(unsigned long)length);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* copy the chunk. */
|
||||||
|
printf (" reading MNG %c%c%c%c chunk, %lu bytes\n",chunk_name[0],
|
||||||
|
chunk_name[1],chunk_name[2],chunk_name[3],(unsigned long)length);
|
||||||
|
if (length > malloced_length) {
|
||||||
|
png_free(mng_ptr,bb);
|
||||||
|
printf (" png_malloc %lu bytes.\n",(unsigned long)length);
|
||||||
|
bb=png_malloc(mng_ptr, length);
|
||||||
|
malloced_length=length;
|
||||||
|
}
|
||||||
|
png_crc_read(png_ptr, bb, length);
|
||||||
|
png_write_chunk(mng_ptr, chunk_name,
|
||||||
|
bb, (png_size_t) length);
|
||||||
|
|
||||||
|
if (!png_memcmp(chunk_name, png_DHDR, 4)) {
|
||||||
|
if (verbose > 1) {
|
||||||
|
printf(" objid=%lu\n",(unsigned long)(bb[1]+(bb[0]<<8)));
|
||||||
|
printf(" itype=%lu\n",(unsigned long)(bb[2]));
|
||||||
|
printf(" dtype=%lu\n",(unsigned long)(bb[3]));
|
||||||
|
printf(" width=%lu\n",(unsigned long)(bb[7]+(bb[6]<<8)
|
||||||
|
+(bb[5]<<16)+(bb[4]<<24)));
|
||||||
|
printf(" height=%lu\n",(unsigned long)(bb[11]+(bb[10]<<8)
|
||||||
|
+(bb[9]<<16)+(bb[8]<<24)));
|
||||||
|
printf(" xloc=%lu\n",(unsigned long)(bb[15]+(bb[14]<<8)
|
||||||
|
+(bb[13]<<16)+(bb[12]<<24)));
|
||||||
|
printf(" yloc=%lu\n",(unsigned long)(bb[19]+(bb[18]<<8)
|
||||||
|
+(bb[17]<<16)+(bb[16]<<24)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!png_memcmp(chunk_name, png_DEFI, 4)) {
|
||||||
|
if (verbose > 1) {
|
||||||
|
printf(" objid=%lu\n",(unsigned long)(bb[1]+(bb[0]<<8)));
|
||||||
|
printf(" do_not_show=%lu\n",(unsigned long)(bb[2]));
|
||||||
|
printf(" concrete=%lu\n",(unsigned long)(bb[3]));
|
||||||
|
if (length > 4) {
|
||||||
|
printf(" xloc=%lu\n",(unsigned long)(bb[15]+(bb[14]<<8)
|
||||||
|
+(bb[13]<<16)+(bb[12]<<24)));
|
||||||
|
printf(" yloc=%lu\n",(unsigned long)(bb[19]+(bb[18]<<8)
|
||||||
|
+(bb[17]<<16)+(bb[16]<<24)));
|
||||||
|
if (length > 12) {
|
||||||
|
printf(" l_cb=%lu\n",(unsigned long)(bb[20]+(bb[19]<<8)
|
||||||
|
+(bb[18]<<16)+(bb[17]<<24)));
|
||||||
|
printf(" r_cb=%lu\n",(unsigned long)(bb[24]+(bb[23]<<8)
|
||||||
|
+(bb[22]<<16)+(bb[21]<<24)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!png_memcmp(chunk_name, png_FRAM, 4)) {
|
||||||
|
if (verbose > 1) {
|
||||||
|
printf(" mode=%lu\n",(unsigned long)bb[0]);
|
||||||
|
if (length > 1) {
|
||||||
|
int ib;
|
||||||
|
printf(" name = ");
|
||||||
|
for (ib=0; bb[ib]; ib++)
|
||||||
|
{
|
||||||
|
printf ("%c", bb[ib]);
|
||||||
|
}
|
||||||
|
printf ("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
length=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
|
||||||
#ifdef PNG_UINT_IDAT
|
#ifdef PNG_UINT_IDAT
|
||||||
if (png_get_uint_32(chunk_name) == PNG_UINT_IDAT)
|
if (png_get_uint_32(chunk_name) == PNG_UINT_IDAT)
|
||||||
#else
|
#else
|
||||||
@@ -4395,8 +4584,8 @@ png_uint_32 png_measure_idat(png_structp png_ptr)
|
|||||||
|
|
||||||
if (verbose > 1) {
|
if (verbose > 1) {
|
||||||
chunk_name[4] = '\0';
|
chunk_name[4] = '\0';
|
||||||
printf("Reading %s chunk, length = %ld.\n", chunk_name,
|
printf("Reading %s chunk, length = %lu.\n", chunk_name,
|
||||||
length);
|
(unsigned long)length);
|
||||||
}
|
}
|
||||||
#ifdef PNG_UINT_IHDR
|
#ifdef PNG_UINT_IHDR
|
||||||
if (png_get_uint_32(chunk_name) == PNG_UINT_IHDR)
|
if (png_get_uint_32(chunk_name) == PNG_UINT_IHDR)
|
||||||
@@ -4409,6 +4598,17 @@ png_uint_32 png_measure_idat(png_structp png_ptr)
|
|||||||
length -= 13;
|
length -= 13;
|
||||||
input_color_type = buffer[9];
|
input_color_type = buffer[9];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_gAMA_SUPPORTED
|
||||||
|
if (png_get_uint_32(chunk_name) == PNG_UINT_gAMA)
|
||||||
|
found_gAMA=1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_cHRM_SUPPORTED
|
||||||
|
if (png_get_uint_32(chunk_name) == PNG_UINT_cHRM)
|
||||||
|
found_cHRM=1;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_iCCP_SUPPORTED
|
#ifdef PNG_iCCP_SUPPORTED
|
||||||
/* check for bad Photoshop iCCP chunk */
|
/* check for bad Photoshop iCCP chunk */
|
||||||
#ifdef PNG_UINT_iCCP
|
#ifdef PNG_UINT_iCCP
|
||||||
@@ -4445,8 +4645,32 @@ png_uint_32 png_measure_idat(png_structp png_ptr)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
png_crc_finish(png_ptr, length);
|
png_crc_finish(png_ptr, length);
|
||||||
|
|
||||||
|
#ifdef PNGCRUSH_LOCO
|
||||||
|
#ifdef PNG_UINT_MEND
|
||||||
|
if (png_get_uint_32(chunk_name) == PNG_UINT_MEND)
|
||||||
|
return sum_idat_length;
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
const png_byte png_MEND[5] =
|
||||||
|
{ 77, 69, 78, 68, '\0' };
|
||||||
|
if (!png_memcmp(chunk_name, png_MEND, 4))
|
||||||
|
{
|
||||||
|
if (new_mng)
|
||||||
|
png_free(mng_ptr,bb);
|
||||||
|
return (0);
|
||||||
|
return sum_idat_length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
if (input_format == 0)
|
||||||
|
{
|
||||||
#ifdef PNG_UINT_IEND
|
#ifdef PNG_UINT_IEND
|
||||||
if (png_get_uint_32(chunk_name) == PNG_UINT_IEND)
|
if (png_get_uint_32(chunk_name) == PNG_UINT_IEND)
|
||||||
#else
|
#else
|
||||||
@@ -4454,6 +4678,7 @@ png_uint_32 png_measure_idat(png_structp png_ptr)
|
|||||||
#endif
|
#endif
|
||||||
return sum_idat_length;
|
return sum_idat_length;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4556,8 +4781,15 @@ int count_colors(FILE * fpin)
|
|||||||
#if defined(PNGCRUSH_LOCO)
|
#if defined(PNGCRUSH_LOCO)
|
||||||
if (!(int) (png_memcmp(mng_signature, png_signature, 8))) {
|
if (!(int) (png_memcmp(mng_signature, png_signature, 8))) {
|
||||||
png_byte buffer[40];
|
png_byte buffer[40];
|
||||||
|
unsigned long length;
|
||||||
/* skip the MHDR */
|
/* skip the MHDR */
|
||||||
png_default_read_data(read_ptr, buffer, 40);
|
png_default_read_data(read_ptr, buffer, 4);
|
||||||
|
length=buffer[3]+(buffer[2]<<8)+(buffer[1]<<16)+(buffer[0]<<24);
|
||||||
|
png_default_read_data(read_ptr, buffer, 4);
|
||||||
|
printf("Skipping %c%c%c%c chunk.\n",buffer[0],buffer[1],
|
||||||
|
buffer[2],buffer[3]);
|
||||||
|
png_default_read_data(read_ptr, buffer, length);
|
||||||
|
png_default_read_data(read_ptr, buffer, 4);
|
||||||
png_permit_mng_features(read_ptr,
|
png_permit_mng_features(read_ptr,
|
||||||
PNG_FLAG_MNG_FILTER_64);
|
PNG_FLAG_MNG_FILTER_64);
|
||||||
input_format = 1;
|
input_format = 1;
|
||||||
@@ -4963,7 +5195,7 @@ void print_version_info(void)
|
|||||||
" | pngcrush %s\n"
|
" | pngcrush %s\n"
|
||||||
/* If you have modified this source, you may insert additional notices
|
/* If you have modified this source, you may insert additional notices
|
||||||
* immediately after this sentence: */
|
* immediately after this sentence: */
|
||||||
" | Copyright (C) 1998-2002,2006 Glenn Randers-Pehrson\n"
|
" | Copyright (C) 1998-2002,2006-2008 Glenn Randers-Pehrson\n"
|
||||||
" | Copyright (C) 2005 Greg Roelofs\n"
|
" | Copyright (C) 2005 Greg Roelofs\n"
|
||||||
" | This is a free, open-source program. Permission is irrevocably\n"
|
" | This is a free, open-source program. Permission is irrevocably\n"
|
||||||
" | granted to everyone to use this version of pngcrush without\n"
|
" | granted to everyone to use this version of pngcrush without\n"
|
||||||
@@ -4971,7 +5203,7 @@ void print_version_info(void)
|
|||||||
" | Executable name is %s\n"
|
" | Executable name is %s\n"
|
||||||
" | It was built with libpng version %s, and is\n"
|
" | It was built with libpng version %s, and is\n"
|
||||||
" | running with %s"
|
" | running with %s"
|
||||||
" | Copyright (C) 1998-2004,2006 Glenn Randers-Pehrson,\n"
|
" | Copyright (C) 1998-2004,2006-2008 Glenn Randers-Pehrson,\n"
|
||||||
" | Copyright (C) 1996, 1997 Andreas Dilger,\n"
|
" | Copyright (C) 1996, 1997 Andreas Dilger,\n"
|
||||||
" | Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc.,\n"
|
" | Copyright (C) 1995, Guy Eric Schalnat, Group 42 Inc.,\n"
|
||||||
" | and zlib version %s, Copyright (C) 1998-2002 (or later),\n"
|
" | and zlib version %s, Copyright (C) 1998-2002 (or later),\n"
|
||||||
@@ -5009,7 +5241,7 @@ static const char *pngcrush_legal[] = {
|
|||||||
"",
|
"",
|
||||||
/* If you have modified this source, you may insert additional notices
|
/* If you have modified this source, you may insert additional notices
|
||||||
* immediately after this sentence: */
|
* immediately after this sentence: */
|
||||||
"Copyright (C) 1998-2002,2006 Glenn Randers-Pehrson (glennrp@users.sf.net)",
|
"Copyright (C) 1998-2002,2006-2008 Glenn Randers-Pehrson (glennrp@users.sf.net)",
|
||||||
"Copyright (C) 2005 Greg Roelofs",
|
"Copyright (C) 2005 Greg Roelofs",
|
||||||
"",
|
"",
|
||||||
"DISCLAIMER: The pngcrush computer program is supplied \"AS IS\".",
|
"DISCLAIMER: The pngcrush computer program is supplied \"AS IS\".",
|
||||||
@@ -5197,6 +5429,12 @@ struct options_help pngcrush_options[] = {
|
|||||||
{0, " -max maximum_IDAT_size [default "STRNGIFY(PNG_ZBUF_SIZE)"]"},
|
{0, " -max maximum_IDAT_size [default "STRNGIFY(PNG_ZBUF_SIZE)"]"},
|
||||||
{2, ""},
|
{2, ""},
|
||||||
|
|
||||||
|
#ifdef PNGCRUSH_LOCO
|
||||||
|
{0, " -mng (write a new MNG, do not crush embedded PNGs)"},
|
||||||
|
{2, ""},
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef PNGCRUSH_COUNT_COLORS
|
#ifdef PNGCRUSH_COUNT_COLORS
|
||||||
{0, " -no_cc (no color counting)"},
|
{0, " -no_cc (no color counting)"},
|
||||||
{2, ""},
|
{2, ""},
|
||||||
|
|||||||
@@ -18,10 +18,7 @@
|
|||||||
#define PNGCRUSH_LIBPNG_VER 10007
|
#define PNGCRUSH_LIBPNG_VER 10007
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(PNG_USE_PNGGCCRD) && !defined(PNG_USE_PNGVCRD) && \
|
|
||||||
!defined(PNG_NO_ASSEMBLER_CODE)
|
|
||||||
#define PNG_NO_ASSEMBLER_CODE
|
#define PNG_NO_ASSEMBLER_CODE
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PNG_NO_ZALLOC_ZERO
|
#ifndef PNG_NO_ZALLOC_ZERO
|
||||||
# define PNG_NO_ZALLOC_ZERO /* speeds it up a little */
|
# define PNG_NO_ZALLOC_ZERO /* speeds it up a little */
|
||||||
|
|||||||
78
pngerror.c
78
pngerror.c
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
/* pngerror.c - stub functions for i/o and memory allocation
|
/* pngerror.c - stub functions for i/o and memory allocation
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.2.9 April 14, 2006
|
* Last changed in libpng 1.2.22 [October 13, 2007]
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@@ -20,15 +20,18 @@
|
|||||||
static void /* PRIVATE */
|
static void /* PRIVATE */
|
||||||
png_default_error PNGARG((png_structp png_ptr,
|
png_default_error PNGARG((png_structp png_ptr,
|
||||||
png_const_charp error_message));
|
png_const_charp error_message));
|
||||||
|
#ifndef PNG_NO_WARNINGS
|
||||||
static void /* PRIVATE */
|
static void /* PRIVATE */
|
||||||
png_default_warning PNGARG((png_structp png_ptr,
|
png_default_warning PNGARG((png_structp png_ptr,
|
||||||
png_const_charp warning_message));
|
png_const_charp warning_message));
|
||||||
|
#endif /* PNG_NO_WARNINGS */
|
||||||
|
|
||||||
/* This function is called whenever there is a fatal error. This function
|
/* This function is called whenever there is a fatal error. This function
|
||||||
* should not be changed. If there is a need to handle errors differently,
|
* should not be changed. If there is a need to handle errors differently,
|
||||||
* you should supply a replacement error function and use png_set_error_fn()
|
* you should supply a replacement error function and use png_set_error_fn()
|
||||||
* to replace the error function at run-time.
|
* to replace the error function at run-time.
|
||||||
*/
|
*/
|
||||||
|
#ifndef PNG_NO_ERROR_TEXT
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_error(png_structp png_ptr, png_const_charp error_message)
|
png_error(png_structp png_ptr, png_const_charp error_message)
|
||||||
{
|
{
|
||||||
@@ -75,7 +78,20 @@ png_error(png_structp png_ptr, png_const_charp error_message)
|
|||||||
use the default handler, which will not return. */
|
use the default handler, which will not return. */
|
||||||
png_default_error(png_ptr, error_message);
|
png_default_error(png_ptr, error_message);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
void PNGAPI
|
||||||
|
png_err(png_structp png_ptr)
|
||||||
|
{
|
||||||
|
if (png_ptr != NULL && png_ptr->error_fn != NULL)
|
||||||
|
(*(png_ptr->error_fn))(png_ptr, '\0');
|
||||||
|
|
||||||
|
/* If the custom handler doesn't exist, or if it returns,
|
||||||
|
use the default handler, which will not return. */
|
||||||
|
png_default_error(png_ptr, '\0');
|
||||||
|
}
|
||||||
|
#endif /* PNG_NO_ERROR_TEXT */
|
||||||
|
|
||||||
|
#ifndef PNG_NO_WARNINGS
|
||||||
/* This function is called whenever there is a non-fatal error. This function
|
/* This function is called whenever there is a non-fatal error. This function
|
||||||
* should not be changed. If there is a need to handle warnings differently,
|
* should not be changed. If there is a need to handle warnings differently,
|
||||||
* you should supply a replacement warning function and use
|
* you should supply a replacement warning function and use
|
||||||
@@ -105,6 +121,8 @@ png_warning(png_structp png_ptr, png_const_charp warning_message)
|
|||||||
else
|
else
|
||||||
png_default_warning(png_ptr, warning_message+offset);
|
png_default_warning(png_ptr, warning_message+offset);
|
||||||
}
|
}
|
||||||
|
#endif /* PNG_NO_WARNINGS */
|
||||||
|
|
||||||
|
|
||||||
/* These utilities are used internally to build an error message that relates
|
/* These utilities are used internally to build an error message that relates
|
||||||
* to the current chunk. The chunk name comes from png_ptr->chunk_name,
|
* to the current chunk. The chunk name comes from png_ptr->chunk_name,
|
||||||
@@ -118,6 +136,9 @@ static PNG_CONST char png_digit[16] = {
|
|||||||
'A', 'B', 'C', 'D', 'E', 'F'
|
'A', 'B', 'C', 'D', 'E', 'F'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define PNG_MAX_ERROR_TEXT 64
|
||||||
|
|
||||||
|
#if !defined(PNG_NO_WARNINGS) || !defined(PNG_NO_ERROR_TEXT)
|
||||||
static void /* PRIVATE */
|
static void /* PRIVATE */
|
||||||
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
||||||
error_message)
|
error_message)
|
||||||
@@ -141,35 +162,47 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (error_message == NULL)
|
if (error_message == NULL)
|
||||||
buffer[iout] = 0;
|
buffer[iout] = '\0';
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buffer[iout++] = ':';
|
buffer[iout++] = ':';
|
||||||
buffer[iout++] = ' ';
|
buffer[iout++] = ' ';
|
||||||
png_strncpy(buffer+iout, error_message, 63);
|
png_memcpy(buffer+iout, error_message, PNG_MAX_ERROR_TEXT);
|
||||||
buffer[iout+63] = 0;
|
buffer[iout+PNG_MAX_ERROR_TEXT-1] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_READ_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_chunk_error(png_structp png_ptr, png_const_charp error_message)
|
png_chunk_error(png_structp png_ptr, png_const_charp error_message)
|
||||||
{
|
{
|
||||||
char msg[18+64];
|
char msg[18+PNG_MAX_ERROR_TEXT];
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
png_error(png_ptr, error_message);
|
png_error(png_ptr, error_message);
|
||||||
png_format_buffer(png_ptr, msg, error_message);
|
else
|
||||||
png_error(png_ptr, msg);
|
{
|
||||||
|
png_format_buffer(png_ptr, msg, error_message);
|
||||||
|
png_error(png_ptr, msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* PNG_READ_SUPPORTED */
|
||||||
|
#endif /* !defined(PNG_NO_WARNINGS) || !defined(PNG_NO_ERROR_TEXT) */
|
||||||
|
|
||||||
|
#ifndef PNG_NO_WARNINGS
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
|
png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
|
||||||
{
|
{
|
||||||
char msg[18+64];
|
char msg[18+PNG_MAX_ERROR_TEXT];
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
png_warning(png_ptr, warning_message);
|
png_warning(png_ptr, warning_message);
|
||||||
png_format_buffer(png_ptr, msg, warning_message);
|
else
|
||||||
png_warning(png_ptr, msg);
|
{
|
||||||
|
png_format_buffer(png_ptr, msg, warning_message);
|
||||||
|
png_warning(png_ptr, msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* PNG_NO_WARNINGS */
|
||||||
|
|
||||||
|
|
||||||
/* This is the default error handling function. Note that replacements for
|
/* This is the default error handling function. Note that replacements for
|
||||||
* this function MUST NOT RETURN, or the program will likely crash. This
|
* this function MUST NOT RETURN, or the program will likely crash. This
|
||||||
@@ -206,27 +239,27 @@ png_default_error(png_structp png_ptr, png_const_charp error_message)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_SETJMP_SUPPORTED
|
#ifdef PNG_SETJMP_SUPPORTED
|
||||||
|
if (png_ptr)
|
||||||
|
{
|
||||||
# ifdef USE_FAR_KEYWORD
|
# ifdef USE_FAR_KEYWORD
|
||||||
{
|
{
|
||||||
jmp_buf jmpbuf;
|
jmp_buf jmpbuf;
|
||||||
png_memcpy(jmpbuf,png_ptr->jmpbuf,png_sizeof(jmp_buf));
|
png_memcpy(jmpbuf, png_ptr->jmpbuf, png_sizeof(jmp_buf));
|
||||||
longjmp(jmpbuf, 1);
|
longjmp(jmpbuf, 1);
|
||||||
}
|
}
|
||||||
# else
|
# else
|
||||||
longjmp(png_ptr->jmpbuf, 1);
|
longjmp(png_ptr->jmpbuf, 1);
|
||||||
# endif
|
# endif
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
/* make compiler happy */ ;
|
|
||||||
if (png_ptr)
|
|
||||||
PNG_ABORT();
|
PNG_ABORT();
|
||||||
#endif
|
#endif
|
||||||
#ifdef PNG_NO_CONSOLE_IO
|
#ifdef PNG_NO_CONSOLE_IO
|
||||||
/* make compiler happy */ ;
|
error_message = error_message; /* make compiler happy */
|
||||||
if (&error_message != NULL)
|
|
||||||
return;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef PNG_NO_WARNINGS
|
||||||
/* This function is called when there is a warning, but the library thinks
|
/* This function is called when there is a warning, but the library thinks
|
||||||
* it can continue anyway. Replacement functions don't have to do anything
|
* it can continue anyway. Replacement functions don't have to do anything
|
||||||
* here if you don't want them to. In the default configuration, png_ptr is
|
* here if you don't want them to. In the default configuration, png_ptr is
|
||||||
@@ -260,14 +293,11 @@ png_default_warning(png_structp png_ptr, png_const_charp warning_message)
|
|||||||
# endif
|
# endif
|
||||||
fprintf(stderr, "libpng warning: %s\n", warning_message);
|
fprintf(stderr, "libpng warning: %s\n", warning_message);
|
||||||
#else
|
#else
|
||||||
/* make compiler happy */ ;
|
warning_message = warning_message; /* make compiler happy */
|
||||||
if (warning_message)
|
|
||||||
return;
|
|
||||||
#endif
|
#endif
|
||||||
/* make compiler happy */ ;
|
png_ptr = png_ptr; /* make compiler happy */
|
||||||
if (png_ptr)
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
#endif /* PNG_NO_WARNINGS */
|
||||||
|
|
||||||
/* This function is called when the application wants to use another method
|
/* This function is called when the application wants to use another method
|
||||||
* of handling errors and warnings. Note that the error function MUST NOT
|
* of handling errors and warnings. Note that the error function MUST NOT
|
||||||
|
|||||||
5389
pnggccrd.c
5389
pnggccrd.c
File diff suppressed because it is too large
Load Diff
88
pngget.c
88
pngget.c
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
/* pngget.c - retrieval of values from info struct
|
/* pngget.c - retrieval of values from info struct
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.2.9 April 14, 2006
|
* Last changed in libpng 1.2.15 January 5, 2007
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*/
|
*/
|
||||||
@@ -512,8 +512,11 @@ png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
|
|||||||
png_sPLT_tpp spalettes)
|
png_sPLT_tpp spalettes)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
|
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
|
||||||
|
{
|
||||||
*spalettes = info_ptr->splt_palettes;
|
*spalettes = info_ptr->splt_palettes;
|
||||||
return ((png_uint_32)info_ptr->splt_palettes_num);
|
return ((png_uint_32)info_ptr->splt_palettes_num);
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -800,8 +803,11 @@ png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
|
|||||||
png_unknown_chunkpp unknowns)
|
png_unknown_chunkpp unknowns)
|
||||||
{
|
{
|
||||||
if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
|
if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
|
||||||
|
{
|
||||||
*unknowns = info_ptr->unknown_chunks;
|
*unknowns = info_ptr->unknown_chunks;
|
||||||
return ((png_uint_32)info_ptr->unknown_chunks_num);
|
return ((png_uint_32)info_ptr->unknown_chunks_num);
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -829,96 +835,53 @@ png_get_compression_buffer_size(png_structp png_ptr)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PNG_1_0_X
|
|
||||||
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
|
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
|
||||||
|
#ifndef PNG_1_0_X
|
||||||
/* this function was added to libpng 1.2.0 and should exist by default */
|
/* this function was added to libpng 1.2.0 and should exist by default */
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_asm_flags (png_structp png_ptr)
|
png_get_asm_flags (png_structp png_ptr)
|
||||||
{
|
{
|
||||||
return (png_uint_32)(png_ptr? png_ptr->asm_flags : 0L);
|
/* obsolete, to be removed from libpng-1.4.0 */
|
||||||
|
return (png_ptr? 0L: 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this function was added to libpng 1.2.0 and should exist by default */
|
/* this function was added to libpng 1.2.0 and should exist by default */
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_asm_flagmask (int flag_select)
|
png_get_asm_flagmask (int flag_select)
|
||||||
{
|
{
|
||||||
png_uint_32 settable_asm_flags = 0;
|
/* obsolete, to be removed from libpng-1.4.0 */
|
||||||
|
flag_select=flag_select;
|
||||||
if (flag_select & PNG_SELECT_READ)
|
return 0L;
|
||||||
settable_asm_flags |=
|
|
||||||
PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_INTERLACE |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_FILTER_UP |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
|
|
||||||
/* no non-MMX flags yet */
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* GRR: no write-flags yet, either, but someday... */
|
|
||||||
if (flag_select & PNG_SELECT_WRITE)
|
|
||||||
settable_asm_flags |=
|
|
||||||
PNG_ASM_FLAG_MMX_WRITE_ [whatever] ;
|
|
||||||
#endif /* 0 */
|
|
||||||
|
|
||||||
return settable_asm_flags; /* _theoretically_ settable capabilities only */
|
|
||||||
}
|
}
|
||||||
#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
|
|
||||||
/* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */
|
/* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */
|
||||||
/* this function was added to libpng 1.2.0 */
|
/* this function was added to libpng 1.2.0 */
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_mmx_flagmask (int flag_select, int *compilerID)
|
png_get_mmx_flagmask (int flag_select, int *compilerID)
|
||||||
{
|
{
|
||||||
png_uint_32 settable_mmx_flags = 0;
|
/* obsolete, to be removed from libpng-1.4.0 */
|
||||||
|
flag_select=flag_select;
|
||||||
if (flag_select & PNG_SELECT_READ)
|
*compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */
|
||||||
settable_mmx_flags |=
|
return 0L;
|
||||||
PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_INTERLACE |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_FILTER_UP |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ;
|
|
||||||
#if 0
|
|
||||||
/* GRR: no MMX write support yet, but someday... */
|
|
||||||
if (flag_select & PNG_SELECT_WRITE)
|
|
||||||
settable_mmx_flags |=
|
|
||||||
PNG_ASM_FLAG_MMX_WRITE_ [whatever] ;
|
|
||||||
#endif /* 0 */
|
|
||||||
|
|
||||||
if (compilerID != NULL) {
|
|
||||||
#ifdef PNG_USE_PNGVCRD
|
|
||||||
*compilerID = 1; /* MSVC */
|
|
||||||
#else
|
|
||||||
#ifdef PNG_USE_PNGGCCRD
|
|
||||||
*compilerID = 2; /* gcc/gas */
|
|
||||||
#else
|
|
||||||
*compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return settable_mmx_flags; /* _theoretically_ settable capabilities only */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this function was added to libpng 1.2.0 */
|
/* this function was added to libpng 1.2.0 */
|
||||||
png_byte PNGAPI
|
png_byte PNGAPI
|
||||||
png_get_mmx_bitdepth_threshold (png_structp png_ptr)
|
png_get_mmx_bitdepth_threshold (png_structp png_ptr)
|
||||||
{
|
{
|
||||||
return (png_byte)(png_ptr? png_ptr->mmx_bitdepth_threshold : 0);
|
/* obsolete, to be removed from libpng-1.4.0 */
|
||||||
|
return (png_ptr? 0: 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this function was added to libpng 1.2.0 */
|
/* this function was added to libpng 1.2.0 */
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_get_mmx_rowbytes_threshold (png_structp png_ptr)
|
png_get_mmx_rowbytes_threshold (png_structp png_ptr)
|
||||||
{
|
{
|
||||||
return (png_uint_32)(png_ptr? png_ptr->mmx_rowbytes_threshold : 0L);
|
/* obsolete, to be removed from libpng-1.4.0 */
|
||||||
|
return (png_ptr? 0L: 0L);
|
||||||
}
|
}
|
||||||
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
|
|
||||||
#endif /* ?PNG_1_0_X */
|
#endif /* ?PNG_1_0_X */
|
||||||
|
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
|
||||||
|
|
||||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||||
/* these functions were added to libpng 1.2.6 */
|
/* these functions were added to libpng 1.2.6 */
|
||||||
@@ -933,5 +896,6 @@ png_get_user_height_max (png_structp png_ptr)
|
|||||||
return (png_ptr? png_ptr->user_height_max : 0);
|
return (png_ptr? png_ptr->user_height_max : 0);
|
||||||
}
|
}
|
||||||
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
|
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
|
||||||
|
|
||||||
|
|
||||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||||
|
|||||||
18
pngmem.c
18
pngmem.c
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
/* pngmem.c - stub functions for memory allocation
|
/* pngmem.c - stub functions for memory allocation
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.2.9 April 14, 2006
|
* Last changed in libpng 1.2.27 [April 29, 2008]
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@@ -137,6 +137,9 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
|
|||||||
png_voidp ret;
|
png_voidp ret;
|
||||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
|
|
||||||
|
if (png_ptr == NULL || size == 0)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
#ifdef PNG_MAX_MALLOC_64K
|
#ifdef PNG_MAX_MALLOC_64K
|
||||||
if (size > (png_uint_32)65536L)
|
if (size > (png_uint_32)65536L)
|
||||||
{
|
{
|
||||||
@@ -290,6 +293,8 @@ png_free_default(png_structp png_ptr, png_voidp ptr)
|
|||||||
{
|
{
|
||||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
|
|
||||||
|
if(png_ptr == NULL || ptr == NULL) return;
|
||||||
|
|
||||||
if (png_ptr->offset_table != NULL)
|
if (png_ptr->offset_table != NULL)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -451,7 +456,7 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size)
|
|||||||
if (size > (png_uint_32)65536L)
|
if (size > (png_uint_32)65536L)
|
||||||
{
|
{
|
||||||
#ifndef PNG_USER_MEM_SUPPORTED
|
#ifndef PNG_USER_MEM_SUPPORTED
|
||||||
if(png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
|
||||||
png_error(png_ptr, "Cannot Allocate > 64K");
|
png_error(png_ptr, "Cannot Allocate > 64K");
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@@ -536,8 +541,10 @@ png_voidp PNGAPI
|
|||||||
png_malloc_warn(png_structp png_ptr, png_uint_32 size)
|
png_malloc_warn(png_structp png_ptr, png_uint_32 size)
|
||||||
{
|
{
|
||||||
png_voidp ptr;
|
png_voidp ptr;
|
||||||
png_uint_32 save_flags=png_ptr->flags;
|
png_uint_32 save_flags;
|
||||||
|
if(png_ptr == NULL) return (NULL);
|
||||||
|
|
||||||
|
save_flags=png_ptr->flags;
|
||||||
png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
|
png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
|
||||||
ptr = (png_voidp)png_malloc((png_structp)png_ptr, size);
|
ptr = (png_voidp)png_malloc((png_structp)png_ptr, size);
|
||||||
png_ptr->flags=save_flags;
|
png_ptr->flags=save_flags;
|
||||||
@@ -580,9 +587,11 @@ void PNGAPI
|
|||||||
png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
||||||
malloc_fn, png_free_ptr free_fn)
|
malloc_fn, png_free_ptr free_fn)
|
||||||
{
|
{
|
||||||
|
if(png_ptr != NULL) {
|
||||||
png_ptr->mem_ptr = mem_ptr;
|
png_ptr->mem_ptr = mem_ptr;
|
||||||
png_ptr->malloc_fn = malloc_fn;
|
png_ptr->malloc_fn = malloc_fn;
|
||||||
png_ptr->free_fn = free_fn;
|
png_ptr->free_fn = free_fn;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function returns a pointer to the mem_ptr associated with the user
|
/* This function returns a pointer to the mem_ptr associated with the user
|
||||||
@@ -592,6 +601,7 @@ png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
|
|||||||
png_voidp PNGAPI
|
png_voidp PNGAPI
|
||||||
png_get_mem_ptr(png_structp png_ptr)
|
png_get_mem_ptr(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
|
if(png_ptr == NULL) return (NULL);
|
||||||
return ((png_voidp)png_ptr->mem_ptr);
|
return ((png_voidp)png_ptr->mem_ptr);
|
||||||
}
|
}
|
||||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
|
|||||||
234
pngpread.c
234
pngpread.c
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
/* pngpread.c - read a png file in push mode
|
/* pngpread.c - read a png file in push mode
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.2.8 - December 3, 2004
|
* Last changed in libpng 1.2.27 [April 29, 2008]
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*/
|
*/
|
||||||
@@ -28,6 +28,7 @@ void PNGAPI
|
|||||||
png_process_data(png_structp png_ptr, png_infop info_ptr,
|
png_process_data(png_structp png_ptr, png_infop info_ptr,
|
||||||
png_bytep buffer, png_size_t buffer_size)
|
png_bytep buffer, png_size_t buffer_size)
|
||||||
{
|
{
|
||||||
|
if(png_ptr == NULL || info_ptr == NULL) return;
|
||||||
png_push_restore_buffer(png_ptr, buffer, buffer_size);
|
png_push_restore_buffer(png_ptr, buffer, buffer_size);
|
||||||
|
|
||||||
while (png_ptr->buffer_size)
|
while (png_ptr->buffer_size)
|
||||||
@@ -42,6 +43,7 @@ png_process_data(png_structp png_ptr, png_infop info_ptr,
|
|||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_process_some_data(png_structp png_ptr, png_infop info_ptr)
|
png_process_some_data(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
switch (png_ptr->process_mode)
|
switch (png_ptr->process_mode)
|
||||||
{
|
{
|
||||||
case PNG_READ_SIG_MODE:
|
case PNG_READ_SIG_MODE:
|
||||||
@@ -135,60 +137,60 @@ void /* PRIVATE */
|
|||||||
png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||||
PNG_IHDR;
|
PNG_CONST PNG_IHDR;
|
||||||
PNG_IDAT;
|
PNG_CONST PNG_IDAT;
|
||||||
PNG_IEND;
|
PNG_CONST PNG_IEND;
|
||||||
PNG_PLTE;
|
PNG_CONST PNG_PLTE;
|
||||||
#if defined(PNG_READ_bKGD_SUPPORTED)
|
#if defined(PNG_READ_bKGD_SUPPORTED)
|
||||||
PNG_bKGD;
|
PNG_CONST PNG_bKGD;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_cHRM_SUPPORTED)
|
#if defined(PNG_READ_cHRM_SUPPORTED)
|
||||||
PNG_cHRM;
|
PNG_CONST PNG_cHRM;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_gAMA_SUPPORTED)
|
#if defined(PNG_READ_gAMA_SUPPORTED)
|
||||||
PNG_gAMA;
|
PNG_CONST PNG_gAMA;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||||
PNG_hIST;
|
PNG_CONST PNG_hIST;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_iCCP_SUPPORTED)
|
#if defined(PNG_READ_iCCP_SUPPORTED)
|
||||||
PNG_iCCP;
|
PNG_CONST PNG_iCCP;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_iTXt_SUPPORTED)
|
#if defined(PNG_READ_iTXt_SUPPORTED)
|
||||||
PNG_iTXt;
|
PNG_CONST PNG_iTXt;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_oFFs_SUPPORTED)
|
#if defined(PNG_READ_oFFs_SUPPORTED)
|
||||||
PNG_oFFs;
|
PNG_CONST PNG_oFFs;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_pCAL_SUPPORTED)
|
#if defined(PNG_READ_pCAL_SUPPORTED)
|
||||||
PNG_pCAL;
|
PNG_CONST PNG_pCAL;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_pHYs_SUPPORTED)
|
#if defined(PNG_READ_pHYs_SUPPORTED)
|
||||||
PNG_pHYs;
|
PNG_CONST PNG_pHYs;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sBIT_SUPPORTED)
|
#if defined(PNG_READ_sBIT_SUPPORTED)
|
||||||
PNG_sBIT;
|
PNG_CONST PNG_sBIT;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sCAL_SUPPORTED)
|
#if defined(PNG_READ_sCAL_SUPPORTED)
|
||||||
PNG_sCAL;
|
PNG_CONST PNG_sCAL;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||||
PNG_sRGB;
|
PNG_CONST PNG_sRGB;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sPLT_SUPPORTED)
|
#if defined(PNG_READ_sPLT_SUPPORTED)
|
||||||
PNG_sPLT;
|
PNG_CONST PNG_sPLT;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_tEXt_SUPPORTED)
|
#if defined(PNG_READ_tEXt_SUPPORTED)
|
||||||
PNG_tEXt;
|
PNG_CONST PNG_tEXt;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_tIME_SUPPORTED)
|
#if defined(PNG_READ_tIME_SUPPORTED)
|
||||||
PNG_tIME;
|
PNG_CONST PNG_tIME;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_tRNS_SUPPORTED)
|
#if defined(PNG_READ_tRNS_SUPPORTED)
|
||||||
PNG_tRNS;
|
PNG_CONST PNG_tRNS;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_zTXt_SUPPORTED)
|
#if defined(PNG_READ_zTXt_SUPPORTED)
|
||||||
PNG_zTXt;
|
PNG_CONST PNG_zTXt;
|
||||||
#endif
|
#endif
|
||||||
#endif /* PNG_USE_LOCAL_ARRAYS */
|
#endif /* PNG_USE_LOCAL_ARRAYS */
|
||||||
/* First we make sure we have enough data for the 4 byte chunk name
|
/* First we make sure we have enough data for the 4 byte chunk name
|
||||||
@@ -214,7 +216,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
|||||||
png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
|
png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4))
|
if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||||
if(png_ptr->mode & PNG_AFTER_IDAT)
|
if(png_ptr->mode & PNG_AFTER_IDAT)
|
||||||
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
|
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
|
||||||
|
|
||||||
@@ -222,6 +224,8 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
|||||||
{
|
{
|
||||||
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
|
||||||
{
|
{
|
||||||
|
if (png_ptr->push_length != 13)
|
||||||
|
png_error(png_ptr, "Invalid IHDR length");
|
||||||
png_push_save_buffer(png_ptr);
|
png_push_save_buffer(png_ptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -271,7 +275,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
|
|||||||
}
|
}
|
||||||
png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length);
|
png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length);
|
||||||
}
|
}
|
||||||
else if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4))
|
else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||||
{
|
{
|
||||||
/* If we reach an IDAT chunk, this means we have read all of the
|
/* If we reach an IDAT chunk, this means we have read all of the
|
||||||
* header chunks, and we can start reading the image (or if this
|
* header chunks, and we can start reading the image (or if this
|
||||||
@@ -561,6 +565,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
|||||||
{
|
{
|
||||||
png_bytep ptr;
|
png_bytep ptr;
|
||||||
|
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
ptr = buffer;
|
ptr = buffer;
|
||||||
if (png_ptr->save_buffer_size)
|
if (png_ptr->save_buffer_size)
|
||||||
{
|
{
|
||||||
@@ -657,7 +662,7 @@ void /* PRIVATE */
|
|||||||
png_push_read_IDAT(png_structp png_ptr)
|
png_push_read_IDAT(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||||
PNG_IDAT;
|
PNG_CONST PNG_IDAT;
|
||||||
#endif
|
#endif
|
||||||
if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
|
if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
|
||||||
{
|
{
|
||||||
@@ -675,7 +680,7 @@ png_push_read_IDAT(png_structp png_ptr)
|
|||||||
png_crc_read(png_ptr, png_ptr->chunk_name, 4);
|
png_crc_read(png_ptr, png_ptr->chunk_name, 4);
|
||||||
png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
|
png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
|
||||||
|
|
||||||
if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4))
|
if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||||
{
|
{
|
||||||
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
|
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
|
||||||
if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
|
if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
|
||||||
@@ -987,25 +992,20 @@ png_read_push_finish_row(png_structp png_ptr)
|
|||||||
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||||
|
|
||||||
/* start of interlace block */
|
/* start of interlace block */
|
||||||
const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
|
PNG_CONST int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
|
||||||
|
|
||||||
/* offset to next interlace block */
|
/* offset to next interlace block */
|
||||||
const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
|
PNG_CONST int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
|
||||||
|
|
||||||
/* start of interlace block in the y direction */
|
/* start of interlace block in the y direction */
|
||||||
const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
|
PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
|
||||||
|
|
||||||
/* offset to next interlace block in the y direction */
|
/* offset to next interlace block in the y direction */
|
||||||
const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
|
PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
|
||||||
|
|
||||||
/* Width of interlace block. This is not currently used - if you need
|
|
||||||
* it, uncomment it here and in png.h
|
|
||||||
const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1};
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Height of interlace block. This is not currently used - if you need
|
/* Height of interlace block. This is not currently used - if you need
|
||||||
* it, uncomment it here and in png.h
|
* it, uncomment it here and in png.h
|
||||||
const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
|
PNG_CONST int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
|
||||||
*/
|
*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1020,32 +1020,37 @@ png_read_push_finish_row(png_structp png_ptr)
|
|||||||
png_ptr->rowbytes + 1);
|
png_ptr->rowbytes + 1);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
png_ptr->pass++;
|
int pass;
|
||||||
if ((png_ptr->pass == 1 && png_ptr->width < 5) ||
|
pass = png_ptr->pass;
|
||||||
(png_ptr->pass == 3 && png_ptr->width < 3) ||
|
pass++;
|
||||||
(png_ptr->pass == 5 && png_ptr->width < 2))
|
if ((pass == 1 && png_ptr->width < 5) ||
|
||||||
png_ptr->pass++;
|
(pass == 3 && png_ptr->width < 3) ||
|
||||||
|
(pass == 5 && png_ptr->width < 2))
|
||||||
|
pass++;
|
||||||
|
|
||||||
if (png_ptr->pass > 7)
|
if (pass > 7)
|
||||||
png_ptr->pass--;
|
pass--;
|
||||||
if (png_ptr->pass >= 7)
|
png_ptr->pass = (png_byte) pass;
|
||||||
break;
|
if (pass < 7)
|
||||||
|
{
|
||||||
|
png_ptr->iwidth = (png_ptr->width +
|
||||||
|
png_pass_inc[pass] - 1 -
|
||||||
|
png_pass_start[pass]) /
|
||||||
|
png_pass_inc[pass];
|
||||||
|
|
||||||
png_ptr->iwidth = (png_ptr->width +
|
png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,
|
||||||
png_pass_inc[png_ptr->pass] - 1 -
|
png_ptr->iwidth) + 1;
|
||||||
png_pass_start[png_ptr->pass]) /
|
|
||||||
png_pass_inc[png_ptr->pass];
|
|
||||||
|
|
||||||
png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,
|
if (png_ptr->transformations & PNG_INTERLACE)
|
||||||
png_ptr->iwidth) + 1;
|
break;
|
||||||
|
|
||||||
if (png_ptr->transformations & PNG_INTERLACE)
|
png_ptr->num_rows = (png_ptr->height +
|
||||||
break;
|
png_pass_yinc[pass] - 1 -
|
||||||
|
png_pass_ystart[pass]) /
|
||||||
png_ptr->num_rows = (png_ptr->height +
|
png_pass_yinc[pass];
|
||||||
png_pass_yinc[png_ptr->pass] - 1 -
|
}
|
||||||
png_pass_ystart[png_ptr->pass]) /
|
else
|
||||||
png_pass_yinc[png_ptr->pass];
|
break;
|
||||||
|
|
||||||
} while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0);
|
} while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0);
|
||||||
}
|
}
|
||||||
@@ -1059,8 +1064,7 @@ png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
|||||||
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
|
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
|
||||||
{
|
{
|
||||||
png_error(png_ptr, "Out of place tEXt");
|
png_error(png_ptr, "Out of place tEXt");
|
||||||
/* to quiet some compiler warnings */
|
info_ptr = info_ptr; /* to quiet some compiler warnings */
|
||||||
if(info_ptr == NULL) return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_MAX_MALLOC_64K
|
#ifdef PNG_MAX_MALLOC_64K
|
||||||
@@ -1123,7 +1127,7 @@ png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
|
|||||||
for (text = key; *text; text++)
|
for (text = key; *text; text++)
|
||||||
/* empty loop */ ;
|
/* empty loop */ ;
|
||||||
|
|
||||||
if (text != key + png_ptr->current_text_size)
|
if (text < key + png_ptr->current_text_size)
|
||||||
text++;
|
text++;
|
||||||
|
|
||||||
text_ptr = (png_textp)png_malloc(png_ptr,
|
text_ptr = (png_textp)png_malloc(png_ptr,
|
||||||
@@ -1156,8 +1160,7 @@ png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
|||||||
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
|
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
|
||||||
{
|
{
|
||||||
png_error(png_ptr, "Out of place zTXt");
|
png_error(png_ptr, "Out of place zTXt");
|
||||||
/* to quiet some compiler warnings */
|
info_ptr = info_ptr; /* to quiet some compiler warnings */
|
||||||
if(info_ptr == NULL) return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_MAX_MALLOC_64K
|
#ifdef PNG_MAX_MALLOC_64K
|
||||||
@@ -1219,7 +1222,7 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
|
|||||||
/* empty loop */ ;
|
/* empty loop */ ;
|
||||||
|
|
||||||
/* zTXt can't have zero text */
|
/* zTXt can't have zero text */
|
||||||
if (text == key + png_ptr->current_text_size)
|
if (text >= key + png_ptr->current_text_size)
|
||||||
{
|
{
|
||||||
png_ptr->current_text = NULL;
|
png_ptr->current_text = NULL;
|
||||||
png_free(png_ptr, key);
|
png_free(png_ptr, key);
|
||||||
@@ -1349,8 +1352,7 @@ png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
|||||||
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
|
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
|
||||||
{
|
{
|
||||||
png_error(png_ptr, "Out of place iTXt");
|
png_error(png_ptr, "Out of place iTXt");
|
||||||
/* to quiet some compiler warnings */
|
info_ptr = info_ptr; /* to quiet some compiler warnings */
|
||||||
if(info_ptr == NULL) return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_MAX_MALLOC_64K
|
#ifdef PNG_MAX_MALLOC_64K
|
||||||
@@ -1417,7 +1419,7 @@ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
|
|||||||
for (lang = key; *lang; lang++)
|
for (lang = key; *lang; lang++)
|
||||||
/* empty loop */ ;
|
/* empty loop */ ;
|
||||||
|
|
||||||
if (lang != key + png_ptr->current_text_size)
|
if (lang < key + png_ptr->current_text_size - 3)
|
||||||
lang++;
|
lang++;
|
||||||
|
|
||||||
comp_flag = *lang++;
|
comp_flag = *lang++;
|
||||||
@@ -1427,10 +1429,14 @@ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
|
|||||||
/* empty loop */ ;
|
/* empty loop */ ;
|
||||||
lang_key++; /* skip NUL separator */
|
lang_key++; /* skip NUL separator */
|
||||||
|
|
||||||
for (text = lang_key; *text; text++)
|
text=lang_key;
|
||||||
/* empty loop */ ;
|
if (lang_key < key + png_ptr->current_text_size - 1)
|
||||||
|
{
|
||||||
|
for (; *text; text++)
|
||||||
|
/* empty loop */ ;
|
||||||
|
}
|
||||||
|
|
||||||
if (text != key + png_ptr->current_text_size)
|
if (text < key + png_ptr->current_text_size)
|
||||||
text++;
|
text++;
|
||||||
|
|
||||||
text_ptr = (png_textp)png_malloc(png_ptr,
|
text_ptr = (png_textp)png_malloc(png_ptr,
|
||||||
@@ -1468,55 +1474,66 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32
|
|||||||
if (!(png_ptr->chunk_name[0] & 0x20))
|
if (!(png_ptr->chunk_name[0] & 0x20))
|
||||||
{
|
{
|
||||||
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||||
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
|
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
|
||||||
PNG_HANDLE_CHUNK_ALWAYS
|
PNG_HANDLE_CHUNK_ALWAYS
|
||||||
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
|
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
|
||||||
&& png_ptr->read_user_chunk_fn == NULL
|
&& png_ptr->read_user_chunk_fn == NULL
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
#endif
|
#endif
|
||||||
png_chunk_error(png_ptr, "unknown critical chunk");
|
png_chunk_error(png_ptr, "unknown critical chunk");
|
||||||
|
|
||||||
/* to quiet compiler warnings about unused info_ptr */
|
info_ptr = info_ptr; /* to quiet some compiler warnings */
|
||||||
if (info_ptr == NULL)
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||||
if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS)
|
if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS)
|
||||||
{
|
{
|
||||||
png_unknown_chunk chunk;
|
|
||||||
|
|
||||||
#ifdef PNG_MAX_MALLOC_64K
|
#ifdef PNG_MAX_MALLOC_64K
|
||||||
if (length > (png_uint_32)65535L)
|
if (length > (png_uint_32)65535L)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "unknown chunk too large to fit in memory");
|
png_warning(png_ptr, "unknown chunk too large to fit in memory");
|
||||||
skip = length - (png_uint_32)65535L;
|
skip = length - (png_uint_32)65535L;
|
||||||
length = (png_uint_32)65535L;
|
length = (png_uint_32)65535L;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
png_memcpy((png_charp)png_ptr->unknown_chunk.name,
|
||||||
|
(png_charp)png_ptr->chunk_name,
|
||||||
|
png_sizeof(png_ptr->unknown_chunk.name));
|
||||||
|
png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name)-1]='\0';
|
||||||
|
|
||||||
png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name);
|
png_ptr->unknown_chunk.size = (png_size_t)length;
|
||||||
chunk.data = (png_bytep)png_malloc(png_ptr, length);
|
if (length == 0)
|
||||||
png_crc_read(png_ptr, chunk.data, length);
|
png_ptr->unknown_chunk.data = NULL;
|
||||||
chunk.size = length;
|
else
|
||||||
|
{
|
||||||
|
png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length);
|
||||||
|
png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length);
|
||||||
|
}
|
||||||
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
|
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
|
||||||
if(png_ptr->read_user_chunk_fn != NULL)
|
if(png_ptr->read_user_chunk_fn != NULL)
|
||||||
{
|
{
|
||||||
/* callback to user unknown chunk handler */
|
/* callback to user unknown chunk handler */
|
||||||
if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0)
|
int ret;
|
||||||
{
|
ret = (*(png_ptr->read_user_chunk_fn))
|
||||||
if (!(png_ptr->chunk_name[0] & 0x20))
|
(png_ptr, &png_ptr->unknown_chunk);
|
||||||
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
|
if (ret < 0)
|
||||||
PNG_HANDLE_CHUNK_ALWAYS)
|
png_chunk_error(png_ptr, "error in user chunk");
|
||||||
png_chunk_error(png_ptr, "unknown critical chunk");
|
if (ret == 0)
|
||||||
}
|
{
|
||||||
png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
|
if (!(png_ptr->chunk_name[0] & 0x20))
|
||||||
}
|
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
|
||||||
else
|
PNG_HANDLE_CHUNK_ALWAYS)
|
||||||
|
png_chunk_error(png_ptr, "unknown critical chunk");
|
||||||
|
png_set_unknown_chunks(png_ptr, info_ptr,
|
||||||
|
&png_ptr->unknown_chunk, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
#endif
|
#endif
|
||||||
png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
|
png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1);
|
||||||
png_free(png_ptr, chunk.data);
|
png_free(png_ptr, png_ptr->unknown_chunk.data);
|
||||||
|
png_ptr->unknown_chunk.data = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@@ -1551,9 +1568,10 @@ png_progressive_combine_row (png_structp png_ptr,
|
|||||||
png_bytep old_row, png_bytep new_row)
|
png_bytep old_row, png_bytep new_row)
|
||||||
{
|
{
|
||||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||||
const int FARDATA png_pass_dsp_mask[7] =
|
PNG_CONST int FARDATA png_pass_dsp_mask[7] =
|
||||||
{0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
|
{0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
|
||||||
#endif
|
#endif
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */
|
if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */
|
||||||
png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]);
|
png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]);
|
||||||
}
|
}
|
||||||
@@ -1563,6 +1581,7 @@ png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr,
|
|||||||
png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
|
png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
|
||||||
png_progressive_end_ptr end_fn)
|
png_progressive_end_ptr end_fn)
|
||||||
{
|
{
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
png_ptr->info_fn = info_fn;
|
png_ptr->info_fn = info_fn;
|
||||||
png_ptr->row_fn = row_fn;
|
png_ptr->row_fn = row_fn;
|
||||||
png_ptr->end_fn = end_fn;
|
png_ptr->end_fn = end_fn;
|
||||||
@@ -1573,6 +1592,7 @@ png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr,
|
|||||||
png_voidp PNGAPI
|
png_voidp PNGAPI
|
||||||
png_get_progressive_ptr(png_structp png_ptr)
|
png_get_progressive_ptr(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
|
if(png_ptr == NULL) return (NULL);
|
||||||
return png_ptr->io_ptr;
|
return png_ptr->io_ptr;
|
||||||
}
|
}
|
||||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||||
|
|||||||
174
pngread.c
174
pngread.c
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
/* pngread.c - read a PNG file
|
/* pngread.c - read a PNG file
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.2.9 April 14, 2006
|
* Last changed in libpng 1.2.25 [February 18, 2008]
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@@ -55,12 +55,6 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
#if !defined(PNG_1_0_X)
|
|
||||||
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
|
|
||||||
png_init_mmx_flags(png_ptr); /* 1.2.0 addition */
|
|
||||||
#endif
|
|
||||||
#endif /* PNG_1_0_X */
|
|
||||||
|
|
||||||
/* added at libpng-1.2.6 */
|
/* added at libpng-1.2.6 */
|
||||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||||
png_ptr->user_width_max=PNG_USER_WIDTH_MAX;
|
png_ptr->user_width_max=PNG_USER_WIDTH_MAX;
|
||||||
@@ -95,12 +89,18 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||||||
|
|
||||||
png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
|
png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
|
||||||
|
|
||||||
i=0;
|
if(user_png_ver)
|
||||||
do
|
|
||||||
{
|
{
|
||||||
if(user_png_ver[i] != png_libpng_ver[i])
|
i=0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if(user_png_ver[i] != png_libpng_ver[i])
|
||||||
|
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
||||||
|
} while (png_libpng_ver[i++]);
|
||||||
|
}
|
||||||
|
else
|
||||||
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
||||||
} while (png_libpng_ver[i++]);
|
|
||||||
|
|
||||||
if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
|
if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
|
||||||
{
|
{
|
||||||
@@ -117,11 +117,13 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||||||
char msg[80];
|
char msg[80];
|
||||||
if (user_png_ver)
|
if (user_png_ver)
|
||||||
{
|
{
|
||||||
sprintf(msg, "Application was compiled with png.h from libpng-%.20s",
|
png_snprintf(msg, 80,
|
||||||
|
"Application was compiled with png.h from libpng-%.20s",
|
||||||
user_png_ver);
|
user_png_ver);
|
||||||
png_warning(png_ptr, msg);
|
png_warning(png_ptr, msg);
|
||||||
}
|
}
|
||||||
sprintf(msg, "Application is running with png.c from libpng-%.20s",
|
png_snprintf(msg, 80,
|
||||||
|
"Application is running with png.c from libpng-%.20s",
|
||||||
png_libpng_ver);
|
png_libpng_ver);
|
||||||
png_warning(png_ptr, msg);
|
png_warning(png_ptr, msg);
|
||||||
#endif
|
#endif
|
||||||
@@ -188,6 +190,7 @@ png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver,
|
|||||||
png_size_t png_struct_size, png_size_t png_info_size)
|
png_size_t png_struct_size, png_size_t png_info_size)
|
||||||
{
|
{
|
||||||
/* We only come here via pre-1.0.12-compiled applications */
|
/* We only come here via pre-1.0.12-compiled applications */
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
|
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
|
||||||
if(png_sizeof(png_struct) > png_struct_size ||
|
if(png_sizeof(png_struct) > png_struct_size ||
|
||||||
png_sizeof(png_info) > png_info_size)
|
png_sizeof(png_info) > png_info_size)
|
||||||
@@ -196,11 +199,13 @@ png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver,
|
|||||||
png_ptr->warning_fn=NULL;
|
png_ptr->warning_fn=NULL;
|
||||||
if (user_png_ver)
|
if (user_png_ver)
|
||||||
{
|
{
|
||||||
sprintf(msg, "Application was compiled with png.h from libpng-%.20s",
|
png_snprintf(msg, 80,
|
||||||
|
"Application was compiled with png.h from libpng-%.20s",
|
||||||
user_png_ver);
|
user_png_ver);
|
||||||
png_warning(png_ptr, msg);
|
png_warning(png_ptr, msg);
|
||||||
}
|
}
|
||||||
sprintf(msg, "Application is running with png.c from libpng-%.20s",
|
png_snprintf(msg, 80,
|
||||||
|
"Application is running with png.c from libpng-%.20s",
|
||||||
png_libpng_ver);
|
png_libpng_ver);
|
||||||
png_warning(png_ptr, msg);
|
png_warning(png_ptr, msg);
|
||||||
}
|
}
|
||||||
@@ -239,6 +244,8 @@ png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
|
|||||||
|
|
||||||
png_structp png_ptr=*ptr_ptr;
|
png_structp png_ptr=*ptr_ptr;
|
||||||
|
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if(user_png_ver[i] != png_libpng_ver[i])
|
if(user_png_ver[i] != png_libpng_ver[i])
|
||||||
@@ -317,6 +324,7 @@ png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
|
|||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_read_info(png_structp png_ptr, png_infop info_ptr)
|
png_read_info(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
|
if(png_ptr == NULL || info_ptr == NULL) return;
|
||||||
png_debug(1, "in png_read_info\n");
|
png_debug(1, "in png_read_info\n");
|
||||||
/* If we haven't checked all of the PNG signature bytes, do so now. */
|
/* If we haven't checked all of the PNG signature bytes, do so now. */
|
||||||
if (png_ptr->sig_bytes < 8)
|
if (png_ptr->sig_bytes < 8)
|
||||||
@@ -342,60 +350,60 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
|||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||||
PNG_IHDR;
|
PNG_CONST PNG_IHDR;
|
||||||
PNG_IDAT;
|
PNG_CONST PNG_IDAT;
|
||||||
PNG_IEND;
|
PNG_CONST PNG_IEND;
|
||||||
PNG_PLTE;
|
PNG_CONST PNG_PLTE;
|
||||||
#if defined(PNG_READ_bKGD_SUPPORTED)
|
#if defined(PNG_READ_bKGD_SUPPORTED)
|
||||||
PNG_bKGD;
|
PNG_CONST PNG_bKGD;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_cHRM_SUPPORTED)
|
#if defined(PNG_READ_cHRM_SUPPORTED)
|
||||||
PNG_cHRM;
|
PNG_CONST PNG_cHRM;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_gAMA_SUPPORTED)
|
#if defined(PNG_READ_gAMA_SUPPORTED)
|
||||||
PNG_gAMA;
|
PNG_CONST PNG_gAMA;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||||
PNG_hIST;
|
PNG_CONST PNG_hIST;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_iCCP_SUPPORTED)
|
#if defined(PNG_READ_iCCP_SUPPORTED)
|
||||||
PNG_iCCP;
|
PNG_CONST PNG_iCCP;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_iTXt_SUPPORTED)
|
#if defined(PNG_READ_iTXt_SUPPORTED)
|
||||||
PNG_iTXt;
|
PNG_CONST PNG_iTXt;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_oFFs_SUPPORTED)
|
#if defined(PNG_READ_oFFs_SUPPORTED)
|
||||||
PNG_oFFs;
|
PNG_CONST PNG_oFFs;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_pCAL_SUPPORTED)
|
#if defined(PNG_READ_pCAL_SUPPORTED)
|
||||||
PNG_pCAL;
|
PNG_CONST PNG_pCAL;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_pHYs_SUPPORTED)
|
#if defined(PNG_READ_pHYs_SUPPORTED)
|
||||||
PNG_pHYs;
|
PNG_CONST PNG_pHYs;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sBIT_SUPPORTED)
|
#if defined(PNG_READ_sBIT_SUPPORTED)
|
||||||
PNG_sBIT;
|
PNG_CONST PNG_sBIT;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sCAL_SUPPORTED)
|
#if defined(PNG_READ_sCAL_SUPPORTED)
|
||||||
PNG_sCAL;
|
PNG_CONST PNG_sCAL;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sPLT_SUPPORTED)
|
#if defined(PNG_READ_sPLT_SUPPORTED)
|
||||||
PNG_sPLT;
|
PNG_CONST PNG_sPLT;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||||
PNG_sRGB;
|
PNG_CONST PNG_sRGB;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_tEXt_SUPPORTED)
|
#if defined(PNG_READ_tEXt_SUPPORTED)
|
||||||
PNG_tEXt;
|
PNG_CONST PNG_tEXt;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_tIME_SUPPORTED)
|
#if defined(PNG_READ_tIME_SUPPORTED)
|
||||||
PNG_tIME;
|
PNG_CONST PNG_tIME;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_tRNS_SUPPORTED)
|
#if defined(PNG_READ_tRNS_SUPPORTED)
|
||||||
PNG_tRNS;
|
PNG_CONST PNG_tRNS;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_zTXt_SUPPORTED)
|
#if defined(PNG_READ_zTXt_SUPPORTED)
|
||||||
PNG_zTXt;
|
PNG_CONST PNG_zTXt;
|
||||||
#endif
|
#endif
|
||||||
#endif /* PNG_USE_LOCAL_ARRAYS */
|
#endif /* PNG_USE_LOCAL_ARRAYS */
|
||||||
png_byte chunk_length[4];
|
png_byte chunk_length[4];
|
||||||
@@ -413,7 +421,7 @@ png_read_info(png_structp png_ptr, png_infop info_ptr)
|
|||||||
/* This should be a binary subdivision search or a hash for
|
/* This should be a binary subdivision search or a hash for
|
||||||
* matching the chunk name rather than a linear search.
|
* matching the chunk name rather than a linear search.
|
||||||
*/
|
*/
|
||||||
if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4))
|
if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||||
if(png_ptr->mode & PNG_AFTER_IDAT)
|
if(png_ptr->mode & PNG_AFTER_IDAT)
|
||||||
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
|
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
|
||||||
|
|
||||||
@@ -533,6 +541,7 @@ void PNGAPI
|
|||||||
png_read_update_info(png_structp png_ptr, png_infop info_ptr)
|
png_read_update_info(png_structp png_ptr, png_infop info_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_read_update_info\n");
|
png_debug(1, "in png_read_update_info\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||||
png_read_start_row(png_ptr);
|
png_read_start_row(png_ptr);
|
||||||
else
|
else
|
||||||
@@ -551,6 +560,7 @@ void PNGAPI
|
|||||||
png_start_read_image(png_structp png_ptr)
|
png_start_read_image(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_start_read_image\n");
|
png_debug(1, "in png_start_read_image\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||||
png_read_start_row(png_ptr);
|
png_read_start_row(png_ptr);
|
||||||
}
|
}
|
||||||
@@ -561,11 +571,13 @@ void PNGAPI
|
|||||||
png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||||
{
|
{
|
||||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||||
PNG_IDAT;
|
PNG_CONST PNG_IDAT;
|
||||||
const int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
|
PNG_CONST int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55,
|
||||||
const int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
|
0xff};
|
||||||
|
PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
|
||||||
#endif
|
#endif
|
||||||
int ret;
|
int ret;
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
png_debug2(1, "in png_read_row (row %lu, pass %d)\n",
|
png_debug2(1, "in png_read_row (row %lu, pass %d)\n",
|
||||||
png_ptr->row_number, png_ptr->pass);
|
png_ptr->row_number, png_ptr->pass);
|
||||||
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||||
@@ -824,6 +836,7 @@ png_read_rows(png_structp png_ptr, png_bytepp row,
|
|||||||
png_bytepp dp;
|
png_bytepp dp;
|
||||||
|
|
||||||
png_debug(1, "in png_read_rows\n");
|
png_debug(1, "in png_read_rows\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
rp = row;
|
rp = row;
|
||||||
dp = display_row;
|
dp = display_row;
|
||||||
if (rp != NULL && dp != NULL)
|
if (rp != NULL && dp != NULL)
|
||||||
@@ -872,6 +885,7 @@ png_read_image(png_structp png_ptr, png_bytepp image)
|
|||||||
png_bytepp rp;
|
png_bytepp rp;
|
||||||
|
|
||||||
png_debug(1, "in png_read_image\n");
|
png_debug(1, "in png_read_image\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
|
|
||||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||||
pass = png_set_interlace_handling(png_ptr);
|
pass = png_set_interlace_handling(png_ptr);
|
||||||
@@ -910,65 +924,66 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
|
|||||||
png_uint_32 length;
|
png_uint_32 length;
|
||||||
|
|
||||||
png_debug(1, "in png_read_end\n");
|
png_debug(1, "in png_read_end\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */
|
png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||||
PNG_IHDR;
|
PNG_CONST PNG_IHDR;
|
||||||
PNG_IDAT;
|
PNG_CONST PNG_IDAT;
|
||||||
PNG_IEND;
|
PNG_CONST PNG_IEND;
|
||||||
PNG_PLTE;
|
PNG_CONST PNG_PLTE;
|
||||||
#if defined(PNG_READ_bKGD_SUPPORTED)
|
#if defined(PNG_READ_bKGD_SUPPORTED)
|
||||||
PNG_bKGD;
|
PNG_CONST PNG_bKGD;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_cHRM_SUPPORTED)
|
#if defined(PNG_READ_cHRM_SUPPORTED)
|
||||||
PNG_cHRM;
|
PNG_CONST PNG_cHRM;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_gAMA_SUPPORTED)
|
#if defined(PNG_READ_gAMA_SUPPORTED)
|
||||||
PNG_gAMA;
|
PNG_CONST PNG_gAMA;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_hIST_SUPPORTED)
|
#if defined(PNG_READ_hIST_SUPPORTED)
|
||||||
PNG_hIST;
|
PNG_CONST PNG_hIST;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_iCCP_SUPPORTED)
|
#if defined(PNG_READ_iCCP_SUPPORTED)
|
||||||
PNG_iCCP;
|
PNG_CONST PNG_iCCP;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_iTXt_SUPPORTED)
|
#if defined(PNG_READ_iTXt_SUPPORTED)
|
||||||
PNG_iTXt;
|
PNG_CONST PNG_iTXt;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_oFFs_SUPPORTED)
|
#if defined(PNG_READ_oFFs_SUPPORTED)
|
||||||
PNG_oFFs;
|
PNG_CONST PNG_oFFs;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_pCAL_SUPPORTED)
|
#if defined(PNG_READ_pCAL_SUPPORTED)
|
||||||
PNG_pCAL;
|
PNG_CONST PNG_pCAL;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_pHYs_SUPPORTED)
|
#if defined(PNG_READ_pHYs_SUPPORTED)
|
||||||
PNG_pHYs;
|
PNG_CONST PNG_pHYs;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sBIT_SUPPORTED)
|
#if defined(PNG_READ_sBIT_SUPPORTED)
|
||||||
PNG_sBIT;
|
PNG_CONST PNG_sBIT;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sCAL_SUPPORTED)
|
#if defined(PNG_READ_sCAL_SUPPORTED)
|
||||||
PNG_sCAL;
|
PNG_CONST PNG_sCAL;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sPLT_SUPPORTED)
|
#if defined(PNG_READ_sPLT_SUPPORTED)
|
||||||
PNG_sPLT;
|
PNG_CONST PNG_sPLT;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_sRGB_SUPPORTED)
|
#if defined(PNG_READ_sRGB_SUPPORTED)
|
||||||
PNG_sRGB;
|
PNG_CONST PNG_sRGB;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_tEXt_SUPPORTED)
|
#if defined(PNG_READ_tEXt_SUPPORTED)
|
||||||
PNG_tEXt;
|
PNG_CONST PNG_tEXt;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_tIME_SUPPORTED)
|
#if defined(PNG_READ_tIME_SUPPORTED)
|
||||||
PNG_tIME;
|
PNG_CONST PNG_tIME;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_tRNS_SUPPORTED)
|
#if defined(PNG_READ_tRNS_SUPPORTED)
|
||||||
PNG_tRNS;
|
PNG_CONST PNG_tRNS;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_READ_zTXt_SUPPORTED)
|
#if defined(PNG_READ_zTXt_SUPPORTED)
|
||||||
PNG_zTXt;
|
PNG_CONST PNG_zTXt;
|
||||||
#endif
|
#endif
|
||||||
#endif /* PNG_USE_LOCAL_ARRAYS */
|
#endif /* PNG_USE_LOCAL_ARRAYS */
|
||||||
|
|
||||||
@@ -1090,13 +1105,22 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
|||||||
png_structp png_ptr = NULL;
|
png_structp png_ptr = NULL;
|
||||||
png_infop info_ptr = NULL, end_info_ptr = NULL;
|
png_infop info_ptr = NULL, end_info_ptr = NULL;
|
||||||
#ifdef PNG_USER_MEM_SUPPORTED
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
png_free_ptr free_fn;
|
png_free_ptr free_fn = NULL;
|
||||||
png_voidp mem_ptr;
|
png_voidp mem_ptr = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
png_debug(1, "in png_destroy_read_struct\n");
|
png_debug(1, "in png_destroy_read_struct\n");
|
||||||
if (png_ptr_ptr != NULL)
|
if (png_ptr_ptr != NULL)
|
||||||
|
{
|
||||||
png_ptr = *png_ptr_ptr;
|
png_ptr = *png_ptr_ptr;
|
||||||
|
}
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
free_fn = png_ptr->free_fn;
|
||||||
|
mem_ptr = png_ptr->mem_ptr;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (info_ptr_ptr != NULL)
|
if (info_ptr_ptr != NULL)
|
||||||
info_ptr = *info_ptr_ptr;
|
info_ptr = *info_ptr_ptr;
|
||||||
@@ -1104,11 +1128,6 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
|||||||
if (end_info_ptr_ptr != NULL)
|
if (end_info_ptr_ptr != NULL)
|
||||||
end_info_ptr = *end_info_ptr_ptr;
|
end_info_ptr = *end_info_ptr_ptr;
|
||||||
|
|
||||||
#ifdef PNG_USER_MEM_SUPPORTED
|
|
||||||
free_fn = png_ptr->free_fn;
|
|
||||||
mem_ptr = png_ptr->mem_ptr;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
png_read_destroy(png_ptr, info_ptr, end_info_ptr);
|
png_read_destroy(png_ptr, info_ptr, end_info_ptr);
|
||||||
|
|
||||||
if (info_ptr != NULL)
|
if (info_ptr != NULL)
|
||||||
@@ -1140,16 +1159,13 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
|
|||||||
*end_info_ptr_ptr = NULL;
|
*end_info_ptr_ptr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (png_ptr != NULL)
|
|
||||||
{
|
|
||||||
#ifdef PNG_USER_MEM_SUPPORTED
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn,
|
png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn,
|
||||||
(png_voidp)mem_ptr);
|
(png_voidp)mem_ptr);
|
||||||
#else
|
#else
|
||||||
png_destroy_struct((png_voidp)png_ptr);
|
png_destroy_struct((png_voidp)png_ptr);
|
||||||
#endif
|
#endif
|
||||||
*png_ptr_ptr = NULL;
|
*png_ptr_ptr = NULL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free all memory used by the read (old method) */
|
/* free all memory used by the read (old method) */
|
||||||
@@ -1300,6 +1316,7 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr
|
|||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn)
|
png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn)
|
||||||
{
|
{
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
png_ptr->read_row_fn = read_row_fn;
|
png_ptr->read_row_fn = read_row_fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1313,6 +1330,7 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
|
|||||||
{
|
{
|
||||||
int row;
|
int row;
|
||||||
|
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
|
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
|
||||||
/* invert the alpha channel from opacity to transparency
|
/* invert the alpha channel from opacity to transparency
|
||||||
*/
|
*/
|
||||||
@@ -1452,8 +1470,8 @@ png_read_png(png_structp png_ptr, png_infop info_ptr,
|
|||||||
/* read rest of file, and get additional chunks in info_ptr - REQUIRED */
|
/* read rest of file, and get additional chunks in info_ptr - REQUIRED */
|
||||||
png_read_end(png_ptr, info_ptr);
|
png_read_end(png_ptr, info_ptr);
|
||||||
|
|
||||||
if(transforms == 0 || params == NULL)
|
transforms = transforms; /* quiet compiler warnings */
|
||||||
/* quiet compiler warnings */ return;
|
params = params;
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif /* PNG_INFO_IMAGE_SUPPORTED */
|
#endif /* PNG_INFO_IMAGE_SUPPORTED */
|
||||||
|
|||||||
5
pngrio.c
5
pngrio.c
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngrio.c - functions for data input
|
/* pngrio.c - functions for data input
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.2.9 April 14, 2006
|
* Last changed in libpng 1.2.13 November 13, 2006
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
@@ -46,6 +46,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||||||
{
|
{
|
||||||
png_size_t check;
|
png_size_t check;
|
||||||
|
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
/* fread() returns 0 on error, so it is OK to store this in a png_size_t
|
/* fread() returns 0 on error, so it is OK to store this in a png_size_t
|
||||||
* instead of an int, which is what fread() actually returns.
|
* instead of an int, which is what fread() actually returns.
|
||||||
*/
|
*/
|
||||||
@@ -76,6 +77,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||||||
png_byte *n_data;
|
png_byte *n_data;
|
||||||
png_FILE_p io_ptr;
|
png_FILE_p io_ptr;
|
||||||
|
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
/* Check if data really is near. If so, use usual code. */
|
/* Check if data really is near. If so, use usual code. */
|
||||||
n_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
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_ptr->io_ptr);
|
||||||
@@ -136,6 +138,7 @@ void PNGAPI
|
|||||||
png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||||
png_rw_ptr read_data_fn)
|
png_rw_ptr read_data_fn)
|
||||||
{
|
{
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
png_ptr->io_ptr = io_ptr;
|
png_ptr->io_ptr = io_ptr;
|
||||||
|
|
||||||
#if !defined(PNG_NO_STDIO)
|
#if !defined(PNG_NO_STDIO)
|
||||||
|
|||||||
149
pngrtran.c
149
pngrtran.c
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.2.9 April 14, 2006
|
* Last changed in libpng 1.2.27 [April 29, 2008]
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@@ -24,6 +24,7 @@ png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
|
|||||||
{
|
{
|
||||||
png_debug(1, "in png_set_crc_action\n");
|
png_debug(1, "in png_set_crc_action\n");
|
||||||
/* Tell libpng how we react to CRC errors in critical chunks */
|
/* Tell libpng how we react to CRC errors in critical chunks */
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
switch (crit_action)
|
switch (crit_action)
|
||||||
{
|
{
|
||||||
case PNG_CRC_NO_CHANGE: /* leave setting as is */
|
case PNG_CRC_NO_CHANGE: /* leave setting as is */
|
||||||
@@ -80,6 +81,7 @@ png_set_background(png_structp png_ptr,
|
|||||||
int need_expand, double background_gamma)
|
int need_expand, double background_gamma)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_background\n");
|
png_debug(1, "in png_set_background\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN)
|
if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "Application must supply a known background gamma");
|
png_warning(png_ptr, "Application must supply a known background gamma");
|
||||||
@@ -92,17 +94,6 @@ png_set_background(png_structp png_ptr,
|
|||||||
png_ptr->background_gamma = (float)background_gamma;
|
png_ptr->background_gamma = (float)background_gamma;
|
||||||
png_ptr->background_gamma_type = (png_byte)(background_gamma_code);
|
png_ptr->background_gamma_type = (png_byte)(background_gamma_code);
|
||||||
png_ptr->transformations |= (need_expand ? PNG_BACKGROUND_EXPAND : 0);
|
png_ptr->transformations |= (need_expand ? PNG_BACKGROUND_EXPAND : 0);
|
||||||
|
|
||||||
/* Note: if need_expand is set and color_type is either RGB or RGB_ALPHA
|
|
||||||
* (in which case need_expand is superfluous anyway), the background color
|
|
||||||
* might actually be gray yet not be flagged as such. This is not a problem
|
|
||||||
* for the current code, which uses PNG_BACKGROUND_IS_GRAY only to
|
|
||||||
* decide when to do the png_do_gray_to_rgb() transformation.
|
|
||||||
*/
|
|
||||||
if ((need_expand && !(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) ||
|
|
||||||
(!need_expand && background_color->red == background_color->green &&
|
|
||||||
background_color->red == background_color->blue))
|
|
||||||
png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -112,6 +103,7 @@ void PNGAPI
|
|||||||
png_set_strip_16(png_structp png_ptr)
|
png_set_strip_16(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_strip_16\n");
|
png_debug(1, "in png_set_strip_16\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
png_ptr->transformations |= PNG_16_TO_8;
|
png_ptr->transformations |= PNG_16_TO_8;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -121,6 +113,7 @@ void PNGAPI
|
|||||||
png_set_strip_alpha(png_structp png_ptr)
|
png_set_strip_alpha(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_strip_alpha\n");
|
png_debug(1, "in png_set_strip_alpha\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
png_ptr->flags |= PNG_FLAG_STRIP_ALPHA;
|
png_ptr->flags |= PNG_FLAG_STRIP_ALPHA;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -150,6 +143,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
|||||||
int full_dither)
|
int full_dither)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_dither\n");
|
png_debug(1, "in png_set_dither\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
png_ptr->transformations |= PNG_DITHER;
|
png_ptr->transformations |= PNG_DITHER;
|
||||||
|
|
||||||
if (!full_dither)
|
if (!full_dither)
|
||||||
@@ -533,6 +527,7 @@ void PNGAPI
|
|||||||
png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma)
|
png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_gamma\n");
|
png_debug(1, "in png_set_gamma\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
if ((fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD) ||
|
if ((fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD) ||
|
||||||
(png_ptr->color_type & PNG_COLOR_MASK_ALPHA) ||
|
(png_ptr->color_type & PNG_COLOR_MASK_ALPHA) ||
|
||||||
(png_ptr->color_type == PNG_COLOR_TYPE_PALETTE))
|
(png_ptr->color_type == PNG_COLOR_TYPE_PALETTE))
|
||||||
@@ -551,7 +546,9 @@ void PNGAPI
|
|||||||
png_set_expand(png_structp png_ptr)
|
png_set_expand(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_expand\n");
|
png_debug(1, "in png_set_expand\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||||
|
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* GRR 19990627: the following three functions currently are identical
|
/* GRR 19990627: the following three functions currently are identical
|
||||||
@@ -576,7 +573,9 @@ void PNGAPI
|
|||||||
png_set_palette_to_rgb(png_structp png_ptr)
|
png_set_palette_to_rgb(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_palette_to_rgb\n");
|
png_debug(1, "in png_set_palette_to_rgb\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||||
|
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(PNG_1_0_X)
|
#if !defined(PNG_1_0_X)
|
||||||
@@ -585,7 +584,9 @@ void PNGAPI
|
|||||||
png_set_expand_gray_1_2_4_to_8(png_structp png_ptr)
|
png_set_expand_gray_1_2_4_to_8(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_expand_gray_1_2_4_to_8\n");
|
png_debug(1, "in png_set_expand_gray_1_2_4_to_8\n");
|
||||||
png_ptr->transformations |= PNG_EXPAND_tRNS;
|
if(png_ptr == NULL) return;
|
||||||
|
png_ptr->transformations |= PNG_EXPAND;
|
||||||
|
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -596,6 +597,7 @@ void PNGAPI
|
|||||||
png_set_gray_1_2_4_to_8(png_structp png_ptr)
|
png_set_gray_1_2_4_to_8(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_gray_1_2_4_to_8\n");
|
png_debug(1, "in png_set_gray_1_2_4_to_8\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -605,8 +607,9 @@ png_set_gray_1_2_4_to_8(png_structp png_ptr)
|
|||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_tRNS_to_alpha(png_structp png_ptr)
|
png_set_tRNS_to_alpha(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_expand\n");
|
png_debug(1, "in png_set_tRNS_to_alpha\n");
|
||||||
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
|
||||||
|
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
||||||
}
|
}
|
||||||
#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */
|
#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */
|
||||||
|
|
||||||
@@ -616,6 +619,7 @@ png_set_gray_to_rgb(png_structp png_ptr)
|
|||||||
{
|
{
|
||||||
png_debug(1, "in png_set_gray_to_rgb\n");
|
png_debug(1, "in png_set_gray_to_rgb\n");
|
||||||
png_ptr->transformations |= PNG_GRAY_TO_RGB;
|
png_ptr->transformations |= PNG_GRAY_TO_RGB;
|
||||||
|
png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -631,6 +635,7 @@ png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red,
|
|||||||
{
|
{
|
||||||
int red_fixed = (int)((float)red*100000.0 + 0.5);
|
int red_fixed = (int)((float)red*100000.0 + 0.5);
|
||||||
int green_fixed = (int)((float)green*100000.0 + 0.5);
|
int green_fixed = (int)((float)green*100000.0 + 0.5);
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed);
|
png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -640,6 +645,7 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
|
|||||||
png_fixed_point red, png_fixed_point green)
|
png_fixed_point red, png_fixed_point green)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_rgb_to_gray\n");
|
png_debug(1, "in png_set_rgb_to_gray\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
switch(error_action)
|
switch(error_action)
|
||||||
{
|
{
|
||||||
case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY;
|
case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY;
|
||||||
@@ -690,6 +696,7 @@ png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
|
|||||||
read_user_transform_fn)
|
read_user_transform_fn)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_read_user_transform_fn\n");
|
png_debug(1, "in png_set_read_user_transform_fn\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
|
||||||
png_ptr->transformations |= PNG_USER_TRANSFORM;
|
png_ptr->transformations |= PNG_USER_TRANSFORM;
|
||||||
png_ptr->read_user_transform_fn = read_user_transform_fn;
|
png_ptr->read_user_transform_fn = read_user_transform_fn;
|
||||||
@@ -719,6 +726,32 @@ png_init_read_transformations(png_structp png_ptr)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)
|
#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||||
|
|
||||||
|
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
|
||||||
|
/* Detect gray background and attempt to enable optimization
|
||||||
|
* for gray --> RGB case */
|
||||||
|
/* Note: if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or
|
||||||
|
* RGB_ALPHA (in which case need_expand is superfluous anyway), the
|
||||||
|
* background color might actually be gray yet not be flagged as such.
|
||||||
|
* This is not a problem for the current code, which uses
|
||||||
|
* PNG_BACKGROUND_IS_GRAY only to decide when to do the
|
||||||
|
* png_do_gray_to_rgb() transformation.
|
||||||
|
*/
|
||||||
|
if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
|
||||||
|
!(color_type & PNG_COLOR_MASK_COLOR))
|
||||||
|
{
|
||||||
|
png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;
|
||||||
|
} else if ((png_ptr->transformations & PNG_BACKGROUND) &&
|
||||||
|
!(png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
|
||||||
|
(png_ptr->transformations & PNG_GRAY_TO_RGB) &&
|
||||||
|
png_ptr->background.red == png_ptr->background.green &&
|
||||||
|
png_ptr->background.red == png_ptr->background.blue)
|
||||||
|
{
|
||||||
|
png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;
|
||||||
|
png_ptr->background.gray = png_ptr->background.red;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
|
if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
|
||||||
(png_ptr->transformations & PNG_EXPAND))
|
(png_ptr->transformations & PNG_EXPAND))
|
||||||
{
|
{
|
||||||
@@ -814,7 +847,7 @@ png_init_read_transformations(png_structp png_ptr)
|
|||||||
k=1; /* partial transparency is present */
|
k=1; /* partial transparency is present */
|
||||||
}
|
}
|
||||||
if (k == 0)
|
if (k == 0)
|
||||||
png_ptr->transformations &= (~PNG_GAMMA);
|
png_ptr->transformations &= ~PNG_GAMMA;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY)) &&
|
if ((png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY)) &&
|
||||||
@@ -921,6 +954,14 @@ png_init_read_transformations(png_structp png_ptr)
|
|||||||
palette[i].blue = png_ptr->gamma_table[palette[i].blue];
|
palette[i].blue = png_ptr->gamma_table[palette[i].blue];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Prevent the transformations being done again, and make sure
|
||||||
|
* that the now spurious alpha channel is stripped - the code
|
||||||
|
* has just reduced background composition and gamma correction
|
||||||
|
* to a simple alpha channel strip.
|
||||||
|
*/
|
||||||
|
png_ptr->transformations &= ~PNG_BACKGROUND;
|
||||||
|
png_ptr->transformations &= ~PNG_GAMMA;
|
||||||
|
png_ptr->transformations |= PNG_STRIP_ALPHA;
|
||||||
}
|
}
|
||||||
/* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */
|
/* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */
|
||||||
else
|
else
|
||||||
@@ -995,6 +1036,9 @@ png_init_read_transformations(png_structp png_ptr)
|
|||||||
palette[i].green = png_ptr->gamma_table[palette[i].green];
|
palette[i].green = png_ptr->gamma_table[palette[i].green];
|
||||||
palette[i].blue = png_ptr->gamma_table[palette[i].blue];
|
palette[i].blue = png_ptr->gamma_table[palette[i].blue];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Done the gamma correction. */
|
||||||
|
png_ptr->transformations &= ~PNG_GAMMA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
|
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||||
@@ -1032,6 +1076,10 @@ png_init_read_transformations(png_structp png_ptr)
|
|||||||
png_ptr->trans[i], back.blue);
|
png_ptr->trans[i], back.blue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Handled alpha, still need to strip the channel. */
|
||||||
|
png_ptr->transformations &= ~PNG_BACKGROUND;
|
||||||
|
png_ptr->transformations |= PNG_STRIP_ALPHA;
|
||||||
}
|
}
|
||||||
#endif /* PNG_READ_BACKGROUND_SUPPORTED */
|
#endif /* PNG_READ_BACKGROUND_SUPPORTED */
|
||||||
|
|
||||||
@@ -1080,7 +1128,8 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
|||||||
{
|
{
|
||||||
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||||
{
|
{
|
||||||
if (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND_tRNS))
|
if (png_ptr->num_trans &&
|
||||||
|
(png_ptr->transformations & PNG_EXPAND_tRNS))
|
||||||
info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
|
info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
|
||||||
else
|
else
|
||||||
info_ptr->color_type = PNG_COLOR_TYPE_RGB;
|
info_ptr->color_type = PNG_COLOR_TYPE_RGB;
|
||||||
@@ -1093,8 +1142,10 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
|||||||
{
|
{
|
||||||
if (png_ptr->transformations & PNG_EXPAND_tRNS)
|
if (png_ptr->transformations & PNG_EXPAND_tRNS)
|
||||||
info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
|
info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
|
||||||
|
#if 0 /* Removed from libpng-1.2.27 */
|
||||||
else
|
else
|
||||||
info_ptr->color_type |= PNG_COLOR_MASK_COLOR;
|
info_ptr->color_type |= PNG_COLOR_MASK_COLOR;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (info_ptr->bit_depth < 8)
|
if (info_ptr->bit_depth < 8)
|
||||||
info_ptr->bit_depth = 8;
|
info_ptr->bit_depth = 8;
|
||||||
@@ -1216,19 +1267,29 @@ void /* PRIVATE */
|
|||||||
png_do_read_transformations(png_structp png_ptr)
|
png_do_read_transformations(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_do_read_transformations\n");
|
png_debug(1, "in png_do_read_transformations\n");
|
||||||
#if !defined(PNG_USELESS_TESTS_SUPPORTED)
|
|
||||||
if (png_ptr->row_buf == NULL)
|
if (png_ptr->row_buf == NULL)
|
||||||
{
|
{
|
||||||
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
|
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
|
||||||
char msg[50];
|
char msg[50];
|
||||||
|
|
||||||
sprintf(msg, "NULL row buffer for row %ld, pass %d", png_ptr->row_number,
|
png_snprintf2(msg, 50,
|
||||||
|
"NULL row buffer for row %ld, pass %d", png_ptr->row_number,
|
||||||
png_ptr->pass);
|
png_ptr->pass);
|
||||||
png_error(png_ptr, msg);
|
png_error(png_ptr, msg);
|
||||||
#else
|
#else
|
||||||
png_error(png_ptr, "NULL row buffer");
|
png_error(png_ptr, "NULL row buffer");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifdef PNG_WARN_UNINITIALIZED_ROW
|
||||||
|
if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
|
||||||
|
/* Application has failed to call either png_read_start_image()
|
||||||
|
* or png_read_update_info() after setting transforms that expand
|
||||||
|
* pixels. This check added to libpng-1.2.19 */
|
||||||
|
#if (PNG_WARN_UNINITIALIZED_ROW==1)
|
||||||
|
png_error(png_ptr, "Uninitialized row");
|
||||||
|
#else
|
||||||
|
png_warning(png_ptr, "Uninitialized row");
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_READ_EXPAND_SUPPORTED)
|
#if defined(PNG_READ_EXPAND_SUPPORTED)
|
||||||
@@ -1241,7 +1302,8 @@ png_do_read_transformations(png_structp png_ptr)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND_tRNS))
|
if (png_ptr->num_trans &&
|
||||||
|
(png_ptr->transformations & PNG_EXPAND_tRNS))
|
||||||
png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||||
&(png_ptr->trans_values));
|
&(png_ptr->trans_values));
|
||||||
else
|
else
|
||||||
@@ -1265,9 +1327,11 @@ png_do_read_transformations(png_structp png_ptr)
|
|||||||
if(rgb_error)
|
if(rgb_error)
|
||||||
{
|
{
|
||||||
png_ptr->rgb_to_gray_status=1;
|
png_ptr->rgb_to_gray_status=1;
|
||||||
if(png_ptr->transformations == PNG_RGB_TO_GRAY_WARN)
|
if((png_ptr->transformations & PNG_RGB_TO_GRAY) ==
|
||||||
|
PNG_RGB_TO_GRAY_WARN)
|
||||||
png_warning(png_ptr, "png_do_rgb_to_gray found nongray pixel");
|
png_warning(png_ptr, "png_do_rgb_to_gray found nongray pixel");
|
||||||
if(png_ptr->transformations == PNG_RGB_TO_GRAY_ERR)
|
if((png_ptr->transformations & PNG_RGB_TO_GRAY) ==
|
||||||
|
PNG_RGB_TO_GRAY_ERR)
|
||||||
png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel");
|
png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3671,7 +3735,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
|||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
gray = (png_uint_16)(gray*0xff);
|
gray = (png_uint_16)((gray&0x01)*0xff);
|
||||||
sp = row + (png_size_t)((row_width - 1) >> 3);
|
sp = row + (png_size_t)((row_width - 1) >> 3);
|
||||||
dp = row + (png_size_t)row_width - 1;
|
dp = row + (png_size_t)row_width - 1;
|
||||||
shift = 7 - (int)((row_width + 7) & 0x07);
|
shift = 7 - (int)((row_width + 7) & 0x07);
|
||||||
@@ -3695,7 +3759,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
|||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
gray = (png_uint_16)(gray*0x55);
|
gray = (png_uint_16)((gray&0x03)*0x55);
|
||||||
sp = row + (png_size_t)((row_width - 1) >> 2);
|
sp = row + (png_size_t)((row_width - 1) >> 2);
|
||||||
dp = row + (png_size_t)row_width - 1;
|
dp = row + (png_size_t)row_width - 1;
|
||||||
shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
|
shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
|
||||||
@@ -3718,7 +3782,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
|||||||
}
|
}
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
gray = (png_uint_16)(gray*0x11);
|
gray = (png_uint_16)((gray&0x0f)*0x11);
|
||||||
sp = row + (png_size_t)((row_width - 1) >> 1);
|
sp = row + (png_size_t)((row_width - 1) >> 1);
|
||||||
dp = row + (png_size_t)row_width - 1;
|
dp = row + (png_size_t)row_width - 1;
|
||||||
shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);
|
shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);
|
||||||
@@ -3748,6 +3812,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
|||||||
{
|
{
|
||||||
if (row_info->bit_depth == 8)
|
if (row_info->bit_depth == 8)
|
||||||
{
|
{
|
||||||
|
gray = gray & 0xff;
|
||||||
sp = row + (png_size_t)row_width - 1;
|
sp = row + (png_size_t)row_width - 1;
|
||||||
dp = row + (png_size_t)(row_width << 1) - 1;
|
dp = row + (png_size_t)(row_width << 1) - 1;
|
||||||
for (i = 0; i < row_width; i++)
|
for (i = 0; i < row_width; i++)
|
||||||
@@ -3761,12 +3826,13 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
|||||||
}
|
}
|
||||||
else if (row_info->bit_depth == 16)
|
else if (row_info->bit_depth == 16)
|
||||||
{
|
{
|
||||||
|
png_byte gray_high = (gray >> 8) & 0xff;
|
||||||
|
png_byte gray_low = gray & 0xff;
|
||||||
sp = row + row_info->rowbytes - 1;
|
sp = row + row_info->rowbytes - 1;
|
||||||
dp = row + (row_info->rowbytes << 1) - 1;
|
dp = row + (row_info->rowbytes << 1) - 1;
|
||||||
for (i = 0; i < row_width; i++)
|
for (i = 0; i < row_width; i++)
|
||||||
{
|
{
|
||||||
if (((png_uint_16)*(sp) |
|
if (*(sp-1) == gray_high && *(sp) == gray_low)
|
||||||
((png_uint_16)*(sp - 1) << 8)) == gray)
|
|
||||||
{
|
{
|
||||||
*dp-- = 0;
|
*dp-- = 0;
|
||||||
*dp-- = 0;
|
*dp-- = 0;
|
||||||
@@ -3791,13 +3857,14 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
|||||||
{
|
{
|
||||||
if (row_info->bit_depth == 8)
|
if (row_info->bit_depth == 8)
|
||||||
{
|
{
|
||||||
|
png_byte red = trans_value->red & 0xff;
|
||||||
|
png_byte green = trans_value->green & 0xff;
|
||||||
|
png_byte blue = trans_value->blue & 0xff;
|
||||||
sp = row + (png_size_t)row_info->rowbytes - 1;
|
sp = row + (png_size_t)row_info->rowbytes - 1;
|
||||||
dp = row + (png_size_t)(row_width << 2) - 1;
|
dp = row + (png_size_t)(row_width << 2) - 1;
|
||||||
for (i = 0; i < row_width; i++)
|
for (i = 0; i < row_width; i++)
|
||||||
{
|
{
|
||||||
if (*(sp - 2) == trans_value->red &&
|
if (*(sp - 2) == red && *(sp - 1) == green && *(sp) == blue)
|
||||||
*(sp - 1) == trans_value->green &&
|
|
||||||
*(sp - 0) == trans_value->blue)
|
|
||||||
*dp-- = 0;
|
*dp-- = 0;
|
||||||
else
|
else
|
||||||
*dp-- = 0xff;
|
*dp-- = 0xff;
|
||||||
@@ -3808,16 +3875,22 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
|||||||
}
|
}
|
||||||
else if (row_info->bit_depth == 16)
|
else if (row_info->bit_depth == 16)
|
||||||
{
|
{
|
||||||
|
png_byte red_high = (trans_value->red >> 8) & 0xff;
|
||||||
|
png_byte green_high = (trans_value->green >> 8) & 0xff;
|
||||||
|
png_byte blue_high = (trans_value->blue >> 8) & 0xff;
|
||||||
|
png_byte red_low = trans_value->red & 0xff;
|
||||||
|
png_byte green_low = trans_value->green & 0xff;
|
||||||
|
png_byte blue_low = trans_value->blue & 0xff;
|
||||||
sp = row + row_info->rowbytes - 1;
|
sp = row + row_info->rowbytes - 1;
|
||||||
dp = row + (png_size_t)(row_width << 3) - 1;
|
dp = row + (png_size_t)(row_width << 3) - 1;
|
||||||
for (i = 0; i < row_width; i++)
|
for (i = 0; i < row_width; i++)
|
||||||
{
|
{
|
||||||
if ((((png_uint_16)*(sp - 4) |
|
if (*(sp - 5) == red_high &&
|
||||||
((png_uint_16)*(sp - 5) << 8)) == trans_value->red) &&
|
*(sp - 4) == red_low &&
|
||||||
(((png_uint_16)*(sp - 2) |
|
*(sp - 3) == green_high &&
|
||||||
((png_uint_16)*(sp - 3) << 8)) == trans_value->green) &&
|
*(sp - 2) == green_low &&
|
||||||
(((png_uint_16)*(sp - 0) |
|
*(sp - 1) == blue_high &&
|
||||||
((png_uint_16)*(sp - 1) << 8)) == trans_value->blue))
|
*(sp ) == blue_low)
|
||||||
{
|
{
|
||||||
*dp-- = 0;
|
*dp-- = 0;
|
||||||
*dp-- = 0;
|
*dp-- = 0;
|
||||||
@@ -3937,8 +4010,8 @@ png_do_dither(png_row_infop row_info, png_bytep row,
|
|||||||
|
|
||||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
#if defined(PNG_READ_GAMMA_SUPPORTED)
|
#if defined(PNG_READ_GAMMA_SUPPORTED)
|
||||||
static int png_gamma_shift[] =
|
static PNG_CONST int png_gamma_shift[] =
|
||||||
{0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0};
|
{0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0, 0x00};
|
||||||
|
|
||||||
/* We build the 8- or 16-bit gamma tables here. Note that for 16-bit
|
/* We build the 8- or 16-bit gamma tables here. Note that for 16-bit
|
||||||
* tables, we don't make a full table if we are reducing to 8-bit in
|
* tables, we don't make a full table if we are reducing to 8-bit in
|
||||||
|
|||||||
208
pngrutil.c
208
pngrutil.c
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
/* pngrutil.c - utilities to read a PNG file
|
/* pngrutil.c - utilities to read a PNG file
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.2.11 June 4, 2006
|
* Last changed in libpng 1.2.27 [April 29, 2008]
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@@ -16,27 +16,33 @@
|
|||||||
|
|
||||||
#if defined(PNG_READ_SUPPORTED)
|
#if defined(PNG_READ_SUPPORTED)
|
||||||
|
|
||||||
#if defined(_WIN32_WCE)
|
#if defined(_WIN32_WCE) && (_WIN32_WCE<0x500)
|
||||||
|
# define WIN32_WCE_OLD
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
|
# if defined(WIN32_WCE_OLD)
|
||||||
/* strtod() function is not supported on WindowsCE */
|
/* strtod() function is not supported on WindowsCE */
|
||||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
__inline double png_strtod(png_structp png_ptr, PNG_CONST char *nptr, char **endptr)
|
||||||
__inline double strtod(const char *nptr, char **endptr)
|
|
||||||
{
|
{
|
||||||
double result = 0;
|
double result = 0;
|
||||||
int len;
|
int len;
|
||||||
wchar_t *str, *end;
|
wchar_t *str, *end;
|
||||||
|
|
||||||
len = MultiByteToWideChar(CP_ACP, 0, nptr, -1, NULL, 0);
|
len = MultiByteToWideChar(CP_ACP, 0, nptr, -1, NULL, 0);
|
||||||
str = (wchar_t *)malloc(len * sizeof(wchar_t));
|
str = (wchar_t *)png_malloc(png_ptr, len * sizeof(wchar_t));
|
||||||
if ( NULL != str )
|
if ( NULL != str )
|
||||||
{
|
{
|
||||||
MultiByteToWideChar(CP_ACP, 0, nptr, -1, str, len);
|
MultiByteToWideChar(CP_ACP, 0, nptr, -1, str, len);
|
||||||
result = wcstod(str, &end);
|
result = wcstod(str, &end);
|
||||||
len = WideCharToMultiByte(CP_ACP, 0, end, -1, NULL, 0, NULL, NULL);
|
len = WideCharToMultiByte(CP_ACP, 0, end, -1, NULL, 0, NULL, NULL);
|
||||||
*endptr = (char *)nptr + (png_strlen(nptr) - len + 1);
|
*endptr = (char *)nptr + (png_strlen(nptr) - len + 1);
|
||||||
free(str);
|
png_free(png_ptr, str);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
# else
|
||||||
|
# define png_strtod(p,a,b) strtod(a,b)
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -90,6 +96,7 @@ png_get_uint_16(png_bytep buf)
|
|||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length)
|
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_read_data(png_ptr, buf, length);
|
||||||
png_calculate_crc(png_ptr, buf, length);
|
png_calculate_crc(png_ptr, buf, length);
|
||||||
}
|
}
|
||||||
@@ -178,7 +185,7 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
|
|||||||
png_charp chunkdata, png_size_t chunklength,
|
png_charp chunkdata, png_size_t chunklength,
|
||||||
png_size_t prefix_size, png_size_t *newlength)
|
png_size_t prefix_size, png_size_t *newlength)
|
||||||
{
|
{
|
||||||
static char msg[] = "Error decoding compressed text";
|
static PNG_CONST char msg[] = "Error decoding compressed text";
|
||||||
png_charp text;
|
png_charp text;
|
||||||
png_size_t text_size;
|
png_size_t text_size;
|
||||||
|
|
||||||
@@ -223,7 +230,7 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
|
|||||||
text_size = (png_size_t)(chunklength - (text - chunkdata) - 1);
|
text_size = (png_size_t)(chunklength - (text - chunkdata) - 1);
|
||||||
text_size = png_sizeof(msg) > text_size ? text_size :
|
text_size = png_sizeof(msg) > text_size ? text_size :
|
||||||
png_sizeof(msg);
|
png_sizeof(msg);
|
||||||
png_memcpy(text + prefix_size, msg, text_size + 1);
|
png_memcpy(text + prefix_size, msg, text_size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!png_ptr->zstream.avail_out || ret == Z_STREAM_END)
|
if (!png_ptr->zstream.avail_out || ret == Z_STREAM_END)
|
||||||
@@ -276,16 +283,19 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
|
|||||||
if (ret != Z_STREAM_END)
|
if (ret != Z_STREAM_END)
|
||||||
{
|
{
|
||||||
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
|
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
|
||||||
char umsg[50];
|
char umsg[52];
|
||||||
|
|
||||||
if (ret == Z_BUF_ERROR)
|
if (ret == Z_BUF_ERROR)
|
||||||
sprintf(umsg,"Buffer error in compressed datastream in %s chunk",
|
png_snprintf(umsg, 52,
|
||||||
|
"Buffer error in compressed datastream in %s chunk",
|
||||||
png_ptr->chunk_name);
|
png_ptr->chunk_name);
|
||||||
else if (ret == Z_DATA_ERROR)
|
else if (ret == Z_DATA_ERROR)
|
||||||
sprintf(umsg,"Data error in compressed datastream in %s chunk",
|
png_snprintf(umsg, 52,
|
||||||
|
"Data error in compressed datastream in %s chunk",
|
||||||
png_ptr->chunk_name);
|
png_ptr->chunk_name);
|
||||||
else
|
else
|
||||||
sprintf(umsg,"Incomplete compressed datastream in %s chunk",
|
png_snprintf(umsg, 52,
|
||||||
|
"Incomplete compressed datastream in %s chunk",
|
||||||
png_ptr->chunk_name);
|
png_ptr->chunk_name);
|
||||||
png_warning(png_ptr, umsg);
|
png_warning(png_ptr, umsg);
|
||||||
#else
|
#else
|
||||||
@@ -318,7 +328,8 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
|
|||||||
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
|
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
|
||||||
char umsg[50];
|
char umsg[50];
|
||||||
|
|
||||||
sprintf(umsg, "Unknown zTXt compression type %d", comp_type);
|
png_snprintf(umsg, 50,
|
||||||
|
"Unknown zTXt compression type %d", comp_type);
|
||||||
png_warning(png_ptr, umsg);
|
png_warning(png_ptr, umsg);
|
||||||
#else
|
#else
|
||||||
png_warning(png_ptr, "Unknown zTXt compression type");
|
png_warning(png_ptr, "Unknown zTXt compression type");
|
||||||
@@ -560,8 +571,7 @@ png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
}
|
}
|
||||||
png_crc_finish(png_ptr, length);
|
png_crc_finish(png_ptr, length);
|
||||||
|
|
||||||
if (&info_ptr == NULL) /* quiet compiler warnings about unused info_ptr */
|
info_ptr =info_ptr; /* quiet compiler warnings about unused info_ptr */
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PNG_READ_gAMA_SUPPORTED)
|
#if defined(PNG_READ_gAMA_SUPPORTED)
|
||||||
@@ -1034,7 +1044,7 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
|
|
||||||
/* there should be at least one zero (the compression type byte)
|
/* there should be at least one zero (the compression type byte)
|
||||||
following the separator, and we should be on it */
|
following the separator, and we should be on it */
|
||||||
if ( profile >= chunkdata + slength)
|
if ( profile >= chunkdata + slength - 1)
|
||||||
{
|
{
|
||||||
png_free(png_ptr, chunkdata);
|
png_free(png_ptr, chunkdata);
|
||||||
png_warning(png_ptr, "Malformed iCCP chunk");
|
png_warning(png_ptr, "Malformed iCCP chunk");
|
||||||
@@ -1138,7 +1148,7 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
++entry_start;
|
++entry_start;
|
||||||
|
|
||||||
/* a sample depth should follow the separator, and we should be on it */
|
/* a sample depth should follow the separator, and we should be on it */
|
||||||
if (entry_start > chunkdata + slength)
|
if (entry_start > chunkdata + slength - 2)
|
||||||
{
|
{
|
||||||
png_free(png_ptr, chunkdata);
|
png_free(png_ptr, chunkdata);
|
||||||
png_warning(png_ptr, "malformed sPLT chunk");
|
png_warning(png_ptr, "malformed sPLT chunk");
|
||||||
@@ -1311,7 +1321,10 @@ png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (png_crc_finish(png_ptr, 0))
|
if (png_crc_finish(png_ptr, 0))
|
||||||
|
{
|
||||||
|
png_ptr->num_trans = 0;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans,
|
png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans,
|
||||||
&(png_ptr->trans_values));
|
&(png_ptr->trans_values));
|
||||||
@@ -1374,7 +1387,7 @@ png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||||
{
|
{
|
||||||
png_ptr->background.index = buf[0];
|
png_ptr->background.index = buf[0];
|
||||||
if(info_ptr->num_palette)
|
if (info_ptr && info_ptr->num_palette)
|
||||||
{
|
{
|
||||||
if(buf[0] > info_ptr->num_palette)
|
if(buf[0] > info_ptr->num_palette)
|
||||||
{
|
{
|
||||||
@@ -1654,7 +1667,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
buf++; /* Skip the null string terminator from previous parameter. */
|
buf++; /* Skip the null string terminator from previous parameter. */
|
||||||
|
|
||||||
png_debug1(3, "Reading pCAL parameter %d\n", i);
|
png_debug1(3, "Reading pCAL parameter %d\n", i);
|
||||||
for (params[i] = buf; *buf != 0x00 && buf <= endptr; buf++)
|
for (params[i] = buf; buf <= endptr && *buf != 0x00; buf++)
|
||||||
/* Empty loop to move past each parameter string */ ;
|
/* Empty loop to move past each parameter string */ ;
|
||||||
|
|
||||||
/* Make sure we haven't run out of data yet */
|
/* Make sure we haven't run out of data yet */
|
||||||
@@ -1730,7 +1743,7 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
ep = buffer + 1; /* skip unit byte */
|
ep = buffer + 1; /* skip unit byte */
|
||||||
|
|
||||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
width = strtod(ep, &vp);
|
width = png_strtod(png_ptr, ep, &vp);
|
||||||
if (*vp)
|
if (*vp)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "malformed width string in sCAL chunk");
|
png_warning(png_ptr, "malformed width string in sCAL chunk");
|
||||||
@@ -1752,8 +1765,19 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
/* empty loop */ ;
|
/* empty loop */ ;
|
||||||
ep++;
|
ep++;
|
||||||
|
|
||||||
|
if (buffer + slength < ep)
|
||||||
|
{
|
||||||
|
png_warning(png_ptr, "Truncated sCAL chunk");
|
||||||
|
#if defined(PNG_FIXED_POINT_SUPPORTED) && \
|
||||||
|
!defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||||
|
png_free(png_ptr, swidth);
|
||||||
|
#endif
|
||||||
|
png_free(png_ptr, buffer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
height = strtod(ep, &vp);
|
height = png_strtod(png_ptr, ep, &vp);
|
||||||
if (*vp)
|
if (*vp)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "malformed height string in sCAL chunk");
|
png_warning(png_ptr, "malformed height string in sCAL chunk");
|
||||||
@@ -1762,7 +1786,7 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
#else
|
#else
|
||||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||||
sheight = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1);
|
sheight = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1);
|
||||||
if (swidth == NULL)
|
if (sheight == NULL)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "Out of memory while processing sCAL chunk height");
|
png_warning(png_ptr, "Out of memory while processing sCAL chunk height");
|
||||||
return;
|
return;
|
||||||
@@ -1975,10 +1999,11 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
/* empty loop */ ;
|
/* empty loop */ ;
|
||||||
|
|
||||||
/* zTXt must have some text after the chunkdataword */
|
/* zTXt must have some text after the chunkdataword */
|
||||||
if (text == chunkdata + slength)
|
if (text >= chunkdata + slength - 2)
|
||||||
{
|
{
|
||||||
comp_type = PNG_TEXT_COMPRESSION_NONE;
|
png_warning(png_ptr, "Truncated zTXt chunk");
|
||||||
png_warning(png_ptr, "Zero length zTXt chunk");
|
png_free(png_ptr, chunkdata);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2078,10 +2103,11 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
translated keyword (possibly empty), and possibly some text after the
|
translated keyword (possibly empty), and possibly some text after the
|
||||||
keyword */
|
keyword */
|
||||||
|
|
||||||
if (lang >= chunkdata + slength)
|
if (lang >= chunkdata + slength - 3)
|
||||||
{
|
{
|
||||||
comp_flag = PNG_TEXT_COMPRESSION_NONE;
|
png_warning(png_ptr, "Truncated iTXt chunk");
|
||||||
png_warning(png_ptr, "Zero length iTXt chunk");
|
png_free(png_ptr, chunkdata);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2093,9 +2119,22 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
/* empty loop */ ;
|
/* empty loop */ ;
|
||||||
lang_key++; /* skip NUL separator */
|
lang_key++; /* skip NUL separator */
|
||||||
|
|
||||||
|
if (lang_key >= chunkdata + slength)
|
||||||
|
{
|
||||||
|
png_warning(png_ptr, "Truncated iTXt chunk");
|
||||||
|
png_free(png_ptr, chunkdata);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (text = lang_key; *text; text++)
|
for (text = lang_key; *text; text++)
|
||||||
/* empty loop */ ;
|
/* empty loop */ ;
|
||||||
text++; /* skip NUL separator */
|
text++; /* skip NUL separator */
|
||||||
|
if (text >= chunkdata + slength)
|
||||||
|
{
|
||||||
|
png_warning(png_ptr, "Malformed iTXt chunk");
|
||||||
|
png_free(png_ptr, chunkdata);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
prefix_len = text - chunkdata;
|
prefix_len = text - chunkdata;
|
||||||
|
|
||||||
@@ -2145,7 +2184,7 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
if (png_ptr->mode & PNG_HAVE_IDAT)
|
if (png_ptr->mode & PNG_HAVE_IDAT)
|
||||||
{
|
{
|
||||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||||
PNG_IDAT;
|
PNG_CONST PNG_IDAT;
|
||||||
#endif
|
#endif
|
||||||
if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) /* not an IDAT */
|
if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) /* not an IDAT */
|
||||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||||
@@ -2170,8 +2209,6 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) ||
|
if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) ||
|
||||||
(png_ptr->read_user_chunk_fn != NULL))
|
(png_ptr->read_user_chunk_fn != NULL))
|
||||||
{
|
{
|
||||||
png_unknown_chunk chunk;
|
|
||||||
|
|
||||||
#ifdef PNG_MAX_MALLOC_64K
|
#ifdef PNG_MAX_MALLOC_64K
|
||||||
if (length > (png_uint_32)65535L)
|
if (length > (png_uint_32)65535L)
|
||||||
{
|
{
|
||||||
@@ -2180,30 +2217,42 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
length = (png_uint_32)65535L;
|
length = (png_uint_32)65535L;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name);
|
png_memcpy((png_charp)png_ptr->unknown_chunk.name,
|
||||||
chunk.data = (png_bytep)png_malloc(png_ptr, length);
|
(png_charp)png_ptr->chunk_name,
|
||||||
chunk.size = (png_size_t)length;
|
png_sizeof(png_ptr->unknown_chunk.name));
|
||||||
png_crc_read(png_ptr, (png_bytep)chunk.data, length);
|
png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name)-1] = '\0';
|
||||||
|
png_ptr->unknown_chunk.size = (png_size_t)length;
|
||||||
|
if (length == 0)
|
||||||
|
png_ptr->unknown_chunk.data = NULL;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length);
|
||||||
|
png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length);
|
||||||
|
}
|
||||||
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
|
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
|
||||||
if(png_ptr->read_user_chunk_fn != NULL)
|
if(png_ptr->read_user_chunk_fn != NULL)
|
||||||
{
|
{
|
||||||
/* callback to user unknown chunk handler */
|
/* callback to user unknown chunk handler */
|
||||||
if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0)
|
int ret;
|
||||||
|
ret = (*(png_ptr->read_user_chunk_fn))
|
||||||
|
(png_ptr, &png_ptr->unknown_chunk);
|
||||||
|
if (ret < 0)
|
||||||
|
png_chunk_error(png_ptr, "error in user chunk");
|
||||||
|
if (ret == 0)
|
||||||
{
|
{
|
||||||
if (!(png_ptr->chunk_name[0] & 0x20))
|
if (!(png_ptr->chunk_name[0] & 0x20))
|
||||||
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
|
if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
|
||||||
PNG_HANDLE_CHUNK_ALWAYS)
|
PNG_HANDLE_CHUNK_ALWAYS)
|
||||||
{
|
|
||||||
png_free(png_ptr, chunk.data);
|
|
||||||
png_chunk_error(png_ptr, "unknown critical chunk");
|
png_chunk_error(png_ptr, "unknown critical chunk");
|
||||||
}
|
png_set_unknown_chunks(png_ptr, info_ptr,
|
||||||
png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
|
&png_ptr->unknown_chunk, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
|
png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1);
|
||||||
png_free(png_ptr, chunk.data);
|
png_free(png_ptr, png_ptr->unknown_chunk.data);
|
||||||
|
png_ptr->unknown_chunk.data = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@@ -2212,8 +2261,7 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
|
|||||||
png_crc_finish(png_ptr, skip);
|
png_crc_finish(png_ptr, skip);
|
||||||
|
|
||||||
#if !defined(PNG_READ_USER_CHUNKS_SUPPORTED)
|
#if !defined(PNG_READ_USER_CHUNKS_SUPPORTED)
|
||||||
if (&info_ptr == NULL) /* quiet compiler warnings about unused info_ptr */
|
info_ptr = info_ptr; /* quiet compiler warnings about unused info_ptr */
|
||||||
return;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2246,7 +2294,7 @@ png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name)
|
|||||||
a zero indicates the pixel is to be skipped. This is in addition
|
a zero indicates the pixel is to be skipped. This is in addition
|
||||||
to any alpha or transparency value associated with the pixel. If
|
to any alpha or transparency value associated with the pixel. If
|
||||||
you want all pixels to be combined, pass 0xff (255) in mask. */
|
you want all pixels to be combined, pass 0xff (255) in mask. */
|
||||||
#ifndef PNG_HAVE_ASSEMBLER_COMBINE_ROW
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_combine_row(png_structp png_ptr, png_bytep row, int mask)
|
png_combine_row(png_structp png_ptr, png_bytep row, int mask)
|
||||||
{
|
{
|
||||||
@@ -2447,10 +2495,8 @@ png_combine_row(png_structp png_ptr, png_bytep row, int mask)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* !PNG_HAVE_ASSEMBLER_COMBINE_ROW */
|
|
||||||
|
|
||||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||||
#ifndef PNG_HAVE_ASSEMBLER_READ_INTERLACE /* else in pngvcrd.c, pnggccrd.c */
|
|
||||||
/* OLD pre-1.0.9 interface:
|
/* OLD pre-1.0.9 interface:
|
||||||
void png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
void png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||||
png_uint_32 transformations)
|
png_uint_32 transformations)
|
||||||
@@ -2465,10 +2511,10 @@ png_do_read_interlace(png_structp png_ptr)
|
|||||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||||
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||||
/* offset to next interlace block */
|
/* offset to next interlace block */
|
||||||
const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
png_debug(1,"in png_do_read_interlace (stock C version)\n");
|
png_debug(1,"in png_do_read_interlace\n");
|
||||||
if (row != NULL && row_info != NULL)
|
if (row != NULL && row_info != NULL)
|
||||||
{
|
{
|
||||||
png_uint_32 final_width;
|
png_uint_32 final_width;
|
||||||
@@ -2672,14 +2718,11 @@ png_do_read_interlace(png_structp png_ptr)
|
|||||||
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width);
|
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width);
|
||||||
}
|
}
|
||||||
#if !defined(PNG_READ_PACKSWAP_SUPPORTED)
|
#if !defined(PNG_READ_PACKSWAP_SUPPORTED)
|
||||||
if (&transformations == NULL) /* silence compiler warning */
|
transformations = transformations; /* silence compiler warning */
|
||||||
return;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif /* !PNG_HAVE_ASSEMBLER_READ_INTERLACE */
|
|
||||||
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||||
|
|
||||||
#ifndef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
|
png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
|
||||||
png_bytep prev_row, int filter)
|
png_bytep prev_row, int filter)
|
||||||
@@ -2802,25 +2845,26 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* !PNG_HAVE_ASSEMBLER_READ_FILTER_ROW */
|
|
||||||
|
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_read_finish_row(png_structp png_ptr)
|
png_read_finish_row(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||||
|
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||||
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||||
|
|
||||||
/* start of interlace block */
|
/* start of interlace block */
|
||||||
const int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
|
PNG_CONST int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
|
||||||
|
|
||||||
/* offset to next interlace block */
|
/* offset to next interlace block */
|
||||||
const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||||
|
|
||||||
/* start of interlace block in the y direction */
|
/* start of interlace block in the y direction */
|
||||||
const int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
|
PNG_CONST int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
|
||||||
|
|
||||||
/* offset to next interlace block in the y direction */
|
/* offset to next interlace block in the y direction */
|
||||||
const int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
||||||
|
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
png_debug(1, "in png_read_finish_row\n");
|
png_debug(1, "in png_read_finish_row\n");
|
||||||
@@ -2828,10 +2872,12 @@ png_read_finish_row(png_structp png_ptr)
|
|||||||
if (png_ptr->row_number < png_ptr->num_rows)
|
if (png_ptr->row_number < png_ptr->num_rows)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||||
if (png_ptr->interlaced)
|
if (png_ptr->interlaced)
|
||||||
{
|
{
|
||||||
png_ptr->row_number = 0;
|
png_ptr->row_number = 0;
|
||||||
png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
|
png_memset_check(png_ptr, png_ptr->prev_row, 0,
|
||||||
|
png_ptr->rowbytes + 1);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
png_ptr->pass++;
|
png_ptr->pass++;
|
||||||
@@ -2861,11 +2907,12 @@ png_read_finish_row(png_structp png_ptr)
|
|||||||
if (png_ptr->pass < 7)
|
if (png_ptr->pass < 7)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||||
|
|
||||||
if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
|
if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
|
||||||
{
|
{
|
||||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||||
PNG_IDAT;
|
PNG_CONST PNG_IDAT;
|
||||||
#endif
|
#endif
|
||||||
char extra;
|
char extra;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -2886,7 +2933,7 @@ png_read_finish_row(png_structp png_ptr)
|
|||||||
png_ptr->idat_size = png_get_uint_31(png_ptr, chunk_length);
|
png_ptr->idat_size = png_get_uint_31(png_ptr, chunk_length);
|
||||||
png_reset_crc(png_ptr);
|
png_reset_crc(png_ptr);
|
||||||
png_crc_read(png_ptr, png_ptr->chunk_name, 4);
|
png_crc_read(png_ptr, png_ptr->chunk_name, 4);
|
||||||
if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4))
|
if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
|
||||||
png_error(png_ptr, "Not enough image data");
|
png_error(png_ptr, "Not enough image data");
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2935,19 +2982,21 @@ void /* PRIVATE */
|
|||||||
png_read_start_row(png_structp png_ptr)
|
png_read_start_row(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||||
|
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||||
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||||
|
|
||||||
/* start of interlace block */
|
/* start of interlace block */
|
||||||
const int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
|
PNG_CONST int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
|
||||||
|
|
||||||
/* offset to next interlace block */
|
/* offset to next interlace block */
|
||||||
const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||||
|
|
||||||
/* start of interlace block in the y direction */
|
/* start of interlace block in the y direction */
|
||||||
const int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
|
PNG_CONST int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
|
||||||
|
|
||||||
/* offset to next interlace block in the y direction */
|
/* offset to next interlace block in the y direction */
|
||||||
const int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int max_pixel_depth;
|
int max_pixel_depth;
|
||||||
@@ -2956,6 +3005,7 @@ png_read_start_row(png_structp png_ptr)
|
|||||||
png_debug(1, "in png_read_start_row\n");
|
png_debug(1, "in png_read_start_row\n");
|
||||||
png_ptr->zstream.avail_in = 0;
|
png_ptr->zstream.avail_in = 0;
|
||||||
png_init_read_transformations(png_ptr);
|
png_init_read_transformations(png_ptr);
|
||||||
|
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||||
if (png_ptr->interlaced)
|
if (png_ptr->interlaced)
|
||||||
{
|
{
|
||||||
if (!(png_ptr->transformations & PNG_INTERLACE))
|
if (!(png_ptr->transformations & PNG_INTERLACE))
|
||||||
@@ -2976,6 +3026,7 @@ png_read_start_row(png_structp png_ptr)
|
|||||||
png_error(png_ptr, "Rowbytes overflow in png_read_start_row");
|
png_error(png_ptr, "Rowbytes overflow in png_read_start_row");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||||
{
|
{
|
||||||
png_ptr->num_rows = png_ptr->height;
|
png_ptr->num_rows = png_ptr->height;
|
||||||
png_ptr->iwidth = png_ptr->width;
|
png_ptr->iwidth = png_ptr->width;
|
||||||
@@ -3094,20 +3145,29 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
|||||||
if (row_bytes > (png_uint_32)65536L)
|
if (row_bytes > (png_uint_32)65536L)
|
||||||
png_error(png_ptr, "This image requires a row greater than 64KB");
|
png_error(png_ptr, "This image requires a row greater than 64KB");
|
||||||
#endif
|
#endif
|
||||||
png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64);
|
|
||||||
png_ptr->row_buf = png_ptr->big_row_buf+32;
|
if(row_bytes + 64 > png_ptr->old_big_row_buf_size)
|
||||||
#if defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD)
|
{
|
||||||
png_ptr->row_buf_size = row_bytes;
|
png_free(png_ptr,png_ptr->big_row_buf);
|
||||||
#endif
|
png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64);
|
||||||
|
png_ptr->row_buf = png_ptr->big_row_buf+32;
|
||||||
|
png_ptr->old_big_row_buf_size = row_bytes+64;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef PNG_MAX_MALLOC_64K
|
#ifdef PNG_MAX_MALLOC_64K
|
||||||
if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L)
|
if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L)
|
||||||
png_error(png_ptr, "This image requires a row greater than 64KB");
|
png_error(png_ptr, "This image requires a row greater than 64KB");
|
||||||
#endif
|
#endif
|
||||||
if ((png_uint_32)png_ptr->rowbytes > PNG_SIZE_MAX - 1)
|
if ((png_uint_32)png_ptr->rowbytes > (png_uint_32)(PNG_SIZE_MAX - 1))
|
||||||
png_error(png_ptr, "Row has too many bytes to allocate in memory.");
|
png_error(png_ptr, "Row has too many bytes to allocate in memory.");
|
||||||
png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)(
|
|
||||||
png_ptr->rowbytes + 1));
|
if(png_ptr->rowbytes+1 > png_ptr->old_prev_row_size)
|
||||||
|
{
|
||||||
|
png_free(png_ptr,png_ptr->prev_row);
|
||||||
|
png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)(
|
||||||
|
png_ptr->rowbytes + 1));
|
||||||
|
png_ptr->old_prev_row_size = png_ptr->rowbytes+1;
|
||||||
|
}
|
||||||
|
|
||||||
png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
|
png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
|
||||||
|
|
||||||
|
|||||||
225
pngset.c
225
pngset.c
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
/* pngset.c - storage of image information into info struct
|
/* pngset.c - storage of image information into info struct
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.2.9 April 14, 2006
|
* Last changed in libpng 1.2.27 [April 29, 2008]
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@@ -41,7 +41,13 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
|
|||||||
png_debug1(1, "in %s storage function\n", "cHRM");
|
png_debug1(1, "in %s storage function\n", "cHRM");
|
||||||
if (png_ptr == NULL || info_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
if (!(white_x || white_y || red_x || red_y || green_x || green_y ||
|
||||||
|
blue_x || blue_y))
|
||||||
|
{
|
||||||
|
png_warning(png_ptr,
|
||||||
|
"Ignoring attempt to set all-zero chromaticity values");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (white_x < 0.0 || white_y < 0.0 ||
|
if (white_x < 0.0 || white_y < 0.0 ||
|
||||||
red_x < 0.0 || red_y < 0.0 ||
|
red_x < 0.0 || red_y < 0.0 ||
|
||||||
green_x < 0.0 || green_y < 0.0 ||
|
green_x < 0.0 || green_y < 0.0 ||
|
||||||
@@ -93,6 +99,13 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
|
|||||||
if (png_ptr == NULL || info_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!(white_x || white_y || red_x || red_y || green_x || green_y ||
|
||||||
|
blue_x || blue_y))
|
||||||
|
{
|
||||||
|
png_warning(png_ptr,
|
||||||
|
"Ignoring attempt to set all-zero chromaticity values");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (white_x < 0 || white_y < 0 ||
|
if (white_x < 0 || white_y < 0 ||
|
||||||
red_x < 0 || red_y < 0 ||
|
red_x < 0 || red_y < 0 ||
|
||||||
green_x < 0 || green_y < 0 ||
|
green_x < 0 || green_y < 0 ||
|
||||||
@@ -102,25 +115,14 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
|
|||||||
"Ignoring attempt to set negative chromaticity value");
|
"Ignoring attempt to set negative chromaticity value");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
if (white_x > (png_fixed_point) PNG_UINT_31_MAX ||
|
||||||
if (white_x > (double) PNG_UINT_31_MAX ||
|
white_y > (png_fixed_point) PNG_UINT_31_MAX ||
|
||||||
white_y > (double) PNG_UINT_31_MAX ||
|
red_x > (png_fixed_point) PNG_UINT_31_MAX ||
|
||||||
red_x > (double) PNG_UINT_31_MAX ||
|
red_y > (png_fixed_point) PNG_UINT_31_MAX ||
|
||||||
red_y > (double) PNG_UINT_31_MAX ||
|
green_x > (png_fixed_point) PNG_UINT_31_MAX ||
|
||||||
green_x > (double) PNG_UINT_31_MAX ||
|
green_y > (png_fixed_point) PNG_UINT_31_MAX ||
|
||||||
green_y > (double) PNG_UINT_31_MAX ||
|
blue_x > (png_fixed_point) PNG_UINT_31_MAX ||
|
||||||
blue_x > (double) PNG_UINT_31_MAX ||
|
blue_y > (png_fixed_point) PNG_UINT_31_MAX )
|
||||||
blue_y > (double) PNG_UINT_31_MAX)
|
|
||||||
#else
|
|
||||||
if (white_x > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
|
|
||||||
white_y > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
|
|
||||||
red_x > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
|
|
||||||
red_y > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
|
|
||||||
green_x > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
|
|
||||||
green_y > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
|
|
||||||
blue_x > (png_fixed_point) PNG_UINT_31_MAX/100000L ||
|
|
||||||
blue_y > (png_fixed_point) PNG_UINT_31_MAX/100000L)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
png_warning(png_ptr,
|
png_warning(png_ptr,
|
||||||
"Ignoring attempt to set chromaticity value exceeding 21474.83");
|
"Ignoring attempt to set chromaticity value exceeding 21474.83");
|
||||||
@@ -222,7 +224,7 @@ png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
|
|||||||
png_debug1(1, "in %s storage function\n", "hIST");
|
png_debug1(1, "in %s storage function\n", "hIST");
|
||||||
if (png_ptr == NULL || info_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
if (info_ptr->num_palette <= 0 || info_ptr->num_palette
|
if (info_ptr->num_palette == 0 || info_ptr->num_palette
|
||||||
> PNG_MAX_PALETTE_LENGTH)
|
> PNG_MAX_PALETTE_LENGTH)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr,
|
png_warning(png_ptr,
|
||||||
@@ -353,7 +355,7 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
|
|||||||
info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
|
info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
|
||||||
|
|
||||||
/* check for potential overflow */
|
/* check for potential overflow */
|
||||||
if ( width > (PNG_UINT_32_MAX
|
if (width > (PNG_UINT_32_MAX
|
||||||
>> 3) /* 8-byte RGBA pixels */
|
>> 3) /* 8-byte RGBA pixels */
|
||||||
- 64 /* bigrowbuf hack */
|
- 64 /* bigrowbuf hack */
|
||||||
- 1 /* filter byte */
|
- 1 /* filter byte */
|
||||||
@@ -484,7 +486,9 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
|
|||||||
info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length);
|
info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length);
|
||||||
if (info_ptr->scal_s_width == NULL)
|
if (info_ptr->scal_s_width == NULL)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "Memory allocation failed while processing sCAL.");
|
png_warning(png_ptr,
|
||||||
|
"Memory allocation failed while processing sCAL.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length);
|
png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length);
|
||||||
|
|
||||||
@@ -494,10 +498,11 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
|
|||||||
if (info_ptr->scal_s_height == NULL)
|
if (info_ptr->scal_s_height == NULL)
|
||||||
{
|
{
|
||||||
png_free (png_ptr, info_ptr->scal_s_width);
|
png_free (png_ptr, info_ptr->scal_s_width);
|
||||||
png_warning(png_ptr, "Memory allocation failed while processing sCAL.");
|
png_warning(png_ptr,
|
||||||
|
"Memory allocation failed while processing sCAL.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length);
|
png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length);
|
||||||
|
|
||||||
info_ptr->valid |= PNG_INFO_sCAL;
|
info_ptr->valid |= PNG_INFO_sCAL;
|
||||||
#ifdef PNG_FREE_ME_SUPPORTED
|
#ifdef PNG_FREE_ME_SUPPORTED
|
||||||
info_ptr->free_me |= PNG_FREE_SCAL;
|
info_ptr->free_me |= PNG_FREE_SCAL;
|
||||||
@@ -677,18 +682,20 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
|
|||||||
{
|
{
|
||||||
png_charp new_iccp_name;
|
png_charp new_iccp_name;
|
||||||
png_charp new_iccp_profile;
|
png_charp new_iccp_profile;
|
||||||
|
png_uint_32 length;
|
||||||
|
|
||||||
png_debug1(1, "in %s storage function\n", "iCCP");
|
png_debug1(1, "in %s storage function\n", "iCCP");
|
||||||
if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL)
|
if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
new_iccp_name = (png_charp)png_malloc_warn(png_ptr, png_strlen(name)+1);
|
length = png_strlen(name)+1;
|
||||||
|
new_iccp_name = (png_charp)png_malloc_warn(png_ptr, length);
|
||||||
if (new_iccp_name == NULL)
|
if (new_iccp_name == NULL)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "Insufficient memory to process iCCP chunk.");
|
png_warning(png_ptr, "Insufficient memory to process iCCP chunk.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
png_strcpy(new_iccp_name, name);
|
png_memcpy(new_iccp_name, name, length);
|
||||||
new_iccp_profile = (png_charp)png_malloc_warn(png_ptr, proflen);
|
new_iccp_profile = (png_charp)png_malloc_warn(png_ptr, proflen);
|
||||||
if (new_iccp_profile == NULL)
|
if (new_iccp_profile == NULL)
|
||||||
{
|
{
|
||||||
@@ -877,7 +884,6 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
|
|||||||
textp->itxt_length = 0;
|
textp->itxt_length = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
info_ptr->text[info_ptr->num_text]= *textp;
|
|
||||||
info_ptr->num_text++;
|
info_ptr->num_text++;
|
||||||
png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text);
|
png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text);
|
||||||
}
|
}
|
||||||
@@ -908,6 +914,8 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
|
|||||||
if (png_ptr == NULL || info_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
|
||||||
|
|
||||||
if (trans != NULL)
|
if (trans != NULL)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -915,30 +923,41 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
|
|||||||
* we do it for backward compatibility with the way the png_handle_tRNS
|
* we do it for backward compatibility with the way the png_handle_tRNS
|
||||||
* function used to do the allocation.
|
* function used to do the allocation.
|
||||||
*/
|
*/
|
||||||
#ifdef PNG_FREE_ME_SUPPORTED
|
|
||||||
png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
|
|
||||||
#endif
|
|
||||||
/* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */
|
/* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */
|
||||||
png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr,
|
png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr,
|
||||||
(png_uint_32)PNG_MAX_PALETTE_LENGTH);
|
(png_uint_32)PNG_MAX_PALETTE_LENGTH);
|
||||||
if (num_trans <= PNG_MAX_PALETTE_LENGTH)
|
if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH)
|
||||||
png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans);
|
png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans);
|
||||||
#ifdef PNG_FREE_ME_SUPPORTED
|
|
||||||
info_ptr->free_me |= PNG_FREE_TRNS;
|
|
||||||
#else
|
|
||||||
png_ptr->flags |= PNG_FLAG_FREE_TRNS;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trans_values != NULL)
|
if (trans_values != NULL)
|
||||||
{
|
{
|
||||||
|
int sample_max = (1 << info_ptr->bit_depth);
|
||||||
|
if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
|
||||||
|
(int)trans_values->gray > sample_max) ||
|
||||||
|
(info_ptr->color_type == PNG_COLOR_TYPE_RGB &&
|
||||||
|
((int)trans_values->red > sample_max ||
|
||||||
|
(int)trans_values->green > sample_max ||
|
||||||
|
(int)trans_values->blue > sample_max)))
|
||||||
|
png_warning(png_ptr,
|
||||||
|
"tRNS chunk has out-of-range samples for bit_depth");
|
||||||
png_memcpy(&(info_ptr->trans_values), trans_values,
|
png_memcpy(&(info_ptr->trans_values), trans_values,
|
||||||
png_sizeof(png_color_16));
|
png_sizeof(png_color_16));
|
||||||
if (num_trans == 0)
|
if (num_trans == 0)
|
||||||
num_trans = 1;
|
num_trans = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
info_ptr->num_trans = (png_uint_16)num_trans;
|
info_ptr->num_trans = (png_uint_16)num_trans;
|
||||||
info_ptr->valid |= PNG_INFO_tRNS;
|
if (num_trans != 0)
|
||||||
|
{
|
||||||
|
info_ptr->valid |= PNG_INFO_tRNS;
|
||||||
|
#ifdef PNG_FREE_ME_SUPPORTED
|
||||||
|
info_ptr->free_me |= PNG_FREE_TRNS;
|
||||||
|
#else
|
||||||
|
png_ptr->flags |= PNG_FLAG_FREE_TRNS;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -970,16 +989,29 @@ png_set_sPLT(png_structp png_ptr,
|
|||||||
{
|
{
|
||||||
png_sPLT_tp to = np + info_ptr->splt_palettes_num + i;
|
png_sPLT_tp to = np + info_ptr->splt_palettes_num + i;
|
||||||
png_sPLT_tp from = entries + i;
|
png_sPLT_tp from = entries + i;
|
||||||
|
png_uint_32 length;
|
||||||
|
|
||||||
to->name = (png_charp)png_malloc(png_ptr,
|
length = png_strlen(from->name) + 1;
|
||||||
png_strlen(from->name) + 1);
|
to->name = (png_charp)png_malloc_warn(png_ptr, length);
|
||||||
/* TODO: use png_malloc_warn */
|
if (to->name == NULL)
|
||||||
png_strcpy(to->name, from->name);
|
{
|
||||||
to->entries = (png_sPLT_entryp)png_malloc(png_ptr,
|
png_warning(png_ptr,
|
||||||
from->nentries * png_sizeof(png_sPLT_t));
|
"Out of memory while processing sPLT chunk");
|
||||||
/* TODO: use png_malloc_warn */
|
continue;
|
||||||
|
}
|
||||||
|
png_memcpy(to->name, from->name, length);
|
||||||
|
to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr,
|
||||||
|
from->nentries * png_sizeof(png_sPLT_entry));
|
||||||
|
if (to->entries == NULL)
|
||||||
|
{
|
||||||
|
png_warning(png_ptr,
|
||||||
|
"Out of memory while processing sPLT chunk");
|
||||||
|
png_free(png_ptr,to->name);
|
||||||
|
to->name = NULL;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
png_memcpy(to->entries, from->entries,
|
png_memcpy(to->entries, from->entries,
|
||||||
from->nentries * png_sizeof(png_sPLT_t));
|
from->nentries * png_sizeof(png_sPLT_entry));
|
||||||
to->nentries = from->nentries;
|
to->nentries = from->nentries;
|
||||||
to->depth = from->depth;
|
to->depth = from->depth;
|
||||||
}
|
}
|
||||||
@@ -1009,7 +1041,8 @@ png_set_unknown_chunks(png_structp png_ptr,
|
|||||||
png_sizeof(png_unknown_chunk));
|
png_sizeof(png_unknown_chunk));
|
||||||
if (np == NULL)
|
if (np == NULL)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "Out of memory while processing unknown chunk.");
|
png_warning(png_ptr,
|
||||||
|
"Out of memory while processing unknown chunk.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1020,23 +1053,31 @@ png_set_unknown_chunks(png_structp png_ptr,
|
|||||||
|
|
||||||
for (i = 0; i < num_unknowns; i++)
|
for (i = 0; i < num_unknowns; i++)
|
||||||
{
|
{
|
||||||
png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i;
|
png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i;
|
||||||
png_unknown_chunkp from = unknowns + i;
|
png_unknown_chunkp from = unknowns + i;
|
||||||
|
|
||||||
png_strncpy((png_charp)to->name, (png_charp)from->name, 5);
|
png_memcpy((png_charp)to->name,
|
||||||
to->data = (png_bytep)png_malloc_warn(png_ptr, from->size);
|
(png_charp)from->name,
|
||||||
if (to->data == NULL)
|
png_sizeof(from->name));
|
||||||
{
|
to->name[png_sizeof(to->name)-1] = '\0';
|
||||||
png_warning(png_ptr, "Out of memory processing unknown chunk.");
|
to->size = from->size;
|
||||||
}
|
/* note our location in the read or write sequence */
|
||||||
else
|
to->location = (png_byte)(png_ptr->mode & 0xff);
|
||||||
{
|
|
||||||
png_memcpy(to->data, from->data, from->size);
|
|
||||||
to->size = from->size;
|
|
||||||
|
|
||||||
/* note our location in the read or write sequence */
|
if (from->size == 0)
|
||||||
to->location = (png_byte)(png_ptr->mode & 0xff);
|
to->data=NULL;
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
to->data = (png_bytep)png_malloc_warn(png_ptr, from->size);
|
||||||
|
if (to->data == NULL)
|
||||||
|
{
|
||||||
|
png_warning(png_ptr,
|
||||||
|
"Out of memory while processing unknown chunk.");
|
||||||
|
to->size=0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
png_memcpy(to->data, from->data, from->size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info_ptr->unknown_chunks = np;
|
info_ptr->unknown_chunks = np;
|
||||||
@@ -1067,7 +1108,7 @@ png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted)
|
|||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
png_ptr->mng_features_permitted = (png_byte)
|
png_ptr->mng_features_permitted = (png_byte)
|
||||||
((png_ptr->mng_features_permitted & (~(PNG_FLAG_MNG_EMPTY_PLTE))) |
|
((png_ptr->mng_features_permitted & (~PNG_FLAG_MNG_EMPTY_PLTE)) |
|
||||||
((empty_plte_permitted & PNG_FLAG_MNG_EMPTY_PLTE)));
|
((empty_plte_permitted & PNG_FLAG_MNG_EMPTY_PLTE)));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1168,8 +1209,7 @@ png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size)
|
|||||||
{
|
{
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
if(png_ptr->zbuf)
|
png_free(png_ptr, png_ptr->zbuf);
|
||||||
png_free(png_ptr, png_ptr->zbuf);
|
|
||||||
png_ptr->zbuf_size = (png_size_t)size;
|
png_ptr->zbuf_size = (png_size_t)size;
|
||||||
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size);
|
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size);
|
||||||
png_ptr->zstream.next_out = png_ptr->zbuf;
|
png_ptr->zstream.next_out = png_ptr->zbuf;
|
||||||
@@ -1181,68 +1221,30 @@ void PNGAPI
|
|||||||
png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask)
|
png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask)
|
||||||
{
|
{
|
||||||
if (png_ptr && info_ptr)
|
if (png_ptr && info_ptr)
|
||||||
info_ptr->valid &= ~(mask);
|
info_ptr->valid &= ~mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef PNG_1_0_X
|
#ifndef PNG_1_0_X
|
||||||
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
|
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
|
||||||
/* this function was added to libpng 1.2.0 and should always exist by default */
|
/* function was added to libpng 1.2.0 and should always exist by default */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags)
|
png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags)
|
||||||
{
|
{
|
||||||
png_uint_32 settable_asm_flags;
|
/* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */
|
||||||
png_uint_32 settable_mmx_flags;
|
if (png_ptr != NULL)
|
||||||
|
png_ptr->asm_flags = 0;
|
||||||
if (png_ptr == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
settable_mmx_flags =
|
|
||||||
#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW
|
|
||||||
PNG_ASM_FLAG_MMX_READ_COMBINE_ROW |
|
|
||||||
#endif
|
|
||||||
#ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE
|
|
||||||
PNG_ASM_FLAG_MMX_READ_INTERLACE |
|
|
||||||
#endif
|
|
||||||
#ifdef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW
|
|
||||||
PNG_ASM_FLAG_MMX_READ_FILTER_SUB |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_FILTER_UP |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_FILTER_AVG |
|
|
||||||
PNG_ASM_FLAG_MMX_READ_FILTER_PAETH |
|
|
||||||
#endif
|
|
||||||
0;
|
|
||||||
|
|
||||||
/* could be some non-MMX ones in the future, but not currently: */
|
|
||||||
settable_asm_flags = settable_mmx_flags;
|
|
||||||
|
|
||||||
if (!(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_COMPILED) ||
|
|
||||||
!(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU))
|
|
||||||
{
|
|
||||||
/* clear all MMX flags if MMX isn't supported */
|
|
||||||
settable_asm_flags &= ~settable_mmx_flags;
|
|
||||||
png_ptr->asm_flags &= ~settable_mmx_flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* we're replacing the settable bits with those passed in by the user,
|
|
||||||
* so first zero them out of the master copy, then logical-OR in the
|
|
||||||
* allowed subset that was requested */
|
|
||||||
|
|
||||||
png_ptr->asm_flags &= ~settable_asm_flags; /* zero them */
|
|
||||||
png_ptr->asm_flags |= (asm_flags & settable_asm_flags); /* set them */
|
|
||||||
}
|
}
|
||||||
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
|
|
||||||
|
|
||||||
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
|
|
||||||
/* this function was added to libpng 1.2.0 */
|
/* this function was added to libpng 1.2.0 */
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_mmx_thresholds (png_structp png_ptr,
|
png_set_mmx_thresholds (png_structp png_ptr,
|
||||||
png_byte mmx_bitdepth_threshold,
|
png_byte mmx_bitdepth_threshold,
|
||||||
png_uint_32 mmx_rowbytes_threshold)
|
png_uint_32 mmx_rowbytes_threshold)
|
||||||
{
|
{
|
||||||
|
/* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
png_ptr->mmx_bitdepth_threshold = mmx_bitdepth_threshold;
|
|
||||||
png_ptr->mmx_rowbytes_threshold = mmx_rowbytes_threshold;
|
|
||||||
}
|
}
|
||||||
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
|
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
|
||||||
|
|
||||||
@@ -1256,6 +1258,7 @@ png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max,
|
|||||||
* rejected by png_set_IHDR(). To accept any PNG datastream
|
* rejected by png_set_IHDR(). To accept any PNG datastream
|
||||||
* regardless of dimensions, set both limits to 0x7ffffffL.
|
* regardless of dimensions, set both limits to 0x7ffffffL.
|
||||||
*/
|
*/
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
png_ptr->user_width_max = user_width_max;
|
png_ptr->user_width_max = user_width_max;
|
||||||
png_ptr->user_height_max = user_height_max;
|
png_ptr->user_height_max = user_height_max;
|
||||||
}
|
}
|
||||||
|
|||||||
91
pngtest.c
91
pngtest.c
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
/* pngtest.c - a simple test program to test libpng
|
/* pngtest.c - a simple test program to test libpng
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.2.6 - August 15, 2004
|
* Last changed in libpng 1.2.27 - [April 29, 2008]
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@@ -81,21 +81,10 @@ static float t_start, t_stop, t_decode, t_encode, t_misc;
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */
|
|
||||||
#ifndef png_jmpbuf
|
|
||||||
# define png_jmpbuf(png_ptr) png_ptr->jmpbuf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PNGTEST_TIMING
|
|
||||||
static float t_start, t_stop, t_decode, t_encode, t_misc;
|
|
||||||
#if !defined(PNG_tIME_SUPPORTED)
|
|
||||||
#include <time.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||||
|
#define PNG_tIME_STRING_LENGTH 30
|
||||||
static int tIME_chunk_present=0;
|
static int tIME_chunk_present=0;
|
||||||
static char tIME_string[30] = "no tIME chunk present in file";
|
static char tIME_string[PNG_tIME_STRING_LENGTH] = "no tIME chunk present in file";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int verbose = 0;
|
static int verbose = 0;
|
||||||
@@ -115,6 +104,16 @@ static int status_pass=1;
|
|||||||
static int status_dots_requested=0;
|
static int status_dots_requested=0;
|
||||||
static int status_dots=1;
|
static int status_dots=1;
|
||||||
|
|
||||||
|
/* In case a system header (e.g., on AIX) defined jmpbuf */
|
||||||
|
#ifdef jmpbuf
|
||||||
|
# undef jmpbuf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */
|
||||||
|
#ifndef png_jmpbuf
|
||||||
|
# define png_jmpbuf(png_ptr) png_ptr->jmpbuf
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
#ifdef PNG_1_0_X
|
#ifdef PNG_1_0_X
|
||||||
PNGAPI
|
PNGAPI
|
||||||
@@ -436,8 +435,9 @@ pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||||||
png_error(png_ptr, "Write Error");
|
png_error(png_ptr, "Write Error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* USE_FAR_KEYWORD */
|
#endif /* USE_FAR_KEYWORD */
|
||||||
|
#endif /* PNG_NO_STDIO */
|
||||||
|
/* END of code to validate stdio-free compilation */
|
||||||
|
|
||||||
/* This function is called when there is a warning, but the library thinks
|
/* This function is called when there is a warning, but the library thinks
|
||||||
* it can continue anyway. Replacement functions don't have to do anything
|
* it can continue anyway. Replacement functions don't have to do anything
|
||||||
@@ -465,8 +465,6 @@ pngtest_error(png_structp png_ptr, png_const_charp message)
|
|||||||
/* We can return because png_error calls the default handler, which is
|
/* We can return because png_error calls the default handler, which is
|
||||||
* actually OK in this case. */
|
* actually OK in this case. */
|
||||||
}
|
}
|
||||||
#endif /* PNG_NO_STDIO */
|
|
||||||
/* END of code to validate stdio-free compilation */
|
|
||||||
|
|
||||||
/* START of code to validate memory allocation and deallocation */
|
/* START of code to validate memory allocation and deallocation */
|
||||||
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
|
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
|
||||||
@@ -536,7 +534,8 @@ png_debug_malloc(png_structp png_ptr, png_uint_32 size)
|
|||||||
/* Make sure the caller isn't assuming zeroed memory. */
|
/* Make sure the caller isn't assuming zeroed memory. */
|
||||||
png_memset(pinfo->pointer, 0xdd, pinfo->size);
|
png_memset(pinfo->pointer, 0xdd, pinfo->size);
|
||||||
if(verbose)
|
if(verbose)
|
||||||
printf("png_malloc %lu bytes at %x\n",size,pinfo->pointer);
|
printf("png_malloc %lu bytes at %x\n",(unsigned long)size,
|
||||||
|
pinfo->pointer);
|
||||||
return (png_voidp)(pinfo->pointer);
|
return (png_voidp)(pinfo->pointer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -659,10 +658,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
|
read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
|
||||||
png_error_ptr_NULL, png_error_ptr_NULL);
|
png_error_ptr_NULL, png_error_ptr_NULL);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_NO_STDIO)
|
|
||||||
png_set_error_fn(read_ptr, (png_voidp)inname, pngtest_error,
|
png_set_error_fn(read_ptr, (png_voidp)inname, pngtest_error,
|
||||||
pngtest_warning);
|
pngtest_warning);
|
||||||
#endif
|
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
|
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
|
||||||
write_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
|
write_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
|
||||||
@@ -672,10 +669,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
write_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
|
write_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL,
|
||||||
png_error_ptr_NULL, png_error_ptr_NULL);
|
png_error_ptr_NULL, png_error_ptr_NULL);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_NO_STDIO)
|
|
||||||
png_set_error_fn(write_ptr, (png_voidp)inname, pngtest_error,
|
png_set_error_fn(write_ptr, (png_voidp)inname, pngtest_error,
|
||||||
pngtest_warning);
|
pngtest_warning);
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
png_debug(0, "Allocating read_info, write_info and end_info structures\n");
|
png_debug(0, "Allocating read_info, write_info and end_info structures\n");
|
||||||
read_info_ptr = png_create_info_struct(read_ptr);
|
read_info_ptr = png_create_info_struct(read_ptr);
|
||||||
@@ -694,8 +689,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname);
|
fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname);
|
||||||
if (row_buf)
|
png_free(read_ptr, row_buf);
|
||||||
png_free(read_ptr, row_buf);
|
|
||||||
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
png_destroy_info_struct(write_ptr, &write_end_info_ptr);
|
png_destroy_info_struct(write_ptr, &write_end_info_ptr);
|
||||||
@@ -1008,10 +1002,13 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
{
|
{
|
||||||
png_set_tIME(write_ptr, write_info_ptr, mod_time);
|
png_set_tIME(write_ptr, write_info_ptr, mod_time);
|
||||||
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||||
/* we have to use png_strcpy instead of "=" because the string
|
/* we have to use png_memcpy instead of "=" because the string
|
||||||
pointed to by png_convert_to_rfc1123() gets free'ed before
|
pointed to by png_convert_to_rfc1123() gets free'ed before
|
||||||
we use it */
|
we use it */
|
||||||
png_strcpy(tIME_string,png_convert_to_rfc1123(read_ptr, mod_time));
|
png_memcpy(tIME_string,
|
||||||
|
png_convert_to_rfc1123(read_ptr, mod_time),
|
||||||
|
png_sizeof(tIME_string));
|
||||||
|
tIME_string[png_sizeof(tIME_string)-1] = '\0';
|
||||||
tIME_chunk_present++;
|
tIME_chunk_present++;
|
||||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||||
}
|
}
|
||||||
@@ -1026,8 +1023,16 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
if (png_get_tRNS(read_ptr, read_info_ptr, &trans, &num_trans,
|
if (png_get_tRNS(read_ptr, read_info_ptr, &trans, &num_trans,
|
||||||
&trans_values))
|
&trans_values))
|
||||||
{
|
{
|
||||||
png_set_tRNS(write_ptr, write_info_ptr, trans, num_trans,
|
int sample_max = (1 << read_info_ptr->bit_depth);
|
||||||
trans_values);
|
/* libpng doesn't reject a tRNS chunk with out-of-range samples */
|
||||||
|
if (!((read_info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
|
||||||
|
(int)trans_values->gray > sample_max) ||
|
||||||
|
(read_info_ptr->color_type == PNG_COLOR_TYPE_RGB &&
|
||||||
|
((int)trans_values->red > sample_max ||
|
||||||
|
(int)trans_values->green > sample_max ||
|
||||||
|
(int)trans_values->blue > sample_max))))
|
||||||
|
png_set_tRNS(write_ptr, write_info_ptr, trans, num_trans,
|
||||||
|
trans_values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1148,10 +1153,13 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
{
|
{
|
||||||
png_set_tIME(write_ptr, write_end_info_ptr, mod_time);
|
png_set_tIME(write_ptr, write_end_info_ptr, mod_time);
|
||||||
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||||
/* we have to use png_strcpy instead of "=" because the string
|
/* we have to use png_memcpy instead of "=" because the string
|
||||||
pointed to by png_convert_to_rfc1123() gets free'ed before
|
pointed to by png_convert_to_rfc1123() gets free'ed before
|
||||||
we use it */
|
we use it */
|
||||||
png_strcpy(tIME_string,png_convert_to_rfc1123(read_ptr, mod_time));
|
png_memcpy(tIME_string,
|
||||||
|
png_convert_to_rfc1123(read_ptr, mod_time),
|
||||||
|
png_sizeof(tIME_string));
|
||||||
|
tIME_string[png_sizeof(tIME_string)-1] = '\0';
|
||||||
tIME_chunk_present++;
|
tIME_chunk_present++;
|
||||||
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
#endif /* PNG_TIME_RFC1123_SUPPORTED */
|
||||||
}
|
}
|
||||||
@@ -1188,7 +1196,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
|||||||
iwidth = png_get_image_width(write_ptr, write_info_ptr);
|
iwidth = png_get_image_width(write_ptr, write_info_ptr);
|
||||||
iheight = png_get_image_height(write_ptr, write_info_ptr);
|
iheight = png_get_image_height(write_ptr, write_info_ptr);
|
||||||
fprintf(STDERR, "Image width = %lu, height = %lu\n",
|
fprintf(STDERR, "Image width = %lu, height = %lu\n",
|
||||||
iwidth, iheight);
|
(unsigned long)iwidth, (unsigned long)iheight);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1312,7 +1320,8 @@ main(int argc, char *argv[])
|
|||||||
fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION);
|
fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION);
|
||||||
fprintf(STDERR,"%s",png_get_copyright(NULL));
|
fprintf(STDERR,"%s",png_get_copyright(NULL));
|
||||||
/* Show the version of libpng used in building the library */
|
/* Show the version of libpng used in building the library */
|
||||||
fprintf(STDERR," library (%lu):%s", png_access_version_number(),
|
fprintf(STDERR," library (%lu):%s",
|
||||||
|
(unsigned long)png_access_version_number(),
|
||||||
png_get_header_version(NULL));
|
png_get_header_version(NULL));
|
||||||
/* Show the version of libpng used in building the application */
|
/* Show the version of libpng used in building the application */
|
||||||
fprintf(STDERR," pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER,
|
fprintf(STDERR," pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER,
|
||||||
@@ -1400,7 +1409,8 @@ main(int argc, char *argv[])
|
|||||||
if (kerror == 0)
|
if (kerror == 0)
|
||||||
{
|
{
|
||||||
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||||
fprintf(STDERR, "\n PASS (%lu zero samples)\n",zero_samples);
|
fprintf(STDERR, "\n PASS (%lu zero samples)\n",
|
||||||
|
(unsigned long)zero_samples);
|
||||||
#else
|
#else
|
||||||
fprintf(STDERR, " PASS\n");
|
fprintf(STDERR, " PASS\n");
|
||||||
#endif
|
#endif
|
||||||
@@ -1408,7 +1418,7 @@ main(int argc, char *argv[])
|
|||||||
for (k=0; k<256; k++)
|
for (k=0; k<256; k++)
|
||||||
if(filters_used[k])
|
if(filters_used[k])
|
||||||
fprintf(STDERR, " Filter %d was used %lu times\n",
|
fprintf(STDERR, " Filter %d was used %lu times\n",
|
||||||
k,filters_used[k]);
|
k,(unsigned long)filters_used[k]);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||||
if(tIME_chunk_present != 0)
|
if(tIME_chunk_present != 0)
|
||||||
@@ -1433,7 +1443,7 @@ main(int argc, char *argv[])
|
|||||||
current_allocation);
|
current_allocation);
|
||||||
while (pinfo != NULL)
|
while (pinfo != NULL)
|
||||||
{
|
{
|
||||||
fprintf(STDERR, " %lu bytes at %x\n", pinfo->size,
|
fprintf(STDERR, " %lu bytes at %x\n", (unsigned long)pinfo->size,
|
||||||
(unsigned int) pinfo->pointer);
|
(unsigned int) pinfo->pointer);
|
||||||
pinfo = pinfo->next;
|
pinfo = pinfo->next;
|
||||||
}
|
}
|
||||||
@@ -1473,7 +1483,8 @@ main(int argc, char *argv[])
|
|||||||
int k;
|
int k;
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||||
fprintf(STDERR, "\n PASS (%lu zero samples)\n",zero_samples);
|
fprintf(STDERR, "\n PASS (%lu zero samples)\n",
|
||||||
|
(unsigned long)zero_samples);
|
||||||
#else
|
#else
|
||||||
fprintf(STDERR, " PASS\n");
|
fprintf(STDERR, " PASS\n");
|
||||||
#endif
|
#endif
|
||||||
@@ -1481,7 +1492,7 @@ main(int argc, char *argv[])
|
|||||||
for (k=0; k<256; k++)
|
for (k=0; k<256; k++)
|
||||||
if(filters_used[k])
|
if(filters_used[k])
|
||||||
fprintf(STDERR, " Filter %d was used %lu times\n",
|
fprintf(STDERR, " Filter %d was used %lu times\n",
|
||||||
k,filters_used[k]);
|
k,(unsigned long)filters_used[k]);
|
||||||
#endif
|
#endif
|
||||||
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||||
if(tIME_chunk_present != 0)
|
if(tIME_chunk_present != 0)
|
||||||
@@ -1509,7 +1520,7 @@ main(int argc, char *argv[])
|
|||||||
while (pinfo != NULL)
|
while (pinfo != NULL)
|
||||||
{
|
{
|
||||||
fprintf(STDERR," %lu bytes at %x\n",
|
fprintf(STDERR," %lu bytes at %x\n",
|
||||||
pinfo->size, (unsigned int)pinfo->pointer);
|
(unsigned long)pinfo->size, (unsigned int)pinfo->pointer);
|
||||||
pinfo = pinfo->next;
|
pinfo = pinfo->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1549,4 +1560,4 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||||
typedef version_1_2_11beta4 your_png_h_is_not_version_1_2_11beta4;
|
typedef version_1_2_29 your_png_h_is_not_version_1_2_29;
|
||||||
|
|||||||
20
pngtrans.c
20
pngtrans.c
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.2.9 April 14, 2006
|
* Last changed in libpng 1.2.17 May 15, 2007
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2007 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*/
|
*/
|
||||||
@@ -18,6 +18,7 @@ void PNGAPI
|
|||||||
png_set_bgr(png_structp png_ptr)
|
png_set_bgr(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_bgr\n");
|
png_debug(1, "in png_set_bgr\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
png_ptr->transformations |= PNG_BGR;
|
png_ptr->transformations |= PNG_BGR;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -28,6 +29,7 @@ void PNGAPI
|
|||||||
png_set_swap(png_structp png_ptr)
|
png_set_swap(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_swap\n");
|
png_debug(1, "in png_set_swap\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
if (png_ptr->bit_depth == 16)
|
if (png_ptr->bit_depth == 16)
|
||||||
png_ptr->transformations |= PNG_SWAP_BYTES;
|
png_ptr->transformations |= PNG_SWAP_BYTES;
|
||||||
}
|
}
|
||||||
@@ -39,6 +41,7 @@ void PNGAPI
|
|||||||
png_set_packing(png_structp png_ptr)
|
png_set_packing(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_packing\n");
|
png_debug(1, "in png_set_packing\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
if (png_ptr->bit_depth < 8)
|
if (png_ptr->bit_depth < 8)
|
||||||
{
|
{
|
||||||
png_ptr->transformations |= PNG_PACK;
|
png_ptr->transformations |= PNG_PACK;
|
||||||
@@ -53,6 +56,7 @@ void PNGAPI
|
|||||||
png_set_packswap(png_structp png_ptr)
|
png_set_packswap(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_packswap\n");
|
png_debug(1, "in png_set_packswap\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
if (png_ptr->bit_depth < 8)
|
if (png_ptr->bit_depth < 8)
|
||||||
png_ptr->transformations |= PNG_PACKSWAP;
|
png_ptr->transformations |= PNG_PACKSWAP;
|
||||||
}
|
}
|
||||||
@@ -63,6 +67,7 @@ void PNGAPI
|
|||||||
png_set_shift(png_structp png_ptr, png_color_8p true_bits)
|
png_set_shift(png_structp png_ptr, png_color_8p true_bits)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_shift\n");
|
png_debug(1, "in png_set_shift\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
png_ptr->transformations |= PNG_SHIFT;
|
png_ptr->transformations |= PNG_SHIFT;
|
||||||
png_ptr->shift = *true_bits;
|
png_ptr->shift = *true_bits;
|
||||||
}
|
}
|
||||||
@@ -74,7 +79,7 @@ int PNGAPI
|
|||||||
png_set_interlace_handling(png_structp png_ptr)
|
png_set_interlace_handling(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_interlace handling\n");
|
png_debug(1, "in png_set_interlace handling\n");
|
||||||
if (png_ptr->interlaced)
|
if (png_ptr && png_ptr->interlaced)
|
||||||
{
|
{
|
||||||
png_ptr->transformations |= PNG_INTERLACE;
|
png_ptr->transformations |= PNG_INTERLACE;
|
||||||
return (7);
|
return (7);
|
||||||
@@ -94,6 +99,7 @@ void PNGAPI
|
|||||||
png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_filler\n");
|
png_debug(1, "in png_set_filler\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
png_ptr->transformations |= PNG_FILLER;
|
png_ptr->transformations |= PNG_FILLER;
|
||||||
png_ptr->filler = (png_byte)filler;
|
png_ptr->filler = (png_byte)filler;
|
||||||
if (filler_loc == PNG_FILLER_AFTER)
|
if (filler_loc == PNG_FILLER_AFTER)
|
||||||
@@ -126,6 +132,7 @@ void PNGAPI
|
|||||||
png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_add_alpha\n");
|
png_debug(1, "in png_set_add_alpha\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
png_set_filler(png_ptr, filler, filler_loc);
|
png_set_filler(png_ptr, filler, filler_loc);
|
||||||
png_ptr->transformations |= PNG_ADD_ALPHA;
|
png_ptr->transformations |= PNG_ADD_ALPHA;
|
||||||
}
|
}
|
||||||
@@ -139,6 +146,7 @@ void PNGAPI
|
|||||||
png_set_swap_alpha(png_structp png_ptr)
|
png_set_swap_alpha(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_swap_alpha\n");
|
png_debug(1, "in png_set_swap_alpha\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
png_ptr->transformations |= PNG_SWAP_ALPHA;
|
png_ptr->transformations |= PNG_SWAP_ALPHA;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -149,6 +157,7 @@ void PNGAPI
|
|||||||
png_set_invert_alpha(png_structp png_ptr)
|
png_set_invert_alpha(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_invert_alpha\n");
|
png_debug(1, "in png_set_invert_alpha\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
png_ptr->transformations |= PNG_INVERT_ALPHA;
|
png_ptr->transformations |= PNG_INVERT_ALPHA;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -158,6 +167,7 @@ void PNGAPI
|
|||||||
png_set_invert_mono(png_structp png_ptr)
|
png_set_invert_mono(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_invert_mono\n");
|
png_debug(1, "in png_set_invert_mono\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
png_ptr->transformations |= PNG_INVERT_MONO;
|
png_ptr->transformations |= PNG_INVERT_MONO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -621,6 +631,7 @@ png_set_user_transform_info(png_structp png_ptr, png_voidp
|
|||||||
user_transform_ptr, int user_transform_depth, int user_transform_channels)
|
user_transform_ptr, int user_transform_depth, int user_transform_channels)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_user_transform_info\n");
|
png_debug(1, "in png_set_user_transform_info\n");
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||||
png_ptr->user_transform_ptr = user_transform_ptr;
|
png_ptr->user_transform_ptr = user_transform_ptr;
|
||||||
png_ptr->user_transform_depth = (png_byte)user_transform_depth;
|
png_ptr->user_transform_depth = (png_byte)user_transform_depth;
|
||||||
@@ -642,10 +653,9 @@ png_voidp PNGAPI
|
|||||||
png_get_user_transform_ptr(png_structp png_ptr)
|
png_get_user_transform_ptr(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||||
|
if (png_ptr == NULL) return (NULL);
|
||||||
return ((png_voidp)png_ptr->user_transform_ptr);
|
return ((png_voidp)png_ptr->user_transform_ptr);
|
||||||
#else
|
#else
|
||||||
if(png_ptr)
|
|
||||||
return (NULL);
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
10
pngwio.c
10
pngwio.c
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
/* pngwio.c - functions for data output
|
/* pngwio.c - functions for data output
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.2.3 - May 21, 2002
|
* Last changed in libpng 1.2.13 November 13, 2006
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998-2002 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*
|
*
|
||||||
@@ -45,6 +45,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||||||
{
|
{
|
||||||
png_uint_32 check;
|
png_uint_32 check;
|
||||||
|
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
#if defined(_WIN32_WCE)
|
#if defined(_WIN32_WCE)
|
||||||
if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
|
if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
|
||||||
check = 0;
|
check = 0;
|
||||||
@@ -70,6 +71,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||||||
png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */
|
png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */
|
||||||
png_FILE_p io_ptr;
|
png_FILE_p io_ptr;
|
||||||
|
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
/* Check if data really is near. If so, use usual code. */
|
/* Check if data really is near. If so, use usual code. */
|
||||||
near_data = (png_byte *)CVT_PTR_NOCHECK(data);
|
near_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_ptr->io_ptr);
|
||||||
@@ -131,6 +133,9 @@ png_default_flush(png_structp png_ptr)
|
|||||||
{
|
{
|
||||||
#if !defined(_WIN32_WCE)
|
#if !defined(_WIN32_WCE)
|
||||||
png_FILE_p io_ptr;
|
png_FILE_p io_ptr;
|
||||||
|
#endif
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
|
#if !defined(_WIN32_WCE)
|
||||||
io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
|
io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
|
||||||
if (io_ptr != NULL)
|
if (io_ptr != NULL)
|
||||||
fflush(io_ptr);
|
fflush(io_ptr);
|
||||||
@@ -165,6 +170,7 @@ void PNGAPI
|
|||||||
png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
|
||||||
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
|
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
|
||||||
{
|
{
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
png_ptr->io_ptr = io_ptr;
|
png_ptr->io_ptr = io_ptr;
|
||||||
|
|
||||||
#if !defined(PNG_NO_STDIO)
|
#if !defined(PNG_NO_STDIO)
|
||||||
|
|||||||
103
pngwrite.c
103
pngwrite.c
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
/* pngwrite.c - general routines to write a PNG file
|
/* pngwrite.c - general routines to write a PNG file
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.2.9 April 14, 2006
|
* Last changed in libpng 1.2.27 [April 29, 2008]
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*/
|
*/
|
||||||
@@ -112,6 +112,8 @@ png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
|
|||||||
((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS ||
|
((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS ||
|
||||||
(png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
|
(png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))
|
||||||
{
|
{
|
||||||
|
if (up->size == 0)
|
||||||
|
png_warning(png_ptr, "Writing zero-length unknown chunk");
|
||||||
png_write_chunk(png_ptr, up->name, up->data, up->size);
|
png_write_chunk(png_ptr, up->name, up->data, up->size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -391,11 +393,6 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
|
|||||||
|
|
||||||
/* write end of PNG file */
|
/* write end of PNG file */
|
||||||
png_write_IEND(png_ptr);
|
png_write_IEND(png_ptr);
|
||||||
#if 0
|
|
||||||
/* This flush, added in libpng-1.0.8, causes some applications to crash
|
|
||||||
because they do not set png_ptr->output_flush_fn */
|
|
||||||
png_flush(png_ptr);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PNG_WRITE_tIME_SUPPORTED)
|
#if defined(PNG_WRITE_tIME_SUPPORTED)
|
||||||
@@ -459,12 +456,6 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
#if !defined(PNG_1_0_X)
|
|
||||||
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
|
|
||||||
png_init_mmx_flags(png_ptr); /* 1.2.0 addition */
|
|
||||||
#endif
|
|
||||||
#endif /* PNG_1_0_X */
|
|
||||||
|
|
||||||
/* added at libpng-1.2.6 */
|
/* added at libpng-1.2.6 */
|
||||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||||
png_ptr->user_width_max=PNG_USER_WIDTH_MAX;
|
png_ptr->user_width_max=PNG_USER_WIDTH_MAX;
|
||||||
@@ -493,12 +484,15 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||||
png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
|
png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
|
||||||
|
|
||||||
i=0;
|
if(user_png_ver)
|
||||||
do
|
|
||||||
{
|
{
|
||||||
if(user_png_ver[i] != png_libpng_ver[i])
|
i=0;
|
||||||
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
do
|
||||||
} while (png_libpng_ver[i++]);
|
{
|
||||||
|
if(user_png_ver[i] != png_libpng_ver[i])
|
||||||
|
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
||||||
|
} while (png_libpng_ver[i++]);
|
||||||
|
}
|
||||||
|
|
||||||
if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
|
if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
|
||||||
{
|
{
|
||||||
@@ -515,11 +509,13 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||||||
char msg[80];
|
char msg[80];
|
||||||
if (user_png_ver)
|
if (user_png_ver)
|
||||||
{
|
{
|
||||||
sprintf(msg, "Application was compiled with png.h from libpng-%.20s",
|
png_snprintf(msg, 80,
|
||||||
|
"Application was compiled with png.h from libpng-%.20s",
|
||||||
user_png_ver);
|
user_png_ver);
|
||||||
png_warning(png_ptr, msg);
|
png_warning(png_ptr, msg);
|
||||||
}
|
}
|
||||||
sprintf(msg, "Application is running with png.c from libpng-%.20s",
|
png_snprintf(msg, 80,
|
||||||
|
"Application is running with png.c from libpng-%.20s",
|
||||||
png_libpng_ver);
|
png_libpng_ver);
|
||||||
png_warning(png_ptr, msg);
|
png_warning(png_ptr, msg);
|
||||||
#endif
|
#endif
|
||||||
@@ -576,6 +572,7 @@ png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver,
|
|||||||
png_size_t png_struct_size, png_size_t png_info_size)
|
png_size_t png_struct_size, png_size_t png_info_size)
|
||||||
{
|
{
|
||||||
/* We only come here via pre-1.0.12-compiled applications */
|
/* We only come here via pre-1.0.12-compiled applications */
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
|
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
|
||||||
if(png_sizeof(png_struct) > png_struct_size ||
|
if(png_sizeof(png_struct) > png_struct_size ||
|
||||||
png_sizeof(png_info) > png_info_size)
|
png_sizeof(png_info) > png_info_size)
|
||||||
@@ -584,11 +581,13 @@ png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver,
|
|||||||
png_ptr->warning_fn=NULL;
|
png_ptr->warning_fn=NULL;
|
||||||
if (user_png_ver)
|
if (user_png_ver)
|
||||||
{
|
{
|
||||||
sprintf(msg, "Application was compiled with png.h from libpng-%.20s",
|
png_snprintf(msg, 80,
|
||||||
|
"Application was compiled with png.h from libpng-%.20s",
|
||||||
user_png_ver);
|
user_png_ver);
|
||||||
png_warning(png_ptr, msg);
|
png_warning(png_ptr, msg);
|
||||||
}
|
}
|
||||||
sprintf(msg, "Application is running with png.c from libpng-%.20s",
|
png_snprintf(msg, 80,
|
||||||
|
"Application is running with png.c from libpng-%.20s",
|
||||||
png_libpng_ver);
|
png_libpng_ver);
|
||||||
png_warning(png_ptr, msg);
|
png_warning(png_ptr, msg);
|
||||||
}
|
}
|
||||||
@@ -668,12 +667,6 @@ png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
|
|||||||
png_ptr->user_height_max=PNG_USER_HEIGHT_MAX;
|
png_ptr->user_height_max=PNG_USER_HEIGHT_MAX;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(PNG_1_0_X)
|
|
||||||
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
|
|
||||||
png_init_mmx_flags(png_ptr); /* 1.2.0 addition */
|
|
||||||
#endif
|
|
||||||
#endif /* PNG_1_0_X */
|
|
||||||
|
|
||||||
#ifdef PNG_SETJMP_SUPPORTED
|
#ifdef PNG_SETJMP_SUPPORTED
|
||||||
/* restore jump buffer */
|
/* restore jump buffer */
|
||||||
png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf));
|
png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf));
|
||||||
@@ -1012,21 +1005,32 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
|
if (png_ptr != NULL)
|
||||||
|
{
|
||||||
|
free_fn = png_ptr->free_fn;
|
||||||
|
mem_ptr = png_ptr->mem_ptr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (info_ptr_ptr != NULL)
|
if (info_ptr_ptr != NULL)
|
||||||
info_ptr = *info_ptr_ptr;
|
info_ptr = *info_ptr_ptr;
|
||||||
|
|
||||||
if (info_ptr != NULL)
|
if (info_ptr != NULL)
|
||||||
{
|
{
|
||||||
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
|
if (png_ptr != NULL)
|
||||||
|
{
|
||||||
|
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
|
||||||
|
|
||||||
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
|
||||||
if (png_ptr->num_chunk_list)
|
if (png_ptr->num_chunk_list)
|
||||||
{
|
{
|
||||||
png_free(png_ptr, png_ptr->chunk_list);
|
png_free(png_ptr, png_ptr->chunk_list);
|
||||||
png_ptr->chunk_list=NULL;
|
png_ptr->chunk_list=NULL;
|
||||||
png_ptr->num_chunk_list=0;
|
png_ptr->num_chunk_list=0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef PNG_USER_MEM_SUPPORTED
|
#ifdef PNG_USER_MEM_SUPPORTED
|
||||||
png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn,
|
png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn,
|
||||||
@@ -1072,11 +1076,13 @@ png_write_destroy(png_structp png_ptr)
|
|||||||
/* free our memory. png_free checks NULL for us. */
|
/* free our memory. png_free checks NULL for us. */
|
||||||
png_free(png_ptr, png_ptr->zbuf);
|
png_free(png_ptr, png_ptr->zbuf);
|
||||||
png_free(png_ptr, png_ptr->row_buf);
|
png_free(png_ptr, png_ptr->row_buf);
|
||||||
|
#ifndef PNG_NO_WRITE_FILTERING
|
||||||
png_free(png_ptr, png_ptr->prev_row);
|
png_free(png_ptr, png_ptr->prev_row);
|
||||||
png_free(png_ptr, png_ptr->sub_row);
|
png_free(png_ptr, png_ptr->sub_row);
|
||||||
png_free(png_ptr, png_ptr->up_row);
|
png_free(png_ptr, png_ptr->up_row);
|
||||||
png_free(png_ptr, png_ptr->avg_row);
|
png_free(png_ptr, png_ptr->avg_row);
|
||||||
png_free(png_ptr, png_ptr->paeth_row);
|
png_free(png_ptr, png_ptr->paeth_row);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
#if defined(PNG_TIME_RFC1123_SUPPORTED)
|
||||||
png_free(png_ptr, png_ptr->time_buffer);
|
png_free(png_ptr, png_ptr->time_buffer);
|
||||||
@@ -1132,15 +1138,26 @@ png_set_filter(png_structp png_ptr, int method, int filters)
|
|||||||
{
|
{
|
||||||
switch (filters & (PNG_ALL_FILTERS | 0x07))
|
switch (filters & (PNG_ALL_FILTERS | 0x07))
|
||||||
{
|
{
|
||||||
|
#ifndef PNG_NO_WRITE_FILTER
|
||||||
case 5:
|
case 5:
|
||||||
case 6:
|
case 6:
|
||||||
case 7: png_warning(png_ptr, "Unknown row filter for method 0");
|
case 7: png_warning(png_ptr, "Unknown row filter for method 0");
|
||||||
case PNG_FILTER_VALUE_NONE: png_ptr->do_filter=PNG_FILTER_NONE; break;
|
#endif /* PNG_NO_WRITE_FILTER */
|
||||||
case PNG_FILTER_VALUE_SUB: png_ptr->do_filter=PNG_FILTER_SUB; break;
|
case PNG_FILTER_VALUE_NONE:
|
||||||
case PNG_FILTER_VALUE_UP: png_ptr->do_filter=PNG_FILTER_UP; break;
|
png_ptr->do_filter=PNG_FILTER_NONE; break;
|
||||||
case PNG_FILTER_VALUE_AVG: png_ptr->do_filter=PNG_FILTER_AVG; break;
|
#ifndef PNG_NO_WRITE_FILTER
|
||||||
case PNG_FILTER_VALUE_PAETH: png_ptr->do_filter=PNG_FILTER_PAETH;break;
|
case PNG_FILTER_VALUE_SUB:
|
||||||
|
png_ptr->do_filter=PNG_FILTER_SUB; break;
|
||||||
|
case PNG_FILTER_VALUE_UP:
|
||||||
|
png_ptr->do_filter=PNG_FILTER_UP; break;
|
||||||
|
case PNG_FILTER_VALUE_AVG:
|
||||||
|
png_ptr->do_filter=PNG_FILTER_AVG; break;
|
||||||
|
case PNG_FILTER_VALUE_PAETH:
|
||||||
|
png_ptr->do_filter=PNG_FILTER_PAETH; break;
|
||||||
default: png_ptr->do_filter = (png_byte)filters; break;
|
default: png_ptr->do_filter = (png_byte)filters; break;
|
||||||
|
#else
|
||||||
|
default: png_warning(png_ptr, "Unknown row filter for method 0");
|
||||||
|
#endif /* PNG_NO_WRITE_FILTER */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we have allocated the row_buf, this means we have already started
|
/* If we have allocated the row_buf, this means we have already started
|
||||||
@@ -1154,6 +1171,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
|
|||||||
*/
|
*/
|
||||||
if (png_ptr->row_buf != NULL)
|
if (png_ptr->row_buf != NULL)
|
||||||
{
|
{
|
||||||
|
#ifndef PNG_NO_WRITE_FILTER
|
||||||
if ((png_ptr->do_filter & PNG_FILTER_SUB) && png_ptr->sub_row == NULL)
|
if ((png_ptr->do_filter & PNG_FILTER_SUB) && png_ptr->sub_row == NULL)
|
||||||
{
|
{
|
||||||
png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,
|
png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,
|
||||||
@@ -1208,6 +1226,7 @@ png_set_filter(png_structp png_ptr, int method, int filters)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (png_ptr->do_filter == PNG_NO_FILTERS)
|
if (png_ptr->do_filter == PNG_NO_FILTERS)
|
||||||
|
#endif /* PNG_NO_WRITE_FILTER */
|
||||||
png_ptr->do_filter = PNG_FILTER_NONE;
|
png_ptr->do_filter = PNG_FILTER_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1506,8 +1525,8 @@ png_write_png(png_structp png_ptr, png_infop info_ptr,
|
|||||||
/* It is REQUIRED to call this to finish writing the rest of the file */
|
/* It is REQUIRED to call this to finish writing the rest of the file */
|
||||||
png_write_end(png_ptr, info_ptr);
|
png_write_end(png_ptr, info_ptr);
|
||||||
|
|
||||||
if(transforms == 0 || params == NULL)
|
transforms = transforms; /* quiet compiler warnings */
|
||||||
/* quiet compiler warnings */ return;
|
params = params;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif /* PNG_WRITE_SUPPORTED */
|
#endif /* PNG_WRITE_SUPPORTED */
|
||||||
|
|||||||
150
pngwutil.c
150
pngwutil.c
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
/* pngwutil.c - utilities to write a PNG file
|
/* pngwutil.c - utilities to write a PNG file
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.2.11 June 4, 2006
|
* Last changed in libpng 1.2.27 [April 29, 2008]
|
||||||
* For conditions of distribution and use, see copyright notice in png.h
|
* For conditions of distribution and use, see copyright notice in png.h
|
||||||
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2008 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
*/
|
*/
|
||||||
@@ -62,6 +62,7 @@ void PNGAPI
|
|||||||
png_write_chunk(png_structp png_ptr, png_bytep chunk_name,
|
png_write_chunk(png_structp png_ptr, png_bytep chunk_name,
|
||||||
png_bytep data, png_size_t length)
|
png_bytep data, png_size_t length)
|
||||||
{
|
{
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
png_write_chunk_start(png_ptr, chunk_name, (png_uint_32)length);
|
png_write_chunk_start(png_ptr, chunk_name, (png_uint_32)length);
|
||||||
png_write_chunk_data(png_ptr, data, length);
|
png_write_chunk_data(png_ptr, data, length);
|
||||||
png_write_chunk_end(png_ptr);
|
png_write_chunk_end(png_ptr);
|
||||||
@@ -77,6 +78,7 @@ png_write_chunk_start(png_structp png_ptr, png_bytep chunk_name,
|
|||||||
{
|
{
|
||||||
png_byte buf[4];
|
png_byte buf[4];
|
||||||
png_debug2(0, "Writing %s chunk (%lu bytes)\n", chunk_name, length);
|
png_debug2(0, "Writing %s chunk (%lu bytes)\n", chunk_name, length);
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
|
|
||||||
/* write the length */
|
/* write the length */
|
||||||
png_save_uint_32(buf, length);
|
png_save_uint_32(buf, length);
|
||||||
@@ -98,6 +100,7 @@ void PNGAPI
|
|||||||
png_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
png_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
{
|
{
|
||||||
/* write the data, and run the CRC over it */
|
/* write the data, and run the CRC over it */
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
if (data != NULL && length > 0)
|
if (data != NULL && length > 0)
|
||||||
{
|
{
|
||||||
png_calculate_crc(png_ptr, data, length);
|
png_calculate_crc(png_ptr, data, length);
|
||||||
@@ -111,6 +114,8 @@ png_write_chunk_end(png_structp png_ptr)
|
|||||||
{
|
{
|
||||||
png_byte buf[4];
|
png_byte buf[4];
|
||||||
|
|
||||||
|
if(png_ptr == NULL) return;
|
||||||
|
|
||||||
/* write the crc */
|
/* write the crc */
|
||||||
png_save_uint_32(buf, png_ptr->crc);
|
png_save_uint_32(buf, png_ptr->crc);
|
||||||
|
|
||||||
@@ -177,7 +182,7 @@ png_text_compress(png_structp png_ptr,
|
|||||||
{
|
{
|
||||||
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
|
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
|
||||||
char msg[50];
|
char msg[50];
|
||||||
sprintf(msg, "Unknown compression type %d", compression);
|
png_snprintf(msg, 50, "Unknown compression type %d", compression);
|
||||||
png_warning(png_ptr, msg);
|
png_warning(png_ptr, msg);
|
||||||
#else
|
#else
|
||||||
png_warning(png_ptr, "Unknown compression type");
|
png_warning(png_ptr, "Unknown compression type");
|
||||||
@@ -375,6 +380,8 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
|
|||||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||||
PNG_IHDR;
|
PNG_IHDR;
|
||||||
#endif
|
#endif
|
||||||
|
int ret;
|
||||||
|
|
||||||
png_byte buf[13]; /* buffer to store the IHDR info */
|
png_byte buf[13]; /* buffer to store the IHDR info */
|
||||||
|
|
||||||
png_debug(1, "in png_write_IHDR\n");
|
png_debug(1, "in png_write_IHDR\n");
|
||||||
@@ -489,7 +496,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
|
|||||||
buf[12] = (png_byte)interlace_type;
|
buf[12] = (png_byte)interlace_type;
|
||||||
|
|
||||||
/* write the chunk */
|
/* write the chunk */
|
||||||
png_write_chunk(png_ptr, (png_bytep)png_IHDR, buf, (png_size_t)13);
|
png_write_chunk(png_ptr, png_IHDR, buf, (png_size_t)13);
|
||||||
|
|
||||||
/* initialize zlib with PNG info */
|
/* initialize zlib with PNG info */
|
||||||
png_ptr->zstream.zalloc = png_zalloc;
|
png_ptr->zstream.zalloc = png_zalloc;
|
||||||
@@ -518,9 +525,19 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
|
|||||||
png_ptr->zlib_window_bits = 15;
|
png_ptr->zlib_window_bits = 15;
|
||||||
if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_METHOD))
|
if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_METHOD))
|
||||||
png_ptr->zlib_method = 8;
|
png_ptr->zlib_method = 8;
|
||||||
deflateInit2(&png_ptr->zstream, png_ptr->zlib_level,
|
ret = deflateInit2(&png_ptr->zstream, png_ptr->zlib_level,
|
||||||
png_ptr->zlib_method, png_ptr->zlib_window_bits,
|
png_ptr->zlib_method, png_ptr->zlib_window_bits,
|
||||||
png_ptr->zlib_mem_level, png_ptr->zlib_strategy);
|
png_ptr->zlib_mem_level, png_ptr->zlib_strategy);
|
||||||
|
if (ret != Z_OK)
|
||||||
|
{
|
||||||
|
if (ret == Z_VERSION_ERROR) png_error(png_ptr,
|
||||||
|
"zlib failed to initialize compressor -- version error");
|
||||||
|
if (ret == Z_STREAM_ERROR) png_error(png_ptr,
|
||||||
|
"zlib failed to initialize compressor -- stream error");
|
||||||
|
if (ret == Z_MEM_ERROR) png_error(png_ptr,
|
||||||
|
"zlib failed to initialize compressor -- mem error");
|
||||||
|
png_error(png_ptr, "zlib failed to initialize compressor");
|
||||||
|
}
|
||||||
png_ptr->zstream.next_out = png_ptr->zbuf;
|
png_ptr->zstream.next_out = png_ptr->zbuf;
|
||||||
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
|
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
|
||||||
/* libpng is not interested in zstream.data_type */
|
/* libpng is not interested in zstream.data_type */
|
||||||
@@ -572,7 +589,7 @@ png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal)
|
|||||||
png_ptr->num_palette = (png_uint_16)num_pal;
|
png_ptr->num_palette = (png_uint_16)num_pal;
|
||||||
png_debug1(3, "num_palette = %d\n", png_ptr->num_palette);
|
png_debug1(3, "num_palette = %d\n", png_ptr->num_palette);
|
||||||
|
|
||||||
png_write_chunk_start(png_ptr, (png_bytep)png_PLTE, num_pal * 3);
|
png_write_chunk_start(png_ptr, png_PLTE, num_pal * 3);
|
||||||
#ifndef PNG_NO_POINTER_INDEXING
|
#ifndef PNG_NO_POINTER_INDEXING
|
||||||
for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++)
|
for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++)
|
||||||
{
|
{
|
||||||
@@ -644,7 +661,7 @@ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||||||
"Invalid zlib compression method or flags in IDAT");
|
"Invalid zlib compression method or flags in IDAT");
|
||||||
}
|
}
|
||||||
|
|
||||||
png_write_chunk(png_ptr, (png_bytep)png_IDAT, data, length);
|
png_write_chunk(png_ptr, png_IDAT, data, length);
|
||||||
png_ptr->mode |= PNG_HAVE_IDAT;
|
png_ptr->mode |= PNG_HAVE_IDAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -656,7 +673,7 @@ png_write_IEND(png_structp png_ptr)
|
|||||||
PNG_IEND;
|
PNG_IEND;
|
||||||
#endif
|
#endif
|
||||||
png_debug(1, "in png_write_IEND\n");
|
png_debug(1, "in png_write_IEND\n");
|
||||||
png_write_chunk(png_ptr, (png_bytep)png_IEND, png_bytep_NULL,
|
png_write_chunk(png_ptr, png_IEND, png_bytep_NULL,
|
||||||
(png_size_t)0);
|
(png_size_t)0);
|
||||||
png_ptr->mode |= PNG_HAVE_IEND;
|
png_ptr->mode |= PNG_HAVE_IEND;
|
||||||
}
|
}
|
||||||
@@ -677,7 +694,7 @@ png_write_gAMA(png_structp png_ptr, double file_gamma)
|
|||||||
/* file_gamma is saved in 1/100,000ths */
|
/* file_gamma is saved in 1/100,000ths */
|
||||||
igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5);
|
igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5);
|
||||||
png_save_uint_32(buf, igamma);
|
png_save_uint_32(buf, igamma);
|
||||||
png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4);
|
png_write_chunk(png_ptr, png_gAMA, buf, (png_size_t)4);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||||
@@ -692,7 +709,7 @@ png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma)
|
|||||||
png_debug(1, "in png_write_gAMA\n");
|
png_debug(1, "in png_write_gAMA\n");
|
||||||
/* file_gamma is saved in 1/100,000ths */
|
/* file_gamma is saved in 1/100,000ths */
|
||||||
png_save_uint_32(buf, (png_uint_32)file_gamma);
|
png_save_uint_32(buf, (png_uint_32)file_gamma);
|
||||||
png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4);
|
png_write_chunk(png_ptr, png_gAMA, buf, (png_size_t)4);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@@ -712,7 +729,7 @@ png_write_sRGB(png_structp png_ptr, int srgb_intent)
|
|||||||
png_warning(png_ptr,
|
png_warning(png_ptr,
|
||||||
"Invalid sRGB rendering intent specified");
|
"Invalid sRGB rendering intent specified");
|
||||||
buf[0]=(png_byte)srgb_intent;
|
buf[0]=(png_byte)srgb_intent;
|
||||||
png_write_chunk(png_ptr, (png_bytep)png_sRGB, buf, (png_size_t)1);
|
png_write_chunk(png_ptr, png_sRGB, buf, (png_size_t)1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -728,6 +745,7 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
|
|||||||
png_size_t name_len;
|
png_size_t name_len;
|
||||||
png_charp new_name;
|
png_charp new_name;
|
||||||
compression_state comp;
|
compression_state comp;
|
||||||
|
int embedded_profile_len = 0;
|
||||||
|
|
||||||
png_debug(1, "in png_write_iCCP\n");
|
png_debug(1, "in png_write_iCCP\n");
|
||||||
|
|
||||||
@@ -750,12 +768,33 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
|
|||||||
if (profile == NULL)
|
if (profile == NULL)
|
||||||
profile_len = 0;
|
profile_len = 0;
|
||||||
|
|
||||||
|
if (profile_len > 3)
|
||||||
|
embedded_profile_len =
|
||||||
|
((*( (png_bytep)profile ))<<24) |
|
||||||
|
((*( (png_bytep)profile+1))<<16) |
|
||||||
|
((*( (png_bytep)profile+2))<< 8) |
|
||||||
|
((*( (png_bytep)profile+3)) );
|
||||||
|
|
||||||
|
if (profile_len < embedded_profile_len)
|
||||||
|
{
|
||||||
|
png_warning(png_ptr,
|
||||||
|
"Embedded profile length too large in iCCP chunk");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (profile_len > embedded_profile_len)
|
||||||
|
{
|
||||||
|
png_warning(png_ptr,
|
||||||
|
"Truncating profile to actual length in iCCP chunk");
|
||||||
|
profile_len = embedded_profile_len;
|
||||||
|
}
|
||||||
|
|
||||||
if (profile_len)
|
if (profile_len)
|
||||||
profile_len = png_text_compress(png_ptr, profile, (png_size_t)profile_len,
|
profile_len = png_text_compress(png_ptr, profile, (png_size_t)profile_len,
|
||||||
PNG_COMPRESSION_TYPE_BASE, &comp);
|
PNG_COMPRESSION_TYPE_BASE, &comp);
|
||||||
|
|
||||||
/* make sure we include the NULL after the name and the compression type */
|
/* make sure we include the NULL after the name and the compression type */
|
||||||
png_write_chunk_start(png_ptr, (png_bytep)png_iCCP,
|
png_write_chunk_start(png_ptr, png_iCCP,
|
||||||
(png_uint_32)name_len+profile_len+2);
|
(png_uint_32)name_len+profile_len+2);
|
||||||
new_name[name_len+1]=0x00;
|
new_name[name_len+1]=0x00;
|
||||||
png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 2);
|
png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 2);
|
||||||
@@ -795,7 +834,7 @@ png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* make sure we include the NULL after the name */
|
/* make sure we include the NULL after the name */
|
||||||
png_write_chunk_start(png_ptr, (png_bytep)png_sPLT,
|
png_write_chunk_start(png_ptr, png_sPLT,
|
||||||
(png_uint_32)(name_len + 2 + palette_size));
|
(png_uint_32)(name_len + 2 + palette_size));
|
||||||
png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 1);
|
png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 1);
|
||||||
png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, 1);
|
png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, 1);
|
||||||
@@ -903,7 +942,7 @@ png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type)
|
|||||||
buf[size++] = sbit->alpha;
|
buf[size++] = sbit->alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
png_write_chunk(png_ptr, (png_bytep)png_sBIT, buf, size);
|
png_write_chunk(png_ptr, png_sBIT, buf, size);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -967,7 +1006,7 @@ png_write_cHRM(png_structp png_ptr, double white_x, double white_y,
|
|||||||
itemp = (png_uint_32)(blue_y * 100000.0 + 0.5);
|
itemp = (png_uint_32)(blue_y * 100000.0 + 0.5);
|
||||||
png_save_uint_32(buf + 28, itemp);
|
png_save_uint_32(buf + 28, itemp);
|
||||||
|
|
||||||
png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32);
|
png_write_chunk(png_ptr, png_cHRM, buf, (png_size_t)32);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||||
@@ -1019,7 +1058,7 @@ png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x,
|
|||||||
png_save_uint_32(buf + 24, (png_uint_32)blue_x);
|
png_save_uint_32(buf + 24, (png_uint_32)blue_x);
|
||||||
png_save_uint_32(buf + 28, (png_uint_32)blue_y);
|
png_save_uint_32(buf + 28, (png_uint_32)blue_y);
|
||||||
|
|
||||||
png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32);
|
png_write_chunk(png_ptr, png_cHRM, buf, (png_size_t)32);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@@ -1044,7 +1083,7 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* write the chunk out as it is */
|
/* write the chunk out as it is */
|
||||||
png_write_chunk(png_ptr, (png_bytep)png_tRNS, trans, (png_size_t)num_trans);
|
png_write_chunk(png_ptr, png_tRNS, trans, (png_size_t)num_trans);
|
||||||
}
|
}
|
||||||
else if (color_type == PNG_COLOR_TYPE_GRAY)
|
else if (color_type == PNG_COLOR_TYPE_GRAY)
|
||||||
{
|
{
|
||||||
@@ -1056,7 +1095,7 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
png_save_uint_16(buf, tran->gray);
|
png_save_uint_16(buf, tran->gray);
|
||||||
png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)2);
|
png_write_chunk(png_ptr, png_tRNS, buf, (png_size_t)2);
|
||||||
}
|
}
|
||||||
else if (color_type == PNG_COLOR_TYPE_RGB)
|
else if (color_type == PNG_COLOR_TYPE_RGB)
|
||||||
{
|
{
|
||||||
@@ -1070,7 +1109,7 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,
|
|||||||
"Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8");
|
"Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)6);
|
png_write_chunk(png_ptr, png_tRNS, buf, (png_size_t)6);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1103,7 +1142,7 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
buf[0] = back->index;
|
buf[0] = back->index;
|
||||||
png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)1);
|
png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)1);
|
||||||
}
|
}
|
||||||
else if (color_type & PNG_COLOR_MASK_COLOR)
|
else if (color_type & PNG_COLOR_MASK_COLOR)
|
||||||
{
|
{
|
||||||
@@ -1116,7 +1155,7 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
|
|||||||
"Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8");
|
"Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)6);
|
png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)6);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1127,7 +1166,7 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
png_save_uint_16(buf, back->gray);
|
png_save_uint_16(buf, back->gray);
|
||||||
png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)2);
|
png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1152,7 +1191,7 @@ png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
png_write_chunk_start(png_ptr, (png_bytep)png_hIST, (png_uint_32)(num_hist * 2));
|
png_write_chunk_start(png_ptr, png_hIST, (png_uint_32)(num_hist * 2));
|
||||||
for (i = 0; i < num_hist; i++)
|
for (i = 0; i < num_hist; i++)
|
||||||
{
|
{
|
||||||
png_save_uint_16(buf, hist[i]);
|
png_save_uint_16(buf, hist[i]);
|
||||||
@@ -1203,12 +1242,14 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
|||||||
/* Replace non-printing characters with a blank and print a warning */
|
/* Replace non-printing characters with a blank and print a warning */
|
||||||
for (kp = key, dp = *new_key; *kp != '\0'; kp++, dp++)
|
for (kp = key, dp = *new_key; *kp != '\0'; kp++, dp++)
|
||||||
{
|
{
|
||||||
if (*kp < 0x20 || (*kp > 0x7E && (png_byte)*kp < 0xA1))
|
if ((png_byte)*kp < 0x20 ||
|
||||||
|
((png_byte)*kp > 0x7E && (png_byte)*kp < 0xA1))
|
||||||
{
|
{
|
||||||
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
|
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
|
||||||
char msg[40];
|
char msg[40];
|
||||||
|
|
||||||
sprintf(msg, "invalid keyword character 0x%02X", *kp);
|
png_snprintf(msg, 40,
|
||||||
|
"invalid keyword character 0x%02X", (png_byte)*kp);
|
||||||
png_warning(png_ptr, msg);
|
png_warning(png_ptr, msg);
|
||||||
#else
|
#else
|
||||||
png_warning(png_ptr, "invalid character in keyword");
|
png_warning(png_ptr, "invalid character in keyword");
|
||||||
@@ -1316,7 +1357,7 @@ png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text,
|
|||||||
text_len = png_strlen(text);
|
text_len = png_strlen(text);
|
||||||
|
|
||||||
/* make sure we include the 0 after the key */
|
/* make sure we include the 0 after the key */
|
||||||
png_write_chunk_start(png_ptr, (png_bytep)png_tEXt, (png_uint_32)key_len+text_len+1);
|
png_write_chunk_start(png_ptr, png_tEXt, (png_uint_32)key_len+text_len+1);
|
||||||
/*
|
/*
|
||||||
* We leave it to the application to meet PNG-1.0 requirements on the
|
* We leave it to the application to meet PNG-1.0 requirements on the
|
||||||
* contents of the text. PNG-1.0 through PNG-1.2 discourage the use of
|
* contents of the text. PNG-1.0 through PNG-1.2 discourage the use of
|
||||||
@@ -1369,17 +1410,17 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
|
|||||||
|
|
||||||
text_len = png_strlen(text);
|
text_len = png_strlen(text);
|
||||||
|
|
||||||
png_free(png_ptr, new_key);
|
|
||||||
|
|
||||||
/* compute the compressed data; do it now for the length */
|
/* compute the compressed data; do it now for the length */
|
||||||
text_len = png_text_compress(png_ptr, text, text_len, compression,
|
text_len = png_text_compress(png_ptr, text, text_len, compression,
|
||||||
&comp);
|
&comp);
|
||||||
|
|
||||||
/* write start of chunk */
|
/* write start of chunk */
|
||||||
png_write_chunk_start(png_ptr, (png_bytep)png_zTXt, (png_uint_32)
|
png_write_chunk_start(png_ptr, png_zTXt, (png_uint_32)
|
||||||
(key_len+text_len+2));
|
(key_len+text_len+2));
|
||||||
/* write key */
|
/* write key */
|
||||||
png_write_chunk_data(png_ptr, (png_bytep)key, key_len + 1);
|
png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1);
|
||||||
|
png_free(png_ptr, new_key);
|
||||||
|
|
||||||
buf[0] = (png_byte)compression;
|
buf[0] = (png_byte)compression;
|
||||||
/* write compression */
|
/* write compression */
|
||||||
png_write_chunk_data(png_ptr, (png_bytep)buf, (png_size_t)1);
|
png_write_chunk_data(png_ptr, (png_bytep)buf, (png_size_t)1);
|
||||||
@@ -1442,7 +1483,7 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
|
|||||||
/* make sure we include the compression flag, the compression byte,
|
/* make sure we include the compression flag, the compression byte,
|
||||||
* and the NULs after the key, lang, and lang_key parts */
|
* and the NULs after the key, lang, and lang_key parts */
|
||||||
|
|
||||||
png_write_chunk_start(png_ptr, (png_bytep)png_iTXt,
|
png_write_chunk_start(png_ptr, png_iTXt,
|
||||||
(png_uint_32)(
|
(png_uint_32)(
|
||||||
5 /* comp byte, comp flag, terminators for key, lang and lang_key */
|
5 /* comp byte, comp flag, terminators for key, lang and lang_key */
|
||||||
+ key_len
|
+ key_len
|
||||||
@@ -1475,8 +1516,7 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key,
|
|||||||
|
|
||||||
png_write_chunk_end(png_ptr);
|
png_write_chunk_end(png_ptr);
|
||||||
png_free(png_ptr, new_key);
|
png_free(png_ptr, new_key);
|
||||||
if (new_lang)
|
png_free(png_ptr, new_lang);
|
||||||
png_free(png_ptr, new_lang);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1499,10 +1539,9 @@ png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset,
|
|||||||
png_save_int_32(buf + 4, y_offset);
|
png_save_int_32(buf + 4, y_offset);
|
||||||
buf[8] = (png_byte)unit_type;
|
buf[8] = (png_byte)unit_type;
|
||||||
|
|
||||||
png_write_chunk(png_ptr, (png_bytep)png_oFFs, buf, (png_size_t)9);
|
png_write_chunk(png_ptr, png_oFFs, buf, (png_size_t)9);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_WRITE_pCAL_SUPPORTED)
|
#if defined(PNG_WRITE_pCAL_SUPPORTED)
|
||||||
/* write the pCAL chunk (described in the PNG extensions document) */
|
/* write the pCAL chunk (described in the PNG extensions document) */
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
@@ -1541,7 +1580,7 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
|
|||||||
}
|
}
|
||||||
|
|
||||||
png_debug1(3, "pCAL total length = %d\n", (int)total_len);
|
png_debug1(3, "pCAL total length = %d\n", (int)total_len);
|
||||||
png_write_chunk_start(png_ptr, (png_bytep)png_pCAL, (png_uint_32)total_len);
|
png_write_chunk_start(png_ptr, png_pCAL, (png_uint_32)total_len);
|
||||||
png_write_chunk_data(png_ptr, (png_bytep)new_purpose, purpose_len);
|
png_write_chunk_data(png_ptr, (png_bytep)new_purpose, purpose_len);
|
||||||
png_save_int_32(buf, X0);
|
png_save_int_32(buf, X0);
|
||||||
png_save_int_32(buf + 4, X1);
|
png_save_int_32(buf + 4, X1);
|
||||||
@@ -1594,14 +1633,14 @@ png_write_sCAL(png_structp png_ptr, int unit, double width, double height)
|
|||||||
total_len += wc_len;
|
total_len += wc_len;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
sprintf(buf + 1, "%12.12e", width);
|
png_snprintf(buf + 1, 63, "%12.12e", width);
|
||||||
total_len = 1 + png_strlen(buf + 1) + 1;
|
total_len = 1 + png_strlen(buf + 1) + 1;
|
||||||
sprintf(buf + total_len, "%12.12e", height);
|
png_snprintf(buf + total_len, 64-total_len, "%12.12e", height);
|
||||||
total_len += png_strlen(buf + total_len);
|
total_len += png_strlen(buf + total_len);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len);
|
png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len);
|
||||||
png_write_chunk(png_ptr, (png_bytep)png_sCAL, (png_bytep)buf, total_len);
|
png_write_chunk(png_ptr, png_sCAL, (png_bytep)buf, total_len);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||||
@@ -1631,7 +1670,7 @@ png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width,
|
|||||||
png_memcpy(buf + wlen + 2, height, hlen); /* do NOT append the '\0' here */
|
png_memcpy(buf + wlen + 2, height, hlen); /* do NOT append the '\0' here */
|
||||||
|
|
||||||
png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len);
|
png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len);
|
||||||
png_write_chunk(png_ptr, (png_bytep)png_sCAL, buf, total_len);
|
png_write_chunk(png_ptr, png_sCAL, buf, total_len);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@@ -1657,7 +1696,7 @@ png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit,
|
|||||||
png_save_uint_32(buf + 4, y_pixels_per_unit);
|
png_save_uint_32(buf + 4, y_pixels_per_unit);
|
||||||
buf[8] = (png_byte)unit_type;
|
buf[8] = (png_byte)unit_type;
|
||||||
|
|
||||||
png_write_chunk(png_ptr, (png_bytep)png_pHYs, buf, (png_size_t)9);
|
png_write_chunk(png_ptr, png_pHYs, buf, (png_size_t)9);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1689,7 +1728,7 @@ png_write_tIME(png_structp png_ptr, png_timep mod_time)
|
|||||||
buf[5] = mod_time->minute;
|
buf[5] = mod_time->minute;
|
||||||
buf[6] = mod_time->second;
|
buf[6] = mod_time->second;
|
||||||
|
|
||||||
png_write_chunk(png_ptr, (png_bytep)png_tIME, buf, (png_size_t)7);
|
png_write_chunk(png_ptr, png_tIME, buf, (png_size_t)7);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1697,6 +1736,7 @@ png_write_tIME(png_structp png_ptr, png_timep mod_time)
|
|||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_write_start_row(png_structp png_ptr)
|
png_write_start_row(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
|
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||||
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||||
|
|
||||||
@@ -1711,6 +1751,7 @@ png_write_start_row(png_structp png_ptr)
|
|||||||
|
|
||||||
/* offset to next interlace block in the y direction */
|
/* offset to next interlace block in the y direction */
|
||||||
int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
png_size_t buf_size;
|
png_size_t buf_size;
|
||||||
@@ -1723,6 +1764,7 @@ png_write_start_row(png_structp png_ptr)
|
|||||||
png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size);
|
png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size);
|
||||||
png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE;
|
png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE;
|
||||||
|
|
||||||
|
#ifndef PNG_NO_WRITE_FILTERING
|
||||||
/* set up filtering buffer, if using this filter */
|
/* set up filtering buffer, if using this filter */
|
||||||
if (png_ptr->do_filter & PNG_FILTER_SUB)
|
if (png_ptr->do_filter & PNG_FILTER_SUB)
|
||||||
{
|
{
|
||||||
@@ -1740,7 +1782,7 @@ png_write_start_row(png_structp png_ptr)
|
|||||||
|
|
||||||
if (png_ptr->do_filter & PNG_FILTER_UP)
|
if (png_ptr->do_filter & PNG_FILTER_UP)
|
||||||
{
|
{
|
||||||
png_ptr->up_row = (png_bytep )png_malloc(png_ptr,
|
png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
|
||||||
(png_ptr->rowbytes + 1));
|
(png_ptr->rowbytes + 1));
|
||||||
png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
|
png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
|
||||||
}
|
}
|
||||||
@@ -1754,10 +1796,11 @@ png_write_start_row(png_structp png_ptr)
|
|||||||
|
|
||||||
if (png_ptr->do_filter & PNG_FILTER_PAETH)
|
if (png_ptr->do_filter & PNG_FILTER_PAETH)
|
||||||
{
|
{
|
||||||
png_ptr->paeth_row = (png_bytep )png_malloc(png_ptr,
|
png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,
|
||||||
(png_ptr->rowbytes + 1));
|
(png_ptr->rowbytes + 1));
|
||||||
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
|
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
|
||||||
}
|
}
|
||||||
|
#endif /* PNG_NO_WRITE_FILTERING */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||||
@@ -1791,6 +1834,7 @@ png_write_start_row(png_structp png_ptr)
|
|||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_write_finish_row(png_structp png_ptr)
|
png_write_finish_row(png_structp png_ptr)
|
||||||
{
|
{
|
||||||
|
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||||
#ifdef PNG_USE_LOCAL_ARRAYS
|
#ifdef PNG_USE_LOCAL_ARRAYS
|
||||||
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||||
|
|
||||||
@@ -1805,6 +1849,7 @@ png_write_finish_row(png_structp png_ptr)
|
|||||||
|
|
||||||
/* offset to next interlace block in the y direction */
|
/* offset to next interlace block in the y direction */
|
||||||
int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
@@ -2079,7 +2124,9 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
|
|||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
||||||
{
|
{
|
||||||
png_bytep prev_row, best_row, row_buf;
|
png_bytep best_row;
|
||||||
|
#ifndef PNG_NO_WRITE_FILTER
|
||||||
|
png_bytep prev_row, row_buf;
|
||||||
png_uint_32 mins, bpp;
|
png_uint_32 mins, bpp;
|
||||||
png_byte filter_to_do = png_ptr->do_filter;
|
png_byte filter_to_do = png_ptr->do_filter;
|
||||||
png_uint_32 row_bytes = row_info->rowbytes;
|
png_uint_32 row_bytes = row_info->rowbytes;
|
||||||
@@ -2092,7 +2139,10 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
|||||||
bpp = (row_info->pixel_depth + 7) >> 3;
|
bpp = (row_info->pixel_depth + 7) >> 3;
|
||||||
|
|
||||||
prev_row = png_ptr->prev_row;
|
prev_row = png_ptr->prev_row;
|
||||||
best_row = row_buf = png_ptr->row_buf;
|
#endif
|
||||||
|
best_row = png_ptr->row_buf;
|
||||||
|
#ifndef PNG_NO_WRITE_FILTER
|
||||||
|
row_buf = best_row;
|
||||||
mins = PNG_MAXSUM;
|
mins = PNG_MAXSUM;
|
||||||
|
|
||||||
/* The prediction method we use is to find which method provides the
|
/* The prediction method we use is to find which method provides the
|
||||||
@@ -2667,11 +2717,12 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
|||||||
best_row = png_ptr->paeth_row;
|
best_row = png_ptr->paeth_row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* PNG_NO_WRITE_FILTER */
|
||||||
/* Do the actual writing of the filtered row data from the chosen filter. */
|
/* Do the actual writing of the filtered row data from the chosen filter. */
|
||||||
|
|
||||||
png_write_filtered_row(png_ptr, best_row);
|
png_write_filtered_row(png_ptr, best_row);
|
||||||
|
|
||||||
|
#ifndef PNG_NO_WRITE_FILTER
|
||||||
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
|
||||||
/* Save the type of filter we picked this time for future calculations */
|
/* Save the type of filter we picked this time for future calculations */
|
||||||
if (png_ptr->num_prev_filters > 0)
|
if (png_ptr->num_prev_filters > 0)
|
||||||
@@ -2684,6 +2735,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
|
|||||||
png_ptr->prev_filters[j] = best_row[0];
|
png_ptr->prev_filters[j] = best_row[0];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif /* PNG_NO_WRITE_FILTER */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
54
trees.c
54
trees.c
@@ -1,5 +1,6 @@
|
|||||||
/* trees.c -- output deflated data using Huffman coding
|
/* trees.c -- output deflated data using Huffman coding
|
||||||
* Copyright (C) 1995-2005 Jean-loup Gailly
|
* Copyright (C) 1995-2006 Jean-loup Gailly
|
||||||
|
* detect_data_type() function provided freely by Cosmin Truta, 2006
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -152,7 +153,7 @@ local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
|
|||||||
int blcodes));
|
int blcodes));
|
||||||
local void compress_block OF((deflate_state *s, ct_data *ltree,
|
local void compress_block OF((deflate_state *s, ct_data *ltree,
|
||||||
ct_data *dtree));
|
ct_data *dtree));
|
||||||
local void set_data_type OF((deflate_state *s));
|
local int detect_data_type OF((deflate_state *s));
|
||||||
local unsigned bi_reverse OF((unsigned value, int length));
|
local unsigned bi_reverse OF((unsigned value, int length));
|
||||||
local void bi_windup OF((deflate_state *s));
|
local void bi_windup OF((deflate_state *s));
|
||||||
local void bi_flush OF((deflate_state *s));
|
local void bi_flush OF((deflate_state *s));
|
||||||
@@ -250,11 +251,13 @@ local void tr_static_init()
|
|||||||
if (static_init_done) return;
|
if (static_init_done) return;
|
||||||
|
|
||||||
/* For some embedded targets, global variables are not initialized: */
|
/* For some embedded targets, global variables are not initialized: */
|
||||||
|
#ifdef NO_INIT_GLOBAL_POINTERS
|
||||||
static_l_desc.static_tree = static_ltree;
|
static_l_desc.static_tree = static_ltree;
|
||||||
static_l_desc.extra_bits = extra_lbits;
|
static_l_desc.extra_bits = extra_lbits;
|
||||||
static_d_desc.static_tree = static_dtree;
|
static_d_desc.static_tree = static_dtree;
|
||||||
static_d_desc.extra_bits = extra_dbits;
|
static_d_desc.extra_bits = extra_dbits;
|
||||||
static_bl_desc.extra_bits = extra_blbits;
|
static_bl_desc.extra_bits = extra_blbits;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Initialize the mapping length (0..255) -> length code (0..28) */
|
/* Initialize the mapping length (0..255) -> length code (0..28) */
|
||||||
length = 0;
|
length = 0;
|
||||||
@@ -931,8 +934,8 @@ void _tr_flush_block(s, buf, stored_len, eof)
|
|||||||
if (s->level > 0) {
|
if (s->level > 0) {
|
||||||
|
|
||||||
/* Check if the file is binary or text */
|
/* Check if the file is binary or text */
|
||||||
if (stored_len > 0 && s->strm->data_type == Z_UNKNOWN)
|
if (s->strm->data_type == Z_UNKNOWN)
|
||||||
set_data_type(s);
|
s->strm->data_type = detect_data_type(s);
|
||||||
|
|
||||||
/* Construct the literal and distance trees */
|
/* Construct the literal and distance trees */
|
||||||
build_tree(s, (tree_desc *)(&(s->l_desc)));
|
build_tree(s, (tree_desc *)(&(s->l_desc)));
|
||||||
@@ -1118,24 +1121,45 @@ local void compress_block(s, ltree, dtree)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Set the data type to BINARY or TEXT, using a crude approximation:
|
* Check if the data type is TEXT or BINARY, using the following algorithm:
|
||||||
* set it to Z_TEXT if all symbols are either printable characters (33 to 255)
|
* - TEXT if the two conditions below are satisfied:
|
||||||
* or white spaces (9 to 13, or 32); or set it to Z_BINARY otherwise.
|
* a) There are no non-portable control characters belonging to the
|
||||||
|
* "black list" (0..6, 14..25, 28..31).
|
||||||
|
* b) There is at least one printable character belonging to the
|
||||||
|
* "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
|
||||||
|
* - BINARY otherwise.
|
||||||
|
* - The following partially-portable control characters form a
|
||||||
|
* "gray list" that is ignored in this detection algorithm:
|
||||||
|
* (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
|
||||||
* IN assertion: the fields Freq of dyn_ltree are set.
|
* IN assertion: the fields Freq of dyn_ltree are set.
|
||||||
*/
|
*/
|
||||||
local void set_data_type(s)
|
local int detect_data_type(s)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
{
|
{
|
||||||
|
/* black_mask is the bit mask of black-listed bytes
|
||||||
|
* set bits 0..6, 14..25, and 28..31
|
||||||
|
* 0xf3ffc07f = binary 11110011111111111100000001111111
|
||||||
|
*/
|
||||||
|
unsigned long black_mask = 0xf3ffc07fUL;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
for (n = 0; n < 9; n++)
|
/* Check for non-textual ("black-listed") bytes. */
|
||||||
|
for (n = 0; n <= 31; n++, black_mask >>= 1)
|
||||||
|
if ((black_mask & 1) && (s->dyn_ltree[n].Freq != 0))
|
||||||
|
return Z_BINARY;
|
||||||
|
|
||||||
|
/* Check for textual ("white-listed") bytes. */
|
||||||
|
if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0
|
||||||
|
|| s->dyn_ltree[13].Freq != 0)
|
||||||
|
return Z_TEXT;
|
||||||
|
for (n = 32; n < LITERALS; n++)
|
||||||
if (s->dyn_ltree[n].Freq != 0)
|
if (s->dyn_ltree[n].Freq != 0)
|
||||||
break;
|
return Z_TEXT;
|
||||||
if (n == 9)
|
|
||||||
for (n = 14; n < 32; n++)
|
/* There are no "black-listed" or "white-listed" bytes:
|
||||||
if (s->dyn_ltree[n].Freq != 0)
|
* this stream either is empty or has tolerated ("gray-listed") bytes only.
|
||||||
break;
|
*/
|
||||||
s->strm->data_type = (n == 32) ? Z_TEXT : Z_BINARY;
|
return Z_BINARY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
|
|||||||
144
zconf.h
144
zconf.h
@@ -1,5 +1,5 @@
|
|||||||
/* zconf.h -- configuration of the zlib compression library
|
/* zconf.h -- configuration of the zlib compression library
|
||||||
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
* Copyright (C) 1995-2006 Jean-loup Gailly.
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -11,52 +11,115 @@
|
|||||||
/*
|
/*
|
||||||
* If you *really* need a unique prefix for all types and library functions,
|
* If you *really* need a unique prefix for all types and library functions,
|
||||||
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
|
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
|
||||||
|
* Even better than compiling with -DZ_PREFIX would be to use configure to set
|
||||||
|
* this permanently in zconf.h using "./configure --zprefix".
|
||||||
*/
|
*/
|
||||||
#ifdef Z_PREFIX
|
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
|
||||||
# define deflateInit_ z_deflateInit_
|
|
||||||
# define deflate z_deflate
|
/* all linked symbols */
|
||||||
# define deflateEnd z_deflateEnd
|
# define _dist_code z__dist_code
|
||||||
# define inflateInit_ z_inflateInit_
|
# define _length_code z__length_code
|
||||||
# define inflate z_inflate
|
# define _tr_align z__tr_align
|
||||||
# define inflateEnd z_inflateEnd
|
# define _tr_flush_block z__tr_flush_block
|
||||||
# define deflateInit2_ z_deflateInit2_
|
# define _tr_init z__tr_init
|
||||||
# define deflateSetDictionary z_deflateSetDictionary
|
# define _tr_stored_block z__tr_stored_block
|
||||||
# define deflateCopy z_deflateCopy
|
# define _tr_tally z__tr_tally
|
||||||
# define deflateReset z_deflateReset
|
# define adler32 z_adler32
|
||||||
# define deflateParams z_deflateParams
|
# define adler32_combine z_adler32_combine
|
||||||
# define deflateBound z_deflateBound
|
|
||||||
# define deflatePrime z_deflatePrime
|
|
||||||
# define inflateInit2_ z_inflateInit2_
|
|
||||||
# define inflateSetDictionary z_inflateSetDictionary
|
|
||||||
# define inflateSync z_inflateSync
|
|
||||||
# define inflateSyncPoint z_inflateSyncPoint
|
|
||||||
# define inflateCopy z_inflateCopy
|
|
||||||
# define inflateReset z_inflateReset
|
|
||||||
# define inflateBack z_inflateBack
|
|
||||||
# define inflateBackEnd z_inflateBackEnd
|
|
||||||
# define compress z_compress
|
# define compress z_compress
|
||||||
# define compress2 z_compress2
|
# define compress2 z_compress2
|
||||||
# define compressBound z_compressBound
|
# define compressBound z_compressBound
|
||||||
# define uncompress z_uncompress
|
|
||||||
# define adler32 z_adler32
|
|
||||||
# define crc32 z_crc32
|
# define crc32 z_crc32
|
||||||
|
# define crc32_combine z_crc32_combine
|
||||||
|
# define deflate z_deflate
|
||||||
|
# define deflateBound z_deflateBound
|
||||||
|
# define deflateCopy z_deflateCopy
|
||||||
|
# define deflateEnd z_deflateEnd
|
||||||
|
# define deflateInit2_ z_deflateInit2_
|
||||||
|
# define deflateInit_ z_deflateInit_
|
||||||
|
# define deflateParams z_deflateParams
|
||||||
|
# define deflatePrime z_deflatePrime
|
||||||
|
# define deflateReset z_deflateReset
|
||||||
|
# define deflateSetDictionary z_deflateSetDictionary
|
||||||
|
# define deflateSetHeader z_deflateSetHeader
|
||||||
|
# define deflateTune z_deflateTune
|
||||||
|
# define deflate_copyright z_deflate_copyright
|
||||||
# define get_crc_table z_get_crc_table
|
# define get_crc_table z_get_crc_table
|
||||||
|
# define gzclearerr z_gzclearerr
|
||||||
|
# define gzclose z_gzclose
|
||||||
|
# define gzdirect z_gzdirect
|
||||||
|
# define gzdopen z_gzdopen
|
||||||
|
# define gzeof z_gzeof
|
||||||
|
# define gzerror z_gzerror
|
||||||
|
# define gzflush z_gzflush
|
||||||
|
# define gzgetc z_gzgetc
|
||||||
|
# define gzgets z_gzgets
|
||||||
|
# define gzopen z_gzopen
|
||||||
|
# define gzprintf z_gzprintf
|
||||||
|
# define gzputc z_gzputc
|
||||||
|
# define gzputs z_gzputs
|
||||||
|
# define gzread z_gzread
|
||||||
|
# define gzrewind z_gzrewind
|
||||||
|
# define gzseek z_gzseek
|
||||||
|
# define gzsetparams z_gzsetparams
|
||||||
|
# define gztell z_gztell
|
||||||
|
# define gzungetc z_gzungetc
|
||||||
|
# define gzwrite z_gzwrite
|
||||||
|
# define inflate z_inflate
|
||||||
|
# define inflateBack z_inflateBack
|
||||||
|
# define inflateBackEnd z_inflateBackEnd
|
||||||
|
# define inflateBackInit_ z_inflateBackInit_
|
||||||
|
# define inflateCopy z_inflateCopy
|
||||||
|
# define inflateEnd z_inflateEnd
|
||||||
|
# define inflateGetHeader z_inflateGetHeader
|
||||||
|
# define inflateInit2_ z_inflateInit2_
|
||||||
|
# define inflateInit_ z_inflateInit_
|
||||||
|
# define inflatePrime z_inflatePrime
|
||||||
|
# define inflateReset z_inflateReset
|
||||||
|
# define inflateSetDictionary z_inflateSetDictionary
|
||||||
|
# define inflateSync z_inflateSync
|
||||||
|
# define inflateSyncPoint z_inflateSyncPoint
|
||||||
|
# define inflate_copyright z_inflate_copyright
|
||||||
|
# define inflate_fast z_inflate_fast
|
||||||
|
# define inflate_table z_inflate_table
|
||||||
|
# define uncompress z_uncompress
|
||||||
# define zError z_zError
|
# define zError z_zError
|
||||||
|
# define z_errmsg z_z_errmsg
|
||||||
|
# define zcalloc z_zcalloc
|
||||||
|
# define zcfree z_zcfree
|
||||||
|
# define zlibCompileFlags z_zlibCompileFlags
|
||||||
|
# define zlibVersion z_zlibVersion
|
||||||
|
|
||||||
# define alloc_func z_alloc_func
|
/* all zlib typedefs in zlib.h and zconf.h */
|
||||||
# define free_func z_free_func
|
|
||||||
# define in_func z_in_func
|
|
||||||
# define out_func z_out_func
|
|
||||||
# define Byte z_Byte
|
# define Byte z_Byte
|
||||||
# define uInt z_uInt
|
|
||||||
# define uLong z_uLong
|
|
||||||
# define Bytef z_Bytef
|
# define Bytef z_Bytef
|
||||||
|
# define alloc_func z_alloc_func
|
||||||
# define charf z_charf
|
# define charf z_charf
|
||||||
|
# define free_func z_free_func
|
||||||
|
# define gzFile z_gzFile
|
||||||
|
# define gz_header z_gz_header
|
||||||
|
# define gz_headerp z_gz_headerp
|
||||||
|
# define in_func z_in_func
|
||||||
# define intf z_intf
|
# define intf z_intf
|
||||||
|
# define out_func z_out_func
|
||||||
|
# define uInt z_uInt
|
||||||
# define uIntf z_uIntf
|
# define uIntf z_uIntf
|
||||||
|
# define uLong z_uLong
|
||||||
# define uLongf z_uLongf
|
# define uLongf z_uLongf
|
||||||
# define voidpf z_voidpf
|
|
||||||
# define voidp z_voidp
|
# define voidp z_voidp
|
||||||
|
# define voidp z_voidp
|
||||||
|
# define voidpc z_voidpc
|
||||||
|
# define voidpc z_voidpc
|
||||||
|
# define voidpf z_voidpf
|
||||||
|
# define voidpf z_voidpf
|
||||||
|
# define z_stream z_z_stream
|
||||||
|
# define z_streamp z_z_streamp
|
||||||
|
|
||||||
|
/* all zlib structs in zlib.h and zconf.h */
|
||||||
|
# define gz_header_s z_gz_header_s
|
||||||
|
# define internal_state z_internal_state
|
||||||
|
# define z_stream_s z_z_stream_s
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__MSDOS__) && !defined(MSDOS)
|
#if defined(__MSDOS__) && !defined(MSDOS)
|
||||||
@@ -243,6 +306,10 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_VISIBILITY_PRAGMA
|
||||||
|
# define ZEXTERN __attribute__((visibility ("default"))) extern
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef ZEXTERN
|
#ifndef ZEXTERN
|
||||||
# define ZEXTERN extern
|
# define ZEXTERN extern
|
||||||
#endif
|
#endif
|
||||||
@@ -284,14 +351,8 @@ typedef uLong FAR uLongf;
|
|||||||
typedef Byte *voidp;
|
typedef Byte *voidp;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */
|
#include "zlibdefs.h" /* created by configure */
|
||||||
# include <sys/types.h> /* for off_t */
|
|
||||||
# include <unistd.h> /* for SEEK_* and off_t */
|
|
||||||
# ifdef VMS
|
|
||||||
# include <unixio.h> /* for off_t */
|
|
||||||
# endif
|
|
||||||
# define z_off_t off_t
|
|
||||||
#endif
|
|
||||||
#ifndef SEEK_SET
|
#ifndef SEEK_SET
|
||||||
# define SEEK_SET 0 /* Seek from beginning of file. */
|
# define SEEK_SET 0 /* Seek from beginning of file. */
|
||||||
# define SEEK_CUR 1 /* Seek from current position. */
|
# define SEEK_CUR 1 /* Seek from current position. */
|
||||||
@@ -307,9 +368,6 @@ typedef uLong FAR uLongf;
|
|||||||
|
|
||||||
#if defined(__MVS__)
|
#if defined(__MVS__)
|
||||||
# define NO_vsnprintf
|
# define NO_vsnprintf
|
||||||
# ifdef FAR
|
|
||||||
# undef FAR
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* MVS linker does not support external names larger than 8 bytes */
|
/* MVS linker does not support external names larger than 8 bytes */
|
||||||
|
|||||||
92
zlib.h
92
zlib.h
@@ -1,7 +1,7 @@
|
|||||||
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
||||||
version 1.2.3, July 18th, 2005
|
version 1.2.3.3, October 2nd, 2006
|
||||||
|
|
||||||
Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler
|
Copyright (C) 1995-2006 Jean-loup Gailly and Mark Adler
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
This software is provided 'as-is', without any express or implied
|
||||||
warranty. In no event will the authors be held liable for any damages
|
warranty. In no event will the authors be held liable for any damages
|
||||||
@@ -37,8 +37,11 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ZLIB_VERSION "1.2.3"
|
#define ZLIB_VERSION "1.2.3.3"
|
||||||
#define ZLIB_VERNUM 0x1230
|
#define ZLIB_VERNUM 0x1233
|
||||||
|
#define ZLIB_VER_MAJOR 1
|
||||||
|
#define ZLIB_VER_MINOR 2
|
||||||
|
#define ZLIB_VER_REVISION 3
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The 'zlib' compression library provides in-memory compression and
|
The 'zlib' compression library provides in-memory compression and
|
||||||
@@ -157,6 +160,8 @@ typedef gz_header FAR *gz_headerp;
|
|||||||
a single step).
|
a single step).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
|
||||||
|
|
||||||
/* constants */
|
/* constants */
|
||||||
|
|
||||||
#define Z_NO_FLUSH 0
|
#define Z_NO_FLUSH 0
|
||||||
@@ -353,10 +358,14 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
|
|||||||
|
|
||||||
inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||||
memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
|
memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
|
||||||
version assumed by the caller. msg is set to null if there is no error
|
version assumed by the caller, or Z_STREAM_ERROR if the parameters are
|
||||||
message. inflateInit does not perform any decompression apart from reading
|
invalid, such as a null pointer to the structure. msg is set to null if
|
||||||
the zlib header if present: this will be done by inflate(). (So next_in and
|
there is no error message. inflateInit does not perform any decompression
|
||||||
avail_in may be modified, but next_out and avail_out are unchanged.)
|
apart from possibly reading the zlib header if present: actual decompression
|
||||||
|
will be done by inflate(). (So next_in and avail_in may be modified, but
|
||||||
|
next_out and avail_out are unused and unchanged.) The current
|
||||||
|
implementation of inflateInit() does not process any header information --
|
||||||
|
that is deferred until inflate() is called.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -645,9 +654,10 @@ ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
|
|||||||
uLong sourceLen));
|
uLong sourceLen));
|
||||||
/*
|
/*
|
||||||
deflateBound() returns an upper bound on the compressed size after
|
deflateBound() returns an upper bound on the compressed size after
|
||||||
deflation of sourceLen bytes. It must be called after deflateInit()
|
deflation of sourceLen bytes. It must be called after deflateInit() or
|
||||||
or deflateInit2(). This would be used to allocate an output buffer
|
deflateInit2(), and after deflateSetHeader(), if used. This would be used
|
||||||
for deflation in a single pass, and so would be called before deflate().
|
to allocate an output buffer for deflation in a single pass, and so would be
|
||||||
|
called before deflate().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
|
ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
|
||||||
@@ -726,11 +736,15 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
|
|||||||
a crc32 instead of an adler32.
|
a crc32 instead of an adler32.
|
||||||
|
|
||||||
inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||||
memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg
|
memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
|
||||||
is set to null if there is no error message. inflateInit2 does not perform
|
version assumed by the caller, or Z_STREAM_ERROR if the parameters are
|
||||||
any decompression apart from reading the zlib header if present: this will
|
invalid, such as a null pointer to the structure. msg is set to null if
|
||||||
be done by inflate(). (So next_in and avail_in may be modified, but next_out
|
there is no error message. inflateInit2 does not perform any decompression
|
||||||
and avail_out are unchanged.)
|
apart from possibly reading the zlib header if present: actual decompression
|
||||||
|
will be done by inflate(). (So next_in and avail_in may be modified, but
|
||||||
|
next_out and avail_out are unused and unchanged.) The current
|
||||||
|
implementation of inflateInit2() does not process any header information --
|
||||||
|
that is deferred until inflate() is called.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
|
ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
|
||||||
@@ -1065,8 +1079,9 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
|
|||||||
|
|
||||||
typedef voidp gzFile;
|
typedef voidp gzFile;
|
||||||
|
|
||||||
ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
|
|
||||||
/*
|
/*
|
||||||
|
ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
|
||||||
|
|
||||||
Opens a gzip (.gz) file for reading or writing. The mode parameter
|
Opens a gzip (.gz) file for reading or writing. The mode parameter
|
||||||
is as in fopen ("rb" or "wb") but can also include a compression level
|
is as in fopen ("rb" or "wb") but can also include a compression level
|
||||||
("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
|
("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
|
||||||
@@ -1180,9 +1195,10 @@ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
|
|||||||
degrade compression.
|
degrade compression.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
|
ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
|
||||||
z_off_t offset, int whence));
|
z_off_t offset, int whence));
|
||||||
/*
|
|
||||||
Sets the starting position for the next gzread or gzwrite on the
|
Sets the starting position for the next gzread or gzwrite on the
|
||||||
given compressed file. The offset represents a number of bytes in the
|
given compressed file. The offset represents a number of bytes in the
|
||||||
uncompressed data stream. The whence parameter is defined as in lseek(2);
|
uncompressed data stream. The whence parameter is defined as in lseek(2);
|
||||||
@@ -1205,8 +1221,9 @@ ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
|
|||||||
gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
|
gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
|
|
||||||
/*
|
/*
|
||||||
|
ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
|
||||||
|
|
||||||
Returns the starting position for the next gzread or gzwrite on the
|
Returns the starting position for the next gzread or gzwrite on the
|
||||||
given compressed file. This position represents a number of bytes in the
|
given compressed file. This position represents a number of bytes in the
|
||||||
uncompressed data stream.
|
uncompressed data stream.
|
||||||
@@ -1230,7 +1247,8 @@ ZEXTERN int ZEXPORT gzclose OF((gzFile file));
|
|||||||
/*
|
/*
|
||||||
Flushes all pending output if necessary, closes the compressed file
|
Flushes all pending output if necessary, closes the compressed file
|
||||||
and deallocates all the (de)compression state. The return value is the zlib
|
and deallocates all the (de)compression state. The return value is the zlib
|
||||||
error number (see function gzerror below).
|
error number. Note that once file is close, you cannot call gzerror with
|
||||||
|
file, since its structures have been deallocated.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
|
ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
|
||||||
@@ -1240,6 +1258,9 @@ ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
|
|||||||
error occurred in the file system and not in the compression library,
|
error occurred in the file system and not in the compression library,
|
||||||
errnum is set to Z_ERRNO and the application may consult errno
|
errnum is set to Z_ERRNO and the application may consult errno
|
||||||
to get the exact error code.
|
to get the exact error code.
|
||||||
|
|
||||||
|
The application must not modify the returned string and future calls to
|
||||||
|
this function may invalidate the returned string.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
|
ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
|
||||||
@@ -1273,9 +1294,10 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
|
|||||||
if (adler != original_adler) error();
|
if (adler != original_adler) error();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
|
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
|
||||||
z_off_t len2));
|
z_off_t len2));
|
||||||
/*
|
|
||||||
Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
|
Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
|
||||||
and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
|
and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
|
||||||
each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of
|
each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of
|
||||||
@@ -1298,9 +1320,9 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
|
|||||||
if (crc != original_crc) error();
|
if (crc != original_crc) error();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
|
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
|
||||||
|
|
||||||
/*
|
|
||||||
Combine two CRC-32 check values into one. For two sequences of bytes,
|
Combine two CRC-32 check values into one. For two sequences of bytes,
|
||||||
seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
|
seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
|
||||||
calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32
|
calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32
|
||||||
@@ -1339,16 +1361,38 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
|
|||||||
inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
|
inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
|
||||||
#define inflateBackInit(strm, windowBits, window) \
|
#define inflateBackInit(strm, windowBits, window) \
|
||||||
inflateBackInit_((strm), (windowBits), (window), \
|
inflateBackInit_((strm), (windowBits), (window), \
|
||||||
ZLIB_VERSION, sizeof(z_stream))
|
ZLIB_VERSION, sizeof(z_stream))
|
||||||
|
|
||||||
|
#ifdef _LARGEFILE64_SOURCE
|
||||||
|
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
|
||||||
|
ZEXTERN off64_t ZEXPORT gzseek64 OF((gzFile, off64_t, int));
|
||||||
|
ZEXTERN off64_t ZEXPORT gztell64 OF((gzFile));
|
||||||
|
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, off64_t));
|
||||||
|
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, off64_t));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _FILE_OFFSET_BITS == 64
|
||||||
|
# define gzopen gzopen64
|
||||||
|
# define gzseek gzseek64
|
||||||
|
# define gztell gztell64
|
||||||
|
# define adler32_combine adler32_combine64
|
||||||
|
# define crc32_combine crc32_combine64
|
||||||
|
#else
|
||||||
|
ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));
|
||||||
|
ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));
|
||||||
|
ZEXTERN z_off_t ZEXPORT gztell OF((gzFile));
|
||||||
|
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
|
||||||
|
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
|
#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
|
||||||
struct internal_state {int dummy;}; /* hack for buggy compilers */
|
struct internal_state {int dummy;}; /* hack for buggy compilers */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ZEXTERN const char * ZEXPORT zError OF((int));
|
ZEXTERN const char * ZEXPORT zError OF((int));
|
||||||
ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z));
|
ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
|
||||||
ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
|
ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
|
||||||
|
ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
13
zlibdefs.h
Normal file
13
zlibdefs.h
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/* zlibdefs.h -- compile-time definitions for the zlib compression library
|
||||||
|
* Copyright (C) 1995-2006 Jean-loup Gailly.
|
||||||
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h> /* for off_t */
|
||||||
|
#include <unistd.h> /* for SEEK_* and off_t */
|
||||||
|
#ifdef VMS
|
||||||
|
# include <unixio.h> /* for off_t */
|
||||||
|
#endif
|
||||||
|
#ifndef z_off_t
|
||||||
|
# define z_off_t off_t
|
||||||
|
#endif
|
||||||
22
zutil.h
22
zutil.h
@@ -1,5 +1,5 @@
|
|||||||
/* zutil.h -- internal interface and configuration of the compression library
|
/* zutil.h -- internal interface and configuration of the compression library
|
||||||
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
* Copyright (C) 1995-2006 Jean-loup Gailly.
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
# include <string.h>
|
# include <string.h>
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef NO_ERRNO_H
|
#if defined(NO_ERRNO_H) || defined(_WIN32_WCE)
|
||||||
# ifdef _WIN32_WCE
|
# ifdef _WIN32_WCE
|
||||||
/* The Microsoft C Run-Time Library for Windows CE doesn't have
|
/* The Microsoft C Run-Time Library for Windows CE doesn't have
|
||||||
* errno. We define it as a global variable to simplify porting.
|
* errno. We define it as a global variable to simplify porting.
|
||||||
@@ -34,9 +34,7 @@
|
|||||||
# endif
|
# endif
|
||||||
extern int errno;
|
extern int errno;
|
||||||
#else
|
#else
|
||||||
# ifndef _WIN32_WCE
|
# include <errno.h>
|
||||||
# include <errno.h>
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef local
|
#ifndef local
|
||||||
@@ -151,7 +149,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
|||||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined(_MSC_VER) && (_MSC_VER > 600))
|
#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
|
||||||
# if defined(_WIN32_WCE)
|
# if defined(_WIN32_WCE)
|
||||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||||
# ifndef _PTRDIFF_T_DEFINED
|
# ifndef _PTRDIFF_T_DEFINED
|
||||||
@@ -161,6 +159,12 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
|||||||
# else
|
# else
|
||||||
# define fdopen(fd,type) _fdopen(fd,type)
|
# define fdopen(fd,type) _fdopen(fd,type)
|
||||||
# endif
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__BORLANDC__)
|
||||||
|
#pragma warn -8004
|
||||||
|
#pragma warn -8008
|
||||||
|
#pragma warn -8066
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* common defaults */
|
/* common defaults */
|
||||||
@@ -171,6 +175,12 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
|||||||
|
|
||||||
#ifndef F_OPEN
|
#ifndef F_OPEN
|
||||||
# define F_OPEN(name, mode) fopen((name), (mode))
|
# define F_OPEN(name, mode) fopen((name), (mode))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _LARGEFILE64_SOURCE
|
||||||
|
# define F_OPEN64(name, mode) fopen64((name), (mode))
|
||||||
|
#else
|
||||||
|
# define F_OPEN64(name, mode) fopen((name), (mode))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* functions */
|
/* functions */
|
||||||
|
|||||||
Reference in New Issue
Block a user