wok-next rev 19776

Up libpng16 for -lpthread (to fix message in gdk-pixbuf's gdk-pixbuf-query-loaders), pygobject, perl-gtk2, perl-gtk2-trayicon, imagemagick, imagemagick6.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Jun 16 03:38:59 2017 +0300 (2017-06-16)
parents 402a4118d0fc
children cf03631202da
files imagemagick/receipt imagemagick6/receipt libpng16/receipt libpng16/stuff/patches/README libpng16/stuff/patches/libpng-1.6.28-apng.patch libpng16/stuff/patches/series perl-gtk2-trayicon/receipt perl-gtk2/receipt pygobject/receipt
line diff
     1.1 --- a/imagemagick/receipt	Fri Jun 16 01:31:57 2017 +0300
     1.2 +++ b/imagemagick/receipt	Fri Jun 16 03:38:59 2017 +0300
     1.3 @@ -13,7 +13,7 @@
     1.4  
     1.5  BUILD_DEPENDS="bzip2-dev xorg-libX11-dev xorg-libICE-dev xorg-libXext-dev \
     1.6  xorg-libXt-dev zlib-dev libtool fftw-dev fontconfig-dev freetype-dev \
     1.7 -libjpeg-turbo-dev lcms2-dev liblzma-dev pango-dev libpng-dev tiff-dev \
     1.8 +libjpeg-turbo-dev lcms2-dev xz-dev pango-dev libpng-dev tiff-dev \
     1.9  libxml2-dev librsvg-dev perl util-linux-uuid-dev"
    1.10  # jasper-dev ilmbase-dev openexr-dev graphviz-dev libgsf-dev
    1.11  SPLIT="imagemagick-dev perl-image-magick"
     2.1 --- a/imagemagick6/receipt	Fri Jun 16 01:31:57 2017 +0300
     2.2 +++ b/imagemagick6/receipt	Fri Jun 16 03:38:59 2017 +0300
     2.3 @@ -13,7 +13,7 @@
     2.4  
     2.5  BUILD_DEPENDS="bzip2-dev xorg-libX11-dev xorg-libICE-dev xorg-libXext-dev \
     2.6  xorg-libXt-dev zlib-dev libtool fftw-dev fontconfig-dev freetype-dev \
     2.7 -libjpeg-turbo-dev lcms2-dev liblzma-dev pango-dev libpng-dev tiff-dev \
     2.8 +libjpeg-turbo-dev lcms2-dev xz-dev pango-dev libpng-dev tiff-dev \
     2.9  libxml2-dev librsvg-dev perl util-linux-uuid-dev"
    2.10  # jasper-dev ilmbase-dev openexr-dev graphviz-dev libgsf-dev
    2.11  SPLIT="imagemagick6-dev"
     3.1 --- a/libpng16/receipt	Fri Jun 16 01:31:57 2017 +0300
     3.2 +++ b/libpng16/receipt	Fri Jun 16 03:38:59 2017 +0300
     3.3 @@ -12,22 +12,21 @@
     3.4  TARBALL="libpng-$VERSION.tar.xz"
     3.5  WGET_URL="$SF_MIRROR/libpng/$TARBALL"
     3.6  
     3.7 -PATCH="libpng-$VERSION-apng.patch.gz"
     3.8 -PATCH_URL="$SF_MIRROR/apng/$PATCH"
     3.9 -
    3.10  BUILD_DEPENDS="gawk zlib-dev"
    3.11  SPLIT="libpng16-dev"
    3.12  
    3.13  # Rules to configure and make the package.
    3.14  compile_rules()
    3.15  {
    3.16 -	[ -s "$SRC/$PATCH" ] || wget -O "$SRC/$PATCH" $PATCH_URL
    3.17 -	gzip -cd $SRC/$PATCH | patch -p0
    3.18 -
    3.19 +	LIBS=-lpthread \
    3.20  	./configure \
    3.21  		--disable-static \
    3.22  		$CONFIGURE_ARGS &&
    3.23 -	make && make install
    3.24 +	make && make install &&
    3.25 +
    3.26 +	docdir=$install/usr/share/doc/libpng-$VERSION &&
    3.27 +	mkdir -p $docdir &&
    3.28 +	cp -v README libpng-manual.txt $docdir
    3.29  
    3.30  	# Misc png tools
    3.31  	cd contrib/pngminus
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/libpng16/stuff/patches/README	Fri Jun 16 03:38:59 2017 +0300
     4.3 @@ -0,0 +1,4 @@
     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 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/libpng16/stuff/patches/libpng-1.6.28-apng.patch	Fri Jun 16 03:38:59 2017 +0300
     5.3 @@ -0,0 +1,1629 @@
     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/series	Fri Jun 16 03:38:59 2017 +0300
     6.3 @@ -0,0 +1,1 @@
     6.4 +libpng-1.6.28-apng.patch
     7.1 --- a/perl-gtk2-trayicon/receipt	Fri Jun 16 01:31:57 2017 +0300
     7.2 +++ b/perl-gtk2-trayicon/receipt	Fri Jun 16 03:38:59 2017 +0300
     7.3 @@ -12,7 +12,8 @@
     7.4  WGET_URL="https://cpan.metacpan.org/authors/id/B/BO/BORUP/$TARBALL"
     7.5  
     7.6  DEPENDS="perl-gtk2"
     7.7 -BUILD_DEPENDS="$DEPENDS perl-extutils-depends perl-extutils-pkgconfig gtk+-dev"
     7.8 +BUILD_DEPENDS="$DEPENDS perl-dev perl-extutils-depends perl-extutils-pkgconfig \
     7.9 +gtk+-dev"
    7.10  
    7.11  # Rules to configure and make the package.
    7.12  compile_rules()
     8.1 --- a/perl-gtk2/receipt	Fri Jun 16 01:31:57 2017 +0300
     8.2 +++ b/perl-gtk2/receipt	Fri Jun 16 03:38:59 2017 +0300
     8.3 @@ -13,7 +13,7 @@
     8.4  
     8.5  DEPENDS="perl-glib perl-pango atk cairo fontconfig freetype gdk-pixbuf glib \
     8.6  gtk+ libgio pango"
     8.7 -BUILD_DEPENDS="perl-glib perl-pango perl-extutils-depends \
     8.8 +BUILD_DEPENDS="perl-dev perl-glib perl-pango perl-extutils-depends \
     8.9  perl-extutils-pkgconfig gtk+-dev"
    8.10  
    8.11  # Rules to configure and make the package.
     9.1 --- a/pygobject/receipt	Fri Jun 16 01:31:57 2017 +0300
     9.2 +++ b/pygobject/receipt	Fri Jun 16 03:38:59 2017 +0300
     9.3 @@ -12,7 +12,7 @@
     9.4  WGET_URL="$GNOME_MIRROR/$PACKAGE/${VERSION%.*}/$TARBALL"
     9.5  
     9.6  BUILD_DEPENDS="python python-dev pkg-config glib-dev libgio-dev pycairo-dev \
     9.7 -cairo-dev libffi-dev"
     9.8 +cairo-dev libffi-dev util-linux-mount-dev"
     9.9  SPLIT="pygobject-dev"
    9.10  
    9.11  # Rules to configure and make the package.