View | Details | Raw Unified | Return to bug 18152
Collapse All | Expand All

(-)libpng-1.2.31/pngread.c.orig (-2 / +142 lines)
Lines 407-412 Link Here
407
#if defined(PNG_READ_zTXt_SUPPORTED)
407
#if defined(PNG_READ_zTXt_SUPPORTED)
408
      PNG_CONST PNG_zTXt;
408
      PNG_CONST PNG_zTXt;
409
#endif
409
#endif
410
#if defined(PNG_READ_APNG_SUPPORTED)
411
      PNG_CONST PNG_acTL;
412
      PNG_CONST PNG_fcTL;
413
      PNG_CONST PNG_fdAT;
414
#endif
410
#endif /* PNG_USE_LOCAL_ARRAYS */
415
#endif /* PNG_USE_LOCAL_ARRAYS */
411
      png_uint_32 length = png_read_chunk_header(png_ptr);
416
      png_uint_32 length = png_read_chunk_header(png_ptr);
412
      PNG_CONST png_bytep chunk_name = png_ptr->chunk_name;
417
      PNG_CONST png_bytep chunk_name = png_ptr->chunk_name;
Lines 451-456 Link Here
451
                  !(png_ptr->mode & PNG_HAVE_PLTE))
456
                  !(png_ptr->mode & PNG_HAVE_PLTE))
452
            png_error(png_ptr, "Missing PLTE before IDAT");
457
            png_error(png_ptr, "Missing PLTE before IDAT");
453
458
459
#if defined(PNG_READ_APNG_SUPPORTED)
460
         png_have_info(png_ptr, info_ptr);
461
#endif
454
         png_ptr->idat_size = length;
462
         png_ptr->idat_size = length;
455
         png_ptr->mode |= PNG_HAVE_IDAT;
463
         png_ptr->mode |= PNG_HAVE_IDAT;
456
         break;
464
         break;
Lines 523-534 Link Here
523
      else if (!png_memcmp(chunk_name, png_iTXt, 4))
531
      else if (!png_memcmp(chunk_name, png_iTXt, 4))
524
         png_handle_iTXt(png_ptr, info_ptr, length);
532
         png_handle_iTXt(png_ptr, info_ptr, length);
525
#endif
533
#endif
534
#if defined(PNG_READ_APNG_SUPPORTED)
535
      else if (!png_memcmp(png_ptr->chunk_name, png_acTL, 4))
536
         png_handle_acTL(png_ptr, info_ptr, length);
537
      else if (!png_memcmp(png_ptr->chunk_name, png_fcTL, 4))
538
         png_handle_fcTL(png_ptr, info_ptr, length);
539
      else if (!png_memcmp(png_ptr->chunk_name, png_fdAT, 4))
540
         png_handle_fdAT(png_ptr, info_ptr, length);
541
#endif
526
      else
542
      else
527
         png_handle_unknown(png_ptr, info_ptr, length);
543
         png_handle_unknown(png_ptr, info_ptr, length);
528
   }
544
   }
529
}
545
}
530
#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
546
#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
531
547
548
#if defined(PNG_READ_APNG_SUPPORTED)
549
void PNGAPI
550
png_read_frame_head(png_structp png_ptr, png_infop info_ptr)
551
{
552
    png_byte have_chunk_after_DAT; /* after IDAT or after fdAT */
553
    
554
    png_debug(0, "Reading frame head\n");
555
    
556
    if (!(png_ptr->mode & PNG_HAVE_acTL))
557
        png_error(png_ptr, "attempt to png_read_frame_head() but "
558
                           "no acTL present");
559
    
560
    /* do nothing for the main IDAT */
561
    if (png_ptr->num_frames_read == 0)
562
        return;
563
    
564
    png_crc_finish(png_ptr, 0); /* CRC from last IDAT or fdAT chunk */
565
    
566
    png_read_reset(png_ptr);
567
    png_ptr->mode &= ~PNG_HAVE_fcTL;
568
    
569
    have_chunk_after_DAT = 0;
570
    for (;;)
571
    {
572
#ifdef PNG_USE_LOCAL_ARRAYS
573
        PNG_IDAT;
574
        PNG_fdAT;
575
        PNG_fcTL;
576
#endif
577
        png_byte chunk_length[4];
578
        png_uint_32 length;
579
        
580
        png_read_data(png_ptr, chunk_length, 4);
581
        length = png_get_uint_31(png_ptr, chunk_length);
582
        
583
        png_reset_crc(png_ptr);
584
        png_crc_read(png_ptr, png_ptr->chunk_name, 4);
585
        
586
        if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
587
        {
588
            /* discard trailing IDATs for the first frame */
589
            if (have_chunk_after_DAT || png_ptr->num_frames_read > 1)
590
                png_error(png_ptr, "png_read_frame_head(): out of place IDAT");
591
            png_crc_finish(png_ptr, length);
592
        }
593
        else if (!png_memcmp(png_ptr->chunk_name, png_fcTL, 4))
594
        {
595
            png_handle_fcTL(png_ptr, info_ptr, length);
596
            have_chunk_after_DAT = 1;
597
        }
598
        else if (!png_memcmp(png_ptr->chunk_name, png_fdAT, 4))
599
        {
600
            png_ensure_sequence_number(png_ptr, length);
601
            
602
            /* discard trailing fdATs for frames other than the first */
603
            if (!have_chunk_after_DAT && png_ptr->num_frames_read > 1)
604
                png_crc_finish(png_ptr, length - 4);
605
            else if(png_ptr->mode & PNG_HAVE_fcTL)
606
            {
607
                png_ptr->idat_size = length - 4;
608
                png_ptr->mode |= PNG_HAVE_IDAT;
609
                
610
                break;
611
            }
612
            else
613
                png_error(png_ptr, "png_read_frame_head(): out of place fdAT");
614
        }
615
        else
616
        {
617
            png_warning(png_ptr, "Skipped (ignored) a chunk "
618
                                 "between APNG chunks");
619
            png_crc_finish(png_ptr, length);
620
        }
621
    }
622
}
623
#endif /* PNG_READ_APNG_SUPPORTED */
624
532
/* optional call to update the users info_ptr structure */
625
/* optional call to update the users info_ptr structure */
533
void PNGAPI
626
void PNGAPI
534
png_read_update_info(png_structp png_ptr, png_infop info_ptr)
627
png_read_update_info(png_structp png_ptr, png_infop info_ptr)
Lines 565-570 Link Here
565
{
658
{
566
#ifdef PNG_USE_LOCAL_ARRAYS
659
#ifdef PNG_USE_LOCAL_ARRAYS
567
   PNG_CONST PNG_IDAT;
660
   PNG_CONST PNG_IDAT;
661
#if defined(PNG_READ_APNG_SUPPORTED)
662
   PNG_CONST PNG_fdAT;
663
   PNG_CONST PNG_IEND;
664
#endif
568
   PNG_CONST int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55,
665
   PNG_CONST int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55,
569
      0xff};
666
      0xff};
570
   PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
667
   PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
Lines 694-706 Link Here
694
   {
791
   {
695
      if (!(png_ptr->zstream.avail_in))
792
      if (!(png_ptr->zstream.avail_in))
696
      {
793
      {
697
         while (!png_ptr->idat_size)
794
         png_uint_32 bytes_to_skip = 0;
795
796
         while (!png_ptr->idat_size || bytes_to_skip != 0)
698
         {
797
         {
699
            png_crc_finish(png_ptr, 0);
798
            png_crc_finish(png_ptr, bytes_to_skip);
799
	    bytes_to_skip = 0;
700
800
701
            png_ptr->idat_size = png_read_chunk_header(png_ptr);
801
            png_ptr->idat_size = png_read_chunk_header(png_ptr);
802
            
803
#if defined(PNG_READ_APNG_SUPPORTED)
804
            if (png_ptr->num_frames_read == 0)
805
            {
806
#endif
702
            if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
807
            if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
703
               png_error(png_ptr, "Not enough image data");
808
               png_error(png_ptr, "Not enough image data");
809
#if defined(PNG_READ_APNG_SUPPORTED)
810
            }
811
            else
812
            {
813
               if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
814
                  png_error(png_ptr, "Not enough image data");
815
               if (png_memcmp(png_ptr->chunk_name, png_fdAT, 4))
816
               {
817
                  png_warning(png_ptr, "Skipped (ignored) a chunk "
818
                                       "between APNG chunks");
819
                  bytes_to_skip = png_ptr->idat_size;
820
                  continue;
821
               }
822
               
823
               png_ensure_sequence_number(png_ptr, png_ptr->idat_size);
824
               
825
               png_ptr->idat_size -= 4;
826
            }
827
#endif
704
         }
828
         }
705
         png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size;
829
         png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size;
706
         png_ptr->zstream.next_in = png_ptr->zbuf;
830
         png_ptr->zstream.next_in = png_ptr->zbuf;
Lines 718-723 Link Here
718
            png_error(png_ptr, "Extra compressed data");
842
            png_error(png_ptr, "Extra compressed data");
719
         png_ptr->mode |= PNG_AFTER_IDAT;
843
         png_ptr->mode |= PNG_AFTER_IDAT;
720
         png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
844
         png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
845
#if defined(PNG_READ_APNG_SUPPORTED)
846
         png_ptr->num_frames_read++;
847
#endif
721
         break;
848
         break;
722
      }
849
      }
723
      if (ret != Z_OK)
850
      if (ret != Z_OK)
Lines 969-974 Link Here
969
#if defined(PNG_READ_zTXt_SUPPORTED)
1096
#if defined(PNG_READ_zTXt_SUPPORTED)
970
      PNG_CONST PNG_zTXt;
1097
      PNG_CONST PNG_zTXt;
971
#endif
1098
#endif
1099
#if defined(PNG_READ_APNG_SUPPORTED)
1100
      PNG_CONST PNG_acTL;
1101
      PNG_CONST PNG_fcTL;
1102
      PNG_CONST PNG_fdAT;
1103
#endif
972
#endif /* PNG_USE_LOCAL_ARRAYS */
1104
#endif /* PNG_USE_LOCAL_ARRAYS */
973
      png_uint_32 length = png_read_chunk_header(png_ptr);
1105
      png_uint_32 length = png_read_chunk_header(png_ptr);
974
      PNG_CONST png_bytep chunk_name = png_ptr->chunk_name;
1106
      PNG_CONST png_bytep chunk_name = png_ptr->chunk_name;
Lines 1069-1074 Link Here
1069
      else if (!png_memcmp(chunk_name, png_iTXt, 4))
1201
      else if (!png_memcmp(chunk_name, png_iTXt, 4))
1070
         png_handle_iTXt(png_ptr, info_ptr, length);
1202
         png_handle_iTXt(png_ptr, info_ptr, length);
1071
#endif
1203
#endif
1204
#if defined(PNG_READ_APNG_SUPPORTED)
1205
      else if (!png_memcmp(png_ptr->chunk_name, png_acTL, 4))
1206
         png_handle_acTL(png_ptr, info_ptr, length);
1207
      else if (!png_memcmp(png_ptr->chunk_name, png_fcTL, 4))
1208
         png_handle_fcTL(png_ptr, info_ptr, length);
1209
      else if (!png_memcmp(png_ptr->chunk_name, png_fdAT, 4))
1210
         png_handle_fdAT(png_ptr, info_ptr, length);
1211
#endif
1072
      else
1212
      else
1073
         png_handle_unknown(png_ptr, info_ptr, length);
1213
         png_handle_unknown(png_ptr, info_ptr, length);
1074
   } while (!(png_ptr->mode & PNG_HAVE_IEND));
1214
   } while (!(png_ptr->mode & PNG_HAVE_IEND));
(-)libpng-1.2.31/pngget.c.orig (+161 lines)
Lines 796-801 Link Here
796
}
796
}
797
#endif
797
#endif
798
798
799
#if defined(PNG_APNG_SUPPORTED)
800
png_uint_32 PNGAPI
801
png_get_acTL(png_structp png_ptr, png_infop info_ptr,
802
             png_uint_32 *num_frames, png_uint_32 *num_plays)
803
{
804
    png_debug1(1, "in %s retrieval function\n", "acTL");
805
    
806
    if (png_ptr != NULL && info_ptr != NULL &&
807
        (info_ptr->valid & PNG_INFO_acTL) &&
808
        num_frames != NULL && num_plays != NULL)
809
    {
810
        *num_frames = info_ptr->num_frames;
811
        *num_plays = info_ptr->num_plays;
812
        return (1);
813
    }
814
    
815
    return (0);
816
}
817
818
png_uint_32 PNGAPI
819
png_get_num_frames(png_structp png_ptr, png_infop info_ptr)
820
{
821
    png_debug(1, "in png_get_num_frames()\n");
822
    
823
    if (png_ptr != NULL && info_ptr != NULL)
824
        return (info_ptr->num_frames);
825
    return (0);
826
}
827
828
png_uint_32 PNGAPI
829
png_get_num_plays(png_structp png_ptr, png_infop info_ptr)
830
{
831
    png_debug(1, "in png_get_num_plays()\n");
832
    
833
    if (png_ptr != NULL && info_ptr != NULL)
834
        return (info_ptr->num_plays);
835
    return (0);
836
}
837
838
png_uint_32 PNGAPI
839
png_get_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr,
840
             png_uint_32 *width, png_uint_32 *height,
841
             png_uint_32 *x_offset, png_uint_32 *y_offset,
842
             png_uint_16 *delay_num, png_uint_16 *delay_den,
843
             png_byte *dispose_op, png_byte *blend_op)
844
{
845
    png_debug1(1, "in %s retrieval function\n", "fcTL");
846
    
847
    if (png_ptr != NULL && info_ptr != NULL &&
848
        (info_ptr->valid & PNG_INFO_fcTL) &&
849
        width != NULL && height != NULL && 
850
        x_offset != NULL && x_offset != NULL && 
851
        delay_num != NULL && delay_den != NULL &&
852
	dispose_op != NULL && blend_op != NULL)
853
    {
854
        *width = info_ptr->next_frame_width;
855
        *height = info_ptr->next_frame_height;
856
        *x_offset = info_ptr->next_frame_x_offset;
857
        *y_offset = info_ptr->next_frame_y_offset;
858
        *delay_num = info_ptr->next_frame_delay_num;
859
        *delay_den = info_ptr->next_frame_delay_den;
860
        *dispose_op = info_ptr->next_frame_dispose_op;
861
        *blend_op = info_ptr->next_frame_blend_op;
862
        return (1);
863
    }
864
    
865
    return (0);
866
}
867
868
png_uint_32 PNGAPI
869
png_get_next_frame_width(png_structp png_ptr, png_infop info_ptr)
870
{
871
    png_debug(1, "in png_get_next_frame_width()\n");
872
    
873
    if (png_ptr != NULL && info_ptr != NULL)
874
        return (info_ptr->next_frame_width);
875
    return (0);
876
}
877
878
png_uint_32 PNGAPI
879
png_get_next_frame_height(png_structp png_ptr, png_infop info_ptr)
880
{
881
    png_debug(1, "in png_get_next_frame_height()\n");
882
    
883
    if (png_ptr != NULL && info_ptr != NULL)
884
        return (info_ptr->next_frame_height);
885
    return (0);
886
}
887
888
png_uint_32 PNGAPI
889
png_get_next_frame_x_offset(png_structp png_ptr, png_infop info_ptr)
890
{
891
    png_debug(1, "in png_get_next_frame_x_offset()\n");
892
    
893
    if (png_ptr != NULL && info_ptr != NULL)
894
        return (info_ptr->next_frame_x_offset);
895
    return (0);
896
}
897
898
png_uint_32 PNGAPI
899
png_get_next_frame_y_offset(png_structp png_ptr, png_infop info_ptr)
900
{
901
    png_debug(1, "in png_get_next_frame_y_offset()\n");
902
    
903
    if (png_ptr != NULL && info_ptr != NULL)
904
        return (info_ptr->next_frame_y_offset);
905
    return (0);
906
}
907
908
png_uint_16 PNGAPI
909
png_get_next_frame_delay_num(png_structp png_ptr, png_infop info_ptr)
910
{
911
    png_debug(1, "in png_get_next_frame_delay_num()\n");
912
    
913
    if (png_ptr != NULL && info_ptr != NULL)
914
        return (info_ptr->next_frame_delay_num);
915
    return (0);
916
}
917
918
png_uint_16 PNGAPI
919
png_get_next_frame_delay_den(png_structp png_ptr, png_infop info_ptr)
920
{
921
    png_debug(1, "in png_get_next_frame_delay_den()\n");
922
    
923
    if (png_ptr != NULL && info_ptr != NULL)
924
        return (info_ptr->next_frame_delay_den);
925
    return (0);
926
}
927
928
png_byte PNGAPI
929
png_get_next_frame_dispose_op(png_structp png_ptr, png_infop info_ptr)
930
{
931
    png_debug(1, "in png_get_next_frame_dispose_op()\n");
932
    
933
    if (png_ptr != NULL && info_ptr != NULL)
934
        return (info_ptr->next_frame_dispose_op);
935
    return (0);
936
}
937
938
png_byte PNGAPI
939
png_get_next_frame_blend_op(png_structp png_ptr, png_infop info_ptr)
940
{
941
    png_debug(1, "in png_get_next_frame_blend_op()\n");
942
    
943
    if (png_ptr != NULL && info_ptr != NULL)
944
        return (info_ptr->next_frame_blend_op);
945
    return (0);
946
}
947
948
png_byte PNGAPI
949
png_get_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr)
950
{
951
    png_debug(1, "in png_first_frame_is_hidden()\n");
952
    
953
    if (png_ptr != NULL)
954
       return (png_byte)(png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN);
955
    
956
    return 0;
957
}
958
#endif /* PNG_APNG_SUPPORTED */
959
799
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
960
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
800
png_uint_32 PNGAPI
961
png_uint_32 PNGAPI
801
png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
962
png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
(-)libpng-1.2.31/png.c.orig (+3 lines)
Lines 51-56 Link Here
51
PNG_tIME;
51
PNG_tIME;
52
PNG_tRNS;
52
PNG_tRNS;
53
PNG_zTXt;
53
PNG_zTXt;
54
PNG_acTL;
55
PNG_fcTL;
56
PNG_fdAT;
54
57
55
#ifdef PNG_READ_SUPPORTED
58
#ifdef PNG_READ_SUPPORTED
56
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
59
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
(-)libpng-1.2.31/png.h.orig (+167 lines)
Lines 974-979 Link Here
974
   png_fixed_point int_y_blue;
974
   png_fixed_point int_y_blue;
975
#endif
975
#endif
976
976
977
#if defined(PNG_APNG_SUPPORTED)
978
   png_uint_32 num_frames; /* including default image */
979
   png_uint_32 num_plays;
980
   png_uint_32 next_frame_width;
981
   png_uint_32 next_frame_height;
982
   png_uint_32 next_frame_x_offset;
983
   png_uint_32 next_frame_y_offset;
984
   png_uint_16 next_frame_delay_num;
985
   png_uint_16 next_frame_delay_den;
986
   png_byte next_frame_dispose_op;
987
   png_byte next_frame_blend_op;
988
#endif
989
977
} png_info;
990
} png_info;
978
991
979
typedef png_info FAR * png_infop;
992
typedef png_info FAR * png_infop;
Lines 1075-1080 Link Here
1075
#define PNG_INFO_sPLT 0x2000   /* ESR, 1.0.6 */
1088
#define PNG_INFO_sPLT 0x2000   /* ESR, 1.0.6 */
1076
#define PNG_INFO_sCAL 0x4000   /* ESR, 1.0.6 */
1089
#define PNG_INFO_sCAL 0x4000   /* ESR, 1.0.6 */
1077
#define PNG_INFO_IDAT 0x8000L  /* ESR, 1.0.6 */
1090
#define PNG_INFO_IDAT 0x8000L  /* ESR, 1.0.6 */
1091
#define PNG_INFO_acTL 0x10000L
1092
#define PNG_INFO_fcTL 0x20000L
1078
1093
1079
/* This is used for the transformation routines, as some of them
1094
/* This is used for the transformation routines, as some of them
1080
 * change these values for the row.  It also should enable using
1095
 * change these values for the row.  It also should enable using
Lines 1115-1120 Link Here
1115
typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop));
1130
typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop));
1116
typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep,
1131
typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep,
1117
   png_uint_32, int));
1132
   png_uint_32, int));
1133
#if defined(PNG_APNG_SUPPORTED)
1134
typedef void (PNGAPI *png_progressive_frame_ptr) PNGARG((png_structp, 
1135
   png_uint_32));
1136
#endif
1118
#endif
1137
#endif
1119
1138
1120
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
1139
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
Lines 1446-1451 Link Here
1446
   png_uint_32 user_height_max;
1465
   png_uint_32 user_height_max;
1447
#endif
1466
#endif
1448
1467
1468
#if defined(PNG_APNG_SUPPORTED)
1469
   png_uint_32 apng_flags;
1470
   png_uint_32 next_seq_num;         /* next fcTL/fdAT chunk sequence number */
1471
   png_uint_32 first_frame_width;
1472
   png_uint_32 first_frame_height;
1473
1474
#if defined(PNG_READ_APNG_SUPPORTED)
1475
   png_uint_32 num_frames_read;      /* incremented after all image data of */
1476
                                     /* a frame is read */
1477
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
1478
   png_progressive_frame_ptr frame_info_fn; /* frame info read callback */
1479
   png_progressive_frame_ptr frame_end_fn;  /* frame data read callback */
1480
#endif
1481
#endif
1482
1483
#if defined(PNG_WRITE_APNG_SUPPORTED)
1484
   png_uint_32 num_frames_to_write;
1485
   png_uint_32 num_frames_written;
1486
#endif
1487
#endif
1488
1489
/* For png_struct.apng_flags: */
1490
#define PNG_FIRST_FRAME_HIDDEN       0x0001
1491
1492
/* dispose_op flags from inside fcTL */
1493
#define PNG_DISPOSE_OP_NONE        0x00
1494
#define PNG_DISPOSE_OP_BACKGROUND  0x01
1495
#define PNG_DISPOSE_OP_PREVIOUS    0x02
1496
1497
/* blend_op flags from inside fcTL */
1498
#define PNG_BLEND_OP_SOURCE        0x00
1499
#define PNG_BLEND_OP_OVER          0x01
1500
1449
/* New member added in libpng-1.0.25 and 1.2.17 */
1501
/* New member added in libpng-1.0.25 and 1.2.17 */
1450
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
1502
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
1451
   /* storage for unknown chunk that the library doesn't recognize. */
1503
   /* storage for unknown chunk that the library doesn't recognize. */
Lines 1779-1784 Link Here
1779
extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr,
1831
extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr,
1780
   png_bytepp image));
1832
   png_bytepp image));
1781
1833
1834
#if defined(PNG_WRITE_APNG_SUPPORTED)
1835
extern PNG_EXPORT (void,png_write_frame_head) PNGARG((png_structp png_ptr,
1836
   png_infop png_info, png_bytepp row_pointers,
1837
   png_uint_32 width, png_uint_32 height,
1838
   png_uint_32 x_offset, png_uint_32 y_offset, 
1839
   png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
1840
   png_byte blend_op));
1841
1842
extern PNG_EXPORT (void,png_write_frame_tail) PNGARG((png_structp png_ptr,
1843
   png_infop png_info));
1844
#endif
1845
   
1782
/* writes the end of the PNG file. */
1846
/* writes the end of the PNG file. */
1783
extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr,
1847
extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr,
1784
   png_infop info_ptr));
1848
   png_infop info_ptr));
Lines 2027-2032 Link Here
2027
   png_voidp progressive_ptr,
2091
   png_voidp progressive_ptr,
2028
   png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
2092
   png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
2029
   png_progressive_end_ptr end_fn));
2093
   png_progressive_end_ptr end_fn));
2094
#if defined(PNG_READ_APNG_SUPPORTED)
2095
extern PNG_EXPORT(void,png_set_progressive_frame_fn) PNGARG((png_structp png_ptr,
2096
   png_progressive_frame_ptr frame_info_fn,
2097
   png_progressive_frame_ptr frame_end_fn));
2098
#endif
2030
2099
2031
/* returns the user pointer associated with the push read functions */
2100
/* returns the user pointer associated with the push read functions */
2032
extern PNG_EXPORT(png_voidp,png_get_progressive_ptr)
2101
extern PNG_EXPORT(png_voidp,png_get_progressive_ptr)
Lines 2464-2469 Link Here
2464
#endif
2533
#endif
2465
#endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */
2534
#endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */
2466
2535
2536
#if defined(PNG_APNG_SUPPORTED)
2537
extern PNG_EXPORT(png_uint_32,png_get_acTL) PNGARG((png_structp png_ptr,
2538
   png_infop info_ptr, png_uint_32 *num_frames, png_uint_32 *num_plays));
2539
extern PNG_EXPORT(png_uint_32,png_set_acTL) PNGARG((png_structp png_ptr, 
2540
   png_infop info_ptr, png_uint_32 num_frames, png_uint_32 num_plays));
2541
extern PNG_EXPORT(png_uint_32,png_get_num_frames) PNGARG((png_structp png_ptr,
2542
   png_infop info_ptr));
2543
extern PNG_EXPORT(png_uint_32,png_get_num_plays) 
2544
   PNGARG((png_structp png_ptr, png_infop info_ptr));
2545
2546
extern PNG_EXPORT(png_uint_32,png_get_next_frame_fcTL) 
2547
   PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 *width, 
2548
   png_uint_32 *height, png_uint_32 *x_offset, png_uint_32 *y_offset, 
2549
   png_uint_16 *delay_num, png_uint_16 *delay_den, png_byte *dispose_op,
2550
   png_byte *blend_op));
2551
extern PNG_EXPORT(png_uint_32,png_set_next_frame_fcTL) 
2552
   PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 width, 
2553
   png_uint_32 height, png_uint_32 x_offset, png_uint_32 y_offset, 
2554
   png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
2555
   png_byte blend_op));
2556
extern PNG_EXPORT(void,png_ensure_fcTL_is_valid)
2557
   PNGARG((png_structp png_ptr,
2558
   png_uint_32 width, png_uint_32 height,
2559
   png_uint_32 x_offset, png_uint_32 y_offset,
2560
   png_uint_16 delay_num, png_uint_16 delay_den,
2561
   png_byte dispose_op, png_byte blend_op));
2562
extern PNG_EXPORT(png_uint_32,png_get_next_frame_width)
2563
   PNGARG((png_structp png_ptr, png_infop info_ptr));
2564
extern PNG_EXPORT(png_uint_32,png_get_next_frame_height)
2565
   PNGARG((png_structp png_ptr, png_infop info_ptr));
2566
extern PNG_EXPORT(png_uint_32,png_get_next_frame_x_offset)
2567
   PNGARG((png_structp png_ptr, png_infop info_ptr));
2568
extern PNG_EXPORT(png_uint_32,png_get_next_frame_y_offset)
2569
   PNGARG((png_structp png_ptr, png_infop info_ptr));
2570
extern PNG_EXPORT(png_uint_16,png_get_next_frame_delay_num)
2571
   PNGARG((png_structp png_ptr, png_infop info_ptr));
2572
extern PNG_EXPORT(png_uint_16,png_get_next_frame_delay_den)
2573
   PNGARG((png_structp png_ptr, png_infop info_ptr));
2574
extern PNG_EXPORT(png_byte,png_get_next_frame_dispose_op)
2575
   PNGARG((png_structp png_ptr, png_infop info_ptr));
2576
extern PNG_EXPORT(png_byte,png_get_next_frame_blend_op)
2577
   PNGARG((png_structp png_ptr, png_infop info_ptr));
2578
extern PNG_EXPORT(png_byte,png_get_first_frame_is_hidden)
2579
   PNGARG((png_structp png_ptr, png_infop info_ptr));
2580
extern PNG_EXPORT(png_uint_32,png_set_first_frame_is_hidden)
2581
   PNGARG((png_structp png_ptr, png_infop info_ptr, png_byte is_hidden));
2582
#endif /* PNG_APNG_SUPPORTED */
2583
2584
#if defined(PNG_READ_APNG_SUPPORTED)
2585
extern PNG_EXPORT(void,png_read_frame_head) PNGARG((png_structp png_ptr,
2586
   png_infop info_ptr));
2587
#endif
2588
2467
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
2589
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
2468
/* provide a list of chunks and how they are to be handled, if the built-in
2590
/* provide a list of chunks and how they are to be handled, if the built-in
2469
   handling or default unknown chunk handling is not desired.  Any chunks not
2591
   handling or default unknown chunk handling is not desired.  Any chunks not
Lines 2771-2776 Link Here
2771
#define PNG_BACKGROUND_IS_GRAY     0x800
2893
#define PNG_BACKGROUND_IS_GRAY     0x800
2772
#define PNG_HAVE_PNG_SIGNATURE    0x1000
2894
#define PNG_HAVE_PNG_SIGNATURE    0x1000
2773
#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */
2895
#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */
2896
#define PNG_HAVE_acTL             0x4000
2897
#define PNG_HAVE_fcTL             0x8000L
2774
2898
2775
/* flags for the transformations the PNG library does on the image data */
2899
/* flags for the transformations the PNG library does on the image data */
2776
#define PNG_BGR                0x0001
2900
#define PNG_BGR                0x0001
Lines 2911-2916 Link Here
2911
#define PNG_tIME png_byte png_tIME[5] = {116,  73,  77,  69, '\0'}
3035
#define PNG_tIME png_byte png_tIME[5] = {116,  73,  77,  69, '\0'}
2912
#define PNG_tRNS png_byte png_tRNS[5] = {116,  82,  78,  83, '\0'}
3036
#define PNG_tRNS png_byte png_tRNS[5] = {116,  82,  78,  83, '\0'}
2913
#define PNG_zTXt png_byte png_zTXt[5] = {122,  84,  88, 116, '\0'}
3037
#define PNG_zTXt png_byte png_zTXt[5] = {122,  84,  88, 116, '\0'}
3038
#define PNG_acTL png_byte png_acTL[5] = { 97,  99,  84,  76, '\0'}
3039
#define PNG_fcTL png_byte png_fcTL[5] = {102,  99,  84,  76, '\0'}
3040
#define PNG_fdAT png_byte png_fdAT[5] = {102, 100,  65,  84, '\0'}
2914
3041
2915
#ifdef PNG_USE_GLOBAL_ARRAYS
3042
#ifdef PNG_USE_GLOBAL_ARRAYS
2916
PNG_EXPORT_VAR (png_byte FARDATA) png_IHDR[5];
3043
PNG_EXPORT_VAR (png_byte FARDATA) png_IHDR[5];
Lines 2934-2939 Link Here
2934
PNG_EXPORT_VAR (png_byte FARDATA) png_tIME[5];
3061
PNG_EXPORT_VAR (png_byte FARDATA) png_tIME[5];
2935
PNG_EXPORT_VAR (png_byte FARDATA) png_tRNS[5];
3062
PNG_EXPORT_VAR (png_byte FARDATA) png_tRNS[5];
2936
PNG_EXPORT_VAR (png_byte FARDATA) png_zTXt[5];
3063
PNG_EXPORT_VAR (png_byte FARDATA) png_zTXt[5];
3064
PNG_EXPORT_VAR (png_byte FARDATA) png_acTL[5];
3065
PNG_EXPORT_VAR (png_byte FARDATA) png_fcTL[5];
3066
PNG_EXPORT_VAR (png_byte FARDATA) png_fdAT[5];
2937
#endif /* PNG_USE_GLOBAL_ARRAYS */
3067
#endif /* PNG_USE_GLOBAL_ARRAYS */
2938
3068
2939
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
3069
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
Lines 3208-3213 Link Here
3208
#endif
3338
#endif
3209
#endif
3339
#endif
3210
3340
3341
#if defined(PNG_WRITE_APNG_SUPPORTED)
3342
PNG_EXTERN void png_write_acTL PNGARG((png_structp png_ptr,
3343
   png_uint_32 num_frames, png_uint_32 num_plays));
3344
3345
PNG_EXTERN void png_write_fcTL PNGARG((png_structp png_ptr, 
3346
   png_uint_32 width, png_uint_32 height, 
3347
   png_uint_32 x_offset, png_uint_32 y_offset, 
3348
   png_uint_16 delay_num, png_uint_16 delay_den,
3349
   png_byte dispose_op, png_byte blend_op));
3350
#endif
3351
3211
/* Called when finished processing a row of data */
3352
/* Called when finished processing a row of data */
3212
PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr));
3353
PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr));
3213
3354
Lines 3259-3264 Link Here
3259
PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr,
3400
PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr,
3260
   png_infop info_ptr));
3401
   png_infop info_ptr));
3261
3402
3403
#if defined(PNG_READ_APNG_SUPPORTED)
3404
/* private, reset some things to become ready for reading next frame */
3405
PNG_EXTERN void png_read_reset PNGARG((png_structp png_ptr));
3406
PNG_EXTERN void png_read_reinit PNGARG((png_structp png_ptr,
3407
   png_infop info_ptr));
3408
PNG_EXTERN void png_progressive_read_reset PNGARG((png_structp png_ptr));
3409
#endif
3410
#if defined(PNG_WRITE_APNG_SUPPORTED)
3411
/* private, reset some things to become ready for writing next frame */
3412
PNG_EXTERN void png_write_reset PNGARG((png_structp png_ptr));
3413
PNG_EXTERN void png_write_reinit PNGARG((png_structp png_ptr, 
3414
   png_infop info_ptr, png_uint_32 width, png_uint_32 height));
3415
#endif
3416
3262
/* these are the functions that do the transformations */
3417
/* these are the functions that do the transformations */
3263
#if defined(PNG_READ_FILLER_SUPPORTED)
3418
#if defined(PNG_READ_FILLER_SUPPORTED)
3264
PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info,
3419
PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info,
Lines 3474-3479 Link Here
3474
   png_uint_32 length));
3629
   png_uint_32 length));
3475
#endif
3630
#endif
3476
3631
3632
#if defined(PNG_READ_APNG_SUPPORTED)
3633
PNG_EXTERN void png_handle_acTL PNGARG((png_structp png_ptr, png_infop info_ptr,
3634
   png_uint_32 length));
3635
PNG_EXTERN void png_handle_fcTL PNGARG((png_structp png_ptr, png_infop info_ptr,
3636
   png_uint_32 length));
3637
PNG_EXTERN void png_have_info PNGARG((png_structp png_ptr, png_infop info_ptr));
3638
PNG_EXTERN void png_handle_fdAT PNGARG((png_structp png_ptr, png_infop info_ptr,
3639
   png_uint_32 length));
3640
PNG_EXTERN void png_ensure_sequence_number PNGARG((png_structp png_ptr, 
3641
   png_uint_32 length));
3642
#endif
3643
3477
PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr,
3644
PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr,
3478
   png_infop info_ptr, png_uint_32 length));
3645
   png_infop info_ptr, png_uint_32 length));
3479
3646
(-)libpng-1.2.31/pngwrite.c.orig (+43 lines)
Lines 263-268 Link Here
263
      }
263
      }
264
   }
264
   }
265
#endif
265
#endif
266
#if defined(PNG_WRITE_APNG_SUPPORTED)
267
   if (info_ptr->valid & PNG_INFO_acTL)
268
      png_write_acTL(png_ptr, info_ptr->num_frames, info_ptr->num_plays);
269
#endif
266
#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED)
270
#if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED)
267
   if (info_ptr->unknown_chunks_num)
271
   if (info_ptr->unknown_chunks_num)
268
   {
272
   {
Lines 301-306 Link Here
301
      return;
305
      return;
302
   if (!(png_ptr->mode & PNG_HAVE_IDAT))
306
   if (!(png_ptr->mode & PNG_HAVE_IDAT))
303
      png_error(png_ptr, "No IDATs written into file");
307
      png_error(png_ptr, "No IDATs written into file");
308
#if defined(PNG_WRITE_APNG_SUPPORTED)
309
   if (png_ptr->num_frames_written != png_ptr->num_frames_to_write)
310
      png_error(png_ptr, "Not enough frames written");
311
#endif
304
312
305
   /* see if user wants us to write information chunks */
313
   /* see if user wants us to write information chunks */
306
   if (info_ptr != NULL)
314
   if (info_ptr != NULL)
Lines 1544-1547 Link Here
1544
   params = params;
1552
   params = params;
1545
}
1553
}
1546
#endif
1554
#endif
1555
1556
#if defined(PNG_WRITE_APNG_SUPPORTED)
1557
void PNGAPI
1558
png_write_frame_head(png_structp png_ptr, png_infop info_ptr,
1559
    png_bytepp row_pointers, png_uint_32 width, png_uint_32 height, 
1560
    png_uint_32 x_offset, png_uint_32 y_offset, 
1561
    png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
1562
    png_byte blend_op)
1563
{
1564
    png_debug(1, "in png_write_frame_head\n");
1565
    
1566
    /* there is a chance this has been set after png_write_info was called,
1567
    * so it would be set but not written. is there a way to be sure? */
1568
    if (!(info_ptr->valid & PNG_INFO_acTL))
1569
        png_error(png_ptr, "png_write_frame_head(): acTL not set");
1570
    
1571
    png_write_reset(png_ptr);
1572
    
1573
    png_write_reinit(png_ptr, info_ptr, width, height);
1574
    
1575
    if ( !(png_ptr->num_frames_written == 0 && 
1576
           (png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN) ) )
1577
        png_write_fcTL(png_ptr, width, height, x_offset, y_offset, 
1578
                       delay_num, delay_den, dispose_op, blend_op);
1579
}
1580
1581
void PNGAPI
1582
png_write_frame_tail(png_structp png_ptr, png_infop png_info)
1583
{
1584
    png_debug(1, "in png_write_frame_tail\n");
1585
    
1586
    png_ptr->num_frames_written++;
1587
}
1588
#endif /* PNG_WRITE_APNG_SUPPORTED */
1589
1547
#endif /* PNG_WRITE_SUPPORTED */
1590
#endif /* PNG_WRITE_SUPPORTED */
(-)libpng-1.2.31/pngconf.h.orig (+10 lines)
Lines 925-930 Link Here
925
#  define PNG_READ_zTXt_SUPPORTED
925
#  define PNG_READ_zTXt_SUPPORTED
926
#  define PNG_zTXt_SUPPORTED
926
#  define PNG_zTXt_SUPPORTED
927
#endif
927
#endif
928
#ifndef PNG_NO_READ_APNG
929
#  define PNG_READ_APNG_SUPPORTED
930
#  define PNG_APNG_SUPPORTED
931
#endif
928
#ifndef PNG_NO_READ_UNKNOWN_CHUNKS
932
#ifndef PNG_NO_READ_UNKNOWN_CHUNKS
929
#  define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
933
#  define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
930
#  ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
934
#  ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
Lines 1067-1072 Link Here
1067
#    define PNG_zTXt_SUPPORTED
1071
#    define PNG_zTXt_SUPPORTED
1068
#  endif
1072
#  endif
1069
#endif
1073
#endif
1074
#ifndef PNG_NO_WRITE_APNG
1075
#  define PNG_WRITE_APNG_SUPPORTED
1076
#  ifndef PNG_APNG_SUPPORTED
1077
#    define PNG_APNG_SUPPORTED
1078
#  endif
1079
#endif
1070
#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS
1080
#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS
1071
#  define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
1081
#  define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
1072
#  ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
1082
#  ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
(-)libpng-1.2.31/pngpread.c.orig (-4 / +197 lines)
Lines 191-196 Link Here
191
#if defined(PNG_READ_zTXt_SUPPORTED)
191
#if defined(PNG_READ_zTXt_SUPPORTED)
192
      PNG_CONST PNG_zTXt;
192
      PNG_CONST PNG_zTXt;
193
#endif
193
#endif
194
#if defined(PNG_READ_APNG_SUPPORTED)
195
      PNG_CONST PNG_acTL;
196
      PNG_CONST PNG_fcTL;
197
      PNG_CONST PNG_fdAT;
198
#endif
194
#endif /* PNG_USE_LOCAL_ARRAYS */
199
#endif /* PNG_USE_LOCAL_ARRAYS */
195
   /* First we make sure we have enough data for the 4 byte chunk name
200
   /* First we make sure we have enough data for the 4 byte chunk name
196
    * and the 4 byte chunk length before proceeding with decoding the
201
    * and the 4 byte chunk length before proceeding with decoding the
Lines 215-221 Link Here
215
      png_check_chunk_name(png_ptr, png_ptr->chunk_name);
220
      png_check_chunk_name(png_ptr, png_ptr->chunk_name);
216
      png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
221
      png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
217
   }
222
   }
218
223
   
224
#if defined(PNG_READ_APNG_SUPPORTED)
225
   if (png_ptr->num_frames_read > 0 && 
226
       png_ptr->num_frames_read < info_ptr->num_frames)
227
   {
228
      if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
229
      {
230
         /* discard trailing IDATs for the first frame */
231
         if (png_ptr->mode & PNG_HAVE_fcTL || png_ptr->num_frames_read > 1)
232
            png_error(png_ptr, "out of place IDAT");
233
         
234
         if (png_ptr->push_length + 4 > png_ptr->buffer_size)
235
         {
236
            png_push_save_buffer(png_ptr);
237
            return;
238
         }
239
         png_push_crc_skip(png_ptr, png_ptr->push_length);
240
         png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
241
         return;
242
      }
243
      else if (!png_memcmp(png_ptr->chunk_name, png_fdAT, 4))
244
      {
245
         if (png_ptr->buffer_size < 4)
246
         {
247
            png_push_save_buffer(png_ptr);
248
            return;
249
         }
250
         png_ensure_sequence_number(png_ptr, 4);
251
         
252
         if (!(png_ptr->mode & PNG_HAVE_fcTL))
253
         {
254
            /* discard trailing fdATs for frames other than the first */
255
            if (png_ptr->num_frames_read < 2)
256
               png_error(png_ptr, "out of place fdAT");
257
            
258
            if (png_ptr->push_length + 4 > png_ptr->buffer_size)
259
            {
260
               png_push_save_buffer(png_ptr);
261
               return;
262
            }
263
            png_push_crc_skip(png_ptr, png_ptr->push_length);
264
            png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
265
            return;
266
         }
267
         else
268
         {
269
            /* frame data follows */
270
            png_ptr->idat_size = png_ptr->push_length - 4;
271
            png_ptr->mode |= PNG_HAVE_IDAT;
272
            png_ptr->process_mode = PNG_READ_IDAT_MODE;
273
            
274
            return;
275
         }
276
      }
277
      else if(!png_memcmp(png_ptr->chunk_name, png_fcTL, 4))
278
      {
279
         if (png_ptr->push_length + 4 > png_ptr->buffer_size)
280
         {
281
            png_push_save_buffer(png_ptr);
282
            return;
283
         }
284
         
285
         png_read_reset(png_ptr);
286
         png_ptr->mode &= ~PNG_HAVE_fcTL;
287
         
288
         png_handle_fcTL(png_ptr, info_ptr, png_ptr->push_length);
289
         
290
         if (!(png_ptr->mode & PNG_HAVE_fcTL))
291
            png_error(png_ptr, "missing required fcTL chunk");
292
         
293
         png_read_reinit(png_ptr, info_ptr);
294
         png_progressive_read_reset(png_ptr);
295
         
296
         if (png_ptr->frame_info_fn != NULL)
297
            (*(png_ptr->frame_info_fn))(png_ptr, png_ptr->num_frames_read);
298
         
299
         png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
300
         
301
         return;
302
      }
303
      else
304
      {
305
         if (png_ptr->push_length + 4 > png_ptr->buffer_size)
306
         {
307
            png_push_save_buffer(png_ptr);
308
            return;
309
         }
310
         png_warning(png_ptr, "Skipped (ignored) a chunk "
311
                              "between APNG chunks");
312
         png_push_crc_skip(png_ptr, png_ptr->push_length);
313
         png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
314
         return;
315
      }
316
      
317
      return;
318
   }
319
#endif /* PNG_READ_APNG_SUPPORTED */
320
   
219
   if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
321
   if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
220
     if (png_ptr->mode & PNG_AFTER_IDAT)
322
     if (png_ptr->mode & PNG_AFTER_IDAT)
221
        png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
323
        png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
Lines 297-302 Link Here
297
            png_error(png_ptr, "Too many IDAT's found");
399
            png_error(png_ptr, "Too many IDAT's found");
298
      }
400
      }
299
401
402
#if defined(PNG_READ_APNG_SUPPORTED)
403
      png_have_info(png_ptr, info_ptr);
404
#endif
300
      png_ptr->idat_size = png_ptr->push_length;
405
      png_ptr->idat_size = png_ptr->push_length;
301
      png_ptr->mode |= PNG_HAVE_IDAT;
406
      png_ptr->mode |= PNG_HAVE_IDAT;
302
      png_ptr->process_mode = PNG_READ_IDAT_MODE;
407
      png_ptr->process_mode = PNG_READ_IDAT_MODE;
Lines 492-497 Link Here
492
      png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
597
      png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
493
   }
598
   }
494
#endif
599
#endif
600
#if defined(PNG_READ_APNG_SUPPORTED)
601
   else if (!png_memcmp(png_ptr->chunk_name, png_acTL, 4))
602
   {
603
      if (png_ptr->push_length + 4 > png_ptr->buffer_size)
604
      {
605
         png_push_save_buffer(png_ptr);
606
         return;
607
      }
608
      png_handle_acTL(png_ptr, info_ptr, png_ptr->push_length);
609
   }
610
   else if (!png_memcmp(png_ptr->chunk_name, png_fcTL, 4))
611
   {
612
      if (png_ptr->push_length + 4 > png_ptr->buffer_size)
613
      {
614
         png_push_save_buffer(png_ptr);
615
         return;
616
      }
617
      png_handle_fcTL(png_ptr, info_ptr, png_ptr->push_length);
618
   }
619
   else if (!png_memcmp(png_ptr->chunk_name, png_fdAT, 4))
620
   {
621
      if (png_ptr->push_length + 4 > png_ptr->buffer_size)
622
      {
623
         png_push_save_buffer(png_ptr);
624
         return;
625
      }
626
      png_handle_fdAT(png_ptr, info_ptr, png_ptr->push_length);
627
   }
628
#endif /* PNG_READ_APNG_SUPPORTED */
495
   else
629
   else
496
   {
630
   {
497
      if (png_ptr->push_length + 4 > png_ptr->buffer_size)
631
      if (png_ptr->push_length + 4 > png_ptr->buffer_size)
Lines 662-674 Link Here
662
png_push_read_IDAT(png_structp png_ptr)
796
png_push_read_IDAT(png_structp png_ptr)
663
{
797
{
664
#ifdef PNG_USE_LOCAL_ARRAYS
798
#ifdef PNG_USE_LOCAL_ARRAYS
665
   PNG_CONST PNG_IDAT;
799
   PNG_IDAT;
800
#if defined(PNG_READ_APNG_SUPPORTED)
801
   PNG_fdAT;
802
   PNG_IEND;
803
#endif
666
#endif
804
#endif
667
   if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
805
   if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
668
   {
806
   {
669
      png_byte chunk_length[4];
807
      png_byte chunk_length[4];
670
808
671
      if (png_ptr->buffer_size < 8)
809
      if (png_ptr->buffer_size < 12)
672
      {
810
      {
673
         png_push_save_buffer(png_ptr);
811
         png_push_save_buffer(png_ptr);
674
         return;
812
         return;
Lines 680-694 Link Here
680
      png_crc_read(png_ptr, png_ptr->chunk_name, 4);
818
      png_crc_read(png_ptr, png_ptr->chunk_name, 4);
681
      png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
819
      png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
682
820
683
      if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
821
#if defined(PNG_READ_APNG_SUPPORTED)
822
      if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_fdAT, 4)
823
          && png_ptr->num_frames_read > 0)
824
      {
825
          if (png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)
826
          {
827
              png_ptr->process_mode = PNG_READ_CHUNK_MODE;
828
              if (png_ptr->frame_end_fn != NULL)
829
                 (*(png_ptr->frame_end_fn))(png_ptr, png_ptr->num_frames_read);
830
              png_ptr->num_frames_read++;
831
              return;
832
          }
833
          else
834
          {
835
              if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
836
                  png_error(png_ptr, "Not enough image data");
837
              if (png_ptr->push_length + 4 > png_ptr->buffer_size)
838
              {
839
                 png_push_save_buffer(png_ptr);
840
                 return;
841
              }
842
              png_warning(png_ptr, "Skipping (ignoring) a chunk between "
843
                                   "APNG chunks");
844
              png_crc_finish(png_ptr, png_ptr->push_length);
845
              png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
846
              return;
847
          }
848
      }
849
      else 
850
#endif
851
      if ( png_memcmp(png_ptr->chunk_name, png_IDAT, 4)
852
                && (png_ptr->num_frames_read == 0) )
684
      {
853
      {
685
         png_ptr->process_mode = PNG_READ_CHUNK_MODE;
854
         png_ptr->process_mode = PNG_READ_CHUNK_MODE;
686
         if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
855
         if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
687
            png_error(png_ptr, "Not enough compressed data");
856
            png_error(png_ptr, "Not enough compressed data");
857
#if defined(PNG_READ_APNG_SUPPORTED)
858
         if (png_ptr->frame_end_fn != NULL)
859
            (*(png_ptr->frame_end_fn))(png_ptr, png_ptr->num_frames_read);
860
         png_ptr->num_frames_read++;
861
#endif
688
         return;
862
         return;
689
      }
863
      }
690
864
691
      png_ptr->idat_size = png_ptr->push_length;
865
      png_ptr->idat_size = png_ptr->push_length;
866
      
867
#if defined(PNG_READ_APNG_SUPPORTED)
868
      if(png_ptr->num_frames_read > 0)
869
      {
870
         png_ensure_sequence_number(png_ptr, 4);
871
         png_ptr->idat_size -= 4;
872
      }
873
#endif
692
   }
874
   }
693
   if (png_ptr->idat_size && png_ptr->save_buffer_size)
875
   if (png_ptr->idat_size && png_ptr->save_buffer_size)
694
   {
876
   {
Lines 1585-1590 Link Here
1585
   png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer);
1767
   png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer);
1586
}
1768
}
1587
1769
1770
#if defined(PNG_READ_APNG_SUPPORTED)
1771
void PNGAPI
1772
png_set_progressive_frame_fn(png_structp png_ptr,
1773
   png_progressive_frame_ptr frame_info_fn,
1774
   png_progressive_frame_ptr frame_end_fn)
1775
{
1776
   png_ptr->frame_info_fn = frame_info_fn;
1777
   png_ptr->frame_end_fn = frame_end_fn;
1778
}
1779
#endif
1780
1588
png_voidp PNGAPI
1781
png_voidp PNGAPI
1589
png_get_progressive_ptr(png_structp png_ptr)
1782
png_get_progressive_ptr(png_structp png_ptr)
1590
{
1783
{
(-)libpng-1.2.31/pngset.c.orig (+140 lines)
Lines 363-368 Link Here
363
      info_ptr->rowbytes = (png_size_t)0;
363
      info_ptr->rowbytes = (png_size_t)0;
364
   else
364
   else
365
      info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width);
365
      info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width);
366
   
367
#if defined(PNG_APNG_SUPPORTED)
368
   /* for non-animated png. this may be overritten from an acTL chunk later */
369
   info_ptr->num_frames = 1;
370
#endif
366
}
371
}
367
372
368
#if defined(PNG_oFFs_SUPPORTED)
373
#if defined(PNG_oFFs_SUPPORTED)
Lines 1043-1048 Link Here
1043
}
1048
}
1044
#endif /* PNG_sPLT_SUPPORTED */
1049
#endif /* PNG_sPLT_SUPPORTED */
1045
1050
1051
#if defined(PNG_APNG_SUPPORTED)
1052
png_uint_32 PNGAPI
1053
png_set_acTL(png_structp png_ptr, png_infop info_ptr, 
1054
    png_uint_32 num_frames, png_uint_32 num_plays)
1055
{
1056
    png_debug1(1, "in %s storage function\n", "acTL");
1057
1058
    if (png_ptr == NULL || info_ptr == NULL)
1059
    {
1060
        png_warning(png_ptr, 
1061
                    "Call to png_set_acTL() with NULL png_ptr "
1062
                    "or info_ptr ignored");
1063
        return (0);
1064
    }
1065
    if (num_frames == 0)
1066
    {
1067
        png_warning(png_ptr, 
1068
                    "Ignoring attempt to set acTL with num_frames zero");
1069
        return (0);
1070
    }
1071
    if (num_frames > PNG_UINT_31_MAX)
1072
    {
1073
        png_warning(png_ptr, 
1074
                    "Ignoring attempt to set acTL with num_frames > 2^31-1");
1075
        return (0);
1076
    }
1077
    if (num_plays > PNG_UINT_31_MAX)
1078
    {
1079
        png_warning(png_ptr, 
1080
                    "Ignoring attempt to set acTL with num_plays "
1081
                    "> 2^31-1");
1082
        return (0);
1083
    }
1084
    
1085
    info_ptr->num_frames = num_frames;
1086
    info_ptr->num_plays = num_plays;
1087
    
1088
    info_ptr->valid |= PNG_INFO_acTL;
1089
    
1090
    return (1);
1091
}
1092
1093
/* delay_num and delay_den can hold any 16-bit values including zero */
1094
png_uint_32 PNGAPI
1095
png_set_next_frame_fcTL(png_structp png_ptr, png_infop info_ptr, 
1096
    png_uint_32 width, png_uint_32 height,
1097
    png_uint_32 x_offset, png_uint_32 y_offset,
1098
    png_uint_16 delay_num, png_uint_16 delay_den,
1099
    png_byte dispose_op, png_byte blend_op)
1100
{
1101
    png_debug1(1, "in %s storage function\n", "fcTL");
1102
1103
    if (png_ptr == NULL || info_ptr == NULL)
1104
    {
1105
        png_warning(png_ptr, 
1106
                    "Call to png_set_fcTL() with NULL png_ptr or info_ptr "
1107
                    "ignored");
1108
        return (0);
1109
    }
1110
    
1111
    png_ensure_fcTL_is_valid(png_ptr, width, height, x_offset, y_offset, 
1112
                             delay_num, delay_den, dispose_op, blend_op);
1113
    
1114
    info_ptr->next_frame_width = width;
1115
    info_ptr->next_frame_height = height;
1116
    info_ptr->next_frame_x_offset = x_offset;
1117
    info_ptr->next_frame_y_offset = y_offset;
1118
    info_ptr->next_frame_delay_num = delay_num;
1119
    info_ptr->next_frame_delay_den = delay_den;
1120
    info_ptr->next_frame_dispose_op = dispose_op;
1121
    info_ptr->next_frame_blend_op = blend_op;
1122
    
1123
    info_ptr->valid |= PNG_INFO_fcTL;
1124
    
1125
    return (1);
1126
}
1127
1128
void /* PRIVATE */
1129
png_ensure_fcTL_is_valid(png_structp png_ptr, 
1130
    png_uint_32 width, png_uint_32 height,
1131
    png_uint_32 x_offset, png_uint_32 y_offset,
1132
    png_uint_16 delay_num, png_uint_16 delay_den,
1133
    png_byte dispose_op, png_byte blend_op)
1134
{
1135
    if (width + x_offset > png_ptr->first_frame_width || 
1136
        height + y_offset > png_ptr->first_frame_height)
1137
        png_error(png_ptr, "dimensions of a frame are greater than"
1138
                           "the ones in IHDR");
1139
    if (width > PNG_UINT_31_MAX)
1140
        png_error(png_ptr, "invalid width in fcTL (> 2^31-1)");
1141
    if (height > PNG_UINT_31_MAX)
1142
        png_error(png_ptr, "invalid height in fcTL (> 2^31-1)");
1143
    if (x_offset > PNG_UINT_31_MAX)
1144
        png_error(png_ptr, "invalid x_offset in fcTL (> 2^31-1)");
1145
    if (y_offset > PNG_UINT_31_MAX)
1146
        png_error(png_ptr, "invalid y_offset in fcTL (> 2^31-1)");
1147
1148
    if (dispose_op != PNG_DISPOSE_OP_NONE &&
1149
	dispose_op != PNG_DISPOSE_OP_BACKGROUND &&
1150
	dispose_op != PNG_DISPOSE_OP_PREVIOUS)
1151
        png_error(png_ptr, "invalid dispose_op in fcTL");
1152
1153
    if (blend_op != PNG_BLEND_OP_SOURCE &&
1154
	blend_op != PNG_BLEND_OP_OVER)
1155
        png_error(png_ptr, "invalid blend_op in fcTL");
1156
1157
    if (blend_op == PNG_BLEND_OP_OVER) {
1158
        if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY)
1159
            png_error(png_ptr, "PNG_BLEND_OP_OVER is not valid for "
1160
                               "color type 'greyscale without alpha'");
1161
        else if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) &&
1162
		 !(png_ptr->color_type & PNG_COLOR_MASK_ALPHA))
1163
            png_error(png_ptr, "PNG_BLEND_OP_OVER is not valid for "
1164
                               "color type 'truecolor without alpha'");
1165
    }
1166
}
1167
1168
png_uint_32 PNGAPI
1169
png_set_first_frame_is_hidden(png_structp png_ptr, png_infop info_ptr,
1170
                              png_byte is_hidden)
1171
{
1172
    png_debug(1, "in png_first_frame_is_hidden()\n");
1173
    
1174
    if (png_ptr == NULL)
1175
        return 0;
1176
    
1177
    if(is_hidden)
1178
        png_ptr->apng_flags |= PNG_FIRST_FRAME_HIDDEN;
1179
    else
1180
        png_ptr->apng_flags &= ~PNG_FIRST_FRAME_HIDDEN;
1181
    
1182
    return 1;
1183
}
1184
#endif /* PNG_APNG_SUPPORTED */
1185
1046
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
1186
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
1047
void PNGAPI
1187
void PNGAPI
1048
png_set_unknown_chunks(png_structp png_ptr,
1188
png_set_unknown_chunks(png_structp png_ptr,
(-)libpng-1.2.31/pngrutil.c.orig (-2 / +249 lines)
Lines 414-419 Link Here
414
   filter_type = buf[11];
414
   filter_type = buf[11];
415
   interlace_type = buf[12];
415
   interlace_type = buf[12];
416
416
417
#if defined(PNG_READ_APNG_SUPPORTED)
418
   png_ptr->first_frame_width = width;
419
   png_ptr->first_frame_height = height;
420
#endif
421
417
   /* set internal variables */
422
   /* set internal variables */
418
   png_ptr->width = width;
423
   png_ptr->width = width;
419
   png_ptr->height = height;
424
   png_ptr->height = height;
Lines 2220-2225 Link Here
2220
}
2225
}
2221
#endif
2226
#endif
2222
2227
2228
#if defined(PNG_READ_APNG_SUPPORTED)
2229
void /* PRIVATE */
2230
png_handle_acTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
2231
{
2232
    png_byte data[8];
2233
    png_uint_32 num_frames;
2234
    png_uint_32 num_plays;
2235
    png_uint_32 didSet;
2236
    
2237
    png_debug(1, "in png_handle_acTL\n");
2238
2239
    if (!(png_ptr->mode & PNG_HAVE_IHDR))
2240
    {
2241
        png_error(png_ptr, "Missing IHDR before acTL");
2242
    }
2243
    else if (png_ptr->mode & PNG_HAVE_IDAT)
2244
    {
2245
        png_warning(png_ptr, "Invalid acTL after IDAT skipped");
2246
        png_crc_finish(png_ptr, length);
2247
        return;
2248
    }
2249
    else if (png_ptr->mode & PNG_HAVE_acTL)
2250
    {
2251
        png_warning(png_ptr, "Duplicate acTL skipped");
2252
        png_crc_finish(png_ptr, length);
2253
        return;
2254
    }
2255
    else if (length != 8)
2256
    {
2257
        png_warning(png_ptr, "acTL with invalid length skipped");
2258
        png_crc_finish(png_ptr, length);
2259
        return;
2260
    }
2261
    
2262
    png_crc_read(png_ptr, data, 8);
2263
    png_crc_finish(png_ptr, 0);
2264
    
2265
    num_frames = png_get_uint_31(png_ptr, data);
2266
    num_plays = png_get_uint_31(png_ptr, data + 4);
2267
    
2268
    /* the set function will do error checking on num_frames */
2269
    didSet = png_set_acTL(png_ptr, info_ptr, num_frames, num_plays);
2270
    if(didSet)
2271
        png_ptr->mode |= PNG_HAVE_acTL;
2272
}
2273
2274
void /* PRIVATE */
2275
png_handle_fcTL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
2276
{
2277
    png_byte data[22];
2278
    png_uint_32 width;
2279
    png_uint_32 height;
2280
    png_uint_32 x_offset;
2281
    png_uint_32 y_offset;
2282
    png_uint_16 delay_num;
2283
    png_uint_16 delay_den;
2284
    png_byte dispose_op;
2285
    png_byte blend_op;
2286
    
2287
    png_debug(1, "in png_handle_fcTL\n");
2288
    
2289
    if (!(png_ptr->mode & PNG_HAVE_IHDR))
2290
    {
2291
        png_error(png_ptr, "Missing IHDR before fcTL");
2292
    }
2293
    else if (png_ptr->mode & PNG_HAVE_IDAT)
2294
    {
2295
        /* for any frames other then the first this message may be misleading,
2296
        * but correct. PNG_HAVE_IDAT is unset before the frame head is read
2297
        * i can't think of a better message */
2298
        png_warning(png_ptr, "Invalid fcTL after IDAT skipped");
2299
        png_crc_finish(png_ptr, length);
2300
        return;
2301
    }
2302
    else if (png_ptr->mode & PNG_HAVE_fcTL)
2303
    {
2304
        png_warning(png_ptr, "Duplicate fcTL within one frame skipped");
2305
        png_crc_finish(png_ptr, length);
2306
        return;
2307
    }
2308
    else if (length != 26)
2309
    {
2310
        png_warning(png_ptr, "fcTL with invalid length skipped");
2311
        png_crc_finish(png_ptr, length);
2312
        return;
2313
    }
2314
    
2315
    png_ensure_sequence_number(png_ptr, length);
2316
    
2317
    png_crc_read(png_ptr, data, 22);
2318
    png_crc_finish(png_ptr, 0);
2319
    
2320
    width = png_get_uint_31(png_ptr, data);
2321
    height = png_get_uint_31(png_ptr, data + 4);
2322
    x_offset = png_get_uint_31(png_ptr, data + 8);
2323
    y_offset = png_get_uint_31(png_ptr, data + 12);
2324
    delay_num = png_get_uint_16(data + 16);
2325
    delay_den = png_get_uint_16(data + 18);
2326
    dispose_op = data[20];
2327
    blend_op = data[21];
2328
    
2329
    if (png_ptr->num_frames_read == 0 && (x_offset != 0 || y_offset != 0))
2330
        png_error(png_ptr, "fcTL for the first frame must have zero offset");
2331
    if (png_ptr->num_frames_read == 0 && 
2332
        (width != info_ptr->width || height != info_ptr->height))
2333
        png_error(png_ptr, "size in first frame's fcTL must match "
2334
                           "the size in IHDR");
2335
    
2336
    /* the set function will do more error checking */
2337
    png_set_next_frame_fcTL(png_ptr, info_ptr, width, height, 
2338
                            x_offset, y_offset, delay_num, delay_den,
2339
                            dispose_op, blend_op);
2340
    
2341
    png_read_reinit(png_ptr, info_ptr);
2342
    
2343
    png_ptr->mode |= PNG_HAVE_fcTL;
2344
}
2345
2346
void /* PRIVATE */
2347
png_have_info(png_structp png_ptr, png_infop info_ptr)
2348
{
2349
    if((info_ptr->valid & PNG_INFO_acTL) && !(info_ptr->valid & PNG_INFO_fcTL))
2350
    {
2351
        png_ptr->apng_flags |= PNG_FIRST_FRAME_HIDDEN;
2352
        info_ptr->num_frames++;
2353
    }
2354
}
2355
2356
void /* PRIVATE */
2357
png_handle_fdAT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
2358
{
2359
    png_ensure_sequence_number(png_ptr, length);
2360
    
2361
    /* This function is only called from png_read_end(), png_read_info(), 
2362
    * and png_push_read_chunk() which means that:
2363
    * - the user doesn't want to read this frame
2364
    * - or this is an out-of-place fdAT
2365
    * in either case it is safe to ignore the chunk with a warning */
2366
    png_warning(png_ptr, "ignoring fdAT chunk");
2367
    png_crc_finish(png_ptr, length - 4);
2368
}
2369
2370
void /* PRIVATE */
2371
png_ensure_sequence_number(png_structp png_ptr, png_uint_32 length)
2372
{
2373
    png_byte data[4];
2374
    png_uint_32 sequence_number;
2375
    
2376
    if (length < 4)
2377
        png_error(png_ptr, "invalid fcTL or fdAT chunk found");
2378
    
2379
    png_crc_read(png_ptr, data, 4);
2380
    sequence_number = png_get_uint_31(png_ptr, data);
2381
    
2382
    if (sequence_number != png_ptr->next_seq_num)
2383
        png_error(png_ptr, "fcTL or fdAT chunk with out-of-order sequence "
2384
                           "number found");
2385
    
2386
    png_ptr->next_seq_num++;
2387
}
2388
#endif /* PNG_READ_APNG_SUPPORTED */
2389
2223
/* This function is called when we haven't found a handler for a
2390
/* This function is called when we haven't found a handler for a
2224
   chunk.  If there isn't a problem with the chunk itself (ie bad
2391
   chunk.  If there isn't a problem with the chunk itself (ie bad
2225
   chunk name, CRC, or a critical chunk), the chunk is silently ignored
2392
   chunk name, CRC, or a critical chunk), the chunk is silently ignored
Lines 3195-3202 Link Here
3195
   if (row_bytes + 64 > png_ptr->old_big_row_buf_size)
3362
   if (row_bytes + 64 > png_ptr->old_big_row_buf_size)
3196
   {
3363
   {
3197
     png_free(png_ptr, png_ptr->big_row_buf);
3364
     png_free(png_ptr, png_ptr->big_row_buf);
3198
     png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64);
3365
     if (png_ptr->big_row_buf == NULL)
3199
     png_ptr->row_buf = png_ptr->big_row_buf+32;
3366
        png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64);
3367
     if (png_ptr->row_buf == NULL)
3368
        png_ptr->row_buf = png_ptr->big_row_buf+32;
3200
     png_ptr->old_big_row_buf_size = row_bytes+64;
3369
     png_ptr->old_big_row_buf_size = row_bytes+64;
3201
   }
3370
   }
3202
3371
Lines 3226-3229 Link Here
3226
3395
3227
   png_ptr->flags |= PNG_FLAG_ROW_INIT;
3396
   png_ptr->flags |= PNG_FLAG_ROW_INIT;
3228
}
3397
}
3398
3399
#if defined(PNG_READ_APNG_SUPPORTED)
3400
/* This function is to be called after the main IDAT set has been read and
3401
 * before a new IDAT is read. It resets some parts of png_ptr
3402
 * to make them usable by the read functions again */
3403
void /* PRIVATE */
3404
png_read_reset(png_structp png_ptr)
3405
{
3406
    png_ptr->mode &= ~PNG_HAVE_IDAT;
3407
    png_ptr->mode &= ~PNG_AFTER_IDAT;
3408
    png_ptr->row_number = 0;
3409
    png_ptr->pass = 0;
3410
    png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
3411
}
3412
3413
void /* PRIVATE */
3414
png_read_reinit(png_structp png_ptr, png_infop info_ptr)
3415
{
3416
    png_ptr->width = info_ptr->next_frame_width;
3417
    png_ptr->height = info_ptr->next_frame_height;
3418
    png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->width);
3419
}
3420
3421
/* same as png_read_reset() but for the progressive reader */
3422
void /* PRIVATE */
3423
png_progressive_read_reset(png_structp png_ptr)
3424
{
3425
#ifdef PNG_USE_LOCAL_ARRAYS
3426
    /* start of interlace block */
3427
    const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
3428
3429
    /* offset to next interlace block */
3430
    const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
3431
3432
    /* start of interlace block in the y direction */
3433
    const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
3434
3435
    /* offset to next interlace block in the y direction */
3436
    const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
3437
#endif
3438
    png_uint_32 row_bytes;
3439
    
3440
    if (png_ptr->interlaced)
3441
    {
3442
        if (!(png_ptr->transformations & PNG_INTERLACE))
3443
            png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 -
3444
                                png_pass_ystart[0]) / png_pass_yinc[0];
3445
        else
3446
           png_ptr->num_rows = png_ptr->height;
3447
3448
        png_ptr->iwidth = (png_ptr->width +
3449
                           png_pass_inc[png_ptr->pass] - 1 -
3450
                           png_pass_start[png_ptr->pass]) /
3451
                           png_pass_inc[png_ptr->pass];
3452
3453
        row_bytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->iwidth) + 1;
3454
3455
        png_ptr->irowbytes = (png_size_t)row_bytes;
3456
        if((png_uint_32)png_ptr->irowbytes != row_bytes)
3457
            png_error(png_ptr, "png_progressive_read_reset(): Rowbytes "
3458
                               "overflow");
3459
    }
3460
    else
3461
    {
3462
        png_ptr->num_rows = png_ptr->height;
3463
        png_ptr->iwidth = png_ptr->width;
3464
        png_ptr->irowbytes = png_ptr->rowbytes + 1;
3465
    }
3466
    
3467
    png_ptr->flags &= ~PNG_FLAG_ZLIB_FINISHED;
3468
    if (inflateReset(&(png_ptr->zstream)) != Z_OK)
3469
        png_error(png_ptr, "inflateReset failed");
3470
    png_ptr->zstream.avail_in = 0;
3471
    png_ptr->zstream.next_in = 0;
3472
    png_ptr->zstream.next_out = png_ptr->row_buf;
3473
    png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes;
3474
}
3475
#endif /* PNG_READ_APNG_SUPPORTED */
3229
#endif /* PNG_READ_SUPPORTED */
3476
#endif /* PNG_READ_SUPPORTED */
(-)libpng-1.2.31/pngwutil.c.orig (-1 / +129 lines)
Lines 506-511 Link Here
506
   /* write the chunk */
506
   /* write the chunk */
507
   png_write_chunk(png_ptr, (png_bytep)png_IHDR, buf, (png_size_t)13);
507
   png_write_chunk(png_ptr, (png_bytep)png_IHDR, buf, (png_size_t)13);
508
508
509
#if defined(PNG_WRITE_APNG_SUPPORTED)
510
   png_ptr->first_frame_width = width;
511
   png_ptr->first_frame_height = height;
512
#endif
513
509
   /* initialize zlib with PNG info */
514
   /* initialize zlib with PNG info */
510
   png_ptr->zstream.zalloc = png_zalloc;
515
   png_ptr->zstream.zalloc = png_zalloc;
511
   png_ptr->zstream.zfree = png_zfree;
516
   png_ptr->zstream.zfree = png_zfree;
Lines 628-633 Link Here
628
{
633
{
629
#ifdef PNG_USE_LOCAL_ARRAYS
634
#ifdef PNG_USE_LOCAL_ARRAYS
630
   PNG_IDAT;
635
   PNG_IDAT;
636
#if defined(PNG_WRITE_APNG_SUPPORTED)
637
   PNG_fdAT;
638
#endif
631
#endif
639
#endif
632
   png_debug(1, "in png_write_IDAT\n");
640
   png_debug(1, "in png_write_IDAT\n");
633
641
Lines 670-676 Link Here
670
            "Invalid zlib compression method or flags in IDAT");
678
            "Invalid zlib compression method or flags in IDAT");
671
   }
679
   }
672
680
673
   png_write_chunk(png_ptr, (png_bytep)png_IDAT, data, length);
681
#if defined(PNG_WRITE_APNG_SUPPORTED)
682
   if(png_ptr->num_frames_written == 0)
683
#endif
684
      png_write_chunk(png_ptr, (png_bytep)png_IDAT, data, length);
685
#if defined(PNG_WRITE_APNG_SUPPORTED)
686
   else
687
   {
688
      png_byte buf[4];
689
      
690
      png_write_chunk_start(png_ptr, (png_bytep)png_fdAT, 4 + length);
691
      
692
      png_save_uint_32(buf, png_ptr->next_seq_num);
693
      png_write_chunk_data(png_ptr, buf, 4);
694
      
695
      png_write_chunk_data(png_ptr, data, length);
696
      
697
      png_write_chunk_end(png_ptr);
698
      
699
      png_ptr->next_seq_num++;
700
   }
701
#endif
702
674
   png_ptr->mode |= PNG_HAVE_IDAT;
703
   png_ptr->mode |= PNG_HAVE_IDAT;
675
}
704
}
676
705
Lines 1755-1760 Link Here
1755
}
1784
}
1756
#endif
1785
#endif
1757
1786
1787
#if defined(PNG_WRITE_APNG_SUPPORTED)
1788
void /* PRIVATE */
1789
png_write_acTL(png_structp png_ptr,
1790
   png_uint_32 num_frames, png_uint_32 num_plays)
1791
{
1792
#ifdef PNG_USE_LOCAL_ARRAYS
1793
    PNG_acTL;
1794
#endif
1795
    png_byte data[16];
1796
    
1797
    png_debug(1, "in png_write_acTL\n");
1798
    
1799
    png_ptr->num_frames_to_write = num_frames;
1800
    
1801
    if (png_ptr->apng_flags & PNG_FIRST_FRAME_HIDDEN)
1802
        num_frames--;
1803
    
1804
    png_save_uint_32(data, num_frames);
1805
    png_save_uint_32(data + 4, num_plays);
1806
    
1807
    png_write_chunk(png_ptr, (png_bytep)png_acTL, data, (png_size_t)8);
1808
}
1809
1810
void /* PRIVATE */
1811
png_write_fcTL(png_structp png_ptr, png_uint_32 width, png_uint_32 height, 
1812
    png_uint_32 x_offset, png_uint_32 y_offset,
1813
    png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op, 
1814
    png_byte blend_op)
1815
{
1816
#ifdef PNG_USE_LOCAL_ARRAYS
1817
    PNG_fcTL;
1818
#endif
1819
    png_byte data[26];
1820
    
1821
    png_debug(1, "in png_write_fcTL\n");
1822
    
1823
    if (png_ptr->num_frames_written == 0 && (x_offset != 0 || y_offset != 0))
1824
        png_error(png_ptr, "x and/or y offset for the first frame aren't 0\n");
1825
    if (png_ptr->num_frames_written == 0 && 
1826
        (width != png_ptr->first_frame_width || 
1827
         height != png_ptr->first_frame_height))
1828
        png_error(png_ptr, "width and/or height in the first frame's fcTL "
1829
                           "don't match the ones in IHDR\n");
1830
    
1831
    /* more error checking */
1832
    png_ensure_fcTL_is_valid(png_ptr, width, height, x_offset, y_offset, 
1833
                             delay_num, delay_den, dispose_op, blend_op);
1834
    
1835
    png_save_uint_32(data, png_ptr->next_seq_num);
1836
    png_save_uint_32(data + 4, width);
1837
    png_save_uint_32(data + 8, height);
1838
    png_save_uint_32(data + 12, x_offset);
1839
    png_save_uint_32(data + 16, y_offset);
1840
    png_save_uint_16(data + 20, delay_num);
1841
    png_save_uint_16(data + 22, delay_den);
1842
    data[24] = dispose_op;
1843
    data[25] = blend_op;
1844
    
1845
    png_write_chunk(png_ptr, (png_bytep)png_fcTL, data, (png_size_t)26);
1846
    
1847
    png_ptr->next_seq_num++;
1848
}
1849
#endif /* PNG_WRITE_APNG_SUPPORTED */
1850
1758
/* initializes the row writing capability of libpng */
1851
/* initializes the row writing capability of libpng */
1759
void /* PRIVATE */
1852
void /* PRIVATE */
1760
png_write_start_row(png_structp png_ptr)
1853
png_write_start_row(png_structp png_ptr)
Lines 2824-2827 Link Here
2824
   }
2917
   }
2825
#endif
2918
#endif
2826
}
2919
}
2920
2921
#if defined(PNG_WRITE_APNG_SUPPORTED)
2922
void /* PRIVATE */
2923
png_write_reset(png_structp png_ptr)
2924
{
2925
    png_ptr->row_number = 0;
2926
    png_ptr->pass = 0;
2927
    png_ptr->mode &= ~PNG_HAVE_IDAT;
2928
}
2929
2930
void /* PRIVATE */
2931
png_write_reinit(png_structp png_ptr, png_infop info_ptr, 
2932
                 png_uint_32 width, png_uint_32 height)
2933
{
2934
    if (png_ptr->num_frames_written == 0 && 
2935
        (width != png_ptr->first_frame_width || 
2936
         height != png_ptr->first_frame_height))
2937
        png_error(png_ptr, "width and/or height in the first frame's fcTL "
2938
                           "don't match the ones in IHDR\n");
2939
    if (width > png_ptr->first_frame_width || 
2940
        height > png_ptr->first_frame_height)
2941
        png_error(png_ptr, "width and/or height for a frame greater than"
2942
                           "the ones in IHDR");
2943
    
2944
    png_set_IHDR(png_ptr, info_ptr, width, height, 
2945
                 info_ptr->bit_depth, info_ptr->color_type, 
2946
                 info_ptr->interlace_type, info_ptr->compression_type,
2947
                 info_ptr->filter_type);
2948
   
2949
    png_ptr->width = width;
2950
    png_ptr->height = height;
2951
    png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width);
2952
    png_ptr->usr_width = png_ptr->width;
2953
}
2954
#endif
2827
#endif /* PNG_WRITE_SUPPORTED */
2955
#endif /* PNG_WRITE_SUPPORTED */
(-)libpng-1.2.31/pngrtran.c.orig (-1 / +1 lines)
Lines 1288-1294 Link Here
1288
       * or png_read_update_info() after setting transforms that expand
1288
       * or png_read_update_info() after setting transforms that expand
1289
       * pixels.  This check added to libpng-1.2.19 */
1289
       * pixels.  This check added to libpng-1.2.19 */
1290
#if (PNG_WARN_UNINITIALIZED_ROW==1)
1290
#if (PNG_WARN_UNINITIALIZED_ROW==1)
1291
      png_error(png_ptr, "Uninitialized row");
1291
      png_warning(png_ptr, "Uninitialized row");
1292
#else
1292
#else
1293
      png_warning(png_ptr, "Uninitialized row");
1293
      png_warning(png_ptr, "Uninitialized row");
1294
#endif
1294
#endif

Return to bug 18152