wok-next rev 20645

Up libjpeg-turbo (1.5.3), libpng16 (1.6.34), libraw (0.18.7), shared-mime-info (1.9), tree (1.7.0), xapian (1.4.5); add time.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Tue May 01 23:19:32 2018 +0300 (2018-05-01)
parents ef21df344980
children 507b798ce12b
files cpio/receipt libjpeg-turbo/receipt libpng16/receipt libpng16/stuff/patches/README libpng16/stuff/patches/libpng-1.6.28-apng.patch libpng16/stuff/patches/libpng-1.6.34-apng.patch libpng16/stuff/patches/series libraw/receipt shared-mime-info/receipt shared-mime-info/stuff/patches/slitaz-locales.patch time/receipt tree/receipt wv/receipt xapian/receipt yaml/receipt yasm/receipt zip/receipt
line diff
     1.1 --- a/cpio/receipt	Tue May 01 17:41:04 2018 +0300
     1.2 +++ b/cpio/receipt	Tue May 01 23:19:32 2018 +0300
     1.3 @@ -1,42 +1,39 @@
     1.4 -# SliTaz package receipt.
     1.5 +# SliTaz package receipt v2.
     1.6  
     1.7  PACKAGE="cpio"
     1.8  VERSION="2.12"
     1.9  CATEGORY="base-system"
    1.10 -SHORT_DESC="GNU cpio archiver."
    1.11 +SHORT_DESC="GNU cpio archiver"
    1.12  MAINTAINER="pankso@slitaz.org"
    1.13  LICENSE="GPL3"
    1.14  WEB_SITE="https://www.gnu.org/software/cpio/"
    1.15 +LFS="http://www.linuxfromscratch.org/blfs/view/stable/general/cpio.html"
    1.16  
    1.17  TARBALL="$PACKAGE-$VERSION.tar.bz2"
    1.18  WGET_URL="$GNU_MIRROR/$PACKAGE/$TARBALL"
    1.19  
    1.20 -DEPENDS="glibc-base"
    1.21  BUILD_DEPENDS="tar gettext texinfo"
    1.22  
    1.23 -# Rules to configure and make the package.
    1.24 -compile_rules()
    1.25 -{
    1.26 +compile_rules() {
    1.27  	./configure \
    1.28  		--bindir=/bin \
    1.29  		--enable-mt \
    1.30  		--with-rmt=$install/usr/libexec/rmt \
    1.31 -		$CONFIGURE_ARGS  &&
    1.32 +		$CONFIGURE_ARGS &&
    1.33  	make &&
    1.34  	makeinfo --html            -o doc/html      doc/cpio.texi &&
    1.35  	makeinfo --html --no-split -o doc/cpio.html doc/cpio.texi &&
    1.36  	makeinfo --plaintext       -o doc/cpio.txt  doc/cpio.texi &&
    1.37 -	make install
    1.38 +	make install || return 1
    1.39  
    1.40  	docdir=$install/usr/share/doc/$PACKAGE-$VERSION
    1.41 -	install -v -m755 -d $docdir/html
    1.42 +	install -v -m755 -d               $docdir/html
    1.43  	install -v -m644    doc/html/*    $docdir/html
    1.44  	install -v -m644    doc/cpio.html $docdir
    1.45  	install -v -m644    doc/cpio.txt  $docdir
    1.46  }
    1.47  
    1.48 -# Rules to gen a SliTaz package suitable for Tazpkg.
    1.49 -genpkg_rules()
    1.50 -{
    1.51 +genpkg_rules() {
    1.52  	copy @std
    1.53 +	DEPENDS="glibc-base"
    1.54  }
     2.1 --- a/libjpeg-turbo/receipt	Tue May 01 17:41:04 2018 +0300
     2.2 +++ b/libjpeg-turbo/receipt	Tue May 01 23:19:32 2018 +0300
     2.3 @@ -1,12 +1,13 @@
     2.4  # SliTaz package receipt v2.
     2.5  
     2.6  PACKAGE="libjpeg-turbo"
     2.7 -VERSION="1.5.1"
     2.8 +VERSION="1.5.3"
     2.9  CATEGORY="libs"
    2.10  SHORT_DESC="Accelerated JPEG image codec"
    2.11  MAINTAINER="pascal.bellard@slitaz.org"
    2.12  LICENSE="MIT"
    2.13 -WEB_SITE="http://libjpeg-turbo.virtualgl.org/"
    2.14 +WEB_SITE="https://libjpeg-turbo.org/"
    2.15 +LFS="http://www.linuxfromscratch.org/blfs/view/stable/general/libjpeg.html"
    2.16  HOST_ARCH="i486 x86_64"
    2.17  
    2.18  TARBALL="$PACKAGE-$VERSION.tar.gz"
    2.19 @@ -34,6 +35,7 @@
    2.20  			;;
    2.21  		jpeg-turbo)
    2.22  			copy bin/
    2.23 +			DEPENDS="libjpeg-turbo"
    2.24  			CAT="x-window|programs"
    2.25  			TAGS="jpeg jpg"
    2.26  			;;
     3.1 --- a/libpng16/receipt	Tue May 01 17:41:04 2018 +0300
     3.2 +++ b/libpng16/receipt	Tue May 01 23:19:32 2018 +0300
     3.3 @@ -1,23 +1,25 @@
     3.4  # SliTaz package receipt v2.
     3.5  
     3.6  PACKAGE="libpng16"
     3.7 -VERSION="1.6.28"
     3.8 +VERSION="1.6.34"
     3.9  CATEGORY="libs"
    3.10  SHORT_DESC="PNG images library 1.6 series with APNG support"
    3.11  MAINTAINER="al.bobylev@gmail.com"
    3.12  LICENSE="zlib/libpng"
    3.13  WEB_SITE="http://www.libpng.org/pub/png/libpng.html"
    3.14 +LFS="http://www.linuxfromscratch.org/blfs/view/stable/general/libpng.html"
    3.15  
    3.16  TARBALL="libpng-$VERSION.tar.xz"
    3.17  WGET_URL="$SF_MIRROR/libpng/$TARBALL"
    3.18  
    3.19 -#BUILD_DEPENDS="gawk zlib-dev"
    3.20  BUILD_DEPENDS="zlib-dev"
    3.21  SPLIT="libpng16-dev"
    3.22  
    3.23  compile_rules() {
    3.24  	LIBS=-lpthread \
    3.25 -	./configure $CONFIGURE_ARGS &&
    3.26 +	./configure \
    3.27 +		--disable-static \
    3.28 +		$CONFIGURE_ARGS &&
    3.29  	fix libtool &&
    3.30  	make &&
    3.31  	make install || return 1
    3.32 @@ -38,7 +40,7 @@
    3.33  			;;
    3.34  		libpng16-dev)
    3.35  			copy @dev
    3.36 -			DEPENDS="zlib-dev"
    3.37 +			DEPENDS="libpng16 zlib-dev"
    3.38  			;;
    3.39  	esac
    3.40  }
     4.1 --- a/libpng16/stuff/patches/README	Tue May 01 17:41:04 2018 +0300
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,4 +0,0 @@
     4.4 -Original patch file [1] was ungzipped and modified to use with `patch -p1`
     4.5 -instead of `patch -p0`.
     4.6 -
     4.7 -[1] http://downloads.sourceforge.net/project/apng/libpng/libpng16/libpng-1.6.28-apng.patch.gz
     5.1 --- a/libpng16/stuff/patches/libpng-1.6.28-apng.patch	Tue May 01 17:41:04 2018 +0300
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,1629 +0,0 @@
     5.4 -Index: LICENSE
     5.5 -===================================================================
     5.6 ---- a/LICENSE
     5.7 -+++ b/LICENSE
     5.8 -@@ -8,6 +8,12 @@
     5.9 - If you modify libpng you may insert additional notices immediately following
    5.10 - this sentence.
    5.11 - 
    5.12 -+This modified version of libpng code adds animated PNG support and is
    5.13 -+released under the libpng license described below. The modifications are
    5.14 -+Copyright (c) 2006-2007 Andrew Smith, Copyright (c) 2008-2017 Max Stepin,
    5.15 -+and are delimited by "#ifdef PNG_APNG_SUPPORTED / #endif" directives
    5.16 -+surrounding them in the modified libpng source files.
    5.17 -+
    5.18 - This code is released under the libpng license.
    5.19 - 
    5.20 - libpng versions 1.0.7, July 1, 2000 through 1.6.28, January 5, 2017 are
    5.21 -Index: pngread.c
    5.22 -===================================================================
    5.23 ---- a/pngread.c
    5.24 -+++ b/pngread.c
    5.25 -@@ -161,6 +161,9 @@
    5.26 - 
    5.27 -       else if (chunk_name == png_IDAT)
    5.28 -       {
    5.29 -+#ifdef PNG_READ_APNG_SUPPORTED
    5.30 -+         png_have_info(png_ptr, info_ptr);
    5.31 -+#endif
    5.32 -          png_ptr->idat_size = length;
    5.33 -          break;
    5.34 -       }
    5.35 -@@ -250,6 +253,17 @@
    5.36 -          png_handle_iTXt(png_ptr, info_ptr, length);
    5.37 - #endif
    5.38 - 
    5.39 -+#ifdef PNG_READ_APNG_SUPPORTED
    5.40 -+      else if (chunk_name == png_acTL)
    5.41 -+         png_handle_acTL(png_ptr, info_ptr, length);
    5.42 -+
    5.43 -+      else if (chunk_name == png_fcTL)
    5.44 -+         png_handle_fcTL(png_ptr, info_ptr, length);
    5.45 -+
    5.46 -+      else if (chunk_name == png_fdAT)
    5.47 -+         png_handle_fdAT(png_ptr, info_ptr, length);
    5.48 -+#endif
    5.49 -+
    5.50 -       else
    5.51 -          png_handle_unknown(png_ptr, info_ptr, length,
    5.52 -              PNG_HANDLE_CHUNK_AS_DEFAULT);
    5.53 -@@ -257,6 +271,72 @@
    5.54 - }
    5.55 - #endif /* SEQUENTIAL_READ */
    5.56 - 
    5.57 -+#ifdef PNG_READ_APNG_SUPPORTED
    5.58 -+void PNGAPI
    5.59 -+png_read_frame_head(png_structp png_ptr, png_infop info_ptr)
    5.60 -+{
    5.61 -+    png_byte have_chunk_after_DAT; /* after IDAT or after fdAT */
    5.62 -+
    5.63 -+    png_debug(0, "Reading frame head");
    5.64 -+
    5.65 -+    if ((png_ptr->mode & PNG_HAVE_acTL) == 0)
    5.66 -+        png_error(png_ptr, "attempt to png_read_frame_head() but "
    5.67 -+                           "no acTL present");
    5.68 -+
    5.69 -+    /* do nothing for the main IDAT */
    5.70 -+    if (png_ptr->num_frames_read == 0)
    5.71 -+        return;
    5.72 -+
    5.73 -+    png_read_reset(png_ptr);
    5.74 -+    png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
    5.75 -+    png_ptr->mode &= ~PNG_HAVE_fcTL;
    5.76 -+
    5.77 -+    have_chunk_after_DAT = 0;
    5.78 -+    for (;;)
    5.79 -+    {
    5.80 -+        png_uint_32 length = png_read_chunk_header(png_ptr);
    5.81 -+
    5.82 -+        if (png_ptr->chunk_name == png_IDAT)
    5.83 -+        {
    5.84 -+            /* discard trailing IDATs for the first frame */
    5.85 -+            if (have_chunk_after_DAT != 0 || png_ptr->num_frames_read > 1)
    5.86 -+                png_error(png_ptr, "png_read_frame_head(): out of place IDAT");
    5.87 -+            png_crc_finish(png_ptr, length);
    5.88 -+        }
    5.89 -+
    5.90 -+        else if (png_ptr->chunk_name == png_fcTL)
    5.91 -+        {
    5.92 -+            png_handle_fcTL(png_ptr, info_ptr, length);
    5.93 -+            have_chunk_after_DAT = 1;
    5.94 -+        }
    5.95 -+
    5.96 -+        else if (png_ptr->chunk_name == png_fdAT)
    5.97 -+        {
    5.98 -+            png_ensure_sequence_number(png_ptr, length);
    5.99 -+
   5.100 -+            /* discard trailing fdATs for frames other than the first */
   5.101 -+            if (have_chunk_after_DAT == 0 && png_ptr->num_frames_read > 1)
   5.102 -+                png_crc_finish(png_ptr, length - 4);
   5.103 -+            else if (png_ptr->mode & PNG_HAVE_fcTL)
   5.104 -+            {
   5.105 -+                png_ptr->idat_size = length - 4;
   5.106 -+                png_ptr->mode |= PNG_HAVE_IDAT;
   5.107 -+
   5.108 -+                break;
   5.109 -+            }
   5.110 -+            else
   5.111 -+                png_error(png_ptr, "png_read_frame_head(): out of place fdAT");
   5.112 -+        }
   5.113 -+        else
   5.114 -+        {
   5.115 -+            png_warning(png_ptr, "Skipped (ignored) a chunk "
   5.116 -+                                 "between APNG chunks");
   5.117 -+            png_crc_finish(png_ptr, length);
   5.118 -+        }
   5.119 -+    }
   5.120 -+}
   5.121 -+#endif /* READ_APNG */
   5.122 -+
   5.123 - /* Optional call to update the users info_ptr structure */
   5.124 - void PNGAPI
   5.125 - png_read_update_info(png_structrp png_ptr, png_inforp info_ptr)
   5.126 -Index: pngget.c
   5.127 -===================================================================
   5.128 ---- a/pngget.c
   5.129 -+++ b/pngget.c
   5.130 -@@ -1216,4 +1216,166 @@
   5.131 - #  endif
   5.132 - #endif
   5.133 - 
   5.134 -+#ifdef PNG_APNG_SUPPORTED
   5.135 -+png_uint_32 PNGAPI
   5.136 -+png_get_acTL(png_structp png_ptr, png_infop info_ptr,
   5.137 -+             png_uint_32 *num_frames, png_uint_32 *num_plays)
   5.138 -+{
   5.139 -+    png_debug1(1, "in %s retrieval function", "acTL");
   5.140 -+
   5.141 -+    if (png_ptr != NULL && info_ptr != NULL &&
   5.142 -+        (info_ptr->valid & PNG_INFO_acTL) != 0 &&
   5.143 -+        num_frames != NULL && num_plays != NULL)
   5.144 -+    {
   5.145 -+        *num_frames = info_ptr->num_frames;
   5.146 -+        *num_plays = info_ptr->num_plays;
   5.147 -+        return (1);
   5.148 -+    }
   5.149 -+
   5.150 -+    return (0);
   5.151 -+}
   5.152 -+
   5.153 -+png_uint_32 PNGAPI
   5.154 -+png_get_num_frames(png_structp png_ptr, png_infop info_ptr)
   5.155 -+{
   5.156 -+    png_debug(1, "in png_get_num_frames()");
   5.157 -+
   5.158 -+    if (png_ptr != NULL && info_ptr != NULL)
   5.159 -+        return (info_ptr->num_frames);
   5.160 -+    return (0);
   5.161 -+}
   5.162 -+
   5.163 -+png_uint_32 PNGAPI
   5.164 -+png_get_num_plays(png_structp png_ptr, png_infop info_ptr)
   5.165 -+{
   5.166 -+    png_debug(1, "in png_get_num_plays()");
   5.167 -+
   5.168 -+    if (png_ptr != NULL && info_ptr != NULL)
   5.169 -+        return (info_ptr->num_plays);
   5.170 -+    return (0);
   5.171 -+}
   5.172 -+
   5.173 -+png_uint_32 PNGAPI
   5.174 -+png_get_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
   5.175 -+             png_uint_32 *width, png_uint_32 *height,
   5.176 -+             png_uint_32 *x_offset, png_uint_32 *y_offset,
   5.177 -+             png_uint_16 *delay_num, png_uint_16 *delay_den,
   5.178 -+             png_byte *dispose_op, png_byte *blend_op)
   5.179 -+{
   5.180 -+    png_debug1(1, "in %s retrieval function", "fcTL");
   5.181 -+
   5.182 -+    if (png_ptr != NULL && info_ptr != NULL &&
   5.183 -+        (info_ptr->valid & PNG_INFO_fcTL) != 0 &&
   5.184 -+        width != NULL && height != NULL &&
   5.185 -+        x_offset != NULL && y_offset != NULL &&
   5.186 -+        delay_num != NULL && delay_den != NULL &&
   5.187 -+        dispose_op != NULL && blend_op != NULL)
   5.188 -+    {
   5.189 -+        *width = info_ptr->next_frame_width;
   5.190 -+        *height = info_ptr->next_frame_height;
   5.191 -+        *x_offset = info_ptr->next_frame_x_offset;
   5.192 -+        *y_offset = info_ptr->next_frame_y_offset;
   5.193 -+        *delay_num = info_ptr->next_frame_delay_num;
   5.194 -+        *delay_den = info_ptr->next_frame_delay_den;
   5.195 -+        *dispose_op = info_ptr->next_frame_dispose_op;
   5.196 -+        *blend_op = info_ptr->next_frame_blend_op;
   5.197 -+        return (1);
   5.198 -+    }
   5.199 -+
   5.200 -+    return (0);
   5.201 -+}
   5.202 -+
   5.203 -+png_uint_32 PNGAPI
   5.204 -+png_get_next_frame_width(png_structp png_ptr, png_infop info_ptr)
   5.205 -+{
   5.206 -+    png_debug(1, "in png_get_next_frame_width()");
   5.207 -+
   5.208 -+    if (png_ptr != NULL && info_ptr != NULL)
   5.209 -+        return (info_ptr->next_frame_width);
   5.210 -+    return (0);
   5.211 -+}
   5.212 -+
   5.213 -+png_uint_32 PNGAPI
   5.214 -+png_get_next_frame_height(png_structp png_ptr, png_infop info_ptr)
   5.215 -+{
   5.216 -+    png_debug(1, "in png_get_next_frame_height()");
   5.217 -+
   5.218 -+    if (png_ptr != NULL && info_ptr != NULL)
   5.219 -+        return (info_ptr->next_frame_height);
   5.220 -+    return (0);
   5.221 -+}
   5.222 -+
   5.223 -+png_uint_32 PNGAPI
   5.224 -+png_get_next_frame_x_offset(png_structp png_ptr, png_infop info_ptr)
   5.225 -+{
   5.226 -+    png_debug(1, "in png_get_next_frame_x_offset()");
   5.227 -+
   5.228 -+    if (png_ptr != NULL && info_ptr != NULL)
   5.229 -+        return (info_ptr->next_frame_x_offset);
   5.230 -+    return (0);
   5.231 -+}
   5.232 -+
   5.233 -+png_uint_32 PNGAPI
   5.234 -+png_get_next_frame_y_offset(png_structp png_ptr, png_infop info_ptr)
   5.235 -+{
   5.236 -+    png_debug(1, "in png_get_next_frame_y_offset()");
   5.237 -+
   5.238 -+    if (png_ptr != NULL && info_ptr != NULL)
   5.239 -+        return (info_ptr->next_frame_y_offset);
   5.240 -+    return (0);
   5.241 -+}
   5.242 -+
   5.243 -+png_uint_16 PNGAPI
   5.244 -+png_get_next_frame_delay_num(png_structp png_ptr, png_infop info_ptr)
   5.245 -+{
   5.246 -+    png_debug(1, "in png_get_next_frame_delay_num()");
   5.247 -+
   5.248 -+    if (png_ptr != NULL && info_ptr != NULL)
   5.249 -+        return (info_ptr->next_frame_delay_num);
   5.250 -+    return (0);
   5.251 -+}
   5.252 -+
   5.253 -+png_uint_16 PNGAPI
   5.254 -+png_get_next_frame_delay_den(png_structp png_ptr, png_infop info_ptr)
   5.255 -+{
   5.256 -+    png_debug(1, "in png_get_next_frame_delay_den()");
   5.257 -+
   5.258 -+    if (png_ptr != NULL && info_ptr != NULL)
   5.259 -+        return (info_ptr->next_frame_delay_den);
   5.260 -+    return (0);
   5.261 -+}
   5.262 -+
   5.263 -+png_byte PNGAPI
   5.264 -+png_get_next_frame_dispose_op(png_structp png_ptr, png_infop info_ptr)
   5.265 -+{
   5.266 -+    png_debug(1, "in png_get_next_frame_dispose_op()");
   5.267 -+
   5.268 -+    if (png_ptr != NULL && info_ptr != NULL)
   5.269 -+        return (info_ptr->next_frame_dispose_op);
   5.270 -+    return (0);
   5.271 -+}
   5.272 -+
   5.273 -+png_byte PNGAPI
   5.274 -+png_get_next_frame_blend_op(png_structp png_ptr, png_infop info_ptr)
   5.275 -+{
   5.276 -+    png_debug(1, "in png_get_next_frame_blend_op()");
   5.277 -+
   5.278 -+    if (png_ptr != NULL && info_ptr != NULL)
   5.279 -+        return (info_ptr->next_frame_blend_op);
   5.280 -+    return (0);
   5.281 -+}
   5.282 -+
   5.283 -+png_byte PNGAPI
   5.284 -+png_get_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr)
   5.285 -+{
   5.286 -+    png_debug(1, "in png_first_frame_is_hidden()");
   5.287 -+
   5.288 -+    if (png_ptr != NULL)
   5.289 -+       return (png_byte)(png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN);
   5.290 -+
   5.291 -+    PNG_UNUSED(info_ptr)
   5.292 -+
   5.293 -+    return 0;
   5.294 -+}
   5.295 -+#endif /* APNG */
   5.296 - #endif /* READ || WRITE */
   5.297 -Index: png.c
   5.298 -===================================================================
   5.299 ---- a/png.c
   5.300 -+++ b/png.c
   5.301 -@@ -776,17 +776,21 @@
   5.302 - #else
   5.303 - #  ifdef __STDC__
   5.304 -    return PNG_STRING_NEWLINE \
   5.305 --      "libpng version 1.6.28 - January 5, 2017" PNG_STRING_NEWLINE \
   5.306 -+      "libpng version 1.6.28+apng - January 5, 2017" PNG_STRING_NEWLINE \
   5.307 -       "Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson" \
   5.308 -       PNG_STRING_NEWLINE \
   5.309 -       "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
   5.310 -       "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
   5.311 --      PNG_STRING_NEWLINE;
   5.312 -+      PNG_STRING_NEWLINE \
   5.313 -+      "Portions Copyright (c) 2006-2007 Andrew Smith" PNG_STRING_NEWLINE \
   5.314 -+      "Portions Copyright (c) 2008-2017 Max Stepin" PNG_STRING_NEWLINE ;
   5.315 - #  else
   5.316 --   return "libpng version 1.6.28 - January 5, 2017\
   5.317 -+   return "libpng version 1.6.28+apng - January 5, 2017\
   5.318 -       Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson\
   5.319 -       Copyright (c) 1996-1997 Andreas Dilger\
   5.320 --      Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
   5.321 -+      Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\
   5.322 -+      Portions Copyright (c) 2006-2007 Andrew Smith\
   5.323 -+      Portions Copyright (c) 2008-2017 Max Stepin";
   5.324 - #  endif
   5.325 - #endif
   5.326 - }
   5.327 -Index: png.h
   5.328 -===================================================================
   5.329 ---- a/png.h
   5.330 -+++ b/png.h
   5.331 -@@ -23,6 +23,12 @@
   5.332 -  * If you modify libpng you may insert additional notices immediately following
   5.333 -  * this sentence.
   5.334 -  *
   5.335 -+ * This modified version of libpng code adds animated PNG support and is
   5.336 -+ * released under the libpng license described below. The modifications are
   5.337 -+ * Copyright (c) 2006-2007 Andrew Smith, Copyright (c) 2008-2017 Max Stepin,
   5.338 -+ * and are delimited by "#ifdef PNG_APNG_SUPPORTED / #endif" directives
   5.339 -+ * surrounding them in the modified libpng source files.
   5.340 -+ *
   5.341 -  * This code is released under the libpng license.
   5.342 -  *
   5.343 -  * libpng versions 1.0.7, July 1, 2000 through 1.6.28, January 5, 2017 are
   5.344 -@@ -307,8 +313,9 @@
   5.345 -  */
   5.346 - 
   5.347 - /* Version information for png.h - this should match the version in png.c */
   5.348 --#define PNG_LIBPNG_VER_STRING "1.6.28"
   5.349 --#define PNG_HEADER_VERSION_STRING " libpng version 1.6.28 - January 5, 2017\n"
   5.350 -+#define PNG_LIBPNG_VER_STRING "1.6.28+apng"
   5.351 -+#define PNG_HEADER_VERSION_STRING \
   5.352 -+     " libpng version 1.6.28+apng - January 5, 2017\n"
   5.353 - 
   5.354 - #define PNG_LIBPNG_VER_SONUM   16
   5.355 - #define PNG_LIBPNG_VER_DLLNUM  16
   5.356 -@@ -359,6 +366,10 @@
   5.357 - #   include "pnglibconf.h"
   5.358 - #endif
   5.359 - 
   5.360 -+#define PNG_APNG_SUPPORTED
   5.361 -+#define PNG_READ_APNG_SUPPORTED
   5.362 -+#define PNG_WRITE_APNG_SUPPORTED
   5.363 -+
   5.364 - #ifndef PNG_VERSION_INFO_ONLY
   5.365 - /* Machine specific configuration. */
   5.366 - #  include "pngconf.h"
   5.367 -@@ -454,6 +465,17 @@
   5.368 -  * See pngconf.h for base types that vary by machine/system
   5.369 -  */
   5.370 - 
   5.371 -+#ifdef PNG_APNG_SUPPORTED
   5.372 -+/* dispose_op flags from inside fcTL */
   5.373 -+#define PNG_DISPOSE_OP_NONE        0x00
   5.374 -+#define PNG_DISPOSE_OP_BACKGROUND  0x01
   5.375 -+#define PNG_DISPOSE_OP_PREVIOUS    0x02
   5.376 -+
   5.377 -+/* blend_op flags from inside fcTL */
   5.378 -+#define PNG_BLEND_OP_SOURCE        0x00
   5.379 -+#define PNG_BLEND_OP_OVER          0x01
   5.380 -+#endif /* APNG */
   5.381 -+
   5.382 - /* This triggers a compiler error in png.c, if png.c and png.h
   5.383 -  * do not agree upon the version number.
   5.384 -  */
   5.385 -@@ -774,6 +796,10 @@
   5.386 - #define PNG_INFO_sPLT 0x2000U  /* ESR, 1.0.6 */
   5.387 - #define PNG_INFO_sCAL 0x4000U  /* ESR, 1.0.6 */
   5.388 - #define PNG_INFO_IDAT 0x8000U  /* ESR, 1.0.6 */
   5.389 -+#ifdef PNG_APNG_SUPPORTED
   5.390 -+#define PNG_INFO_acTL 0x10000U
   5.391 -+#define PNG_INFO_fcTL 0x20000U
   5.392 -+#endif
   5.393 - 
   5.394 - /* This is used for the transformation routines, as some of them
   5.395 -  * change these values for the row.  It also should enable using
   5.396 -@@ -811,6 +837,10 @@
   5.397 - #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
   5.398 - typedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop));
   5.399 - typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop));
   5.400 -+#ifdef PNG_APNG_SUPPORTED
   5.401 -+typedef PNG_CALLBACK(void, *png_progressive_frame_ptr, (png_structp,
   5.402 -+    png_uint_32));
   5.403 -+#endif
   5.404 - 
   5.405 - /* The following callback receives png_uint_32 row_number, int pass for the
   5.406 -  * png_bytep data of the row.  When transforming an interlaced image the
   5.407 -@@ -3240,6 +3270,75 @@
   5.408 -  *  END OF HARDWARE AND SOFTWARE OPTIONS
   5.409 -  ******************************************************************************/
   5.410 - 
   5.411 -+#ifdef PNG_APNG_SUPPORTED
   5.412 -+PNG_EXPORT(246, png_uint_32, png_get_acTL, (png_structp png_ptr,
   5.413 -+   png_infop info_ptr, png_uint_32 *num_frames, png_uint_32 *num_plays));
   5.414 -+
   5.415 -+PNG_EXPORT(247, png_uint_32, png_set_acTL, (png_structp png_ptr,
   5.416 -+   png_infop info_ptr, png_uint_32 num_frames, png_uint_32 num_plays));
   5.417 -+
   5.418 -+PNG_EXPORT(248, png_uint_32, png_get_num_frames, (png_structp png_ptr,
   5.419 -+   png_infop info_ptr));
   5.420 -+
   5.421 -+PNG_EXPORT(249, png_uint_32, png_get_num_plays, (png_structp png_ptr,
   5.422 -+   png_infop info_ptr));
   5.423 -+
   5.424 -+PNG_EXPORT(250, png_uint_32, png_get_next_frame_fcTL,
   5.425 -+   (png_structp png_ptr, png_infop info_ptr, png_uint_32 *width,
   5.426 -+   png_uint_32 *height, png_uint_32 *x_offset, png_uint_32 *y_offset,
   5.427 -+   png_uint_16 *delay_num, png_uint_16 *delay_den, png_byte *dispose_op,
   5.428 -+   png_byte *blend_op));
   5.429 -+
   5.430 -+PNG_EXPORT(251, png_uint_32, png_set_next_frame_fcTL,
   5.431 -+   (png_structp png_ptr, png_infop info_ptr, png_uint_32 width,
   5.432 -+   png_uint_32 height, png_uint_32 x_offset, png_uint_32 y_offset,
   5.433 -+   png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
   5.434 -+   png_byte blend_op));
   5.435 -+
   5.436 -+PNG_EXPORT(252, png_uint_32, png_get_next_frame_width,
   5.437 -+   (png_structp png_ptr, png_infop info_ptr));
   5.438 -+PNG_EXPORT(253, png_uint_32, png_get_next_frame_height,
   5.439 -+   (png_structp png_ptr, png_infop info_ptr));
   5.440 -+PNG_EXPORT(254, png_uint_32, png_get_next_frame_x_offset,
   5.441 -+   (png_structp png_ptr, png_infop info_ptr));
   5.442 -+PNG_EXPORT(255, png_uint_32, png_get_next_frame_y_offset,
   5.443 -+   (png_structp png_ptr, png_infop info_ptr));
   5.444 -+PNG_EXPORT(256, png_uint_16, png_get_next_frame_delay_num,
   5.445 -+   (png_structp png_ptr, png_infop info_ptr));
   5.446 -+PNG_EXPORT(257, png_uint_16, png_get_next_frame_delay_den,
   5.447 -+   (png_structp png_ptr, png_infop info_ptr));
   5.448 -+PNG_EXPORT(258, png_byte, png_get_next_frame_dispose_op,
   5.449 -+   (png_structp png_ptr, png_infop info_ptr));
   5.450 -+PNG_EXPORT(259, png_byte, png_get_next_frame_blend_op,
   5.451 -+   (png_structp png_ptr, png_infop info_ptr));
   5.452 -+PNG_EXPORT(260, png_byte, png_get_first_frame_is_hidden,
   5.453 -+   (png_structp png_ptr, png_infop info_ptr));
   5.454 -+PNG_EXPORT(261, png_uint_32, png_set_first_frame_is_hidden,
   5.455 -+   (png_structp png_ptr, png_infop info_ptr, png_byte is_hidden));
   5.456 -+
   5.457 -+#ifdef PNG_READ_APNG_SUPPORTED
   5.458 -+PNG_EXPORT(262, void, png_read_frame_head, (png_structp png_ptr,
   5.459 -+   png_infop info_ptr));
   5.460 -+#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
   5.461 -+PNG_EXPORT(263, void, png_set_progressive_frame_fn, (png_structp png_ptr,
   5.462 -+   png_progressive_frame_ptr frame_info_fn,
   5.463 -+   png_progressive_frame_ptr frame_end_fn));
   5.464 -+#endif /* PROGRESSIVE_READ */
   5.465 -+#endif /* READ_APNG */
   5.466 -+
   5.467 -+#ifdef PNG_WRITE_APNG_SUPPORTED
   5.468 -+PNG_EXPORT(264, void, png_write_frame_head, (png_structp png_ptr,
   5.469 -+   png_infop info_ptr, png_bytepp row_pointers,
   5.470 -+   png_uint_32 width, png_uint_32 height,
   5.471 -+   png_uint_32 x_offset, png_uint_32 y_offset,
   5.472 -+   png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
   5.473 -+   png_byte blend_op));
   5.474 -+
   5.475 -+PNG_EXPORT(265, void, png_write_frame_tail, (png_structp png_ptr,
   5.476 -+   png_infop info_ptr));
   5.477 -+#endif /* WRITE_APNG */
   5.478 -+#endif /* APNG */
   5.479 -+
   5.480 - /* Maintainer: Put new public prototypes here ^, in libpng.3, in project
   5.481 -  * defs, and in scripts/symbols.def.
   5.482 -  */
   5.483 -@@ -3248,7 +3347,11 @@
   5.484 -  * one to use is one more than this.)
   5.485 -  */
   5.486 - #ifdef PNG_EXPORT_LAST_ORDINAL
   5.487 -+#ifdef PNG_APNG_SUPPORTED
   5.488 -+  PNG_EXPORT_LAST_ORDINAL(265);
   5.489 -+#else
   5.490 -   PNG_EXPORT_LAST_ORDINAL(245);
   5.491 -+#endif /* APNG */
   5.492 - #endif
   5.493 - 
   5.494 - #ifdef __cplusplus
   5.495 -Index: pngpriv.h
   5.496 -===================================================================
   5.497 ---- a/pngpriv.h
   5.498 -+++ b/pngpriv.h
   5.499 -@@ -567,6 +567,10 @@
   5.500 - #define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000U /* Have another chunk after IDAT */
   5.501 -                    /*             0x4000U (unused) */
   5.502 - #define PNG_IS_READ_STRUCT        0x8000U /* Else is a write struct */
   5.503 -+#ifdef PNG_APNG_SUPPORTED
   5.504 -+#define PNG_HAVE_acTL            0x10000U
   5.505 -+#define PNG_HAVE_fcTL            0x20000U
   5.506 -+#endif
   5.507 - 
   5.508 - /* Flags for the transformations the PNG library does on the image data */
   5.509 - #define PNG_BGR                 0x0001U
   5.510 -@@ -802,6 +806,16 @@
   5.511 - #define png_tRNS PNG_U32(116,  82,  78,  83)
   5.512 - #define png_zTXt PNG_U32(122,  84,  88, 116)
   5.513 - 
   5.514 -+#ifdef PNG_APNG_SUPPORTED
   5.515 -+#define png_acTL PNG_U32( 97,  99,  84,  76)
   5.516 -+#define png_fcTL PNG_U32(102,  99,  84,  76)
   5.517 -+#define png_fdAT PNG_U32(102, 100,  65,  84)
   5.518 -+
   5.519 -+/* For png_struct.apng_flags: */
   5.520 -+#define PNG_FIRST_FRAME_HIDDEN       0x0001U
   5.521 -+#define PNG_APNG_APP                 0x0002U
   5.522 -+#endif
   5.523 -+
   5.524 - /* The following will work on (signed char*) strings, whereas the get_uint_32
   5.525 -  * macro will fail on top-bit-set values because of the sign extension.
   5.526 -  */
   5.527 -@@ -1508,6 +1522,49 @@
   5.528 - 
   5.529 - #endif /* PROGRESSIVE_READ */
   5.530 - 
   5.531 -+#ifdef PNG_APNG_SUPPORTED
   5.532 -+PNG_INTERNAL_FUNCTION(void,png_ensure_fcTL_is_valid,(png_structp png_ptr,
   5.533 -+   png_uint_32 width, png_uint_32 height,
   5.534 -+   png_uint_32 x_offset, png_uint_32 y_offset,
   5.535 -+   png_uint_16 delay_num, png_uint_16 delay_den,
   5.536 -+   png_byte dispose_op, png_byte blend_op),PNG_EMPTY);
   5.537 -+
   5.538 -+#ifdef PNG_READ_APNG_SUPPORTED
   5.539 -+PNG_INTERNAL_FUNCTION(void,png_handle_acTL,(png_structp png_ptr,
   5.540 -+   png_infop info_ptr, png_uint_32 length),PNG_EMPTY);
   5.541 -+PNG_INTERNAL_FUNCTION(void,png_handle_fcTL,(png_structp png_ptr,
   5.542 -+   png_infop info_ptr, png_uint_32 length),PNG_EMPTY);
   5.543 -+PNG_INTERNAL_FUNCTION(void,png_handle_fdAT,(png_structp png_ptr,
   5.544 -+   png_infop info_ptr, png_uint_32 length),PNG_EMPTY);
   5.545 -+PNG_INTERNAL_FUNCTION(void,png_have_info,(png_structp png_ptr,
   5.546 -+   png_infop info_ptr),PNG_EMPTY);
   5.547 -+PNG_INTERNAL_FUNCTION(void,png_ensure_sequence_number,(png_structp png_ptr,
   5.548 -+   png_uint_32 length),PNG_EMPTY);
   5.549 -+PNG_INTERNAL_FUNCTION(void,png_read_reset,(png_structp png_ptr),PNG_EMPTY);
   5.550 -+PNG_INTERNAL_FUNCTION(void,png_read_reinit,(png_structp png_ptr,
   5.551 -+   png_infop info_ptr),PNG_EMPTY);
   5.552 -+#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
   5.553 -+PNG_INTERNAL_FUNCTION(void,png_progressive_read_reset,(png_structp png_ptr),
   5.554 -+   PNG_EMPTY);
   5.555 -+#endif /* PROGRESSIVE_READ */
   5.556 -+#endif /* READ_APNG */
   5.557 -+
   5.558 -+#ifdef PNG_WRITE_APNG_SUPPORTED
   5.559 -+PNG_INTERNAL_FUNCTION(void,png_write_acTL,(png_structp png_ptr,
   5.560 -+   png_uint_32 num_frames, png_uint_32 num_plays),PNG_EMPTY);
   5.561 -+PNG_INTERNAL_FUNCTION(void,png_write_fcTL,(png_structp png_ptr,
   5.562 -+   png_uint_32 width, png_uint_32 height,
   5.563 -+   png_uint_32 x_offset, png_uint_32 y_offset,
   5.564 -+   png_uint_16 delay_num, png_uint_16 delay_den,
   5.565 -+   png_byte dispose_op, png_byte blend_op),PNG_EMPTY);
   5.566 -+PNG_INTERNAL_FUNCTION(void,png_write_fdAT,(png_structp png_ptr,
   5.567 -+   png_const_bytep data, png_size_t length),PNG_EMPTY);
   5.568 -+PNG_INTERNAL_FUNCTION(void,png_write_reset,(png_structp png_ptr),PNG_EMPTY);
   5.569 -+PNG_INTERNAL_FUNCTION(void,png_write_reinit,(png_structp png_ptr,
   5.570 -+   png_infop info_ptr, png_uint_32 width, png_uint_32 height),PNG_EMPTY);
   5.571 -+#endif /* WRITE_APNG */
   5.572 -+#endif /* APNG */
   5.573 -+
   5.574 - /* Added at libpng version 1.6.0 */
   5.575 - #ifdef PNG_GAMMA_SUPPORTED
   5.576 - PNG_INTERNAL_FUNCTION(void,png_colorspace_set_gamma,(png_const_structrp png_ptr,
   5.577 -Index: pnginfo.h
   5.578 -===================================================================
   5.579 ---- a/pnginfo.h
   5.580 -+++ b/pnginfo.h
   5.581 -@@ -255,5 +255,18 @@
   5.582 -    png_bytepp row_pointers;        /* the image bits */
   5.583 - #endif
   5.584 - 
   5.585 -+#ifdef PNG_APNG_SUPPORTED
   5.586 -+   png_uint_32 num_frames; /* including default image */
   5.587 -+   png_uint_32 num_plays;
   5.588 -+   png_uint_32 next_frame_width;
   5.589 -+   png_uint_32 next_frame_height;
   5.590 -+   png_uint_32 next_frame_x_offset;
   5.591 -+   png_uint_32 next_frame_y_offset;
   5.592 -+   png_uint_16 next_frame_delay_num;
   5.593 -+   png_uint_16 next_frame_delay_den;
   5.594 -+   png_byte next_frame_dispose_op;
   5.595 -+   png_byte next_frame_blend_op;
   5.596 -+#endif
   5.597 -+
   5.598 - };
   5.599 - #endif /* PNGINFO_H */
   5.600 -Index: pngstruct.h
   5.601 -===================================================================
   5.602 ---- a/pngstruct.h
   5.603 -+++ b/pngstruct.h
   5.604 -@@ -403,6 +403,27 @@
   5.605 -    png_byte filter_type;
   5.606 - #endif
   5.607 - 
   5.608 -+#ifdef PNG_APNG_SUPPORTED
   5.609 -+   png_uint_32 apng_flags;
   5.610 -+   png_uint_32 next_seq_num;         /* next fcTL/fdAT chunk sequence number */
   5.611 -+   png_uint_32 first_frame_width;
   5.612 -+   png_uint_32 first_frame_height;
   5.613 -+
   5.614 -+#ifdef PNG_READ_APNG_SUPPORTED
   5.615 -+   png_uint_32 num_frames_read;      /* incremented after all image data of */
   5.616 -+                                     /* a frame is read */
   5.617 -+#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
   5.618 -+   png_progressive_frame_ptr frame_info_fn; /* frame info read callback */
   5.619 -+   png_progressive_frame_ptr frame_end_fn;  /* frame data read callback */
   5.620 -+#endif
   5.621 -+#endif
   5.622 -+
   5.623 -+#ifdef PNG_WRITE_APNG_SUPPORTED
   5.624 -+   png_uint_32 num_frames_to_write;
   5.625 -+   png_uint_32 num_frames_written;
   5.626 -+#endif
   5.627 -+#endif /* APNG */
   5.628 -+
   5.629 - /* New members added in libpng-1.2.0 */
   5.630 - 
   5.631 - /* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */
   5.632 -Index: pngwrite.c
   5.633 -===================================================================
   5.634 ---- a/pngwrite.c
   5.635 -+++ b/pngwrite.c
   5.636 -@@ -128,6 +128,10 @@
   5.637 -        * the application continues writing the PNG.  So check the 'invalid'
   5.638 -        * flag here too.
   5.639 -        */
   5.640 -+#ifdef PNG_WRITE_APNG_SUPPORTED
   5.641 -+   if ((info_ptr->valid & PNG_INFO_acTL) != 0)
   5.642 -+      png_write_acTL(png_ptr, info_ptr->num_frames, info_ptr->num_plays);
   5.643 -+#endif
   5.644 - #ifdef PNG_GAMMA_SUPPORTED
   5.645 - #  ifdef PNG_WRITE_gAMA_SUPPORTED
   5.646 -       if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
   5.647 -@@ -360,6 +364,11 @@
   5.648 -    if ((png_ptr->mode & PNG_HAVE_IDAT) == 0)
   5.649 -       png_error(png_ptr, "No IDATs written into file");
   5.650 - 
   5.651 -+#ifdef PNG_WRITE_APNG_SUPPORTED
   5.652 -+   if (png_ptr->num_frames_written != png_ptr->num_frames_to_write)
   5.653 -+      png_error(png_ptr, "Not enough frames written");
   5.654 -+#endif
   5.655 -+
   5.656 - #ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
   5.657 -    if (png_ptr->num_palette_max > png_ptr->num_palette)
   5.658 -       png_benign_error(png_ptr, "Wrote palette index exceeding num_palette");
   5.659 -@@ -2382,4 +2391,42 @@
   5.660 - }
   5.661 - #endif /* SIMPLIFIED_WRITE_STDIO */
   5.662 - #endif /* SIMPLIFIED_WRITE */
   5.663 -+
   5.664 -+#ifdef PNG_WRITE_APNG_SUPPORTED
   5.665 -+void PNGAPI
   5.666 -+png_write_frame_head(png_structp png_ptr, png_infop info_ptr,
   5.667 -+    png_bytepp row_pointers, png_uint_32 width, png_uint_32 height,
   5.668 -+    png_uint_32 x_offset, png_uint_32 y_offset,
   5.669 -+    png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
   5.670 -+    png_byte blend_op)
   5.671 -+{
   5.672 -+    png_debug(1, "in png_write_frame_head");
   5.673 -+
   5.674 -+    /* there is a chance this has been set after png_write_info was called,
   5.675 -+    * so it would be set but not written. is there a way to be sure? */
   5.676 -+    if ((info_ptr->valid & PNG_INFO_acTL) == 0)
   5.677 -+        png_error(png_ptr, "png_write_frame_head(): acTL not set");
   5.678 -+
   5.679 -+    png_write_reset(png_ptr);
   5.680 -+
   5.681 -+    png_write_reinit(png_ptr, info_ptr, width, height);
   5.682 -+
   5.683 -+    if ((png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN) == 0 ||
   5.684 -+        png_ptr->num_frames_written != 0)
   5.685 -+        png_write_fcTL(png_ptr, width, height, x_offset, y_offset,
   5.686 -+                       delay_num, delay_den, dispose_op, blend_op);
   5.687 -+
   5.688 -+    PNG_UNUSED(row_pointers)
   5.689 -+}
   5.690 -+
   5.691 -+void PNGAPI
   5.692 -+png_write_frame_tail(png_structp png_ptr, png_infop info_ptr)
   5.693 -+{
   5.694 -+    png_debug(1, "in png_write_frame_tail");
   5.695 -+
   5.696 -+    png_ptr->num_frames_written++;
   5.697 -+
   5.698 -+    PNG_UNUSED(info_ptr)
   5.699 -+}
   5.700 -+#endif /* WRITE_APNG */
   5.701 - #endif /* WRITE */
   5.702 -Index: pngpread.c
   5.703 -===================================================================
   5.704 ---- a/pngpread.c
   5.705 -+++ b/pngpread.c
   5.706 -@@ -194,6 +194,89 @@
   5.707 - 
   5.708 -    chunk_name = png_ptr->chunk_name;
   5.709 - 
   5.710 -+#ifdef PNG_READ_APNG_SUPPORTED
   5.711 -+   if (png_ptr->num_frames_read > 0 &&
   5.712 -+       png_ptr->num_frames_read < info_ptr->num_frames)
   5.713 -+   {
   5.714 -+      if (chunk_name == png_IDAT)
   5.715 -+      {
   5.716 -+         /* Discard trailing IDATs for the first frame */
   5.717 -+         if ((png_ptr->mode & PNG_HAVE_fcTL) != 0 ||
   5.718 -+             png_ptr->num_frames_read > 1)
   5.719 -+            png_error(png_ptr, "out of place IDAT");
   5.720 -+
   5.721 -+         PNG_PUSH_SAVE_BUFFER_IF_FULL
   5.722 -+         png_crc_finish(png_ptr, png_ptr->push_length);
   5.723 -+         png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
   5.724 -+      }
   5.725 -+
   5.726 -+      else if (chunk_name == png_fdAT)
   5.727 -+      {
   5.728 -+         PNG_PUSH_SAVE_BUFFER_IF_LT(4)
   5.729 -+         png_ensure_sequence_number(png_ptr, 4);
   5.730 -+
   5.731 -+         if ((png_ptr->mode & PNG_HAVE_fcTL) == 0)
   5.732 -+         {
   5.733 -+            /* Discard trailing fdATs for frames other than the first */
   5.734 -+            if (png_ptr->num_frames_read < 2)
   5.735 -+               png_error(png_ptr, "out of place fdAT");
   5.736 -+
   5.737 -+            PNG_PUSH_SAVE_BUFFER_IF_FULL
   5.738 -+            png_crc_finish(png_ptr, png_ptr->push_length);
   5.739 -+            png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
   5.740 -+         }
   5.741 -+
   5.742 -+         else
   5.743 -+         {
   5.744 -+            /* frame data follows */
   5.745 -+            png_ptr->idat_size = png_ptr->push_length - 4;
   5.746 -+            png_ptr->mode |= PNG_HAVE_IDAT;
   5.747 -+            png_ptr->process_mode = PNG_READ_IDAT_MODE;
   5.748 -+         }
   5.749 -+      }
   5.750 -+
   5.751 -+      else if (chunk_name == png_fcTL)
   5.752 -+      {
   5.753 -+         PNG_PUSH_SAVE_BUFFER_IF_FULL
   5.754 -+         png_read_reset(png_ptr);
   5.755 -+         png_ptr->mode &= ~PNG_HAVE_fcTL;
   5.756 -+
   5.757 -+         png_handle_fcTL(png_ptr, info_ptr, png_ptr->push_length);
   5.758 -+
   5.759 -+         if ((png_ptr->mode & PNG_HAVE_fcTL) == 0)
   5.760 -+            png_error(png_ptr, "missing required fcTL chunk");
   5.761 -+
   5.762 -+         png_read_reinit(png_ptr, info_ptr);
   5.763 -+         png_progressive_read_reset(png_ptr);
   5.764 -+
   5.765 -+         if (png_ptr->frame_info_fn != NULL)
   5.766 -+            (*(png_ptr->frame_info_fn))(png_ptr, png_ptr->num_frames_read);
   5.767 -+
   5.768 -+         png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
   5.769 -+      }
   5.770 -+
   5.771 -+      else if (chunk_name == png_IEND)
   5.772 -+      {
   5.773 -+         PNG_PUSH_SAVE_BUFFER_IF_FULL
   5.774 -+         png_warning(png_ptr, "Number of actual frames fewer than expected");
   5.775 -+         png_crc_finish(png_ptr, png_ptr->push_length);
   5.776 -+         png_ptr->process_mode = PNG_READ_DONE_MODE;
   5.777 -+         png_push_have_end(png_ptr, info_ptr);
   5.778 -+      }
   5.779 -+
   5.780 -+      else
   5.781 -+      {
   5.782 -+         PNG_PUSH_SAVE_BUFFER_IF_FULL
   5.783 -+         png_warning(png_ptr, "Skipped (ignored) a chunk "
   5.784 -+                              "between APNG chunks");
   5.785 -+         png_crc_finish(png_ptr, png_ptr->push_length);
   5.786 -+         png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
   5.787 -+      }
   5.788 -+
   5.789 -+      return;
   5.790 -+   }
   5.791 -+#endif /* READ_APNG */
   5.792 -+
   5.793 -    if (chunk_name == png_IDAT)
   5.794 -    {
   5.795 -       if ((png_ptr->mode & PNG_AFTER_IDAT) != 0)
   5.796 -@@ -260,6 +343,9 @@
   5.797 - 
   5.798 -    else if (chunk_name == png_IDAT)
   5.799 -    {
   5.800 -+#ifdef PNG_READ_APNG_SUPPORTED
   5.801 -+      png_have_info(png_ptr, info_ptr);
   5.802 -+#endif
   5.803 -       png_ptr->idat_size = png_ptr->push_length;
   5.804 -       png_ptr->process_mode = PNG_READ_IDAT_MODE;
   5.805 -       png_push_have_info(png_ptr, info_ptr);
   5.806 -@@ -406,6 +492,20 @@
   5.807 -    }
   5.808 - #endif
   5.809 - 
   5.810 -+#ifdef PNG_READ_APNG_SUPPORTED
   5.811 -+   else if (chunk_name == png_acTL)
   5.812 -+   {
   5.813 -+      PNG_PUSH_SAVE_BUFFER_IF_FULL
   5.814 -+      png_handle_acTL(png_ptr, info_ptr, png_ptr->push_length);
   5.815 -+   }
   5.816 -+
   5.817 -+   else if (chunk_name == png_fcTL)
   5.818 -+   {
   5.819 -+      PNG_PUSH_SAVE_BUFFER_IF_FULL
   5.820 -+      png_handle_fcTL(png_ptr, info_ptr, png_ptr->push_length);
   5.821 -+   }
   5.822 -+
   5.823 -+#endif /* READ_APNG */
   5.824 -    else
   5.825 -    {
   5.826 -       PNG_PUSH_SAVE_BUFFER_IF_FULL
   5.827 -@@ -538,7 +638,11 @@
   5.828 -       png_byte chunk_tag[4];
   5.829 - 
   5.830 -       /* TODO: this code can be commoned up with the same code in push_read */
   5.831 -+#ifdef PNG_READ_APNG_SUPPORTED
   5.832 -+      PNG_PUSH_SAVE_BUFFER_IF_LT(12)
   5.833 -+#else
   5.834 -       PNG_PUSH_SAVE_BUFFER_IF_LT(8)
   5.835 -+#endif
   5.836 -       png_push_fill_buffer(png_ptr, chunk_length, 4);
   5.837 -       png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
   5.838 -       png_reset_crc(png_ptr);
   5.839 -@@ -546,17 +650,60 @@
   5.840 -       png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);
   5.841 -       png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
   5.842 - 
   5.843 -+#ifdef PNG_READ_APNG_SUPPORTED
   5.844 -+      if (png_ptr->chunk_name != png_fdAT && png_ptr->num_frames_read > 0)
   5.845 -+      {
   5.846 -+          if ((png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) != 0)
   5.847 -+          {
   5.848 -+              png_ptr->process_mode = PNG_READ_CHUNK_MODE;
   5.849 -+              if (png_ptr->frame_end_fn != NULL)
   5.850 -+                 (*(png_ptr->frame_end_fn))(png_ptr, png_ptr->num_frames_read);
   5.851 -+              png_ptr->num_frames_read++;
   5.852 -+              return;
   5.853 -+          }
   5.854 -+          else
   5.855 -+          {
   5.856 -+              if (png_ptr->chunk_name == png_IEND)
   5.857 -+                  png_error(png_ptr, "Not enough image data");
   5.858 -+              PNG_PUSH_SAVE_BUFFER_IF_FULL
   5.859 -+              png_warning(png_ptr, "Skipping (ignoring) a chunk between "
   5.860 -+                                   "APNG chunks");
   5.861 -+              png_crc_finish(png_ptr, png_ptr->push_length);
   5.862 -+              png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
   5.863 -+              return;
   5.864 -+          }
   5.865 -+      }
   5.866 -+      else
   5.867 -+#endif
   5.868 -+#ifdef PNG_READ_APNG_SUPPORTED
   5.869 -+      if (png_ptr->chunk_name != png_IDAT && png_ptr->num_frames_read == 0)
   5.870 -+#else
   5.871 -       if (png_ptr->chunk_name != png_IDAT)
   5.872 -+#endif
   5.873 -       {
   5.874 -          png_ptr->process_mode = PNG_READ_CHUNK_MODE;
   5.875 - 
   5.876 -          if ((png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0)
   5.877 -             png_error(png_ptr, "Not enough compressed data");
   5.878 - 
   5.879 -+#ifdef PNG_READ_APNG_SUPPORTED
   5.880 -+         if (png_ptr->frame_end_fn != NULL)
   5.881 -+            (*(png_ptr->frame_end_fn))(png_ptr, png_ptr->num_frames_read);
   5.882 -+         png_ptr->num_frames_read++;
   5.883 -+#endif
   5.884 -+
   5.885 -          return;
   5.886 -       }
   5.887 - 
   5.888 -       png_ptr->idat_size = png_ptr->push_length;
   5.889 -+
   5.890 -+#ifdef PNG_READ_APNG_SUPPORTED
   5.891 -+      if (png_ptr->num_frames_read > 0)
   5.892 -+      {
   5.893 -+         png_ensure_sequence_number(png_ptr, 4);
   5.894 -+         png_ptr->idat_size -= 4;
   5.895 -+      }
   5.896 -+#endif
   5.897 -    }
   5.898 - 
   5.899 -    if (png_ptr->idat_size != 0 && png_ptr->save_buffer_size != 0)
   5.900 -@@ -630,6 +777,16 @@
   5.901 -    if (!(buffer_length > 0) || buffer == NULL)
   5.902 -       png_error(png_ptr, "No IDAT data (internal error)");
   5.903 - 
   5.904 -+#ifdef PNG_READ_APNG_SUPPORTED
   5.905 -+   /* If the app is not APNG-aware, decode only the first frame */
   5.906 -+   if ((png_ptr->apng_flags & PNG_APNG_APP) == 0 &&
   5.907 -+      png_ptr->num_frames_read > 0)
   5.908 -+   {
   5.909 -+      png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
   5.910 -+      return;
   5.911 -+   }
   5.912 -+#endif
   5.913 -+
   5.914 -    /* This routine must process all the data it has been given
   5.915 -     * before returning, calling the row callback as required to
   5.916 -     * handle the uncompressed results.
   5.917 -@@ -1084,6 +1241,18 @@
   5.918 -    png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer);
   5.919 - }
   5.920 - 
   5.921 -+#ifdef PNG_READ_APNG_SUPPORTED
   5.922 -+void PNGAPI
   5.923 -+png_set_progressive_frame_fn(png_structp png_ptr,
   5.924 -+   png_progressive_frame_ptr frame_info_fn,
   5.925 -+   png_progressive_frame_ptr frame_end_fn)
   5.926 -+{
   5.927 -+   png_ptr->frame_info_fn = frame_info_fn;
   5.928 -+   png_ptr->frame_end_fn = frame_end_fn;
   5.929 -+   png_ptr->apng_flags |= PNG_APNG_APP;
   5.930 -+}
   5.931 -+#endif
   5.932 -+
   5.933 - png_voidp PNGAPI
   5.934 - png_get_progressive_ptr(png_const_structrp png_ptr)
   5.935 - {
   5.936 -Index: pngset.c
   5.937 -===================================================================
   5.938 ---- a/pngset.c
   5.939 -+++ b/pngset.c
   5.940 -@@ -241,6 +241,11 @@
   5.941 -    info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
   5.942 - 
   5.943 -    info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width);
   5.944 -+
   5.945 -+#ifdef PNG_APNG_SUPPORTED
   5.946 -+   /* for non-animated png. this may be overwritten from an acTL chunk later */
   5.947 -+   info_ptr->num_frames = 1;
   5.948 -+#endif
   5.949 - }
   5.950 - 
   5.951 - #ifdef PNG_oFFs_SUPPORTED
   5.952 -@@ -1110,6 +1115,146 @@
   5.953 - }
   5.954 - #endif /* sPLT */
   5.955 - 
   5.956 -+#ifdef PNG_APNG_SUPPORTED
   5.957 -+png_uint_32 PNGAPI
   5.958 -+png_set_acTL(png_structp png_ptr, png_infop info_ptr,
   5.959 -+    png_uint_32 num_frames, png_uint_32 num_plays)
   5.960 -+{
   5.961 -+    png_debug1(1, "in %s storage function", "acTL");
   5.962 -+
   5.963 -+    if (png_ptr == NULL || info_ptr == NULL)
   5.964 -+    {
   5.965 -+        png_warning(png_ptr,
   5.966 -+                    "Call to png_set_acTL() with NULL png_ptr "
   5.967 -+                    "or info_ptr ignored");
   5.968 -+        return (0);
   5.969 -+    }
   5.970 -+    if (num_frames == 0)
   5.971 -+    {
   5.972 -+        png_warning(png_ptr,
   5.973 -+                    "Ignoring attempt to set acTL with num_frames zero");
   5.974 -+        return (0);
   5.975 -+    }
   5.976 -+    if (num_frames > PNG_UINT_31_MAX)
   5.977 -+    {
   5.978 -+        png_warning(png_ptr,
   5.979 -+                    "Ignoring attempt to set acTL with num_frames > 2^31-1");
   5.980 -+        return (0);
   5.981 -+    }
   5.982 -+    if (num_plays > PNG_UINT_31_MAX)
   5.983 -+    {
   5.984 -+        png_warning(png_ptr,
   5.985 -+                    "Ignoring attempt to set acTL with num_plays > 2^31-1");
   5.986 -+        return (0);
   5.987 -+    }
   5.988 -+
   5.989 -+    info_ptr->num_frames = num_frames;
   5.990 -+    info_ptr->num_plays = num_plays;
   5.991 -+
   5.992 -+    info_ptr->valid |= PNG_INFO_acTL;
   5.993 -+
   5.994 -+    return (1);
   5.995 -+}
   5.996 -+
   5.997 -+/* delay_num and delay_den can hold any 16-bit values including zero */
   5.998 -+png_uint_32 PNGAPI
   5.999 -+png_set_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
  5.1000 -+    png_uint_32 width, png_uint_32 height,
  5.1001 -+    png_uint_32 x_offset, png_uint_32 y_offset,
  5.1002 -+    png_uint_16 delay_num, png_uint_16 delay_den,
  5.1003 -+    png_byte dispose_op, png_byte blend_op)
  5.1004 -+{
  5.1005 -+    png_debug1(1, "in %s storage function", "fcTL");
  5.1006 -+
  5.1007 -+    if (png_ptr == NULL || info_ptr == NULL)
  5.1008 -+    {
  5.1009 -+        png_warning(png_ptr,
  5.1010 -+                    "Call to png_set_fcTL() with NULL png_ptr or info_ptr "
  5.1011 -+                    "ignored");
  5.1012 -+        return (0);
  5.1013 -+    }
  5.1014 -+
  5.1015 -+    png_ensure_fcTL_is_valid(png_ptr, width, height, x_offset, y_offset,
  5.1016 -+                             delay_num, delay_den, dispose_op, blend_op);
  5.1017 -+
  5.1018 -+    if (blend_op == PNG_BLEND_OP_OVER)
  5.1019 -+    {
  5.1020 -+        if ((png_ptr->color_type & PNG_COLOR_MASK_ALPHA) == 0 &&
  5.1021 -+            png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) == 0)
  5.1022 -+        {
  5.1023 -+          png_warning(png_ptr, "PNG_BLEND_OP_OVER is meaningless "
  5.1024 -+                               "and wasteful for opaque images, ignored");
  5.1025 -+          blend_op = PNG_BLEND_OP_SOURCE;
  5.1026 -+        }
  5.1027 -+    }
  5.1028 -+
  5.1029 -+    info_ptr->next_frame_width = width;
  5.1030 -+    info_ptr->next_frame_height = height;
  5.1031 -+    info_ptr->next_frame_x_offset = x_offset;
  5.1032 -+    info_ptr->next_frame_y_offset = y_offset;
  5.1033 -+    info_ptr->next_frame_delay_num = delay_num;
  5.1034 -+    info_ptr->next_frame_delay_den = delay_den;
  5.1035 -+    info_ptr->next_frame_dispose_op = dispose_op;
  5.1036 -+    info_ptr->next_frame_blend_op = blend_op;
  5.1037 -+
  5.1038 -+    info_ptr->valid |= PNG_INFO_fcTL;
  5.1039 -+
  5.1040 -+    return (1);
  5.1041 -+}
  5.1042 -+
  5.1043 -+void /* PRIVATE */
  5.1044 -+png_ensure_fcTL_is_valid(png_structp png_ptr,
  5.1045 -+    png_uint_32 width, png_uint_32 height,
  5.1046 -+    png_uint_32 x_offset, png_uint_32 y_offset,
  5.1047 -+    png_uint_16 delay_num, png_uint_16 delay_den,
  5.1048 -+    png_byte dispose_op, png_byte blend_op)
  5.1049 -+{
  5.1050 -+    if (width == 0 || width > PNG_UINT_31_MAX)
  5.1051 -+        png_error(png_ptr, "invalid width in fcTL (0 or > 2^31-1)");
  5.1052 -+    if (height == 0 || height > PNG_UINT_31_MAX)
  5.1053 -+        png_error(png_ptr, "invalid height in fcTL (0 or > 2^31-1)");
  5.1054 -+    if (x_offset > PNG_UINT_31_MAX)
  5.1055 -+        png_error(png_ptr, "invalid x_offset in fcTL (> 2^31-1)");
  5.1056 -+    if (y_offset > PNG_UINT_31_MAX)
  5.1057 -+        png_error(png_ptr, "invalid y_offset in fcTL (> 2^31-1)");
  5.1058 -+    if (width + x_offset > png_ptr->first_frame_width ||
  5.1059 -+        height + y_offset > png_ptr->first_frame_height)
  5.1060 -+        png_error(png_ptr, "dimensions of a frame are greater than "
  5.1061 -+                           "the ones in IHDR");
  5.1062 -+
  5.1063 -+    if (dispose_op != PNG_DISPOSE_OP_NONE &&
  5.1064 -+        dispose_op != PNG_DISPOSE_OP_BACKGROUND &&
  5.1065 -+        dispose_op != PNG_DISPOSE_OP_PREVIOUS)
  5.1066 -+        png_error(png_ptr, "invalid dispose_op in fcTL");
  5.1067 -+
  5.1068 -+    if (blend_op != PNG_BLEND_OP_SOURCE &&
  5.1069 -+        blend_op != PNG_BLEND_OP_OVER)
  5.1070 -+        png_error(png_ptr, "invalid blend_op in fcTL");
  5.1071 -+
  5.1072 -+    PNG_UNUSED(delay_num)
  5.1073 -+    PNG_UNUSED(delay_den)
  5.1074 -+}
  5.1075 -+
  5.1076 -+png_uint_32 PNGAPI
  5.1077 -+png_set_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr,
  5.1078 -+                              png_byte is_hidden)
  5.1079 -+{
  5.1080 -+    png_debug(1, "in png_first_frame_is_hidden()");
  5.1081 -+
  5.1082 -+    if (png_ptr == NULL)
  5.1083 -+        return 0;
  5.1084 -+
  5.1085 -+    if (is_hidden != 0)
  5.1086 -+        png_ptr->apng_flags |= PNG_FIRST_FRAME_HIDDEN;
  5.1087 -+    else
  5.1088 -+        png_ptr->apng_flags &= ~PNG_FIRST_FRAME_HIDDEN;
  5.1089 -+
  5.1090 -+    PNG_UNUSED(info_ptr)
  5.1091 -+
  5.1092 -+    return 1;
  5.1093 -+}
  5.1094 -+#endif /* APNG */
  5.1095 -+
  5.1096 - #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
  5.1097 - static png_byte
  5.1098 - check_location(png_const_structrp png_ptr, int location)
  5.1099 -Index: pngrutil.c
  5.1100 -===================================================================
  5.1101 ---- a/pngrutil.c
  5.1102 -+++ b/pngrutil.c
  5.1103 -@@ -861,6 +861,11 @@
  5.1104 -    filter_type = buf[11];
  5.1105 -    interlace_type = buf[12];
  5.1106 - 
  5.1107 -+#ifdef PNG_READ_APNG_SUPPORTED
  5.1108 -+   png_ptr->first_frame_width = width;
  5.1109 -+   png_ptr->first_frame_height = height;
  5.1110 -+#endif
  5.1111 -+
  5.1112 -    /* Set internal variables */
  5.1113 -    png_ptr->width = width;
  5.1114 -    png_ptr->height = height;
  5.1115 -@@ -2761,6 +2766,180 @@
  5.1116 - }
  5.1117 - #endif
  5.1118 - 
  5.1119 -+#ifdef PNG_READ_APNG_SUPPORTED
  5.1120 -+void /* PRIVATE */
  5.1121 -+png_handle_acTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
  5.1122 -+{
  5.1123 -+    png_byte data[8];
  5.1124 -+    png_uint_32 num_frames;
  5.1125 -+    png_uint_32 num_plays;
  5.1126 -+    png_uint_32 didSet;
  5.1127 -+
  5.1128 -+    png_debug(1, "in png_handle_acTL");
  5.1129 -+
  5.1130 -+    if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
  5.1131 -+    {
  5.1132 -+        png_error(png_ptr, "Missing IHDR before acTL");
  5.1133 -+    }
  5.1134 -+    else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
  5.1135 -+    {
  5.1136 -+        png_warning(png_ptr, "Invalid acTL after IDAT skipped");
  5.1137 -+        png_crc_finish(png_ptr, length);
  5.1138 -+        return;
  5.1139 -+    }
  5.1140 -+    else if ((png_ptr->mode & PNG_HAVE_acTL) != 0)
  5.1141 -+    {
  5.1142 -+        png_warning(png_ptr, "Duplicate acTL skipped");
  5.1143 -+        png_crc_finish(png_ptr, length);
  5.1144 -+        return;
  5.1145 -+    }
  5.1146 -+    else if (length != 8)
  5.1147 -+    {
  5.1148 -+        png_warning(png_ptr, "acTL with invalid length skipped");
  5.1149 -+        png_crc_finish(png_ptr, length);
  5.1150 -+        return;
  5.1151 -+    }
  5.1152 -+
  5.1153 -+    png_crc_read(png_ptr, data, 8);
  5.1154 -+    png_crc_finish(png_ptr, 0);
  5.1155 -+
  5.1156 -+    num_frames = png_get_uint_31(png_ptr, data);
  5.1157 -+    num_plays = png_get_uint_31(png_ptr, data + 4);
  5.1158 -+
  5.1159 -+    /* the set function will do error checking on num_frames */
  5.1160 -+    didSet = png_set_acTL(png_ptr, info_ptr, num_frames, num_plays);
  5.1161 -+    if (didSet != 0)
  5.1162 -+        png_ptr->mode |= PNG_HAVE_acTL;
  5.1163 -+}
  5.1164 -+
  5.1165 -+void /* PRIVATE */
  5.1166 -+png_handle_fcTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
  5.1167 -+{
  5.1168 -+    png_byte data[22];
  5.1169 -+    png_uint_32 width;
  5.1170 -+    png_uint_32 height;
  5.1171 -+    png_uint_32 x_offset;
  5.1172 -+    png_uint_32 y_offset;
  5.1173 -+    png_uint_16 delay_num;
  5.1174 -+    png_uint_16 delay_den;
  5.1175 -+    png_byte dispose_op;
  5.1176 -+    png_byte blend_op;
  5.1177 -+
  5.1178 -+    png_debug(1, "in png_handle_fcTL");
  5.1179 -+
  5.1180 -+    png_ensure_sequence_number(png_ptr, length);
  5.1181 -+
  5.1182 -+    if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
  5.1183 -+    {
  5.1184 -+        png_error(png_ptr, "Missing IHDR before fcTL");
  5.1185 -+    }
  5.1186 -+    else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
  5.1187 -+    {
  5.1188 -+        /* for any frames other then the first this message may be misleading,
  5.1189 -+        * but correct. PNG_HAVE_IDAT is unset before the frame head is read
  5.1190 -+        * i can't think of a better message */
  5.1191 -+        png_warning(png_ptr, "Invalid fcTL after IDAT skipped");
  5.1192 -+        png_crc_finish(png_ptr, length-4);
  5.1193 -+        return;
  5.1194 -+    }
  5.1195 -+    else if ((png_ptr->mode & PNG_HAVE_fcTL) != 0)
  5.1196 -+    {
  5.1197 -+        png_warning(png_ptr, "Duplicate fcTL within one frame skipped");
  5.1198 -+        png_crc_finish(png_ptr, length-4);
  5.1199 -+        return;
  5.1200 -+    }
  5.1201 -+    else if (length != 26)
  5.1202 -+    {
  5.1203 -+        png_warning(png_ptr, "fcTL with invalid length skipped");
  5.1204 -+        png_crc_finish(png_ptr, length-4);
  5.1205 -+        return;
  5.1206 -+    }
  5.1207 -+
  5.1208 -+    png_crc_read(png_ptr, data, 22);
  5.1209 -+    png_crc_finish(png_ptr, 0);
  5.1210 -+
  5.1211 -+    width = png_get_uint_31(png_ptr, data);
  5.1212 -+    height = png_get_uint_31(png_ptr, data + 4);
  5.1213 -+    x_offset = png_get_uint_31(png_ptr, data + 8);
  5.1214 -+    y_offset = png_get_uint_31(png_ptr, data + 12);
  5.1215 -+    delay_num = png_get_uint_16(data + 16);
  5.1216 -+    delay_den = png_get_uint_16(data + 18);
  5.1217 -+    dispose_op = data[20];
  5.1218 -+    blend_op = data[21];
  5.1219 -+
  5.1220 -+    if (png_ptr->num_frames_read == 0 && (x_offset != 0 || y_offset != 0))
  5.1221 -+    {
  5.1222 -+        png_warning(png_ptr, "fcTL for the first frame must have zero offset");
  5.1223 -+        return;
  5.1224 -+    }
  5.1225 -+
  5.1226 -+    if (info_ptr != NULL)
  5.1227 -+    {
  5.1228 -+        if (png_ptr->num_frames_read == 0 &&
  5.1229 -+            (width != info_ptr->width || height != info_ptr->height))
  5.1230 -+        {
  5.1231 -+            png_warning(png_ptr, "size in first frame's fcTL must match "
  5.1232 -+                               "the size in IHDR");
  5.1233 -+            return;
  5.1234 -+        }
  5.1235 -+
  5.1236 -+        /* The set function will do more error checking */
  5.1237 -+        png_set_next_frame_fcTL(png_ptr, info_ptr, width, height,
  5.1238 -+                                x_offset, y_offset, delay_num, delay_den,
  5.1239 -+                                dispose_op, blend_op);
  5.1240 -+
  5.1241 -+        png_read_reinit(png_ptr, info_ptr);
  5.1242 -+
  5.1243 -+        png_ptr->mode |= PNG_HAVE_fcTL;
  5.1244 -+    }
  5.1245 -+}
  5.1246 -+
  5.1247 -+void /* PRIVATE */
  5.1248 -+png_have_info(png_structp png_ptr, png_infop info_ptr)
  5.1249 -+{
  5.1250 -+    if ((info_ptr->valid & PNG_INFO_acTL) != 0 &&
  5.1251 -+        (info_ptr->valid & PNG_INFO_fcTL) == 0)
  5.1252 -+    {
  5.1253 -+        png_ptr->apng_flags |= PNG_FIRST_FRAME_HIDDEN;
  5.1254 -+        info_ptr->num_frames++;
  5.1255 -+    }
  5.1256 -+}
  5.1257 -+
  5.1258 -+void /* PRIVATE */
  5.1259 -+png_handle_fdAT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
  5.1260 -+{
  5.1261 -+    png_ensure_sequence_number(png_ptr, length);
  5.1262 -+
  5.1263 -+    /* This function is only called from png_read_end(), png_read_info(),
  5.1264 -+    * and png_push_read_chunk() which means that:
  5.1265 -+    * - the user doesn't want to read this frame
  5.1266 -+    * - or this is an out-of-place fdAT
  5.1267 -+    * in either case it is safe to ignore the chunk with a warning */
  5.1268 -+    png_warning(png_ptr, "ignoring fdAT chunk");
  5.1269 -+    png_crc_finish(png_ptr, length - 4);
  5.1270 -+    PNG_UNUSED(info_ptr)
  5.1271 -+}
  5.1272 -+
  5.1273 -+void /* PRIVATE */
  5.1274 -+png_ensure_sequence_number(png_structp png_ptr, png_uint_32 length)
  5.1275 -+{
  5.1276 -+    png_byte data[4];
  5.1277 -+    png_uint_32 sequence_number;
  5.1278 -+
  5.1279 -+    if (length < 4)
  5.1280 -+        png_error(png_ptr, "invalid fcTL or fdAT chunk found");
  5.1281 -+
  5.1282 -+    png_crc_read(png_ptr, data, 4);
  5.1283 -+    sequence_number = png_get_uint_31(png_ptr, data);
  5.1284 -+
  5.1285 -+    if (sequence_number != png_ptr->next_seq_num)
  5.1286 -+        png_error(png_ptr, "fcTL or fdAT chunk with out-of-order sequence "
  5.1287 -+                           "number found");
  5.1288 -+
  5.1289 -+    png_ptr->next_seq_num++;
  5.1290 -+}
  5.1291 -+#endif /* READ_APNG */
  5.1292 -+
  5.1293 - #ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
  5.1294 - /* Utility function for png_handle_unknown; set up png_ptr::unknown_chunk */
  5.1295 - static int
  5.1296 -@@ -4023,6 +4202,38 @@
  5.1297 -          uInt avail_in;
  5.1298 -          png_bytep buffer;
  5.1299 - 
  5.1300 -+#ifdef PNG_READ_APNG_SUPPORTED
  5.1301 -+         png_uint_32 bytes_to_skip = 0;
  5.1302 -+
  5.1303 -+         while (png_ptr->idat_size == 0 || bytes_to_skip != 0)
  5.1304 -+         {
  5.1305 -+            png_crc_finish(png_ptr, bytes_to_skip);
  5.1306 -+            bytes_to_skip = 0;
  5.1307 -+
  5.1308 -+            png_ptr->idat_size = png_read_chunk_header(png_ptr);
  5.1309 -+            if (png_ptr->num_frames_read == 0)
  5.1310 -+            {
  5.1311 -+               if (png_ptr->chunk_name != png_IDAT)
  5.1312 -+                  png_error(png_ptr, "Not enough image data");
  5.1313 -+            }
  5.1314 -+            else
  5.1315 -+            {
  5.1316 -+               if (png_ptr->chunk_name == png_IEND)
  5.1317 -+                  png_error(png_ptr, "Not enough image data");
  5.1318 -+               if (png_ptr->chunk_name != png_fdAT)
  5.1319 -+               {
  5.1320 -+                  png_warning(png_ptr, "Skipped (ignored) a chunk "
  5.1321 -+                                       "between APNG chunks");
  5.1322 -+                  bytes_to_skip = png_ptr->idat_size;
  5.1323 -+                  continue;
  5.1324 -+               }
  5.1325 -+
  5.1326 -+               png_ensure_sequence_number(png_ptr, png_ptr->idat_size);
  5.1327 -+
  5.1328 -+               png_ptr->idat_size -= 4;
  5.1329 -+            }
  5.1330 -+         }
  5.1331 -+#else
  5.1332 -          while (png_ptr->idat_size == 0)
  5.1333 -          {
  5.1334 -             png_crc_finish(png_ptr, 0);
  5.1335 -@@ -4034,6 +4245,7 @@
  5.1336 -             if (png_ptr->chunk_name != png_IDAT)
  5.1337 -                png_error(png_ptr, "Not enough image data");
  5.1338 -          }
  5.1339 -+#endif /* READ_APNG */
  5.1340 - 
  5.1341 -          avail_in = png_ptr->IDAT_read_size;
  5.1342 - 
  5.1343 -@@ -4097,6 +4309,9 @@
  5.1344 - 
  5.1345 -          png_ptr->mode |= PNG_AFTER_IDAT;
  5.1346 -          png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
  5.1347 -+#ifdef PNG_READ_APNG_SUPPORTED
  5.1348 -+         png_ptr->num_frames_read++;
  5.1349 -+#endif
  5.1350 - 
  5.1351 -          if (png_ptr->zstream.avail_in > 0 || png_ptr->idat_size > 0)
  5.1352 -             png_chunk_benign_error(png_ptr, "Extra compressed data");
  5.1353 -@@ -4535,4 +4750,80 @@
  5.1354 - 
  5.1355 -    png_ptr->flags |= PNG_FLAG_ROW_INIT;
  5.1356 - }
  5.1357 -+
  5.1358 -+#ifdef PNG_READ_APNG_SUPPORTED
  5.1359 -+/* This function is to be called after the main IDAT set has been read and
  5.1360 -+ * before a new IDAT is read. It resets some parts of png_ptr
  5.1361 -+ * to make them usable by the read functions again */
  5.1362 -+void /* PRIVATE */
  5.1363 -+png_read_reset(png_structp png_ptr)
  5.1364 -+{
  5.1365 -+    png_ptr->mode &= ~PNG_HAVE_IDAT;
  5.1366 -+    png_ptr->mode &= ~PNG_AFTER_IDAT;
  5.1367 -+    png_ptr->row_number = 0;
  5.1368 -+    png_ptr->pass = 0;
  5.1369 -+}
  5.1370 -+
  5.1371 -+void /* PRIVATE */
  5.1372 -+png_read_reinit(png_structp png_ptr, png_infop info_ptr)
  5.1373 -+{
  5.1374 -+    png_ptr->width = info_ptr->next_frame_width;
  5.1375 -+    png_ptr->height = info_ptr->next_frame_height;
  5.1376 -+    png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->width);
  5.1377 -+    png_ptr->info_rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,
  5.1378 -+        png_ptr->width);
  5.1379 -+    if (png_ptr->prev_row != NULL)
  5.1380 -+        memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
  5.1381 -+}
  5.1382 -+
  5.1383 -+#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
  5.1384 -+/* same as png_read_reset() but for the progressive reader */
  5.1385 -+void /* PRIVATE */
  5.1386 -+png_progressive_read_reset(png_structp png_ptr)
  5.1387 -+{
  5.1388 -+#ifdef PNG_READ_INTERLACING_SUPPORTED
  5.1389 -+    /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
  5.1390 -+
  5.1391 -+    /* Start of interlace block */
  5.1392 -+    static PNG_CONST png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
  5.1393 -+
  5.1394 -+    /* Offset to next interlace block */
  5.1395 -+    static PNG_CONST png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
  5.1396 -+
  5.1397 -+    /* Start of interlace block in the y direction */
  5.1398 -+    static PNG_CONST png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
  5.1399 -+
  5.1400 -+    /* Offset to next interlace block in the y direction */
  5.1401 -+    static PNG_CONST png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
  5.1402 -+
  5.1403 -+    if (png_ptr->interlaced != 0)
  5.1404 -+    {
  5.1405 -+        if ((png_ptr->transformations & PNG_INTERLACE) == 0)
  5.1406 -+            png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 -
  5.1407 -+                                png_pass_ystart[0]) / png_pass_yinc[0];
  5.1408 -+        else
  5.1409 -+            png_ptr->num_rows = png_ptr->height;
  5.1410 -+
  5.1411 -+        png_ptr->iwidth = (png_ptr->width +
  5.1412 -+                           png_pass_inc[png_ptr->pass] - 1 -
  5.1413 -+                           png_pass_start[png_ptr->pass]) /
  5.1414 -+                           png_pass_inc[png_ptr->pass];
  5.1415 -+    }
  5.1416 -+    else
  5.1417 -+#endif /* READ_INTERLACING */
  5.1418 -+    {
  5.1419 -+        png_ptr->num_rows = png_ptr->height;
  5.1420 -+        png_ptr->iwidth = png_ptr->width;
  5.1421 -+    }
  5.1422 -+    png_ptr->flags &= ~PNG_FLAG_ZSTREAM_ENDED;
  5.1423 -+    if (inflateReset(&(png_ptr->zstream)) != Z_OK)
  5.1424 -+        png_error(png_ptr, "inflateReset failed");
  5.1425 -+    png_ptr->zstream.avail_in = 0;
  5.1426 -+    png_ptr->zstream.next_in = 0;
  5.1427 -+    png_ptr->zstream.next_out = png_ptr->row_buf;
  5.1428 -+    png_ptr->zstream.avail_out = (uInt)PNG_ROWBYTES(png_ptr->pixel_depth,
  5.1429 -+        png_ptr->iwidth) + 1;
  5.1430 -+}
  5.1431 -+#endif /* PROGRESSIVE_READ */
  5.1432 -+#endif /* READ_APNG */
  5.1433 - #endif /* READ */
  5.1434 -Index: pngwutil.c
  5.1435 -===================================================================
  5.1436 ---- a/pngwutil.c
  5.1437 -+++ b/pngwutil.c
  5.1438 -@@ -817,6 +817,11 @@
  5.1439 -    /* Write the chunk */
  5.1440 -    png_write_complete_chunk(png_ptr, png_IHDR, buf, (png_size_t)13);
  5.1441 - 
  5.1442 -+#ifdef PNG_WRITE_APNG_SUPPORTED
  5.1443 -+   png_ptr->first_frame_width = width;
  5.1444 -+   png_ptr->first_frame_height = height;
  5.1445 -+#endif
  5.1446 -+
  5.1447 -    if ((png_ptr->do_filter) == PNG_NO_FILTERS)
  5.1448 -    {
  5.1449 -       if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE ||
  5.1450 -@@ -998,7 +1003,15 @@
  5.1451 -                optimize_cmf(data, png_image_size(png_ptr));
  5.1452 - #endif
  5.1453 - 
  5.1454 -+#ifdef PNG_WRITE_APNG_SUPPORTED
  5.1455 -+         if (png_ptr->num_frames_written == 0)
  5.1456 -+#endif
  5.1457 -          png_write_complete_chunk(png_ptr, png_IDAT, data, size);
  5.1458 -+#ifdef PNG_WRITE_APNG_SUPPORTED
  5.1459 -+         else
  5.1460 -+            png_write_fdAT(png_ptr, data, size);
  5.1461 -+#endif /* WRITE_APNG */
  5.1462 -+
  5.1463 -          png_ptr->mode |= PNG_HAVE_IDAT;
  5.1464 - 
  5.1465 -          png_ptr->zstream.next_out = data;
  5.1466 -@@ -1044,7 +1057,15 @@
  5.1467 -             optimize_cmf(data, png_image_size(png_ptr));
  5.1468 - #endif
  5.1469 - 
  5.1470 -+#ifdef PNG_WRITE_APNG_SUPPORTED
  5.1471 -+         if (png_ptr->num_frames_written == 0)
  5.1472 -+#endif
  5.1473 -          png_write_complete_chunk(png_ptr, png_IDAT, data, size);
  5.1474 -+#ifdef PNG_WRITE_APNG_SUPPORTED
  5.1475 -+         else
  5.1476 -+            png_write_fdAT(png_ptr, data, size);
  5.1477 -+#endif /* WRITE_APNG */
  5.1478 -+
  5.1479 -          png_ptr->zstream.avail_out = 0;
  5.1480 -          png_ptr->zstream.next_out = NULL;
  5.1481 -          png_ptr->mode |= PNG_HAVE_IDAT | PNG_AFTER_IDAT;
  5.1482 -@@ -1858,6 +1879,82 @@
  5.1483 - }
  5.1484 - #endif
  5.1485 - 
  5.1486 -+#ifdef PNG_WRITE_APNG_SUPPORTED
  5.1487 -+void /* PRIVATE */
  5.1488 -+png_write_acTL(png_structp png_ptr,
  5.1489 -+    png_uint_32 num_frames, png_uint_32 num_plays)
  5.1490 -+{
  5.1491 -+    png_byte buf[8];
  5.1492 -+
  5.1493 -+    png_debug(1, "in png_write_acTL");
  5.1494 -+
  5.1495 -+    png_ptr->num_frames_to_write = num_frames;
  5.1496 -+
  5.1497 -+    if ((png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN) != 0)
  5.1498 -+        num_frames--;
  5.1499 -+
  5.1500 -+    png_save_uint_32(buf, num_frames);
  5.1501 -+    png_save_uint_32(buf + 4, num_plays);
  5.1502 -+
  5.1503 -+    png_write_complete_chunk(png_ptr, png_acTL, buf, (png_size_t)8);
  5.1504 -+}
  5.1505 -+
  5.1506 -+void /* PRIVATE */
  5.1507 -+png_write_fcTL(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
  5.1508 -+    png_uint_32 x_offset, png_uint_32 y_offset,
  5.1509 -+    png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
  5.1510 -+    png_byte blend_op)
  5.1511 -+{
  5.1512 -+    png_byte buf[26];
  5.1513 -+
  5.1514 -+    png_debug(1, "in png_write_fcTL");
  5.1515 -+
  5.1516 -+    if (png_ptr->num_frames_written == 0 && (x_offset != 0 || y_offset != 0))
  5.1517 -+        png_error(png_ptr, "x and/or y offset for the first frame aren't 0");
  5.1518 -+    if (png_ptr->num_frames_written == 0 &&
  5.1519 -+        (width != png_ptr->first_frame_width ||
  5.1520 -+         height != png_ptr->first_frame_height))
  5.1521 -+        png_error(png_ptr, "width and/or height in the first frame's fcTL "
  5.1522 -+                           "don't match the ones in IHDR");
  5.1523 -+
  5.1524 -+    /* more error checking */
  5.1525 -+    png_ensure_fcTL_is_valid(png_ptr, width, height, x_offset, y_offset,
  5.1526 -+                             delay_num, delay_den, dispose_op, blend_op);
  5.1527 -+
  5.1528 -+    png_save_uint_32(buf, png_ptr->next_seq_num);
  5.1529 -+    png_save_uint_32(buf + 4, width);
  5.1530 -+    png_save_uint_32(buf + 8, height);
  5.1531 -+    png_save_uint_32(buf + 12, x_offset);
  5.1532 -+    png_save_uint_32(buf + 16, y_offset);
  5.1533 -+    png_save_uint_16(buf + 20, delay_num);
  5.1534 -+    png_save_uint_16(buf + 22, delay_den);
  5.1535 -+    buf[24] = dispose_op;
  5.1536 -+    buf[25] = blend_op;
  5.1537 -+
  5.1538 -+    png_write_complete_chunk(png_ptr, png_fcTL, buf, (png_size_t)26);
  5.1539 -+
  5.1540 -+    png_ptr->next_seq_num++;
  5.1541 -+}
  5.1542 -+
  5.1543 -+void /* PRIVATE */
  5.1544 -+png_write_fdAT(png_structp png_ptr,
  5.1545 -+    png_const_bytep data, png_size_t length)
  5.1546 -+{
  5.1547 -+    png_byte buf[4];
  5.1548 -+
  5.1549 -+    png_write_chunk_header(png_ptr, png_fdAT, (png_uint_32)(4 + length));
  5.1550 -+
  5.1551 -+    png_save_uint_32(buf, png_ptr->next_seq_num);
  5.1552 -+    png_write_chunk_data(png_ptr, buf, 4);
  5.1553 -+
  5.1554 -+    png_write_chunk_data(png_ptr, data, length);
  5.1555 -+
  5.1556 -+    png_write_chunk_end(png_ptr);
  5.1557 -+
  5.1558 -+    png_ptr->next_seq_num++;
  5.1559 -+}
  5.1560 -+#endif /* WRITE_APNG */
  5.1561 -+
  5.1562 - /* Initializes the row writing capability of libpng */
  5.1563 - void /* PRIVATE */
  5.1564 - png_write_start_row(png_structrp png_ptr)
  5.1565 -@@ -2752,4 +2849,39 @@
  5.1566 -    }
  5.1567 - #endif /* WRITE_FLUSH */
  5.1568 - }
  5.1569 -+
  5.1570 -+#ifdef PNG_WRITE_APNG_SUPPORTED
  5.1571 -+void /* PRIVATE */
  5.1572 -+png_write_reset(png_structp png_ptr)
  5.1573 -+{
  5.1574 -+    png_ptr->row_number = 0;
  5.1575 -+    png_ptr->pass = 0;
  5.1576 -+    png_ptr->mode &= ~PNG_HAVE_IDAT;
  5.1577 -+}
  5.1578 -+
  5.1579 -+void /* PRIVATE */
  5.1580 -+png_write_reinit(png_structp png_ptr, png_infop info_ptr,
  5.1581 -+                 png_uint_32 width, png_uint_32 height)
  5.1582 -+{
  5.1583 -+    if (png_ptr->num_frames_written == 0 &&
  5.1584 -+        (width != png_ptr->first_frame_width ||
  5.1585 -+         height != png_ptr->first_frame_height))
  5.1586 -+        png_error(png_ptr, "width and/or height in the first frame's fcTL "
  5.1587 -+                           "don't match the ones in IHDR");
  5.1588 -+    if (width > png_ptr->first_frame_width ||
  5.1589 -+        height > png_ptr->first_frame_height)
  5.1590 -+        png_error(png_ptr, "width and/or height for a frame greater than "
  5.1591 -+                           "the ones in IHDR");
  5.1592 -+
  5.1593 -+    png_set_IHDR(png_ptr, info_ptr, width, height,
  5.1594 -+                 info_ptr->bit_depth, info_ptr->color_type,
  5.1595 -+                 info_ptr->interlace_type, info_ptr->compression_type,
  5.1596 -+                 info_ptr->filter_type);
  5.1597 -+
  5.1598 -+    png_ptr->width = width;
  5.1599 -+    png_ptr->height = height;
  5.1600 -+    png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width);
  5.1601 -+    png_ptr->usr_width = png_ptr->width;
  5.1602 -+}
  5.1603 -+#endif /* WRITE_APNG */
  5.1604 - #endif /* WRITE */
  5.1605 -Index: scripts/symbols.def
  5.1606 -===================================================================
  5.1607 ---- a/scripts/symbols.def
  5.1608 -+++ b/scripts/symbols.def
  5.1609 -@@ -250,3 +250,23 @@
  5.1610 -  png_get_palette_max @243
  5.1611 -  png_set_option @244
  5.1612 -  png_image_write_to_memory @245
  5.1613 -+ png_get_acTL @246
  5.1614 -+ png_set_acTL @247
  5.1615 -+ png_get_num_frames @248
  5.1616 -+ png_get_num_plays @249
  5.1617 -+ png_get_next_frame_fcTL @250
  5.1618 -+ png_set_next_frame_fcTL @251
  5.1619 -+ png_get_next_frame_width @252
  5.1620 -+ png_get_next_frame_height @253
  5.1621 -+ png_get_next_frame_x_offset @254
  5.1622 -+ png_get_next_frame_y_offset @255
  5.1623 -+ png_get_next_frame_delay_num @256
  5.1624 -+ png_get_next_frame_delay_den @257
  5.1625 -+ png_get_next_frame_dispose_op @258
  5.1626 -+ png_get_next_frame_blend_op @259
  5.1627 -+ png_get_first_frame_is_hidden @260
  5.1628 -+ png_set_first_frame_is_hidden @261
  5.1629 -+ png_read_frame_head @262
  5.1630 -+ png_set_progressive_frame_fn @263
  5.1631 -+ png_write_frame_head @264
  5.1632 -+ png_write_frame_tail @265
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/libpng16/stuff/patches/libpng-1.6.34-apng.patch	Tue May 01 23:19:32 2018 +0300
     6.3 @@ -0,0 +1,1728 @@
     6.4 +diff -Naru libpng-1.6.34.org/png.h libpng-1.6.34/png.h
     6.5 +--- libpng-1.6.34.org/png.h	2017-09-29 18:55:30.653711999 +0900
     6.6 ++++ libpng-1.6.34/png.h	2017-09-29 18:56:30.306850103 +0900
     6.7 +@@ -361,6 +361,10 @@
     6.8 + #   include "pnglibconf.h"
     6.9 + #endif
    6.10 + 
    6.11 ++#define PNG_APNG_SUPPORTED
    6.12 ++#define PNG_READ_APNG_SUPPORTED
    6.13 ++#define PNG_WRITE_APNG_SUPPORTED
    6.14 ++
    6.15 + #ifndef PNG_VERSION_INFO_ONLY
    6.16 + /* Machine specific configuration. */
    6.17 + #  include "pngconf.h"
    6.18 +@@ -456,6 +460,17 @@
    6.19 +  * See pngconf.h for base types that vary by machine/system
    6.20 +  */
    6.21 + 
    6.22 ++#ifdef PNG_APNG_SUPPORTED
    6.23 ++/* dispose_op flags from inside fcTL */
    6.24 ++#define PNG_DISPOSE_OP_NONE        0x00U
    6.25 ++#define PNG_DISPOSE_OP_BACKGROUND  0x01U
    6.26 ++#define PNG_DISPOSE_OP_PREVIOUS    0x02U
    6.27 ++
    6.28 ++/* blend_op flags from inside fcTL */
    6.29 ++#define PNG_BLEND_OP_SOURCE        0x00U
    6.30 ++#define PNG_BLEND_OP_OVER          0x01U
    6.31 ++#endif /* PNG_APNG_SUPPORTED */
    6.32 ++
    6.33 + /* This triggers a compiler error in png.c, if png.c and png.h
    6.34 +  * do not agree upon the version number.
    6.35 +  */
    6.36 +@@ -777,6 +792,10 @@
    6.37 + #define PNG_INFO_sCAL 0x4000U  /* ESR, 1.0.6 */
    6.38 + #define PNG_INFO_IDAT 0x8000U  /* ESR, 1.0.6 */
    6.39 + #define PNG_INFO_eXIf 0x10000U /* GR-P, 1.6.31 */
    6.40 ++#ifdef PNG_APNG_SUPPORTED
    6.41 ++#define PNG_INFO_acTL 0x20000U
    6.42 ++#define PNG_INFO_fcTL 0x40000U
    6.43 ++#endif
    6.44 + 
    6.45 + /* This is used for the transformation routines, as some of them
    6.46 +  * change these values for the row.  It also should enable using
    6.47 +@@ -814,6 +833,10 @@
    6.48 + #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
    6.49 + typedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop));
    6.50 + typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop));
    6.51 ++#ifdef PNG_APNG_SUPPORTED
    6.52 ++typedef PNG_CALLBACK(void, *png_progressive_frame_ptr, (png_structp,
    6.53 ++    png_uint_32));
    6.54 ++#endif
    6.55 + 
    6.56 + /* The following callback receives png_uint_32 row_number, int pass for the
    6.57 +  * png_bytep data of the row.  When transforming an interlaced image the
    6.58 +@@ -3257,6 +3280,74 @@
    6.59 + /*******************************************************************************
    6.60 +  *  END OF HARDWARE AND SOFTWARE OPTIONS
    6.61 +  ******************************************************************************/
    6.62 ++#ifdef PNG_APNG_SUPPORTED
    6.63 ++PNG_EXPORT(250, png_uint_32, png_get_acTL, (png_structp png_ptr,
    6.64 ++   png_infop info_ptr, png_uint_32 *num_frames, png_uint_32 *num_plays));
    6.65 ++
    6.66 ++PNG_EXPORT(251, png_uint_32, png_set_acTL, (png_structp png_ptr,
    6.67 ++   png_infop info_ptr, png_uint_32 num_frames, png_uint_32 num_plays));
    6.68 ++
    6.69 ++PNG_EXPORT(252, png_uint_32, png_get_num_frames, (png_structp png_ptr,
    6.70 ++   png_infop info_ptr));
    6.71 ++
    6.72 ++PNG_EXPORT(253, png_uint_32, png_get_num_plays, (png_structp png_ptr,
    6.73 ++   png_infop info_ptr));
    6.74 ++
    6.75 ++PNG_EXPORT(254, png_uint_32, png_get_next_frame_fcTL,
    6.76 ++   (png_structp png_ptr, png_infop info_ptr, png_uint_32 *width,
    6.77 ++   png_uint_32 *height, png_uint_32 *x_offset, png_uint_32 *y_offset,
    6.78 ++   png_uint_16 *delay_num, png_uint_16 *delay_den, png_byte *dispose_op,
    6.79 ++   png_byte *blend_op));
    6.80 ++
    6.81 ++PNG_EXPORT(255, png_uint_32, png_set_next_frame_fcTL,
    6.82 ++   (png_structp png_ptr, png_infop info_ptr, png_uint_32 width,
    6.83 ++   png_uint_32 height, png_uint_32 x_offset, png_uint_32 y_offset,
    6.84 ++   png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
    6.85 ++   png_byte blend_op));
    6.86 ++
    6.87 ++PNG_EXPORT(256, png_uint_32, png_get_next_frame_width,
    6.88 ++   (png_structp png_ptr, png_infop info_ptr));
    6.89 ++PNG_EXPORT(257, png_uint_32, png_get_next_frame_height,
    6.90 ++   (png_structp png_ptr, png_infop info_ptr));
    6.91 ++PNG_EXPORT(258, png_uint_32, png_get_next_frame_x_offset,
    6.92 ++   (png_structp png_ptr, png_infop info_ptr));
    6.93 ++PNG_EXPORT(259, png_uint_32, png_get_next_frame_y_offset,
    6.94 ++   (png_structp png_ptr, png_infop info_ptr));
    6.95 ++PNG_EXPORT(260, png_uint_16, png_get_next_frame_delay_num,
    6.96 ++   (png_structp png_ptr, png_infop info_ptr));
    6.97 ++PNG_EXPORT(261, png_uint_16, png_get_next_frame_delay_den,
    6.98 ++   (png_structp png_ptr, png_infop info_ptr));
    6.99 ++PNG_EXPORT(262, png_byte, png_get_next_frame_dispose_op,
   6.100 ++   (png_structp png_ptr, png_infop info_ptr));
   6.101 ++PNG_EXPORT(263, png_byte, png_get_next_frame_blend_op,
   6.102 ++   (png_structp png_ptr, png_infop info_ptr));
   6.103 ++PNG_EXPORT(264, png_byte, png_get_first_frame_is_hidden,
   6.104 ++   (png_structp png_ptr, png_infop info_ptr));
   6.105 ++PNG_EXPORT(265, png_uint_32, png_set_first_frame_is_hidden,
   6.106 ++   (png_structp png_ptr, png_infop info_ptr, png_byte is_hidden));
   6.107 ++
   6.108 ++#ifdef PNG_READ_APNG_SUPPORTED
   6.109 ++PNG_EXPORT(266, void, png_read_frame_head, (png_structp png_ptr,
   6.110 ++   png_infop info_ptr));
   6.111 ++#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
   6.112 ++PNG_EXPORT(267, void, png_set_progressive_frame_fn, (png_structp png_ptr,
   6.113 ++   png_progressive_frame_ptr frame_info_fn,
   6.114 ++   png_progressive_frame_ptr frame_end_fn));
   6.115 ++#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
   6.116 ++#endif /* PNG_READ_APNG_SUPPORTED */
   6.117 ++
   6.118 ++#ifdef PNG_WRITE_APNG_SUPPORTED
   6.119 ++PNG_EXPORT(268, void, png_write_frame_head, (png_structp png_ptr,
   6.120 ++   png_infop info_ptr, png_bytepp row_pointers,
   6.121 ++   png_uint_32 width, png_uint_32 height,
   6.122 ++   png_uint_32 x_offset, png_uint_32 y_offset,
   6.123 ++   png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
   6.124 ++   png_byte blend_op));
   6.125 ++
   6.126 ++PNG_EXPORT(269, void, png_write_frame_tail, (png_structp png_ptr,
   6.127 ++   png_infop info_ptr));
   6.128 ++#endif /* PNG_WRITE_APNG_SUPPORTED */
   6.129 ++#endif /* PNG_APNG_SUPPORTED */
   6.130 + 
   6.131 + /* Maintainer: Put new public prototypes here ^, in libpng.3, in project
   6.132 +  * defs, and in scripts/symbols.def.
   6.133 +@@ -3266,7 +3357,11 @@
   6.134 +  * one to use is one more than this.)
   6.135 +  */
   6.136 + #ifdef PNG_EXPORT_LAST_ORDINAL
   6.137 ++#ifdef PNG_APNG_SUPPORTED
   6.138 ++  PNG_EXPORT_LAST_ORDINAL(269);
   6.139 ++#else
   6.140 +   PNG_EXPORT_LAST_ORDINAL(249);
   6.141 ++#endif /* PNG_APNG_SUPPORTED */
   6.142 + #endif
   6.143 + 
   6.144 + #ifdef __cplusplus
   6.145 +diff -Naru libpng-1.6.34.org/pngget.c libpng-1.6.34/pngget.c
   6.146 +--- libpng-1.6.34.org/pngget.c	2017-09-29 18:53:22.698691668 +0900
   6.147 ++++ libpng-1.6.34/pngget.c	2017-09-29 18:56:30.286848380 +0900
   6.148 +@@ -1245,4 +1245,166 @@
   6.149 + #  endif
   6.150 + #endif
   6.151 + 
   6.152 ++#ifdef PNG_APNG_SUPPORTED
   6.153 ++png_uint_32 PNGAPI
   6.154 ++png_get_acTL(png_structp png_ptr, png_infop info_ptr,
   6.155 ++             png_uint_32 *num_frames, png_uint_32 *num_plays)
   6.156 ++{
   6.157 ++    png_debug1(1, "in %s retrieval function", "acTL");
   6.158 ++
   6.159 ++    if (png_ptr != NULL && info_ptr != NULL &&
   6.160 ++        (info_ptr->valid & PNG_INFO_acTL) &&
   6.161 ++        num_frames != NULL && num_plays != NULL)
   6.162 ++    {
   6.163 ++        *num_frames = info_ptr->num_frames;
   6.164 ++        *num_plays = info_ptr->num_plays;
   6.165 ++        return (1);
   6.166 ++    }
   6.167 ++
   6.168 ++    return (0);
   6.169 ++}
   6.170 ++
   6.171 ++png_uint_32 PNGAPI
   6.172 ++png_get_num_frames(png_structp png_ptr, png_infop info_ptr)
   6.173 ++{
   6.174 ++    png_debug(1, "in png_get_num_frames()");
   6.175 ++
   6.176 ++    if (png_ptr != NULL && info_ptr != NULL)
   6.177 ++        return (info_ptr->num_frames);
   6.178 ++    return (0);
   6.179 ++}
   6.180 ++
   6.181 ++png_uint_32 PNGAPI
   6.182 ++png_get_num_plays(png_structp png_ptr, png_infop info_ptr)
   6.183 ++{
   6.184 ++    png_debug(1, "in png_get_num_plays()");
   6.185 ++
   6.186 ++    if (png_ptr != NULL && info_ptr != NULL)
   6.187 ++        return (info_ptr->num_plays);
   6.188 ++    return (0);
   6.189 ++}
   6.190 ++
   6.191 ++png_uint_32 PNGAPI
   6.192 ++png_get_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
   6.193 ++             png_uint_32 *width, png_uint_32 *height,
   6.194 ++             png_uint_32 *x_offset, png_uint_32 *y_offset,
   6.195 ++             png_uint_16 *delay_num, png_uint_16 *delay_den,
   6.196 ++             png_byte *dispose_op, png_byte *blend_op)
   6.197 ++{
   6.198 ++    png_debug1(1, "in %s retrieval function", "fcTL");
   6.199 ++
   6.200 ++    if (png_ptr != NULL && info_ptr != NULL &&
   6.201 ++        (info_ptr->valid & PNG_INFO_fcTL) &&
   6.202 ++        width != NULL && height != NULL &&
   6.203 ++        x_offset != NULL && y_offset != NULL &&
   6.204 ++        delay_num != NULL && delay_den != NULL &&
   6.205 ++        dispose_op != NULL && blend_op != NULL)
   6.206 ++    {
   6.207 ++        *width = info_ptr->next_frame_width;
   6.208 ++        *height = info_ptr->next_frame_height;
   6.209 ++        *x_offset = info_ptr->next_frame_x_offset;
   6.210 ++        *y_offset = info_ptr->next_frame_y_offset;
   6.211 ++        *delay_num = info_ptr->next_frame_delay_num;
   6.212 ++        *delay_den = info_ptr->next_frame_delay_den;
   6.213 ++        *dispose_op = info_ptr->next_frame_dispose_op;
   6.214 ++        *blend_op = info_ptr->next_frame_blend_op;
   6.215 ++        return (1);
   6.216 ++    }
   6.217 ++
   6.218 ++    return (0);
   6.219 ++}
   6.220 ++
   6.221 ++png_uint_32 PNGAPI
   6.222 ++png_get_next_frame_width(png_structp png_ptr, png_infop info_ptr)
   6.223 ++{
   6.224 ++    png_debug(1, "in png_get_next_frame_width()");
   6.225 ++
   6.226 ++    if (png_ptr != NULL && info_ptr != NULL)
   6.227 ++        return (info_ptr->next_frame_width);
   6.228 ++    return (0);
   6.229 ++}
   6.230 ++
   6.231 ++png_uint_32 PNGAPI
   6.232 ++png_get_next_frame_height(png_structp png_ptr, png_infop info_ptr)
   6.233 ++{
   6.234 ++    png_debug(1, "in png_get_next_frame_height()");
   6.235 ++
   6.236 ++    if (png_ptr != NULL && info_ptr != NULL)
   6.237 ++        return (info_ptr->next_frame_height);
   6.238 ++    return (0);
   6.239 ++}
   6.240 ++
   6.241 ++png_uint_32 PNGAPI
   6.242 ++png_get_next_frame_x_offset(png_structp png_ptr, png_infop info_ptr)
   6.243 ++{
   6.244 ++    png_debug(1, "in png_get_next_frame_x_offset()");
   6.245 ++
   6.246 ++    if (png_ptr != NULL && info_ptr != NULL)
   6.247 ++        return (info_ptr->next_frame_x_offset);
   6.248 ++    return (0);
   6.249 ++}
   6.250 ++
   6.251 ++png_uint_32 PNGAPI
   6.252 ++png_get_next_frame_y_offset(png_structp png_ptr, png_infop info_ptr)
   6.253 ++{
   6.254 ++    png_debug(1, "in png_get_next_frame_y_offset()");
   6.255 ++
   6.256 ++    if (png_ptr != NULL && info_ptr != NULL)
   6.257 ++        return (info_ptr->next_frame_y_offset);
   6.258 ++    return (0);
   6.259 ++}
   6.260 ++
   6.261 ++png_uint_16 PNGAPI
   6.262 ++png_get_next_frame_delay_num(png_structp png_ptr, png_infop info_ptr)
   6.263 ++{
   6.264 ++    png_debug(1, "in png_get_next_frame_delay_num()");
   6.265 ++
   6.266 ++    if (png_ptr != NULL && info_ptr != NULL)
   6.267 ++        return (info_ptr->next_frame_delay_num);
   6.268 ++    return (0);
   6.269 ++}
   6.270 ++
   6.271 ++png_uint_16 PNGAPI
   6.272 ++png_get_next_frame_delay_den(png_structp png_ptr, png_infop info_ptr)
   6.273 ++{
   6.274 ++    png_debug(1, "in png_get_next_frame_delay_den()");
   6.275 ++
   6.276 ++    if (png_ptr != NULL && info_ptr != NULL)
   6.277 ++        return (info_ptr->next_frame_delay_den);
   6.278 ++    return (0);
   6.279 ++}
   6.280 ++
   6.281 ++png_byte PNGAPI
   6.282 ++png_get_next_frame_dispose_op(png_structp png_ptr, png_infop info_ptr)
   6.283 ++{
   6.284 ++    png_debug(1, "in png_get_next_frame_dispose_op()");
   6.285 ++
   6.286 ++    if (png_ptr != NULL && info_ptr != NULL)
   6.287 ++        return (info_ptr->next_frame_dispose_op);
   6.288 ++    return (0);
   6.289 ++}
   6.290 ++
   6.291 ++png_byte PNGAPI
   6.292 ++png_get_next_frame_blend_op(png_structp png_ptr, png_infop info_ptr)
   6.293 ++{
   6.294 ++    png_debug(1, "in png_get_next_frame_blend_op()");
   6.295 ++
   6.296 ++    if (png_ptr != NULL && info_ptr != NULL)
   6.297 ++        return (info_ptr->next_frame_blend_op);
   6.298 ++    return (0);
   6.299 ++}
   6.300 ++
   6.301 ++png_byte PNGAPI
   6.302 ++png_get_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr)
   6.303 ++{
   6.304 ++    png_debug(1, "in png_first_frame_is_hidden()");
   6.305 ++
   6.306 ++    if (png_ptr != NULL)
   6.307 ++       return (png_byte)(png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN);
   6.308 ++
   6.309 ++    PNG_UNUSED(info_ptr)
   6.310 ++
   6.311 ++    return 0;
   6.312 ++}
   6.313 ++#endif /* PNG_APNG_SUPPORTED */
   6.314 + #endif /* READ || WRITE */
   6.315 +diff -Naru libpng-1.6.34.org/pnginfo.h libpng-1.6.34/pnginfo.h
   6.316 +--- libpng-1.6.34.org/pnginfo.h	2017-09-29 18:53:22.698691668 +0900
   6.317 ++++ libpng-1.6.34/pnginfo.h	2017-09-29 18:56:30.286848380 +0900
   6.318 +@@ -263,5 +263,18 @@
   6.319 +    png_bytepp row_pointers;        /* the image bits */
   6.320 + #endif
   6.321 + 
   6.322 ++#ifdef PNG_APNG_SUPPORTED
   6.323 ++   png_uint_32 num_frames; /* including default image */
   6.324 ++   png_uint_32 num_plays;
   6.325 ++   png_uint_32 next_frame_width;
   6.326 ++   png_uint_32 next_frame_height;
   6.327 ++   png_uint_32 next_frame_x_offset;
   6.328 ++   png_uint_32 next_frame_y_offset;
   6.329 ++   png_uint_16 next_frame_delay_num;
   6.330 ++   png_uint_16 next_frame_delay_den;
   6.331 ++   png_byte next_frame_dispose_op;
   6.332 ++   png_byte next_frame_blend_op;
   6.333 ++#endif
   6.334 ++
   6.335 + };
   6.336 + #endif /* PNGINFO_H */
   6.337 +diff -Naru libpng-1.6.34.org/pngpread.c libpng-1.6.34/pngpread.c
   6.338 +--- libpng-1.6.34.org/pngpread.c	2017-09-29 18:53:22.698691668 +0900
   6.339 ++++ libpng-1.6.34/pngpread.c	2017-09-29 18:56:30.286848380 +0900
   6.340 +@@ -195,6 +195,106 @@
   6.341 + 
   6.342 +    chunk_name = png_ptr->chunk_name;
   6.343 + 
   6.344 ++#ifdef PNG_READ_APNG_SUPPORTED
   6.345 ++   if (png_ptr->num_frames_read > 0 &&
   6.346 ++       png_ptr->num_frames_read < info_ptr->num_frames)
   6.347 ++   {
   6.348 ++      if (chunk_name == png_IDAT)
   6.349 ++      {
   6.350 ++         /* Discard trailing IDATs for the first frame */
   6.351 ++         if (png_ptr->mode & PNG_HAVE_fcTL || png_ptr->num_frames_read > 1)
   6.352 ++            png_error(png_ptr, "out of place IDAT");
   6.353 ++
   6.354 ++         if (png_ptr->push_length + 4 > png_ptr->buffer_size)
   6.355 ++         {
   6.356 ++            png_push_save_buffer(png_ptr);
   6.357 ++            return;
   6.358 ++         }
   6.359 ++
   6.360 ++         png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
   6.361 ++         return;
   6.362 ++      }
   6.363 ++      else if (chunk_name == png_fdAT)
   6.364 ++      {
   6.365 ++         if (png_ptr->buffer_size < 4)
   6.366 ++         {
   6.367 ++            png_push_save_buffer(png_ptr);
   6.368 ++            return;
   6.369 ++         }
   6.370 ++
   6.371 ++         png_ensure_sequence_number(png_ptr, 4);
   6.372 ++
   6.373 ++         if (!(png_ptr->mode & PNG_HAVE_fcTL))
   6.374 ++         {
   6.375 ++            /* Discard trailing fdATs for frames other than the first */
   6.376 ++            if (png_ptr->num_frames_read < 2)
   6.377 ++               png_error(png_ptr, "out of place fdAT");
   6.378 ++
   6.379 ++            if (png_ptr->push_length + 4 > png_ptr->buffer_size)
   6.380 ++            {
   6.381 ++               png_push_save_buffer(png_ptr);
   6.382 ++               return;
   6.383 ++            }
   6.384 ++
   6.385 ++            png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
   6.386 ++            return;
   6.387 ++         }
   6.388 ++
   6.389 ++         else
   6.390 ++         {
   6.391 ++            /* frame data follows */
   6.392 ++            png_ptr->idat_size = png_ptr->push_length - 4;
   6.393 ++            png_ptr->mode |= PNG_HAVE_IDAT;
   6.394 ++            png_ptr->process_mode = PNG_READ_IDAT_MODE;
   6.395 ++
   6.396 ++            return;
   6.397 ++         }
   6.398 ++      }
   6.399 ++
   6.400 ++      else if (chunk_name == png_fcTL)
   6.401 ++      {
   6.402 ++         if (png_ptr->push_length + 4 > png_ptr->buffer_size)
   6.403 ++         {
   6.404 ++            png_push_save_buffer(png_ptr);
   6.405 ++            return;
   6.406 ++         }
   6.407 ++
   6.408 ++         png_read_reset(png_ptr);
   6.409 ++         png_ptr->mode &= ~PNG_HAVE_fcTL;
   6.410 ++
   6.411 ++         png_handle_fcTL(png_ptr, info_ptr, png_ptr->push_length);
   6.412 ++
   6.413 ++         if (!(png_ptr->mode & PNG_HAVE_fcTL))
   6.414 ++            png_error(png_ptr, "missing required fcTL chunk");
   6.415 ++
   6.416 ++         png_read_reinit(png_ptr, info_ptr);
   6.417 ++         png_progressive_read_reset(png_ptr);
   6.418 ++
   6.419 ++         if (png_ptr->frame_info_fn != NULL)
   6.420 ++            (*(png_ptr->frame_info_fn))(png_ptr, png_ptr->num_frames_read);
   6.421 ++
   6.422 ++         png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
   6.423 ++
   6.424 ++         return;
   6.425 ++      }
   6.426 ++
   6.427 ++      else
   6.428 ++      {
   6.429 ++         if (png_ptr->push_length + 4 > png_ptr->buffer_size)
   6.430 ++         {
   6.431 ++            png_push_save_buffer(png_ptr);
   6.432 ++            return;
   6.433 ++         }
   6.434 ++         png_warning(png_ptr, "Skipped (ignored) a chunk "
   6.435 ++                              "between APNG chunks");
   6.436 ++         png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
   6.437 ++         return;
   6.438 ++      }
   6.439 ++
   6.440 ++      return;
   6.441 ++   }
   6.442 ++#endif /* PNG_READ_APNG_SUPPORTED */
   6.443 ++
   6.444 +    if (chunk_name == png_IDAT)
   6.445 +    {
   6.446 +       if ((png_ptr->mode & PNG_AFTER_IDAT) != 0)
   6.447 +@@ -261,6 +361,9 @@
   6.448 + 
   6.449 +    else if (chunk_name == png_IDAT)
   6.450 +    {
   6.451 ++#ifdef PNG_READ_APNG_SUPPORTED
   6.452 ++      png_have_info(png_ptr, info_ptr);
   6.453 ++#endif
   6.454 +       png_ptr->idat_size = png_ptr->push_length;
   6.455 +       png_ptr->process_mode = PNG_READ_IDAT_MODE;
   6.456 +       png_push_have_info(png_ptr, info_ptr);
   6.457 +@@ -406,6 +509,30 @@
   6.458 +       png_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
   6.459 +    }
   6.460 + #endif
   6.461 ++#ifdef PNG_READ_APNG_SUPPORTED
   6.462 ++   else if (chunk_name == png_acTL)
   6.463 ++   {
   6.464 ++      if (png_ptr->push_length + 4 > png_ptr->buffer_size)
   6.465 ++      {
   6.466 ++         png_push_save_buffer(png_ptr);
   6.467 ++         return;
   6.468 ++      }
   6.469 ++
   6.470 ++      png_handle_acTL(png_ptr, info_ptr, png_ptr->push_length);
   6.471 ++   }
   6.472 ++
   6.473 ++   else if (chunk_name == png_fcTL)
   6.474 ++   {
   6.475 ++      if (png_ptr->push_length + 4 > png_ptr->buffer_size)
   6.476 ++      {
   6.477 ++         png_push_save_buffer(png_ptr);
   6.478 ++         return;
   6.479 ++      }
   6.480 ++
   6.481 ++      png_handle_fcTL(png_ptr, info_ptr, png_ptr->push_length);
   6.482 ++   }
   6.483 ++
   6.484 ++#endif /* PNG_READ_APNG_SUPPORTED */
   6.485 + 
   6.486 +    else
   6.487 +    {
   6.488 +@@ -539,7 +666,11 @@
   6.489 +       png_byte chunk_tag[4];
   6.490 + 
   6.491 +       /* TODO: this code can be commoned up with the same code in push_read */
   6.492 ++#ifdef PNG_READ_APNG_SUPPORTED
   6.493 ++      PNG_PUSH_SAVE_BUFFER_IF_LT(12)
   6.494 ++#else
   6.495 +       PNG_PUSH_SAVE_BUFFER_IF_LT(8)
   6.496 ++#endif
   6.497 +       png_push_fill_buffer(png_ptr, chunk_length, 4);
   6.498 +       png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
   6.499 +       png_reset_crc(png_ptr);
   6.500 +@@ -547,17 +678,64 @@
   6.501 +       png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);
   6.502 +       png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
   6.503 + 
   6.504 ++#ifdef PNG_READ_APNG_SUPPORTED
   6.505 ++      if (png_ptr->chunk_name != png_fdAT && png_ptr->num_frames_read > 0)
   6.506 ++      {
   6.507 ++          if (png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED)
   6.508 ++          {
   6.509 ++              png_ptr->process_mode = PNG_READ_CHUNK_MODE;
   6.510 ++              if (png_ptr->frame_end_fn != NULL)
   6.511 ++                 (*(png_ptr->frame_end_fn))(png_ptr, png_ptr->num_frames_read);
   6.512 ++              png_ptr->num_frames_read++;
   6.513 ++              return;
   6.514 ++          }
   6.515 ++          else
   6.516 ++          {
   6.517 ++              if (png_ptr->chunk_name == png_IEND)
   6.518 ++                  png_error(png_ptr, "Not enough image data");
   6.519 ++              if (png_ptr->push_length + 4 > png_ptr->buffer_size)
   6.520 ++              {
   6.521 ++                 png_push_save_buffer(png_ptr);
   6.522 ++                 return;
   6.523 ++              }
   6.524 ++              png_warning(png_ptr, "Skipping (ignoring) a chunk between "
   6.525 ++                                   "APNG chunks");
   6.526 ++              png_crc_finish(png_ptr, png_ptr->push_length);
   6.527 ++              png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
   6.528 ++              return;
   6.529 ++          }
   6.530 ++      }
   6.531 ++      else
   6.532 ++#endif
   6.533 ++#ifdef PNG_READ_APNG_SUPPORTED
   6.534 ++      if (png_ptr->chunk_name != png_IDAT && png_ptr->num_frames_read == 0)
   6.535 ++#else
   6.536 +       if (png_ptr->chunk_name != png_IDAT)
   6.537 ++#endif
   6.538 +       {
   6.539 +          png_ptr->process_mode = PNG_READ_CHUNK_MODE;
   6.540 + 
   6.541 +          if ((png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0)
   6.542 +             png_error(png_ptr, "Not enough compressed data");
   6.543 + 
   6.544 ++#ifdef PNG_READ_APNG_SUPPORTED
   6.545 ++         if (png_ptr->frame_end_fn != NULL)
   6.546 ++            (*(png_ptr->frame_end_fn))(png_ptr, png_ptr->num_frames_read);
   6.547 ++         png_ptr->num_frames_read++;
   6.548 ++#endif
   6.549 ++
   6.550 +          return;
   6.551 +       }
   6.552 + 
   6.553 +       png_ptr->idat_size = png_ptr->push_length;
   6.554 ++
   6.555 ++#ifdef PNG_READ_APNG_SUPPORTED
   6.556 ++      if (png_ptr->num_frames_read > 0)
   6.557 ++      {
   6.558 ++         png_ensure_sequence_number(png_ptr, 4);
   6.559 ++         png_ptr->idat_size -= 4;
   6.560 ++      }
   6.561 ++#endif
   6.562 +    }
   6.563 + 
   6.564 +    if (png_ptr->idat_size != 0 && png_ptr->save_buffer_size != 0)
   6.565 +@@ -631,6 +809,15 @@
   6.566 +    if (!(buffer_length > 0) || buffer == NULL)
   6.567 +       png_error(png_ptr, "No IDAT data (internal error)");
   6.568 + 
   6.569 ++#ifdef PNG_READ_APNG_SUPPORTED
   6.570 ++   /* If the app is not APNG-aware, decode only the first frame */
   6.571 ++   if (!(png_ptr->apng_flags & PNG_APNG_APP) && png_ptr->num_frames_read > 0)
   6.572 ++   {
   6.573 ++     png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
   6.574 ++     return;
   6.575 ++   }
   6.576 ++#endif
   6.577 ++
   6.578 +    /* This routine must process all the data it has been given
   6.579 +     * before returning, calling the row callback as required to
   6.580 +     * handle the uncompressed results.
   6.581 +@@ -1085,6 +1272,18 @@
   6.582 +    png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer);
   6.583 + }
   6.584 + 
   6.585 ++#ifdef PNG_READ_APNG_SUPPORTED
   6.586 ++void PNGAPI
   6.587 ++png_set_progressive_frame_fn(png_structp png_ptr,
   6.588 ++   png_progressive_frame_ptr frame_info_fn,
   6.589 ++   png_progressive_frame_ptr frame_end_fn)
   6.590 ++{
   6.591 ++   png_ptr->frame_info_fn = frame_info_fn;
   6.592 ++   png_ptr->frame_end_fn = frame_end_fn;
   6.593 ++   png_ptr->apng_flags |= PNG_APNG_APP;
   6.594 ++}
   6.595 ++#endif
   6.596 ++
   6.597 + png_voidp PNGAPI
   6.598 + png_get_progressive_ptr(png_const_structrp png_ptr)
   6.599 + {
   6.600 +diff -Naru libpng-1.6.34.org/pngpriv.h libpng-1.6.34/pngpriv.h
   6.601 +--- libpng-1.6.34.org/pngpriv.h	2017-09-29 18:53:22.699691754 +0900
   6.602 ++++ libpng-1.6.34/pngpriv.h	2017-09-29 18:56:30.286848380 +0900
   6.603 +@@ -628,6 +628,10 @@
   6.604 + #define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000U /* Have another chunk after IDAT */
   6.605 +                    /*             0x4000U (unused) */
   6.606 + #define PNG_IS_READ_STRUCT        0x8000U /* Else is a write struct */
   6.607 ++#ifdef PNG_APNG_SUPPORTED
   6.608 ++#define PNG_HAVE_acTL            0x10000U
   6.609 ++#define PNG_HAVE_fcTL            0x20000U
   6.610 ++#endif
   6.611 + 
   6.612 + /* Flags for the transformations the PNG library does on the image data */
   6.613 + #define PNG_BGR                 0x0001U
   6.614 +@@ -864,6 +868,16 @@
   6.615 + #define png_tRNS PNG_U32(116,  82,  78,  83)
   6.616 + #define png_zTXt PNG_U32(122,  84,  88, 116)
   6.617 + 
   6.618 ++#ifdef PNG_APNG_SUPPORTED
   6.619 ++#define png_acTL PNG_U32( 97,  99,  84,  76)
   6.620 ++#define png_fcTL PNG_U32(102,  99,  84,  76)
   6.621 ++#define png_fdAT PNG_U32(102, 100,  65,  84)
   6.622 ++
   6.623 ++/* For png_struct.apng_flags: */
   6.624 ++#define PNG_FIRST_FRAME_HIDDEN       0x0001U
   6.625 ++#define PNG_APNG_APP                 0x0002U
   6.626 ++#endif
   6.627 ++
   6.628 + /* The following will work on (signed char*) strings, whereas the get_uint_32
   6.629 +  * macro will fail on top-bit-set values because of the sign extension.
   6.630 +  */
   6.631 +@@ -1635,6 +1649,47 @@
   6.632 +     */
   6.633 + #endif
   6.634 + 
   6.635 ++#ifdef PNG_APNG_SUPPORTED
   6.636 ++PNG_INTERNAL_FUNCTION(void,png_ensure_fcTL_is_valid,(png_structp png_ptr,
   6.637 ++   png_uint_32 width, png_uint_32 height,
   6.638 ++   png_uint_32 x_offset, png_uint_32 y_offset,
   6.639 ++   png_uint_16 delay_num, png_uint_16 delay_den,
   6.640 ++   png_byte dispose_op, png_byte blend_op), PNG_EMPTY);
   6.641 ++
   6.642 ++#ifdef PNG_READ_APNG_SUPPORTED
   6.643 ++PNG_INTERNAL_FUNCTION(void,png_handle_acTL,(png_structp png_ptr, png_infop info_ptr,
   6.644 ++   png_uint_32 length),PNG_EMPTY);
   6.645 ++PNG_INTERNAL_FUNCTION(void,png_handle_fcTL,(png_structp png_ptr, png_infop info_ptr,
   6.646 ++   png_uint_32 length),PNG_EMPTY);
   6.647 ++PNG_INTERNAL_FUNCTION(void,png_handle_fdAT,(png_structp png_ptr, png_infop info_ptr,
   6.648 ++   png_uint_32 length),PNG_EMPTY);
   6.649 ++PNG_INTERNAL_FUNCTION(void,png_have_info,(png_structp png_ptr, png_infop info_ptr),PNG_EMPTY);
   6.650 ++PNG_INTERNAL_FUNCTION(void,png_ensure_sequence_number,(png_structp png_ptr,
   6.651 ++   png_uint_32 length),PNG_EMPTY);
   6.652 ++PNG_INTERNAL_FUNCTION(void,png_read_reset,(png_structp png_ptr),PNG_EMPTY);
   6.653 ++PNG_INTERNAL_FUNCTION(void,png_read_reinit,(png_structp png_ptr,
   6.654 ++   png_infop info_ptr),PNG_EMPTY);
   6.655 ++#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
   6.656 ++PNG_INTERNAL_FUNCTION(void,png_progressive_read_reset,(png_structp png_ptr),PNG_EMPTY);
   6.657 ++#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
   6.658 ++#endif /* PNG_READ_APNG_SUPPORTED */
   6.659 ++
   6.660 ++#ifdef PNG_WRITE_APNG_SUPPORTED
   6.661 ++PNG_INTERNAL_FUNCTION(void,png_write_acTL,(png_structp png_ptr,
   6.662 ++   png_uint_32 num_frames, png_uint_32 num_plays),PNG_EMPTY);
   6.663 ++PNG_INTERNAL_FUNCTION(void,png_write_fcTL,(png_structp png_ptr,
   6.664 ++   png_uint_32 width, png_uint_32 height,
   6.665 ++   png_uint_32 x_offset, png_uint_32 y_offset,
   6.666 ++   png_uint_16 delay_num, png_uint_16 delay_den,
   6.667 ++   png_byte dispose_op, png_byte blend_op),PNG_EMPTY);
   6.668 ++PNG_INTERNAL_FUNCTION(void,png_write_fdAT,(png_structp png_ptr,
   6.669 ++   png_const_bytep data, png_size_t length),PNG_EMPTY);
   6.670 ++PNG_INTERNAL_FUNCTION(void,png_write_reset,(png_structp png_ptr),PNG_EMPTY);
   6.671 ++PNG_INTERNAL_FUNCTION(void,png_write_reinit,(png_structp png_ptr,
   6.672 ++   png_infop info_ptr, png_uint_32 width, png_uint_32 height),PNG_EMPTY);
   6.673 ++#endif /* PNG_WRITE_APNG_SUPPORTED */
   6.674 ++#endif /* PNG_APNG_SUPPORTED */
   6.675 ++
   6.676 + /* Added at libpng version 1.4.0 */
   6.677 + #ifdef PNG_COLORSPACE_SUPPORTED
   6.678 + /* These internal functions are for maintaining the colorspace structure within
   6.679 +diff -Naru libpng-1.6.34.org/pngread.c libpng-1.6.34/pngread.c
   6.680 +--- libpng-1.6.34.org/pngread.c	2017-09-29 18:53:22.699691754 +0900
   6.681 ++++ libpng-1.6.34/pngread.c	2017-09-29 18:56:30.286848380 +0900
   6.682 +@@ -161,6 +161,9 @@
   6.683 + 
   6.684 +       else if (chunk_name == png_IDAT)
   6.685 +       {
   6.686 ++#ifdef PNG_READ_APNG_SUPPORTED
   6.687 ++         png_have_info(png_ptr, info_ptr);
   6.688 ++#endif
   6.689 +          png_ptr->idat_size = length;
   6.690 +          break;
   6.691 +       }
   6.692 +@@ -255,6 +258,17 @@
   6.693 +          png_handle_iTXt(png_ptr, info_ptr, length);
   6.694 + #endif
   6.695 + 
   6.696 ++#ifdef PNG_READ_APNG_SUPPORTED
   6.697 ++      else if (chunk_name == png_acTL)
   6.698 ++         png_handle_acTL(png_ptr, info_ptr, length);
   6.699 ++
   6.700 ++      else if (chunk_name == png_fcTL)
   6.701 ++         png_handle_fcTL(png_ptr, info_ptr, length);
   6.702 ++
   6.703 ++      else if (chunk_name == png_fdAT)
   6.704 ++         png_handle_fdAT(png_ptr, info_ptr, length);
   6.705 ++#endif
   6.706 ++
   6.707 +       else
   6.708 +          png_handle_unknown(png_ptr, info_ptr, length,
   6.709 +              PNG_HANDLE_CHUNK_AS_DEFAULT);
   6.710 +@@ -262,6 +276,72 @@
   6.711 + }
   6.712 + #endif /* SEQUENTIAL_READ */
   6.713 + 
   6.714 ++#ifdef PNG_READ_APNG_SUPPORTED
   6.715 ++void PNGAPI
   6.716 ++png_read_frame_head(png_structp png_ptr, png_infop info_ptr)
   6.717 ++{
   6.718 ++    png_byte have_chunk_after_DAT; /* after IDAT or after fdAT */
   6.719 ++
   6.720 ++    png_debug(0, "Reading frame head");
   6.721 ++
   6.722 ++    if (!(png_ptr->mode & PNG_HAVE_acTL))
   6.723 ++        png_error(png_ptr, "attempt to png_read_frame_head() but "
   6.724 ++                           "no acTL present");
   6.725 ++
   6.726 ++    /* do nothing for the main IDAT */
   6.727 ++    if (png_ptr->num_frames_read == 0)
   6.728 ++        return;
   6.729 ++
   6.730 ++    png_read_reset(png_ptr);
   6.731 ++    png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
   6.732 ++    png_ptr->mode &= ~PNG_HAVE_fcTL;
   6.733 ++
   6.734 ++    have_chunk_after_DAT = 0;
   6.735 ++    for (;;)
   6.736 ++    {
   6.737 ++        png_uint_32 length = png_read_chunk_header(png_ptr);
   6.738 ++
   6.739 ++        if (png_ptr->chunk_name == png_IDAT)
   6.740 ++        {
   6.741 ++            /* discard trailing IDATs for the first frame */
   6.742 ++            if (have_chunk_after_DAT || png_ptr->num_frames_read > 1)
   6.743 ++                png_error(png_ptr, "png_read_frame_head(): out of place IDAT");
   6.744 ++            png_crc_finish(png_ptr, length);
   6.745 ++        }
   6.746 ++
   6.747 ++        else if (png_ptr->chunk_name == png_fcTL)
   6.748 ++        {
   6.749 ++            png_handle_fcTL(png_ptr, info_ptr, length);
   6.750 ++            have_chunk_after_DAT = 1;
   6.751 ++        }
   6.752 ++
   6.753 ++        else if (png_ptr->chunk_name == png_fdAT)
   6.754 ++        {
   6.755 ++            png_ensure_sequence_number(png_ptr, length);
   6.756 ++
   6.757 ++            /* discard trailing fdATs for frames other than the first */
   6.758 ++            if (!have_chunk_after_DAT && png_ptr->num_frames_read > 1)
   6.759 ++                png_crc_finish(png_ptr, length - 4);
   6.760 ++            else if(png_ptr->mode & PNG_HAVE_fcTL)
   6.761 ++            {
   6.762 ++                png_ptr->idat_size = length - 4;
   6.763 ++                png_ptr->mode |= PNG_HAVE_IDAT;
   6.764 ++
   6.765 ++                break;
   6.766 ++            }
   6.767 ++            else
   6.768 ++                png_error(png_ptr, "png_read_frame_head(): out of place fdAT");
   6.769 ++        }
   6.770 ++        else
   6.771 ++        {
   6.772 ++            png_warning(png_ptr, "Skipped (ignored) a chunk "
   6.773 ++                                 "between APNG chunks");
   6.774 ++            png_crc_finish(png_ptr, length);
   6.775 ++        }
   6.776 ++    }
   6.777 ++}
   6.778 ++#endif /* PNG_READ_APNG_SUPPORTED */
   6.779 ++
   6.780 + /* Optional call to update the users info_ptr structure */
   6.781 + void PNGAPI
   6.782 + png_read_update_info(png_structrp png_ptr, png_inforp info_ptr)
   6.783 +diff -Naru libpng-1.6.34.org/pngrutil.c libpng-1.6.34/pngrutil.c
   6.784 +--- libpng-1.6.34.org/pngrutil.c	2017-09-29 18:53:22.701691926 +0900
   6.785 ++++ libpng-1.6.34/pngrutil.c	2017-09-29 18:56:30.287848466 +0900
   6.786 +@@ -865,6 +865,11 @@
   6.787 +    filter_type = buf[11];
   6.788 +    interlace_type = buf[12];
   6.789 + 
   6.790 ++#ifdef PNG_READ_APNG_SUPPORTED
   6.791 ++   png_ptr->first_frame_width = width;
   6.792 ++   png_ptr->first_frame_height = height;
   6.793 ++#endif
   6.794 ++
   6.795 +    /* Set internal variables */
   6.796 +    png_ptr->width = width;
   6.797 +    png_ptr->height = height;
   6.798 +@@ -2840,6 +2845,179 @@
   6.799 + }
   6.800 + #endif
   6.801 + 
   6.802 ++#ifdef PNG_READ_APNG_SUPPORTED
   6.803 ++void /* PRIVATE */
   6.804 ++png_handle_acTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
   6.805 ++{
   6.806 ++    png_byte data[8];
   6.807 ++    png_uint_32 num_frames;
   6.808 ++    png_uint_32 num_plays;
   6.809 ++    png_uint_32 didSet;
   6.810 ++
   6.811 ++    png_debug(1, "in png_handle_acTL");
   6.812 ++
   6.813 ++    if (!(png_ptr->mode & PNG_HAVE_IHDR))
   6.814 ++    {
   6.815 ++        png_error(png_ptr, "Missing IHDR before acTL");
   6.816 ++    }
   6.817 ++    else if (png_ptr->mode & PNG_HAVE_IDAT)
   6.818 ++    {
   6.819 ++        png_warning(png_ptr, "Invalid acTL after IDAT skipped");
   6.820 ++        png_crc_finish(png_ptr, length);
   6.821 ++        return;
   6.822 ++    }
   6.823 ++    else if (png_ptr->mode & PNG_HAVE_acTL)
   6.824 ++    {
   6.825 ++        png_warning(png_ptr, "Duplicate acTL skipped");
   6.826 ++        png_crc_finish(png_ptr, length);
   6.827 ++        return;
   6.828 ++    }
   6.829 ++    else if (length != 8)
   6.830 ++    {
   6.831 ++        png_warning(png_ptr, "acTL with invalid length skipped");
   6.832 ++        png_crc_finish(png_ptr, length);
   6.833 ++        return;
   6.834 ++    }
   6.835 ++
   6.836 ++    png_crc_read(png_ptr, data, 8);
   6.837 ++    png_crc_finish(png_ptr, 0);
   6.838 ++
   6.839 ++    num_frames = png_get_uint_31(png_ptr, data);
   6.840 ++    num_plays = png_get_uint_31(png_ptr, data + 4);
   6.841 ++
   6.842 ++    /* the set function will do error checking on num_frames */
   6.843 ++    didSet = png_set_acTL(png_ptr, info_ptr, num_frames, num_plays);
   6.844 ++    if(didSet)
   6.845 ++        png_ptr->mode |= PNG_HAVE_acTL;
   6.846 ++}
   6.847 ++
   6.848 ++void /* PRIVATE */
   6.849 ++png_handle_fcTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
   6.850 ++{
   6.851 ++    png_byte data[22];
   6.852 ++    png_uint_32 width;
   6.853 ++    png_uint_32 height;
   6.854 ++    png_uint_32 x_offset;
   6.855 ++    png_uint_32 y_offset;
   6.856 ++    png_uint_16 delay_num;
   6.857 ++    png_uint_16 delay_den;
   6.858 ++    png_byte dispose_op;
   6.859 ++    png_byte blend_op;
   6.860 ++
   6.861 ++    png_debug(1, "in png_handle_fcTL");
   6.862 ++
   6.863 ++    png_ensure_sequence_number(png_ptr, length);
   6.864 ++
   6.865 ++    if (!(png_ptr->mode & PNG_HAVE_IHDR))
   6.866 ++    {
   6.867 ++        png_error(png_ptr, "Missing IHDR before fcTL");
   6.868 ++    }
   6.869 ++    else if (png_ptr->mode & PNG_HAVE_IDAT)
   6.870 ++    {
   6.871 ++        /* for any frames other then the first this message may be misleading,
   6.872 ++        * but correct. PNG_HAVE_IDAT is unset before the frame head is read
   6.873 ++        * i can't think of a better message */
   6.874 ++        png_warning(png_ptr, "Invalid fcTL after IDAT skipped");
   6.875 ++        png_crc_finish(png_ptr, length-4);
   6.876 ++        return;
   6.877 ++    }
   6.878 ++    else if (png_ptr->mode & PNG_HAVE_fcTL)
   6.879 ++    {
   6.880 ++        png_warning(png_ptr, "Duplicate fcTL within one frame skipped");
   6.881 ++        png_crc_finish(png_ptr, length-4);
   6.882 ++        return;
   6.883 ++    }
   6.884 ++    else if (length != 26)
   6.885 ++    {
   6.886 ++        png_warning(png_ptr, "fcTL with invalid length skipped");
   6.887 ++        png_crc_finish(png_ptr, length-4);
   6.888 ++        return;
   6.889 ++    }
   6.890 ++
   6.891 ++    png_crc_read(png_ptr, data, 22);
   6.892 ++    png_crc_finish(png_ptr, 0);
   6.893 ++
   6.894 ++    width = png_get_uint_31(png_ptr, data);
   6.895 ++    height = png_get_uint_31(png_ptr, data + 4);
   6.896 ++    x_offset = png_get_uint_31(png_ptr, data + 8);
   6.897 ++    y_offset = png_get_uint_31(png_ptr, data + 12);
   6.898 ++    delay_num = png_get_uint_16(data + 16);
   6.899 ++    delay_den = png_get_uint_16(data + 18);
   6.900 ++    dispose_op = data[20];
   6.901 ++    blend_op = data[21];
   6.902 ++
   6.903 ++    if (png_ptr->num_frames_read == 0 && (x_offset != 0 || y_offset != 0))
   6.904 ++    {
   6.905 ++        png_warning(png_ptr, "fcTL for the first frame must have zero offset");
   6.906 ++        return;
   6.907 ++    }
   6.908 ++
   6.909 ++    if (info_ptr != NULL)
   6.910 ++    {
   6.911 ++        if (png_ptr->num_frames_read == 0 &&
   6.912 ++            (width != info_ptr->width || height != info_ptr->height))
   6.913 ++        {
   6.914 ++            png_warning(png_ptr, "size in first frame's fcTL must match "
   6.915 ++                               "the size in IHDR");
   6.916 ++            return;
   6.917 ++        }
   6.918 ++
   6.919 ++        /* The set function will do more error checking */
   6.920 ++        png_set_next_frame_fcTL(png_ptr, info_ptr, width, height,
   6.921 ++                                x_offset, y_offset, delay_num, delay_den,
   6.922 ++                                dispose_op, blend_op);
   6.923 ++
   6.924 ++        png_read_reinit(png_ptr, info_ptr);
   6.925 ++
   6.926 ++        png_ptr->mode |= PNG_HAVE_fcTL;
   6.927 ++    }
   6.928 ++}
   6.929 ++
   6.930 ++void /* PRIVATE */
   6.931 ++png_have_info(png_structp png_ptr, png_infop info_ptr)
   6.932 ++{
   6.933 ++    if((info_ptr->valid & PNG_INFO_acTL) && !(info_ptr->valid & PNG_INFO_fcTL))
   6.934 ++    {
   6.935 ++        png_ptr->apng_flags |= PNG_FIRST_FRAME_HIDDEN;
   6.936 ++        info_ptr->num_frames++;
   6.937 ++    }
   6.938 ++}
   6.939 ++
   6.940 ++void /* PRIVATE */
   6.941 ++png_handle_fdAT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
   6.942 ++{
   6.943 ++    png_ensure_sequence_number(png_ptr, length);
   6.944 ++
   6.945 ++    /* This function is only called from png_read_end(), png_read_info(),
   6.946 ++    * and png_push_read_chunk() which means that:
   6.947 ++    * - the user doesn't want to read this frame
   6.948 ++    * - or this is an out-of-place fdAT
   6.949 ++    * in either case it is safe to ignore the chunk with a warning */
   6.950 ++    png_warning(png_ptr, "ignoring fdAT chunk");
   6.951 ++    png_crc_finish(png_ptr, length - 4);
   6.952 ++    PNG_UNUSED(info_ptr)
   6.953 ++}
   6.954 ++
   6.955 ++void /* PRIVATE */
   6.956 ++png_ensure_sequence_number(png_structp png_ptr, png_uint_32 length)
   6.957 ++{
   6.958 ++    png_byte data[4];
   6.959 ++    png_uint_32 sequence_number;
   6.960 ++
   6.961 ++    if (length < 4)
   6.962 ++        png_error(png_ptr, "invalid fcTL or fdAT chunk found");
   6.963 ++
   6.964 ++    png_crc_read(png_ptr, data, 4);
   6.965 ++    sequence_number = png_get_uint_31(png_ptr, data);
   6.966 ++
   6.967 ++    if (sequence_number != png_ptr->next_seq_num)
   6.968 ++        png_error(png_ptr, "fcTL or fdAT chunk with out-of-order sequence "
   6.969 ++                           "number found");
   6.970 ++
   6.971 ++    png_ptr->next_seq_num++;
   6.972 ++}
   6.973 ++#endif /* PNG_READ_APNG_SUPPORTED */
   6.974 ++
   6.975 + #ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
   6.976 + /* Utility function for png_handle_unknown; set up png_ptr::unknown_chunk */
   6.977 + static int
   6.978 +@@ -4145,7 +4323,38 @@
   6.979 +       {
   6.980 +          uInt avail_in;
   6.981 +          png_bytep buffer;
   6.982 ++#ifdef PNG_READ_APNG_SUPPORTED
   6.983 ++         png_uint_32 bytes_to_skip = 0;
   6.984 ++
   6.985 ++         while (png_ptr->idat_size == 0 || bytes_to_skip != 0)
   6.986 ++         {
   6.987 ++            png_crc_finish(png_ptr, bytes_to_skip);
   6.988 ++            bytes_to_skip = 0;
   6.989 ++
   6.990 ++            png_ptr->idat_size = png_read_chunk_header(png_ptr);
   6.991 ++            if (png_ptr->num_frames_read == 0)
   6.992 ++            {
   6.993 ++               if (png_ptr->chunk_name != png_IDAT)
   6.994 ++                  png_error(png_ptr, "Not enough image data");
   6.995 ++            }
   6.996 ++            else
   6.997 ++            {
   6.998 ++               if (png_ptr->chunk_name == png_IEND)
   6.999 ++                  png_error(png_ptr, "Not enough image data");
  6.1000 ++               if (png_ptr->chunk_name != png_fdAT)
  6.1001 ++               {
  6.1002 ++                  png_warning(png_ptr, "Skipped (ignored) a chunk "
  6.1003 ++                                       "between APNG chunks");
  6.1004 ++                  bytes_to_skip = png_ptr->idat_size;
  6.1005 ++                  continue;
  6.1006 ++               }
  6.1007 + 
  6.1008 ++               png_ensure_sequence_number(png_ptr, png_ptr->idat_size);
  6.1009 ++
  6.1010 ++               png_ptr->idat_size -= 4;
  6.1011 ++            }
  6.1012 ++         }
  6.1013 ++#else
  6.1014 +          while (png_ptr->idat_size == 0)
  6.1015 +          {
  6.1016 +             png_crc_finish(png_ptr, 0);
  6.1017 +@@ -4157,7 +4366,7 @@
  6.1018 +             if (png_ptr->chunk_name != png_IDAT)
  6.1019 +                png_error(png_ptr, "Not enough image data");
  6.1020 +          }
  6.1021 +-
  6.1022 ++#endif /* PNG_READ_APNG_SUPPORTED */
  6.1023 +          avail_in = png_ptr->IDAT_read_size;
  6.1024 + 
  6.1025 +          if (avail_in > png_ptr->idat_size)
  6.1026 +@@ -4220,6 +4429,9 @@
  6.1027 + 
  6.1028 +          png_ptr->mode |= PNG_AFTER_IDAT;
  6.1029 +          png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;
  6.1030 ++#ifdef PNG_READ_APNG_SUPPORTED
  6.1031 ++         png_ptr->num_frames_read++;
  6.1032 ++#endif
  6.1033 + 
  6.1034 +          if (png_ptr->zstream.avail_in > 0 || png_ptr->idat_size > 0)
  6.1035 +             png_chunk_benign_error(png_ptr, "Extra compressed data");
  6.1036 +@@ -4658,4 +4870,80 @@
  6.1037 + 
  6.1038 +    png_ptr->flags |= PNG_FLAG_ROW_INIT;
  6.1039 + }
  6.1040 ++
  6.1041 ++#ifdef PNG_READ_APNG_SUPPORTED
  6.1042 ++/* This function is to be called after the main IDAT set has been read and
  6.1043 ++ * before a new IDAT is read. It resets some parts of png_ptr
  6.1044 ++ * to make them usable by the read functions again */
  6.1045 ++void /* PRIVATE */
  6.1046 ++png_read_reset(png_structp png_ptr)
  6.1047 ++{
  6.1048 ++    png_ptr->mode &= ~PNG_HAVE_IDAT;
  6.1049 ++    png_ptr->mode &= ~PNG_AFTER_IDAT;
  6.1050 ++    png_ptr->row_number = 0;
  6.1051 ++    png_ptr->pass = 0;
  6.1052 ++}
  6.1053 ++
  6.1054 ++void /* PRIVATE */
  6.1055 ++png_read_reinit(png_structp png_ptr, png_infop info_ptr)
  6.1056 ++{
  6.1057 ++    png_ptr->width = info_ptr->next_frame_width;
  6.1058 ++    png_ptr->height = info_ptr->next_frame_height;
  6.1059 ++    png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->width);
  6.1060 ++    png_ptr->info_rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,
  6.1061 ++        png_ptr->width);
  6.1062 ++    if (png_ptr->prev_row)
  6.1063 ++        memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
  6.1064 ++}
  6.1065 ++
  6.1066 ++#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
  6.1067 ++/* same as png_read_reset() but for the progressive reader */
  6.1068 ++void /* PRIVATE */
  6.1069 ++png_progressive_read_reset(png_structp png_ptr)
  6.1070 ++{
  6.1071 ++#ifdef PNG_READ_INTERLACING_SUPPORTED
  6.1072 ++   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
  6.1073 ++
  6.1074 ++   /* Start of interlace block */
  6.1075 ++    const int png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
  6.1076 ++
  6.1077 ++    /* Offset to next interlace block */
  6.1078 ++    const int png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
  6.1079 ++
  6.1080 ++    /* Start of interlace block in the y direction */
  6.1081 ++    const int png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
  6.1082 ++
  6.1083 ++    /* Offset to next interlace block in the y direction */
  6.1084 ++    const int png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
  6.1085 ++
  6.1086 ++    if (png_ptr->interlaced)
  6.1087 ++    {
  6.1088 ++        if (!(png_ptr->transformations & PNG_INTERLACE))
  6.1089 ++            png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 -
  6.1090 ++                                png_pass_ystart[0]) / png_pass_yinc[0];
  6.1091 ++        else
  6.1092 ++            png_ptr->num_rows = png_ptr->height;
  6.1093 ++
  6.1094 ++        png_ptr->iwidth = (png_ptr->width +
  6.1095 ++                           png_pass_inc[png_ptr->pass] - 1 -
  6.1096 ++                           png_pass_start[png_ptr->pass]) /
  6.1097 ++                           png_pass_inc[png_ptr->pass];
  6.1098 ++    }
  6.1099 ++    else
  6.1100 ++#endif /* PNG_READ_INTERLACING_SUPPORTED */
  6.1101 ++    {
  6.1102 ++        png_ptr->num_rows = png_ptr->height;
  6.1103 ++        png_ptr->iwidth = png_ptr->width;
  6.1104 ++    }
  6.1105 ++    png_ptr->flags &= ~PNG_FLAG_ZSTREAM_ENDED;
  6.1106 ++    if (inflateReset(&(png_ptr->zstream)) != Z_OK)
  6.1107 ++        png_error(png_ptr, "inflateReset failed");
  6.1108 ++    png_ptr->zstream.avail_in = 0;
  6.1109 ++    png_ptr->zstream.next_in = 0;
  6.1110 ++    png_ptr->zstream.next_out = png_ptr->row_buf;
  6.1111 ++    png_ptr->zstream.avail_out = (uInt)PNG_ROWBYTES(png_ptr->pixel_depth,
  6.1112 ++        png_ptr->iwidth) + 1;
  6.1113 ++}
  6.1114 ++#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
  6.1115 ++#endif /* PNG_READ_APNG_SUPPORTED */
  6.1116 + #endif /* READ */
  6.1117 +diff -Naru libpng-1.6.34.org/pngset.c libpng-1.6.34/pngset.c
  6.1118 +--- libpng-1.6.34.org/pngset.c	2017-09-29 18:53:22.701691926 +0900
  6.1119 ++++ libpng-1.6.34/pngset.c	2017-09-29 18:56:30.292848897 +0900
  6.1120 +@@ -288,6 +288,11 @@
  6.1121 +    info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
  6.1122 + 
  6.1123 +    info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width);
  6.1124 ++
  6.1125 ++#ifdef PNG_APNG_SUPPORTED
  6.1126 ++   /* for non-animated png. this may be overwritten from an acTL chunk later */
  6.1127 ++   info_ptr->num_frames = 1;
  6.1128 ++#endif
  6.1129 + }
  6.1130 + 
  6.1131 + #ifdef PNG_oFFs_SUPPORTED
  6.1132 +@@ -1158,6 +1163,147 @@
  6.1133 + }
  6.1134 + #endif /* sPLT */
  6.1135 + 
  6.1136 ++#ifdef PNG_APNG_SUPPORTED
  6.1137 ++png_uint_32 PNGAPI
  6.1138 ++png_set_acTL(png_structp png_ptr, png_infop info_ptr,
  6.1139 ++    png_uint_32 num_frames, png_uint_32 num_plays)
  6.1140 ++{
  6.1141 ++    png_debug1(1, "in %s storage function", "acTL");
  6.1142 ++
  6.1143 ++    if (png_ptr == NULL || info_ptr == NULL)
  6.1144 ++    {
  6.1145 ++        png_warning(png_ptr,
  6.1146 ++                    "Call to png_set_acTL() with NULL png_ptr "
  6.1147 ++                    "or info_ptr ignored");
  6.1148 ++        return (0);
  6.1149 ++    }
  6.1150 ++    if (num_frames == 0)
  6.1151 ++    {
  6.1152 ++        png_warning(png_ptr,
  6.1153 ++                    "Ignoring attempt to set acTL with num_frames zero");
  6.1154 ++        return (0);
  6.1155 ++    }
  6.1156 ++    if (num_frames > PNG_UINT_31_MAX)
  6.1157 ++    {
  6.1158 ++        png_warning(png_ptr,
  6.1159 ++                    "Ignoring attempt to set acTL with num_frames > 2^31-1");
  6.1160 ++        return (0);
  6.1161 ++    }
  6.1162 ++    if (num_plays > PNG_UINT_31_MAX)
  6.1163 ++    {
  6.1164 ++        png_warning(png_ptr,
  6.1165 ++                    "Ignoring attempt to set acTL with num_plays "
  6.1166 ++                    "> 2^31-1");
  6.1167 ++        return (0);
  6.1168 ++    }
  6.1169 ++
  6.1170 ++    info_ptr->num_frames = num_frames;
  6.1171 ++    info_ptr->num_plays = num_plays;
  6.1172 ++
  6.1173 ++    info_ptr->valid |= PNG_INFO_acTL;
  6.1174 ++
  6.1175 ++    return (1);
  6.1176 ++}
  6.1177 ++
  6.1178 ++/* delay_num and delay_den can hold any 16-bit values including zero */
  6.1179 ++png_uint_32 PNGAPI
  6.1180 ++png_set_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
  6.1181 ++    png_uint_32 width, png_uint_32 height,
  6.1182 ++    png_uint_32 x_offset, png_uint_32 y_offset,
  6.1183 ++    png_uint_16 delay_num, png_uint_16 delay_den,
  6.1184 ++    png_byte dispose_op, png_byte blend_op)
  6.1185 ++{
  6.1186 ++    png_debug1(1, "in %s storage function", "fcTL");
  6.1187 ++
  6.1188 ++    if (png_ptr == NULL || info_ptr == NULL)
  6.1189 ++    {
  6.1190 ++        png_warning(png_ptr,
  6.1191 ++                    "Call to png_set_fcTL() with NULL png_ptr or info_ptr "
  6.1192 ++                    "ignored");
  6.1193 ++        return (0);
  6.1194 ++    }
  6.1195 ++
  6.1196 ++    png_ensure_fcTL_is_valid(png_ptr, width, height, x_offset, y_offset,
  6.1197 ++                             delay_num, delay_den, dispose_op, blend_op);
  6.1198 ++
  6.1199 ++    if (blend_op == PNG_BLEND_OP_OVER)
  6.1200 ++    {
  6.1201 ++        if (!(png_ptr->color_type & PNG_COLOR_MASK_ALPHA) &&
  6.1202 ++            !(png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)))
  6.1203 ++        {
  6.1204 ++          png_warning(png_ptr, "PNG_BLEND_OP_OVER is meaningless "
  6.1205 ++                               "and wasteful for opaque images, ignored");
  6.1206 ++          blend_op = PNG_BLEND_OP_SOURCE;
  6.1207 ++        }
  6.1208 ++    }
  6.1209 ++
  6.1210 ++    info_ptr->next_frame_width = width;
  6.1211 ++    info_ptr->next_frame_height = height;
  6.1212 ++    info_ptr->next_frame_x_offset = x_offset;
  6.1213 ++    info_ptr->next_frame_y_offset = y_offset;
  6.1214 ++    info_ptr->next_frame_delay_num = delay_num;
  6.1215 ++    info_ptr->next_frame_delay_den = delay_den;
  6.1216 ++    info_ptr->next_frame_dispose_op = dispose_op;
  6.1217 ++    info_ptr->next_frame_blend_op = blend_op;
  6.1218 ++
  6.1219 ++    info_ptr->valid |= PNG_INFO_fcTL;
  6.1220 ++
  6.1221 ++    return (1);
  6.1222 ++}
  6.1223 ++
  6.1224 ++void /* PRIVATE */
  6.1225 ++png_ensure_fcTL_is_valid(png_structp png_ptr,
  6.1226 ++    png_uint_32 width, png_uint_32 height,
  6.1227 ++    png_uint_32 x_offset, png_uint_32 y_offset,
  6.1228 ++    png_uint_16 delay_num, png_uint_16 delay_den,
  6.1229 ++    png_byte dispose_op, png_byte blend_op)
  6.1230 ++{
  6.1231 ++    if (width == 0 || width > PNG_UINT_31_MAX)
  6.1232 ++        png_error(png_ptr, "invalid width in fcTL (> 2^31-1)");
  6.1233 ++    if (height == 0 || height > PNG_UINT_31_MAX)
  6.1234 ++        png_error(png_ptr, "invalid height in fcTL (> 2^31-1)");
  6.1235 ++    if (x_offset > PNG_UINT_31_MAX)
  6.1236 ++        png_error(png_ptr, "invalid x_offset in fcTL (> 2^31-1)");
  6.1237 ++    if (y_offset > PNG_UINT_31_MAX)
  6.1238 ++        png_error(png_ptr, "invalid y_offset in fcTL (> 2^31-1)");
  6.1239 ++    if (width + x_offset > png_ptr->first_frame_width ||
  6.1240 ++        height + y_offset > png_ptr->first_frame_height)
  6.1241 ++        png_error(png_ptr, "dimensions of a frame are greater than"
  6.1242 ++                           "the ones in IHDR");
  6.1243 ++
  6.1244 ++    if (dispose_op != PNG_DISPOSE_OP_NONE &&
  6.1245 ++        dispose_op != PNG_DISPOSE_OP_BACKGROUND &&
  6.1246 ++        dispose_op != PNG_DISPOSE_OP_PREVIOUS)
  6.1247 ++        png_error(png_ptr, "invalid dispose_op in fcTL");
  6.1248 ++
  6.1249 ++    if (blend_op != PNG_BLEND_OP_SOURCE &&
  6.1250 ++        blend_op != PNG_BLEND_OP_OVER)
  6.1251 ++        png_error(png_ptr, "invalid blend_op in fcTL");
  6.1252 ++
  6.1253 ++    PNG_UNUSED(delay_num)
  6.1254 ++    PNG_UNUSED(delay_den)
  6.1255 ++}
  6.1256 ++
  6.1257 ++png_uint_32 PNGAPI
  6.1258 ++png_set_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr,
  6.1259 ++                              png_byte is_hidden)
  6.1260 ++{
  6.1261 ++    png_debug(1, "in png_first_frame_is_hidden()");
  6.1262 ++
  6.1263 ++    if (png_ptr == NULL)
  6.1264 ++        return 0;
  6.1265 ++
  6.1266 ++    if (is_hidden)
  6.1267 ++        png_ptr->apng_flags |= PNG_FIRST_FRAME_HIDDEN;
  6.1268 ++    else
  6.1269 ++        png_ptr->apng_flags &= ~PNG_FIRST_FRAME_HIDDEN;
  6.1270 ++
  6.1271 ++    PNG_UNUSED(info_ptr)
  6.1272 ++
  6.1273 ++    return 1;
  6.1274 ++}
  6.1275 ++#endif /* PNG_APNG_SUPPORTED */
  6.1276 ++
  6.1277 + #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
  6.1278 + static png_byte
  6.1279 + check_location(png_const_structrp png_ptr, int location)
  6.1280 +diff -Naru libpng-1.6.34.org/pngstruct.h libpng-1.6.34/pngstruct.h
  6.1281 +--- libpng-1.6.34.org/pngstruct.h	2017-09-29 18:53:22.701691926 +0900
  6.1282 ++++ libpng-1.6.34/pngstruct.h	2017-09-29 18:56:30.287848466 +0900
  6.1283 +@@ -403,6 +403,27 @@
  6.1284 +    png_byte filter_type;
  6.1285 + #endif
  6.1286 + 
  6.1287 ++#ifdef PNG_APNG_SUPPORTED
  6.1288 ++   png_uint_32 apng_flags;
  6.1289 ++   png_uint_32 next_seq_num;         /* next fcTL/fdAT chunk sequence number */
  6.1290 ++   png_uint_32 first_frame_width;
  6.1291 ++   png_uint_32 first_frame_height;
  6.1292 ++
  6.1293 ++#ifdef PNG_READ_APNG_SUPPORTED
  6.1294 ++   png_uint_32 num_frames_read;      /* incremented after all image data of */
  6.1295 ++                                     /* a frame is read */
  6.1296 ++#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
  6.1297 ++   png_progressive_frame_ptr frame_info_fn; /* frame info read callback */
  6.1298 ++   png_progressive_frame_ptr frame_end_fn;  /* frame data read callback */
  6.1299 ++#endif
  6.1300 ++#endif
  6.1301 ++
  6.1302 ++#ifdef PNG_WRITE_APNG_SUPPORTED
  6.1303 ++   png_uint_32 num_frames_to_write;
  6.1304 ++   png_uint_32 num_frames_written;
  6.1305 ++#endif
  6.1306 ++#endif /* PNG_APNG_SUPPORTED */
  6.1307 ++
  6.1308 + /* New members added in libpng-1.2.0 */
  6.1309 + 
  6.1310 + /* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */
  6.1311 +diff -Naru libpng-1.6.34.org/pngtest.c libpng-1.6.34/pngtest.c
  6.1312 +--- libpng-1.6.34.org/pngtest.c	2017-09-29 18:55:30.654712085 +0900
  6.1313 ++++ libpng-1.6.34/pngtest.c	2017-09-29 18:56:30.287848466 +0900
  6.1314 +@@ -875,6 +875,10 @@
  6.1315 +    volatile int num_passes;
  6.1316 +    int pass;
  6.1317 +    int bit_depth, color_type;
  6.1318 ++#ifdef PNG_APNG_SUPPORTED
  6.1319 ++   png_uint_32 num_frames;
  6.1320 ++   png_uint_32 num_plays;
  6.1321 ++#endif
  6.1322 + 
  6.1323 +    row_buf = NULL;
  6.1324 +    error_parameters.file_name = inname;
  6.1325 +@@ -1381,6 +1385,22 @@
  6.1326 +       }
  6.1327 +    }
  6.1328 + #endif
  6.1329 ++
  6.1330 ++#ifdef PNG_APNG_SUPPORTED
  6.1331 ++   if (png_get_valid(read_ptr, read_info_ptr, PNG_INFO_acTL))
  6.1332 ++   {
  6.1333 ++      if (png_get_acTL(read_ptr, read_info_ptr, &num_frames, &num_plays))
  6.1334 ++      {
  6.1335 ++         png_byte is_hidden;
  6.1336 ++         pngtest_debug2("Handling acTL chunks (frames %ld, plays %ld)",
  6.1337 ++                    num_frames, num_plays);
  6.1338 ++         png_set_acTL(write_ptr, write_info_ptr, num_frames, num_plays);
  6.1339 ++         is_hidden = png_get_first_frame_is_hidden(read_ptr, read_info_ptr);
  6.1340 ++         png_set_first_frame_is_hidden(write_ptr, write_info_ptr, is_hidden);
  6.1341 ++      }
  6.1342 ++   }
  6.1343 ++#endif
  6.1344 ++
  6.1345 + #ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
  6.1346 +    {
  6.1347 +       png_unknown_chunkp unknowns;
  6.1348 +@@ -1461,6 +1481,110 @@
  6.1349 +    t_misc += (t_stop - t_start);
  6.1350 +    t_start = t_stop;
  6.1351 + #endif
  6.1352 ++#ifdef PNG_APNG_SUPPORTED
  6.1353 ++   if (png_get_valid(read_ptr, read_info_ptr, PNG_INFO_acTL))
  6.1354 ++   {
  6.1355 ++      png_uint_32 frame;
  6.1356 ++      for (frame = 0; frame < num_frames; frame++)
  6.1357 ++      {
  6.1358 ++         png_uint_32 frame_width;
  6.1359 ++         png_uint_32 frame_height;
  6.1360 ++         png_uint_32 x_offset;
  6.1361 ++         png_uint_32 y_offset;
  6.1362 ++         png_uint_16 delay_num;
  6.1363 ++         png_uint_16 delay_den;
  6.1364 ++         png_byte dispose_op;
  6.1365 ++         png_byte blend_op;
  6.1366 ++         png_read_frame_head(read_ptr, read_info_ptr);
  6.1367 ++         if (png_get_valid(read_ptr, read_info_ptr, PNG_INFO_fcTL))
  6.1368 ++         {
  6.1369 ++            png_get_next_frame_fcTL(read_ptr, read_info_ptr,
  6.1370 ++                                    &frame_width, &frame_height,
  6.1371 ++                                    &x_offset, &y_offset,
  6.1372 ++                                    &delay_num, &delay_den,
  6.1373 ++                                    &dispose_op, &blend_op);
  6.1374 ++         }
  6.1375 ++         else
  6.1376 ++         {
  6.1377 ++            frame_width = width;
  6.1378 ++            frame_height = height;
  6.1379 ++            x_offset = 0;
  6.1380 ++            y_offset = 0;
  6.1381 ++            delay_num = 1;
  6.1382 ++            delay_den = 1;
  6.1383 ++            dispose_op = PNG_DISPOSE_OP_NONE;
  6.1384 ++            blend_op = PNG_BLEND_OP_SOURCE;
  6.1385 ++         }
  6.1386 ++#ifdef PNG_WRITE_APNG_SUPPORTED
  6.1387 ++         png_write_frame_head(write_ptr, write_info_ptr, (png_bytepp)&row_buf,
  6.1388 ++                              frame_width, frame_height,
  6.1389 ++                              x_offset, y_offset,
  6.1390 ++                              delay_num, delay_den,
  6.1391 ++                              dispose_op, blend_op);
  6.1392 ++#endif
  6.1393 ++         for (pass = 0; pass < num_passes; pass++)
  6.1394 ++         {
  6.1395 ++#           ifdef calc_pass_height
  6.1396 ++               png_uint_32 pass_height;
  6.1397 ++
  6.1398 ++               if (num_passes == 7) /* interlaced */
  6.1399 ++               {
  6.1400 ++                  if (PNG_PASS_COLS(frame_width, pass) > 0)
  6.1401 ++                     pass_height = PNG_PASS_ROWS(frame_height, pass);
  6.1402 ++
  6.1403 ++                  else
  6.1404 ++                     pass_height = 0;
  6.1405 ++               }
  6.1406 ++
  6.1407 ++               else /* not interlaced */
  6.1408 ++                  pass_height = frame_height;
  6.1409 ++#           else
  6.1410 ++#              define pass_height frame_height
  6.1411 ++#           endif
  6.1412 ++
  6.1413 ++            pngtest_debug1("Writing row data for pass %d", pass);
  6.1414 ++            for (y = 0; y < pass_height; y++)
  6.1415 ++            {
  6.1416 ++#ifndef SINGLE_ROWBUF_ALLOC
  6.1417 ++               pngtest_debug2("Allocating row buffer (pass %d, y = %u)...", pass, y);
  6.1418 ++
  6.1419 ++               row_buf = (png_bytep)png_malloc(read_ptr,
  6.1420 ++                  png_get_rowbytes(read_ptr, read_info_ptr));
  6.1421 ++
  6.1422 ++               pngtest_debug2("\t0x%08lx (%lu bytes)", (unsigned long)row_buf,
  6.1423 ++                  (unsigned long)png_get_rowbytes(read_ptr, read_info_ptr));
  6.1424 ++
  6.1425 ++#endif /* !SINGLE_ROWBUF_ALLOC */
  6.1426 ++               png_read_rows(read_ptr, (png_bytepp)&row_buf, NULL, 1);
  6.1427 ++
  6.1428 ++#ifdef PNG_WRITE_SUPPORTED
  6.1429 ++#ifdef PNGTEST_TIMING
  6.1430 ++               t_stop = (float)clock();
  6.1431 ++               t_decode += (t_stop - t_start);
  6.1432 ++               t_start = t_stop;
  6.1433 ++#endif
  6.1434 ++               png_write_rows(write_ptr, (png_bytepp)&row_buf, 1);
  6.1435 ++#ifdef PNGTEST_TIMING
  6.1436 ++               t_stop = (float)clock();
  6.1437 ++               t_encode += (t_stop - t_start);
  6.1438 ++               t_start = t_stop;
  6.1439 ++#endif
  6.1440 ++#endif /* PNG_WRITE_SUPPORTED */
  6.1441 ++
  6.1442 ++#ifndef SINGLE_ROWBUF_ALLOC
  6.1443 ++               pngtest_debug2("Freeing row buffer (pass %d, y = %u)", pass, y);
  6.1444 ++               png_free(read_ptr, row_buf);
  6.1445 ++               row_buf = NULL;
  6.1446 ++#endif /* !SINGLE_ROWBUF_ALLOC */
  6.1447 ++            }
  6.1448 ++         }
  6.1449 ++#ifdef PNG_WRITE_APNG_SUPPORTED
  6.1450 ++         png_write_frame_tail(write_ptr, write_info_ptr);
  6.1451 ++#endif
  6.1452 ++      }
  6.1453 ++   }
  6.1454 ++   else
  6.1455 ++#endif
  6.1456 +    for (pass = 0; pass < num_passes; pass++)
  6.1457 +    {
  6.1458 + #     ifdef calc_pass_height
  6.1459 +diff -Naru libpng-1.6.34.org/pngwrite.c libpng-1.6.34/pngwrite.c
  6.1460 +--- libpng-1.6.34.org/pngwrite.c	2017-09-29 18:53:22.702692013 +0900
  6.1461 ++++ libpng-1.6.34/pngwrite.c	2017-09-29 18:56:30.288848552 +0900
  6.1462 +@@ -128,6 +128,10 @@
  6.1463 +        * the application continues writing the PNG.  So check the 'invalid'
  6.1464 +        * flag here too.
  6.1465 +        */
  6.1466 ++#ifdef PNG_WRITE_APNG_SUPPORTED
  6.1467 ++      if (info_ptr->valid & PNG_INFO_acTL)
  6.1468 ++         png_write_acTL(png_ptr, info_ptr->num_frames, info_ptr->num_plays);
  6.1469 ++#endif
  6.1470 + #ifdef PNG_GAMMA_SUPPORTED
  6.1471 + #  ifdef PNG_WRITE_gAMA_SUPPORTED
  6.1472 +       if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
  6.1473 +@@ -370,6 +374,11 @@
  6.1474 +       png_benign_error(png_ptr, "Wrote palette index exceeding num_palette");
  6.1475 + #endif
  6.1476 + 
  6.1477 ++#ifdef PNG_WRITE_APNG_SUPPORTED
  6.1478 ++   if (png_ptr->num_frames_written != png_ptr->num_frames_to_write)
  6.1479 ++      png_error(png_ptr, "Not enough frames written");
  6.1480 ++#endif
  6.1481 ++
  6.1482 +    /* See if user wants us to write information chunks */
  6.1483 +    if (info_ptr != NULL)
  6.1484 +    {
  6.1485 +@@ -1461,6 +1470,43 @@
  6.1486 + }
  6.1487 + #endif
  6.1488 + 
  6.1489 ++#ifdef PNG_WRITE_APNG_SUPPORTED
  6.1490 ++void PNGAPI
  6.1491 ++png_write_frame_head(png_structp png_ptr, png_infop info_ptr,
  6.1492 ++    png_bytepp row_pointers, png_uint_32 width, png_uint_32 height,
  6.1493 ++    png_uint_32 x_offset, png_uint_32 y_offset,
  6.1494 ++    png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
  6.1495 ++    png_byte blend_op)
  6.1496 ++{
  6.1497 ++    png_debug(1, "in png_write_frame_head");
  6.1498 ++
  6.1499 ++    /* there is a chance this has been set after png_write_info was called,
  6.1500 ++    * so it would be set but not written. is there a way to be sure? */
  6.1501 ++    if (!(info_ptr->valid & PNG_INFO_acTL))
  6.1502 ++        png_error(png_ptr, "png_write_frame_head(): acTL not set");
  6.1503 ++
  6.1504 ++    png_write_reset(png_ptr);
  6.1505 ++
  6.1506 ++    png_write_reinit(png_ptr, info_ptr, width, height);
  6.1507 ++
  6.1508 ++    if ( !(png_ptr->num_frames_written == 0 &&
  6.1509 ++           (png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN) ) )
  6.1510 ++        png_write_fcTL(png_ptr, width, height, x_offset, y_offset,
  6.1511 ++                       delay_num, delay_den, dispose_op, blend_op);
  6.1512 ++
  6.1513 ++    PNG_UNUSED(row_pointers)
  6.1514 ++}
  6.1515 ++
  6.1516 ++void PNGAPI
  6.1517 ++png_write_frame_tail(png_structp png_ptr, png_infop info_ptr)
  6.1518 ++{
  6.1519 ++    png_debug(1, "in png_write_frame_tail");
  6.1520 ++
  6.1521 ++    png_ptr->num_frames_written++;
  6.1522 ++
  6.1523 ++    PNG_UNUSED(info_ptr)
  6.1524 ++}
  6.1525 ++#endif /* PNG_WRITE_APNG_SUPPORTED */
  6.1526 + 
  6.1527 + #ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
  6.1528 + /* Initialize the write structure - general purpose utility. */
  6.1529 +diff -Naru libpng-1.6.34.org/pngwutil.c libpng-1.6.34/pngwutil.c
  6.1530 +--- libpng-1.6.34.org/pngwutil.c	2017-09-29 18:53:22.703692099 +0900
  6.1531 ++++ libpng-1.6.34/pngwutil.c	2017-09-29 18:56:30.302849758 +0900
  6.1532 +@@ -822,6 +822,11 @@
  6.1533 +    /* Write the chunk */
  6.1534 +    png_write_complete_chunk(png_ptr, png_IHDR, buf, (png_size_t)13);
  6.1535 + 
  6.1536 ++#ifdef PNG_WRITE_APNG_SUPPORTED
  6.1537 ++   png_ptr->first_frame_width = width;
  6.1538 ++   png_ptr->first_frame_height = height;
  6.1539 ++#endif
  6.1540 ++
  6.1541 +    if ((png_ptr->do_filter) == PNG_NO_FILTERS)
  6.1542 +    {
  6.1543 +       if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE ||
  6.1544 +@@ -1003,8 +1008,17 @@
  6.1545 +                optimize_cmf(data, png_image_size(png_ptr));
  6.1546 + #endif
  6.1547 + 
  6.1548 +-         if (size > 0)
  6.1549 +-            png_write_complete_chunk(png_ptr, png_IDAT, data, size);
  6.1550 ++            if (size > 0)
  6.1551 ++#ifdef PNG_WRITE_APNG_SUPPORTED
  6.1552 ++            {
  6.1553 ++               if (png_ptr->num_frames_written == 0)
  6.1554 ++#endif
  6.1555 ++               png_write_complete_chunk(png_ptr, png_IDAT, data, size);
  6.1556 ++#ifdef PNG_WRITE_APNG_SUPPORTED
  6.1557 ++               else
  6.1558 ++                  png_write_fdAT(png_ptr, data, size);
  6.1559 ++            }
  6.1560 ++#endif /* PNG_WRITE_APNG_SUPPORTED */
  6.1561 +          png_ptr->mode |= PNG_HAVE_IDAT;
  6.1562 + 
  6.1563 +          png_ptr->zstream.next_out = data;
  6.1564 +@@ -1051,7 +1065,17 @@
  6.1565 + #endif
  6.1566 + 
  6.1567 +          if (size > 0)
  6.1568 ++#ifdef PNG_WRITE_APNG_SUPPORTED
  6.1569 ++         {
  6.1570 ++            if (png_ptr->num_frames_written == 0)
  6.1571 ++#endif
  6.1572 +             png_write_complete_chunk(png_ptr, png_IDAT, data, size);
  6.1573 ++#ifdef PNG_WRITE_APNG_SUPPORTED
  6.1574 ++            else
  6.1575 ++               png_write_fdAT(png_ptr, data, size);
  6.1576 ++         }
  6.1577 ++#endif /* PNG_WRITE_APNG_SUPPORTED */
  6.1578 ++
  6.1579 +          png_ptr->zstream.avail_out = 0;
  6.1580 +          png_ptr->zstream.next_out = NULL;
  6.1581 +          png_ptr->mode |= PNG_HAVE_IDAT | PNG_AFTER_IDAT;
  6.1582 +@@ -1887,6 +1911,82 @@
  6.1583 + }
  6.1584 + #endif
  6.1585 + 
  6.1586 ++#ifdef PNG_WRITE_APNG_SUPPORTED
  6.1587 ++void /* PRIVATE */
  6.1588 ++png_write_acTL(png_structp png_ptr,
  6.1589 ++    png_uint_32 num_frames, png_uint_32 num_plays)
  6.1590 ++{
  6.1591 ++    png_byte buf[8];
  6.1592 ++
  6.1593 ++    png_debug(1, "in png_write_acTL");
  6.1594 ++
  6.1595 ++    png_ptr->num_frames_to_write = num_frames;
  6.1596 ++
  6.1597 ++    if (png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN)
  6.1598 ++        num_frames--;
  6.1599 ++
  6.1600 ++    png_save_uint_32(buf, num_frames);
  6.1601 ++    png_save_uint_32(buf + 4, num_plays);
  6.1602 ++
  6.1603 ++    png_write_complete_chunk(png_ptr, png_acTL, buf, (png_size_t)8);
  6.1604 ++}
  6.1605 ++
  6.1606 ++void /* PRIVATE */
  6.1607 ++png_write_fcTL(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
  6.1608 ++    png_uint_32 x_offset, png_uint_32 y_offset,
  6.1609 ++    png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
  6.1610 ++    png_byte blend_op)
  6.1611 ++{
  6.1612 ++    png_byte buf[26];
  6.1613 ++
  6.1614 ++    png_debug(1, "in png_write_fcTL");
  6.1615 ++
  6.1616 ++    if (png_ptr->num_frames_written == 0 && (x_offset != 0 || y_offset != 0))
  6.1617 ++        png_error(png_ptr, "x and/or y offset for the first frame aren't 0");
  6.1618 ++    if (png_ptr->num_frames_written == 0 &&
  6.1619 ++        (width != png_ptr->first_frame_width ||
  6.1620 ++         height != png_ptr->first_frame_height))
  6.1621 ++        png_error(png_ptr, "width and/or height in the first frame's fcTL "
  6.1622 ++                           "don't match the ones in IHDR");
  6.1623 ++
  6.1624 ++    /* more error checking */
  6.1625 ++    png_ensure_fcTL_is_valid(png_ptr, width, height, x_offset, y_offset,
  6.1626 ++                             delay_num, delay_den, dispose_op, blend_op);
  6.1627 ++
  6.1628 ++    png_save_uint_32(buf, png_ptr->next_seq_num);
  6.1629 ++    png_save_uint_32(buf + 4, width);
  6.1630 ++    png_save_uint_32(buf + 8, height);
  6.1631 ++    png_save_uint_32(buf + 12, x_offset);
  6.1632 ++    png_save_uint_32(buf + 16, y_offset);
  6.1633 ++    png_save_uint_16(buf + 20, delay_num);
  6.1634 ++    png_save_uint_16(buf + 22, delay_den);
  6.1635 ++    buf[24] = dispose_op;
  6.1636 ++    buf[25] = blend_op;
  6.1637 ++
  6.1638 ++    png_write_complete_chunk(png_ptr, png_fcTL, buf, (png_size_t)26);
  6.1639 ++
  6.1640 ++    png_ptr->next_seq_num++;
  6.1641 ++}
  6.1642 ++
  6.1643 ++void /* PRIVATE */
  6.1644 ++png_write_fdAT(png_structp png_ptr,
  6.1645 ++    png_const_bytep data, png_size_t length)
  6.1646 ++{
  6.1647 ++    png_byte buf[4];
  6.1648 ++
  6.1649 ++    png_write_chunk_header(png_ptr, png_fdAT, (png_uint_32)(4 + length));
  6.1650 ++
  6.1651 ++    png_save_uint_32(buf, png_ptr->next_seq_num);
  6.1652 ++    png_write_chunk_data(png_ptr, buf, 4);
  6.1653 ++
  6.1654 ++    png_write_chunk_data(png_ptr, data, length);
  6.1655 ++
  6.1656 ++    png_write_chunk_end(png_ptr);
  6.1657 ++
  6.1658 ++    png_ptr->next_seq_num++;
  6.1659 ++}
  6.1660 ++#endif /* PNG_WRITE_APNG_SUPPORTED */
  6.1661 ++
  6.1662 + /* Initializes the row writing capability of libpng */
  6.1663 + void /* PRIVATE */
  6.1664 + png_write_start_row(png_structrp png_ptr)
  6.1665 +@@ -2781,4 +2881,39 @@
  6.1666 +    }
  6.1667 + #endif /* WRITE_FLUSH */
  6.1668 + }
  6.1669 ++
  6.1670 ++#ifdef PNG_WRITE_APNG_SUPPORTED
  6.1671 ++void /* PRIVATE */
  6.1672 ++png_write_reset(png_structp png_ptr)
  6.1673 ++{
  6.1674 ++    png_ptr->row_number = 0;
  6.1675 ++    png_ptr->pass = 0;
  6.1676 ++    png_ptr->mode &= ~PNG_HAVE_IDAT;
  6.1677 ++}
  6.1678 ++
  6.1679 ++void /* PRIVATE */
  6.1680 ++png_write_reinit(png_structp png_ptr, png_infop info_ptr,
  6.1681 ++                 png_uint_32 width, png_uint_32 height)
  6.1682 ++{
  6.1683 ++    if (png_ptr->num_frames_written == 0 &&
  6.1684 ++        (width != png_ptr->first_frame_width ||
  6.1685 ++         height != png_ptr->first_frame_height))
  6.1686 ++        png_error(png_ptr, "width and/or height in the first frame's fcTL "
  6.1687 ++                           "don't match the ones in IHDR");
  6.1688 ++    if (width > png_ptr->first_frame_width ||
  6.1689 ++        height > png_ptr->first_frame_height)
  6.1690 ++        png_error(png_ptr, "width and/or height for a frame greater than"
  6.1691 ++                           "the ones in IHDR");
  6.1692 ++
  6.1693 ++    png_set_IHDR(png_ptr, info_ptr, width, height,
  6.1694 ++                 info_ptr->bit_depth, info_ptr->color_type,
  6.1695 ++                 info_ptr->interlace_type, info_ptr->compression_type,
  6.1696 ++                 info_ptr->filter_type);
  6.1697 ++
  6.1698 ++    png_ptr->width = width;
  6.1699 ++    png_ptr->height = height;
  6.1700 ++    png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width);
  6.1701 ++    png_ptr->usr_width = png_ptr->width;
  6.1702 ++}
  6.1703 ++#endif /* PNG_WRITE_APNG_SUPPORTED */
  6.1704 + #endif /* WRITE */
  6.1705 +diff -Naru libpng-1.6.34.org/scripts/symbols.def libpng-1.6.34/scripts/symbols.def
  6.1706 +--- libpng-1.6.34.org/scripts/symbols.def	2017-09-29 18:55:30.655712171 +0900
  6.1707 ++++ libpng-1.6.34/scripts/symbols.def	2017-09-29 18:56:30.289848638 +0900
  6.1708 +@@ -254,3 +254,23 @@
  6.1709 +  png_set_eXIf @247
  6.1710 +  png_get_eXIf_1 @248
  6.1711 +  png_set_eXIf_1 @249
  6.1712 ++ png_get_acTL @250
  6.1713 ++ png_set_acTL @251
  6.1714 ++ png_get_num_frames @252
  6.1715 ++ png_get_num_plays @253
  6.1716 ++ png_get_next_frame_fcTL @254
  6.1717 ++ png_set_next_frame_fcTL @255
  6.1718 ++ png_get_next_frame_width @256
  6.1719 ++ png_get_next_frame_height @257
  6.1720 ++ png_get_next_frame_x_offset @258
  6.1721 ++ png_get_next_frame_y_offset @259
  6.1722 ++ png_get_next_frame_delay_num @260
  6.1723 ++ png_get_next_frame_delay_den @261
  6.1724 ++ png_get_next_frame_dispose_op @262
  6.1725 ++ png_get_next_frame_blend_op @263
  6.1726 ++ png_get_first_frame_is_hidden @264
  6.1727 ++ png_set_first_frame_is_hidden @265
  6.1728 ++ png_read_frame_head @266
  6.1729 ++ png_set_progressive_frame_fn @267
  6.1730 ++ png_write_frame_head @268
  6.1731 ++ png_write_frame_tail @269
     7.1 --- a/libpng16/stuff/patches/series	Tue May 01 17:41:04 2018 +0300
     7.2 +++ b/libpng16/stuff/patches/series	Tue May 01 23:19:32 2018 +0300
     7.3 @@ -1,1 +1,5 @@
     7.4 -libpng-1.6.28-apng.patch
     7.5 +# This patch listed in the BLFS page, was downloaded using following address and
     7.6 +# unzipped:
     7.7 +# https://downloads.sourceforge.net/sourceforge/libpng-apng/libpng-1.6.34-apng.patch.gz
     7.8 +
     7.9 +-p1|libpng-1.6.34-apng.patch
     8.1 --- a/libraw/receipt	Tue May 01 17:41:04 2018 +0300
     8.2 +++ b/libraw/receipt	Tue May 01 23:19:32 2018 +0300
     8.3 @@ -1,12 +1,13 @@
     8.4  # SliTaz package receipt v2.
     8.5  
     8.6  PACKAGE="libraw"
     8.7 -VERSION="0.18.1"
     8.8 +VERSION="0.18.7"
     8.9  CATEGORY="graphics"
    8.10 -SHORT_DESC="Raw image decoder library"
    8.11 +SHORT_DESC="RAW image decoder library"
    8.12  MAINTAINER="slaxemulator@gmail.com"
    8.13  LICENSE="LGPL2.1"
    8.14  WEB_SITE="https://www.libraw.org/"
    8.15 +LFS="http://www.linuxfromscratch.org/blfs/view/stable/general/libraw.html"
    8.16  
    8.17  TARBALL="LibRaw-$VERSION.tar.gz"
    8.18  WGET_URL="http://www.libraw.org/data/$TARBALL"
    8.19 @@ -29,7 +30,13 @@
    8.20  
    8.21  genpkg_rules() {
    8.22  	case $PACKAGE in
    8.23 -		libraw) copy @std; DEPENDS="jasper lcms2 libgomp libjpeg-turbo";;
    8.24 -		*-dev)  copy @dev; DEPENDS="libraw jasper-dev lcms2-dev libjpeg-turbo-dev";;
    8.25 +		libraw)
    8.26 +			copy @std
    8.27 +			DEPENDS="jasper lcms2 libgomp libjpeg-turbo"
    8.28 +			;;
    8.29 +		*-dev)
    8.30 +			copy @dev
    8.31 +			DEPENDS="libraw lcms2-dev"
    8.32 +			;;
    8.33  	esac
    8.34  }
     9.1 --- a/shared-mime-info/receipt	Tue May 01 17:41:04 2018 +0300
     9.2 +++ b/shared-mime-info/receipt	Tue May 01 23:19:32 2018 +0300
     9.3 @@ -1,15 +1,16 @@
     9.4  # SliTaz package receipt v2.
     9.5  
     9.6  PACKAGE="shared-mime-info"
     9.7 -VERSION="1.8"
     9.8 +VERSION="1.9"
     9.9  CATEGORY="system-tools"
    9.10  SHORT_DESC="Core database of common types"
    9.11  MAINTAINER="pankso@slitaz.org"
    9.12  LICENSE="GPL2"
    9.13  WEB_SITE="https://freedesktop.org/wiki/Software/shared-mime-info/"
    9.14 +LFS="http://www.linuxfromscratch.org/blfs/view/stable/general/shared-mime-info.html"
    9.15  
    9.16  TARBALL="$PACKAGE-$VERSION.tar.xz"
    9.17 -WGET_URL="http://freedesktop.org/~hadess/$TARBALL"
    9.18 +WGET_URL="https://people.freedesktop.org/~hadess/$TARBALL"
    9.19  
    9.20  BUILD_DEPENDS_arm="glib-dev libxml2-dev"
    9.21  BUILD_DEPENDS="intltool"
    9.22 @@ -24,7 +25,8 @@
    9.23  	./configure \
    9.24  		--disable-update-mimedb \
    9.25  		$CONFIGURE_ARGS &&
    9.26 -	make -j1 && make -j1 DESTDIR=$DESTDIR install
    9.27 +	make -j1 &&
    9.28 +	make -j1 install || return 1
    9.29  
    9.30  	# Additional MIME-types supported by SliTaz
    9.31  	cp $stuff/*.xml $install/usr/share/mime/packages
    10.1 --- a/shared-mime-info/stuff/patches/slitaz-locales.patch	Tue May 01 17:41:04 2018 +0300
    10.2 +++ b/shared-mime-info/stuff/patches/slitaz-locales.patch	Tue May 01 23:19:32 2018 +0300
    10.3 @@ -2,13 +2,13 @@
    10.4  
    10.5  --- a/po/LINGUAS
    10.6  +++ b/po/LINGUAS
    10.7 -@@ -1,73 +1,34 @@
    10.8 +@@ -1,71 +1,32 @@
    10.9   ar
   10.10  -as
   10.11 +-ast
   10.12  -az
   10.13  -be@latin
   10.14  -bg
   10.15 --bg_BG
   10.16  -bn_IN
   10.17   ca
   10.18   ca@valencia
   10.19 @@ -23,10 +23,9 @@
   10.20  -et
   10.21  -eu
   10.22   fa
   10.23 - fa_IR
   10.24   fi
   10.25 +-fo
   10.26   fr
   10.27 --fo
   10.28  -ga
   10.29  -gl
   10.30  -gu
   10.31 @@ -58,7 +57,6 @@
   10.32   pt_BR
   10.33   ro
   10.34   ru
   10.35 - ru_RU
   10.36  -rw
   10.37  -sk
   10.38   sl
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/time/receipt	Tue May 01 23:19:32 2018 +0300
    11.3 @@ -0,0 +1,23 @@
    11.4 +# SliTaz package receipt v2.
    11.5 +
    11.6 +PACKAGE="time"
    11.7 +VERSION="1.8"
    11.8 +CATEGORY="utilities"
    11.9 +SHORT_DESC="Displays information about the resources used by another program"
   11.10 +MAINTAINER="al.bobylev@gmail.com"
   11.11 +LICENSE="GPL3"
   11.12 +WEB_SITE="https://www.gnu.org/software/time/"
   11.13 +LFS="http://www.linuxfromscratch.org/blfs/view/stable/general/time.html"
   11.14 +
   11.15 +TARBALL="$PACKAGE-$VERSION.tar.gz"
   11.16 +WGET_URL="https://ftp.gnu.org/gnu/time/$TARBALL"
   11.17 +
   11.18 +compile_rules() {
   11.19 +	./configure $CONFIGURE_ARGS &&
   11.20 +	make &&
   11.21 +	make install
   11.22 +}
   11.23 +
   11.24 +genpkg_rules() {
   11.25 +	copy @std
   11.26 +}
    12.1 --- a/tree/receipt	Tue May 01 17:41:04 2018 +0300
    12.2 +++ b/tree/receipt	Tue May 01 23:19:32 2018 +0300
    12.3 @@ -1,27 +1,25 @@
    12.4 -# SliTaz package receipt.
    12.5 +# SliTaz package receipt v2.
    12.6  
    12.7  PACKAGE="tree"
    12.8 -VERSION="1.6.0"
    12.9 +VERSION="1.7.0"
   12.10  CATEGORY="utilities"
   12.11  SHORT_DESC="Recursive directory listing program"
   12.12  MAINTAINER="MikeDSmith25@gmail.com"
   12.13  LICENSE="GPL2"
   12.14 +WEB_SITE="http://mama.indstate.edu/users/ice/tree/"
   12.15 +LFS="http://www.linuxfromscratch.org/blfs/view/stable/general/tree.html"
   12.16 +
   12.17  TARBALL="$PACKAGE-$VERSION.tgz"
   12.18 -WEB_SITE="http://mama.indstate.edu/users/ice/tree/"
   12.19 -WGET_URL="ftp://mama.indstate.edu/linux/tree/$TARBALL"
   12.20 +WGET_URL="http://mama.indstate.edu/users/ice/tree/src/$TARBALL"
   12.21  
   12.22 -# Rules to configure and make the package.
   12.23 -compile_rules()
   12.24 -{
   12.25 -	cd $src
   12.26 -	make
   12.27 -	make BINDIR=$DESTDIR/usr/bin MANDIR=$DESTDIR/usr/share/man install
   12.28 +compile_rules() {
   12.29 +	make &&
   12.30 +	make \
   12.31 +		BINDIR=$install/usr/bin \
   12.32 +		MANDIR=$install/usr/share/man/man1 \
   12.33 +		install || return 1
   12.34  }
   12.35  
   12.36 -# Rules to gen a SliTaz package suitable for Tazpkg.
   12.37 -genpkg_rules()
   12.38 -{
   12.39 -	mkdir -p $fs/usr
   12.40 -	cp -a $install/usr/bin $fs/usr
   12.41 +genpkg_rules() {
   12.42 +	copy @std
   12.43  }
   12.44 -
    13.1 --- a/wv/receipt	Tue May 01 17:41:04 2018 +0300
    13.2 +++ b/wv/receipt	Tue May 01 23:19:32 2018 +0300
    13.3 @@ -7,28 +7,30 @@
    13.4  MAINTAINER="pankso@slitaz.org"
    13.5  LICENSE="GPL2"
    13.6  WEB_SITE="http://www.abisource.com/projects/"
    13.7 +LFS="http://www.linuxfromscratch.org/blfs/view/stable/general/wv.html"
    13.8  
    13.9  TARBALL="$PACKAGE-$VERSION.tar.gz"
   13.10  WGET_URL="http://www.abisource.com/downloads/wv/$VERSION/$TARBALL"
   13.11  
   13.12 -BUILD_DEPENDS="libgsf libgsf-dev glib-dev libxml2-dev libpng16-dev"
   13.13 +BUILD_DEPENDS="libgsf-dev glib-dev libxml2-dev libpng16-dev"
   13.14  SPLIT="wv-dev"
   13.15  
   13.16  compile_rules() {
   13.17  	sed -i 's|.ac_install_sh -d|mkdir -p|' configure
   13.18  
   13.19 -	./configure $CONFIGURE_ARGS &&
   13.20 +	./configure \
   13.21 +		--disable-static \
   13.22 +		$CONFIGURE_ARGS &&
   13.23  	fix libtool &&
   13.24  	make &&
   13.25 -	make DESTDIR=$DESTDIR install
   13.26 +	make install
   13.27  }
   13.28  
   13.29  genpkg_rules() {
   13.30  	case $PACKAGE in
   13.31  		wv)
   13.32  			copy @std
   13.33 -			#chmod +x $fs/usr/bin/*
   13.34 -			DEPENDS="glib libgsf libpng16 libxml2 zlib"
   13.35 +			DEPENDS="glib libgsf libxml2 zlib"
   13.36  			;;
   13.37  		*-dev)
   13.38  			copy @dev
    14.1 --- a/xapian/receipt	Tue May 01 17:41:04 2018 +0300
    14.2 +++ b/xapian/receipt	Tue May 01 23:19:32 2018 +0300
    14.3 @@ -1,12 +1,13 @@
    14.4  # SliTaz package receipt v2.
    14.5  
    14.6  PACKAGE="xapian"
    14.7 -VERSION="1.4.4"
    14.8 +VERSION="1.4.5"
    14.9  CATEGORY="utilities"
   14.10  SHORT_DESC="The open source search engine"
   14.11  MAINTAINER="pascal.bellard@slitaz.org"
   14.12  LICENSE="GPL2"
   14.13  WEB_SITE="https://xapian.org/"
   14.14 +LFS="http://www.linuxfromscratch.org/blfs/view/stable/general/xapian.html"
   14.15  
   14.16  TARBALL="xapian-core-$VERSION.tar.xz"
   14.17  WGET_URL="http://oligarchy.co.uk/xapian/$VERSION/$TARBALL"
   14.18 @@ -15,7 +16,9 @@
   14.19  SPLIT="xapian-dev"
   14.20  
   14.21  compile_rules() {
   14.22 -	./configure $CONFIGURE_ARGS &&
   14.23 +	./configure \
   14.24 +		--disable-static \
   14.25 +		$CONFIGURE_ARGS &&
   14.26  	fix libtool &&
   14.27  	make &&
   14.28  	make install
    15.1 --- a/yaml/receipt	Tue May 01 17:41:04 2018 +0300
    15.2 +++ b/yaml/receipt	Tue May 01 23:19:32 2018 +0300
    15.3 @@ -14,7 +14,9 @@
    15.4  SPLIT="yaml-dev"
    15.5  
    15.6  compile_rules() {
    15.7 -	./configure $CONFIGURE_ARGS &&
    15.8 +	./configure \
    15.9 +		--disable-static \
   15.10 +		$CONFIGURE_ARGS &&
   15.11  	fix libtool &&
   15.12  	make &&
   15.13  	make install
    16.1 --- a/yasm/receipt	Tue May 01 17:41:04 2018 +0300
    16.2 +++ b/yasm/receipt	Tue May 01 23:19:32 2018 +0300
    16.3 @@ -18,7 +18,9 @@
    16.4  	# prevent compiling vsyasm and ytasm that are only of use on MS Windows
    16.5  	sed -i 's#) ytasm.*#)#' Makefile.in
    16.6  
    16.7 -	./configure $CONFIGURE_ARGS && make && make install
    16.8 +	./configure $CONFIGURE_ARGS &&
    16.9 +	make &&
   16.10 +	make install
   16.11  }
   16.12  
   16.13  genpkg_rules() {
    17.1 --- a/zip/receipt	Tue May 01 17:41:04 2018 +0300
    17.2 +++ b/zip/receipt	Tue May 01 23:19:32 2018 +0300
    17.3 @@ -7,9 +7,10 @@
    17.4  MAINTAINER="pankso@slitaz.org"
    17.5  LICENSE="other"
    17.6  WEB_SITE="http://www.info-zip.org/"
    17.7 +LFS="http://www.linuxfromscratch.org/blfs/view/stable/general/zip.html"
    17.8  
    17.9 -TARBALL="$PACKAGE${VERSION//./}.tgz"
   17.10 -WGET_URL="ftp://ftp.info-zip.org/pub/infozip/src/$TARBALL"
   17.11 +TARBALL="$PACKAGE${VERSION//./}.tar.gz"
   17.12 +WGET_URL="$SF_MIRROR/infozip/$TARBALL"
   17.13  
   17.14  BUILD_DEPENDS="bzip2-dev"
   17.15