]> git.pld-linux.org Git - packages/crossmingw32-libpng.git/blob - libpng-apng.patch
- updated to 1.2.28
[packages/crossmingw32-libpng.git] / libpng-apng.patch
1 Index: pngread.c
2 ===================================================================
3 --- pngread.c   (révision 149)
4 +++ pngread.c   (copie de travail)
5 @@ -405,6 +405,11 @@
6  #if defined(PNG_READ_zTXt_SUPPORTED)
7        PNG_CONST PNG_zTXt;
8  #endif
9 +#if defined(PNG_READ_APNG_SUPPORTED)
10 +      PNG_CONST PNG_acTL;
11 +      PNG_CONST PNG_fcTL;
12 +      PNG_CONST PNG_fdAT;
13 +#endif
14  #endif /* PNG_USE_LOCAL_ARRAYS */
15        png_byte chunk_length[4];
16        png_uint_32 length;
17 @@ -458,6 +463,9 @@
18                    !(png_ptr->mode & PNG_HAVE_PLTE))
19              png_error(png_ptr, "Missing PLTE before IDAT");
20  
21 +#if defined(PNG_READ_APNG_SUPPORTED)
22 +         png_have_info(png_ptr, info_ptr);
23 +#endif
24           png_ptr->idat_size = length;
25           png_ptr->mode |= PNG_HAVE_IDAT;
26           break;
27 @@ -530,12 +538,97 @@
28        else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4))
29           png_handle_iTXt(png_ptr, info_ptr, length);
30  #endif
31 +#if defined(PNG_READ_APNG_SUPPORTED)
32 +      else if (!png_memcmp(png_ptr->chunk_name, png_acTL, 4))
33 +         png_handle_acTL(png_ptr, info_ptr, length);
34 +      else if (!png_memcmp(png_ptr->chunk_name, png_fcTL, 4))
35 +         png_handle_fcTL(png_ptr, info_ptr, length);
36 +      else if (!png_memcmp(png_ptr->chunk_name, png_fdAT, 4))
37 +         png_handle_fdAT(png_ptr, info_ptr, length);
38 +#endif
39        else
40           png_handle_unknown(png_ptr, info_ptr, length);
41     }
42  }
43  #endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
44  
45 +#if defined(PNG_READ_APNG_SUPPORTED)
46 +void PNGAPI
47 +png_read_frame_head(png_structp png_ptr, png_infop info_ptr)
48 +{
49 +    png_byte have_chunk_after_DAT; /* after IDAT or after fdAT */
50 +    
51 +    png_debug(0, "Reading frame head\n");
52 +    
53 +    if (!(png_ptr->mode & PNG_HAVE_acTL))
54 +        png_error(png_ptr, "attempt to png_read_frame_head() but "
55 +                           "no acTL present");
56 +    
57 +    /* do nothing for the main IDAT */
58 +    if (png_ptr->num_frames_read == 0)
59 +        return;
60 +    
61 +    png_crc_finish(png_ptr, 0); /* CRC from last IDAT or fdAT chunk */
62 +    
63 +    png_read_reset(png_ptr);
64 +    png_ptr->mode &= ~PNG_HAVE_fcTL;
65 +    
66 +    have_chunk_after_DAT = 0;
67 +    for (;;)
68 +    {
69 +#ifdef PNG_USE_LOCAL_ARRAYS
70 +        PNG_IDAT;
71 +        PNG_fdAT;
72 +        PNG_fcTL;
73 +#endif
74 +        png_byte chunk_length[4];
75 +        png_uint_32 length;
76 +        
77 +        png_read_data(png_ptr, chunk_length, 4);
78 +        length = png_get_uint_31(png_ptr, chunk_length);
79 +        
80 +        png_reset_crc(png_ptr);
81 +        png_crc_read(png_ptr, png_ptr->chunk_name, 4);
82 +        
83 +        if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
84 +        {
85 +            /* discard trailing IDATs for the first frame */
86 +            if (have_chunk_after_DAT || png_ptr->num_frames_read > 1)
87 +                png_error(png_ptr, "png_read_frame_head(): out of place IDAT");
88 +            png_crc_finish(png_ptr, length);
89 +        }
90 +        else if (!png_memcmp(png_ptr->chunk_name, png_fcTL, 4))
91 +        {
92 +            png_handle_fcTL(png_ptr, info_ptr, length);
93 +            have_chunk_after_DAT = 1;
94 +        }
95 +        else if (!png_memcmp(png_ptr->chunk_name, png_fdAT, 4))
96 +        {
97 +            png_ensure_sequence_number(png_ptr, length);
98 +            
99 +            /* discard trailing fdATs for frames other than the first */
100 +            if (!have_chunk_after_DAT && png_ptr->num_frames_read > 1)
101 +                png_crc_finish(png_ptr, length - 4);
102 +            else if(png_ptr->mode & PNG_HAVE_fcTL)
103 +            {
104 +                png_ptr->idat_size = length - 4;
105 +                png_ptr->mode |= PNG_HAVE_IDAT;
106 +                
107 +                break;
108 +            }
109 +            else
110 +                png_error(png_ptr, "png_read_frame_head(): out of place fdAT");
111 +        }
112 +        else
113 +        {
114 +            png_warning(png_ptr, "Skipped (ignored) a chunk "
115 +                                 "between APNG chunks");
116 +            png_crc_finish(png_ptr, length);
117 +        }
118 +    }
119 +}
120 +#endif /* PNG_READ_APNG_SUPPORTED */
121 +
122  /* optional call to update the users info_ptr structure */
123  void PNGAPI
124  png_read_update_info(png_structp png_ptr, png_infop info_ptr)
125 @@ -572,6 +665,10 @@
126  {
127  #ifdef PNG_USE_LOCAL_ARRAYS
128     PNG_CONST PNG_IDAT;
129 +#if defined(PNG_READ_APNG_SUPPORTED)
130 +   PNG_CONST PNG_fdAT;
131 +   PNG_CONST PNG_IEND;
132 +#endif
133     PNG_CONST int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55,
134       0xff};
135     PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
136 @@ -701,19 +798,46 @@
137     {
138        if (!(png_ptr->zstream.avail_in))
139        {
140 -         while (!png_ptr->idat_size)
141 +         png_uint_32 bytes_to_skip = 0;
142 +         
143 +         while (!png_ptr->idat_size || bytes_to_skip != 0)
144           {
145              png_byte chunk_length[4];
146  
147 -            png_crc_finish(png_ptr, 0);
148 -
149 +            png_crc_finish(png_ptr, bytes_to_skip);
150 +            bytes_to_skip = 0;
151 +            
152              png_read_data(png_ptr, chunk_length, 4);
153              png_ptr->idat_size = png_get_uint_31(png_ptr,chunk_length);
154 -
155 +            
156              png_reset_crc(png_ptr);
157              png_crc_read(png_ptr, png_ptr->chunk_name, 4);
158 -            if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
159 -               png_error(png_ptr, "Not enough image data");
160 +            
161 +#if defined(PNG_READ_APNG_SUPPORTED)
162 +            if (png_ptr->num_frames_read == 0)
163 +            {
164 +#endif
165 +               if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
166 +                  png_error(png_ptr, "Not enough image data");
167 +#if defined(PNG_READ_APNG_SUPPORTED)
168 +            }
169 +            else
170 +            {
171 +               if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
172 +                  png_error(png_ptr, "Not enough image data");
173 +               if (png_memcmp(png_ptr->chunk_name, png_fdAT, 4))
174 +               {
175 +                  png_warning(png_ptr, "Skipped (ignored) a chunk "
176 +                                       "between APNG chunks");
177 +                  bytes_to_skip = png_ptr->idat_size;
178 +                  continue;
179 +               }
180 +               
181 +               png_ensure_sequence_number(png_ptr, png_ptr->idat_size);
182 +               
183 +               png_ptr->idat_size -= 4;
184 +            }
185 +#endif
186           }
187           png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size;
188           png_ptr->zstream.next_in = png_ptr->zbuf;
189 @@ -731,6 +855,9 @@
190              png_error(png_ptr, "Extra compressed data");
191           png_ptr->mode |= PNG_AFTER_IDAT;
192           png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
193 +#if defined(PNG_READ_APNG_SUPPORTED)
194 +         png_ptr->num_frames_read++;
195 +#endif
196           break;
197        }
198        if (ret != Z_OK)
199 @@ -985,6 +1112,11 @@
200  #if defined(PNG_READ_zTXt_SUPPORTED)
201        PNG_CONST PNG_zTXt;
202  #endif
203 +#if defined(PNG_READ_APNG_SUPPORTED)
204 +      PNG_CONST PNG_acTL;
205 +      PNG_CONST PNG_fcTL;
206 +      PNG_CONST PNG_fdAT;
207 +#endif
208  #endif /* PNG_USE_LOCAL_ARRAYS */
209  
210        png_read_data(png_ptr, chunk_length, 4);
211 @@ -1091,6 +1223,14 @@
212        else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4))
213           png_handle_iTXt(png_ptr, info_ptr, length);
214  #endif
215 +#if defined(PNG_READ_APNG_SUPPORTED)
216 +      else if (!png_memcmp(png_ptr->chunk_name, png_acTL, 4))
217 +         png_handle_acTL(png_ptr, info_ptr, length);
218 +      else if (!png_memcmp(png_ptr->chunk_name, png_fcTL, 4))
219 +         png_handle_fcTL(png_ptr, info_ptr, length);
220 +      else if (!png_memcmp(png_ptr->chunk_name, png_fdAT, 4))
221 +         png_handle_fdAT(png_ptr, info_ptr, length);
222 +#endif
223        else
224           png_handle_unknown(png_ptr, info_ptr, length);
225     } while (!(png_ptr->mode & PNG_HAVE_IEND));
226 Index: pngget.c
227 ===================================================================
228 --- pngget.c    (révision 149)
229 +++ pngget.c    (copie de travail)
230 @@ -797,6 +797,167 @@
231  }
232  #endif
233  
234 +#if defined(PNG_APNG_SUPPORTED)
235 +png_uint_32 PNGAPI
236 +png_get_acTL(png_structp png_ptr, png_infop info_ptr,
237 +             png_uint_32 *num_frames, png_uint_32 *num_plays)
238 +{
239 +    png_debug1(1, "in %s retrieval function\n", "acTL");
240 +    
241 +    if (png_ptr != NULL && info_ptr != NULL &&
242 +        (info_ptr->valid & PNG_INFO_acTL) &&
243 +        num_frames != NULL && num_plays != NULL)
244 +    {
245 +        *num_frames = info_ptr->num_frames;
246 +        *num_plays = info_ptr->num_plays;
247 +        return (1);
248 +    }
249 +    
250 +    return (0);
251 +}
252 +
253 +png_uint_32 PNGAPI
254 +png_get_num_frames(png_structp png_ptr, png_infop info_ptr)
255 +{
256 +    png_debug(1, "in png_get_num_frames()\n");
257 +    
258 +    if (png_ptr != NULL && info_ptr != NULL)
259 +        return (info_ptr->num_frames);
260 +    return (0);
261 +}
262 +
263 +png_uint_32 PNGAPI
264 +png_get_num_plays(png_structp png_ptr, png_infop info_ptr)
265 +{
266 +    png_debug(1, "in png_get_num_plays()\n");
267 +    
268 +    if (png_ptr != NULL && info_ptr != NULL)
269 +        return (info_ptr->num_plays);
270 +    return (0);
271 +}
272 +
273 +png_uint_32 PNGAPI
274 +png_get_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
275 +             png_uint_32 *width, png_uint_32 *height,
276 +             png_uint_32 *x_offset, png_uint_32 *y_offset,
277 +             png_uint_16 *delay_num, png_uint_16 *delay_den,
278 +             png_byte *dispose_op, png_byte *blend_op)
279 +{
280 +    png_debug1(1, "in %s retrieval function\n", "fcTL");
281 +    
282 +    if (png_ptr != NULL && info_ptr != NULL &&
283 +        (info_ptr->valid & PNG_INFO_fcTL) &&
284 +        width != NULL && height != NULL && 
285 +        x_offset != NULL && x_offset != NULL && 
286 +        delay_num != NULL && delay_den != NULL &&
287 +       dispose_op != NULL && blend_op != NULL)
288 +    {
289 +        *width = info_ptr->next_frame_width;
290 +        *height = info_ptr->next_frame_height;
291 +        *x_offset = info_ptr->next_frame_x_offset;
292 +        *y_offset = info_ptr->next_frame_y_offset;
293 +        *delay_num = info_ptr->next_frame_delay_num;
294 +        *delay_den = info_ptr->next_frame_delay_den;
295 +        *dispose_op = info_ptr->next_frame_dispose_op;
296 +        *blend_op = info_ptr->next_frame_blend_op;
297 +        return (1);
298 +    }
299 +    
300 +    return (0);
301 +}
302 +
303 +png_uint_32 PNGAPI
304 +png_get_next_frame_width(png_structp png_ptr, png_infop info_ptr)
305 +{
306 +    png_debug(1, "in png_get_next_frame_width()\n");
307 +    
308 +    if (png_ptr != NULL && info_ptr != NULL)
309 +        return (info_ptr->next_frame_width);
310 +    return (0);
311 +}
312 +
313 +png_uint_32 PNGAPI
314 +png_get_next_frame_height(png_structp png_ptr, png_infop info_ptr)
315 +{
316 +    png_debug(1, "in png_get_next_frame_height()\n");
317 +    
318 +    if (png_ptr != NULL && info_ptr != NULL)
319 +        return (info_ptr->next_frame_height);
320 +    return (0);
321 +}
322 +
323 +png_uint_32 PNGAPI
324 +png_get_next_frame_x_offset(png_structp png_ptr, png_infop info_ptr)
325 +{
326 +    png_debug(1, "in png_get_next_frame_x_offset()\n");
327 +    
328 +    if (png_ptr != NULL && info_ptr != NULL)
329 +        return (info_ptr->next_frame_x_offset);
330 +    return (0);
331 +}
332 +
333 +png_uint_32 PNGAPI
334 +png_get_next_frame_y_offset(png_structp png_ptr, png_infop info_ptr)
335 +{
336 +    png_debug(1, "in png_get_next_frame_y_offset()\n");
337 +    
338 +    if (png_ptr != NULL && info_ptr != NULL)
339 +        return (info_ptr->next_frame_y_offset);
340 +    return (0);
341 +}
342 +
343 +png_uint_16 PNGAPI
344 +png_get_next_frame_delay_num(png_structp png_ptr, png_infop info_ptr)
345 +{
346 +    png_debug(1, "in png_get_next_frame_delay_num()\n");
347 +    
348 +    if (png_ptr != NULL && info_ptr != NULL)
349 +        return (info_ptr->next_frame_delay_num);
350 +    return (0);
351 +}
352 +
353 +png_uint_16 PNGAPI
354 +png_get_next_frame_delay_den(png_structp png_ptr, png_infop info_ptr)
355 +{
356 +    png_debug(1, "in png_get_next_frame_delay_den()\n");
357 +    
358 +    if (png_ptr != NULL && info_ptr != NULL)
359 +        return (info_ptr->next_frame_delay_den);
360 +    return (0);
361 +}
362 +
363 +png_byte PNGAPI
364 +png_get_next_frame_dispose_op(png_structp png_ptr, png_infop info_ptr)
365 +{
366 +    png_debug(1, "in png_get_next_frame_dispose_op()\n");
367 +    
368 +    if (png_ptr != NULL && info_ptr != NULL)
369 +        return (info_ptr->next_frame_dispose_op);
370 +    return (0);
371 +}
372 +
373 +png_byte PNGAPI
374 +png_get_next_frame_blend_op(png_structp png_ptr, png_infop info_ptr)
375 +{
376 +    png_debug(1, "in png_get_next_frame_blend_op()\n");
377 +    
378 +    if (png_ptr != NULL && info_ptr != NULL)
379 +        return (info_ptr->next_frame_blend_op);
380 +    return (0);
381 +}
382 +
383 +png_byte PNGAPI
384 +png_get_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr)
385 +{
386 +    png_debug(1, "in png_first_frame_is_hidden()\n");
387 +    
388 +    if (png_ptr != NULL)
389 +       return (png_byte)(png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN);
390 +    
391 +    return 0;
392 +}
393 +#endif /* PNG_APNG_SUPPORTED */
394 +
395  #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
396  png_uint_32 PNGAPI
397  png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
398 Index: png.c
399 ===================================================================
400 --- png.c       (révision 149)
401 +++ png.c       (copie de travail)
402 @@ -51,6 +51,9 @@
403  PNG_tIME;
404  PNG_tRNS;
405  PNG_zTXt;
406 +PNG_acTL;
407 +PNG_fcTL;
408 +PNG_fdAT;
409  
410  #ifdef PNG_READ_SUPPORTED
411  /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
412 Index: png.h
413 ===================================================================
414 --- png.h       (révision 149)
415 +++ png.h       (copie de travail)
416 @@ -949,6 +949,19 @@
417     png_fixed_point int_y_blue;
418  #endif
419  
420 +#if defined(PNG_APNG_SUPPORTED)
421 +   png_uint_32 num_frames; /* including default image */
422 +   png_uint_32 num_plays;
423 +   png_uint_32 next_frame_width;
424 +   png_uint_32 next_frame_height;
425 +   png_uint_32 next_frame_x_offset;
426 +   png_uint_32 next_frame_y_offset;
427 +   png_uint_16 next_frame_delay_num;
428 +   png_uint_16 next_frame_delay_den;
429 +   png_byte next_frame_dispose_op;
430 +   png_byte next_frame_blend_op;
431 +#endif
432 +
433  } png_info;
434  
435  typedef png_info FAR * png_infop;
436 @@ -1050,6 +1063,8 @@
437  #define PNG_INFO_sPLT 0x2000   /* ESR, 1.0.6 */
438  #define PNG_INFO_sCAL 0x4000   /* ESR, 1.0.6 */
439  #define PNG_INFO_IDAT 0x8000L  /* ESR, 1.0.6 */
440 +#define PNG_INFO_acTL 0x10000L
441 +#define PNG_INFO_fcTL 0x20000L
442  
443  /* This is used for the transformation routines, as some of them
444   * change these values for the row.  It also should enable using
445 @@ -1090,7 +1105,11 @@
446  typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop));
447  typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep,
448     png_uint_32, int));
449 +#if defined(PNG_APNG_SUPPORTED)
450 +typedef void (PNGAPI *png_progressive_frame_ptr) PNGARG((png_structp, 
451 +   png_uint_32));
452  #endif
453 +#endif
454  
455  #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
456      defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
457 @@ -1421,6 +1440,39 @@
458     png_uint_32 user_height_max;
459  #endif
460  
461 +#if defined(PNG_APNG_SUPPORTED)
462 +   png_uint_32 apng_flags;
463 +   png_uint_32 next_seq_num;         /* next fcTL/fdAT chunk sequence number */
464 +   png_uint_32 first_frame_width;
465 +   png_uint_32 first_frame_height;
466 +
467 +#if defined(PNG_READ_APNG_SUPPORTED)
468 +   png_uint_32 num_frames_read;      /* incremented after all image data of */
469 +                                     /* a frame is read */
470 +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
471 +   png_progressive_frame_ptr frame_info_fn; /* frame info read callback */
472 +   png_progressive_frame_ptr frame_end_fn;  /* frame data read callback */
473 +#endif
474 +#endif
475 +
476 +#if defined(PNG_WRITE_APNG_SUPPORTED)
477 +   png_uint_32 num_frames_to_write;
478 +   png_uint_32 num_frames_written;
479 +#endif
480 +#endif
481 +
482 +/* For png_struct.apng_flags: */
483 +#define PNG_FIRST_FRAME_HIDDEN       0x0001
484 +
485 +/* dispose_op flags from inside fcTL */
486 +#define PNG_DISPOSE_OP_NONE        0x00
487 +#define PNG_DISPOSE_OP_BACKGROUND  0x01
488 +#define PNG_DISPOSE_OP_PREVIOUS    0x02
489 +
490 +/* blend_op flags from inside fcTL */
491 +#define PNG_BLEND_OP_SOURCE        0x00
492 +#define PNG_BLEND_OP_OVER          0x01
493 +
494  /* New member added in libpng-1.0.25 and 1.2.17 */
495  #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
496     /* storage for unknown chunk that the library doesn't recognize. */
497 @@ -1747,6 +1799,18 @@
498  extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr,
499     png_bytepp image));
500  
501 +#if defined(PNG_WRITE_APNG_SUPPORTED)
502 +extern PNG_EXPORT (void,png_write_frame_head) PNGARG((png_structp png_ptr,
503 +   png_infop png_info, png_bytepp row_pointers,
504 +   png_uint_32 width, png_uint_32 height,
505 +   png_uint_32 x_offset, png_uint_32 y_offset, 
506 +   png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
507 +   png_byte blend_op));
508 +
509 +extern PNG_EXPORT (void,png_write_frame_tail) PNGARG((png_structp png_ptr,
510 +   png_infop png_info));
511 +#endif
512 +   
513  /* writes the end of the PNG file. */
514  extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr,
515     png_infop info_ptr));
516 @@ -1995,6 +2059,11 @@
517     png_voidp progressive_ptr,
518     png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
519     png_progressive_end_ptr end_fn));
520 +#if defined(PNG_READ_APNG_SUPPORTED)
521 +extern PNG_EXPORT(void,png_set_progressive_frame_fn) PNGARG((png_structp png_ptr,
522 +   png_progressive_frame_ptr frame_info_fn,
523 +   png_progressive_frame_ptr frame_end_fn));
524 +#endif
525  
526  /* returns the user pointer associated with the push read functions */
527  extern PNG_EXPORT(png_voidp,png_get_progressive_ptr)
528 @@ -2432,6 +2501,59 @@
529  #endif
530  #endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */
531  
532 +#if defined(PNG_APNG_SUPPORTED)
533 +extern PNG_EXPORT(png_uint_32,png_get_acTL) PNGARG((png_structp png_ptr,
534 +   png_infop info_ptr, png_uint_32 *num_frames, png_uint_32 *num_plays));
535 +extern PNG_EXPORT(png_uint_32,png_set_acTL) PNGARG((png_structp png_ptr, 
536 +   png_infop info_ptr, png_uint_32 num_frames, png_uint_32 num_plays));
537 +extern PNG_EXPORT(png_uint_32,png_get_num_frames) PNGARG((png_structp png_ptr,
538 +   png_infop info_ptr));
539 +extern PNG_EXPORT(png_uint_32,png_get_num_plays) 
540 +   PNGARG((png_structp png_ptr, png_infop info_ptr));
541 +
542 +extern PNG_EXPORT(png_uint_32,png_get_next_frame_fcTL) 
543 +   PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 *width, 
544 +   png_uint_32 *height, png_uint_32 *x_offset, png_uint_32 *y_offset, 
545 +   png_uint_16 *delay_num, png_uint_16 *delay_den, png_byte *dispose_op,
546 +   png_byte *blend_op));
547 +extern PNG_EXPORT(png_uint_32,png_set_next_frame_fcTL) 
548 +   PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 width, 
549 +   png_uint_32 height, png_uint_32 x_offset, png_uint_32 y_offset, 
550 +   png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
551 +   png_byte blend_op));
552 +extern PNG_EXPORT(void,png_ensure_fcTL_is_valid)
553 +   PNGARG((png_structp png_ptr,
554 +   png_uint_32 width, png_uint_32 height,
555 +   png_uint_32 x_offset, png_uint_32 y_offset,
556 +   png_uint_16 delay_num, png_uint_16 delay_den,
557 +   png_byte dispose_op, png_byte blend_op));
558 +extern PNG_EXPORT(png_uint_32,png_get_next_frame_width)
559 +   PNGARG((png_structp png_ptr, png_infop info_ptr));
560 +extern PNG_EXPORT(png_uint_32,png_get_next_frame_height)
561 +   PNGARG((png_structp png_ptr, png_infop info_ptr));
562 +extern PNG_EXPORT(png_uint_32,png_get_next_frame_x_offset)
563 +   PNGARG((png_structp png_ptr, png_infop info_ptr));
564 +extern PNG_EXPORT(png_uint_32,png_get_next_frame_y_offset)
565 +   PNGARG((png_structp png_ptr, png_infop info_ptr));
566 +extern PNG_EXPORT(png_uint_16,png_get_next_frame_delay_num)
567 +   PNGARG((png_structp png_ptr, png_infop info_ptr));
568 +extern PNG_EXPORT(png_uint_16,png_get_next_frame_delay_den)
569 +   PNGARG((png_structp png_ptr, png_infop info_ptr));
570 +extern PNG_EXPORT(png_byte,png_get_next_frame_dispose_op)
571 +   PNGARG((png_structp png_ptr, png_infop info_ptr));
572 +extern PNG_EXPORT(png_byte,png_get_next_frame_blend_op)
573 +   PNGARG((png_structp png_ptr, png_infop info_ptr));
574 +extern PNG_EXPORT(png_byte,png_get_first_frame_is_hidden)
575 +   PNGARG((png_structp png_ptr, png_infop info_ptr));
576 +extern PNG_EXPORT(png_uint_32,png_set_first_frame_is_hidden)
577 +   PNGARG((png_structp png_ptr, png_infop info_ptr, png_byte is_hidden));
578 +#endif /* PNG_APNG_SUPPORTED */
579 +
580 +#if defined(PNG_READ_APNG_SUPPORTED)
581 +extern PNG_EXPORT(void,png_read_frame_head) PNGARG((png_structp png_ptr,
582 +   png_infop info_ptr));
583 +#endif
584 +
585  #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
586  /* provide a list of chunks and how they are to be handled, if the built-in
587     handling or default unknown chunk handling is not desired.  Any chunks not
588 @@ -2738,6 +2860,8 @@
589  #define PNG_BACKGROUND_IS_GRAY     0x800
590  #define PNG_HAVE_PNG_SIGNATURE    0x1000
591  #define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */
592 +#define PNG_HAVE_acTL             0x4000
593 +#define PNG_HAVE_fcTL             0x8000L
594  
595  /* flags for the transformations the PNG library does on the image data */
596  #define PNG_BGR                0x0001
597 @@ -2878,6 +3002,9 @@
598  #define PNG_tIME png_byte png_tIME[5] = {116,  73,  77,  69, '\0'}
599  #define PNG_tRNS png_byte png_tRNS[5] = {116,  82,  78,  83, '\0'}
600  #define PNG_zTXt png_byte png_zTXt[5] = {122,  84,  88, 116, '\0'}
601 +#define PNG_acTL png_byte png_acTL[5] = { 97,  99,  84,  76, '\0'}
602 +#define PNG_fcTL png_byte png_fcTL[5] = {102,  99,  84,  76, '\0'}
603 +#define PNG_fdAT png_byte png_fdAT[5] = {102, 100,  65,  84, '\0'}
604  
605  #ifdef PNG_USE_GLOBAL_ARRAYS
606  PNG_EXPORT_VAR (png_byte FARDATA) png_IHDR[5];
607 @@ -2901,6 +3028,9 @@
608  PNG_EXPORT_VAR (png_byte FARDATA) png_tIME[5];
609  PNG_EXPORT_VAR (png_byte FARDATA) png_tRNS[5];
610  PNG_EXPORT_VAR (png_byte FARDATA) png_zTXt[5];
611 +PNG_EXPORT_VAR (png_byte FARDATA) png_acTL[5];
612 +PNG_EXPORT_VAR (png_byte FARDATA) png_fcTL[5];
613 +PNG_EXPORT_VAR (png_byte FARDATA) png_fdAT[5];
614  #endif /* PNG_USE_GLOBAL_ARRAYS */
615  
616  #if defined(PNG_1_0_X) || defined (PNG_1_2_X)
617 @@ -3175,6 +3305,17 @@
618  #endif
619  #endif
620  
621 +#if defined(PNG_WRITE_APNG_SUPPORTED)
622 +PNG_EXTERN void png_write_acTL PNGARG((png_structp png_ptr,
623 +   png_uint_32 num_frames, png_uint_32 num_plays));
624 +
625 +PNG_EXTERN void png_write_fcTL PNGARG((png_structp png_ptr, 
626 +   png_uint_32 width, png_uint_32 height, 
627 +   png_uint_32 x_offset, png_uint_32 y_offset, 
628 +   png_uint_16 delay_num, png_uint_16 delay_den,
629 +   png_byte dispose_op, png_byte blend_op));
630 +#endif
631 +
632  /* Called when finished processing a row of data */
633  PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr));
634  
635 @@ -3226,6 +3367,20 @@
636  PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr,
637     png_infop info_ptr));
638  
639 +#if defined(PNG_READ_APNG_SUPPORTED)
640 +/* private, reset some things to become ready for reading next frame */
641 +PNG_EXTERN void png_read_reset PNGARG((png_structp png_ptr));
642 +PNG_EXTERN void png_read_reinit PNGARG((png_structp png_ptr,
643 +   png_infop info_ptr));
644 +PNG_EXTERN void png_progressive_read_reset PNGARG((png_structp png_ptr));
645 +#endif
646 +#if defined(PNG_WRITE_APNG_SUPPORTED)
647 +/* private, reset some things to become ready for writing next frame */
648 +PNG_EXTERN void png_write_reset PNGARG((png_structp png_ptr));
649 +PNG_EXTERN void png_write_reinit PNGARG((png_structp png_ptr, 
650 +   png_infop info_ptr, png_uint_32 width, png_uint_32 height));
651 +#endif
652 +
653  /* these are the functions that do the transformations */
654  #if defined(PNG_READ_FILLER_SUPPORTED)
655  PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info,
656 @@ -3441,6 +3596,18 @@
657     png_uint_32 length));
658  #endif
659  
660 +#if defined(PNG_READ_APNG_SUPPORTED)
661 +PNG_EXTERN void png_handle_acTL PNGARG((png_structp png_ptr, png_infop info_ptr,
662 +   png_uint_32 length));
663 +PNG_EXTERN void png_handle_fcTL PNGARG((png_structp png_ptr, png_infop info_ptr,
664 +   png_uint_32 length));
665 +PNG_EXTERN void png_have_info PNGARG((png_structp png_ptr, png_infop info_ptr));
666 +PNG_EXTERN void png_handle_fdAT PNGARG((png_structp png_ptr, png_infop info_ptr,
667 +   png_uint_32 length));
668 +PNG_EXTERN void png_ensure_sequence_number PNGARG((png_structp png_ptr, 
669 +   png_uint_32 length));
670 +#endif
671 +
672  PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr,
673     png_infop info_ptr, png_uint_32 length));
674  
675 Index: pngtrans.c
676 ===================================================================
677 --- pngtrans.c  (révision 149)
678 +++ pngtrans.c  (copie de travail)
679 @@ -652,11 +652,10 @@
680  png_voidp PNGAPI
681  png_get_user_transform_ptr(png_structp png_ptr)
682  {
683 -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
684     if (png_ptr == NULL) return (NULL);
685 +#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
686     return ((png_voidp)png_ptr->user_transform_ptr);
687 -#else
688 -   return (NULL);
689  #endif
690 +   return (NULL);
691  }
692  #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
693 Index: pngwrite.c
694 ===================================================================
695 --- pngwrite.c  (révision 149)
696 +++ pngwrite.c  (copie de travail)
697 @@ -261,6 +261,10 @@
698        }
699     }
700  #endif
701 +#if defined(PNG_WRITE_APNG_SUPPORTED)
702 +   if (info_ptr->valid & PNG_INFO_acTL)
703 +      png_write_acTL(png_ptr, info_ptr->num_frames, info_ptr->num_plays);
704 +#endif
705  #if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED)
706     if (info_ptr->unknown_chunks_num)
707     {
708 @@ -299,6 +303,10 @@
709        return;
710     if (!(png_ptr->mode & PNG_HAVE_IDAT))
711        png_error(png_ptr, "No IDATs written into file");
712 +#if defined(PNG_WRITE_APNG_SUPPORTED)
713 +   if (png_ptr->num_frames_written != png_ptr->num_frames_to_write)
714 +      png_error(png_ptr, "Not enough frames written");
715 +#endif
716  
717     /* see if user wants us to write information chunks */
718     if (info_ptr != NULL)
719 @@ -1527,4 +1535,39 @@
720     params = params;
721  }
722  #endif
723 +
724 +#if defined(PNG_WRITE_APNG_SUPPORTED)
725 +void PNGAPI
726 +png_write_frame_head(png_structp png_ptr, png_infop info_ptr,
727 +    png_bytepp row_pointers, png_uint_32 width, png_uint_32 height, 
728 +    png_uint_32 x_offset, png_uint_32 y_offset, 
729 +    png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
730 +    png_byte blend_op)
731 +{
732 +    png_debug(1, "in png_write_frame_head\n");
733 +    
734 +    /* there is a chance this has been set after png_write_info was called,
735 +    * so it would be set but not written. is there a way to be sure? */
736 +    if (!(info_ptr->valid & PNG_INFO_acTL))
737 +        png_error(png_ptr, "png_write_frame_head(): acTL not set");
738 +    
739 +    png_write_reset(png_ptr);
740 +    
741 +    png_write_reinit(png_ptr, info_ptr, width, height);
742 +    
743 +    if ( !(png_ptr->num_frames_written == 0 && 
744 +           (png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN) ) )
745 +        png_write_fcTL(png_ptr, width, height, x_offset, y_offset, 
746 +                       delay_num, delay_den, dispose_op, blend_op);
747 +}
748 +
749 +void PNGAPI
750 +png_write_frame_tail(png_structp png_ptr, png_infop png_info)
751 +{
752 +    png_debug(1, "in png_write_frame_tail\n");
753 +    
754 +    png_ptr->num_frames_written++;
755 +}
756 +#endif /* PNG_WRITE_APNG_SUPPORTED */
757 +
758  #endif /* PNG_WRITE_SUPPORTED */
759 Index: pngconf.h
760 ===================================================================
761 --- pngconf.h   (révision 149)
762 +++ pngconf.h   (copie de travail)
763 @@ -925,6 +925,10 @@
764  #  define PNG_READ_zTXt_SUPPORTED
765  #  define PNG_zTXt_SUPPORTED
766  #endif
767 +#ifndef PNG_NO_READ_APNG
768 +#  define PNG_READ_APNG_SUPPORTED
769 +#  define PNG_APNG_SUPPORTED
770 +#endif
771  #ifndef PNG_NO_READ_UNKNOWN_CHUNKS
772  #  define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
773  #  ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
774 @@ -1067,6 +1071,12 @@
775  #    define PNG_zTXt_SUPPORTED
776  #  endif
777  #endif
778 +#ifndef PNG_NO_WRITE_APNG
779 +#  define PNG_WRITE_APNG_SUPPORTED
780 +#  ifndef PNG_APNG_SUPPORTED
781 +#    define PNG_APNG_SUPPORTED
782 +#  endif
783 +#endif
784  #ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS
785  #  define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
786  #  ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
787 Index: pngpread.c
788 ===================================================================
789 --- pngpread.c  (révision 149)
790 +++ pngpread.c  (copie de travail)
791 @@ -192,6 +192,11 @@
792  #if defined(PNG_READ_zTXt_SUPPORTED)
793        PNG_CONST PNG_zTXt;
794  #endif
795 +#if defined(PNG_READ_APNG_SUPPORTED)
796 +      PNG_CONST PNG_acTL;
797 +      PNG_CONST PNG_fcTL;
798 +      PNG_CONST PNG_fdAT;
799 +#endif
800  #endif /* PNG_USE_LOCAL_ARRAYS */
801     /* First we make sure we have enough data for the 4 byte chunk name
802      * and the 4 byte chunk length before proceeding with decoding the
803 @@ -215,7 +220,104 @@
804        png_crc_read(png_ptr, png_ptr->chunk_name, 4);
805        png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
806     }
807 -
808 +   
809 +#if defined(PNG_READ_APNG_SUPPORTED)
810 +   if (png_ptr->num_frames_read > 0 && 
811 +       png_ptr->num_frames_read < info_ptr->num_frames)
812 +   {
813 +      if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
814 +      {
815 +         /* discard trailing IDATs for the first frame */
816 +         if (png_ptr->mode & PNG_HAVE_fcTL || png_ptr->num_frames_read > 1)
817 +            png_error(png_ptr, "out of place IDAT");
818 +         
819 +         if (png_ptr->push_length + 4 > png_ptr->buffer_size)
820 +         {
821 +            png_push_save_buffer(png_ptr);
822 +            return;
823 +         }
824 +         png_push_crc_skip(png_ptr, png_ptr->push_length);
825 +         png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
826 +         return;
827 +      }
828 +      else if (!png_memcmp(png_ptr->chunk_name, png_fdAT, 4))
829 +      {
830 +         if (png_ptr->buffer_size < 4)
831 +         {
832 +            png_push_save_buffer(png_ptr);
833 +            return;
834 +         }
835 +         png_ensure_sequence_number(png_ptr, 4);
836 +         
837 +         if (!(png_ptr->mode & PNG_HAVE_fcTL))
838 +         {
839 +            /* discard trailing fdATs for frames other than the first */
840 +            if (png_ptr->num_frames_read < 2)
841 +               png_error(png_ptr, "out of place fdAT");
842 +            
843 +            if (png_ptr->push_length + 4 > png_ptr->buffer_size)
844 +            {
845 +               png_push_save_buffer(png_ptr);
846 +               return;
847 +            }
848 +            png_push_crc_skip(png_ptr, png_ptr->push_length);
849 +            png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
850 +            return;
851 +         }
852 +         else
853 +         {
854 +            /* frame data follows */
855 +            png_ptr->idat_size = png_ptr->push_length - 4;
856 +            png_ptr->mode |= PNG_HAVE_IDAT;
857 +            png_ptr->process_mode = PNG_READ_IDAT_MODE;
858 +            
859 +            return;
860 +         }
861 +      }
862 +      else if(!png_memcmp(png_ptr->chunk_name, png_fcTL, 4))
863 +      {
864 +         if (png_ptr->push_length + 4 > png_ptr->buffer_size)
865 +         {
866 +            png_push_save_buffer(png_ptr);
867 +            return;
868 +         }
869 +         
870 +         png_read_reset(png_ptr);
871 +         png_ptr->mode &= ~PNG_HAVE_fcTL;
872 +         
873 +         png_handle_fcTL(png_ptr, info_ptr, png_ptr->push_length);
874 +         
875 +         if (!(png_ptr->mode & PNG_HAVE_fcTL))
876 +            png_error(png_ptr, "missing required fcTL chunk");
877 +         
878 +         png_read_reinit(png_ptr, info_ptr);
879 +         png_progressive_read_reset(png_ptr);
880 +         
881 +         if (png_ptr->frame_info_fn != NULL)
882 +            (*(png_ptr->frame_info_fn))(png_ptr, png_ptr->num_frames_read);
883 +         
884 +         png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
885 +         
886 +         return;
887 +      }
888 +      else
889 +      {
890 +         if (png_ptr->push_length + 4 > png_ptr->buffer_size)
891 +         {
892 +            png_push_save_buffer(png_ptr);
893 +            return;
894 +         }
895 +         png_warning(png_ptr, "Skipped (ignored) a chunk "
896 +                              "between APNG chunks");
897 +         png_push_crc_skip(png_ptr, png_ptr->push_length);
898 +         png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
899 +         return;
900 +      }
901 +      
902 +      return;
903 +   }
904 +#endif /* PNG_READ_APNG_SUPPORTED */
905 +   
906     if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
907       if(png_ptr->mode & PNG_AFTER_IDAT)
908          png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
909 @@ -295,6 +397,9 @@
910              png_error(png_ptr, "Too many IDAT's found");
911        }
912  
913 +#if defined(PNG_READ_APNG_SUPPORTED)
914 +      png_have_info(png_ptr, info_ptr);
915 +#endif
916        png_ptr->idat_size = png_ptr->push_length;
917        png_ptr->mode |= PNG_HAVE_IDAT;
918        png_ptr->process_mode = PNG_READ_IDAT_MODE;
919 @@ -490,6 +595,35 @@
920        png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
921     }
922  #endif
923 +#if defined(PNG_READ_APNG_SUPPORTED)
924 +   else if (!png_memcmp(png_ptr->chunk_name, png_acTL, 4))
925 +   {
926 +      if (png_ptr->push_length + 4 > png_ptr->buffer_size)
927 +      {
928 +         png_push_save_buffer(png_ptr);
929 +         return;
930 +      }
931 +      png_handle_acTL(png_ptr, info_ptr, png_ptr->push_length);
932 +   }
933 +   else if (!png_memcmp(png_ptr->chunk_name, png_fcTL, 4))
934 +   {
935 +      if (png_ptr->push_length + 4 > png_ptr->buffer_size)
936 +      {
937 +         png_push_save_buffer(png_ptr);
938 +         return;
939 +      }
940 +      png_handle_fcTL(png_ptr, info_ptr, png_ptr->push_length);
941 +   }
942 +   else if (!png_memcmp(png_ptr->chunk_name, png_fdAT, 4))
943 +   {
944 +      if (png_ptr->push_length + 4 > png_ptr->buffer_size)
945 +      {
946 +         png_push_save_buffer(png_ptr);
947 +         return;
948 +      }
949 +      png_handle_fdAT(png_ptr, info_ptr, png_ptr->push_length);
950 +   }
951 +#endif /* PNG_READ_APNG_SUPPORTED */
952     else
953     {
954        if (png_ptr->push_length + 4 > png_ptr->buffer_size)
955 @@ -660,13 +794,17 @@
956  png_push_read_IDAT(png_structp png_ptr)
957  {
958  #ifdef PNG_USE_LOCAL_ARRAYS
959 -   PNG_CONST PNG_IDAT;
960 +   PNG_IDAT;
961 +#if defined(PNG_READ_APNG_SUPPORTED)
962 +   PNG_fdAT;
963 +   PNG_IEND;
964  #endif
965 +#endif
966     if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
967     {
968        png_byte chunk_length[4];
969  
970 -      if (png_ptr->buffer_size < 8)
971 +      if (png_ptr->buffer_size < 12)
972        {
973           png_push_save_buffer(png_ptr);
974           return;
975 @@ -678,15 +816,59 @@
976        png_crc_read(png_ptr, png_ptr->chunk_name, 4);
977        png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
978  
979 -      if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
980 +#if defined(PNG_READ_APNG_SUPPORTED)
981 +      if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_fdAT, 4)
982 +          && png_ptr->num_frames_read > 0)
983        {
984 +          if (png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)
985 +          {
986 +              png_ptr->process_mode = PNG_READ_CHUNK_MODE;
987 +              if (png_ptr->frame_end_fn != NULL)
988 +                 (*(png_ptr->frame_end_fn))(png_ptr, png_ptr->num_frames_read);
989 +              png_ptr->num_frames_read++;
990 +              return;
991 +          }
992 +          else
993 +          {
994 +              if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
995 +                  png_error(png_ptr, "Not enough image data");
996 +              if (png_ptr->push_length + 4 > png_ptr->buffer_size)
997 +              {
998 +                 png_push_save_buffer(png_ptr);
999 +                 return;
1000 +              }
1001 +              png_warning(png_ptr, "Skipping (ignoring) a chunk between "
1002 +                                   "APNG chunks");
1003 +              png_crc_finish(png_ptr, png_ptr->push_length);
1004 +              png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
1005 +              return;
1006 +          }
1007 +      }
1008 +      else 
1009 +#endif
1010 +      if ( png_memcmp(png_ptr->chunk_name, png_IDAT, 4)
1011 +                && (png_ptr->num_frames_read == 0) )
1012 +      {
1013           png_ptr->process_mode = PNG_READ_CHUNK_MODE;
1014           if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
1015              png_error(png_ptr, "Not enough compressed data");
1016 +#if defined(PNG_READ_APNG_SUPPORTED)
1017 +         if (png_ptr->frame_end_fn != NULL)
1018 +            (*(png_ptr->frame_end_fn))(png_ptr, png_ptr->num_frames_read);
1019 +         png_ptr->num_frames_read++;
1020 +#endif
1021           return;
1022        }
1023  
1024        png_ptr->idat_size = png_ptr->push_length;
1025 +      
1026 +#if defined(PNG_READ_APNG_SUPPORTED)
1027 +      if(png_ptr->num_frames_read > 0)
1028 +      {
1029 +         png_ensure_sequence_number(png_ptr, 4);
1030 +         png_ptr->idat_size -= 4;
1031 +      }
1032 +#endif
1033     }
1034     if (png_ptr->idat_size && png_ptr->save_buffer_size)
1035     {
1036 @@ -1582,6 +1764,17 @@
1037     png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer);
1038  }
1039  
1040 +#if defined(PNG_READ_APNG_SUPPORTED)
1041 +void PNGAPI
1042 +png_set_progressive_frame_fn(png_structp png_ptr,
1043 +   png_progressive_frame_ptr frame_info_fn,
1044 +   png_progressive_frame_ptr frame_end_fn)
1045 +{
1046 +   png_ptr->frame_info_fn = frame_info_fn;
1047 +   png_ptr->frame_end_fn = frame_end_fn;
1048 +}
1049 +#endif
1050 +
1051  png_voidp PNGAPI
1052  png_get_progressive_ptr(png_structp png_ptr)
1053  {
1054 Index: pngset.c
1055 ===================================================================
1056 --- pngset.c    (révision 149)
1057 +++ pngset.c    (copie de travail)
1058 @@ -364,6 +364,11 @@
1059        info_ptr->rowbytes = (png_size_t)0;
1060     else
1061        info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,width);
1062 +   
1063 +#if defined(PNG_APNG_SUPPORTED)
1064 +   /* for non-animated png. this may be overritten from an acTL chunk later */
1065 +   info_ptr->num_frames = 1;
1066 +#endif
1067  }
1068  
1069  #if defined(PNG_oFFs_SUPPORTED)
1070 @@ -1012,6 +1017,141 @@
1071  }
1072  #endif /* PNG_sPLT_SUPPORTED */
1073  
1074 +#if defined(PNG_APNG_SUPPORTED)
1075 +png_uint_32 PNGAPI
1076 +png_set_acTL(png_structp png_ptr, png_infop info_ptr, 
1077 +    png_uint_32 num_frames, png_uint_32 num_plays)
1078 +{
1079 +    png_debug1(1, "in %s storage function\n", "acTL");
1080 +
1081 +    if (png_ptr == NULL || info_ptr == NULL)
1082 +    {
1083 +        png_warning(png_ptr, 
1084 +                    "Call to png_set_acTL() with NULL png_ptr "
1085 +                    "or info_ptr ignored");
1086 +        return (0);
1087 +    }
1088 +    if (num_frames == 0)
1089 +    {
1090 +        png_warning(png_ptr, 
1091 +                    "Ignoring attempt to set acTL with num_frames zero");
1092 +        return (0);
1093 +    }
1094 +    if (num_frames > PNG_UINT_31_MAX)
1095 +    {
1096 +        png_warning(png_ptr, 
1097 +                    "Ignoring attempt to set acTL with num_frames > 2^31-1");
1098 +        return (0);
1099 +    }
1100 +    if (num_plays > PNG_UINT_31_MAX)
1101 +    {
1102 +        png_warning(png_ptr, 
1103 +                    "Ignoring attempt to set acTL with num_plays "
1104 +                    "> 2^31-1");
1105 +        return (0);
1106 +    }
1107 +    
1108 +    info_ptr->num_frames = num_frames;
1109 +    info_ptr->num_plays = num_plays;
1110 +    
1111 +    info_ptr->valid |= PNG_INFO_acTL;
1112 +    
1113 +    return (1);
1114 +}
1115 +
1116 +/* delay_num and delay_den can hold any 16-bit values including zero */
1117 +png_uint_32 PNGAPI
1118 +png_set_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr, 
1119 +    png_uint_32 width, png_uint_32 height,
1120 +    png_uint_32 x_offset, png_uint_32 y_offset,
1121 +    png_uint_16 delay_num, png_uint_16 delay_den,
1122 +    png_byte dispose_op, png_byte blend_op)
1123 +{
1124 +    png_debug1(1, "in %s storage function\n", "fcTL");
1125 +
1126 +    if (png_ptr == NULL || info_ptr == NULL)
1127 +    {
1128 +        png_warning(png_ptr, 
1129 +                    "Call to png_set_fcTL() with NULL png_ptr or info_ptr "
1130 +                    "ignored");
1131 +        return (0);
1132 +    }
1133 +    
1134 +    png_ensure_fcTL_is_valid(png_ptr, width, height, x_offset, y_offset, 
1135 +                             delay_num, delay_den, dispose_op, blend_op);
1136 +    
1137 +    info_ptr->next_frame_width = width;
1138 +    info_ptr->next_frame_height = height;
1139 +    info_ptr->next_frame_x_offset = x_offset;
1140 +    info_ptr->next_frame_y_offset = y_offset;
1141 +    info_ptr->next_frame_delay_num = delay_num;
1142 +    info_ptr->next_frame_delay_den = delay_den;
1143 +    info_ptr->next_frame_dispose_op = dispose_op;
1144 +    info_ptr->next_frame_blend_op = blend_op;
1145 +    
1146 +    info_ptr->valid |= PNG_INFO_fcTL;
1147 +    
1148 +    return (1);
1149 +}
1150 +
1151 +void /* PRIVATE */
1152 +png_ensure_fcTL_is_valid(png_structp png_ptr, 
1153 +    png_uint_32 width, png_uint_32 height,
1154 +    png_uint_32 x_offset, png_uint_32 y_offset,
1155 +    png_uint_16 delay_num, png_uint_16 delay_den,
1156 +    png_byte dispose_op, png_byte blend_op)
1157 +{
1158 +    if (width + x_offset > png_ptr->first_frame_width || 
1159 +        height + y_offset > png_ptr->first_frame_height)
1160 +        png_error(png_ptr, "dimensions of a frame are greater than"
1161 +                           "the ones in IHDR");
1162 +    if (width > PNG_UINT_31_MAX)
1163 +        png_error(png_ptr, "invalid width in fcTL (> 2^31-1)");
1164 +    if (height > PNG_UINT_31_MAX)
1165 +        png_error(png_ptr, "invalid height in fcTL (> 2^31-1)");
1166 +    if (x_offset > PNG_UINT_31_MAX)
1167 +        png_error(png_ptr, "invalid x_offset in fcTL (> 2^31-1)");
1168 +    if (y_offset > PNG_UINT_31_MAX)
1169 +        png_error(png_ptr, "invalid y_offset in fcTL (> 2^31-1)");
1170 +
1171 +    if (dispose_op != PNG_DISPOSE_OP_NONE &&
1172 +       dispose_op != PNG_DISPOSE_OP_BACKGROUND &&
1173 +       dispose_op != PNG_DISPOSE_OP_PREVIOUS)
1174 +        png_error(png_ptr, "invalid dispose_op in fcTL");
1175 +
1176 +    if (blend_op != PNG_BLEND_OP_SOURCE &&
1177 +       blend_op != PNG_BLEND_OP_OVER)
1178 +        png_error(png_ptr, "invalid blend_op in fcTL");
1179 +
1180 +    if (blend_op == PNG_BLEND_OP_OVER) {
1181 +        if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY)
1182 +            png_error(png_ptr, "PNG_BLEND_OP_OVER is not valid for "
1183 +                               "color type 'greyscale without alpha'");
1184 +        else if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) &&
1185 +                !(png_ptr->color_type & PNG_COLOR_MASK_ALPHA))
1186 +            png_error(png_ptr, "PNG_BLEND_OP_OVER is not valid for "
1187 +                               "color type 'truecolor without alpha'");
1188 +    }
1189 +}
1190 +
1191 +png_uint_32 PNGAPI
1192 +png_set_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr,
1193 +                              png_byte is_hidden)
1194 +{
1195 +    png_debug(1, "in png_first_frame_is_hidden()\n");
1196 +    
1197 +    if (png_ptr == NULL)
1198 +        return 0;
1199 +    
1200 +    if(is_hidden)
1201 +        png_ptr->apng_flags |= PNG_FIRST_FRAME_HIDDEN;
1202 +    else
1203 +        png_ptr->apng_flags &= ~PNG_FIRST_FRAME_HIDDEN;
1204 +    
1205 +    return 1;
1206 +}
1207 +#endif /* PNG_APNG_SUPPORTED */
1208 +
1209  #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
1210  void PNGAPI
1211  png_set_unknown_chunks(png_structp png_ptr,
1212 Index: pngrutil.c
1213 ===================================================================
1214 --- pngrutil.c  (révision 149)
1215 +++ pngrutil.c  (copie de travail)
1216 @@ -374,6 +374,11 @@
1217     filter_type = buf[11];
1218     interlace_type = buf[12];
1219  
1220 +#if defined(PNG_READ_APNG_SUPPORTED)
1221 +   png_ptr->first_frame_width = width;
1222 +   png_ptr->first_frame_height = height;
1223 +#endif
1224 +
1225     /* set internal variables */
1226     png_ptr->width = width;
1227     png_ptr->height = height;
1228 @@ -2175,6 +2180,168 @@
1229  }
1230  #endif
1231  
1232 +#if defined(PNG_READ_APNG_SUPPORTED)
1233 +void /* PRIVATE */
1234 +png_handle_acTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
1235 +{
1236 +    png_byte data[8];
1237 +    png_uint_32 num_frames;
1238 +    png_uint_32 num_plays;
1239 +    png_uint_32 didSet;
1240 +    
1241 +    png_debug(1, "in png_handle_acTL\n");
1242 +
1243 +    if (!(png_ptr->mode & PNG_HAVE_IHDR))
1244 +    {
1245 +        png_error(png_ptr, "Missing IHDR before acTL");
1246 +    }
1247 +    else if (png_ptr->mode & PNG_HAVE_IDAT)
1248 +    {
1249 +        png_warning(png_ptr, "Invalid acTL after IDAT skipped");
1250 +        png_crc_finish(png_ptr, length);
1251 +        return;
1252 +    }
1253 +    else if (png_ptr->mode & PNG_HAVE_acTL)
1254 +    {
1255 +        png_warning(png_ptr, "Duplicate acTL skipped");
1256 +        png_crc_finish(png_ptr, length);
1257 +        return;
1258 +    }
1259 +    else if (length != 8)
1260 +    {
1261 +        png_warning(png_ptr, "acTL with invalid length skipped");
1262 +        png_crc_finish(png_ptr, length);
1263 +        return;
1264 +    }
1265 +    
1266 +    png_crc_read(png_ptr, data, 8);
1267 +    png_crc_finish(png_ptr, 0);
1268 +    
1269 +    num_frames = png_get_uint_31(png_ptr, data);
1270 +    num_plays = png_get_uint_31(png_ptr, data + 4);
1271 +    
1272 +    /* the set function will do error checking on num_frames */
1273 +    didSet = png_set_acTL(png_ptr, info_ptr, num_frames, num_plays);
1274 +    if(didSet)
1275 +        png_ptr->mode |= PNG_HAVE_acTL;
1276 +}
1277 +
1278 +void /* PRIVATE */
1279 +png_handle_fcTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
1280 +{
1281 +    png_byte data[22];
1282 +    png_uint_32 width;
1283 +    png_uint_32 height;
1284 +    png_uint_32 x_offset;
1285 +    png_uint_32 y_offset;
1286 +    png_uint_16 delay_num;
1287 +    png_uint_16 delay_den;
1288 +    png_byte dispose_op;
1289 +    png_byte blend_op;
1290 +    
1291 +    png_debug(1, "in png_handle_fcTL\n");
1292 +    
1293 +    if (!(png_ptr->mode & PNG_HAVE_IHDR))
1294 +    {
1295 +        png_error(png_ptr, "Missing IHDR before fcTL");
1296 +    }
1297 +    else if (png_ptr->mode & PNG_HAVE_IDAT)
1298 +    {
1299 +        /* for any frames other then the first this message may be misleading,
1300 +        * but correct. PNG_HAVE_IDAT is unset before the frame head is read
1301 +        * i can't think of a better message */
1302 +        png_warning(png_ptr, "Invalid fcTL after IDAT skipped");
1303 +        png_crc_finish(png_ptr, length);
1304 +        return;
1305 +    }
1306 +    else if (png_ptr->mode & PNG_HAVE_fcTL)
1307 +    {
1308 +        png_warning(png_ptr, "Duplicate fcTL within one frame skipped");
1309 +        png_crc_finish(png_ptr, length);
1310 +        return;
1311 +    }
1312 +    else if (length != 26)
1313 +    {
1314 +        png_warning(png_ptr, "fcTL with invalid length skipped");
1315 +        png_crc_finish(png_ptr, length);
1316 +        return;
1317 +    }
1318 +    
1319 +    png_ensure_sequence_number(png_ptr, length);
1320 +    
1321 +    png_crc_read(png_ptr, data, 22);
1322 +    png_crc_finish(png_ptr, 0);
1323 +    
1324 +    width = png_get_uint_31(png_ptr, data);
1325 +    height = png_get_uint_31(png_ptr, data + 4);
1326 +    x_offset = png_get_uint_31(png_ptr, data + 8);
1327 +    y_offset = png_get_uint_31(png_ptr, data + 12);
1328 +    delay_num = png_get_uint_16(data + 16);
1329 +    delay_den = png_get_uint_16(data + 18);
1330 +    dispose_op = data[20];
1331 +    blend_op = data[21];
1332 +    
1333 +    if (png_ptr->num_frames_read == 0 && (x_offset != 0 || y_offset != 0))
1334 +        png_error(png_ptr, "fcTL for the first frame must have zero offset");
1335 +    if (png_ptr->num_frames_read == 0 && 
1336 +        (width != info_ptr->width || height != info_ptr->height))
1337 +        png_error(png_ptr, "size in first frame's fcTL must match "
1338 +                           "the size in IHDR");
1339 +    
1340 +    /* the set function will do more error checking */
1341 +    png_set_next_frame_fcTL(png_ptr, info_ptr, width, height, 
1342 +                            x_offset, y_offset, delay_num, delay_den,
1343 +                            dispose_op, blend_op);
1344 +    
1345 +    png_read_reinit(png_ptr, info_ptr);
1346 +    
1347 +    png_ptr->mode |= PNG_HAVE_fcTL;
1348 +}
1349 +
1350 +void /* PRIVATE */
1351 +png_have_info(png_structp png_ptr, png_infop info_ptr)
1352 +{
1353 +    if((info_ptr->valid & PNG_INFO_acTL) && !(info_ptr->valid & PNG_INFO_fcTL))
1354 +    {
1355 +        png_ptr->apng_flags |= PNG_FIRST_FRAME_HIDDEN;
1356 +        info_ptr->num_frames++;
1357 +    }
1358 +}
1359 +
1360 +void /* PRIVATE */
1361 +png_handle_fdAT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
1362 +{
1363 +    png_ensure_sequence_number(png_ptr, length);
1364 +    
1365 +    /* This function is only called from png_read_end(), png_read_info(), 
1366 +    * and png_push_read_chunk() which means that:
1367 +    * - the user doesn't want to read this frame
1368 +    * - or this is an out-of-place fdAT
1369 +    * in either case it is safe to ignore the chunk with a warning */
1370 +    png_warning(png_ptr, "ignoring fdAT chunk");
1371 +    png_crc_finish(png_ptr, length - 4);
1372 +}
1373 +
1374 +void /* PRIVATE */
1375 +png_ensure_sequence_number(png_structp png_ptr, png_uint_32 length)
1376 +{
1377 +    png_byte data[4];
1378 +    png_uint_32 sequence_number;
1379 +    
1380 +    if (length < 4)
1381 +        png_error(png_ptr, "invalid fcTL or fdAT chunk found");
1382 +    
1383 +    png_crc_read(png_ptr, data, 4);
1384 +    sequence_number = png_get_uint_31(png_ptr, data);
1385 +    
1386 +    if (sequence_number != png_ptr->next_seq_num)
1387 +        png_error(png_ptr, "fcTL or fdAT chunk with out-of-order sequence "
1388 +                           "number found");
1389 +    
1390 +    png_ptr->next_seq_num++;
1391 +}
1392 +#endif /* PNG_READ_APNG_SUPPORTED */
1393 +
1394  /* This function is called when we haven't found a handler for a
1395     chunk.  If there isn't a problem with the chunk itself (ie bad
1396     chunk name, CRC, or a critical chunk), the chunk is silently ignored
1397 @@ -3318,8 +3318,10 @@
1398     if(row_bytes + 64 > png_ptr->old_big_row_buf_size)
1399     {
1400       png_free(png_ptr,png_ptr->big_row_buf);
1401 -     png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64);
1402 -     png_ptr->row_buf = png_ptr->big_row_buf+32;
1403 +     if (png_ptr->big_row_buf == NULL)
1404 +        png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64);
1405 +     if (png_ptr->row_buf == NULL)
1406 +        png_ptr->row_buf = png_ptr->big_row_buf+32;
1407       png_ptr->old_big_row_buf_size = row_bytes+64;
1408     }
1409  
1410 @@ -3161,4 +3330,82 @@
1411  
1412     png_ptr->flags |= PNG_FLAG_ROW_INIT;
1413  }
1414 +
1415 +#if defined(PNG_READ_APNG_SUPPORTED)
1416 +/* This function is to be called after the main IDAT set has been read and
1417 + * before a new IDAT is read. It resets some parts of png_ptr
1418 + * to make them usable by the read functions again */
1419 +void /* PRIVATE */
1420 +png_read_reset(png_structp png_ptr)
1421 +{
1422 +    png_ptr->mode &= ~PNG_HAVE_IDAT;
1423 +    png_ptr->mode &= ~PNG_AFTER_IDAT;
1424 +    png_ptr->row_number = 0;
1425 +    png_ptr->pass = 0;
1426 +    png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
1427 +}
1428 +
1429 +void /* PRIVATE */
1430 +png_read_reinit(png_structp png_ptr, png_infop info_ptr)
1431 +{
1432 +    png_ptr->width = info_ptr->next_frame_width;
1433 +    png_ptr->height = info_ptr->next_frame_height;
1434 +    png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->width);
1435 +}
1436 +
1437 +/* same as png_read_reset() but for the progressive reader */
1438 +void /* PRIVATE */
1439 +png_progressive_read_reset(png_structp png_ptr)
1440 +{
1441 +#ifdef PNG_USE_LOCAL_ARRAYS
1442 +    /* start of interlace block */
1443 +    const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
1444 +
1445 +    /* offset to next interlace block */
1446 +    const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
1447 +
1448 +    /* start of interlace block in the y direction */
1449 +    const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
1450 +
1451 +    /* offset to next interlace block in the y direction */
1452 +    const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
1453 +#endif
1454 +    png_uint_32 row_bytes;
1455 +    
1456 +    if (png_ptr->interlaced)
1457 +    {
1458 +        if (!(png_ptr->transformations & PNG_INTERLACE))
1459 +            png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 -
1460 +                                png_pass_ystart[0]) / png_pass_yinc[0];
1461 +        else
1462 +           png_ptr->num_rows = png_ptr->height;
1463 +
1464 +        png_ptr->iwidth = (png_ptr->width +
1465 +                           png_pass_inc[png_ptr->pass] - 1 -
1466 +                           png_pass_start[png_ptr->pass]) /
1467 +                           png_pass_inc[png_ptr->pass];
1468 +
1469 +        row_bytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->iwidth) + 1;
1470 +
1471 +        png_ptr->irowbytes = (png_size_t)row_bytes;
1472 +        if((png_uint_32)png_ptr->irowbytes != row_bytes)
1473 +            png_error(png_ptr, "png_progressive_read_reset(): Rowbytes "
1474 +                               "overflow");
1475 +    }
1476 +    else
1477 +    {
1478 +        png_ptr->num_rows = png_ptr->height;
1479 +        png_ptr->iwidth = png_ptr->width;
1480 +        png_ptr->irowbytes = png_ptr->rowbytes + 1;
1481 +    }
1482 +    
1483 +    png_ptr->flags &= ~PNG_FLAG_ZLIB_FINISHED;
1484 +    if (inflateReset(&(png_ptr->zstream)) != Z_OK)
1485 +        png_error(png_ptr, "inflateReset failed");
1486 +    png_ptr->zstream.avail_in = 0;
1487 +    png_ptr->zstream.next_in = 0;
1488 +    png_ptr->zstream.next_out = png_ptr->row_buf;
1489 +    png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes;
1490 +}
1491 +#endif /* PNG_READ_APNG_SUPPORTED */
1492  #endif /* PNG_READ_SUPPORTED */
1493 Index: pngwutil.c
1494 ===================================================================
1495 --- pngwutil.c  (révision 149)
1496 +++ pngwutil.c  (copie de travail)
1497 @@ -496,6 +496,11 @@
1498     /* write the chunk */
1499     png_write_chunk(png_ptr, png_IHDR, buf, (png_size_t)13);
1500  
1501 +#if defined(PNG_WRITE_APNG_SUPPORTED)
1502 +   png_ptr->first_frame_width = width;
1503 +   png_ptr->first_frame_height = height;
1504 +#endif
1505 +
1506     /* initialize zlib with PNG info */
1507     png_ptr->zstream.zalloc = png_zalloc;
1508     png_ptr->zstream.zfree = png_zfree;
1509 @@ -608,7 +613,10 @@
1510  {
1511  #ifdef PNG_USE_LOCAL_ARRAYS
1512     PNG_IDAT;
1513 +#if defined(PNG_WRITE_APNG_SUPPORTED)
1514 +   PNG_fdAT;
1515  #endif
1516 +#endif
1517     png_debug(1, "in png_write_IDAT\n");
1518  
1519     /* Optimize the CMF field in the zlib stream. */
1520 @@ -650,7 +658,28 @@
1521              "Invalid zlib compression method or flags in IDAT");
1522     }
1523  
1524 -   png_write_chunk(png_ptr, png_IDAT, data, length);
1525 +#if defined(PNG_WRITE_APNG_SUPPORTED)
1526 +   if(png_ptr->num_frames_written == 0)
1527 +#endif
1528 +      png_write_chunk(png_ptr, (png_bytep)png_IDAT, data, length);
1529 +#if defined(PNG_WRITE_APNG_SUPPORTED)
1530 +   else
1531 +   {
1532 +      png_byte buf[4];
1533 +      
1534 +      png_write_chunk_start(png_ptr, (png_bytep)png_fdAT, 4 + length);
1535 +      
1536 +      png_save_uint_32(buf, png_ptr->next_seq_num);
1537 +      png_write_chunk_data(png_ptr, buf, 4);
1538 +      
1539 +      png_write_chunk_data(png_ptr, data, length);
1540 +      
1541 +      png_write_chunk_end(png_ptr);
1542 +      
1543 +      png_ptr->next_seq_num++;
1544 +   }
1545 +#endif
1546 +
1547     png_ptr->mode |= PNG_HAVE_IDAT;
1548  }
1549  
1550 @@ -662,7 +691,7 @@
1551     PNG_IEND;
1552  #endif
1553     png_debug(1, "in png_write_IEND\n");
1554 -   png_write_chunk(png_ptr, png_IEND, png_bytep_NULL,
1555 +   png_write_chunk(png_ptr, (png_bytep)png_IEND, png_bytep_NULL,
1556       (png_size_t)0);
1557     png_ptr->mode |= PNG_HAVE_IEND;
1558  }
1559 @@ -1722,6 +1751,70 @@
1560  }
1561  #endif
1562  
1563 +#if defined(PNG_WRITE_APNG_SUPPORTED)
1564 +void /* PRIVATE */
1565 +png_write_acTL(png_structp png_ptr,
1566 +   png_uint_32 num_frames, png_uint_32 num_plays)
1567 +{
1568 +#ifdef PNG_USE_LOCAL_ARRAYS
1569 +    PNG_acTL;
1570 +#endif
1571 +    png_byte data[16];
1572 +    
1573 +    png_debug(1, "in png_write_acTL\n");
1574 +    
1575 +    png_ptr->num_frames_to_write = num_frames;
1576 +    
1577 +    if (png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN)
1578 +        num_frames--;
1579 +    
1580 +    png_save_uint_32(data, num_frames);
1581 +    png_save_uint_32(data + 4, num_plays);
1582 +    
1583 +    png_write_chunk(png_ptr, (png_bytep)png_acTL, data, (png_size_t)8);
1584 +}
1585 +
1586 +void /* PRIVATE */
1587 +png_write_fcTL(png_structp png_ptr, png_uint_32 width, png_uint_32 height, 
1588 +    png_uint_32 x_offset, png_uint_32 y_offset,
1589 +    png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op, 
1590 +    png_byte blend_op)
1591 +{
1592 +#ifdef PNG_USE_LOCAL_ARRAYS
1593 +    PNG_fcTL;
1594 +#endif
1595 +    png_byte data[26];
1596 +    
1597 +    png_debug(1, "in png_write_fcTL\n");
1598 +    
1599 +    if (png_ptr->num_frames_written == 0 && (x_offset != 0 || y_offset != 0))
1600 +        png_error(png_ptr, "x and/or y offset for the first frame aren't 0\n");
1601 +    if (png_ptr->num_frames_written == 0 && 
1602 +        (width != png_ptr->first_frame_width || 
1603 +         height != png_ptr->first_frame_height))
1604 +        png_error(png_ptr, "width and/or height in the first frame's fcTL "
1605 +                           "don't match the ones in IHDR\n");
1606 +    
1607 +    /* more error checking */
1608 +    png_ensure_fcTL_is_valid(png_ptr, width, height, x_offset, y_offset, 
1609 +                             delay_num, delay_den, dispose_op, blend_op);
1610 +    
1611 +    png_save_uint_32(data, png_ptr->next_seq_num);
1612 +    png_save_uint_32(data + 4, width);
1613 +    png_save_uint_32(data + 8, height);
1614 +    png_save_uint_32(data + 12, x_offset);
1615 +    png_save_uint_32(data + 16, y_offset);
1616 +    png_save_uint_16(data + 20, delay_num);
1617 +    png_save_uint_16(data + 22, delay_den);
1618 +    data[24] = dispose_op;
1619 +    data[25] = blend_op;
1620 +    
1621 +    png_write_chunk(png_ptr, (png_bytep)png_fcTL, data, (png_size_t)26);
1622 +    
1623 +    png_ptr->next_seq_num++;
1624 +}
1625 +#endif /* PNG_WRITE_APNG_SUPPORTED */
1626 +
1627  /* initializes the row writing capability of libpng */
1628  void /* PRIVATE */
1629  png_write_start_row(png_structp png_ptr)
1630 @@ -2789,4 +2882,39 @@
1631     }
1632  #endif
1633  }
1634 +
1635 +#if defined(PNG_WRITE_APNG_SUPPORTED)
1636 +void /* PRIVATE */
1637 +png_write_reset(png_structp png_ptr)
1638 +{
1639 +    png_ptr->row_number = 0;
1640 +    png_ptr->pass = 0;
1641 +    png_ptr->mode &= ~PNG_HAVE_IDAT;
1642 +}
1643 +
1644 +void /* PRIVATE */
1645 +png_write_reinit(png_structp png_ptr, png_infop info_ptr, 
1646 +                 png_uint_32 width, png_uint_32 height)
1647 +{
1648 +    if (png_ptr->num_frames_written == 0 && 
1649 +        (width != png_ptr->first_frame_width || 
1650 +         height != png_ptr->first_frame_height))
1651 +        png_error(png_ptr, "width and/or height in the first frame's fcTL "
1652 +                           "don't match the ones in IHDR\n");
1653 +    if (width > png_ptr->first_frame_width || 
1654 +        height > png_ptr->first_frame_height)
1655 +        png_error(png_ptr, "width and/or height for a frame greater than"
1656 +                           "the ones in IHDR");
1657 +    
1658 +    png_set_IHDR(png_ptr, info_ptr, width, height, 
1659 +                 info_ptr->bit_depth, info_ptr->color_type, 
1660 +                 info_ptr->interlace_type, info_ptr->compression_type,
1661 +                 info_ptr->filter_type);
1662 +   
1663 +    png_ptr->width = width;
1664 +    png_ptr->height = height;
1665 +    png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width);
1666 +    png_ptr->usr_width = png_ptr->width;
1667 +}
1668 +#endif
1669  #endif /* PNG_WRITE_SUPPORTED */
1670 Index: pngrtran.c
1671 ===================================================================
1672 --- pngrtran.c  (révision 149)
1673 +++ pngrtran.c  (copie de travail)
1674 @@ -1293,7 +1293,7 @@
1675         * or png_read_update_info() after setting transforms that expand
1676         * pixels.  This check added to libpng-1.2.19 */
1677  #if (PNG_WARN_UNINITIALIZED_ROW==1)
1678 -      png_error(png_ptr, "Uninitialized row");
1679 +      png_warning(png_ptr, "Uninitialized row");
1680  #else
1681        png_warning(png_ptr, "Uninitialized row");
1682  #endif
This page took 0.334799 seconds and 3 git commands to generate.