Imported from libpng-1.0.4d.tar
diff --git a/ANNOUNCE b/ANNOUNCE
index dcdd135..f839384 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,5 +1,5 @@
 
-Libpng 1.0.4c - October 1, 1999
+Libpng 1.0.4d - October 6, 1999
 
 This is not intended to be a public release.  It will be replaced
 within a few weeks by a public version or by another test version.
@@ -69,15 +69,20 @@
   Split makefile.win32vc into two versions, makefile.vcawin32 (uses MMX
     assembler code) and makefile.vcwin32 (doesn't).
   Added a CPU timing report to pngtest.c (enabled by defining PNGTEST_TIMING)
+  Added a copy of pngnow.png to the distribution.
 version 1.0.4a September 25, 1999
   Increase max_pixel_depth in pngrutil.c if a user transform needs it.
   Changed several division operations to right-shifts in pngvcrd.c
 version 1.0.4b September 30, 1999
   Added parentheses in line 3732 of pngvcrd.c
   Added a comment in makefile.linux warning about buggy -O3 in pgcc 2.95.1
-version 1.0.4c [October 1, 1999]
   Added a "png_check_version" function in png.c and pngtest.c that will generate
     a helpful compiler error if an old png.h is found in the search path.
+version 1.0.4c October 1, 1999
+  Changed type of png_user_transform_depth|channels from int to png_byte.
+version 1.0.4d [October 6, 1999]
+  Changed 0.45 to 0.45455 in png_set_sRGB()
+  Removed unused PLTE entries from pngnow.png
 
 Send comments/corrections/commendations to
 png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
diff --git a/CHANGES b/CHANGES
index ee7c17f..faf94e3 100644
--- a/CHANGES
+++ b/CHANGES
@@ -449,6 +449,7 @@
   Split makefile.win32vc into two versions, makefile.vcawin32 (uses MMX
     assembler code) and makefile.vcwin32 (doesn't).
   Added a CPU timing report to pngtest.c (enabled by defining PNGTEST_TIMING)
+  Added a copy of pngnow.png to the distribution.
 version 1.0.4a [September 25, 1999]
   Increase max_pixel_depth in pngrutil.c if a user transform needs it.
   Changed several division operations to right-shifts in pngvcrd.c
@@ -458,3 +459,7 @@
 version 1.0.4c [October 1, 1999]
   Added a "png_check_version" function in png.c and pngtest.c that will generate
     a helpful compiler error if an old png.h is found in the search path.
+version 1.0.4d [October 6, 1999]
+  Changed type of png_user_transform_depth|channels from int to png_byte.
+  Changed 0.45 to 0.45455 in png_set_sRGB()
+  Removed unused PLTE entries from pngnow.png
diff --git a/INSTALL b/INSTALL
index 475a8d4..b67764e 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,5 +1,5 @@
 
-Installing libpng version 1.0.4c - October 1, 1999
+Installing libpng version 1.0.4d - October 6, 1999
 
 Before installing libpng, you must first install zlib.  zlib
 can usually be found wherever you got libpng.  zlib can be
@@ -10,7 +10,7 @@
 version of zlib that's installed.
 
 You can rename the directories that you downloaded (they
-might be called "libpng-1.0.4c" or "lpng103" and "zlib-1.1.3"
+might be called "libpng-1.0.4d" or "lpng103" and "zlib-1.1.3"
 or "zlib113") so that you have directories called "zlib" and "libpng".
 
 Your directory structure should look like this:
@@ -47,8 +47,8 @@
  makefile.hpux    =>  HPUX (10.20 and 11.00) makefile
  makefile.sgi     =>  Silicon Graphics IRIX makefile
  makefile.sunos   =>  Sun makefile
- makefile.solaris =>  Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.4c)
- makefile.linux   =>  Linux/ELF makefile (gcc, creates libpng.so.2.1.0.4c)
+ makefile.solaris =>  Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.4d)
+ makefile.linux   =>  Linux/ELF makefile (gcc, creates libpng.so.2.1.0.4d)
  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 1c5629d..964674a 100644
--- a/KNOWNBUG
+++ b/KNOWNBUG
@@ -38,3 +38,13 @@
    for the png_set_gAMA(), png_set_cHRM(), and corresponding png_get_()
    functions will be needed.
 
+4. September 1999 -- BUG --
+
+   Portions of the new MMX code in pngvcrd.c are defined out because the
+   did not work properly.  When PNGVCRD_INTERLACE_BUG_IS_FIXED is defined,
+   to enable the code, pngtest pngtest.png pngout.png results in a
+   "Debug error! Damage before normal block # 57 at 0x007e19f0" on
+   a Pentium II with MMX system.  This seems to be caused by the heap
+   being trashed before a free() in png_read_destroy().
+
+   When PNGVCRD_COMBINE_BUG_IS_FIXED is defined (what?)
diff --git a/LICENSE b/LICENSE
index 22fc3f2..e85524d 100644
--- a/LICENSE
+++ b/LICENSE
@@ -5,7 +5,7 @@
 Copyright (c) 1996, 1997 Andreas Dilger
 (libpng versions 0.90, December 1996, through 0.96, May 1997)
 Copyright (c) 1998, 1999 Glenn Randers-Pehrson
-(libpng versions 0.97, January 1998, through 1.0.4c, October 1, 1999)
+(libpng versions 0.97, January 1998, through 1.0.4d, October 6, 1999)
 
 For the purposes of this copyright and license, "Contributing Authors"
 is defined as the following set of individuals:
@@ -56,4 +56,4 @@
 
 Glenn Randers-Pehrson
 randeg@alum.rpi.edu
-October 1, 1999
+October 6, 1999
diff --git a/README b/README
index e19f306..db3ac07 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-README for libpng 1.0.4c - October 1, 1999 (shared library 2.1)
+README for libpng 1.0.4d - October 6, 1999 (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.
@@ -163,9 +163,9 @@
        makefile.sgi     =>  Silicon Graphics IRIX makefile
        makefile.sunos   =>  Sun makefile
        makefile.solaris =>  Solaris 2.X makefile
-                            (gcc, creates libpng.so.2.1.0.4c)
+                            (gcc, creates libpng.so.2.1.0.4d)
        makefile.linux   =>  Linux/ELF makefile
-                            (gcc, creates libpng.so.2.1.0.4c)
+                            (gcc, creates libpng.so.2.1.0.4d)
        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 103579a..cdbaabf 100644
--- a/Y2KINFO
+++ b/Y2KINFO
@@ -1,13 +1,13 @@
    Y2K compliance in libpng:
    =========================
       
-      October 1, 1999
+      October 6, 1999
       
       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.4c are Y2K compliant.  It is my belief that earlier
+      upward through 1.0.4d 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/libpng.3 b/libpng.3
index 8fbfa99..e9669ba 100644
--- a/libpng.3
+++ b/libpng.3
@@ -1,6 +1,6 @@
-.TH LIBPNG 3 "October 1, 1999"
+.TH LIBPNG 3 "October 6, 1999"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.0.4c - October 1, 1999
+libpng \- Portable Network Graphics (PNG) Reference Library 1.0.4d - October 6, 1999
 .SH SYNOPSIS
 \fI\fB
 
@@ -617,7 +617,7 @@
 .SH LIBPNG.TXT
 libpng.txt - A description on how to use and modify libpng
 
- libpng version 1.0.4c - October 1, 1999
+ libpng version 1.0.4d - October 6, 1999
  Updated and distributed by Glenn Randers-Pehrson
  <randeg@alum.rpi.edu>
  Copyright (c) 1998, 1999 Glenn Randers-Pehrson
@@ -2675,13 +2675,13 @@
 
 .SH VII. Y2K Compliance in libpng
 
-October 1, 1999
+October 6, 1999
 
 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.4c are Y2K compliant.  It is my belief that earlier
+upward through 1.0.4d 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
@@ -2807,7 +2807,7 @@
 
 Thanks to Frank J. T. Wojcik for helping with the documentation.
   
-Libpng version 1.0.4c - October 1, 1999:
+Libpng version 1.0.4d - October 6, 1999:
 Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
 Currently maintained by Glenn Randers-Pehrson (randeg@alum.rpi.edu).
 
@@ -2822,7 +2822,7 @@
 Copyright (c) 1996, 1997 Andreas Dilger
 (libpng versions 0.90, December 1996, through 0.96, May 1997)
 Copyright (c) 1998, 1999 Glenn Randers-Pehrson
-(libpng versions 0.97, January 1998, through 1.0.4c, October 1, 1999)
+(libpng versions 0.97, January 1998, through 1.0.4d, October 6, 1999)
 
 For the purposes of this copyright and license, "Contributing Authors"
 is defined as the following set of individuals:
diff --git a/libpng.txt b/libpng.txt
index 8023e79..1628878 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.4c - October 1, 1999
+ libpng version 1.0.4d - October 6, 1999
  Updated and distributed by Glenn Randers-Pehrson
  <randeg@alum.rpi.edu>
  Copyright (c) 1998, 1999 Glenn Randers-Pehrson
@@ -2058,13 +2058,13 @@
 
 VII. Y2K Compliance in libpng
 
-October 1, 1999
+October 6, 1999
 
 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.4c are Y2K compliant.  It is my belief that earlier
+upward through 1.0.4d 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 fb0803f..def345c 100644
--- a/libpngpf.3
+++ b/libpngpf.3
@@ -1,6 +1,6 @@
-.TH LIBPNGPF 3 October 1, 1999
+.TH LIBPNGPF 3 October 6, 1999
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.0.4c - October 1, 1999
+libpng \- Portable Network Graphics (PNG) Reference Library 1.0.4d - October 6, 1999
 (private functions)
 .SH SYNOPSIS
 \fB#include <png.h>\fP
diff --git a/png.5 b/png.5
index 081adb5..be84fb8 100644
--- a/png.5
+++ b/png.5
@@ -1,4 +1,4 @@
-.TH PNG 5 "October 1, 1999"
+.TH PNG 5 "October 6, 1999"
 .SH NAME
 png \- Portable Network Graphics (PNG) format
 .SH DESCRIPTION
diff --git a/png.c b/png.c
index 1b0141b..dfcc680 100644
--- a/png.c
+++ b/png.c
@@ -1,7 +1,7 @@
 
 /* png.c - location for general purpose libpng functions
  *
- * libpng version 1.0.4c - October 1, 1999
+ * libpng version 1.0.4d - October 6, 1999
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
  * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
@@ -16,7 +16,7 @@
  * string defined in png.h.
  */
 
-char png_libpng_ver[12] = "1.0.4c";
+char png_libpng_ver[12] = "1.0.4d";
 
 /* Place to hold the signature string for a PNG file. */
 png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
@@ -352,7 +352,7 @@
 {
    if(png_ptr == NULL)
      /* silence compiler warning about unused png_ptr */ ;
-   return("\n libpng version 1.0.4c - October 1, 1999\n\
+   return("\n libpng version 1.0.4d - October 6, 1999\n\
    Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n\
    Copyright (c) 1996, 1997 Andreas Dilger\n\
    Copyright (c) 1998, 1999 Glenn Randers-Pehrson\n");
@@ -361,8 +361,8 @@
 /* Generate a compiler error if there is an old png.h in the search path. */
 void
 png_check_version
-   (version_1_0_4c png_h_is_not_version_1_0_4c)
+   (version_1_0_4d png_h_is_not_version_1_0_4d)
 {
-   if(png_h_is_not_version_1_0_4c == NULL)
+   if(png_h_is_not_version_1_0_4d == NULL)
      /* silence compiler warning about unused parameter */ ;
 }
diff --git a/png.h b/png.h
index 67a29e5..07ea6d6 100644
--- a/png.h
+++ b/png.h
@@ -1,7 +1,7 @@
 
 /* png.h - header file for PNG reference library
  *
- * libpng version 1.0.4c - October 1, 1999
+ * libpng version 1.0.4d - October 6, 1999
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
  * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
@@ -9,19 +9,19 @@
  * Authors and maintainers:
  *  libpng versions 0.71, May 1995, through 0.89c, May 1996: Guy Schalnat
  *  libpng versions 0.90, December 1996, through 0.96, May 1997: Andreas Dilger
- *  libpng versions 0.97, January 1998, through 1.0.4c - October 1, 1999: Glenn
+ *  libpng versions 0.97, January 1998, through 1.0.4d - October 6, 1999: Glenn
  *  See also "Contributing Authors", below.
  *
  * Y2K compliance in libpng:
  * =========================
  *    
- *    October 1, 1999
+ *    October 6, 1999
  *    
  *    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.4c are Y2K compliant.  It is my belief that earlier
+ *    upward through 1.0.4d 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
@@ -117,7 +117,7 @@
  * Copyright (c) 1996, 1997 Andreas Dilger
  * (libpng versions 0.90, December 1996, through 0.96, May 1997)
  * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
- * (libpng versions 0.97, January 1998, through 1.0.4c, October 1, 1999)
+ * (libpng versions 0.97, January 1998, through 1.0.4d, October 6, 1999)
  *
  * For the purposes of this copyright and license, "Contributing Authors"
  * is defined as the following set of individuals:
@@ -208,7 +208,7 @@
  */
 
 /* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.0.4c"
+#define PNG_LIBPNG_VER_STRING "1.0.4d"
 
 /* Careful here.  At one time, Guy wanted to use 082, but that would be octal.
  * We must not include leading zeros.
@@ -644,8 +644,8 @@
 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
     defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
    png_voidp user_transform_ptr; /* user supplied struct for user transform */
-   int user_transform_depth;    /* bit depth of user transformed pixels */
-   int user_transform_channels; /* channels in user transformed pixels */
+   png_byte user_transform_depth;    /* bit depth of user transformed pixels */
+   png_byte user_transform_channels; /* channels in user transformed pixels */
 #endif
 
    png_uint_32 mode;          /* tells us where we are in the PNG file */
@@ -806,9 +806,9 @@
 };
 
 /* This prevents a compiler error in png_get_copyright() in png.c if png.c
-and png.h are both at * version 1.0.4c
+and png.h are both at * version 1.0.4d
  */
-typedef png_structp version_1_0_4c;
+typedef png_structp version_1_0_4d;
 
 typedef png_struct FAR * FAR * png_structpp;
 
@@ -1629,7 +1629,7 @@
 {
    if(png_ptr == NULL)
      /* silence compiler warning about unused png_ptr */ ;
-   return("\n libpng version 1.0.4c - October 1, 1999 (header)\n");
+   return("\n libpng version 1.0.4d - October 6, 1999 (header)\n");
 }
 #endif
 
diff --git a/pngasmrd.h b/pngasmrd.h
index e6c9c02..27b747c 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.4c - October 1, 1999
+ * libpng 1.0.4d - October 6, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1999 Glenn Randers-Pehrson
  *
@@ -21,7 +21,7 @@
 /* Set this in the makefile for gcc on Pentium, not in pngconf.h */
 #ifdef PNG_USE_PNGGCCRD
 /* Platform must be Pentium.  Makefile must assemble and load pnggccrd.c
- * (not available in libpng 1.0.4c).
+ * (not available in libpng 1.0.4d).
  * MMX will be detected at run time and used if present.
  */
 #define PNG_HAVE_ASSEMBLER_COMBINE_ROW
diff --git a/pngconf.h b/pngconf.h
index 41316d9..63749eb 100644
--- a/pngconf.h
+++ b/pngconf.h
@@ -1,7 +1,7 @@
 
 /* pngconf.h - machine configurable file for libpng
  *
- * libpng 1.0.4c - October 1, 1999
+ * libpng 1.0.4d - October 6, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngerror.c b/pngerror.c
index 63a2b48..b7446d3 100644
--- a/pngerror.c
+++ b/pngerror.c
@@ -1,7 +1,7 @@
 
 /* pngerror.c - stub functions for i/o and memory allocation
  *
- * libpng 1.0.4c - October 1, 1999
+ * libpng 1.0.4d - October 6, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngget.c b/pngget.c
index c27d9b9..7a850e4 100644
--- a/pngget.c
+++ b/pngget.c
@@ -1,7 +1,7 @@
 
 /* pngget.c - retrieval of values from info struct
  *
- * libpng 1.0.4c - October 1, 1999
+ * libpng 1.0.4d - October 6, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngmem.c b/pngmem.c
index cbaa27e..2f5ecd2 100644
--- a/pngmem.c
+++ b/pngmem.c
@@ -1,7 +1,7 @@
 
 /* pngmem.c - stub functions for memory allocation
  *
- * libpng 1.0.4c - October 1, 1999
+ * libpng 1.0.4d - October 6, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngnow.png b/pngnow.png
index 16280e7..2172b49 100644
--- a/pngnow.png
+++ b/pngnow.png
Binary files differ
diff --git a/pngpread.c b/pngpread.c
index d703b81..c66b8ad 100644
--- a/pngpread.c
+++ b/pngpread.c
@@ -1,7 +1,7 @@
 
 /* pngpread.c - read a png file in push mode
  *
- * libpng 1.0.4c - October 1, 1999
+ * libpng 1.0.4d - October 6, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngread.c b/pngread.c
index 1517535..733689e 100644
--- a/pngread.c
+++ b/pngread.c
@@ -1,7 +1,7 @@
 
 /* pngread.c - read a PNG file
  *
- * libpng 1.0.4c - October 1, 1999
+ * libpng 1.0.4d - October 6, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
@@ -531,7 +531,7 @@
  * 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.4c.
+ * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.4d.
  */
 
 void
@@ -580,7 +580,7 @@
  * 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.4c.
+ * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.4d.
  */
 void
 png_read_image(png_structp png_ptr, png_bytepp image)
diff --git a/pngrio.c b/pngrio.c
index 4cc33a7..056d87d 100644
--- a/pngrio.c
+++ b/pngrio.c
@@ -1,7 +1,7 @@
 
 /* pngrio.c - functions for data input
  *
- * libpng 1.0.4c - October 1, 1999
+ * libpng 1.0.4d - October 6, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngrtran.c b/pngrtran.c
index 9c2b0ed..4f94155 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.4c - October 1, 1999
+ * libpng 1.0.4d - October 6, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngrutil.c b/pngrutil.c
index bbf0838..bd98317 100644
--- a/pngrutil.c
+++ b/pngrutil.c
@@ -1,7 +1,7 @@
 
 /* pngrutil.c - utilities to read a PNG file
  *
- * libpng 1.0.4c - October 1, 1999
+ * libpng 1.0.4d - October 6, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngset.c b/pngset.c
index bfec907..751a592 100644
--- a/pngset.c
+++ b/pngset.c
@@ -1,7 +1,7 @@
 
 /* pngset.c - storage of image information into info struct
  *
- * libpng 1.0.4c - October 1, 1999
+ * libpng 1.0.4d - October 6, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
@@ -249,7 +249,7 @@
    png_set_sRGB(png_ptr, info_ptr, intent);
 
 #if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
-   file_gamma = (float).45;
+   file_gamma = (float).45455;
    png_set_gAMA(png_ptr, info_ptr, file_gamma);
 #endif
 
diff --git a/pngtest.c b/pngtest.c
index 51d289c..7267fdb 100644
--- a/pngtest.c
+++ b/pngtest.c
@@ -1,7 +1,7 @@
 
 /* pngtest.c - a simple test program to test libpng
  *
- * libpng 1.0.4c - October 1, 1999
+ * libpng 1.0.4d - October 6, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
@@ -1172,7 +1172,7 @@
 /* Generate a compiler error if there is an old png.h in the search path. */
 void
 png_check_pngtest_version
-   (version_1_0_4c png_h_is_not_version_1_0_4c)
+   (version_1_0_4d png_h_is_not_version_1_0_4d)
 {
-   if(png_h_is_not_version_1_0_4c == NULL) return;
+   if(png_h_is_not_version_1_0_4d == NULL) return;
 }
diff --git a/pngtrans.c b/pngtrans.c
index 57a1f94..9313d47 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.4c - October 1, 1999
+ * libpng 1.0.4d - October 6, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
@@ -578,8 +578,8 @@
 {
    png_debug(1, "in png_set_user_transform_info\n");
    png_ptr->user_transform_ptr = user_transform_ptr;
-   png_ptr->user_transform_depth = user_transform_depth;
-   png_ptr->user_transform_channels = user_transform_channels;
+   png_ptr->user_transform_depth = (png_byte)user_transform_depth;
+   png_ptr->user_transform_channels = (png_byte)user_transform_channels;
 }
 
 /* This function returns a pointer to the user_transform_ptr associated with
diff --git a/pngvcrd.c b/pngvcrd.c
index 4ab0a91..0e9248c 100644
--- a/pngvcrd.c
+++ b/pngvcrd.c
@@ -2,7 +2,7 @@
  *
  * For Intel x86 CPU and Microsoft Visual C++ compiler
  *
- * libpng 1.0.4c - October 1, 1999
+ * libpng 1.0.4d - October 6, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998, Intel Corporation
  * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
@@ -80,8 +80,8 @@
    of interlaced images, depending on the mask value.
    The mask value describes which pixels are to be combined with
    the row.  The pattern always repeats every 8 pixels, so just 8
-   bits are needed.  A one indicates the pixels is to be combined,
-   a zero indicates the pixel is to be skipped.  This is in addition
+   bits are needed.  A one indicates the pixel is to be combined; a
+   zero indicates the pixel is to be skipped.  This is in addition
    to any alpha or transparency value associated with the pixel.  If
    you want all pixels to be combined, pass 0xff (255) in mask.  */
 
@@ -91,12 +91,17 @@
 void
 png_combine_row(png_structp png_ptr, png_bytep row, int mask)
 {
+#ifdef DISABLE_PNGVCRD_COMBINE
    int save_mmx_supported = mmx_supported;
+#endif
+
    png_debug(1,"in png_combine_row_asm\n");
 
+#ifdef DISABLE_PNGVCRD_COMBINE
    if ((png_ptr->transformations & PNG_INTERLACE) && png_ptr->pass != 6)
        mmx_supported = 0;
    else
+#endif
       if (mmx_supported == 2)
           mmx_supported = mmxsupport();
 
@@ -105,6 +110,8 @@
       png_memcpy(row, png_ptr->row_buf + 1,
        (png_size_t)((png_ptr->width * png_ptr->row_info.pixel_depth + 7) >> 3));
    }
+   /* GRR:  add "else if (mask == 0)" case?
+    *       or does png_combine_row() not even get called in that case? */
    else
    {
       switch (png_ptr->row_info.pixel_depth)
@@ -220,6 +227,7 @@
             }
             break;
          }
+
          case 4:
          {
             png_bytep sp;
@@ -273,6 +281,7 @@
             }
             break;
          }
+
          case 8:
          {
             png_bytep srcptr;
@@ -305,7 +314,7 @@
                   pand       mm0,mm7       //nonzero if keep byte
                   pcmpeqb    mm0,mm6       //zeros->1s, v versa
 
-                  mov        ecx,len       //load length of line
+                  mov        ecx,len       //load length of line (pixels)
                   mov        esi,srcptr    //load source
                   mov        ebx,dstptr    //load dest
                   cmp        ecx,0         //lcr
@@ -353,9 +362,9 @@
                register unsigned int incr1, initial_val, final_val;
                png_size_t pixel_bytes;
                png_uint_32 i;
-               //if ((mask != 0x0f) && (mask != 0x33))
                register int disp = png_pass_inc[png_ptr->pass];
                int offset_table[7] = {0, 4, 0, 2, 0, 1, 0};
+
                pixel_bytes = (png_ptr->row_info.pixel_depth >> 3);
                srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]*
                   pixel_bytes;
@@ -372,7 +381,7 @@
             } /* end of else */
 
             break;
-         }       //end 8bpp
+         }       // end 8 bpp
 
          case 16:
          {
@@ -483,7 +492,7 @@
             } /* end of else */
 
             break;
-         }
+         }       // end 16 bpp
 
          case 24:
          {
@@ -596,6 +605,7 @@
                png_uint_32 i;
                register int disp = png_pass_inc[png_ptr->pass];
                int offset_table[7] = {0, 4, 0, 2, 0, 1, 0};
+
                pixel_bytes = (png_ptr->row_info.pixel_depth >> 3);
                srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]*
                   pixel_bytes;
@@ -612,7 +622,7 @@
             } /* end of else */
 
             break;
-         }       //end 24bpp
+         }       // end 24 bpp
 
          case 32:
          {
@@ -734,6 +744,7 @@
                png_uint_32 i;
                register int disp = png_pass_inc[png_ptr->pass];
                int offset_table[7] = {0, 4, 0, 2, 0, 1, 0};
+
                pixel_bytes = (png_ptr->row_info.pixel_depth >> 3);
                srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]*
                   pixel_bytes;
@@ -750,7 +761,7 @@
             } /* end of else */
 
             break;
-         }       //end 32bpp
+         }       // end 32 bpp
 
          case 48:
          {
@@ -890,6 +901,7 @@
                png_uint_32 i;
                register int disp = png_pass_inc[png_ptr->pass];
                int offset_table[7] = {0, 4, 0, 2, 0, 1, 0};
+
                pixel_bytes = (png_ptr->row_info.pixel_depth >> 3);
                srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]*
                   pixel_bytes;
@@ -904,8 +916,9 @@
                   dstptr += incr1;
                }
             } /* end of else */
-            break;  // end 48 bpp
-         }
+
+            break;
+         }       // end 48 bpp
 
          default:
          {
@@ -916,6 +929,7 @@
             unsigned int i;
             register int disp = png_pass_inc[png_ptr->pass];  // get the offset
             register unsigned int incr1, initial_val, final_val;
+
             pixel_bytes = (png_ptr->row_info.pixel_depth >> 3);
             sptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]*
                pixel_bytes;
@@ -932,8 +946,11 @@
             break;
          }
       } /* end switch (png_ptr->row_info.pixel_depth) */
-   }
+   } /* end if (non-trivial mask) */
+
+#ifdef DISABLE_PNGVCRD_COMBINE
    mmx_supported = save_mmx_supported;
+#endif
 
 } /* end png_combine_row() */
 
@@ -944,12 +961,24 @@
 png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
    png_uint_32 transformations)
 {
-
+#ifndef ENABLE_PNGVCRD_INTERLACE
    int save_mmx_supported = mmx_supported;
+#endif
+
    png_debug(1,"in png_do_read_interlace\n");
 
-   // mmx_supported = mmxsupport();  // doesn't work
-   mmx_supported = 0;
+#ifndef ENABLE_PNGVCRD_INTERLACE
+   /* passes 0 and 2 affect rpng2-win + stefan_full_rgba.png
+    * symptom: first pixel in every 4th or 8th row is wrong color
+    * pass < 6 affects pngtest + any interlaced png
+    * symptom: corruption of heap, crash in png_destroy_read
+    */
+   if(pass < 6)
+      mmx_supported = 0;
+#else
+   if (mmx_supported == 2)
+       mmx_supported = mmxsupport();
+#endif
 
    if (row != NULL && row_info != NULL)
    {
@@ -1848,7 +1877,10 @@
       row_info->rowbytes = ((final_width *
          (png_uint_32)row_info->pixel_depth + 7) >> 3);
    }
+
+#ifndef ENABLE_PNGVCRD_INTERLACE
    mmx_supported = save_mmx_supported;
+#endif
 }
 
 #endif /* PNG_READ_INTERLACING_SUPPORTED */
@@ -3769,7 +3801,7 @@
                p = b - c;
                pc = a - c;
 
-#ifdef    PNG_USE_ABS
+#ifdef PNG_USE_ABS
                pa = abs(p);
                pb = abs(pc);
                pc = abs(p + pc);
diff --git a/pngwio.c b/pngwio.c
index d5444a0..13a35b2 100644
--- a/pngwio.c
+++ b/pngwio.c
@@ -1,7 +1,7 @@
 
 /* pngwio.c - functions for data output
  *
- * libpng 1.0.4c - October 1, 1999
+ * libpng 1.0.4d - October 6, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngwrite.c b/pngwrite.c
index 9830ca1..33ac2a7 100644
--- a/pngwrite.c
+++ b/pngwrite.c
@@ -1,7 +1,7 @@
 
 /* pngwrite.c - general routines to write a PNG file
  *
- * libpng 1.0.4c - October 1, 1999
+ * libpng 1.0.4d - October 6, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngwtran.c b/pngwtran.c
index cd32a62..bdedf5b 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.4c - October 1, 1999
+ * libpng 1.0.4d - October 6, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngwutil.c b/pngwutil.c
index b7a104b..f3ff2e9 100644
--- a/pngwutil.c
+++ b/pngwutil.c
@@ -1,7 +1,7 @@
 
 /* pngwutil.c - utilities to write a PNG file
  *
- * libpng 1.0.4c - October 1, 1999
+ * libpng 1.0.4d - October 6, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/scripts/makefile.beos b/scripts/makefile.beos
index 0a89151..dbebbe0 100644
--- a/scripts/makefile.beos
+++ b/scripts/makefile.beos
@@ -31,7 +31,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.0.4c
+PNGMIN = 1.0.4d
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 # where make install puts libpng.a, libpng.so*, and png.h
diff --git a/scripts/makefile.dec b/scripts/makefile.dec
index 51403ca..9cfaf7e 100644
--- a/scripts/makefile.dec
+++ b/scripts/makefile.dec
@@ -14,7 +14,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.0.4c
+PNGMIN = 1.0.4d
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 CC=cc
diff --git a/scripts/makefile.linux b/scripts/makefile.linux
index c84b6ce..79c824b 100644
--- a/scripts/makefile.linux
+++ b/scripts/makefile.linux
@@ -34,7 +34,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.0.4c
+PNGMIN = 1.0.4d
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
diff --git a/scripts/makefile.sco b/scripts/makefile.sco
index 1e51004..7f6b81a 100644
--- a/scripts/makefile.sco
+++ b/scripts/makefile.sco
@@ -25,7 +25,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.0.4c
+PNGMIN = 1.0.4d
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
diff --git a/scripts/makefile.solaris b/scripts/makefile.solaris
index fcc3078..005f259 100644
--- a/scripts/makefile.solaris
+++ b/scripts/makefile.solaris
@@ -36,7 +36,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.0.4c
+PNGMIN = 1.0.4d
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
diff --git a/scripts/pngdef.pas b/scripts/pngdef.pas
index 1441808..995ddaf 100644
--- a/scripts/pngdef.pas
+++ b/scripts/pngdef.pas
@@ -3,7 +3,7 @@
 interface
 
 const
-  PNG_LIBPNG_VER_STRING = '1.0.4c';
+  PNG_LIBPNG_VER_STRING = '1.0.4d';
   PNG_LIBPNG_VER        =  10005;
 
 type