diff --git a/ANNOUNCE b/ANNOUNCE index c97e93ff4..0d3986bfc 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,5 +1,5 @@ -Libpng 1.0.12beta1 - May 14, 2001 +Libpng 1.2.0beta1 - May 6, 2001 This is a public release of libpng, intended for use in production codes. @@ -9,12 +9,10 @@ Changes since the last public release (1.0.11): Updated makefile.cygwin and handling of Cygwin's ALL_STATIC in pngconf.h Added some never-to-be-executed code in pnggccrd.c to quiet compiler warnings. Bumped DLLNUM to 2. - Added a check for attempts to read or write PLTE in grayscale PNG datastreams. - Eliminated the png_error about apps using png_read|write_init(). Instead, - libpng will reallocate the png_struct and info_struct if they are too small. - This achieves future binary compatibility for old applications written for - libpng-0.88 and earlier. - Modified png_create_struct so it passes user mem_ptr to user memory allocator. + Enabled PNG_MNG_FEATURES_SUPPORTED and enabled PNG_ASSEMBLER_CODE_SUPPORTED + by default. + Added runtime selection of MMX features. + Added png_set_strip_error_numbers function and related macros. Send comments/corrections/commendations to png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu diff --git a/CHANGES b/CHANGES index e4b75f47f..c3cf929c0 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,4 @@ + CHANGES - changes for libpng version 0.2 @@ -930,17 +931,15 @@ version 1.0.11beta4 [April 20, 2001] Added makefile.netbsd version 1.0.11 [April 27, 2001] Revised makefile.netbsd -version 1.0.12beta1 [May 14, 2001] +version 1.2.0beta1 [May 6, 2001] Test for Windows platform in pngconf.h when including malloc.h (Emmanuel Blot) Updated makefile.cygwin and handling of Cygwin's ALL_STATIC in pngconf.h Added some never-to-be-executed code in pnggccrd.c to quiet compiler warnings. Bumped DLLNUM to 2. - Added a check for attempts to read or write PLTE in grayscale PNG datastreams. - Eliminated the png_error about apps using png_read|write_init(). Instead, - libpng will reallocate the png_struct and info_struct if they are too small. - This achieves future binary compatibility for old applications written for - libpng-0.88 and earlier. - Modified png_create_struct so it passes user mem_ptr to user memory allocator. + Re-enabled PNG_MNG_FEATURES_SUPPORTED and enabled PNG_ASSEMBLER_CODE_SUPPORTED + by default. + Added runtime selection of MMX features. + Added png_set_strip_error_numbers function and related macros. Send comments/corrections/commendations to png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu diff --git a/INSTALL b/INSTALL index 58111cd7b..d2ad28632 100644 --- a/INSTALL +++ b/INSTALL @@ -1,5 +1,5 @@ -Installing libpng version 1.0.12beta1 - May 14, 2001 +Installing libpng version 1.2.0beta1 - May 6, 2001 Before installing libpng, you must first install zlib. zlib can usually be found wherever you got libpng. zlib can be @@ -10,7 +10,7 @@ zlib.h and zconf.h include files that correspond to the version of zlib that's installed. You can rename the directories that you downloaded (they -might be called "libpng-1.0.12beta1" or "lpng109" and "zlib-1.1.3" +might be called "libpng-1.2.0beta1" or "lpng109" and "zlib-1.1.3" or "zlib113") so that you have directories called "zlib" and "libpng". Your directory structure should look like this: @@ -28,7 +28,6 @@ Your directory structure should look like this: pngsuite visupng projects - beos borland msvc wince @@ -60,8 +59,8 @@ The files that are presently available in the scripts directory include makefile.std => Generic UNIX makefile (cc, creates static libpng.a) - makefile.linux => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.12beta1) - makefile.gcmmx => Linux/ELF makefile (gcc, creates libpng.so.2.1.0.12beta1, + makefile.linux => Linux/ELF makefile (gcc, creates libpng.so.2.1.2.0beta1) + makefile.gcmmx => Linux/ELF makefile (gcc, creates libpng.so.2.1.2.0beta1, uses assembler code tuned for Intel MMX platform) makefile.gcc => Generic makefile (gcc, creates static libpng.a) makefile.knr => Archaic UNIX Makefile that converts files with @@ -70,17 +69,15 @@ include makefile.aix => AIX makefile makefile.cygwin => Cygwin/gcc makefile makefile.dec => DEC Alpha UNIX makefile - makefile.hpgcc => HPUX makefile using gcc makefile.hpux => HPUX (10.20 and 11.00) makefile makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static) makefile.intel => Intel C/C++ version 4.0 and later libpng.icc => Project file for IBM VisualAge/C++ version 4.0 or later makefile.macosx => MACOS X Makefile - makefile.netbsd => NetBSD/cc makefile, uses PNGGCCRD makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib) - makefile.sggcc => Silicon Graphics (gcc, creates libpng.so.2.1.0.12beta1) + makefile.sggcc => Silicon Graphics (gcc, creates libpng.so.2.1.2.0beta1) makefile.sunos => Sun makefile - makefile.solaris => Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.12beta1) + makefile.solaris => Solaris 2.X makefile (gcc, creates libpng.so.2.1.2.0beta1) makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc makefile.mips => MIPS makefile makefile.acorn => Acorn makefile diff --git a/KNOWNBUG b/KNOWNBUG index d596debed..7b0928cd1 100644 --- a/KNOWNBUG +++ b/KNOWNBUG @@ -1,7 +1,8 @@ -Known bugs in libpng-1.0.11 +Known bugs in libpng-1.2.0 1. April 22, 2001: pnggccrd.c has been reported to crash on NetBSD when reading interlaced PNG files, when assembler code is enabled. STATUS: Under investigation. + diff --git a/LICENSE b/LICENSE index e5e9b4a2f..aadf18f09 100644 --- a/LICENSE +++ b/LICENSE @@ -8,8 +8,8 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: If you modify libpng you may insert additional notices immediately following this sentence. -libpng versions 1.0.7, July 1, 2000, through 1.0.12beta1, May 14, 2001, are -Copyright (c) 2000, 2001 Glenn Randers-Pehrson +libpng versions 1.0.7, July 1, 2000, through 1.2.0beta1, May 6, 2001, are +Copyright (c) 2000 Glenn Randers-Pehrson and are distributed according to the same disclaimer and license as libpng-1.0.6 with the following individuals added to the list of Contributing Authors @@ -73,11 +73,11 @@ to the following restrictions: 1. The origin of this source code must not be misrepresented. -2. Altered versions must be plainly marked as such and - must not be misrepresented as being the original source. +2. Altered versions must be plainly marked as such and must not + be misrepresented as being the original source. -3. This Copyright notice may not be removed or altered from - any source or altered source distribution. +3. This Copyright notice may not be removed or altered from any + source or altered source distribution. The Contributing Authors and Group 42, Inc. specifically permit, without fee, and encourage the use of this source code as a component to @@ -99,4 +99,4 @@ certification mark of the Open Source Initiative. Glenn Randers-Pehrson randeg@alum.rpi.edu -May 14, 2001 +May 6, 2001 diff --git a/README b/README index 6c83f338f..44c77c83f 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -README for libpng 1.0.12beta1 - May 14, 2001 (shared library 2.1) +README for libpng 1.2.0beta1 - May 6, 2001 (shared library 2.1) See the note about version numbers near the top of png.h See INSTALL for instructions on how to install libpng. @@ -172,7 +172,6 @@ Files in this distribution: pngsuite => Test images visupng => Contains a MSVC workspace for VisualPng projects => Contains project files and workspaces for building DLL - beos => Contains a Beos workspace for building libpng borland => Contains a Borland workspace for building libpng and zlib msvc => Contains a Microsoft Visual C++ (MSVC) workspace @@ -183,9 +182,9 @@ Files in this distribution: descrip.mms => VMS makefile for MMS or MMK makefile.std => Generic UNIX makefile (cc, creates static libpng.a) makefile.linux => Linux/ELF makefile - (gcc, creates libpng.so.2.1.0.12beta1) + (gcc, creates libpng.so.2.1.2.0beta1) makefile.gcmmx => Linux/ELF makefile (gcc, creates - libpng.so.2.1.0.12beta1, uses assembler code + libpng.so.2.1.2.0beta1, uses assembler code tuned for Intel MMX platform) makefile.gcc => Generic makefile (gcc, creates static libpng.a) makefile.knr => Archaic UNIX Makefile that converts files with @@ -194,18 +193,16 @@ Files in this distribution: makefile.aix => AIX makefile makefile.cygwin => Cygwin/gcc makefile makefile.dec => DEC Alpha UNIX makefile - makefile.hpgcc => HPUX makefile using gcc makefile.hpux => HPUX (10.20 and 11.00) makefile makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static) makefile.intel => Intel C/C++ version 4.0 and later libpng.icc => Project file, IBM VisualAge/C++ 4.0 or later makefile.macosx => MACOS X Makefile - makefile.netbsd => NetBSD/cc makefile, uses PNGGCCRD makefile.sgi => Silicon Graphics IRIX (cc, creates static lib) - makefile.sggcc => Silicon Graphics (gcc, creates libpng.so.2.1.0.12beta1) + makefile.sggcc => Silicon Graphics (gcc, creates libpng.so.2.1.2.0beta1) makefile.sunos => Sun makefile makefile.solaris => Solaris 2.X makefile - (gcc, creates libpng.so.2.1.0.12beta1) + (gcc, creates libpng.so.2.1.2.0beta1) makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc makefile.mips => MIPS makefile makefile.acorn => Acorn makefile diff --git a/Y2KINFO b/Y2KINFO index 86b7213a4..174c73007 100644 --- a/Y2KINFO +++ b/Y2KINFO @@ -1,13 +1,13 @@ Y2K compliance in libpng: ========================= - May 14, 2001 + May 6, 2001 Since the PNG Development group is an ad-hoc body, we can't make an official declaration. This is your unofficial assurance that libpng from version 0.71 and - upward through 1.0.12beta1 are Y2K compliant. It is my belief that earlier + upward through 1.2.0beta1 are Y2K compliant. It is my belief that earlier versions were also Y2K compliant. Libpng only has three year fields. One is a 2-byte unsigned integer diff --git a/configure b/configure index 1d125c632..159fbad31 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ echo " - There is no \"configure\" script for Libpng-1.0.12beta1. Instead, please + There is no \"configure\" script for Libpng-1.2.0beta1. Instead, please copy the appropriate makefile for your system from the \"scripts\" directory. Read the INSTALL file for more details. " diff --git a/contrib/gregbook/readpng2.c b/contrib/gregbook/readpng2.c index 498d96770..434229fa8 100644 --- a/contrib/gregbook/readpng2.c +++ b/contrib/gregbook/readpng2.c @@ -49,8 +49,77 @@ static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg); void readpng2_version_info(void) { +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && \ + (defined(__i386__) || defined(_M_IX86)) && \ + defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) + /* + * WARNING: This preprocessor approach means that the following code + * cannot be used with a libpng DLL older than 1.2.0--the + * compiled-in symbols for the new functions will not exist. + * (Could use dlopen() and dlsym() on Unix and corresponding + * calls for Windows, but not portable...) + */ + { + int mmxsupport = png_mmx_support(); + if (mmxsupport < 0) + fprintf(stderr, " Compiled with libpng %s; using libpng %s " + "without MMX support.\n", PNG_LIBPNG_VER_STRING, png_libpng_ver); + else { + int compilerID; + png_uint_32 mmx_mask = png_get_mmx_flagmask( + PNG_SELECT_READ | PNG_SELECT_WRITE, &compilerID); + + fprintf(stderr, " Compiled with libpng %s; using libpng %s " + "with MMX support\n (%s version).", PNG_LIBPNG_VER_STRING, + png_libpng_ver, compilerID == 1? "MSVC++" : + (compilerID == 2? "GNU C" : "unknown")); + fprintf(stderr, " Processor %s MMX instructions.\n", + mmxsupport? "supports" : "does not support"); + if (mmxsupport > 0) { + int num_optims = 0; + + fprintf(stderr, + " Potential MMX optimizations supported by libpng:\n"); + if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_SUB) + ++num_optims; + if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_UP) + ++num_optims; + if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_AVG) + ++num_optims; + if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH) + ++num_optims; + if (num_optims) + fprintf(stderr, + " decoding %s row filters (reading)\n", + (num_optims == 4)? "all non-trivial" : "some"); + if (mmx_mask & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) { + fprintf(stderr, " combining rows (reading)\n"); + ++num_optims; + } + if (mmx_mask & PNG_ASM_FLAG_MMX_READ_INTERLACE) { + fprintf(stderr, + " expanding interlacing (reading)\n"); + ++num_optims; + } + mmx_mask &= ~( 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 (mmx_mask) { + fprintf(stderr, " other (unknown)\n"); + ++num_optims; + } + if (num_optims == 0) + fprintf(stderr, " (none)\n"); + } + } + } +#else fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n", PNG_LIBPNG_VER_STRING, png_libpng_ver); +#endif fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n", ZLIB_VERSION, zlib_version); @@ -111,6 +180,97 @@ int readpng2_init(mainprog_info *mainprog_ptr) png_set_progressive_read_fn(png_ptr, mainprog_ptr, readpng2_info_callback, readpng2_row_callback, readpng2_end_callback); + + /* + * may as well enable or disable MMX routines here, if supported; + * + * to enable all: mask = png_get_mmx_flagmask ( + * PNG_SELECT_READ | PNG_SELECT_WRITE, &compilerID); + * flags = png_get_asm_flags (png_ptr); + * flags |= mask; + * png_set_asm_flags (png_ptr, flags); + * + * to disable all: mask = png_get_mmx_flagmask ( + * PNG_SELECT_READ | PNG_SELECT_WRITE, &compilerID); + * flags = png_get_asm_flags (png_ptr); + * flags &= ~mask; + * png_set_asm_flags (png_ptr, flags); + */ + +#if (defined(__i386__) || defined(_M_IX86)) && \ + defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) + /* + * WARNING: This preprocessor approach means that the following code + * cannot be used with a libpng DLL older than 1.2.0--the + * compiled-in symbols for the new functions will not exist. + * (Could use dlopen() and dlsym() on Unix and corresponding + * calls for Windows, but not portable...) + */ + { +#ifdef PNG_ASSEMBLER_CODE_SUPPORTED + png_uint_32 mmx_disable_mask = 0; + png_uint_32 asm_flags, mmx_mask; + int compilerID; + + if (mainprog_ptr->nommxfilters) + mmx_disable_mask |= ( 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 (mainprog_ptr->nommxcombine) + mmx_disable_mask |= PNG_ASM_FLAG_MMX_READ_COMBINE_ROW; + if (mainprog_ptr->nommxinterlace) + mmx_disable_mask |= PNG_ASM_FLAG_MMX_READ_INTERLACE; + asm_flags = png_get_asm_flags(png_ptr); + png_set_asm_flags(png_ptr, asm_flags & ~mmx_disable_mask); + + + /* Now query libpng's asm settings, just for yuks. Note that this + * differs from the querying of its *potential* MMX capabilities + * in readpng2_version_info(); this is true runtime verification. */ + + asm_flags = png_get_asm_flags(png_ptr); + mmx_mask = png_get_mmx_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE, + &compilerID); + if (asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_COMPILED) + fprintf(stderr, + " MMX support (%s version) is compiled into libpng\n", + compilerID == 1? "MSVC++" : + (compilerID == 2? "GNU C" : "unknown")); + else + fprintf(stderr, " MMX support is not compiled into libpng\n"); + fprintf(stderr, " MMX instructions are %ssupported by CPU\n", + (asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU)? "" : "not "); + fprintf(stderr, " MMX read support for combining rows is %sabled\n", + (asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW)? "en" : "dis"); + fprintf(stderr, + " MMX read support for expanding interlacing is %sabled\n", + (asm_flags & PNG_ASM_FLAG_MMX_READ_INTERLACE)? "en" : "dis"); + fprintf(stderr, " MMX read support for \"sub\" filter is %sabled\n", + (asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "en" : "dis"); + fprintf(stderr, " MMX read support for \"up\" filter is %sabled\n", + (asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP)? "en" : "dis"); + fprintf(stderr, " MMX read support for \"avg\" filter is %sabled\n", + (asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)? "en" : "dis"); + fprintf(stderr, " MMX read support for \"Paeth\" filter is %sabled\n", + (asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)? "en" : "dis"); + asm_flags &= (mmx_mask & ~( 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 (asm_flags) + fprintf(stderr, + " additional MMX support is also enabled (0x%02lx)\n", + asm_flags); +#else /* !PNG_ASSEMBLER_CODE_SUPPORTED */ + fprintf(stderr, " MMX querying is disabled in libpng.\n"); +#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ + } +#endif + + /* make sure we save our pointers for use in readpng2_decode_data() */ mainprog_ptr->png_ptr = png_ptr; @@ -370,6 +530,7 @@ static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr) (*mainprog_ptr->mainprog_finish_display)(); + info_ptr = info_ptr; /* without this the compiler whines about info_ptr */ /* all done */ diff --git a/contrib/visupng/PngFile.c b/contrib/visupng/PngFile.c index af8d81c70..959afe9de 100644 --- a/contrib/visupng/PngFile.c +++ b/contrib/visupng/PngFile.c @@ -370,14 +370,14 @@ BOOL PngSaveImage (PTSTR pstrFileName, png_byte *pDiData, // clean up after the write, and free any memory allocated - png_destroy_write_struct(&png_ptr, &info_ptr); + png_destroy_write_struct(&png_ptr, (png_infopp) NULL); // yepp, done } Catch (msg) { - png_destroy_write_struct(&png_ptr, &info_ptr); + png_destroy_write_struct(&png_ptr, (png_infopp) NULL); if(ppbRowPointers) free (ppbRowPointers); diff --git a/example.c b/example.c index f0fe688a7..1e953c84e 100644 --- a/example.c +++ b/example.c @@ -338,8 +338,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */ for (row = 0; row < height; row++) { - row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr, - info_ptr)); + row_pointers[row] = malloc(png_get_rowbytes(png_ptr, info_ptr)); } /* Now it's time to read the image. One of these methods is REQUIRED */ @@ -495,7 +494,7 @@ row_callback(png_structp png_ptr, png_bytep new_row, * png_progressive_combine_row() passing in the row and the * old row. You can call this function for NULL rows (it will * just return) and for non-interlaced images (it just does the - * png_memcpy for you) if it will make the code easier. Thus, you + * memcpy for you) if it will make the code easier. Thus, you * can just do this for all cases: */ @@ -604,8 +603,7 @@ void write_png(char *file_name /* , ... other image information ... */) PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); /* set the palette if there is one. REQUIRED for indexed-color images */ - palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH - * sizeof (png_color)); + palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH * sizeof (png_color)); /* ... set palette colors ... */ png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH); /* You must not free palette here, because png_set_PLTE only makes a link to diff --git a/libpng.3 b/libpng.3 index e09809a6c..88a3758dc 100644 --- a/libpng.3 +++ b/libpng.3 @@ -1,6 +1,6 @@ -.TH LIBPNG 3 "May 14, 2001" +.TH LIBPNG 3 "May 6, 2001" .SH NAME -libpng \- Portable Network Graphics (PNG) Reference Library 1.0.12beta1 +libpng \- Portable Network Graphics (PNG) Reference Library 1.2.0beta1 .SH SYNOPSIS \fI\fB @@ -100,6 +100,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.12beta1 \fI\fB +\fBpng_uint_32 png_get_asm_flags (png_structp \fIpng_ptr\fP\fB);\fP + +\fI\fB + \fBpng_byte png_get_bit_depth (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP \fI\fB @@ -192,6 +196,18 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.12beta1 \fI\fB +\fBpng_byte png_get_mmx_bitdepth_threshold (png_structp \fIpng_ptr\fP\fB);\fP + +\fI\fB + +\fBpng_uint_32 png_get_mmx_flagmask (int \fP\fIflag_select\fP\fB, int \fI*compilerID\fP\fB);\fP + +\fI\fB + +\fBpng_uint_32 png_get_mmx_rowbytes_threshold (png_structp \fIpng_ptr\fP\fB);\fP + +\fI\fB + \fBpng_uint_32 png_get_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*offset_x\fP\fB, png_uint_32 \fP\fI*offset_y\fP\fB, int \fI*unit_type\fP\fB);\fP \fI\fB @@ -334,6 +350,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.12beta1 \fI\fB +\fBint png_mmx_support \fI(void\fP\fB);\fP + +\fI\fB + \fBvoid png_permit_empty_plte (png_structp \fP\fIpng_ptr\fP\fB, int \fIempty_plte_permitted\fP\fB);\fP \fI\fB @@ -384,6 +404,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.12beta1 \fI\fB +\fBpng_set_asm_flags (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIasm_flags\fP\fB);\fP + +\fI\fB + \fBvoid png_set_background (png_structp \fP\fIpng_ptr\fP\fB, png_color_16p \fP\fIbackground_color\fP\fB, int \fP\fIbackground_gamma_code\fP\fB, int \fP\fIneed_expand\fP\fB, double \fIbackground_gamma\fP\fB);\fP \fI\fB @@ -512,6 +536,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.12beta1 \fI\fB +\fBpng_set_mmx_thresholds (png_structp \fP\fIpng_ptr\fP\fB, png_byte \fP\fImmx_bitdepth_threshold\fP\fB, png_uint_32 \fImmx_rowbytes_threshold\fP\fB);\fP + +\fI\fB + \fBvoid png_set_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIoffset_x\fP\fB, png_uint_32 \fP\fIoffset_y\fP\fB, int \fIunit_type\fP\fB);\fP \fI\fB @@ -604,6 +632,12 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.12beta1 \fI\fB +\fBvoid png_set_strip_error_numbers (png_structp \fIpng_ptr, + +\fBpng_uint_32 \fIstrip_mode\fP\fB);\fP + +\fI\fB + \fBvoid png_set_swap (png_structp \fIpng_ptr\fP\fB);\fP \fI\fB @@ -747,7 +781,7 @@ Following is a copy of the libpng.txt file that accompanies libpng. .SH LIBPNG.TXT libpng.txt - A description on how to use and modify libpng - libpng version 1.0.12beta1 - May 14, 2001 + libpng version 1.2.0beta1 - May 6, 2001 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2001 Glenn Randers-Pehrson @@ -2143,7 +2177,6 @@ png_infop info_ptr; /* This function is called when each row of image data is complete */ - void row_callback(png_structp png_ptr, png_bytep new_row, png_uint_32 row_num, int pass) @@ -3392,8 +3425,106 @@ When PNG_DEBUG = 1, the macros are defined, but only png_debug statements having level = 0 will be printed. There aren't any such statements in this version of libpng, but if you insert some they will be printed. +.SH VI. Runtime optimization -.SH VI. MNG support +A new feature in libpng 1.2.0 is the ability to dynamically switch between +standard and optimized versions of some routines. Currently these are +limited to three computationally intensive tasks when reading PNG files: +decoding row filters, expanding interlacing, and combining interlaced or +transparent row data with previous row data. Currently the optimized +versions are available only for x86 (Intel, AMD, etc.) platforms with +MMX support, though this may change in future versions. (For example, +the non-MMX assembler optimizations for zlib might become similarly +runtime-selectable in future releases, in which case libpng could be +extended to support them. Alternatively, the compile-time choice of +floating-point versus integer routines for gamma correction might become +runtime-selectable.) + +Because such optimizations tend to be very platform- and compiler-dependent, +both in how they are written and in how they perform, the new runtime code +in libpng has been written to allow programs to query, enable, and disable +either specific optimizations or all such optimizations. For example, to +enable all possible optimizations (bearing in mind that some "optimizations" +may actually run more slowly in rare cases): + + #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) + png_uint_32 mask, flags; + + flags = png_get_asm_flags(png_ptr); + mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE); + png_set_asm_flags(png_ptr, flags | mask); + #endif + +To enable only optimizations relevant to reading PNGs, use PNG_SELECT_READ +by itself when calling png_get_asm_flagmask(); similarly for optimizing +only writing. To disable all optimizations: + + #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) + flags = png_get_asm_flags(png_ptr); + mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE); + png_set_asm_flags(png_ptr, flags & ~mask); + #endif + +To enable or disable only MMX-related features, use png_get_mmx_flagmask() +in place of png_get_asm_flagmask(). The mmx version takes one additional +parameter: + + #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) + int selection = PNG_SELECT_READ | PNG_SELECT_WRITE; + int compilerID; + + mask = png_get_mmx_flagmask(selection, &compilerID); + #endif + +On return, compilerID will indicate which version of the MMX assembler +optimizations was compiled. Currently two flavors exist: Microsoft +Visual C++ (compilerID == 1) and GNU C (a.k.a. gcc/gas, compilerID == 2). +On non-x86 platforms or on systems compiled without MMX optimizations, a +value of -1 is used. + +Note that both png_get_asm_flagmask() and png_get_mmx_flagmask() return +all valid, settable optimization bits for the version of the library that's +currently in use. In the case of shared (dynamically linked) libraries, +this may include optimizations that did not exist at the time the code was +written and compiled. It is also possible, of course, to enable only known, +specific optimizations; for example: + + #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) + 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 ; + png_set_asm_flags(png_ptr, flags); + #endif + +This method would enable only the MMX read-optimizations available at the +time of libpng 1.2.0's release, regardless of whether a later version of +the DLL were actually being used. (Also note that these functions did not +exist in versions older than 1.2.0, so any attempt to run a dynamically +linked app on such an older version would fail.) + +To determine whether the processor supports MMX instructions at all, use +the png_mmx_support() function: + + #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) + mmxsupport = png_mmx_support(); + #endif + +It returns -1 if MMX support is not compiled into libpng, 0 if MMX code +is compiled but MMX is not supported by the processor, or 1 if MMX support +is fully available. Note that png_mmx_support(), png_get_mmx_flagmask(), +and png_get_asm_flagmask() all may be called without allocating and ini- +tializing any PNG structures (for example, as part of a usage screen or +"about" box). + +For more extensive examples of runtime querying, enabling and disabling +of optimized features, see contrib/gregbook/readpng2.c in the libpng +source-code distribution. + + +.SH VII. MNG support The MNG specification (available at http://www.libpng.org/pub/mng) allows certain extensions to PNG for PNG images that are embedded in MNG datastreams. @@ -3418,7 +3549,7 @@ or any other MNG chunks; your application must provide its own support for them. You may wish to consider using libmng (available at http://www.libmng.com) instead. -.SH VII. Changes to Libpng from version 0.88 +.SH VIII. Changes to Libpng from version 0.88 It should be noted that versions of libpng later than 0.96 are not distributed by the original libpng author, Guy Schalnat, nor by @@ -3428,7 +3559,7 @@ of the original PNG Group, Glenn Randers-Pehrson. Guy and Andreas are still alive and well, but they have moved on to other things. The old libpng functions png_read_init(), png_write_init(), -png_info_init(), png_read_destroy(), and png_write_destroy() have been +png_info_init(), png_read_destroy(), and png_write_destory() have been moved to PNG_INTERNAL in version 0.95 to discourage their use. These functions will be removed from libpng version 2.0.0. @@ -3467,15 +3598,15 @@ application: png_uint_32 application_vn = PNG_LIBPNG_VER; -.SH VIII. Y2K Compliance in libpng +.SH IX. Y2K Compliance in libpng -May 14, 2001 +May 6, 2001 Since the PNG Development group is an ad-hoc body, we can't make an official declaration. This is your unofficial assurance that libpng from version 0.71 and -upward through 1.0.12beta1 are Y2K compliant. It is my belief that earlier +upward through 1.2.0beta1 are Y2K compliant. It is my belief that earlier versions were also Y2K compliant. Libpng only has three year fields. One is a 2-byte unsigned integer that @@ -3587,7 +3718,8 @@ the first widely used release: 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 1.0.11rc1 1 10011 2.1.0.11rc1 1.0.11 1 10011 2.1.0.11 - 1.0.12beta1 1 10012 2.1.0.12beta1 + 1.1.0a-f 1 10100 2.1.1.0 abandoned + 1.2.0beta1 2 10200 2.1.2.0beta1 Henceforth the source version will match the shared-library minor and patch numbers; the shared-library major version number will be @@ -3645,7 +3777,7 @@ possible without all of you. Thanks to Frank J. T. Wojcik for helping with the documentation. -Libpng version 1.0.12beta1 - May 14, 2001: +Libpng version 1.2.0beta1 - May 6, 2001: Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc. Currently maintained by Glenn Randers-Pehrson (randeg@alum.rpi.edu). @@ -3662,7 +3794,7 @@ included in the libpng distribution, the latter shall prevail.) If you modify libpng you may insert additional notices immediately following this sentence. -libpng versions 1.0.7, July 1, 2000, through 1.0.12beta1, May 14, 2001, are +libpng versions 1.0.7, July 1, 2000, through 1.2.0beta1, May 6, 2001, are Copyright (c) 2000-2001 Glenn Randers-Pehrson, and are distributed according to the same disclaimer and license as libpng-1.0.6 with the following individuals added to the list of Contributing Authors @@ -3754,7 +3886,7 @@ certification mark of the Open Source Initiative. Glenn Randers-Pehrson randeg@alum.rpi.edu -May 14, 2001 +May 6, 2001 .\" end of man page diff --git a/libpng.txt b/libpng.txt index b279116aa..7719a26b5 100644 --- a/libpng.txt +++ b/libpng.txt @@ -1,6 +1,6 @@ libpng.txt - A description on how to use and modify libpng - libpng version 1.0.12beta1 - May 14, 2001 + libpng version 1.2.0beta1 - May 6, 2001 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2001 Glenn Randers-Pehrson @@ -1396,7 +1396,6 @@ png_infop info_ptr; /* This function is called when each row of image data is complete */ - void row_callback(png_structp png_ptr, png_bytep new_row, png_uint_32 row_num, int pass) @@ -2645,8 +2644,106 @@ When PNG_DEBUG = 1, the macros are defined, but only png_debug statements having level = 0 will be printed. There aren't any such statements in this version of libpng, but if you insert some they will be printed. +VI. Runtime optimization -VI. MNG support +A new feature in libpng 1.2.0 is the ability to dynamically switch between +standard and optimized versions of some routines. Currently these are +limited to three computationally intensive tasks when reading PNG files: +decoding row filters, expanding interlacing, and combining interlaced or +transparent row data with previous row data. Currently the optimized +versions are available only for x86 (Intel, AMD, etc.) platforms with +MMX support, though this may change in future versions. (For example, +the non-MMX assembler optimizations for zlib might become similarly +runtime-selectable in future releases, in which case libpng could be +extended to support them. Alternatively, the compile-time choice of +floating-point versus integer routines for gamma correction might become +runtime-selectable.) + +Because such optimizations tend to be very platform- and compiler-dependent, +both in how they are written and in how they perform, the new runtime code +in libpng has been written to allow programs to query, enable, and disable +either specific optimizations or all such optimizations. For example, to +enable all possible optimizations (bearing in mind that some "optimizations" +may actually run more slowly in rare cases): + + #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) + png_uint_32 mask, flags; + + flags = png_get_asm_flags(png_ptr); + mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE); + png_set_asm_flags(png_ptr, flags | mask); + #endif + +To enable only optimizations relevant to reading PNGs, use PNG_SELECT_READ +by itself when calling png_get_asm_flagmask(); similarly for optimizing +only writing. To disable all optimizations: + + #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) + flags = png_get_asm_flags(png_ptr); + mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE); + png_set_asm_flags(png_ptr, flags & ~mask); + #endif + +To enable or disable only MMX-related features, use png_get_mmx_flagmask() +in place of png_get_asm_flagmask(). The mmx version takes one additional +parameter: + + #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) + int selection = PNG_SELECT_READ | PNG_SELECT_WRITE; + int compilerID; + + mask = png_get_mmx_flagmask(selection, &compilerID); + #endif + +On return, compilerID will indicate which version of the MMX assembler +optimizations was compiled. Currently two flavors exist: Microsoft +Visual C++ (compilerID == 1) and GNU C (a.k.a. gcc/gas, compilerID == 2). +On non-x86 platforms or on systems compiled without MMX optimizations, a +value of -1 is used. + +Note that both png_get_asm_flagmask() and png_get_mmx_flagmask() return +all valid, settable optimization bits for the version of the library that's +currently in use. In the case of shared (dynamically linked) libraries, +this may include optimizations that did not exist at the time the code was +written and compiled. It is also possible, of course, to enable only known, +specific optimizations; for example: + + #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) + 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 ; + png_set_asm_flags(png_ptr, flags); + #endif + +This method would enable only the MMX read-optimizations available at the +time of libpng 1.2.0's release, regardless of whether a later version of +the DLL were actually being used. (Also note that these functions did not +exist in versions older than 1.2.0, so any attempt to run a dynamically +linked app on such an older version would fail.) + +To determine whether the processor supports MMX instructions at all, use +the png_mmx_support() function: + + #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) + mmxsupport = png_mmx_support(); + #endif + +It returns -1 if MMX support is not compiled into libpng, 0 if MMX code +is compiled but MMX is not supported by the processor, or 1 if MMX support +is fully available. Note that png_mmx_support(), png_get_mmx_flagmask(), +and png_get_asm_flagmask() all may be called without allocating and ini- +tializing any PNG structures (for example, as part of a usage screen or +"about" box). + +For more extensive examples of runtime querying, enabling and disabling +of optimized features, see contrib/gregbook/readpng2.c in the libpng +source-code distribution. + + +VII. MNG support The MNG specification (available at http://www.libpng.org/pub/mng) allows certain extensions to PNG for PNG images that are embedded in MNG datastreams. @@ -2671,7 +2768,7 @@ or any other MNG chunks; your application must provide its own support for them. You may wish to consider using libmng (available at http://www.libmng.com) instead. -VII. Changes to Libpng from version 0.88 +VIII. Changes to Libpng from version 0.88 It should be noted that versions of libpng later than 0.96 are not distributed by the original libpng author, Guy Schalnat, nor by @@ -2681,7 +2778,7 @@ of the original PNG Group, Glenn Randers-Pehrson. Guy and Andreas are still alive and well, but they have moved on to other things. The old libpng functions png_read_init(), png_write_init(), -png_info_init(), png_read_destroy(), and png_write_destroy() have been +png_info_init(), png_read_destroy(), and png_write_destory() have been moved to PNG_INTERNAL in version 0.95 to discourage their use. These functions will be removed from libpng version 2.0.0. @@ -2720,15 +2817,15 @@ application: png_uint_32 application_vn = PNG_LIBPNG_VER; -VIII. Y2K Compliance in libpng +IX. Y2K Compliance in libpng -May 14, 2001 +May 6, 2001 Since the PNG Development group is an ad-hoc body, we can't make an official declaration. This is your unofficial assurance that libpng from version 0.71 and -upward through 1.0.12beta1 are Y2K compliant. It is my belief that earlier +upward through 1.2.0beta1 are Y2K compliant. It is my belief that earlier versions were also Y2K compliant. Libpng only has three year fields. One is a 2-byte unsigned integer that diff --git a/libpngpf.3 b/libpngpf.3 index d6124039b..67beb26e8 100644 --- a/libpngpf.3 +++ b/libpngpf.3 @@ -1,6 +1,6 @@ -.TH LIBPNGPF 3 "May 14, 2001" +.TH LIBPNGPF 3 "May 6, 2001" .SH NAME -libpng \- Portable Network Graphics (PNG) Reference Library 1.0.12beta1 +libpng \- Portable Network Graphics (PNG) Reference Library 1.2.0beta1 (private functions) .SH SYNOPSIS \fB#include \fP @@ -283,6 +283,10 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.0.12beta1 \fI\fB +\fBvoid png_init_mmx_flags (png_structp \fIpng_ptr\fP\fB);\fP + +\fI\fB + \fBvoid png_init_read_transformations (png_structp \fIpng_ptr\fP\fB);\fP \fI\fB diff --git a/png.5 b/png.5 index 588d96d07..a1fda65a2 100644 --- a/png.5 +++ b/png.5 @@ -1,4 +1,4 @@ -.TH PNG 5 "May 14, 2001" +.TH PNG 5 "May 6, 2001" .SH NAME png \- Portable Network Graphics (PNG) format .SH DESCRIPTION diff --git a/png.c b/png.c index 691807ce4..3010f24b7 100644 --- a/png.c +++ b/png.c @@ -1,7 +1,7 @@ /* png.c - location for general purpose libpng functions * - * libpng version 1.0.12beta1 - May 14, 2001 + * libpng version 1.2.0beta1 - May 6, 2001 * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -13,14 +13,14 @@ #include "png.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef version_1_0_12beta1 Your_png_h_is_not_version_1_0_12beta1; +typedef version_1_2_0beta1 Your_png_h_is_not_version_1_2_0beta1; /* Version information for C files. This had better match the version * string defined in png.h. */ #ifdef PNG_USE_GLOBAL_ARRAYS /* png_libpng_ver was changed to a function in version 1.0.5c */ -const char png_libpng_ver[18] = "1.0.12beta1"; +const char png_libpng_ver[18] = "1.2.0beta1"; /* png_sig was changed to a function in version 1.0.5c */ /* Place to hold the signature string for a PNG file. */ @@ -213,12 +213,12 @@ png_create_info_struct(png_structp png_ptr) if(png_ptr == NULL) return (NULL); #ifdef PNG_USER_MEM_SUPPORTED if ((info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO, - png_ptr->malloc_fn, png_ptr->mem_ptr)) != NULL) + png_ptr->malloc_fn)) != NULL) #else if ((info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO)) != NULL) #endif { - png_info_init_3(&info_ptr, sizeof(png_info)); + png_info_init(info_ptr); } return (info_ptr); @@ -243,8 +243,7 @@ png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr) png_info_destroy(png_ptr, info_ptr); #ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)info_ptr, png_ptr->free_fn, - png_ptr->mem_ptr); + png_destroy_struct_2((png_voidp)info_ptr, png_ptr->free_fn); #else png_destroy_struct((png_voidp)info_ptr); #endif @@ -256,28 +255,10 @@ png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr) * and applications using it are urged to use png_create_info_struct() * instead. */ -#undef png_info_init -void PNGAPI +void /* PRIVATE */ png_info_init(png_infop info_ptr) { - /* We only come here via pre-1.0.12-compiled applications */ - png_info_init_3(&info_ptr, 0); -} - -void PNGAPI -png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size) -{ - png_infop info_ptr = *ptr_ptr; - - png_debug(1, "in png_info_init_3\n"); - - if(sizeof(png_info) > png_info_struct_size) - { - png_destroy_struct(info_ptr); - info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); - *ptr_ptr = info_ptr; - } - + png_debug(1, "in png_info_init\n"); /* set everything to 0 */ png_memset(info_ptr, 0, sizeof (png_info)); } @@ -556,7 +537,7 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr) } #endif - png_info_init_3(&info_ptr, sizeof(png_info)); + png_info_init(info_ptr); } /* This function returns a pointer to the io_ptr associated with the user @@ -646,7 +627,7 @@ png_charp PNGAPI png_get_copyright(png_structp png_ptr) { if (png_ptr != NULL || png_ptr == NULL) /* silence compiler warning */ - return ((png_charp) "\n libpng version 1.0.12beta1 - May 14, 2001\n\ + return ((png_charp) "\n libpng version 1.2.0beta1 - May 6, 2001\n\ Copyright (c) 1998-2001 Glenn Randers-Pehrson\n\ Copyright (c) 1996, 1997 Andreas Dilger\n\ Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n"); @@ -664,8 +645,8 @@ png_get_libpng_ver(png_structp png_ptr) { /* Version of *.c files used when building libpng */ if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */ - return((png_charp) "1.0.12beta1"); - return((png_charp) "1.0.12beta1"); + return((png_charp) "1.2.0beta1"); + return((png_charp) "1.2.0beta1"); } png_charp PNGAPI @@ -715,9 +696,58 @@ png_uint_32 PNGAPI png_access_version_number(void) { /* Version of *.c files used when building libpng */ - return((png_uint_32) 10012L); + return((png_uint_32) 10200L); } + +#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()) { + 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 */ #if !defined(PNG_USE_PNGGCCRD) && \ !(defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD)) diff --git a/png.h b/png.h index 03a2bc1f3..993ec20d3 100644 --- a/png.h +++ b/png.h @@ -1,7 +1,7 @@ /* png.h - header file for PNG reference library * - * libpng version 1.0.12beta1 - May 14, 2001 + * libpng version 1.2.0beta1 - May 6, 2001 * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -9,7 +9,7 @@ * Authors and maintainers: * 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.97, January 1998, through 1.0.12beta1 - May 14, 2001: Glenn + * libpng versions 0.97, January 1998, through 1.2.0beta1 - May 6, 2001: Glenn * See also "Contributing Authors", below. * * Note about libpng version numbers: @@ -70,10 +70,8 @@ * 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 * 1.0.11rc1 1 10011 2.1.0.11rc1 * 1.0.11 1 10011 2.1.0.11 - * 1.0.12beta1 2 10012 2.1.0.11beta1 - * 1.1.0a-f 1 10100 2.1.1.0a-f (branch abandoned) - * 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 - * 1.2.0beta3 3 10200 3.1.2.0beta3 + * 1.1.0a-f 1 10100 2.1.1.0 (branch abandoned) + * 1.2.0beta1 2 10200 2.1.2.0beta1 * * Henceforth the source version will match the shared-library major * and minor numbers; the shared-library major version number will be @@ -103,7 +101,7 @@ * If you modify libpng you may insert additional notices immediately following * this sentence. * - * libpng versions 1.0.7, July 1, 2000, through 1.0.12beta1, May 14, 2001, are + * libpng versions 1.0.7, July 1, 2000, through 1.2.0beta1, May 6, 2001, are * Copyright (c) 2000, 2001 Glenn Randers-Pehrson, and are * distributed according to the same disclaimer and license as libpng-1.0.6 * with the following individuals added to the list of Contributing Authors @@ -208,13 +206,13 @@ * Y2K compliance in libpng: * ========================= * - * May 14, 2001 + * May 6, 2001 * * Since the PNG Development group is an ad-hoc body, we can't make * an official declaration. * * This is your unofficial assurance that libpng from version 0.71 and - * upward through 1.0.12beta1 are Y2K compliant. It is my belief that earlier + * upward through 1.2.0beta1 are Y2K compliant. It is my belief that earlier * versions were also Y2K compliant. * * Libpng only has three year fields. One is a 2-byte unsigned integer @@ -270,15 +268,15 @@ */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.0.12beta1" +#define PNG_LIBPNG_VER_STRING "1.2.0beta1" #define PNG_LIBPNG_VER_SONUM 2 #define PNG_LIBPNG_VER_DLLNUM %DLLNUM% /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ #define PNG_LIBPNG_VER_MAJOR 1 -#define PNG_LIBPNG_VER_MINOR 0 -#define PNG_LIBPNG_VER_RELEASE 12 +#define PNG_LIBPNG_VER_MINOR 2 +#define PNG_LIBPNG_VER_RELEASE 0 /* This should match the numeric part of the final component of * PNG_LIBPNG_VER_STRING, omitting any leading zero: */ @@ -297,7 +295,7 @@ * 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.1 it's xxyyzz, where x=major, y=minor, z=release */ -#define PNG_LIBPNG_VER 10012 /* 1.0.12 */ +#define PNG_LIBPNG_VER 10200 /* 1.2.0 */ #ifndef PNG_VERSION_INFO_ONLY @@ -703,7 +701,6 @@ defined(PNG_READ_BACKGROUND_SUPPORTED) png_byte pcal_nparams; /* number of parameters given in pcal_params */ #endif -/* New members added in libpng-1.0.6 */ #ifdef PNG_FREE_ME_SUPPORTED png_uint_32 free_me; /* flags items libpng is responsible for freeing */ #endif @@ -1144,6 +1141,12 @@ struct png_struct_def png_charp time_buffer; /* String to hold RFC 1123 time text */ #endif +#ifdef PNG_USER_MEM_SUPPORTED + png_voidp mem_ptr; /* user supplied struct for mem functions */ + png_malloc_ptr malloc_fn; /* function for allocating memory */ + png_free_ptr free_fn; /* function for freeing memory */ +#endif + /* New members added in libpng-1.0.6 */ #ifdef PNG_FREE_ME_SUPPORTED @@ -1160,59 +1163,41 @@ struct png_struct_def png_bytep chunk_list; #endif -/* New members added in libpng-1.0.3 */ #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) png_byte rgb_to_gray_status; - /* These were changed from png_byte in libpng-1.0.6 */ png_uint_16 rgb_to_gray_red_coeff; png_uint_16 rgb_to_gray_green_coeff; png_uint_16 rgb_to_gray_blue_coeff; #endif -/* New member added in libpng-1.0.4 (renamed in 1.0.9) */ #if defined(PNG_MNG_FEATURES_SUPPORTED) || \ defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) -/* changed from png_byte to png_uint_32 at version 1.2.0 */ +/* Note to maintainer: change this to png_uint_32 at next opportunity */ png_byte mng_features_permitted; #endif -/* New member added in libpng-1.0.7 */ #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) png_fixed_point int_gamma; #endif -/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */ -#if defined(PNG_MNG_FEATURES_SUPPORTED) png_byte filter_type; -#endif -#if defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD) -/* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */ - png_uint_32 row_buf_size; -#endif - -/* New members added in libpng-1.2.0 */ #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) png_byte mmx_bitdepth_threshold; png_uint_32 mmx_rowbytes_threshold; png_uint_32 asm_flags; #endif -/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ -#ifdef PNG_USER_MEM_SUPPORTED - png_voidp mem_ptr; /* user supplied struct for mem functions */ - png_malloc_ptr malloc_fn; /* function for allocating memory */ - png_free_ptr free_fn; /* function for freeing memory */ -#endif + png_uint_32 row_buf_size; }; /* This prevents a compiler error in png_get_copyright() in png.c if png.c - and png.h are both at version 1.0.12beta1 +and png.h are both at * version 1.2.0beta1 */ -typedef png_structp version_1_0_12beta1; +typedef png_structp version_1_2_0beta1; typedef png_struct FAR * FAR * png_structpp; @@ -1263,7 +1248,6 @@ extern PNG_EXPORT(void,png_set_compression_buffer_size) /* Reset the compression stream */ extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr)); -/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ #ifdef PNG_USER_MEM_SUPPORTED extern PNG_EXPORT(png_structp,png_create_read_struct_2) PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, @@ -1294,11 +1278,8 @@ extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr)); extern PNG_EXPORT(png_infop,png_create_info_struct) PNGARG((png_structp png_ptr)); -/* Initialize the info structure (old interface - DEPRECATED) */ -extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr)); -#define png_info_init(info_ptr) png_info_init_3(&info_ptr, sizeof(png_info)); -extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr, - png_size_t png_info_struct_size)); +/* Initialize the info structure (old interface - NOT DLL EXPORTED) */ +extern void png_info_init PNGARG((png_infop info_ptr)); /* Writes all the PNG information before the image. */ extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr, @@ -2256,11 +2237,68 @@ extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp png_ptr, png_uint_32 mng_features_permitted)); #endif -/* png_mmx_support will be included unconditionally starting in version 1.2.0 */ -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) || defined(PNG_USE_PNGGCCRD) +/* Added to version 1.2.0 */ +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) +#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_READ_COMBINE_ROW 0x04 +#define PNG_ASM_FLAG_MMX_READ_INTERLACE 0x08 +#define PNG_ASM_FLAG_MMX_READ_FILTER_SUB 0x10 +#define PNG_ASM_FLAG_MMX_READ_FILTER_UP 0x20 +#define PNG_ASM_FLAG_MMX_READ_FILTER_AVG 0x40 +#define PNG_ASM_FLAG_MMX_READ_FILTER_PAETH 0x80 +#define PNG_ASM_FLAGS_INITIALIZED 0x80000000 /* not user-settable */ + +#define PNG_MMX_READ_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 ) +#define PNG_MMX_WRITE_FLAGS ( 0 ) + +#define PNG_MMX_FLAGS ( PNG_ASM_FLAG_MMX_SUPPORT_COMPILED \ + | PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU \ + | PNG_MMX_READ_FLAGS \ + | PNG_MMX_WRITE_FLAGS ) + +#define PNG_SELECT_READ 1 +#define PNG_SELECT_WRITE 2 + + +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_mmx_flagmask) + PNGARG((int flag_select, int *compilerID)); + +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_asm_flagmask) + PNGARG((int flag_select)); + +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_asm_flags) + PNGARG((png_structp png_ptr)); + +/* pngget.c */ +extern PNG_EXPORT(png_byte,png_get_mmx_bitdepth_threshold) + PNGARG((png_structp png_ptr)); + +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_mmx_rowbytes_threshold) + PNGARG((png_structp png_ptr)); + +/* pngset.c */ +extern PNG_EXPORT(void,png_set_asm_flags) + PNGARG((png_structp png_ptr, png_uint_32 asm_flags)); + +/* pngset.c */ +extern PNG_EXPORT(void,png_set_mmx_thresholds) + PNGARG((png_structp png_ptr, png_byte mmx_bitdepth_threshold, + png_uint_32 mmx_rowbytes_threshold)); + +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ + /* png.c, pnggccrd.c, or pngvcrd.c */ extern PNG_EXPORT(int,png_mmx_support) PNGARG((void)); -#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ /* Strip the prepended error numbers ("#nnn ") from error and warning * messages before passing them to the error or warning handler. */ @@ -2272,7 +2310,7 @@ extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp /* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */ #define PNG_HEADER_VERSION_STRING \ - " libpng version 1.0.12beta1 - May 14, 2001 (header)\n" + " libpng version 1.2.0beta1 - May 6, 2001 (header)\n" #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED /* With these routines we avoid an integer divide, which will be slower on @@ -2505,10 +2543,8 @@ PNG_EXTERN png_uint_16 png_get_uint_16 PNGARG((png_bytep buf)); * (old interface - DEPRECATED - use png_create_read_struct instead). */ extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr)); -#define png_read_init(png_ptr) png_read_init_3(&png_ptr, \ - PNG_LIBPNG_VER_STRING, sizeof(png_struct)); -extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size)); +#define png_read_init(png_ptr) png_read_init_2(png_ptr, \ + PNG_LIBPNG_VER_STRING, sizeof(png_struct), sizeof(png_info)); extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr, png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t png_info_size)); @@ -2517,10 +2553,8 @@ extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr, * (old interface - DEPRECATED - use png_create_write_struct instead). */ extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr)); -#define png_write_init(png_ptr) png_write_init_3(&png_ptr, \ - PNG_LIBPNG_VER_STRING, sizeof(png_struct)); -extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr, - png_const_charp user_png_ver, png_size_t png_struct_size)); +#define png_write_init(png_ptr) png_write_init_2(png_ptr, \ + PNG_LIBPNG_VER_STRING, sizeof(png_struct), sizeof(png_info)); extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr, png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t png_info_size)); @@ -2532,9 +2566,9 @@ PNG_EXTERN png_voidp png_create_struct PNGARG((int type)); PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr)); PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr - malloc_fn, png_voidp mem_ptr)); + malloc_fn)); PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr, - png_free_ptr free_fn, png_voidp mem_ptr)); + png_free_ptr free_fn)); /* Free any memory that info_ptr points to and reset struct. */ PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr, @@ -3078,6 +3112,10 @@ PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info, png_bytep row)); #endif +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) +/* png.c */ /* PRIVATE */ +PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr)); +#endif /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ #endif /* PNG_INTERNAL */ diff --git a/pngasmrd.h b/pngasmrd.h index 728fec997..db25524e3 100644 --- a/pngasmrd.h +++ b/pngasmrd.h @@ -1,6 +1,6 @@ /* pngasmrd.h - assembler version of utilities to read a PNG file * - * libpng 1.0.12beta1 - May 14, 2001 + * libpng 1.2.0beta1 - May 6, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 2001 Glenn Randers-Pehrson * diff --git a/pngconf.h b/pngconf.h index 35150785e..8c311580e 100644 --- a/pngconf.h +++ b/pngconf.h @@ -1,6 +1,6 @@ /* pngconf.h - machine configurable file for libpng * - * libpng 1.0.12beta1 - May 14, 2001 + * libpng 1.2.0beta1 - May 6, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -47,13 +47,11 @@ /* Enabled by default in 1.2.0. You can disable this if you don't need to support PNGs that are embedded in MNG datastreams */ -/* #ifndef PNG_NO_MNG_FEATURES # ifndef PNG_MNG_FEATURES_SUPPORTED # define PNG_MNG_FEATURES_SUPPORTED # endif #endif -*/ #ifndef PNG_NO_FLOATING_POINT_SUPPORTED # ifndef PNG_FLOATING_POINT_SUPPORTED @@ -590,12 +588,9 @@ # define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED #endif -/* Will be enabled in libpng-1.2.0 */ -/* #ifndef PNG_NO_ERROR_NUMBERS #define PNG_ERROR_NUMBERS_SUPPORTED #endif -*/ #ifndef PNG_NO_WRITE_FLUSH # define PNG_WRITE_FLUSH_SUPPORTED @@ -628,13 +623,12 @@ * png_get_x_offset_microns() * png_get_y_offset_microns() */ -#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED) +#ifndef PNG_NO_EASY_ACCESS # define PNG_EASY_ACCESS_SUPPORTED #endif /* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0 even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined */ -/* #if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE) # ifndef PNG_ASSEMBLER_CODE_SUPPORTED # define PNG_ASSEMBLER_CODE_SUPPORTED @@ -643,24 +637,6 @@ # define PNG_MMX_CODE_SUPPORTED # endif #endif -*/ -#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE) -# if defined(PNG_USE_PNGVCRD) || defined(PNG_USE_PNGGCCRD) -# ifndef PNG_ASSEMBLER_CODE_SUPPORTED -# define PNG_ASSEMBLER_CODE_SUPPORTED -# endif -# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) -# define PNG_MMX_CODE_SUPPORTED -# endif -# endif -#endif - -/* This will be enabled by default in libpng-1.2.0 */ -/* -#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED) -# define PNG_USER_MEM_SUPPORTED -#endif -*/ /* These are currently experimental features, define them if you want */ @@ -671,6 +647,9 @@ # define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED # endif #endif +#ifndef PNG_NO_USER_MEM +# define PNG_USER_MEM_SUPPORTED +#endif #ifndef PNG_NO_ZALLOC_ZERO # define PNG_ZALLOC_ZERO #endif diff --git a/pngerror.c b/pngerror.c index 1e6602cdc..98f8c7b18 100644 --- a/pngerror.c +++ b/pngerror.c @@ -1,7 +1,7 @@ /* pngerror.c - stub functions for i/o and memory allocation * - * libpng 1.0.12beta1 - May 14, 2001 + * libpng 1.2.0beta1 - May 6, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -152,7 +152,7 @@ png_chunk_error(png_structp png_ptr, png_const_charp message) void PNGAPI png_chunk_warning(png_structp png_ptr, png_const_charp message) { - char msg[18+64]; + char msg[16+64]; png_format_buffer(png_ptr, msg, message); png_warning(png_ptr, msg); } diff --git a/pnggccrd.c b/pnggccrd.c index 557a9434c..e0ca20302 100644 --- a/pnggccrd.c +++ b/pnggccrd.c @@ -6,7 +6,7 @@ * and http://www.intel.com/drg/pentiumII/appnotes/923/923.htm * for Intel's performance analysis of the MMX vs. non-MMX code. * - * libpng version 1.0.12beta1 - May 14, 2001 + * libpng version 1.2.0beta1 - May 6, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * Copyright (c) 1998, Intel Corporation @@ -203,9 +203,14 @@ * - "_ShiftRem.use = 40;" should have been "_ShiftRem.use = 48;" * - "psllq _ShiftRem, %%mm2" should have been "psrlq _ShiftRem, %%mm2" * + * 20010101: + * - added new png_init_mmx_flags() function (here only because it needs to + * call mmxsupport(), which should probably become global png_mmxsupport()); + * modified other MMX routines to run conditionally (png_ptr->asm_flags) + * * 20010103: * - renamed mmxsupport() to png_mmx_support(), with auto-set of mmx_supported, - * and made it public + * and made it public; moved png_init_mmx_flags() to png.c as internal func * * 20010104: * - removed dependency on png_read_filter_row_c() (C code already duplicated @@ -226,7 +231,7 @@ * x pick one version of mmxsupport() and get rid of the other * - add error messages to any remaining bogus default cases * - enable pixel_depth == 8 cases in png_read_filter_row()? (test speed) - * - add support for runtime enable/disable/query of various MMX routines + * x add support for runtime enable/disable/query of various MMX routines */ /* @@ -333,8 +338,37 @@ static int _dif; static int _patemp; // temp variables for Paeth routine static int _pbtemp; static int _pctemp; + +static void /* PRIVATE */ +png_squelch_warnings(void) +{ + _dif = _dif; + _patemp = _patemp; + _pbtemp = _pbtemp; + _pctemp = _pctemp; + _const4 = _const4; + _const6 = _const6; + _MMXLength = _MMXLength; + _mask8_0 = _mask8_0; + _mask16_1 = _mask16_1; + _mask16_0 = _mask16_0; + _mask24_2 = _mask24_2; + _mask24_1 = _mask24_1; + _mask24_0 = _mask24_0; + _mask32_3 = _mask32_3; + _mask32_2 = _mask32_2; + _mask32_1 = _mask32_1; + _mask32_0 = _mask32_0; + _mask48_5 = _mask48_5; + _mask48_4 = _mask48_4; + _mask48_3 = _mask48_3; + _mask48_2 = _mask48_2; + _mask48_1 = _mask48_1; + _mask48_0 = _mask48_0; +} #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ + static int _mmx_supported = 2; /*===========================================================================*/ @@ -370,9 +404,13 @@ png_combine_row(png_structp png_ptr, png_bytep row, int mask) { png_debug(1, "in png_combine_row (pnggccrd.c)\n"); +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) if (_mmx_supported == 2) { + /* this should have happened in png_init_mmx_flags() already */ + png_warning(png_ptr, "asm_flags may not have been initialized"); png_mmx_support(); } +#endif if (mask == 0xff) { @@ -556,7 +594,8 @@ png_combine_row(png_structp png_ptr, png_bytep row, int mask) png_bytep dstptr; #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - if ( _mmx_supported ) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && _mmx_supported */ ) { png_uint_32 len; int diff; @@ -689,7 +728,8 @@ png_combine_row(png_structp png_ptr, png_bytep row, int mask) png_bytep dstptr; #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - if ( _mmx_supported ) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && _mmx_supported */ ) { png_uint_32 len; int diff; @@ -837,7 +877,8 @@ png_combine_row(png_structp png_ptr, png_bytep row, int mask) png_bytep dstptr; #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - if ( _mmx_supported ) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && _mmx_supported */ ) { png_uint_32 len; int diff; @@ -1000,7 +1041,8 @@ png_combine_row(png_structp png_ptr, png_bytep row, int mask) png_bytep dstptr; #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - if ( _mmx_supported ) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && _mmx_supported */ ) { png_uint_32 len; int diff; @@ -1170,7 +1212,8 @@ png_combine_row(png_structp png_ptr, png_bytep row, int mask) png_bytep dstptr; #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - if ( _mmx_supported ) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && _mmx_supported */ ) { png_uint_32 len; int diff; @@ -1436,9 +1479,13 @@ png_do_read_interlace(png_structp png_ptr) png_debug(1, "in png_do_read_interlace (pnggccrd.c)\n"); +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) if (_mmx_supported == 2) { + /* this should have happened in png_init_mmx_flags() already */ + png_warning(png_ptr, "asm_flags may not have been initialized"); png_mmx_support(); } +#endif if (row != NULL && row_info != NULL) { @@ -1644,7 +1691,8 @@ png_do_read_interlace(png_structp png_ptr) /* New code by Nirav Chhatrapati - Intel Corporation */ #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - if ( _mmx_supported ) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_INTERLACE) + /* && _mmx_supported */ ) { //-------------------------------------------------------------- if (pixel_bytes == 3) @@ -2665,7 +2713,7 @@ png_do_read_interlace(png_structp png_ptr) - +#if defined(PNG_HAVE_ASSEMBLER_READ_FILTER_ROW) #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) // These variables are utilized in the functions below. They are declared @@ -2678,8 +2726,6 @@ union uAll { _HBClearMask = {0x7f7f7f7f7f7f7f7fLL}, _ActiveMask, _ActiveMask2, _ActiveMaskEnd, _ShiftBpp, _ShiftRem; - - //===========================================================================// // // // P N G _ R E A D _ F I L T E R _ R O W _ M M X _ A V G // @@ -4884,7 +4930,6 @@ png_read_filter_row_mmx_up(png_row_infop row_info, png_bytep row, /* */ /*===========================================================================*/ -#if defined(PNG_HAVE_ASSEMBLER_READ_FILTER_ROW) /* Optimized png_read_filter_row routines */ @@ -4904,6 +4949,8 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep #define UseMMX_paeth 1 // GRR: converted 20000828 if (_mmx_supported == 2) { + /* this should have happened in png_init_mmx_flags() already */ + png_warning(png_ptr, "asm_flags may not have been initialized"); png_mmx_support(); } #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ @@ -4914,13 +4961,17 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep { case 0: sprintf(filnm, "none"); break; - case 1: sprintf(filnm, "sub-%s", "MMX"); + case 1: sprintf(filnm, "sub-%s", + (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "MMX" : "x86"); break; - case 2: sprintf(filnm, "up-%s", "MMX"); + case 2: sprintf(filnm, "up-%s", + (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP)? "MMX" : "x86"); break; - case 3: sprintf(filnm, "avg-%s", "MMX"); + case 3: sprintf(filnm, "avg-%s", + (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)? "MMX" : "x86"); break; - case 4: sprintf(filnm, "Paeth-%s", "MMX"); + case 4: sprintf(filnm, "Paeth-%s", + (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)? "MMX":"x86"); break; default: sprintf(filnm, "unknw"); break; @@ -4939,9 +4990,9 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep case PNG_FILTER_VALUE_SUB: #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - if ( _mmx_supported && - (row_info->pixel_depth >= PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT) && - (row_info->rowbytes >= PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT)) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB) && + (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && + (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) { png_read_filter_row_mmx_sub(row_info, row); } @@ -4964,9 +5015,9 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep case PNG_FILTER_VALUE_UP: #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - if ( _mmx_supported && - (row_info->pixel_depth >= PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT) && - (row_info->rowbytes >= PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT)) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP) && + (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && + (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) { png_read_filter_row_mmx_up(row_info, row, prev_row); } @@ -4988,9 +5039,9 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep case PNG_FILTER_VALUE_AVG: #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - if ( _mmx_supported && - (row_info->pixel_depth >= PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT) && - (row_info->rowbytes >= PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT)) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG) && + (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && + (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) { png_read_filter_row_mmx_avg(row_info, row, prev_row); } @@ -5022,9 +5073,9 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep case PNG_FILTER_VALUE_PAETH: #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) - if ( _mmx_supported && - (row_info->pixel_depth >= PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT) && - (row_info->rowbytes >= PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT)) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH) && + (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && + (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) { png_read_filter_row_mmx_paeth(row_info, row, prev_row); } @@ -5177,4 +5228,5 @@ png_mmx_support(void) return _mmx_supported; } + #endif /* PNG_USE_PNGGCCRD */ diff --git a/pngget.c b/pngget.c index c5a6444eb..df0d63662 100644 --- a/pngget.c +++ b/pngget.c @@ -1,7 +1,7 @@ /* pngget.c - retrieval of values from info struct * - * libpng 1.0.12beta1 - May 14, 2001 + * libpng 1.2.0beta1 - May 6, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -137,7 +137,7 @@ png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) #if defined(PNG_pHYs_SUPPORTED) if (info_ptr->valid & PNG_INFO_pHYs) { - png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter"); + png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter"); if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) return (0); else return (info_ptr->y_pixels_per_unit); @@ -297,7 +297,7 @@ png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr) *.00003937); } -#if defined(PNG_pHYs_SUPPORTED) +#if defined(PNG_READ_pHYs_SUPPORTED) png_uint_32 PNGAPI png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) @@ -330,7 +330,7 @@ png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr, } return (retval); } -#endif /* PNG_pHYs_SUPPORTED */ +#endif /* PNG_READ_pHYs_SUPPORTED */ #endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ /* png_get_channels really belongs in here, too, but it's been around longer */ @@ -355,7 +355,7 @@ png_get_signature(png_structp png_ptr, png_infop info_ptr) return (NULL); } -#if defined(PNG_bKGD_SUPPORTED) +#if defined(PNG_READ_bKGD_SUPPORTED) png_uint_32 PNGAPI png_get_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p *background) @@ -371,7 +371,7 @@ png_get_bKGD(png_structp png_ptr, png_infop info_ptr, } #endif -#if defined(PNG_cHRM_SUPPORTED) +#if defined(PNG_READ_cHRM_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED png_uint_32 PNGAPI png_get_cHRM(png_structp png_ptr, png_infop info_ptr, @@ -435,7 +435,7 @@ png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, #endif #endif -#if defined(PNG_gAMA_SUPPORTED) +#if defined(PNG_READ_gAMA_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED png_uint_32 PNGAPI png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma) @@ -467,7 +467,7 @@ png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, #endif #endif -#if defined(PNG_sRGB_SUPPORTED) +#if defined(PNG_READ_sRGB_SUPPORTED) png_uint_32 PNGAPI png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent) { @@ -482,7 +482,7 @@ png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent) } #endif -#if defined(PNG_iCCP_SUPPORTED) +#if defined(PNG_READ_iCCP_SUPPORTED) png_uint_32 PNGAPI png_get_iCCP(png_structp png_ptr, png_infop info_ptr, png_charpp name, int *compression_type, @@ -504,7 +504,7 @@ png_get_iCCP(png_structp png_ptr, png_infop info_ptr, } #endif -#if defined(PNG_sPLT_SUPPORTED) +#if defined(PNG_READ_sPLT_SUPPORTED) png_uint_32 PNGAPI png_get_sPLT(png_structp png_ptr, png_infop info_ptr, png_sPLT_tpp spalettes) @@ -515,7 +515,7 @@ png_get_sPLT(png_structp png_ptr, png_infop info_ptr, } #endif -#if defined(PNG_hIST_SUPPORTED) +#if defined(PNG_READ_hIST_SUPPORTED) png_uint_32 PNGAPI png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist) { @@ -576,7 +576,7 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr, return (0); } -#if defined(PNG_oFFs_SUPPORTED) +#if defined(PNG_READ_oFFs_SUPPORTED) png_uint_32 PNGAPI png_get_oFFs(png_structp png_ptr, png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) @@ -594,7 +594,7 @@ png_get_oFFs(png_structp png_ptr, png_infop info_ptr, } #endif -#if defined(PNG_pCAL_SUPPORTED) +#if defined(PNG_READ_pCAL_SUPPORTED) png_uint_32 PNGAPI png_get_pCAL(png_structp png_ptr, png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, @@ -618,7 +618,7 @@ png_get_pCAL(png_structp png_ptr, png_infop info_ptr, } #endif -#if defined(PNG_sCAL_SUPPORTED) +#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED png_uint_32 PNGAPI png_get_sCAL(png_structp png_ptr, png_infop info_ptr, @@ -654,7 +654,7 @@ png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr, #endif #endif -#if defined(PNG_pHYs_SUPPORTED) +#if defined(PNG_READ_pHYs_SUPPORTED) png_uint_32 PNGAPI png_get_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) @@ -701,7 +701,7 @@ png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette, return (0); } -#if defined(PNG_sBIT_SUPPORTED) +#if defined(PNG_READ_sBIT_SUPPORTED) png_uint_32 PNGAPI png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit) { @@ -716,7 +716,7 @@ png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit) } #endif -#if defined(PNG_TEXT_SUPPORTED) +#if defined(PNG_READ_TEXT_SUPPORTED) png_uint_32 PNGAPI png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, int *num_text) @@ -738,7 +738,7 @@ png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, } #endif -#if defined(PNG_tIME_SUPPORTED) +#if defined(PNG_READ_tIME_SUPPORTED) png_uint_32 PNGAPI png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time) { @@ -753,7 +753,7 @@ png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time) } #endif -#if defined(PNG_tRNS_SUPPORTED) +#if defined(PNG_READ_tRNS_SUPPORTED) png_uint_32 PNGAPI png_get_tRNS(png_structp png_ptr, png_infop info_ptr, png_bytep *trans, int *num_trans, png_color_16p *trans_values) @@ -792,7 +792,7 @@ png_get_tRNS(png_structp png_ptr, png_infop info_ptr, } #endif -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) png_uint_32 PNGAPI png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr, png_unknown_chunkpp unknowns) @@ -811,7 +811,7 @@ png_get_rgb_to_gray_status (png_structp png_ptr) } #endif -#if defined(PNG_USER_CHUNKS_SUPPORTED) +#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) png_voidp PNGAPI png_get_user_chunk_ptr(png_structp png_ptr) { diff --git a/pngmem.c b/pngmem.c index 3d086bab4..19364c30b 100644 --- a/pngmem.c +++ b/pngmem.c @@ -1,7 +1,7 @@ /* pngmem.c - stub functions for memory allocation * - * libpng 1.0.12beta1 - May 14, 2001 + * libpng 1.2.0beta1 - May 6, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -27,12 +27,12 @@ png_voidp /* PRIVATE */ png_create_struct(int type) { #ifdef PNG_USER_MEM_SUPPORTED - return (png_create_struct_2(type, NULL, NULL)); + return (png_create_struct_2(type, NULL)); } /* Alternate version of png_create_struct, for use with user-defined malloc. */ png_voidp /* PRIVATE */ -png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) +png_create_struct_2(int type, png_malloc_ptr malloc_fn) { #endif /* PNG_USER_MEM_SUPPORTED */ png_size_t size; @@ -48,18 +48,9 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) #ifdef PNG_USER_MEM_SUPPORTED if(malloc_fn != NULL) { - if (mem_ptr != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - struct_ptr = (*(malloc_fn))(png_ptr, size); - } - else - struct_ptr = (*(malloc_fn))(NULL, size); - if (struct_ptr != NULL) + if ((struct_ptr = (*(malloc_fn))(NULL, size)) != NULL) png_memset(struct_ptr, 0, size); - return (struct_ptr); + return (struct_ptr); } #endif /* PNG_USER_MEM_SUPPORTED */ if ((struct_ptr = (png_voidp)farmalloc(size)) != NULL) @@ -75,13 +66,12 @@ void /* PRIVATE */ png_destroy_struct(png_voidp struct_ptr) { #ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2(struct_ptr, (png_free_ptr)NULL, (png_voidp)NULL); + png_destroy_struct_2(struct_ptr, (png_free_ptr)NULL); } /* Free memory allocated by a png_create_struct() call */ void /* PRIVATE */ -png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, - png_voidp mem_ptr) +png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn) { #endif if (struct_ptr != NULL) @@ -91,7 +81,6 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, { png_struct dummy_struct; png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; (*(free_fn))(png_ptr, struct_ptr); return; } @@ -130,12 +119,7 @@ png_malloc(png_structp png_ptr, png_uint_32 size) #ifdef PNG_USER_MEM_SUPPORTED if(png_ptr->malloc_fn != NULL) - { - ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size)); - if (ret == NULL) - png_error(png_ptr, "Out of memory!"); - return (ret); - } + return ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size)); else return png_malloc_default(png_ptr, size); } @@ -297,14 +281,14 @@ png_voidp /* PRIVATE */ png_create_struct(int type) { #ifdef PNG_USER_MEM_SUPPORTED - return (png_create_struct_2(type, NULL, NULL)); + return (png_create_struct_2(type, NULL)); } /* Allocate memory for a png_struct or a png_info. The malloc and memset can be replaced by a single call to calloc() if this is thought to improve performance noticably.*/ png_voidp /* PRIVATE */ -png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) +png_create_struct_2(int type, png_malloc_ptr malloc_fn) { #endif /* PNG_USER_MEM_SUPPORTED */ png_size_t size; @@ -320,16 +304,7 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) #ifdef PNG_USER_MEM_SUPPORTED if(malloc_fn != NULL) { - if (mem_ptr != NULL) - { - png_struct dummy_struct; - png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; - struct_ptr = (*(malloc_fn))(png_ptr, size); - } - else - struct_ptr = (*(malloc_fn))(NULL, size); - if (struct_ptr != NULL) + if ((struct_ptr = (*(malloc_fn))(NULL, size)) != NULL) png_memset(struct_ptr, 0, size); return (struct_ptr); } @@ -357,13 +332,12 @@ void /* PRIVATE */ png_destroy_struct(png_voidp struct_ptr) { #ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2(struct_ptr, (png_free_ptr)NULL, (png_voidp)NULL); + png_destroy_struct_2(struct_ptr, (png_free_ptr)NULL); } /* Free memory allocated by a png_create_struct() call */ void /* PRIVATE */ -png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, - png_voidp mem_ptr) +png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn) { #endif /* PNG_USER_MEM_SUPPORTED */ if (struct_ptr != NULL) @@ -373,7 +347,6 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, { png_struct dummy_struct; png_structp png_ptr = &dummy_struct; - png_ptr->mem_ptr=mem_ptr; (*(free_fn))(png_ptr, struct_ptr); return; } @@ -400,18 +373,15 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, png_voidp PNGAPI png_malloc(png_structp png_ptr, png_uint_32 size) { +#ifndef PNG_USER_MEM_SUPPORTED png_voidp ret; +#endif if (png_ptr == NULL || size == 0) return ((png_voidp)NULL); #ifdef PNG_USER_MEM_SUPPORTED if(png_ptr->malloc_fn != NULL) - { - ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size)); - if (ret == NULL) - png_error(png_ptr, "Out of Memory!"); - return (ret); - } + return ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size)); else return (png_malloc_default(png_ptr, size)); } @@ -437,7 +407,9 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size) #endif if (ret == NULL) + { png_error(png_ptr, "Out of Memory"); + } return (ret); } diff --git a/pngpread.c b/pngpread.c index 309fc2869..50b74ce98 100644 --- a/pngpread.c +++ b/pngpread.c @@ -1,7 +1,7 @@ /* pngpread.c - read a png file in push mode * - * libpng 1.0.12beta1 - May 14, 2001 + * libpng 1.2.0beta1 - May 6, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -796,19 +796,6 @@ png_push_process_row(png_structp png_ptr) png_read_push_finish_row(png_ptr); } } - if (png_ptr->pass == 4 && png_ptr->height <= 4) - { - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } - } - if (png_ptr->pass == 6 && png_ptr->height <= 4) - { - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } break; } case 1: @@ -995,20 +982,19 @@ png_read_push_finish_row(png_structp png_ptr) #if defined(PNG_READ_tEXt_SUPPORTED) void /* PRIVATE */ -png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) +png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) { png_error(png_ptr, "Out of place tEXt"); /* to quiet some compiler warnings */ - if(info_ptr == NULL) return; + info_ptr = info_ptr; } #ifdef PNG_MAX_MALLOC_64K png_ptr->skip_length = 0; /* This may not be necessary */ - if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */ + if (length > (png_uint_32)65535L) /* Can't hold the entire string in memory */ { png_warning(png_ptr, "tEXt chunk too large to fit in memory"); png_ptr->skip_length = length - (png_uint_32)65535L; @@ -1087,14 +1073,13 @@ png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr) #if defined(PNG_READ_zTXt_SUPPORTED) void /* PRIVATE */ -png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) +png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) { png_error(png_ptr, "Out of place zTXt"); /* to quiet some compiler warnings */ - if(info_ptr == NULL) return; + info_ptr = info_ptr; } #ifdef PNG_MAX_MALLOC_64K @@ -1200,8 +1185,8 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr) if (text == NULL) { text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out - + key_size + 1)); + (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out + + key_size + 1)); png_memcpy(text + key_size, png_ptr->zbuf, png_ptr->zbuf_size - png_ptr->zstream.avail_out); png_memcpy(text, key, key_size); @@ -1272,20 +1257,19 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr) #if defined(PNG_READ_iTXt_SUPPORTED) void /* PRIVATE */ -png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) +png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) { png_error(png_ptr, "Out of place iTXt"); /* to quiet some compiler warnings */ - if(info_ptr == NULL) return; + info_ptr = info_ptr; } #ifdef PNG_MAX_MALLOC_64K png_ptr->skip_length = 0; /* This may not be necessary */ - if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */ + if (length > (png_uint_32)65535L) /* Can't hold the entire string in memory */ { png_warning(png_ptr, "iTXt chunk too large to fit in memory"); png_ptr->skip_length = length - (png_uint_32)65535L; @@ -1383,8 +1367,7 @@ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr) * name or a critical chunk), the chunk is (currently) silently ignored. */ void /* PRIVATE */ -png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 - length) +png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_uint_32 skip=0; png_check_chunk_name(png_ptr, png_ptr->chunk_name); @@ -1395,15 +1378,14 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != HANDLE_CHUNK_ALWAYS #if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - && png_ptr->read_user_chunk_fn == NULL + && png_ptr->read_user_chunk_fn == (png_user_chunk_ptr)NULL #endif ) #endif png_chunk_error(png_ptr, "unknown critical chunk"); - /* to quiet compiler warnings about unused info_ptr */ - if (info_ptr == NULL) - return; + /* to quiet compiler warnings about unused info_ptr */ + info_ptr = info_ptr; } #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) @@ -1420,12 +1402,12 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 } #endif - png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name); + strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name); chunk.data = (png_bytep)png_malloc(png_ptr, length); png_crc_read(png_ptr, chunk.data, length); chunk.size = length; #if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - if(png_ptr->read_user_chunk_fn != NULL) + if(png_ptr->read_user_chunk_fn != (png_user_chunk_ptr)NULL) { /* callback to user unknown chunk handler */ if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0) diff --git a/pngread.c b/pngread.c index f4567c4d7..163449419 100644 --- a/pngread.c +++ b/pngread.c @@ -1,7 +1,7 @@ /* pngread.c - read a PNG file * - * libpng 1.0.12beta1 - May 14, 2001 + * libpng 1.2.0beta1 - May 6, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -46,7 +46,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, png_debug(1, "in png_create_read_struct\n"); #ifdef PNG_USER_MEM_SUPPORTED if ((png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, - (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr)) == NULL) + (png_malloc_ptr)malloc_fn)) == NULL) #else if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL) #endif @@ -54,6 +54,10 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, return (png_structp)NULL; } +#ifdef PNG_ASSEMBLER_CODE_SUPPORTED + png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ +#endif + #ifdef PNG_SETJMP_SUPPORTED #ifdef USE_FAR_KEYWORD if (setjmp(jmpbuf)) @@ -92,7 +96,6 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, * only check the first digit. */ if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || - (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || (user_png_ver[0] == '0' && user_png_ver[2] < '9')) { png_error(png_ptr, @@ -100,17 +103,15 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, } /* Libpng 1.0.6 was not binary compatible, due to insertion of the - info_ptr->free_me member. Libpng-1.0.1 and earlier were not - compatible due to insertion of the user transform function. Note - to maintainer: this test can be removed from version 1.2.0 and - beyond because the previous test would have already rejected it. */ + info_ptr->free_me member. Note to maintainer: this test can be + removed from version 2.0.0 and beyond because the previous test + would have already rejected it. */ - if (user_png_ver[0] == '1' && user_png_ver[2] == '0' && - (user_png_ver[4] < '2' || user_png_ver[4] == '6') && - user_png_ver[5] == '\0') + if (user_png_ver[4] == '6' && user_png_ver[2] == '0' && + user_png_ver[0] == '1' && user_png_ver[5] == '\0') { png_error(png_ptr, - "Application must be recompiled; versions <= 1.0.6 were incompatible"); + "Application must be recompiled; version 1.0.6 was incompatible"); } } @@ -147,42 +148,18 @@ void PNGAPI png_read_init(png_structp png_ptr) { /* We only come here via pre-1.0.7-compiled applications */ - png_read_init_2(png_ptr, "1.0.0", 0, 0); + png_read_init_2(png_ptr, "1.0.0", 10000, 10000); } -#undef png_read_init_2 void PNGAPI 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) -{ - /* We only come here via pre-1.0.12-compiled applications */ - if(sizeof(png_struct) > png_struct_size) - { - png_ptr->error_fn=(png_error_ptr)NULL; - png_error(png_ptr, - "The png struct allocated by the application for reading is too small."); - } - if(sizeof(png_info) > png_info_size) - { - png_ptr->error_fn=(png_error_ptr)NULL; - png_error(png_ptr, - "The info struct allocated by application for reading is too small."); - } - png_read_init_3(&png_ptr, user_png_ver, png_struct_size); -} - -void PNGAPI -png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size) { #ifdef PNG_SETJMP_SUPPORTED jmp_buf tmp_jmp; /* to save current jump buffer */ #endif int i=0; - - png_structp png_ptr=*ptr_ptr; - do { if(user_png_ver[i] != png_libpng_ver[i]) @@ -190,31 +167,35 @@ png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, #ifdef PNG_LEGACY_SUPPORTED png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; #else - png_ptr->warning_fn=(png_error_ptr)NULL; - png_warning(png_ptr, - "Application uses deprecated png_read_init() and should be recompiled."); - break; + png_ptr->error_fn=(png_error_ptr)NULL; + png_error(png_ptr, + "Application uses deprecated png_read_init() and must be recompiled."); #endif } } while (png_libpng_ver[i++]); - png_debug(1, "in png_read_init_3\n"); + if(sizeof(png_struct) > png_struct_size || + sizeof(png_info) > png_info_size) + { + png_ptr->error_fn=(png_error_ptr)NULL; + png_error(png_ptr, + "Application and library have different sized structs. Please recompile."); + } + + png_debug(1, "in png_read_init_2\n"); #ifdef PNG_SETJMP_SUPPORTED /* save jump buffer and error functions */ png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf)); #endif - if(sizeof(png_struct) > png_struct_size) - { - png_destroy_struct(png_ptr); - *ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); - png_ptr = *ptr_ptr; - } - /* reset all variables to 0 */ png_memset(png_ptr, 0, sizeof (png_struct)); +#ifdef PNG_ASSEMBLER_CODE_SUPPORTED + png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ +#endif + #ifdef PNG_SETJMP_SUPPORTED /* restore jump buffer */ png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf)); @@ -742,7 +723,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) * not called png_set_interlace_handling(), the display_row buffer will * be ignored, so pass NULL to it. * - * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.12beta1 + * [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.0beta1 */ void PNGAPI @@ -791,7 +772,7 @@ png_read_rows(png_structp png_ptr, png_bytepp row, * only call this function once. If you desire to have an image for * each pass of a interlaced image, use png_read_rows() instead. * - * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.12beta1 + * [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.0beta1 */ void PNGAPI png_read_image(png_structp png_ptr, png_bytepp image) @@ -1021,7 +1002,6 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_infop info_ptr = NULL, end_info_ptr = NULL; #ifdef PNG_USER_MEM_SUPPORTED png_free_ptr free_fn = NULL; - png_voidp mem_ptr = NULL; #endif png_debug(1, "in png_destroy_read_struct\n"); @@ -1037,7 +1017,6 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp 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); @@ -1049,8 +1028,7 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, #endif #ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); + png_destroy_struct_2((png_voidp)info_ptr, free_fn); #else png_destroy_struct((png_voidp)info_ptr); #endif @@ -1063,8 +1041,7 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_free_data(png_ptr, end_info_ptr, PNG_FREE_TEXT, -1); #endif #ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)end_info_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); + png_destroy_struct_2((png_voidp)end_info_ptr, free_fn); #else png_destroy_struct((png_voidp)end_info_ptr); #endif @@ -1074,8 +1051,7 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, if (png_ptr != NULL) { #ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); + png_destroy_struct_2((png_voidp)png_ptr, free_fn); #else png_destroy_struct((png_voidp)png_ptr); #endif @@ -1084,7 +1060,7 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, } /* free all memory used by the read (old method) */ -void /* PRIVATE */ +void PNGAPI png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr) { #ifdef PNG_SETJMP_SUPPORTED @@ -1337,7 +1313,7 @@ png_read_png(png_structp png_ptr, png_infop info_ptr, /* Optional call to gamma correct and add the background to the palette * and update info structure. REQUIRED if you are expecting libpng to - * update the palette for you (i.e., you selected such a transform above). + * update the palette for you (ie you selected such a transform above). */ png_read_update_info(png_ptr, info_ptr); @@ -1349,15 +1325,13 @@ png_read_png(png_structp png_ptr, png_infop info_ptr, if(info_ptr->row_pointers == NULL) { info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr, - info_ptr->height * sizeof(png_bytep)); + info_ptr->height * sizeof(png_bytep)); #ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_ROWS; #endif for (row = 0; row < (int)info_ptr->height; row++) - { - info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr, + info_ptr->row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); - } } png_read_image(png_ptr, info_ptr->row_pointers); @@ -1366,7 +1340,7 @@ png_read_png(png_structp png_ptr, png_infop info_ptr, /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ png_read_end(png_ptr, info_ptr); - if(transforms == 0 || params == NULL) + if(transforms == 0 || params == (voidp)NULL) /* quiet compiler warnings */ return; } diff --git a/pngrio.c b/pngrio.c index 006d72e3e..dd62580eb 100644 --- a/pngrio.c +++ b/pngrio.c @@ -1,7 +1,7 @@ /* pngrio.c - functions for data input * - * libpng 1.0.12beta1 - May 14, 2001 + * libpng 1.2.0beta1 - May 6, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -26,7 +26,7 @@ void /* PRIVATE */ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { - png_debug1(4,"reading %d bytes\n", (int)length); + png_debug1(4,"reading %d bytes\n", length); if (png_ptr->read_data_fn != NULL) (*(png_ptr->read_data_fn))(png_ptr, data, length); else diff --git a/pngrtran.c b/pngrtran.c index e2d46ff4e..279e81cd8 100644 --- a/pngrtran.c +++ b/pngrtran.c @@ -1,7 +1,7 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * libpng 1.0.12beta1 - May 14, 2001 + * libpng 1.2.0beta1 - May 6, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/pngrutil.c b/pngrutil.c index 311f81ee9..dd08ff677 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -1,7 +1,7 @@ /* pngrutil.c - utilities to read a PNG file * - * libpng 1.0.12beta1 - May 14, 2001 + * libpng 1.2.0beta1 - May 6, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -30,7 +30,7 @@ __inline double strtod(const char *nptr, char **endptr) MultiByteToWideChar(CP_ACP, 0, nptr, -1, str, len); result = wcstod(str, &end); len = WideCharToMultiByte(CP_ACP, 0, end, -1, NULL, 0, NULL, NULL); - *endptr = (char *)nptr + (png_strlen(nptr) - len + 1); + *endptr = (char *)nptr + (strlen(nptr) - len + 1); free(str); } return result; @@ -220,7 +220,7 @@ png_decompress_chunk(png_structp png_ptr, int comp_type, png_ptr->zbuf_size - png_ptr->zstream.avail_out; text = (png_charp)png_malloc(png_ptr, text_size + 1); png_memcpy(text + prefix_size, png_ptr->zbuf, - text_size - prefix_size); + text_size - prefix_size); png_memcpy(text, chunkdata, prefix_size); *(text + text_size) = 0x00; } @@ -332,6 +332,59 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) filter_type = buf[11]; interlace_type = buf[12]; + /* check for width and height valid values */ + if (width == 0 || width > PNG_MAX_UINT || height == 0 || + height > PNG_MAX_UINT) + png_error(png_ptr, "Invalid image size in IHDR"); + + /* check other values */ + if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 && + bit_depth != 8 && bit_depth != 16) + png_error(png_ptr, "Invalid bit depth in IHDR"); + + if (color_type < 0 || color_type == 1 || + color_type == 5 || color_type > 6) + png_error(png_ptr, "Invalid color type in IHDR"); + + if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) || + ((color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_GRAY_ALPHA || + color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8)) + png_error(png_ptr, "Invalid color type/bit depth combination in IHDR"); + + if (interlace_type >= PNG_INTERLACE_LAST) + png_error(png_ptr, "Unknown interlace method in IHDR"); + + if (compression_type != PNG_COMPRESSION_TYPE_BASE) + png_error(png_ptr, "Unknown compression method in IHDR"); + +#if defined(PNG_MNG_FEATURES_SUPPORTED) + /* Accept filter_method 64 (intrapixel differencing) only if + * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and + * 2. Libpng did not read a PNG signature (this filter_method is only + * used in PNG datastreams that are embedded in MNG datastreams) and + * 3. The application called png_permit_mng_features with a mask that + * included PNG_FLAG_MNG_FILTER_64 and + * 4. The filter_method is 64 and + * 5. The color_type is RGB or RGBA + */ + if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted) + png_warning(png_ptr,"MNG features are not allowed in a PNG datastream\n"); + if(filter_type != PNG_FILTER_TYPE_BASE) + { + if(!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && + (filter_type == PNG_INTRAPIXEL_DIFFERENCING) && + ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && + (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_RGB_ALPHA))) + png_error(png_ptr, "Unknown filter method in IHDR"); + if(png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) + png_warning(png_ptr, "Invalid filter method in IHDR"); + } +#else + if(filter_type != PNG_FILTER_TYPE_BASE) + png_error(png_ptr, "Unknown filter method in IHDR"); +#endif /* set internal variables */ png_ptr->width = width; @@ -339,9 +392,7 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_ptr->bit_depth = (png_byte)bit_depth; png_ptr->interlaced = (png_byte)interlace_type; png_ptr->color_type = (png_byte)color_type; -#if defined(PNG_MNG_FEATURES_SUPPORTED) png_ptr->filter_type = (png_byte)filter_type; -#endif /* find number of channels */ switch (png_ptr->color_type) @@ -398,13 +449,6 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_ptr->mode |= PNG_HAVE_PLTE; - if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR)) - { - png_warning(png_ptr, - "Ignoring PLTE chunk in grayscale PNG"); - png_crc_finish(png_ptr, length); - return; - } #if !defined(PNG_READ_OPT_PLTE_SUPPORTED) if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) { @@ -582,11 +626,7 @@ png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) igamma = (png_fixed_point)png_get_uint_32(buf); /* check for zero gamma */ if (igamma == 0) - { - png_warning(png_ptr, - "Ignoring gAMA chunk with gamma=0"); - return; - } + return; #if defined(PNG_READ_sRGB_SUPPORTED) if (info_ptr->valid & PNG_INFO_sRGB) @@ -1087,7 +1127,7 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) chunkdata = (png_bytep)png_malloc(png_ptr, length + 1); slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); + png_crc_read(png_ptr, chunkdata, slength); if (png_crc_finish(png_ptr, skip)) { @@ -1117,8 +1157,7 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) if (data_length % entry_size) { png_free(png_ptr, chunkdata); - png_warning(png_ptr, "sPLT chunk has bad length"); - return; + png_error(png_ptr, "sPLT chunk has bad length"); } new_palette.nentries = data_length / entry_size; @@ -1675,8 +1714,8 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) } #else #ifdef PNG_FIXED_POINT_SUPPORTED - swidth = (png_charp)png_malloc(png_ptr, png_strlen(ep) + 1); - png_memcpy(swidth, ep, (png_size_t)png_strlen(ep)); + swidth = (png_charp)png_malloc(png_ptr, strlen(ep) + 1); + png_memcpy(swidth, ep, (png_size_t)strlen(ep)); #endif #endif @@ -1693,8 +1732,8 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) } #else #ifdef PNG_FIXED_POINT_SUPPORTED - sheight = (png_charp)png_malloc(png_ptr, png_strlen(ep) + 1); - png_memcpy(sheight, ep, (png_size_t)png_strlen(ep)); + sheight = (png_charp)png_malloc(png_ptr, strlen(ep) + 1); + png_memcpy(sheight, ep, (png_size_t)strlen(ep)); #endif #endif @@ -1867,7 +1906,7 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) #endif chunkdata = (png_charp)png_malloc(png_ptr, length + 1); - slength = (png_size_t)length; + slength = (png_size_t)length; png_crc_read(png_ptr, (png_bytep)chunkdata, slength); if (png_crc_finish(png_ptr, 0)) { @@ -2041,7 +2080,7 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != HANDLE_CHUNK_ALWAYS #if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - && png_ptr->read_user_chunk_fn == NULL + && png_ptr->read_user_chunk_fn == (png_user_chunk_ptr)NULL #endif ) #endif @@ -2061,12 +2100,12 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) length = (png_uint_32)65535L; } #endif - png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name); + strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name); chunk.data = (png_bytep)png_malloc(png_ptr, length); - chunk.size = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunk.data, length); + png_crc_read(png_ptr, chunk.data, length); + chunk.size = length; #if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - if(png_ptr->read_user_chunk_fn != NULL) + if(png_ptr->read_user_chunk_fn != (png_user_chunk_ptr)NULL) { /* callback to user unknown chunk handler */ if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0) @@ -2329,10 +2368,6 @@ png_combine_row(png_structp png_ptr, png_bytep row, int mask) #ifdef PNG_READ_INTERLACING_SUPPORTED #ifndef PNG_HAVE_ASSEMBLER_READ_INTERLACE /* else in pngvcrd.c, pnggccrd.c */ -/* OLD pre-1.0.9 interface: -void png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, - png_uint_32 transformations) - */ void /* PRIVATE */ png_do_read_interlace(png_structp png_ptr) { @@ -2968,9 +3003,6 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) png_error(png_ptr, "This image requires a row greater than 64KB"); #endif png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, row_bytes); -#if defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD) - png_ptr->row_buf_size = row_bytes; -#endif #ifdef PNG_MAX_MALLOC_64K if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L) diff --git a/pngset.c b/pngset.c index 4fb6c0e97..f851fac7e 100644 --- a/pngset.c +++ b/pngset.c @@ -1,7 +1,7 @@ /* pngset.c - storage of image information into info struct * - * libpng 1.0.12beta1 - May 14, 2001 + * libpng 1.2.0beta1 - May 6, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -109,10 +109,9 @@ png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) info_ptr->int_gamma = (int)(file_gamma*100000.+.5); #endif info_ptr->valid |= PNG_INFO_gAMA; - if(file_gamma == 0.0) - png_warning(png_ptr, "Setting gamma=0"); } #endif +#endif void PNGAPI png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point int_gamma) @@ -128,10 +127,7 @@ png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point info_ptr->int_gamma = int_gamma; #endif info_ptr->valid |= PNG_INFO_gAMA; - if(int_gamma == 0) - png_warning(png_ptr, "Setting gamma=0"); } -#endif #if defined(PNG_hIST_SUPPORTED) void PNGAPI @@ -143,11 +139,8 @@ png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist) if (png_ptr == NULL || info_ptr == NULL) return; if (info_ptr->num_palette == 0) - { png_warning(png_ptr, - "Palette size 0, hIST allocation skipped."); - return; - } + "Palette size 0, hIST allocation skipped."); #ifdef PNG_FREE_ME_SUPPORTED png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); @@ -179,61 +172,6 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr, if (png_ptr == NULL || info_ptr == NULL) return; - /* check for width and height valid values */ - if (width == 0 || height == 0) - png_error(png_ptr, "Image width or height is zero in IHDR"); - if (width > PNG_MAX_UINT || height > PNG_MAX_UINT) - png_error(png_ptr, "Invalid image size in IHDR"); - - /* check other values */ - if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 && - bit_depth != 8 && bit_depth != 16) - png_error(png_ptr, "Invalid bit depth in IHDR"); - - if (color_type < 0 || color_type == 1 || - color_type == 5 || color_type > 6) - png_error(png_ptr, "Invalid color type in IHDR"); - - if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) || - ((color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8)) - png_error(png_ptr, "Invalid color type/bit depth combination in IHDR"); - - if (interlace_type >= PNG_INTERLACE_LAST) - png_error(png_ptr, "Unknown interlace method in IHDR"); - - if (compression_type != PNG_COMPRESSION_TYPE_BASE) - png_error(png_ptr, "Unknown compression method in IHDR"); - -#if defined(PNG_MNG_FEATURES_SUPPORTED) - /* Accept filter_method 64 (intrapixel differencing) only if - * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and - * 2. Libpng did not read a PNG signature (this filter_method is only - * used in PNG datastreams that are embedded in MNG datastreams) and - * 3. The application called png_permit_mng_features with a mask that - * included PNG_FLAG_MNG_FILTER_64 and - * 4. The filter_method is 64 and - * 5. The color_type is RGB or RGBA - */ - if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted) - png_warning(png_ptr,"MNG features are not allowed in a PNG datastream\n"); - if(filter_type != PNG_FILTER_TYPE_BASE) - { - if(!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (filter_type == PNG_INTRAPIXEL_DIFFERENCING) && - ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && - (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA))) - png_error(png_ptr, "Unknown filter method in IHDR"); - if(png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) - png_warning(png_ptr, "Invalid filter method in IHDR"); - } -#else - if(filter_type != PNG_FILTER_TYPE_BASE) - png_error(png_ptr, "Unknown filter method in IHDR"); -#endif - info_ptr->width = width; info_ptr->height = height; info_ptr->bit_depth = (png_byte)bit_depth; @@ -310,7 +248,6 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr, info_ptr->pcal_params = (png_charpp)png_malloc(png_ptr, (png_uint_32)((nparams + 1) * sizeof(png_charp))); - info_ptr->pcal_params[nparams] = NULL; for (i = 0; i < nparams; i++) @@ -365,7 +302,7 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr, length = png_strlen(sheight) + 1; png_debug1(3, "allocating unit for info (%d bytes)\n", length); - info_ptr->scal_s_height = (png_charp)png_malloc(png_ptr, length); + info_ptr->scal_s_width = (png_charp)png_malloc(png_ptr, length); png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length); info_ptr->valid |= PNG_INFO_sCAL; @@ -412,7 +349,7 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr, #endif png_ptr->palette = (png_colorp)png_zalloc(png_ptr, (uInt)num_palette, sizeof (png_color)); - png_memcpy(png_ptr->palette, palette, num_palette * sizeof (png_color)); + memcpy(png_ptr->palette, palette, num_palette * sizeof (png_color)); info_ptr->palette = png_ptr->palette; info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; @@ -535,9 +472,9 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr, if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL) return; - new_iccp_name = (png_charp)png_malloc(png_ptr, png_strlen(name)+1); - png_strcpy(new_iccp_name, name); - new_iccp_profile = (png_charp)png_malloc(png_ptr, proflen); + new_iccp_name = png_malloc(png_ptr, png_strlen(name)+1); + strcpy(new_iccp_name, name); + new_iccp_profile = png_malloc(png_ptr, proflen); png_memcpy(new_iccp_profile, profile, (png_size_t)proflen); png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0); @@ -606,7 +543,7 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, png_size_t lang_len,lang_key_len; png_textp textp = &(info_ptr->text[info_ptr->num_text]); - if (text_ptr[i].key == NULL) + if (text_ptr[i].key == (png_charp)NULL) continue; key_len = png_strlen(text_ptr[i].key); @@ -620,11 +557,11 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, #ifdef PNG_iTXt_SUPPORTED { /* set iTXt data */ - if (text_ptr[i].key != NULL) + if (text_ptr[i].key != (png_charp)NULL) lang_len = png_strlen(text_ptr[i].lang); else lang_len = 0; - if (text_ptr[i].lang_key != NULL) + if (text_ptr[i].lang_key != (png_charp)NULL) lang_key_len = png_strlen(text_ptr[i].lang_key); else lang_key_len = 0; @@ -636,7 +573,7 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, } #endif - if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0') + if (text_ptr[i].text == (png_charp)NULL || text_ptr[i].text[0] == '\0') { text_length = 0; #ifdef PNG_iTXt_SUPPORTED @@ -654,9 +591,8 @@ png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, textp->key = (png_charp)png_malloc(png_ptr, (png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4)); - png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n", - (png_uint_32)(key_len + lang_len + lang_key_len + text_length + 4), - (int)textp->key); + png_debug2(2, "Allocated %d bytes at %x in png_set_text\n", + key_len + lang_len + lang_key_len + text_length + 4, (int)textp->key); png_memcpy(textp->key, text_ptr[i].key, (png_size_t)(key_len)); @@ -740,9 +676,8 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr, #ifdef PNG_FREE_ME_SUPPORTED png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); #endif - png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr, - num_trans); - png_memcpy(info_ptr->trans, trans, num_trans); + png_ptr->trans = info_ptr->trans = png_malloc(png_ptr, num_trans); + memcpy(info_ptr->trans, trans, num_trans); #ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_TRNS; #else @@ -784,12 +719,12 @@ png_set_sPLT(png_structp png_ptr, png_sPLT_tp from = entries + i; to->name = (png_charp)png_malloc(png_ptr, - png_strlen(from->name) + 1); + png_strlen(from->name) + 1); png_strcpy(to->name, from->name); to->entries = (png_sPLT_entryp)png_malloc(png_ptr, - from->nentries * sizeof(png_sPLT_t)); + from->nentries * sizeof(png_sPLT_t)); png_memcpy(to->entries, from->entries, - from->nentries * sizeof(png_sPLT_t)); + from->nentries * sizeof(png_sPLT_t)); to->nentries = from->nentries; to->depth = from->depth; } @@ -803,7 +738,7 @@ png_set_sPLT(png_structp png_ptr, } #endif /* PNG_sPLT_SUPPORTED */ -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) void PNGAPI png_set_unknown_chunks(png_structp png_ptr, png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns) @@ -905,8 +840,8 @@ png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep if (chunk_list == NULL) return; old_num_chunks=png_ptr->num_chunk_list; - new_list=(png_bytep)png_malloc(png_ptr,5*(num_chunks+old_num_chunks)); - if(png_ptr->chunk_list != NULL) + new_list=png_malloc(png_ptr,5*(num_chunks+old_num_chunks)); + if(png_ptr->chunk_list != (png_bytep)NULL) { png_memcpy(new_list, png_ptr->chunk_list, 5*old_num_chunks); png_free(png_ptr, png_ptr->chunk_list); @@ -948,6 +883,7 @@ png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers) info_ptr->row_pointers = row_pointers; if(row_pointers) info_ptr->valid |= PNG_INFO_IDAT; + } #endif @@ -958,6 +894,8 @@ png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size) png_free(png_ptr, png_ptr->zbuf); png_ptr->zbuf_size = (png_size_t)size; png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size); + if(!png_ptr->zbuf) + png_error(png_ptr,"Unable to malloc zbuf"); png_ptr->zstream.next_out = png_ptr->zbuf; png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; } diff --git a/pngtest.c b/pngtest.c index daaa6b8e4..09590fec4 100644 --- a/pngtest.c +++ b/pngtest.c @@ -1,7 +1,7 @@ /* pngtest.c - a simple test program to test libpng * - * libpng 1.0.12beta1 - May 14, 2001 + * libpng 1.2.0beta1 - May 6, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -51,20 +51,16 @@ #endif #if defined(PNG_NO_STDIO) -# if defined(_WIN32_WCE) - typedef HANDLE png_FILE_p; -# else - typedef FILE * png_FILE_p; -# endif +#if defined(_WIN32_WCE) +typedef HANDLE png_FILE_p; +#else +typedef FILE * png_FILE_p; +#endif #endif /* Makes pngtest verbose so we can find problems (needs to be before png.h) */ #ifndef PNG_DEBUG -# define PNG_DEBUG 0 -#endif - -#if !PNG_DEBUG -# define SINGLE_ROWBUF_ALLOC /* makes buffer overruns easier to nail */ +#define PNG_DEBUG 0 #endif /* Turn on CPU timing @@ -283,7 +279,7 @@ pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) if (check != length) { - png_error(png_ptr, "Read Error!"); + png_error(png_ptr, "Read Error"); } } #else @@ -488,15 +484,14 @@ png_debug_malloc(png_structp png_ptr, png_uint_32 size) /* This calls the library allocator twice, once to get the requested buffer and once to get a new free list entry. */ { - memory_infop pinfo = (memory_infop)png_malloc_default(png_ptr, - sizeof *pinfo); + memory_infop pinfo = png_malloc_default(png_ptr, sizeof *pinfo); pinfo->size = size; current_allocation += size; total_allocation += size; num_allocations ++; if (current_allocation > maximum_allocation) maximum_allocation = current_allocation; - pinfo->pointer = (png_voidp)png_malloc_default(png_ptr, size); + pinfo->pointer = png_malloc_default(png_ptr, size); pinfo->next = pinformation; pinformation = pinfo; /* Make sure the caller isn't assuming zeroed memory. */ @@ -538,7 +533,7 @@ png_debug_free(png_structp png_ptr, png_voidp ptr) fprintf(STDERR, "Duplicate free of memory\n"); /* We must free the list element too, but first kill the memory that is to be freed. */ - png_memset(ptr, 0x55, pinfo->size); + memset(ptr, 0x55, pinfo->size); png_free_default(png_ptr, pinfo); pinfo=NULL; break; @@ -569,17 +564,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) { static png_FILE_p fpin; static png_FILE_p fpout; /* "static" prevents setjmp corruption */ - png_structp read_ptr; - png_infop read_info_ptr, end_info_ptr; -#ifdef PNG_WRITE_SUPPORTED - png_structp write_ptr; - png_infop write_info_ptr; - png_infop write_end_info_ptr; -#else - png_structp write_ptr = NULL; - png_infop write_info_ptr = NULL; - png_infop write_end_info_ptr = NULL; -#endif + png_structp read_ptr, write_ptr; + png_infop read_info_ptr, write_info_ptr, end_info_ptr, write_end_info_ptr; png_bytep row_buf; png_uint_32 y; png_uint_32 width, height; @@ -634,7 +620,6 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) png_set_error_fn(read_ptr, (png_voidp)inname, pngtest_error, pngtest_warning); #endif -#ifdef PNG_WRITE_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED write_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, (png_error_ptr)NULL, (png_error_ptr)NULL, (png_voidp)NULL, @@ -646,14 +631,13 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) #if defined(PNG_NO_STDIO) png_set_error_fn(write_ptr, (png_voidp)inname, pngtest_error, pngtest_warning); -#endif #endif png_debug(0, "Allocating read_info, write_info and end_info structures\n"); read_info_ptr = png_create_info_struct(read_ptr); - end_info_ptr = png_create_info_struct(read_ptr); -#ifdef PNG_WRITE_SUPPORTED write_info_ptr = png_create_info_struct(write_ptr); + end_info_ptr = png_create_info_struct(read_ptr); write_end_info_ptr = png_create_info_struct(write_ptr); +#ifdef PNG_USER_MEM_SUPPORTED #endif #ifdef PNG_SETJMP_SUPPORTED @@ -666,10 +650,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) { fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname); png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); -#ifdef PNG_WRITE_SUPPORTED png_destroy_info_struct(write_ptr, &write_end_info_ptr); png_destroy_write_struct(&write_ptr, &write_info_ptr); -#endif FCLOSE(fpin); FCLOSE(fpout); return (1); @@ -678,7 +660,6 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) png_memcpy(png_jmpbuf(read_ptr),jmpbuf,sizeof(jmp_buf)); #endif -#ifdef PNG_WRITE_SUPPORTED png_debug(0, "Setting jmpbuf for write struct\n"); #ifdef USE_FAR_KEYWORD if (setjmp(jmpbuf)) @@ -689,9 +670,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) fprintf(STDERR, "%s -> %s: libpng write error\n", inname, outname); png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); png_destroy_info_struct(write_ptr, &write_end_info_ptr); -#ifdef PNG_WRITE_SUPPORTED png_destroy_write_struct(&write_ptr, &write_info_ptr); -#endif FCLOSE(fpin); FCLOSE(fpout); return (1); @@ -699,38 +678,29 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) #ifdef USE_FAR_KEYWORD png_memcpy(png_jmpbuf(write_ptr),jmpbuf,sizeof(jmp_buf)); #endif -#endif #endif png_debug(0, "Initializing input and output streams\n"); #if !defined(PNG_NO_STDIO) png_init_io(read_ptr, fpin); -# ifdef PNG_WRITE_SUPPORTED png_init_io(write_ptr, fpout); -# endif #else png_set_read_fn(read_ptr, (png_voidp)fpin, pngtest_read_data); -# ifdef PNG_WRITE_SUPPORTED png_set_write_fn(write_ptr, (png_voidp)fpout, pngtest_write_data, -# if defined(PNG_WRITE_FLUSH_SUPPORTED) +#if defined(PNG_WRITE_FLUSH_SUPPORTED) pngtest_flush); -# else +#else NULL); -# endif -# endif +#endif #endif if(status_dots_requested == 1) { -#ifdef PNG_WRITE_SUPPORTED png_set_write_status_fn(write_ptr, write_row_callback); -#endif png_set_read_status_fn(read_ptr, read_row_callback); } else { -#ifdef PNG_WRITE_SUPPORTED png_set_write_status_fn(write_ptr, NULL); -#endif png_set_read_status_fn(read_ptr, NULL); } @@ -1014,29 +984,32 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) } #endif -#ifdef PNG_WRITE_SUPPORTED png_debug(0, "\nWriting info struct\n"); /* If we wanted, we could write info in two steps: png_write_info_before_PLTE(write_ptr, write_info_ptr); */ png_write_info(write_ptr, write_info_ptr); -#endif -#ifdef SINGLE_ROWBUF_ALLOC - png_debug(0, "\nAllocating row buffer..."); + png_debug(0, "\nAllocating row buffer \n"); row_buf = (png_bytep)png_malloc(read_ptr, png_get_rowbytes(read_ptr, read_info_ptr)); - png_debug1(0, "0x%08lx\n\n", (unsigned long)row_buf); -#endif /* SINGLE_ROWBUF_ALLOC */ + if (row_buf == NULL) + { + fprintf(STDERR, "No memory to allocate row buffer\n"); + png_destroy_read_struct(&read_ptr, &read_info_ptr, (png_infopp)NULL); + png_destroy_info_struct(write_ptr, &write_end_info_ptr); + png_destroy_write_struct(&write_ptr, &write_info_ptr); + FCLOSE(fpin); + FCLOSE(fpout); + return (1); + } png_debug(0, "Writing row data\n"); #if defined(PNG_READ_INTERLACING_SUPPORTED) || \ defined(PNG_WRITE_INTERLACING_SUPPORTED) num_pass = png_set_interlace_handling(read_ptr); -# ifdef PNG_WRITE_SUPPORTED png_set_interlace_handling(write_ptr); -# endif #else num_pass=1; #endif @@ -1051,16 +1024,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) png_debug1(0, "Writing row data for pass %d\n",pass); for (y = 0; y < height; y++) { -#ifndef SINGLE_ROWBUF_ALLOC - png_debug2(0, "\nAllocating row buffer (pass %d, y = %ld)...", pass,y); - row_buf = (png_bytep)png_malloc(read_ptr, - png_get_rowbytes(read_ptr, read_info_ptr)); - png_debug2(0, "0x%08lx (%ld bytes)\n", (unsigned long)row_buf, - png_get_rowbytes(read_ptr, read_info_ptr)); -#endif /* !SINGLE_ROWBUF_ALLOC */ png_read_rows(read_ptr, (png_bytepp)&row_buf, (png_bytepp)NULL, 1); - -#ifdef PNG_WRITE_SUPPORTED #ifdef PNGTEST_TIMING t_stop = (float)clock(); t_decode += (t_stop - t_start); @@ -1072,12 +1036,6 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) t_encode += (t_stop - t_start); t_start = t_stop; #endif -#endif /* PNG_WRITE_SUPPORTED */ - -#ifndef SINGLE_ROWBUF_ALLOC - png_debug2(0, "Freeing row buffer (pass %d, y = %ld)\n\n", pass, y); - png_free(read_ptr, row_buf); -#endif /* !SINGLE_ROWBUF_ALLOC */ } } @@ -1140,9 +1098,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) } } #endif -#ifdef PNG_WRITE_SUPPORTED png_write_end(write_ptr, write_end_info_ptr); -#endif #ifdef PNG_EASY_ACCESS_SUPPORTED if(verbose) @@ -1156,20 +1112,11 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) #endif png_debug(0, "Destroying data structs\n"); -#ifdef SINGLE_ROWBUF_ALLOC - png_debug(1, "destroying row_buf for read_ptr\n"); png_free(read_ptr, row_buf); row_buf=NULL; -#endif /* SINGLE_ROWBUF_ALLOC */ - png_debug(1, "destroying read_ptr, read_info_ptr, end_info_ptr\n"); png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); -#ifdef PNG_WRITE_SUPPORTED - png_debug(1, "destroying write_end_info_ptr\n"); png_destroy_info_struct(write_ptr, &write_end_info_ptr); - png_debug(1, "destroying write_ptr, write_info_ptr\n"); png_destroy_write_struct(&write_ptr, &write_info_ptr); -#endif - png_debug(0, "Destruction complete.\n"); FCLOSE(fpin); FCLOSE(fpout); @@ -1511,4 +1458,4 @@ main(int argc, char *argv[]) } /* Generate a compiler error if there is an old png.h in the search path. */ -typedef version_1_0_12beta1 your_png_h_is_not_version_1_0_12beta1; +typedef version_1_2_0beta1 your_png_h_is_not_version_1_2_0beta1; diff --git a/pngtrans.c b/pngtrans.c index 85d27559c..5bc4ad53f 100644 --- a/pngtrans.c +++ b/pngtrans.c @@ -1,7 +1,7 @@ /* pngtrans.c - transforms the data in a row (used by both readers and writers) * - * libpng 1.0.12beta1 - May 14, 2001 + * libpng 1.2.0beta1 - May 6, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -392,12 +392,11 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) sp += 8; dp += 6; for (i = 1; i < row_width; i++) { - /* This could be (although png_memcpy is probably slower): + /* This could be (although memcpy is probably slower): png_memcpy(dp, sp, 6); sp += 8; dp += 6; */ - *dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp++; @@ -412,12 +411,11 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) /* This converts from XXRRGGBB or AARRGGBB to RRGGBB */ for (i = 0; i < row_width; i++) { - /* This could be (although png_memcpy is probably slower): + /* This could be (although memcpy is probably slower): png_memcpy(dp, sp, 6); sp += 8; dp += 6; */ - sp+=2; *dp++ = *sp++; *dp++ = *sp++; diff --git a/pngvcrd.c b/pngvcrd.c index 75cc9b575..04c202516 100644 --- a/pngvcrd.c +++ b/pngvcrd.c @@ -2,14 +2,14 @@ * * For Intel x86 CPU and Microsoft Visual C++ compiler * - * libpng 1.0.12beta1 - May 14, 2001 + * libpng 1.2.0beta1 - May 6, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * Copyright (c) 1998, Intel Corporation * * Contributed by Nirav Chhatrapati, Intel Corporation, 1998 * Interface to libpng contributed by Gilles Vollant, 1999 - * Debugging and cleanup by Greg Roelofs, 2000, 2001 + * * * In png_do_read_interlace() in libpng versions 1.0.3a through 1.0.4d, * a sign error in the post-MMX cleanup code for each pixel_depth resulted @@ -19,6 +19,8 @@ * * [png_read_filter_row_mmx_avg() bpp == 2 bugfix, GRR 20000916] * + * [runtime MMX configuration, GRR 20010102] + * */ #define PNG_INTERNAL @@ -110,6 +112,8 @@ png_combine_row(png_structp png_ptr, png_bytep row, int mask) png_debug(1,"in png_combine_row_asm\n"); if (mmx_supported == 2) { + /* this should have happened in png_init_mmx_flags() already */ + png_warning(png_ptr, "asm_flags may not have been initialized"); png_mmx_support(); } @@ -300,7 +304,8 @@ png_combine_row(png_structp png_ptr, png_bytep row, int mask) __int64 mask0=0x0102040810204080; - if ( mmx_supported ) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && mmx_supported */ ) { srcptr = png_ptr->row_buf + 1; dstptr = row; @@ -382,8 +387,6 @@ end8: incr1 = (disp)*pixel_bytes; for (i = initial_val; i < final_val; i += incr1) { - if (pixel_bytes > (png_size_t)(final_val-i)) - pixel_bytes = (png_size_t)(final_val-i); png_memcpy(dstptr, srcptr, pixel_bytes); srcptr += incr1; dstptr += incr1; @@ -402,7 +405,8 @@ end8: __int64 mask1=0x0101020204040808, mask0=0x1010202040408080; - if ( mmx_supported ) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && mmx_supported */ ) { srcptr = png_ptr->row_buf + 1; dstptr = row; @@ -495,8 +499,6 @@ end16: incr1 = (disp)*pixel_bytes; for (i = initial_val; i < final_val; i += incr1) { - if (pixel_bytes > (png_size_t)(final_val-i)) - pixel_bytes = (png_size_t)(final_val-i); png_memcpy(dstptr, srcptr, pixel_bytes); srcptr += incr1; dstptr += incr1; @@ -524,7 +526,8 @@ end16: len = (png_ptr->width)&~7; diff = (png_ptr->width)&7; - if ( mmx_supported ) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && mmx_supported */ ) { _asm { @@ -627,8 +630,6 @@ end24: incr1 = (disp)*pixel_bytes; for (i = initial_val; i < final_val; i += incr1) { - if (pixel_bytes > (png_size_t)(final_val-i)) - pixel_bytes = (png_size_t)(final_val-i); png_memcpy(dstptr, srcptr, pixel_bytes); srcptr += incr1; dstptr += incr1; @@ -657,7 +658,8 @@ end24: len = (png_ptr->width)&~7; diff = (png_ptr->width)&7; - if ( mmx_supported ) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && mmx_supported */ ) { _asm { @@ -768,8 +770,6 @@ end32: incr1 = (disp)*pixel_bytes; for (i = initial_val; i < final_val; i += incr1) { - if (pixel_bytes > (png_size_t)(final_val-i)) - pixel_bytes = (png_size_t)(final_val-i); png_memcpy(dstptr, srcptr, pixel_bytes); srcptr += incr1; dstptr += incr1; @@ -793,7 +793,8 @@ end32: mask1=0x2020202040404040, mask0=0x4040808080808080; - if ( mmx_supported ) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) + /* && mmx_supported */ ) { srcptr = png_ptr->row_buf + 1; dstptr = row; @@ -927,8 +928,6 @@ end48: incr1 = (disp)*pixel_bytes; for (i = initial_val; i < final_val; i += incr1) { - if (pixel_bytes > (png_size_t)(final_val-i)) - pixel_bytes = (png_size_t)(final_val-i); png_memcpy(dstptr, srcptr, pixel_bytes); srcptr += incr1; dstptr += incr1; @@ -957,8 +956,6 @@ end48: incr1 = (disp)*pixel_bytes; for (i = initial_val; i < final_val; i += incr1) { - if (pixel_bytes > (png_size_t)(final_val-i)) - pixel_bytes = (png_size_t)(final_val-i); png_memcpy(dp, sptr, pixel_bytes); sptr += incr1; dp += incr1; @@ -987,6 +984,8 @@ png_do_read_interlace(png_structp png_ptr) png_debug(1,"in png_do_read_interlace\n"); if (mmx_supported == 2) { + /* this should have happened in png_init_mmx_flags() already */ + png_warning(png_ptr, "asm_flags may not have been initialized"); png_mmx_support(); } @@ -1187,7 +1186,8 @@ png_do_read_interlace(png_structp png_ptr) // NOTE: there is NO MMX code for 48-bit and 64-bit images // use MMX routine if machine supports it - if ( mmx_supported ) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_INTERLACE) + /* && mmx_supported */ ) { if (pixel_bytes == 3) { @@ -1777,7 +1777,7 @@ loop4_pass4: } /* end of mmx_supported */ else /* MMX not supported: use modified C code - takes advantage - * of inlining of png_memcpy for a constant */ + * of inlining of memcpy for a constant */ { if (pixel_bytes == 1) { @@ -3649,6 +3649,8 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep #endif if (mmx_supported == 2) { + /* this should have happened in png_init_mmx_flags() already */ + png_warning(png_ptr, "asm_flags may not have been initialized"); png_mmx_support(); } @@ -3658,13 +3660,17 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep { case 0: sprintf(filnm, "none"); break; - case 1: sprintf(filnm, "sub-%s", "MMX"); + case 1: sprintf(filnm, "sub-%s", + (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "MMX" : "x86"); break; - case 2: sprintf(filnm, "up-%s", "MMX"); + case 2: sprintf(filnm, "up-%s", + (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP)? "MMX" : "x86"); break; - case 3: sprintf(filnm, "avg-%s", "MMX"); + case 3: sprintf(filnm, "avg-%s", + (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)? "MMX" : "x86"); break; - case 4: sprintf(filnm, "Paeth-%s", "MMX"); + case 4: sprintf(filnm, "Paeth-%s", + (png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)? "MMX":"x86"); break; default: sprintf(filnm, "unknw"); break; @@ -3682,9 +3688,9 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep case PNG_FILTER_VALUE_SUB: { - if ( - (row_info->pixel_depth >= PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT) && - (row_info->rowbytes >= PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT)) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB) && + (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && + (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) { png_read_filter_row_mmx_sub(row_info, row); } @@ -3707,9 +3713,9 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep case PNG_FILTER_VALUE_UP: { - if ( - (row_info->pixel_depth >= PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT) && - (row_info->rowbytes >= PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT)) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP) && + (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && + (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) { png_read_filter_row_mmx_up(row_info, row, prev_row); } @@ -3731,9 +3737,9 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep case PNG_FILTER_VALUE_AVG: { - if ( - (row_info->pixel_depth >= PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT) && - (row_info->rowbytes >= PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT)) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG) && + (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && + (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) { png_read_filter_row_mmx_avg(row_info, row, prev_row); } @@ -3765,9 +3771,9 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep case PNG_FILTER_VALUE_PAETH: { - if ( - (row_info->pixel_depth >= PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT) && - (row_info->rowbytes >= PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT)) + if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH) && + (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) && + (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold)) { png_read_filter_row_mmx_paeth(row_info, row, prev_row); } diff --git a/pngwio.c b/pngwio.c index 1b4e2661a..febf217f5 100644 --- a/pngwio.c +++ b/pngwio.c @@ -1,7 +1,7 @@ /* pngwio.c - functions for data output * - * libpng 1.0.12beta1 - May 14, 2001 + * libpng 1.2.0beta1 - May 6, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -17,7 +17,6 @@ #define PNG_INTERNAL #include "png.h" -#ifdef PNG_WRITE_SUPPORTED /* Write the data to whatever output you are using. The default routine writes to a file pointer. Note that this routine sometimes gets called @@ -225,4 +224,3 @@ void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check) } # endif # endif -#endif /* PNG_WRITE_SUPPORTED */ diff --git a/pngwrite.c b/pngwrite.c index 86829c430..606736707 100644 --- a/pngwrite.c +++ b/pngwrite.c @@ -1,7 +1,7 @@ /* pngwrite.c - general routines to write a PNG file * - * libpng 1.0.12beta1 - May 14, 2001 + * libpng 1.2.0beta1 - May 6, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -444,7 +444,7 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, png_debug(1, "in png_create_write_struct\n"); #ifdef PNG_USER_MEM_SUPPORTED if ((png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, - (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr)) == NULL) + (png_malloc_ptr)malloc_fn)) == NULL) #else if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL) #endif /* PNG_USER_MEM_SUPPORTED */ @@ -452,6 +452,10 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, return ((png_structp)NULL); } +#ifdef PNG_ASSEMBLER_CODE_SUPPORTED + png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ +#endif + #ifdef PNG_SETJMP_SUPPORTED #ifdef USE_FAR_KEYWORD if (setjmp(jmpbuf)) @@ -489,7 +493,6 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, * only check the first digit. */ if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || - (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || (user_png_ver[0] == '0' && user_png_ver[2] < '9')) { png_error(png_ptr, @@ -497,17 +500,15 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, } /* Libpng 1.0.6 was not binary compatible, due to insertion of the - info_ptr->free_me member. Libpng-1.0.1 and earlier were not - compatible due to insertion of the user transform function. Note - to maintainer: this test can be removed from version 1.2.0 and - beyond because the previous test would have already rejected it. */ + info_ptr->free_me member. Note to maintainer: this test can be + removed from version 2.0.0 and beyond because the previous test + would have already rejected it. */ - if (user_png_ver[0] == '1' && user_png_ver[2] == '0' && - (user_png_ver[4] < '2' || user_png_ver[4] == '6') && - user_png_ver[5] == '\0') + if (user_png_ver[4] == '6' && user_png_ver[2] == '0' && + user_png_ver[0] == '1' && user_png_ver[5] == '\0') { png_error(png_ptr, - "Application must be recompiled; versions <= 1.0.6 were incompatible"); + "Application must be recompiled; version 1.0.6 was incompatible"); } } @@ -532,36 +533,13 @@ void PNGAPI png_write_init(png_structp png_ptr) { /* We only come here via pre-1.0.7-compiled applications */ - png_write_init_2(png_ptr, "1.0.0", 0, 0); + png_write_init_2(png_ptr, "1.0.0", 10000, 10000); } -#undef png_write_init_2 void PNGAPI 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) { - /* We only come here via pre-1.0.12-compiled applications */ - if(sizeof(png_struct) > png_struct_size) - { - png_ptr->error_fn=(png_error_ptr)NULL; - png_error(png_ptr, - "The png struct allocated by the application is too small."); - } - if(sizeof(png_info) > png_info_size) - { - png_ptr->error_fn=(png_error_ptr)NULL; - png_error(png_ptr, - "The info struct allocated by the application is too small."); - } - png_write_init_3(&png_ptr, user_png_ver, png_struct_size); -} - - -void PNGAPI -png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, - png_size_t png_struct_size) -{ - png_structp png_ptr=*ptr_ptr; #ifdef PNG_SETJMP_SUPPORTED jmp_buf tmp_jmp; /* to save current jump buffer */ #endif @@ -573,42 +551,45 @@ png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, #ifdef PNG_LEGACY_SUPPORTED png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; #else - png_ptr->warning_fn=(png_error_ptr)NULL; - png_warning(png_ptr, - "Application uses deprecated png_write_init() and should be recompiled."); - break; + png_ptr->error_fn=(png_error_ptr)NULL; + png_error(png_ptr, + "Application uses deprecated png_write_init() and must be recompiled."); #endif } } while (png_libpng_ver[i++]); - png_debug(1, "in png_write_init_3\n"); + if (sizeof(png_struct) > png_struct_size || + sizeof(png_info) > png_info_size) + { + png_ptr->error_fn=(png_error_ptr)NULL; + png_error(png_ptr, + "Application and library have different sized structs. Please recompile."); + } + + png_debug(1, "in png_write_init_2\n"); #ifdef PNG_SETJMP_SUPPORTED /* save jump buffer and error functions */ png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf)); #endif - if (sizeof(png_struct) > png_struct_size) - { - png_destroy_struct(png_ptr); - png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); - *ptr_ptr = png_ptr; - } - /* reset all variables to 0 */ png_memset(png_ptr, 0, sizeof (png_struct)); +#ifdef PNG_ASSEMBLER_CODE_SUPPORTED + png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ +#endif + #ifdef PNG_SETJMP_SUPPORTED /* restore jump buffer */ png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf)); #endif - png_set_write_fn(png_ptr, NULL, NULL, NULL); - /* initialize zbuf - compression buffer */ png_ptr->zbuf_size = PNG_ZBUF_SIZE; png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size); + png_set_write_fn(png_ptr, NULL, NULL, NULL); #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT, @@ -903,7 +884,6 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr) png_infop info_ptr = NULL; #ifdef PNG_USER_MEM_SUPPORTED png_free_ptr free_fn = NULL; - png_voidp mem_ptr = NULL; #endif png_debug(1, "in png_destroy_write_struct\n"); @@ -932,8 +912,7 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr) #endif #ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); + png_destroy_struct_2((png_voidp)info_ptr, free_fn); #else png_destroy_struct((png_voidp)info_ptr); #endif @@ -944,8 +923,7 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr) { png_write_destroy(png_ptr); #ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); + png_destroy_struct_2((png_voidp)png_ptr, free_fn); #else png_destroy_struct((png_voidp)png_ptr); #endif diff --git a/pngwtran.c b/pngwtran.c index 8740b83f3..0671ec5ae 100644 --- a/pngwtran.c +++ b/pngwtran.c @@ -1,7 +1,7 @@ /* pngwtran.c - transforms the data in a row for PNG writers * - * libpng 1.0.12beta1 - May 14, 2001 + * libpng 1.2.0beta1 - May 6, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -10,7 +10,6 @@ #define PNG_INTERNAL #include "png.h" -#ifdef PNG_WRITE_SUPPORTED /* Transform the data according to the user's wishes. The order of * transformations is significant. @@ -560,4 +559,3 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row) } } #endif /* PNG_MNG_FEATURES_SUPPORTED */ -#endif /* PNG_WRITE_SUPPORTED */ diff --git a/pngwutil.c b/pngwutil.c index ed964ced8..4bbb7ad6f 100644 --- a/pngwutil.c +++ b/pngwutil.c @@ -1,7 +1,7 @@ /* pngwutil.c - utilities to write a PNG file * - * libpng 1.0.12beta1 - May 14, 2001 + * libpng 1.2.0beta1 - May 6, 2001 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2001 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -10,7 +10,6 @@ #define PNG_INTERNAL #include "png.h" -#ifdef PNG_WRITE_SUPPORTED /* Place a 32-bit number into a buffer in PNG byte order. We work * with unsigned numbers for convenience, although one supported @@ -235,8 +234,8 @@ png_text_compress(png_structp png_ptr, old_ptr = comp->output_ptr; comp->output_ptr = (png_charpp)png_malloc(png_ptr, (png_uint_32)(comp->max_output_ptr * sizeof (png_charpp))); - png_memcpy(comp->output_ptr, old_ptr, old_max - * sizeof (png_charp)); + png_memcpy(comp->output_ptr, old_ptr, + old_max * sizeof (png_charp)); png_free(png_ptr, old_ptr); } else @@ -285,7 +284,7 @@ png_text_compress(png_structp png_ptr, comp->output_ptr = (png_charpp)png_malloc(png_ptr, (png_uint_32)(comp->max_output_ptr * sizeof (png_charpp))); png_memcpy(comp->output_ptr, old_ptr, - old_max * sizeof (png_charp)); + old_max * sizeof (png_charp)); png_free(png_ptr, old_ptr); } else @@ -435,7 +434,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, #if defined(PNG_MNG_FEATURES_SUPPORTED) !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && - (color_type == PNG_COLOR_TYPE_RGB || + (color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_RGB_ALPHA) && (filter_type == PNG_INTRAPIXEL_DIFFERENCING)) && #endif @@ -460,9 +459,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, png_ptr->bit_depth = (png_byte)bit_depth; png_ptr->color_type = (png_byte)color_type; png_ptr->interlaced = (png_byte)interlace_type; -#if defined(PNG_MNG_FEATURES_SUPPORTED) png_ptr->filter_type = (png_byte)filter_type; -#endif png_ptr->width = width; png_ptr->height = height; @@ -537,28 +534,20 @@ png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal) png_debug(1, "in png_write_PLTE\n"); if (( -#if defined(PNG_MNG_FEATURES_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_PERMITTED) +#if defined(PNG_MNG_FEATURES_SUPPORTED) !(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) && #endif num_pal == 0) || num_pal > 256) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { - png_error(png_ptr, "Invalid number of colors in palette"); - } - else - { - png_warning(png_ptr, "Invalid number of colors in palette"); - return; - } - } - - if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR)) - { - png_warning(png_ptr, - "Ignoring request to write a PLTE chunk in grayscale PNG"); - return; + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + png_error(png_ptr, "Invalid number of colors in palette"); + } + else + { + png_warning(png_ptr, "Invalid number of colors in palette"); + return; + } } png_ptr->num_palette = (png_uint_16)num_pal; @@ -739,7 +728,7 @@ png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette) } /* 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_bytep) png_sPLT, (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)&spalette->depth, 1); @@ -1028,8 +1017,7 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type) if (color_type == PNG_COLOR_TYPE_PALETTE) { if ( -#if defined(PNG_MNG_FEATURES_SUPPORTED) || \ - defined(PNG_WRITE_EMPTY_PLTE_PERMITTED) +#if defined(PNG_MNG_FEATURES_SUPPORTED) (png_ptr->num_palette || (!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) && #endif @@ -1426,9 +1414,9 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0, png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); purpose_len = png_check_keyword(png_ptr, purpose, &new_purpose) + 1; - png_debug1(3, "pCAL purpose length = %d\n", (int)purpose_len); + png_debug1(3, "pCAL purpose length = %d\n", purpose_len); units_len = png_strlen(units) + (nparams == 0 ? 0 : 1); - png_debug1(3, "pCAL units length = %d\n", (int)units_len); + png_debug1(3, "pCAL units length = %d\n", units_len); total_len = purpose_len + units_len + 10; params_len = (png_uint_32p)png_malloc(png_ptr, (png_uint_32)(nparams @@ -1443,7 +1431,7 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0, total_len += (png_size_t)params_len[i]; } - png_debug1(3, "pCAL total length = %d\n", (int)total_len); + png_debug1(3, "pCAL total length = %d\n", total_len); png_write_chunk_start(png_ptr, (png_bytep)png_pCAL, (png_uint_32)total_len); png_write_chunk_data(png_ptr, (png_bytep)new_purpose, purpose_len); png_save_int_32(buf, X0); @@ -1495,11 +1483,11 @@ png_write_sCAL(png_structp png_ptr, int unit, double width,double height) #endif total_len = 1 + png_strlen(wbuf)+1 + png_strlen(hbuf); - png_debug1(3, "sCAL total length = %d\n", (int)total_len); + png_debug1(3, "sCAL total length = %d\n", total_len); png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len); png_write_chunk_data(png_ptr, (png_bytep)&unit, 1); - png_write_chunk_data(png_ptr, (png_bytep)wbuf, png_strlen(wbuf)+1); - png_write_chunk_data(png_ptr, (png_bytep)hbuf, png_strlen(hbuf)); + png_write_chunk_data(png_ptr, (png_bytep)wbuf, strlen(wbuf)+1); + png_write_chunk_data(png_ptr, (png_bytep)hbuf, strlen(hbuf)); png_write_chunk_end(png_ptr); } @@ -1517,15 +1505,15 @@ png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width, png_debug(1, "in png_write_sCAL_s\n"); - png_strcpy(wbuf,(const char *)width); - png_strcpy(hbuf,(const char *)height); + strcpy(wbuf,(const char *)width); + strcpy(hbuf,(const char *)height); total_len = 1 + png_strlen(wbuf)+1 + png_strlen(hbuf); png_debug1(3, "sCAL total length = %d\n", total_len); png_write_chunk_start(png_ptr, (png_bytep)png_sCAL, (png_uint_32)total_len); png_write_chunk_data(png_ptr, (png_bytep)&unit, 1); - png_write_chunk_data(png_ptr, (png_bytep)wbuf, png_strlen(wbuf)+1); - png_write_chunk_data(png_ptr, (png_bytep)hbuf, png_strlen(hbuf)); + png_write_chunk_data(png_ptr, (png_bytep)wbuf, strlen(wbuf)+1); + png_write_chunk_data(png_ptr, (png_bytep)hbuf, strlen(hbuf)); png_write_chunk_end(png_ptr); } @@ -2643,4 +2631,3 @@ png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row) } #endif } -#endif /* PNG_WRITE_SUPPORTED */ diff --git a/projects/msvc/README.txt b/projects/msvc/README.txt index b08db7df5..9df523d4f 100644 --- a/projects/msvc/README.txt +++ b/projects/msvc/README.txt @@ -1,5 +1,5 @@ Microsoft Developer Studio Build File, Format Version 6.00 for -libpng 1.0.12beta1 (May 14, 2001) and zlib +libpng 1.2.0beta1 (May 6, 2001) and zlib Copyright (C) 2000 Simon-Pierre Cadieux For conditions of distribution and use, see copyright notice in png.h diff --git a/projects/msvc/png32ms.def b/projects/msvc/png32ms.def index 388fdadc6..83e2231d0 100644 --- a/projects/msvc/png32ms.def +++ b/projects/msvc/png32ms.def @@ -6,7 +6,7 @@ LIBRARY DESCRIPTION "PNG image compression library for Windows" EXPORTS -;Version 1.0.12beta1 +;Version 1.2.0beta1 png_build_grayscale_palette @1 png_check_sig @2 png_chunk_error @3 @@ -175,7 +175,6 @@ EXPORTS png_write_png @163 png_write_row @164 png_write_rows @165 -; png_read_init_2 and png_write_init_2 are deprecated. png_read_init_2 @166 png_write_init_2 @167 png_access_version_number @168 @@ -184,30 +183,14 @@ EXPORTS png_init_io @171 png_convert_to_rfc1123 @172 png_set_invalid @173 -; Added at version 1.0.12 -; For compatiblity with 1.0.7-1.0.11 - png_info_init @174 - png_read_init_3 @175 - png_write_init_3 @176 - png_info_init_3 @177 - png_destroy_struct @178 -; To be added at version 1.2.0 -; For use with PNG_USER_MEM_SUPPORTED -; png_destroy_struct_2 @179 -; png_create_read_struct_2 @180 -; png_create_write_struct_2 @181 -; png_malloc_default @182 -; png_free_default @183 -; MNG features -; png_permit_mng_features @184 -; MMX support -; png_mmx_support @185 -; png_get_mmx_flagmask @186 -; png_get_asm_flagmask @187 -; png_get_asm_flags @188 -; png_get_mmx_bitdepth_threshold @189 -; png_get_mmx_rowbytes_threshold @190 -; png_set_asm_flags @191 -; png_init_mmx_flags @192 -; Strip error numbers -; png_set_strip_error_numbers @193 +; Added at version 1.2.0 + png_permit_mng_features @174 + png_mmx_support @175 + png_get_mmx_flagmask @176 + png_get_asm_flagmask @177 + png_get_asm_flags @178 + png_get_mmx_bitdepth_threshold @179 + png_get_mmx_rowbytes_threshold @180 + png_set_asm_flags @181 + png_init_mmx_flags @182 + png_set_strip_error_numbers @183 diff --git a/projects/wince/READMEE.WCE b/projects/wince/READMEE.WCE index c211cf102..9d15273d2 100644 --- a/projects/wince/READMEE.WCE +++ b/projects/wince/READMEE.WCE @@ -8,9 +8,9 @@ libpng for WindowsCE Rel.1.0 Introduction ============ -This is libpng 1.0.12beta1 ported to WindowsCE 2.0 and 2.11. -libpng 1.0.12beta1 is a PNG reference library. -See README, a document of original libpng 1.0.12beta1. +This is libpng 1.2.0beta1 ported to WindowsCE 2.0 and 2.11. +libpng 1.2.0beta1 is a PNG reference library. +See README, a document of original libpng 1.2.0beta1. zlib for WindowsCE ================== @@ -23,7 +23,7 @@ This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. -See README and LICENSE, documents of original libpng 1.0.12beta1, for conditions +See README and LICENSE, documents of original libpng 1.2.0beta1, for conditions of use and distribution. Files diff --git a/projects/wince/READMEJ.WCE b/projects/wince/READMEJ.WCE index 4a2e2c38b..bda7cb19f 100644 --- a/projects/wince/READMEJ.WCE +++ b/projects/wince/READMEJ.WCE @@ -24,7 +24,7 @@ libpng になったいかなる被害についても、作者、配布者、その他利用者以外の人物、 団体に責任をとる義務はないものとします。 -その他、このソフトウェアの利用条件については、原版である libpng 1.0.12beta1に +その他、このソフトウェアの利用条件については、原版である libpng 1.2.0beta1に 準拠するものとします。詳しくは、付属の README,LICENSE をお読みください。 収録内容 diff --git a/projects/wince/png32ce.def b/projects/wince/png32ce.def index f97061fdc..ddb870f06 100644 --- a/projects/wince/png32ce.def +++ b/projects/wince/png32ce.def @@ -5,7 +5,7 @@ LIBRARY lpngce EXPORTS -;Version 1.0.12beta1 +;Version 1.2.0beta1 png_build_grayscale_palette @1 png_check_sig @2 png_chunk_error @3 @@ -76,7 +76,6 @@ EXPORTS png_malloc @68 png_memcpy_check @69 png_memset_check @70 -; png_permit_empty_plte is deprecated png_permit_empty_plte @71 png_process_data @72 png_progressive_combine_row @73 @@ -174,39 +173,22 @@ EXPORTS png_write_png @163 png_write_row @164 png_write_rows @165 -; png_read_init_2 and png_write_init_2 are deprecated. png_read_init_2 @166 png_write_init_2 @167 png_access_version_number @168 ; png_sig_bytes @169 -; png_libpng_ver @170 + png_libpng_ver @170 png_init_io @171 png_convert_to_rfc1123 @172 png_set_invalid @173 -; Added at version 1.0.12 -; For compatiblity with 1.0.7-1.0.11 - png_info_init @174 - png_read_init_3 @175 - png_write_init_3 @176 - png_info_init_3 @177 - png_destroy_struct @178 -; To be added at version 1.2.0 -; For use with PNG_USER_MEM_SUPPORTED -; png_destroy_struct_2 @179 -; png_create_read_struct_2 @180 -; png_create_write_struct_2 @181 -; png_malloc_default @182 -; png_free_default @183 -; MNG features -; png_permit_mng_features @184 -; MMX support -; png_mmx_support @185 -; png_get_mmx_flagmask @186 -; png_get_asm_flagmask @187 -; png_get_asm_flags @188 -; png_get_mmx_bitdepth_threshold @189 -; png_get_mmx_rowbytes_threshold @190 -; png_set_asm_flags @191 -; png_init_mmx_flags @192 -; Strip error numbers -; png_set_strip_error_numbers @193 +; Added at version 1.2.0 + png_permit_mng_features @174 + png_mmx_support @175 + png_get_mmx_flagmask @176 + png_get_asm_flagmask @177 + png_get_asm_flags @178 + png_get_mmx_bitdepth_threshold @179 + png_get_mmx_rowbytes_threshold @180 + png_set_asm_flags @181 + png_init_mmx_flags @182 + png_set_strip_error_numbers @183 diff --git a/scripts/makefile.aix b/scripts/makefile.aix index 38c44b551..38169d309 100644 --- a/scripts/makefile.aix +++ b/scripts/makefile.aix @@ -18,7 +18,7 @@ RM = rm -f # read libpng.txt or png.h to see why PNGMAJ is 2. You should not # have to change it. PNGMAJ = 2 -PNGMIN = 1.0.12beta1 +PNGMIN = 1.2.0beta1 PNGVER = $(PNGMAJ).$(PNGMIN) prefix=/usr/local diff --git a/scripts/makefile.beos b/scripts/makefile.beos index 8811b576f..3ccda737f 100644 --- a/scripts/makefile.beos +++ b/scripts/makefile.beos @@ -13,7 +13,7 @@ ZLIBINC=/usr/local/include # read libpng.txt or png.h to see why PNGMAJ is 2. You should not # have to change it. PNGMAJ = 2 -PNGMIN = 1.0.12beta1 +PNGMIN = 1.2.0beta1 PNGVER = $(PNGMAJ).$(PNGMIN) ALIGN= diff --git a/scripts/makefile.cygwin b/scripts/makefile.cygwin index c88c98436..de9d218ec 100644 --- a/scripts/makefile.cygwin +++ b/scripts/makefile.cygwin @@ -39,9 +39,9 @@ CFLAGS=-I$(ZLIBINC) -Wall -O3 $(ALIGN) -funroll-loops \ # have to change it. PNGMAJ = 2 #PNGDLL = $2# msvc -PNGDLL = 2# cygwin 1.0.12beta1 -PNGMIN = 1.0.12beta1 -PNGMIN_BASE = 1.0.12 +PNGDLL = 2# cygwin 1.2.0beta1 +PNGMIN = 1.2.0beta1 +PNGMIN_BASE = 1.2.0 PNGVER = $(PNGMAJ).$(PNGMIN) SHAREDLIB=cygpng$(PNGDLL).dll diff --git a/scripts/makefile.dec b/scripts/makefile.dec index 19893cadb..000d7f652 100644 --- a/scripts/makefile.dec +++ b/scripts/makefile.dec @@ -17,7 +17,7 @@ ZLIBINC=../zlib # read libpng.txt or png.h to see why PNGMAJ is 2. You should not # have to change it. PNGMAJ = 2 -PNGMIN = 1.0.12beta1 +PNGMIN = 1.2.0beta1 PNGVER = $(PNGMAJ).$(PNGMIN) CC=cc diff --git a/scripts/makefile.gcmmx b/scripts/makefile.gcmmx index 3fd755991..4a5a98673 100644 --- a/scripts/makefile.gcmmx +++ b/scripts/makefile.gcmmx @@ -51,7 +51,7 @@ RANLIB=ranlib # read libpng.txt or png.h to see why PNGMAJ is 2. You should not # have to change it. PNGMAJ = 2 -PNGMIN = 1.0.12beta1 +PNGMIN = 1.2.0beta1 PNGVER = $(PNGMAJ).$(PNGMIN) INCPATH=$(prefix)/include diff --git a/scripts/makefile.hpgcc b/scripts/makefile.hpgcc index 1002affb4..7c6930ac5 100644 --- a/scripts/makefile.hpgcc +++ b/scripts/makefile.hpgcc @@ -34,7 +34,7 @@ RANLIB=ranlib # read libpng.txt or png.h to see why PNGMAJ is 2. You should not # have to change it. PNGMAJ = 2 -PNGMIN = 1.0.12beta1 +PNGMIN = 1.2.0beta1 PNGVER = $(PNGMAJ).$(PNGMIN) INCPATH=$(prefix)/include diff --git a/scripts/makefile.hpux b/scripts/makefile.hpux index bfd26c89b..692ce1be6 100644 --- a/scripts/makefile.hpux +++ b/scripts/makefile.hpux @@ -19,7 +19,7 @@ RANLIB=ranlib # read libpng.txt or png.h to see why PNGMAJ is 2. You should not # have to change it. PNGMAJ = 2 -PNGMIN = 1.0.12beta1 +PNGMIN = 1.2.0beta1 PNGVER = $(PNGMAJ).$(PNGMIN) # where make install puts libpng.a and png.h diff --git a/scripts/makefile.linux b/scripts/makefile.linux index 5e8ba4cb9..0eb6946c4 100644 --- a/scripts/makefile.linux +++ b/scripts/makefile.linux @@ -34,7 +34,7 @@ RANLIB=ranlib # read libpng.txt or png.h to see why PNGMAJ is 2. You should not # have to change it. PNGMAJ = 2 -PNGMIN = 1.0.12beta1 +PNGMIN = 1.2.0beta1 PNGVER = $(PNGMAJ).$(PNGMIN) INCPATH=$(prefix)/include diff --git a/scripts/makefile.netbsd b/scripts/makefile.netbsd index 719bc7173..056d66264 100644 --- a/scripts/makefile.netbsd +++ b/scripts/makefile.netbsd @@ -11,7 +11,7 @@ INCSDIR=${LOCALBASE}/include LIB=png SHLIB_MAJOR= 2 -SHLIB_MINOR= 1.0.12beta1 +SHLIB_MINOR= 1.2.0beta1 SRCS= pnggccrd.c png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ pngwtran.c pngmem.c pngerror.c pngpread.c diff --git a/scripts/makefile.sco b/scripts/makefile.sco index f32f16409..15b4ca23c 100644 --- a/scripts/makefile.sco +++ b/scripts/makefile.sco @@ -25,7 +25,7 @@ RANLIB=echo # read libpng.txt or png.h to see why PNGMAJ is 2. You should not # have to change it. PNGMAJ = 2 -PNGMIN = 1.0.12beta1 +PNGMIN = 1.2.0beta1 PNGVER = $(PNGMAJ).$(PNGMIN) INCPATH=$(prefix)/include diff --git a/scripts/makefile.sggcc b/scripts/makefile.sggcc index bea044985..efbfe67f6 100644 --- a/scripts/makefile.sggcc +++ b/scripts/makefile.sggcc @@ -19,8 +19,8 @@ CFLAGS=-I$(ZLIBINC) -O2 $(WARNMORE) -fPIC -mabi=n32 LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm LDSHARED=gcc -shared -VER=1.0.12beta1 -LIBS=libpng.so.1.0.12beta1 +VER=1.2.0beta1 +LIBS=libpng.so.1.2.0beta1 SHAREDLIB=libpng.so libdir=$(prefix)/lib32 diff --git a/scripts/makefile.sgi b/scripts/makefile.sgi index 4726d5d17..9ce67c15c 100644 --- a/scripts/makefile.sgi +++ b/scripts/makefile.sgi @@ -25,7 +25,7 @@ CFLAGS=-I$(ZLIBINC) -O $(WARNMORE) -DPNG_USE_PNGGCCRD -DPNG_NO_ASSEMBLER_CODE LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm LDSHARED=cc -shared -VER=1.0.12beta1 +VER=1.2.0beta1 SONUM=2 SHAREDLIB=libpng.so libdir=$(prefix) diff --git a/scripts/makefile.solaris b/scripts/makefile.solaris index 93da477f5..2aec98ab4 100644 --- a/scripts/makefile.solaris +++ b/scripts/makefile.solaris @@ -31,7 +31,7 @@ RANLIB=echo # read libpng.txt or png.h to see why PNGMAJ is 2. You should not # have to change it. PNGMAJ = 2 -PNGMIN = 1.0.12beta1 +PNGMIN = 1.2.0beta1 PNGVER = $(PNGMAJ).$(PNGMIN) INCPATH=$(prefix)/include diff --git a/scripts/pngdef.pas b/scripts/pngdef.pas index 3e8c3bc7f..88be81bb4 100644 --- a/scripts/pngdef.pas +++ b/scripts/pngdef.pas @@ -7,8 +7,8 @@ unit pngdef; interface const - PNG_LIBPNG_VER_STRING = '1.0.12beta1'; - PNG_LIBPNG_VER = 10012; + PNG_LIBPNG_VER_STRING = '1.2.0beta1'; + PNG_LIBPNG_VER = 10200; type png_uint_32 = Cardinal; diff --git a/scripts/pngos2.def b/scripts/pngos2.def index f096faf7c..839258827 100644 --- a/scripts/pngos2.def +++ b/scripts/pngos2.def @@ -2,7 +2,7 @@ ; PNG.LIB module definition file for OS/2 ;---------------------------------------- -; Version 1.0.12beta1 +; Version 1.2.0beta1 LIBRARY PNG DESCRIPTION "PNG image compression library for OS/2" @@ -187,8 +187,17 @@ EXPORTS ;To be added at version 1.2.0 ; png_permit_mng_features -;To be added at version 1.2.0 -; png_mmx_support +; Added at version 1.2.0: + png_mmx_support + png_permit_empty_plte + png_permit_mng_features + png_get_mmx_flagmask + png_get_asm_flagmask + png_get_asm_flags + png_get_mmx_bitdepth_threshold + png_get_mmx_rowbytes_threshold + png_set_asm_flags + png_init_mmx_flags ; These are not present when libpng is compiled with PNG_NO_GLOBAL_ARRAYS png_libpng_ver