Ticket #22489: libpng-1.6.54-apng.patch
| File libpng-1.6.54-apng.patch, 56.0 KB (added by , 9 months ago) |
|---|
-
libpng-1.6.54
diff -Nuarp libpng-1.6.54.orig/pngget.c libpng-1.6.54/pngget.c
old new png_get_palette_max(png_const_structp pn 1366 1366 # endif 1367 1367 #endif 1368 1368 1369 #ifdef PNG_APNG_SUPPORTED 1370 png_uint_32 PNGAPI 1371 png_get_acTL(png_structp png_ptr, png_infop info_ptr, 1372 png_uint_32 *num_frames, png_uint_32 *num_plays) 1373 { 1374 png_debug1(1, "in %s retrieval function", "acTL"); 1375 1376 if (png_ptr != NULL && info_ptr != NULL && 1377 (info_ptr->valid & PNG_INFO_acTL) && 1378 num_frames != NULL && num_plays != NULL) 1379 { 1380 *num_frames = info_ptr->num_frames; 1381 *num_plays = info_ptr->num_plays; 1382 return (1); 1383 } 1384 1385 return (0); 1386 } 1387 1388 png_uint_32 PNGAPI 1389 png_get_num_frames(png_structp png_ptr, png_infop info_ptr) 1390 { 1391 png_debug(1, "in png_get_num_frames()"); 1392 1393 if (png_ptr != NULL && info_ptr != NULL) 1394 return (info_ptr->num_frames); 1395 return (0); 1396 } 1397 1398 png_uint_32 PNGAPI 1399 png_get_num_plays(png_structp png_ptr, png_infop info_ptr) 1400 { 1401 png_debug(1, "in png_get_num_plays()"); 1402 1403 if (png_ptr != NULL && info_ptr != NULL) 1404 return (info_ptr->num_plays); 1405 return (0); 1406 } 1407 1408 png_uint_32 PNGAPI 1409 png_get_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr, 1410 png_uint_32 *width, png_uint_32 *height, 1411 png_uint_32 *x_offset, png_uint_32 *y_offset, 1412 png_uint_16 *delay_num, png_uint_16 *delay_den, 1413 png_byte *dispose_op, png_byte *blend_op) 1414 { 1415 png_debug1(1, "in %s retrieval function", "fcTL"); 1416 1417 if (png_ptr != NULL && info_ptr != NULL && 1418 (info_ptr->valid & PNG_INFO_fcTL) && 1419 width != NULL && height != NULL && 1420 x_offset != NULL && y_offset != NULL && 1421 delay_num != NULL && delay_den != NULL && 1422 dispose_op != NULL && blend_op != NULL) 1423 { 1424 *width = info_ptr->next_frame_width; 1425 *height = info_ptr->next_frame_height; 1426 *x_offset = info_ptr->next_frame_x_offset; 1427 *y_offset = info_ptr->next_frame_y_offset; 1428 *delay_num = info_ptr->next_frame_delay_num; 1429 *delay_den = info_ptr->next_frame_delay_den; 1430 *dispose_op = info_ptr->next_frame_dispose_op; 1431 *blend_op = info_ptr->next_frame_blend_op; 1432 return (1); 1433 } 1434 1435 return (0); 1436 } 1437 1438 png_uint_32 PNGAPI 1439 png_get_next_frame_width(png_structp png_ptr, png_infop info_ptr) 1440 { 1441 png_debug(1, "in png_get_next_frame_width()"); 1442 1443 if (png_ptr != NULL && info_ptr != NULL) 1444 return (info_ptr->next_frame_width); 1445 return (0); 1446 } 1447 1448 png_uint_32 PNGAPI 1449 png_get_next_frame_height(png_structp png_ptr, png_infop info_ptr) 1450 { 1451 png_debug(1, "in png_get_next_frame_height()"); 1452 1453 if (png_ptr != NULL && info_ptr != NULL) 1454 return (info_ptr->next_frame_height); 1455 return (0); 1456 } 1457 1458 png_uint_32 PNGAPI 1459 png_get_next_frame_x_offset(png_structp png_ptr, png_infop info_ptr) 1460 { 1461 png_debug(1, "in png_get_next_frame_x_offset()"); 1462 1463 if (png_ptr != NULL && info_ptr != NULL) 1464 return (info_ptr->next_frame_x_offset); 1465 return (0); 1466 } 1467 1468 png_uint_32 PNGAPI 1469 png_get_next_frame_y_offset(png_structp png_ptr, png_infop info_ptr) 1470 { 1471 png_debug(1, "in png_get_next_frame_y_offset()"); 1472 1473 if (png_ptr != NULL && info_ptr != NULL) 1474 return (info_ptr->next_frame_y_offset); 1475 return (0); 1476 } 1477 1478 png_uint_16 PNGAPI 1479 png_get_next_frame_delay_num(png_structp png_ptr, png_infop info_ptr) 1480 { 1481 png_debug(1, "in png_get_next_frame_delay_num()"); 1482 1483 if (png_ptr != NULL && info_ptr != NULL) 1484 return (info_ptr->next_frame_delay_num); 1485 return (0); 1486 } 1487 1488 png_uint_16 PNGAPI 1489 png_get_next_frame_delay_den(png_structp png_ptr, png_infop info_ptr) 1490 { 1491 png_debug(1, "in png_get_next_frame_delay_den()"); 1492 1493 if (png_ptr != NULL && info_ptr != NULL) 1494 return (info_ptr->next_frame_delay_den); 1495 return (0); 1496 } 1497 1498 png_byte PNGAPI 1499 png_get_next_frame_dispose_op(png_structp png_ptr, png_infop info_ptr) 1500 { 1501 png_debug(1, "in png_get_next_frame_dispose_op()"); 1502 1503 if (png_ptr != NULL && info_ptr != NULL) 1504 return (info_ptr->next_frame_dispose_op); 1505 return (0); 1506 } 1507 1508 png_byte PNGAPI 1509 png_get_next_frame_blend_op(png_structp png_ptr, png_infop info_ptr) 1510 { 1511 png_debug(1, "in png_get_next_frame_blend_op()"); 1512 1513 if (png_ptr != NULL && info_ptr != NULL) 1514 return (info_ptr->next_frame_blend_op); 1515 return (0); 1516 } 1517 1518 png_byte PNGAPI 1519 png_get_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr) 1520 { 1521 png_debug(1, "in png_first_frame_is_hidden()"); 1522 1523 if (png_ptr != NULL) 1524 return (png_byte)(png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN); 1525 1526 PNG_UNUSED(info_ptr) 1527 1528 return 0; 1529 } 1530 #endif /* PNG_APNG_SUPPORTED */ 1369 1531 #endif /* READ || WRITE */ -
libpng-1.6.54
diff -Nuarp libpng-1.6.54.orig/png.h libpng-1.6.54/png.h
old new 328 328 # include "pnglibconf.h" 329 329 #endif 330 330 331 #define PNG_APNG_SUPPORTED 332 #define PNG_READ_APNG_SUPPORTED 333 #define PNG_WRITE_APNG_SUPPORTED 334 331 335 #ifndef PNG_VERSION_INFO_ONLY 332 336 /* Machine specific configuration. */ 333 337 # include "pngconf.h" … … extern "C" { 423 427 * See pngconf.h for base types that vary by machine/system 424 428 */ 425 429 430 #ifdef PNG_APNG_SUPPORTED 431 /* dispose_op flags from inside fcTL */ 432 #define PNG_DISPOSE_OP_NONE 0x00U 433 #define PNG_DISPOSE_OP_BACKGROUND 0x01U 434 #define PNG_DISPOSE_OP_PREVIOUS 0x02U 435 436 /* blend_op flags from inside fcTL */ 437 #define PNG_BLEND_OP_SOURCE 0x00U 438 #define PNG_BLEND_OP_OVER 0x01U 439 #endif /* PNG_APNG_SUPPORTED */ 440 426 441 /* This triggers a compiler error in png.c, if png.c and png.h 427 442 * do not agree upon the version number. 428 443 */ … … typedef PNG_CALLBACK(void, *png_read_sta 795 810 (png_structp, png_uint_32, int)); 796 811 typedef PNG_CALLBACK(void, *png_write_status_ptr, 797 812 (png_structp, png_uint_32, int)); 813 #ifdef PNG_APNG_SUPPORTED 814 typedef PNG_CALLBACK(void, *png_progressive_frame_ptr, 815 (png_structp, png_uint_32)); 816 #endif 798 817 799 818 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED 800 819 typedef PNG_CALLBACK(void, *png_progressive_info_ptr, … … PNG_EXPORT(244, int, png_set_option, (pn 3506 3525 * END OF HARDWARE AND SOFTWARE OPTIONS 3507 3526 ******************************************************************************/ 3508 3527 3528 #ifdef PNG_APNG_SUPPORTED 3529 PNG_EXPORT(260, png_uint_32, png_get_acTL, (png_structp png_ptr, 3530 png_infop info_ptr, png_uint_32 *num_frames, png_uint_32 *num_plays)); 3531 3532 PNG_EXPORT(261, png_uint_32, png_set_acTL, (png_structp png_ptr, 3533 png_infop info_ptr, png_uint_32 num_frames, png_uint_32 num_plays)); 3534 3535 PNG_EXPORT(262, png_uint_32, png_get_num_frames, (png_structp png_ptr, 3536 png_infop info_ptr)); 3537 3538 PNG_EXPORT(263, png_uint_32, png_get_num_plays, (png_structp png_ptr, 3539 png_infop info_ptr)); 3540 3541 PNG_EXPORT(264, png_uint_32, png_get_next_frame_fcTL, 3542 (png_structp png_ptr, png_infop info_ptr, png_uint_32 *width, 3543 png_uint_32 *height, png_uint_32 *x_offset, png_uint_32 *y_offset, 3544 png_uint_16 *delay_num, png_uint_16 *delay_den, png_byte *dispose_op, 3545 png_byte *blend_op)); 3546 3547 PNG_EXPORT(265, png_uint_32, png_set_next_frame_fcTL, 3548 (png_structp png_ptr, png_infop info_ptr, png_uint_32 width, 3549 png_uint_32 height, png_uint_32 x_offset, png_uint_32 y_offset, 3550 png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op, 3551 png_byte blend_op)); 3552 3553 PNG_EXPORT(266, png_uint_32, png_get_next_frame_width, 3554 (png_structp png_ptr, png_infop info_ptr)); 3555 PNG_EXPORT(267, png_uint_32, png_get_next_frame_height, 3556 (png_structp png_ptr, png_infop info_ptr)); 3557 PNG_EXPORT(268, png_uint_32, png_get_next_frame_x_offset, 3558 (png_structp png_ptr, png_infop info_ptr)); 3559 PNG_EXPORT(269, png_uint_32, png_get_next_frame_y_offset, 3560 (png_structp png_ptr, png_infop info_ptr)); 3561 PNG_EXPORT(270, png_uint_16, png_get_next_frame_delay_num, 3562 (png_structp png_ptr, png_infop info_ptr)); 3563 PNG_EXPORT(271, png_uint_16, png_get_next_frame_delay_den, 3564 (png_structp png_ptr, png_infop info_ptr)); 3565 PNG_EXPORT(272, png_byte, png_get_next_frame_dispose_op, 3566 (png_structp png_ptr, png_infop info_ptr)); 3567 PNG_EXPORT(273, png_byte, png_get_next_frame_blend_op, 3568 (png_structp png_ptr, png_infop info_ptr)); 3569 PNG_EXPORT(274, png_byte, png_get_first_frame_is_hidden, 3570 (png_structp png_ptr, png_infop info_ptr)); 3571 PNG_EXPORT(275, png_uint_32, png_set_first_frame_is_hidden, 3572 (png_structp png_ptr, png_infop info_ptr, png_byte is_hidden)); 3573 3574 #ifdef PNG_READ_APNG_SUPPORTED 3575 PNG_EXPORT(276, void, png_read_frame_head, (png_structp png_ptr, 3576 png_infop info_ptr)); 3577 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED 3578 PNG_EXPORT(277, void, png_set_progressive_frame_fn, (png_structp png_ptr, 3579 png_progressive_frame_ptr frame_info_fn, 3580 png_progressive_frame_ptr frame_end_fn)); 3581 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ 3582 #endif /* PNG_READ_APNG_SUPPORTED */ 3583 3584 #ifdef PNG_WRITE_APNG_SUPPORTED 3585 PNG_EXPORT(278, void, png_write_frame_head, (png_structp png_ptr, 3586 png_infop info_ptr, png_bytepp row_pointers, 3587 png_uint_32 width, png_uint_32 height, 3588 png_uint_32 x_offset, png_uint_32 y_offset, 3589 png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op, 3590 png_byte blend_op)); 3591 3592 PNG_EXPORT(279, void, png_write_frame_tail, (png_structp png_ptr, 3593 png_infop info_ptr)); 3594 #endif /* PNG_WRITE_APNG_SUPPORTED */ 3595 #endif /* PNG_APNG_SUPPORTED */ 3596 3509 3597 /* Maintainer: Put new public prototypes here ^, in libpng.3, in project 3510 3598 * defs, and in scripts/symbols.def. 3511 3599 */ … … PNG_EXPORT(244, int, png_set_option, (pn 3514 3602 * one to use is one more than this.) 3515 3603 */ 3516 3604 #ifdef PNG_EXPORT_LAST_ORDINAL 3605 #ifdef PNG_APNG_SUPPORTED 3606 PNG_EXPORT_LAST_ORDINAL(279); 3607 #else 3517 3608 PNG_EXPORT_LAST_ORDINAL(259); 3609 #endif /* PNG_APNG_SUPPORTED */ 3518 3610 #endif 3519 3611 3520 3612 #ifdef __cplusplus -
libpng-1.6.54
diff -Nuarp libpng-1.6.54.orig/pnginfo.h libpng-1.6.54/pnginfo.h
old new defined(PNG_READ_BACKGROUND_SUPPORTED) 259 259 #ifdef PNG_sRGB_SUPPORTED 260 260 int rendering_intent; 261 261 #endif 262 263 #ifdef PNG_APNG_SUPPORTED 264 png_uint_32 num_frames; /* including default image */ 265 png_uint_32 num_plays; 266 png_uint_32 next_frame_width; 267 png_uint_32 next_frame_height; 268 png_uint_32 next_frame_x_offset; 269 png_uint_32 next_frame_y_offset; 270 png_uint_16 next_frame_delay_num; 271 png_uint_16 next_frame_delay_den; 272 png_byte next_frame_dispose_op; 273 png_byte next_frame_blend_op; 274 #endif 262 275 }; 263 276 #endif /* PNGINFO_H */ -
libpng-1.6.54
diff -Nuarp libpng-1.6.54.orig/pngpread.c libpng-1.6.54/pngpread.c
old new png_push_read_chunk(png_structrp png_ptr 200 200 201 201 chunk_name = png_ptr->chunk_name; 202 202 203 #ifdef PNG_READ_APNG_SUPPORTED 204 if (png_ptr->num_frames_read > 0 && 205 png_ptr->num_frames_read < info_ptr->num_frames) 206 { 207 if (chunk_name == png_IDAT) 208 { 209 /* Discard trailing IDATs for the first frame */ 210 if (png_ptr->mode & PNG_HAVE_fcTL || png_ptr->num_frames_read > 1) 211 png_error(png_ptr, "out of place IDAT"); 212 213 if (png_ptr->push_length + 4 > png_ptr->buffer_size) 214 { 215 png_push_save_buffer(png_ptr); 216 return; 217 } 218 219 png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; 220 return; 221 } 222 else if (chunk_name == png_fdAT) 223 { 224 if (png_ptr->buffer_size < 4) 225 { 226 png_push_save_buffer(png_ptr); 227 return; 228 } 229 230 png_ensure_sequence_number(png_ptr, 4); 231 232 if (!(png_ptr->mode & PNG_HAVE_fcTL)) 233 { 234 /* Discard trailing fdATs for frames other than the first */ 235 if (png_ptr->num_frames_read < 2) 236 png_error(png_ptr, "out of place fdAT"); 237 238 if (png_ptr->push_length + 4 > png_ptr->buffer_size) 239 { 240 png_push_save_buffer(png_ptr); 241 return; 242 } 243 244 png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; 245 return; 246 } 247 248 else 249 { 250 /* frame data follows */ 251 png_ptr->idat_size = png_ptr->push_length - 4; 252 png_ptr->mode |= PNG_HAVE_IDAT; 253 png_ptr->process_mode = PNG_READ_IDAT_MODE; 254 255 return; 256 } 257 } 258 259 else if (chunk_name == png_fcTL) 260 { 261 if (png_ptr->push_length + 4 > png_ptr->buffer_size) 262 { 263 png_push_save_buffer(png_ptr); 264 return; 265 } 266 267 png_read_reset(png_ptr); 268 png_ptr->mode &= ~PNG_HAVE_fcTL; 269 270 png_handle_fcTL(png_ptr, info_ptr, png_ptr->push_length); 271 272 if (!(png_ptr->mode & PNG_HAVE_fcTL)) 273 png_error(png_ptr, "missing required fcTL chunk"); 274 275 png_read_reinit(png_ptr, info_ptr); 276 png_progressive_read_reset(png_ptr); 277 278 if (png_ptr->frame_info_fn != NULL) 279 (*(png_ptr->frame_info_fn))(png_ptr, png_ptr->num_frames_read); 280 281 png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; 282 283 return; 284 } 285 286 else 287 { 288 if (png_ptr->push_length + 4 > png_ptr->buffer_size) 289 { 290 png_push_save_buffer(png_ptr); 291 return; 292 } 293 png_warning(png_ptr, "Skipped (ignored) a chunk " 294 "between APNG chunks"); 295 png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; 296 return; 297 } 298 299 return; 300 } 301 #endif /* PNG_READ_APNG_SUPPORTED */ 302 203 303 if (chunk_name == png_IDAT) 204 304 { 205 305 if ((png_ptr->mode & PNG_AFTER_IDAT) != 0) … … png_push_read_chunk(png_structrp png_ptr 268 368 269 369 else if (chunk_name == png_IDAT) 270 370 { 371 #ifdef PNG_READ_APNG_SUPPORTED 372 png_have_info(png_ptr, info_ptr); 373 #endif 271 374 png_ptr->idat_size = png_ptr->push_length; 272 375 png_ptr->process_mode = PNG_READ_IDAT_MODE; 273 376 png_push_have_info(png_ptr, info_ptr); … … png_push_read_chunk(png_structrp png_ptr 278 381 return; 279 382 } 280 383 384 #ifdef PNG_READ_APNG_SUPPORTED 385 else if (chunk_name == png_acTL) 386 { 387 if (png_ptr->push_length + 4 > png_ptr->buffer_size) 388 { 389 png_push_save_buffer(png_ptr); 390 return; 391 } 392 393 png_handle_acTL(png_ptr, info_ptr, png_ptr->push_length); 394 } 395 396 else if (chunk_name == png_fcTL) 397 { 398 if (png_ptr->push_length + 4 > png_ptr->buffer_size) 399 { 400 png_push_save_buffer(png_ptr); 401 return; 402 } 403 404 png_handle_fcTL(png_ptr, info_ptr, png_ptr->push_length); 405 } 406 407 #endif /* PNG_READ_APNG_SUPPORTED */ 408 281 409 else 282 410 { 283 411 PNG_PUSH_SAVE_BUFFER_IF_FULL … … png_push_read_IDAT(png_structrp png_ptr) 409 537 png_byte chunk_tag[4]; 410 538 411 539 /* TODO: this code can be commoned up with the same code in push_read */ 540 #ifdef PNG_READ_APNG_SUPPORTED 541 PNG_PUSH_SAVE_BUFFER_IF_LT(12) 542 #else 412 543 PNG_PUSH_SAVE_BUFFER_IF_LT(8) 544 #endif 413 545 png_push_fill_buffer(png_ptr, chunk_length, 4); 414 546 png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length); 415 547 png_reset_crc(png_ptr); … … png_push_read_IDAT(png_structrp png_ptr) 417 549 png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag); 418 550 png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; 419 551 552 #ifdef PNG_READ_APNG_SUPPORTED 553 if (png_ptr->chunk_name != png_fdAT && png_ptr->num_frames_read > 0) 554 { 555 if (png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) 556 { 557 png_ptr->process_mode = PNG_READ_CHUNK_MODE; 558 if (png_ptr->frame_end_fn != NULL) 559 (*(png_ptr->frame_end_fn))(png_ptr, png_ptr->num_frames_read); 560 png_ptr->num_frames_read++; 561 return; 562 } 563 else 564 { 565 if (png_ptr->chunk_name == png_IEND) 566 png_error(png_ptr, "Not enough image data"); 567 if (png_ptr->push_length + 4 > png_ptr->buffer_size) 568 { 569 png_push_save_buffer(png_ptr); 570 return; 571 } 572 png_warning(png_ptr, "Skipping (ignoring) a chunk between " 573 "APNG chunks"); 574 png_crc_finish(png_ptr, png_ptr->push_length); 575 png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; 576 return; 577 } 578 } 579 else 580 #endif 581 #ifdef PNG_READ_APNG_SUPPORTED 582 if (png_ptr->chunk_name != png_IDAT && png_ptr->num_frames_read == 0) 583 #else 420 584 if (png_ptr->chunk_name != png_IDAT) 585 #endif 421 586 { 422 587 png_ptr->process_mode = PNG_READ_CHUNK_MODE; 423 588 424 589 if ((png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0) 425 590 png_error(png_ptr, "Not enough compressed data"); 426 591 592 #ifdef PNG_READ_APNG_SUPPORTED 593 if (png_ptr->frame_end_fn != NULL) 594 (*(png_ptr->frame_end_fn))(png_ptr, png_ptr->num_frames_read); 595 png_ptr->num_frames_read++; 596 #endif 597 427 598 return; 428 599 } 429 600 430 601 png_ptr->idat_size = png_ptr->push_length; 602 603 #ifdef PNG_READ_APNG_SUPPORTED 604 if (png_ptr->num_frames_read > 0) 605 { 606 png_ensure_sequence_number(png_ptr, 4); 607 png_ptr->idat_size -= 4; 608 } 609 #endif 431 610 } 432 611 433 612 if (png_ptr->idat_size != 0 && png_ptr->save_buffer_size != 0) … … png_process_IDAT_data(png_structrp png_p 501 680 if (!(buffer_length > 0) || buffer == NULL) 502 681 png_error(png_ptr, "No IDAT data (internal error)"); 503 682 683 #ifdef PNG_READ_APNG_SUPPORTED 684 /* If the app is not APNG-aware, decode only the first frame */ 685 if (!(png_ptr->apng_flags & PNG_APNG_APP) && png_ptr->num_frames_read > 0) 686 { 687 png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED; 688 return; 689 } 690 #endif 691 504 692 /* This routine must process all the data it has been given 505 693 * before returning, calling the row callback as required to 506 694 * handle the uncompressed results. … … png_set_progressive_read_fn(png_structrp 934 1122 png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer); 935 1123 } 936 1124 1125 #ifdef PNG_READ_APNG_SUPPORTED 1126 void PNGAPI 1127 png_set_progressive_frame_fn(png_structp png_ptr, 1128 png_progressive_frame_ptr frame_info_fn, 1129 png_progressive_frame_ptr frame_end_fn) 1130 { 1131 png_ptr->frame_info_fn = frame_info_fn; 1132 png_ptr->frame_end_fn = frame_end_fn; 1133 png_ptr->apng_flags |= PNG_APNG_APP; 1134 } 1135 #endif 1136 937 1137 png_voidp PNGAPI 938 1138 png_get_progressive_ptr(png_const_structrp png_ptr) 939 1139 { -
libpng-1.6.54
diff -Nuarp libpng-1.6.54.orig/pngpriv.h libpng-1.6.54/pngpriv.h
old new 653 653 #define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000U /* Have another chunk after IDAT */ 654 654 #define PNG_WROTE_eXIf 0x4000U 655 655 #define PNG_IS_READ_STRUCT 0x8000U /* Else is a write struct */ 656 #ifdef PNG_APNG_SUPPORTED 657 #define PNG_HAVE_acTL 0x10000U 658 #define PNG_HAVE_fcTL 0x20000U 659 #endif 656 660 657 661 /* Flags for the transformations the PNG library does on the image data */ 658 662 #define PNG_BGR 0x0001U … … 917 921 #define png_tRNS PNG_U32(116, 82, 78, 83) 918 922 #define png_zTXt PNG_U32(122, 84, 88, 116) 919 923 924 #ifdef PNG_APNG_SUPPORTED 925 926 /* For png_struct.apng_flags: */ 927 #define PNG_FIRST_FRAME_HIDDEN 0x0001U 928 #define PNG_APNG_APP 0x0002U 929 #endif 930 920 931 /* The following will work on (signed char*) strings, whereas the get_uint_32 921 932 * macro will fail on top-bit-set values because of the sign extension. 922 933 */ … … PNG_INTERNAL_FUNCTION(void, png_read_pus 1880 1891 PNG_EMPTY); 1881 1892 #endif /* PROGRESSIVE_READ */ 1882 1893 1894 #ifdef PNG_APNG_SUPPORTED 1895 PNG_INTERNAL_FUNCTION(void,png_ensure_fcTL_is_valid,(png_structp png_ptr, 1896 png_uint_32 width, png_uint_32 height, 1897 png_uint_32 x_offset, png_uint_32 y_offset, 1898 png_uint_16 delay_num, png_uint_16 delay_den, 1899 png_byte dispose_op, png_byte blend_op), PNG_EMPTY); 1900 1901 #ifdef PNG_READ_APNG_SUPPORTED 1902 PNG_INTERNAL_FUNCTION(void,png_handle_acTL,(png_structp png_ptr, png_infop info_ptr, 1903 png_uint_32 length),PNG_EMPTY); 1904 PNG_INTERNAL_FUNCTION(void,png_handle_fcTL,(png_structp png_ptr, png_infop info_ptr, 1905 png_uint_32 length),PNG_EMPTY); 1906 PNG_INTERNAL_FUNCTION(void,png_handle_fdAT,(png_structp png_ptr, png_infop info_ptr, 1907 png_uint_32 length),PNG_EMPTY); 1908 PNG_INTERNAL_FUNCTION(void,png_have_info,(png_structp png_ptr, png_infop info_ptr),PNG_EMPTY); 1909 PNG_INTERNAL_FUNCTION(void,png_ensure_sequence_number,(png_structp png_ptr, 1910 png_uint_32 length),PNG_EMPTY); 1911 PNG_INTERNAL_FUNCTION(void,png_read_reset,(png_structp png_ptr),PNG_EMPTY); 1912 PNG_INTERNAL_FUNCTION(void,png_read_reinit,(png_structp png_ptr, 1913 png_infop info_ptr),PNG_EMPTY); 1914 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED 1915 PNG_INTERNAL_FUNCTION(void,png_progressive_read_reset,(png_structp png_ptr),PNG_EMPTY); 1916 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ 1917 #endif /* PNG_READ_APNG_SUPPORTED */ 1918 1919 #ifdef PNG_WRITE_APNG_SUPPORTED 1920 PNG_INTERNAL_FUNCTION(void,png_write_acTL,(png_structp png_ptr, 1921 png_uint_32 num_frames, png_uint_32 num_plays),PNG_EMPTY); 1922 PNG_INTERNAL_FUNCTION(void,png_write_fcTL,(png_structp png_ptr, 1923 png_uint_32 width, png_uint_32 height, 1924 png_uint_32 x_offset, png_uint_32 y_offset, 1925 png_uint_16 delay_num, png_uint_16 delay_den, 1926 png_byte dispose_op, png_byte blend_op),PNG_EMPTY); 1927 PNG_INTERNAL_FUNCTION(void,png_write_fdAT,(png_structp png_ptr, 1928 png_const_bytep data, png_size_t length),PNG_EMPTY); 1929 PNG_INTERNAL_FUNCTION(void,png_write_reset,(png_structp png_ptr),PNG_EMPTY); 1930 PNG_INTERNAL_FUNCTION(void,png_write_reinit,(png_structp png_ptr, 1931 png_infop info_ptr, png_uint_32 width, png_uint_32 height),PNG_EMPTY); 1932 #endif /* PNG_WRITE_APNG_SUPPORTED */ 1933 #endif /* PNG_APNG_SUPPORTED */ 1934 1883 1935 #ifdef PNG_iCCP_SUPPORTED 1884 1936 /* Routines for checking parts of an ICC profile. */ 1885 1937 #ifdef PNG_READ_iCCP_SUPPORTED -
libpng-1.6.54
diff -Nuarp libpng-1.6.54.orig/pngread.c libpng-1.6.54/pngread.c
old new png_read_info(png_structrp png_ptr, png_ 157 157 158 158 else if (chunk_name == png_IDAT) 159 159 { 160 #ifdef PNG_READ_APNG_SUPPORTED 161 png_have_info(png_ptr, info_ptr); 162 #endif 160 163 png_ptr->idat_size = length; 161 164 break; 162 165 } 163 166 167 #ifdef PNG_READ_APNG_SUPPORTED 168 else if (chunk_name == png_acTL) 169 png_handle_acTL(png_ptr, info_ptr, length); 170 171 else if (chunk_name == png_fcTL) 172 png_handle_fcTL(png_ptr, info_ptr, length); 173 174 else if (chunk_name == png_fdAT) 175 png_handle_fdAT(png_ptr, info_ptr, length); 176 #endif 177 164 178 else 165 179 png_handle_chunk(png_ptr, info_ptr, length); 166 180 } 167 181 } 168 182 #endif /* SEQUENTIAL_READ */ 169 183 184 #ifdef PNG_READ_APNG_SUPPORTED 185 void PNGAPI 186 png_read_frame_head(png_structp png_ptr, png_infop info_ptr) 187 { 188 png_byte have_chunk_after_DAT; /* after IDAT or after fdAT */ 189 190 png_debug(0, "Reading frame head"); 191 192 if (!(png_ptr->mode & PNG_HAVE_acTL)) 193 png_error(png_ptr, "attempt to png_read_frame_head() but " 194 "no acTL present"); 195 196 /* do nothing for the main IDAT */ 197 if (png_ptr->num_frames_read == 0) 198 return; 199 200 png_read_reset(png_ptr); 201 png_ptr->flags &= ~PNG_FLAG_ROW_INIT; 202 png_ptr->mode &= ~PNG_HAVE_fcTL; 203 204 have_chunk_after_DAT = 0; 205 for (;;) 206 { 207 png_uint_32 length = png_read_chunk_header(png_ptr); 208 209 if (png_ptr->chunk_name == png_IDAT) 210 { 211 /* discard trailing IDATs for the first frame */ 212 if (have_chunk_after_DAT || png_ptr->num_frames_read > 1) 213 png_error(png_ptr, "png_read_frame_head(): out of place IDAT"); 214 png_crc_finish(png_ptr, length); 215 } 216 217 else if (png_ptr->chunk_name == png_fcTL) 218 { 219 png_handle_fcTL(png_ptr, info_ptr, length); 220 have_chunk_after_DAT = 1; 221 } 222 223 else if (png_ptr->chunk_name == png_fdAT) 224 { 225 png_ensure_sequence_number(png_ptr, length); 226 227 /* discard trailing fdATs for frames other than the first */ 228 if (!have_chunk_after_DAT && png_ptr->num_frames_read > 1) 229 png_crc_finish(png_ptr, length - 4); 230 else if(png_ptr->mode & PNG_HAVE_fcTL) 231 { 232 png_ptr->idat_size = length - 4; 233 png_ptr->mode |= PNG_HAVE_IDAT; 234 235 break; 236 } 237 else 238 png_error(png_ptr, "png_read_frame_head(): out of place fdAT"); 239 } 240 else 241 { 242 png_warning(png_ptr, "Skipped (ignored) a chunk " 243 "between APNG chunks"); 244 png_crc_finish(png_ptr, length); 245 } 246 } 247 } 248 #endif /* PNG_READ_APNG_SUPPORTED */ 249 170 250 /* Optional call to update the users info_ptr structure */ 171 251 void PNGAPI 172 252 png_read_update_info(png_structrp png_ptr, png_inforp info_ptr) -
libpng-1.6.54
diff -Nuarp libpng-1.6.54.orig/pngrutil.c libpng-1.6.54/pngrutil.c
old new png_handle_IHDR(png_structrp png_ptr, pn 922 922 filter_type = buf[11]; 923 923 interlace_type = buf[12]; 924 924 925 #ifdef PNG_READ_APNG_SUPPORTED 926 png_ptr->first_frame_width = width; 927 png_ptr->first_frame_height = height; 928 #endif 929 925 930 /* Set internal variables */ 926 931 png_ptr->width = width; 927 932 png_ptr->height = height; … … png_handle_iTXt(png_structrp png_ptr, pn 2718 2723 # define png_handle_iTXt NULL 2719 2724 #endif 2720 2725 2726 #ifdef PNG_READ_APNG_SUPPORTED 2727 void /* PRIVATE */ 2728 png_handle_acTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) 2729 { 2730 png_byte data[8]; 2731 png_uint_32 num_frames; 2732 png_uint_32 num_plays; 2733 png_uint_32 didSet; 2734 2735 png_debug(1, "in png_handle_acTL"); 2736 2737 if (!(png_ptr->mode & PNG_HAVE_IHDR)) 2738 { 2739 png_error(png_ptr, "Missing IHDR before acTL"); 2740 } 2741 else if (png_ptr->mode & PNG_HAVE_IDAT) 2742 { 2743 png_warning(png_ptr, "Invalid acTL after IDAT skipped"); 2744 png_crc_finish(png_ptr, length); 2745 return; 2746 } 2747 else if (png_ptr->mode & PNG_HAVE_acTL) 2748 { 2749 png_warning(png_ptr, "Duplicate acTL skipped"); 2750 png_crc_finish(png_ptr, length); 2751 return; 2752 } 2753 else if (length != 8) 2754 { 2755 png_warning(png_ptr, "acTL with invalid length skipped"); 2756 png_crc_finish(png_ptr, length); 2757 return; 2758 } 2759 2760 png_crc_read(png_ptr, data, 8); 2761 png_crc_finish(png_ptr, 0); 2762 2763 num_frames = png_get_uint_31(png_ptr, data); 2764 num_plays = png_get_uint_31(png_ptr, data + 4); 2765 2766 /* the set function will do error checking on num_frames */ 2767 didSet = png_set_acTL(png_ptr, info_ptr, num_frames, num_plays); 2768 if(didSet) 2769 png_ptr->mode |= PNG_HAVE_acTL; 2770 } 2771 2772 void /* PRIVATE */ 2773 png_handle_fcTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) 2774 { 2775 png_byte data[22]; 2776 png_uint_32 width; 2777 png_uint_32 height; 2778 png_uint_32 x_offset; 2779 png_uint_32 y_offset; 2780 png_uint_16 delay_num; 2781 png_uint_16 delay_den; 2782 png_byte dispose_op; 2783 png_byte blend_op; 2784 2785 png_debug(1, "in png_handle_fcTL"); 2786 2787 png_ensure_sequence_number(png_ptr, length); 2788 2789 if (!(png_ptr->mode & PNG_HAVE_IHDR)) 2790 { 2791 png_error(png_ptr, "Missing IHDR before fcTL"); 2792 } 2793 else if (png_ptr->mode & PNG_HAVE_IDAT) 2794 { 2795 /* for any frames other then the first this message may be misleading, 2796 * but correct. PNG_HAVE_IDAT is unset before the frame head is read 2797 * i can't think of a better message */ 2798 png_warning(png_ptr, "Invalid fcTL after IDAT skipped"); 2799 png_crc_finish(png_ptr, length-4); 2800 return; 2801 } 2802 else if (png_ptr->mode & PNG_HAVE_fcTL) 2803 { 2804 png_warning(png_ptr, "Duplicate fcTL within one frame skipped"); 2805 png_crc_finish(png_ptr, length-4); 2806 return; 2807 } 2808 else if (length != 26) 2809 { 2810 png_warning(png_ptr, "fcTL with invalid length skipped"); 2811 png_crc_finish(png_ptr, length-4); 2812 return; 2813 } 2814 2815 png_crc_read(png_ptr, data, 22); 2816 png_crc_finish(png_ptr, 0); 2817 2818 width = png_get_uint_31(png_ptr, data); 2819 height = png_get_uint_31(png_ptr, data + 4); 2820 x_offset = png_get_uint_31(png_ptr, data + 8); 2821 y_offset = png_get_uint_31(png_ptr, data + 12); 2822 delay_num = png_get_uint_16(data + 16); 2823 delay_den = png_get_uint_16(data + 18); 2824 dispose_op = data[20]; 2825 blend_op = data[21]; 2826 2827 if (png_ptr->num_frames_read == 0 && (x_offset != 0 || y_offset != 0)) 2828 { 2829 png_warning(png_ptr, "fcTL for the first frame must have zero offset"); 2830 return; 2831 } 2832 2833 if (info_ptr != NULL) 2834 { 2835 if (png_ptr->num_frames_read == 0 && 2836 (width != info_ptr->width || height != info_ptr->height)) 2837 { 2838 png_warning(png_ptr, "size in first frame's fcTL must match " 2839 "the size in IHDR"); 2840 return; 2841 } 2842 2843 /* The set function will do more error checking */ 2844 png_set_next_frame_fcTL(png_ptr, info_ptr, width, height, 2845 x_offset, y_offset, delay_num, delay_den, 2846 dispose_op, blend_op); 2847 2848 png_read_reinit(png_ptr, info_ptr); 2849 2850 png_ptr->mode |= PNG_HAVE_fcTL; 2851 } 2852 } 2853 2854 void /* PRIVATE */ 2855 png_have_info(png_structp png_ptr, png_infop info_ptr) 2856 { 2857 if((info_ptr->valid & PNG_INFO_acTL) && !(info_ptr->valid & PNG_INFO_fcTL)) 2858 { 2859 png_ptr->apng_flags |= PNG_FIRST_FRAME_HIDDEN; 2860 info_ptr->num_frames++; 2861 } 2862 } 2863 2864 void /* PRIVATE */ 2865 png_handle_fdAT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) 2866 { 2867 png_ensure_sequence_number(png_ptr, length); 2868 2869 /* This function is only called from png_read_end(), png_read_info(), 2870 * and png_push_read_chunk() which means that: 2871 * - the user doesn't want to read this frame 2872 * - or this is an out-of-place fdAT 2873 * in either case it is safe to ignore the chunk with a warning */ 2874 png_warning(png_ptr, "ignoring fdAT chunk"); 2875 png_crc_finish(png_ptr, length - 4); 2876 PNG_UNUSED(info_ptr) 2877 } 2878 2879 void /* PRIVATE */ 2880 png_ensure_sequence_number(png_structp png_ptr, png_uint_32 length) 2881 { 2882 png_byte data[4]; 2883 png_uint_32 sequence_number; 2884 2885 if (length < 4) 2886 png_error(png_ptr, "invalid fcTL or fdAT chunk found"); 2887 2888 png_crc_read(png_ptr, data, 4); 2889 sequence_number = png_get_uint_31(png_ptr, data); 2890 2891 if (sequence_number != png_ptr->next_seq_num) 2892 png_error(png_ptr, "fcTL or fdAT chunk with out-of-order sequence " 2893 "number found"); 2894 2895 png_ptr->next_seq_num++; 2896 } 2897 #endif /* PNG_READ_APNG_SUPPORTED */ 2898 2721 2899 #ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED 2722 2900 /* Utility function for png_handle_unknown; set up png_ptr::unknown_chunk */ 2723 2901 static int … … png_read_IDAT_data(png_structrp png_ptr, 4200 4378 { 4201 4379 uInt avail_in; 4202 4380 png_bytep buffer; 4381 #ifdef PNG_READ_APNG_SUPPORTED 4382 png_uint_32 bytes_to_skip = 0; 4203 4383 4384 while (png_ptr->idat_size == 0 || bytes_to_skip != 0) 4385 { 4386 png_crc_finish(png_ptr, bytes_to_skip); 4387 bytes_to_skip = 0; 4388 4389 png_ptr->idat_size = png_read_chunk_header(png_ptr); 4390 if (png_ptr->num_frames_read == 0) 4391 { 4392 if (png_ptr->chunk_name != png_IDAT) 4393 png_error(png_ptr, "Not enough image data"); 4394 } 4395 else 4396 { 4397 if (png_ptr->chunk_name == png_IEND) 4398 png_error(png_ptr, "Not enough image data"); 4399 if (png_ptr->chunk_name != png_fdAT) 4400 { 4401 png_warning(png_ptr, "Skipped (ignored) a chunk " 4402 "between APNG chunks"); 4403 bytes_to_skip = png_ptr->idat_size; 4404 continue; 4405 } 4406 4407 png_ensure_sequence_number(png_ptr, png_ptr->idat_size); 4408 4409 png_ptr->idat_size -= 4; 4410 } 4411 } 4412 #else 4204 4413 while (png_ptr->idat_size == 0) 4205 4414 { 4206 4415 png_crc_finish(png_ptr, 0); … … png_read_IDAT_data(png_structrp png_ptr, 4212 4421 if (png_ptr->chunk_name != png_IDAT) 4213 4422 png_error(png_ptr, "Not enough image data"); 4214 4423 } 4215 4424 #endif /* PNG_READ_APNG_SUPPORTED */ 4216 4425 avail_in = png_ptr->IDAT_read_size; 4217 4426 4218 4427 if (avail_in > png_chunk_max(png_ptr)) … … png_read_IDAT_data(png_structrp png_ptr, 4283 4492 4284 4493 png_ptr->mode |= PNG_AFTER_IDAT; 4285 4494 png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED; 4495 #ifdef PNG_READ_APNG_SUPPORTED 4496 png_ptr->num_frames_read++; 4497 #endif 4286 4498 4287 4499 if (png_ptr->zstream.avail_in > 0 || png_ptr->idat_size > 0) 4288 4500 png_chunk_benign_error(png_ptr, "Extra compressed data"); … … defined(PNG_USER_TRANSFORM_PTR_SUPPORTED 4692 4904 4693 4905 png_ptr->flags |= PNG_FLAG_ROW_INIT; 4694 4906 } 4907 4908 #ifdef PNG_READ_APNG_SUPPORTED 4909 /* This function is to be called after the main IDAT set has been read and 4910 * before a new IDAT is read. It resets some parts of png_ptr 4911 * to make them usable by the read functions again */ 4912 void /* PRIVATE */ 4913 png_read_reset(png_structp png_ptr) 4914 { 4915 png_ptr->mode &= ~PNG_HAVE_IDAT; 4916 png_ptr->mode &= ~PNG_AFTER_IDAT; 4917 png_ptr->row_number = 0; 4918 png_ptr->pass = 0; 4919 } 4920 4921 void /* PRIVATE */ 4922 png_read_reinit(png_structp png_ptr, png_infop info_ptr) 4923 { 4924 png_ptr->width = info_ptr->next_frame_width; 4925 png_ptr->height = info_ptr->next_frame_height; 4926 png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->width); 4927 png_ptr->info_rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, 4928 png_ptr->width); 4929 if (png_ptr->prev_row) 4930 memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1); 4931 } 4932 4933 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED 4934 /* same as png_read_reset() but for the progressive reader */ 4935 void /* PRIVATE */ 4936 png_progressive_read_reset(png_structp png_ptr) 4937 { 4938 #ifdef PNG_READ_INTERLACING_SUPPORTED 4939 /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ 4940 4941 /* Start of interlace block */ 4942 const int png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; 4943 4944 /* Offset to next interlace block */ 4945 const int png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; 4946 4947 /* Start of interlace block in the y direction */ 4948 const int png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; 4949 4950 /* Offset to next interlace block in the y direction */ 4951 const int png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; 4952 4953 if (png_ptr->interlaced) 4954 { 4955 if (!(png_ptr->transformations & PNG_INTERLACE)) 4956 png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - 4957 png_pass_ystart[0]) / png_pass_yinc[0]; 4958 else 4959 png_ptr->num_rows = png_ptr->height; 4960 4961 png_ptr->iwidth = (png_ptr->width + 4962 png_pass_inc[png_ptr->pass] - 1 - 4963 png_pass_start[png_ptr->pass]) / 4964 png_pass_inc[png_ptr->pass]; 4965 } 4966 else 4967 #endif /* PNG_READ_INTERLACING_SUPPORTED */ 4968 { 4969 png_ptr->num_rows = png_ptr->height; 4970 png_ptr->iwidth = png_ptr->width; 4971 } 4972 png_ptr->flags &= ~PNG_FLAG_ZSTREAM_ENDED; 4973 if (inflateReset(&(png_ptr->zstream)) != Z_OK) 4974 png_error(png_ptr, "inflateReset failed"); 4975 png_ptr->zstream.avail_in = 0; 4976 png_ptr->zstream.next_in = 0; 4977 png_ptr->zstream.next_out = png_ptr->row_buf; 4978 png_ptr->zstream.avail_out = (uInt)PNG_ROWBYTES(png_ptr->pixel_depth, 4979 png_ptr->iwidth) + 1; 4980 } 4981 #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ 4982 #endif /* PNG_READ_APNG_SUPPORTED */ 4695 4983 #endif /* READ */ -
libpng-1.6.54
diff -Nuarp libpng-1.6.54.orig/pngset.c libpng-1.6.54/pngset.c
old new png_set_IHDR(png_const_structrp png_ptr, 460 460 info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); 461 461 462 462 info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width); 463 464 #ifdef PNG_APNG_SUPPORTED 465 /* for non-animated png. this may be overwritten from an acTL chunk later */ 466 info_ptr->num_frames = 1; 467 #endif 463 468 } 464 469 465 470 #ifdef PNG_oFFs_SUPPORTED … … png_set_sPLT(png_const_structrp png_ptr, 1315 1320 } 1316 1321 #endif /* sPLT */ 1317 1322 1323 #ifdef PNG_APNG_SUPPORTED 1324 png_uint_32 PNGAPI 1325 png_set_acTL(png_structp png_ptr, png_infop info_ptr, 1326 png_uint_32 num_frames, png_uint_32 num_plays) 1327 { 1328 png_debug1(1, "in %s storage function", "acTL"); 1329 1330 if (png_ptr == NULL || info_ptr == NULL) 1331 { 1332 png_warning(png_ptr, 1333 "Call to png_set_acTL() with NULL png_ptr " 1334 "or info_ptr ignored"); 1335 return (0); 1336 } 1337 if (num_frames == 0) 1338 { 1339 png_warning(png_ptr, 1340 "Ignoring attempt to set acTL with num_frames zero"); 1341 return (0); 1342 } 1343 if (num_frames > PNG_UINT_31_MAX) 1344 { 1345 png_warning(png_ptr, 1346 "Ignoring attempt to set acTL with num_frames > 2^31-1"); 1347 return (0); 1348 } 1349 if (num_plays > PNG_UINT_31_MAX) 1350 { 1351 png_warning(png_ptr, 1352 "Ignoring attempt to set acTL with num_plays " 1353 "> 2^31-1"); 1354 return (0); 1355 } 1356 1357 info_ptr->num_frames = num_frames; 1358 info_ptr->num_plays = num_plays; 1359 1360 info_ptr->valid |= PNG_INFO_acTL; 1361 1362 return (1); 1363 } 1364 1365 /* delay_num and delay_den can hold any 16-bit values including zero */ 1366 png_uint_32 PNGAPI 1367 png_set_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr, 1368 png_uint_32 width, png_uint_32 height, 1369 png_uint_32 x_offset, png_uint_32 y_offset, 1370 png_uint_16 delay_num, png_uint_16 delay_den, 1371 png_byte dispose_op, png_byte blend_op) 1372 { 1373 png_debug1(1, "in %s storage function", "fcTL"); 1374 1375 if (png_ptr == NULL || info_ptr == NULL) 1376 { 1377 png_warning(png_ptr, 1378 "Call to png_set_fcTL() with NULL png_ptr or info_ptr " 1379 "ignored"); 1380 return (0); 1381 } 1382 1383 png_ensure_fcTL_is_valid(png_ptr, width, height, x_offset, y_offset, 1384 delay_num, delay_den, dispose_op, blend_op); 1385 1386 if (blend_op == PNG_BLEND_OP_OVER) 1387 { 1388 if (!(png_ptr->color_type & PNG_COLOR_MASK_ALPHA) && 1389 !(png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))) 1390 { 1391 png_warning(png_ptr, "PNG_BLEND_OP_OVER is meaningless " 1392 "and wasteful for opaque images, ignored"); 1393 blend_op = PNG_BLEND_OP_SOURCE; 1394 } 1395 } 1396 1397 info_ptr->next_frame_width = width; 1398 info_ptr->next_frame_height = height; 1399 info_ptr->next_frame_x_offset = x_offset; 1400 info_ptr->next_frame_y_offset = y_offset; 1401 info_ptr->next_frame_delay_num = delay_num; 1402 info_ptr->next_frame_delay_den = delay_den; 1403 info_ptr->next_frame_dispose_op = dispose_op; 1404 info_ptr->next_frame_blend_op = blend_op; 1405 1406 info_ptr->valid |= PNG_INFO_fcTL; 1407 1408 return (1); 1409 } 1410 1411 void /* PRIVATE */ 1412 png_ensure_fcTL_is_valid(png_structp png_ptr, 1413 png_uint_32 width, png_uint_32 height, 1414 png_uint_32 x_offset, png_uint_32 y_offset, 1415 png_uint_16 delay_num, png_uint_16 delay_den, 1416 png_byte dispose_op, png_byte blend_op) 1417 { 1418 if (width == 0 || width > PNG_UINT_31_MAX) 1419 png_error(png_ptr, "invalid width in fcTL (> 2^31-1)"); 1420 if (height == 0 || height > PNG_UINT_31_MAX) 1421 png_error(png_ptr, "invalid height in fcTL (> 2^31-1)"); 1422 if (x_offset > PNG_UINT_31_MAX) 1423 png_error(png_ptr, "invalid x_offset in fcTL (> 2^31-1)"); 1424 if (y_offset > PNG_UINT_31_MAX) 1425 png_error(png_ptr, "invalid y_offset in fcTL (> 2^31-1)"); 1426 if (width + x_offset > png_ptr->first_frame_width || 1427 height + y_offset > png_ptr->first_frame_height) 1428 png_error(png_ptr, "dimensions of a frame are greater than" 1429 "the ones in IHDR"); 1430 1431 if (dispose_op != PNG_DISPOSE_OP_NONE && 1432 dispose_op != PNG_DISPOSE_OP_BACKGROUND && 1433 dispose_op != PNG_DISPOSE_OP_PREVIOUS) 1434 png_error(png_ptr, "invalid dispose_op in fcTL"); 1435 1436 if (blend_op != PNG_BLEND_OP_SOURCE && 1437 blend_op != PNG_BLEND_OP_OVER) 1438 png_error(png_ptr, "invalid blend_op in fcTL"); 1439 1440 PNG_UNUSED(delay_num) 1441 PNG_UNUSED(delay_den) 1442 } 1443 1444 png_uint_32 PNGAPI 1445 png_set_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr, 1446 png_byte is_hidden) 1447 { 1448 png_debug(1, "in png_first_frame_is_hidden()"); 1449 1450 if (png_ptr == NULL) 1451 return 0; 1452 1453 if (is_hidden) 1454 png_ptr->apng_flags |= PNG_FIRST_FRAME_HIDDEN; 1455 else 1456 png_ptr->apng_flags &= ~PNG_FIRST_FRAME_HIDDEN; 1457 1458 PNG_UNUSED(info_ptr) 1459 1460 return 1; 1461 } 1462 #endif /* PNG_APNG_SUPPORTED */ 1463 1318 1464 #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED 1319 1465 static png_byte 1320 1466 check_location(png_const_structrp png_ptr, int location) -
libpng-1.6.54
diff -Nuarp libpng-1.6.54.orig/pngstruct.h libpng-1.6.54/pngstruct.h
old new struct png_struct_def 391 391 png_byte filter_type; 392 392 #endif 393 393 394 #ifdef PNG_APNG_SUPPORTED 395 png_uint_32 apng_flags; 396 png_uint_32 next_seq_num; /* next fcTL/fdAT chunk sequence number */ 397 png_uint_32 first_frame_width; 398 png_uint_32 first_frame_height; 399 400 #ifdef PNG_READ_APNG_SUPPORTED 401 png_uint_32 num_frames_read; /* incremented after all image data of */ 402 /* a frame is read */ 403 #ifdef PNG_PROGRESSIVE_READ_SUPPORTED 404 png_progressive_frame_ptr frame_info_fn; /* frame info read callback */ 405 png_progressive_frame_ptr frame_end_fn; /* frame data read callback */ 406 #endif 407 #endif 408 409 #ifdef PNG_WRITE_APNG_SUPPORTED 410 png_uint_32 num_frames_to_write; 411 png_uint_32 num_frames_written; 412 #endif 413 #endif /* PNG_APNG_SUPPORTED */ 414 394 415 /* New members added in libpng-1.2.0 */ 395 416 396 417 /* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ -
libpng-1.6.54
diff -Nuarp libpng-1.6.54.orig/pngtest.c libpng-1.6.54/pngtest.c
old new test_one_file(const char *inname, const 877 877 int bit_depth, color_type; 878 878 user_chunk_info my_user_chunk_data; 879 879 int pass, num_passes; 880 #ifdef PNG_APNG_SUPPORTED 881 png_uint_32 num_frames; 882 png_uint_32 num_plays; 883 #endif 880 884 881 885 row_buf = NULL; 882 886 error_parameters.file_name = inname; … … test_one_file(const char *inname, const 1437 1441 } 1438 1442 } 1439 1443 #endif 1444 1445 #ifdef PNG_APNG_SUPPORTED 1446 if (png_get_valid(read_ptr, read_info_ptr, PNG_INFO_acTL)) 1447 { 1448 if (png_get_acTL(read_ptr, read_info_ptr, &num_frames, &num_plays)) 1449 { 1450 png_byte is_hidden; 1451 pngtest_debug2("Handling acTL chunks (frames %ld, plays %ld)", 1452 num_frames, num_plays); 1453 png_set_acTL(write_ptr, write_info_ptr, num_frames, num_plays); 1454 is_hidden = png_get_first_frame_is_hidden(read_ptr, read_info_ptr); 1455 png_set_first_frame_is_hidden(write_ptr, write_info_ptr, is_hidden); 1456 } 1457 } 1458 #endif 1459 1440 1460 #ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED 1441 1461 { 1442 1462 png_unknown_chunkp unknowns; … … test_one_file(const char *inname, const 1496 1516 t_misc += (t_stop - t_start); 1497 1517 t_start = t_stop; 1498 1518 #endif 1519 #ifdef PNG_APNG_SUPPORTED 1520 if (png_get_valid(read_ptr, read_info_ptr, PNG_INFO_acTL)) 1521 { 1522 png_uint_32 frame; 1523 for (frame = 0; frame < num_frames; frame++) 1524 { 1525 png_uint_32 frame_width; 1526 png_uint_32 frame_height; 1527 png_uint_32 x_offset; 1528 png_uint_32 y_offset; 1529 png_uint_16 delay_num; 1530 png_uint_16 delay_den; 1531 png_byte dispose_op; 1532 png_byte blend_op; 1533 png_read_frame_head(read_ptr, read_info_ptr); 1534 if (png_get_valid(read_ptr, read_info_ptr, PNG_INFO_fcTL)) 1535 { 1536 png_get_next_frame_fcTL(read_ptr, read_info_ptr, 1537 &frame_width, &frame_height, 1538 &x_offset, &y_offset, 1539 &delay_num, &delay_den, 1540 &dispose_op, &blend_op); 1541 } 1542 else 1543 { 1544 frame_width = width; 1545 frame_height = height; 1546 x_offset = 0; 1547 y_offset = 0; 1548 delay_num = 1; 1549 delay_den = 1; 1550 dispose_op = PNG_DISPOSE_OP_NONE; 1551 blend_op = PNG_BLEND_OP_SOURCE; 1552 } 1553 #ifdef PNG_WRITE_APNG_SUPPORTED 1554 png_write_frame_head(write_ptr, write_info_ptr, (png_bytepp)&row_buf, 1555 frame_width, frame_height, 1556 x_offset, y_offset, 1557 delay_num, delay_den, 1558 dispose_op, blend_op); 1559 #endif 1560 for (pass = 0; pass < num_passes; pass++) 1561 { 1562 # ifdef calc_pass_height 1563 png_uint_32 pass_height; 1564 1565 if (num_passes == 7) /* interlaced */ 1566 { 1567 if (PNG_PASS_COLS(frame_width, pass) > 0) 1568 pass_height = PNG_PASS_ROWS(frame_height, pass); 1569 1570 else 1571 pass_height = 0; 1572 } 1573 1574 else /* not interlaced */ 1575 pass_height = frame_height; 1576 # else 1577 # define pass_height frame_height 1578 # endif 1579 1580 pngtest_debug1("Writing row data for pass %d", pass); 1581 for (y = 0; y < pass_height; y++) 1582 { 1583 #ifndef SINGLE_ROWBUF_ALLOC 1584 pngtest_debug2("Allocating row buffer (pass %d, y = %u)...", pass, y); 1585 1586 row_buf = (png_bytep)png_malloc(read_ptr, 1587 png_get_rowbytes(read_ptr, read_info_ptr)); 1588 1589 pngtest_debug2("\t0x%08lx (%lu bytes)", (unsigned long)row_buf, 1590 (unsigned long)png_get_rowbytes(read_ptr, read_info_ptr)); 1591 1592 #endif /* !SINGLE_ROWBUF_ALLOC */ 1593 png_read_rows(read_ptr, (png_bytepp)&row_buf, NULL, 1); 1594 1595 #ifdef PNG_WRITE_SUPPORTED 1596 #ifdef PNGTEST_TIMING 1597 t_stop = (float)clock(); 1598 t_decode += (t_stop - t_start); 1599 t_start = t_stop; 1600 #endif 1601 png_write_rows(write_ptr, (png_bytepp)&row_buf, 1); 1602 #ifdef PNGTEST_TIMING 1603 t_stop = (float)clock(); 1604 t_encode += (t_stop - t_start); 1605 t_start = t_stop; 1606 #endif 1607 #endif /* PNG_WRITE_SUPPORTED */ 1608 1609 #ifndef SINGLE_ROWBUF_ALLOC 1610 pngtest_debug2("Freeing row buffer (pass %d, y = %u)", pass, y); 1611 png_free(read_ptr, row_buf); 1612 row_buf = NULL; 1613 #endif /* !SINGLE_ROWBUF_ALLOC */ 1614 } 1615 } 1616 #ifdef PNG_WRITE_APNG_SUPPORTED 1617 png_write_frame_tail(write_ptr, write_info_ptr); 1618 #endif 1619 } 1620 } 1621 else 1622 #endif 1499 1623 for (pass = 0; pass < num_passes; pass++) 1500 1624 { 1501 1625 # ifdef calc_pass_height -
libpng-1.6.54
diff -Nuarp libpng-1.6.54.orig/pngwrite.c libpng-1.6.54/pngwrite.c
old new png_write_info_before_PLTE(png_structrp 127 127 * the application continues writing the PNG. So check the 'invalid' 128 128 * flag here too. 129 129 */ 130 #ifdef PNG_WRITE_APNG_SUPPORTED 131 if ((info_ptr->valid & PNG_INFO_acTL) != 0) 132 png_write_acTL(png_ptr, info_ptr->num_frames, info_ptr->num_plays); 133 #endif 134 130 135 #ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED 131 136 /* Write unknown chunks first; PNG v3 establishes a precedence order 132 137 * for colourspace chunks. It is certain therefore that new … … png_write_end(png_structrp png_ptr, png_ 405 410 png_benign_error(png_ptr, "Wrote palette index exceeding num_palette"); 406 411 #endif 407 412 413 #ifdef PNG_WRITE_APNG_SUPPORTED 414 if (png_ptr->num_frames_written != png_ptr->num_frames_to_write) 415 png_error(png_ptr, "Not enough frames written"); 416 #endif 417 408 418 /* See if user wants us to write information chunks */ 409 419 if (info_ptr != NULL) 410 420 { … … png_write_png(png_structrp png_ptr, png_ 1517 1527 } 1518 1528 #endif 1519 1529 1530 #ifdef PNG_WRITE_APNG_SUPPORTED 1531 void PNGAPI 1532 png_write_frame_head(png_structp png_ptr, png_infop info_ptr, 1533 png_bytepp row_pointers, png_uint_32 width, png_uint_32 height, 1534 png_uint_32 x_offset, png_uint_32 y_offset, 1535 png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op, 1536 png_byte blend_op) 1537 { 1538 png_debug(1, "in png_write_frame_head"); 1539 1540 /* there is a chance this has been set after png_write_info was called, 1541 * so it would be set but not written. is there a way to be sure? */ 1542 if (!(info_ptr->valid & PNG_INFO_acTL)) 1543 png_error(png_ptr, "png_write_frame_head(): acTL not set"); 1544 1545 png_write_reset(png_ptr); 1546 1547 png_write_reinit(png_ptr, info_ptr, width, height); 1548 1549 if ( !(png_ptr->num_frames_written == 0 && 1550 (png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN) ) ) 1551 png_write_fcTL(png_ptr, width, height, x_offset, y_offset, 1552 delay_num, delay_den, dispose_op, blend_op); 1553 1554 PNG_UNUSED(row_pointers) 1555 } 1556 1557 void PNGAPI 1558 png_write_frame_tail(png_structp png_ptr, png_infop info_ptr) 1559 { 1560 png_debug(1, "in png_write_frame_tail"); 1561 1562 png_ptr->num_frames_written++; 1563 1564 PNG_UNUSED(info_ptr) 1565 } 1566 #endif /* PNG_WRITE_APNG_SUPPORTED */ 1520 1567 1521 1568 #ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED 1522 1569 /* Initialize the write structure - general purpose utility. */ -
libpng-1.6.54
diff -Nuarp libpng-1.6.54.orig/pngwutil.c libpng-1.6.54/pngwutil.c
old new png_write_IHDR(png_structrp png_ptr, png 838 838 /* Write the chunk */ 839 839 png_write_complete_chunk(png_ptr, png_IHDR, buf, 13); 840 840 841 #ifdef PNG_WRITE_APNG_SUPPORTED 842 png_ptr->first_frame_width = width; 843 png_ptr->first_frame_height = height; 844 #endif 845 841 846 if ((png_ptr->do_filter) == PNG_NO_FILTERS) 842 847 { 843 848 if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE || … … png_compress_IDAT(png_structrp png_ptr, 1019 1024 optimize_cmf(data, png_image_size(png_ptr)); 1020 1025 #endif 1021 1026 1022 if (size > 0) 1023 png_write_complete_chunk(png_ptr, png_IDAT, data, size); 1027 if (size > 0) 1028 #ifdef PNG_WRITE_APNG_SUPPORTED 1029 { 1030 if (png_ptr->num_frames_written == 0) 1031 #endif 1032 png_write_complete_chunk(png_ptr, png_IDAT, data, size); 1033 #ifdef PNG_WRITE_APNG_SUPPORTED 1034 else 1035 png_write_fdAT(png_ptr, data, size); 1036 } 1037 #endif /* PNG_WRITE_APNG_SUPPORTED */ 1024 1038 png_ptr->mode |= PNG_HAVE_IDAT; 1025 1039 1026 1040 png_ptr->zstream.next_out = data; … … png_compress_IDAT(png_structrp png_ptr, 1067 1081 #endif 1068 1082 1069 1083 if (size > 0) 1084 #ifdef PNG_WRITE_APNG_SUPPORTED 1085 { 1086 if (png_ptr->num_frames_written == 0) 1087 #endif 1070 1088 png_write_complete_chunk(png_ptr, png_IDAT, data, size); 1089 #ifdef PNG_WRITE_APNG_SUPPORTED 1090 else 1091 png_write_fdAT(png_ptr, data, size); 1092 } 1093 #endif /* PNG_WRITE_APNG_SUPPORTED */ 1094 1071 1095 png_ptr->zstream.avail_out = 0; 1072 1096 png_ptr->zstream.next_out = NULL; 1073 1097 png_ptr->mode |= PNG_HAVE_IDAT | PNG_AFTER_IDAT; … … png_write_tIME(png_structrp png_ptr, png 1969 1993 } 1970 1994 #endif 1971 1995 1996 #ifdef PNG_WRITE_APNG_SUPPORTED 1997 void /* PRIVATE */ 1998 png_write_acTL(png_structp png_ptr, 1999 png_uint_32 num_frames, png_uint_32 num_plays) 2000 { 2001 png_byte buf[8]; 2002 2003 png_debug(1, "in png_write_acTL"); 2004 2005 png_ptr->num_frames_to_write = num_frames; 2006 2007 if (png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN) 2008 num_frames--; 2009 2010 png_save_uint_32(buf, num_frames); 2011 png_save_uint_32(buf + 4, num_plays); 2012 2013 png_write_complete_chunk(png_ptr, png_acTL, buf, (png_size_t)8); 2014 } 2015 2016 void /* PRIVATE */ 2017 png_write_fcTL(png_structp png_ptr, png_uint_32 width, png_uint_32 height, 2018 png_uint_32 x_offset, png_uint_32 y_offset, 2019 png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op, 2020 png_byte blend_op) 2021 { 2022 png_byte buf[26]; 2023 2024 png_debug(1, "in png_write_fcTL"); 2025 2026 if (png_ptr->num_frames_written == 0 && (x_offset != 0 || y_offset != 0)) 2027 png_error(png_ptr, "x and/or y offset for the first frame aren't 0"); 2028 if (png_ptr->num_frames_written == 0 && 2029 (width != png_ptr->first_frame_width || 2030 height != png_ptr->first_frame_height)) 2031 png_error(png_ptr, "width and/or height in the first frame's fcTL " 2032 "don't match the ones in IHDR"); 2033 2034 /* more error checking */ 2035 png_ensure_fcTL_is_valid(png_ptr, width, height, x_offset, y_offset, 2036 delay_num, delay_den, dispose_op, blend_op); 2037 2038 png_save_uint_32(buf, png_ptr->next_seq_num); 2039 png_save_uint_32(buf + 4, width); 2040 png_save_uint_32(buf + 8, height); 2041 png_save_uint_32(buf + 12, x_offset); 2042 png_save_uint_32(buf + 16, y_offset); 2043 png_save_uint_16(buf + 20, delay_num); 2044 png_save_uint_16(buf + 22, delay_den); 2045 buf[24] = dispose_op; 2046 buf[25] = blend_op; 2047 2048 png_write_complete_chunk(png_ptr, png_fcTL, buf, (png_size_t)26); 2049 2050 png_ptr->next_seq_num++; 2051 } 2052 2053 void /* PRIVATE */ 2054 png_write_fdAT(png_structp png_ptr, 2055 png_const_bytep data, png_size_t length) 2056 { 2057 png_byte buf[4]; 2058 2059 png_write_chunk_header(png_ptr, png_fdAT, (png_uint_32)(4 + length)); 2060 2061 png_save_uint_32(buf, png_ptr->next_seq_num); 2062 png_write_chunk_data(png_ptr, buf, 4); 2063 2064 png_write_chunk_data(png_ptr, data, length); 2065 2066 png_write_chunk_end(png_ptr); 2067 2068 png_ptr->next_seq_num++; 2069 } 2070 #endif /* PNG_WRITE_APNG_SUPPORTED */ 2071 1972 2072 /* Initializes the row writing capability of libpng */ 1973 2073 void /* PRIVATE */ 1974 2074 png_write_start_row(png_structrp png_ptr) … … png_write_filtered_row(png_structrp png_ 2822 2922 } 2823 2923 #endif /* WRITE_FLUSH */ 2824 2924 } 2925 2926 #ifdef PNG_WRITE_APNG_SUPPORTED 2927 void /* PRIVATE */ 2928 png_write_reset(png_structp png_ptr) 2929 { 2930 png_ptr->row_number = 0; 2931 png_ptr->pass = 0; 2932 png_ptr->mode &= ~PNG_HAVE_IDAT; 2933 } 2934 2935 void /* PRIVATE */ 2936 png_write_reinit(png_structp png_ptr, png_infop info_ptr, 2937 png_uint_32 width, png_uint_32 height) 2938 { 2939 if (png_ptr->num_frames_written == 0 && 2940 (width != png_ptr->first_frame_width || 2941 height != png_ptr->first_frame_height)) 2942 png_error(png_ptr, "width and/or height in the first frame's fcTL " 2943 "don't match the ones in IHDR"); 2944 if (width > png_ptr->first_frame_width || 2945 height > png_ptr->first_frame_height) 2946 png_error(png_ptr, "width and/or height for a frame greater than" 2947 "the ones in IHDR"); 2948 2949 png_set_IHDR(png_ptr, info_ptr, width, height, 2950 info_ptr->bit_depth, info_ptr->color_type, 2951 info_ptr->interlace_type, info_ptr->compression_type, 2952 info_ptr->filter_type); 2953 2954 png_ptr->width = width; 2955 png_ptr->height = height; 2956 png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width); 2957 png_ptr->usr_width = png_ptr->width; 2958 } 2959 #endif /* PNG_WRITE_APNG_SUPPORTED */ 2825 2960 #endif /* WRITE */ -
scripts/symbols.def
diff -Nuarp libpng-1.6.54.orig/scripts/symbols.def libpng-1.6.54/scripts/symbols.def
old new EXPORTS 263 263 png_get_mDCV_fixed @257 264 264 png_set_mDCV @258 265 265 png_set_mDCV_fixed @259 266 png_get_acTL @260 267 png_set_acTL @261 268 png_get_num_frames @262 269 png_get_num_plays @263 270 png_get_next_frame_fcTL @264 271 png_set_next_frame_fcTL @265 272 png_get_next_frame_width @266 273 png_get_next_frame_height @267 274 png_get_next_frame_x_offset @268 275 png_get_next_frame_y_offset @269 276 png_get_next_frame_delay_num @270 277 png_get_next_frame_delay_den @271 278 png_get_next_frame_dispose_op @272 279 png_get_next_frame_blend_op @273 280 png_get_first_frame_is_hidden @274 281 png_set_first_frame_is_hidden @275 282 png_read_frame_head @276 283 png_set_progressive_frame_fn @277 284 png_write_frame_head @278 285 png_write_frame_tail @279
